mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-23 08:08:45 +05:00
EventCharges - include syncIDs inside Merge
This commit is contained in:
@@ -19,7 +19,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
package utils
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"strings"
|
||||
@@ -378,13 +377,10 @@ func TestAppend2(t *testing.T) {
|
||||
dn.Type = NMMapType
|
||||
dn.Slice = nil
|
||||
dn.Map = map[string]*DataNode{}
|
||||
dnExpect := NewDataNode(testPath)
|
||||
|
||||
if _, err := dn.Append(testPath, val1); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
fmt.Println(ToJSON(dn.Map["0"]))
|
||||
fmt.Println(ToJSON(dnExpect))
|
||||
|
||||
///
|
||||
dn.Type = NMSliceType
|
||||
|
||||
@@ -47,6 +47,7 @@ type EventCharges struct {
|
||||
|
||||
// Merge will merge the event charges into existing
|
||||
func (ec *EventCharges) Merge(eCs ...*EventCharges) {
|
||||
ec.syncIDs(eCs...) // so we can compare properly
|
||||
for _, nEc := range eCs {
|
||||
if ec.Abstracts != nil {
|
||||
ec.Abstracts = &Decimal{SumBig(ec.Abstracts.Big, nEc.Abstracts.Big)}
|
||||
@@ -63,7 +64,7 @@ func (ec *EventCharges) Merge(eCs ...*EventCharges) {
|
||||
}
|
||||
|
||||
// SyncIDs will repopulate Accounting, UnitFactors and Rating IDs if they equal the references in ec
|
||||
func (ec *EventCharges) SyncIDs(eCs ...*EventCharges) {
|
||||
func (ec *EventCharges) syncIDs(eCs ...*EventCharges) {
|
||||
for _, nEc := range eCs {
|
||||
for _, cIl := range nEc.ChargingIntervals {
|
||||
for _, cIcrm := range cIl.Increments {
|
||||
@@ -120,7 +121,6 @@ func (ec *EventCharges) AppendChargingIntervals(cIls ...*ChargingInterval) {
|
||||
ec.ChargingIntervals = []*ChargingInterval{cIl}
|
||||
continue
|
||||
}
|
||||
|
||||
if ec.ChargingIntervals[len(ec.ChargingIntervals)-1].CompressEquals(cIl) {
|
||||
ec.ChargingIntervals[len(ec.ChargingIntervals)-1].CompressFactor += 1
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user