diff --git a/engine/eventcost.go b/engine/eventcost.go index c334cd04d..7e3cd88d8 100644 --- a/engine/eventcost.go +++ b/engine/eventcost.go @@ -394,8 +394,9 @@ func (ec *EventCost) AsCallCost(tor string) *CallCost { incrs := cIl.Increments if l := len(cIl.Increments); l != 0 { - if ec.Accounting[cIl.Increments[l-1].AccountingID].RatingID == utils.MetaRounding { - // special case: if the last increment is has the ratingID equal to *roundig + if cIl.Increments[l-1].Cost != 0 && + ec.Accounting[cIl.Increments[l-1].AccountingID].RatingID == utils.MetaRounding { + // special case: if the last increment has the ratingID equal to *roundig // we consider it as the roundIncrement l-- incrs = incrs[:l] diff --git a/engine/eventcost_test.go b/engine/eventcost_test.go index 3760edcfc..cc243146a 100644 --- a/engine/eventcost_test.go +++ b/engine/eventcost_test.go @@ -1259,6 +1259,59 @@ func TestECAsCallCost(t *testing.T) { } } +func TestECAsCallCost2(t *testing.T) { + eCC := &CallCost{ + ToR: utils.VOICE, + Cost: 0, + RatedUsage: 60000000000, + Timespans: TimeSpans{ + &TimeSpan{ + TimeStart: time.Date(2017, 1, 9, 16, 18, 21, 0, time.UTC), + TimeEnd: time.Date(2017, 1, 9, 16, 19, 21, 0, time.UTC), + Cost: 0, + RateInterval: &RateInterval{ // standard rating + Timing: &RITiming{ + StartTime: "00:00:00", + }, + Rating: &RIRate{ + ConnectFee: 0.1, + RoundingMethod: "*up", + RoundingDecimals: 5, + Rates: RateGroups{ + &Rate{ + GroupIntervalStart: time.Duration(0), + Value: 0.01, + RateUnit: time.Duration(1 * time.Second), + RateIncrement: time.Duration(1 * time.Minute), + }, + }, + }, + }, + DurationIndex: time.Minute, + MatchedSubject: "*out:cgrates.org:call:*any", + MatchedPrefix: "+49", + MatchedDestId: "GERMANY", + RatingPlanId: "RPL_RETAIL1", + CompressFactor: 1, + Increments: Increments{ + &Increment{ // ConnectFee + Cost: 0, + Duration: time.Minute, + BalanceInfo: &DebitInfo{}, + CompressFactor: 1, + }, + }, + }, + }, + } + ec := NewEventCostFromCallCost(eCC, "cgrID", utils.MetaDefault) + + cc := ec.AsCallCost(utils.EmptyString) + if !reflect.DeepEqual(eCC, cc) { + t.Errorf("Expecting: %+v, received: %+v", utils.ToJSON(eCC), utils.ToJSON(cc)) + } +} + func TestECTrimZeroAndFull(t *testing.T) { ec := testEC.Clone() if srplsEC, err := ec.Trim(time.Duration(10 * time.Minute)); err != nil { diff --git a/packages/debian/changelog b/packages/debian/changelog index 4546a1550..1160ab8a3 100644 --- a/packages/debian/changelog +++ b/packages/debian/changelog @@ -6,6 +6,7 @@ cgrates (0.10.3~dev) UNRELEASED; urgency=medium AccountIDs and RatingPlanIDs to calculate * [SessionS] Compile the SRun.EventCost before store it and send it further * [ApierS] Correct handle error in case of APIerSv1.GetActionTriggers + * [SessionS] Added extra condition to determine if the increment is considered the roundIncrement -- DanB Thu, 08 Oct 2020 16:23:58 +0300 diff --git a/sessions/sessions.go b/sessions/sessions.go index 4e8c836a0..44acf47cb 100644 --- a/sessions/sessions.go +++ b/sessions/sessions.go @@ -558,7 +558,6 @@ func (sS *SessionS) refundSession(s *Session, sRunIdx int, rUsage time.Duration) } else if srplsEC == nil { return } - utils.Logger.Debug(fmt.Sprintf("Preparing for session refund, EC: %s", utils.ToJSON(srplsEC))) sCC := srplsEC.AsCallCost(sr.CD.ToR) var incrmts engine.Increments for _, tmspn := range sCC.Timespans {