EventCost compressing correcting RatingID within Accounting

This commit is contained in:
DanB
2019-03-13 19:49:09 +01:00
parent f1a6a5b21a
commit 351d0fb39e
2 changed files with 6 additions and 0 deletions

View File

@@ -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)

View File

@@ -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",