mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-17 14:19:54 +05:00
Added extra condition to determine if the increment is considered the roundIncrement
This commit is contained in:
committed by
Dan Christian Bogos
parent
d2fdb60482
commit
34206fa765
@@ -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]
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user