mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-25 00:58:45 +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
129b3905fd
commit
4c8f5a2205
@@ -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]
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 <danb@cgrates.org> Thu, 08 Oct 2020 16:23:58 +0300
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user