diff --git a/engine/eventcost.go b/engine/eventcost.go index 223328c36..daef4c965 100644 --- a/engine/eventcost.go +++ b/engine/eventcost.go @@ -395,8 +395,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 63f39e62c..82689559d 100644 --- a/engine/eventcost_test.go +++ b/engine/eventcost_test.go @@ -1262,6 +1262,61 @@ func TestECAsCallCost(t *testing.T) { } } +func TestECAsCallCost2(t *testing.T) { + eCC := &CallCost{ + ToR: utils.MetaVoice, + 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{ + &RGRate{ + 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) + for k := range ec.Timings { + eCC.Timespans[0].RateInterval.Timing.ID = k + } + 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(10 * time.Minute); err != nil { diff --git a/packages/debian/changelog b/packages/debian/changelog index 1d0e29cbe..9a4042020 100644 --- a/packages/debian/changelog +++ b/packages/debian/changelog @@ -137,6 +137,7 @@ cgrates (0.11.0~dev) UNRELEASED; urgency=medium * [ServiceS] Added service dependency map to control the shutdown order * [EEs] Add support for *sql exporter * [ApierS] Correct handle error in case of APIerSv1.GetActionTriggers + * [SessionS] Added extra condition to determine if the increment is considered the roundIncrement -- DanB Wed, 19 Feb 2020 13:25:52 +0200