diff --git a/engine/callcost.go b/engine/callcost.go index 19a02bd3b..acfa8c525 100644 --- a/engine/callcost.go +++ b/engine/callcost.go @@ -20,7 +20,6 @@ package engine import ( "encoding/json" "errors" - "reflect" "time" "github.com/cgrates/cgrates/utils" @@ -40,18 +39,8 @@ func (cc *CallCost) Merge(other *CallCost) { if len(cc.Timespans)-1 < 0 || len(other.Timespans) == 0 { return } - ts := cc.Timespans[len(cc.Timespans)-1] - otherTs := other.Timespans[0] - if reflect.DeepEqual(ts.ratingInfo, otherTs.ratingInfo) && - reflect.DeepEqual(ts.RateInterval, otherTs.RateInterval) { - // extend the last timespan with - ts.TimeEnd = ts.TimeEnd.Add(otherTs.GetDuration()) - // add the rest of the timspans - cc.Timespans = append(cc.Timespans, other.Timespans[1:]...) - } else { - // just add all timespans - cc.Timespans = append(cc.Timespans, other.Timespans...) - } + // just add all timespans + cc.Timespans = append(cc.Timespans, other.Timespans...) cc.Cost += other.Cost } diff --git a/engine/callcost_test.go b/engine/callcost_test.go index 5349b104b..6b3d6701f 100644 --- a/engine/callcost_test.go +++ b/engine/callcost_test.go @@ -121,8 +121,8 @@ func TestMultipleInputRightMerge(t *testing.T) { t.Errorf("expected 91 was %v", cc2.Cost) } cc1.Merge(cc2) - if len(cc1.Timespans) != 2 || cc1.Timespans[0].GetDuration().Seconds() != 120 { - t.Error("wrong resulted timespan: ", len(cc1.Timespans)) + if len(cc1.Timespans) != 3 || cc1.Timespans[0].GetDuration().Seconds() != 60 { + t.Error("wrong resulted timespan: ", len(cc1.Timespans), cc1.Timespans[0].GetDuration().Seconds()) } if cc1.Cost != 152 { t.Errorf("Exdpected 152 was %v", cc1.Cost)