Added extra condition to determine if the increment is considered the roundIncrement

This commit is contained in:
Trial97
2021-01-13 16:57:30 +02:00
committed by Dan Christian Bogos
parent d2fdb60482
commit 34206fa765
3 changed files with 59 additions and 2 deletions

View File

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

View File

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

View File

@@ -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 <danb@cgrates.org> Wed, 19 Feb 2020 13:25:52 +0200