From 351d0fb39ee6c78af0974b8e7872ce633a28f05e Mon Sep 17 00:00:00 2001 From: DanB Date: Wed, 13 Mar 2019 19:49:09 +0100 Subject: [PATCH] EventCost compressing correcting RatingID within Accounting --- engine/eventcost.go | 3 +++ engine/eventcost_test.go | 3 +++ 2 files changed, 6 insertions(+) diff --git a/engine/eventcost.go b/engine/eventcost.go index 280432952..ba220e8e0 100644 --- a/engine/eventcost.go +++ b/engine/eventcost.go @@ -459,6 +459,9 @@ func (ec *EventCost) SyncKeys(refEC *EventCost) { // sync Accounting sncedAcntIDs := make(map[string]string) for key, acnt := range ec.Accounting { + if rtRefKey, has := sncedRatingIDs[acnt.RatingID]; has { + acnt.RatingID = rtRefKey + } for refKey, refAcnt := range refEC.Accounting { if acnt.Equals(refAcnt) { delete(ec.Accounting, key) diff --git a/engine/eventcost_test.go b/engine/eventcost_test.go index c4a8c073f..eb8480d1c 100644 --- a/engine/eventcost_test.go +++ b/engine/eventcost_test.go @@ -2033,6 +2033,7 @@ func TestECAppendCIlFromEC(t *testing.T) { func TestECSyncKeys(t *testing.T) { ec := testEC.Clone() + ec.Accounting["a012888"].RatingID = "c1a5ab9" refEC := &EventCost{ Rating: Rating{ @@ -2050,6 +2051,7 @@ func TestECSyncKeys(t *testing.T) { AccountID: "cgrates.org:dan", BalanceUUID: "8c54a9e9-d610-4c82-bcb5-a315b9a65010", Units: 0.01, + RatingID: "21a5ab9", }, "288bfa6": &BalanceCharge{ AccountID: "cgrates.org:dan", @@ -2204,6 +2206,7 @@ func TestECSyncKeys(t *testing.T) { AccountID: "cgrates.org:dan", BalanceUUID: "8c54a9e9-d610-4c82-bcb5-a315b9a65010", Units: 0.01, + RatingID: "21a5ab9", }, "288bfa6": &BalanceCharge{ AccountID: "cgrates.org:dan",