mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
integration tests fixes
This commit is contained in:
@@ -623,7 +623,7 @@ func TestDmtAgentCdrs(t *testing.T) {
|
||||
if cdrs[0].Usage != "610" {
|
||||
t.Errorf("Unexpected CDR Usage received, cdr: %+v ", cdrs[0])
|
||||
}
|
||||
if cdrs[0].Cost != 0.795 {
|
||||
if cdrs[0].Cost != 0.7565 {
|
||||
t.Errorf("Unexpected CDR Cost received, cdr: %+v ", cdrs[0])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@ func TestSMGV1GetMaxUsage(t *testing.T) {
|
||||
var maxTime float64
|
||||
if err := smgV1Rpc.Call("SMGenericV1.GetMaxUsage", setupReq, &maxTime); err != nil {
|
||||
t.Error(err)
|
||||
} else if maxTime != 2690 {
|
||||
} else if maxTime != 2700 {
|
||||
t.Errorf("Calling ApierV2.MaxUsage got maxTime: %f", maxTime)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -201,20 +201,23 @@ func (cc *CallCost) Round() {
|
||||
ts.RateInterval.Rating.RoundingMethod)
|
||||
correctionCost := roundedCost - cost
|
||||
//log.Print(cost, roundedCost, correctionCost)
|
||||
roundInc := &Increment{
|
||||
Cost: correctionCost,
|
||||
BalanceInfo: inc.BalanceInfo,
|
||||
if correctionCost != 0 {
|
||||
ts.RoundIncrement = &Increment{
|
||||
Cost: correctionCost,
|
||||
BalanceInfo: inc.BalanceInfo,
|
||||
}
|
||||
totalCorrectionCost += correctionCost
|
||||
ts.Cost += correctionCost
|
||||
}
|
||||
totalCorrectionCost += correctionCost
|
||||
ts.Cost += correctionCost
|
||||
ts.RoundIncrements = append(ts.RoundIncrements, roundInc)
|
||||
}
|
||||
cc.Cost += totalCorrectionCost
|
||||
}
|
||||
|
||||
func (cc *CallCost) GetRoundIncrements() (roundIncrements Increments) {
|
||||
for _, ts := range cc.Timespans {
|
||||
roundIncrements = append(roundIncrements, ts.RoundIncrements...)
|
||||
if ts.RoundIncrement != nil && ts.RoundIncrement.Cost != 0 {
|
||||
roundIncrements = append(roundIncrements, ts.RoundIncrement)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@@ -682,9 +682,12 @@ func (cd *CallDescriptor) debit(account *Account, dryRun bool, goNegative bool)
|
||||
}
|
||||
if cd.PerformRounding {
|
||||
cc.Round()
|
||||
rcd := cc.CreateCallDescriptor()
|
||||
rcd.Increments = cc.GetRoundIncrements()
|
||||
rcd.RefundRounding()
|
||||
roundIncrements := cc.GetRoundIncrements()
|
||||
if len(roundIncrements) != 0 {
|
||||
rcd := cc.CreateCallDescriptor()
|
||||
rcd.Increments = roundIncrements
|
||||
rcd.RefundRounding()
|
||||
}
|
||||
}
|
||||
//log.Printf("OUT CC: ", cc)
|
||||
return
|
||||
|
||||
@@ -36,7 +36,7 @@ type TimeSpan struct {
|
||||
RateInterval *RateInterval
|
||||
DurationIndex time.Duration // the call duration so far till TimeEnd
|
||||
Increments Increments
|
||||
RoundIncrements Increments
|
||||
RoundIncrement *Increment
|
||||
MatchedSubject, MatchedPrefix, MatchedDestId, RatingPlanId string
|
||||
CompressFactor int
|
||||
ratingInfo *RatingInfo
|
||||
|
||||
@@ -230,11 +230,14 @@ func (s *Session) SaveOperations() {
|
||||
firstCC.Timespans.Compress()
|
||||
|
||||
firstCC.Round()
|
||||
cd := firstCC.CreateCallDescriptor()
|
||||
cd.Increments = firstCC.GetRoundIncrements()
|
||||
var response float64
|
||||
if err := s.sessionManager.Rater().RefundRounding(cd, &response); err != nil {
|
||||
utils.Logger.Err(fmt.Sprintf("<SM> ERROR failed to refund rounding: %v", err))
|
||||
roundIncrements := firstCC.GetRoundIncrements()
|
||||
if len(roundIncrements) != 0 {
|
||||
cd := firstCC.CreateCallDescriptor()
|
||||
cd.Increments = roundIncrements
|
||||
var response float64
|
||||
if err := s.sessionManager.Rater().RefundRounding(cd, &response); err != nil {
|
||||
utils.Logger.Err(fmt.Sprintf("<SM> ERROR failed to refund rounding: %v", err))
|
||||
}
|
||||
}
|
||||
var reply string
|
||||
err := s.sessionManager.CdrSrv().LogCallCost(&engine.CallCostLog{
|
||||
|
||||
@@ -205,11 +205,14 @@ func (self *SMGSession) saveOperations() error {
|
||||
}
|
||||
firstCC.Timespans.Compress()
|
||||
firstCC.Round()
|
||||
cd := firstCC.CreateCallDescriptor()
|
||||
cd.Increments = firstCC.GetRoundIncrements()
|
||||
var response float64
|
||||
if err := self.rater.RefundRounding(cd, &response); err != nil {
|
||||
return err
|
||||
roundIncrements := firstCC.GetRoundIncrements()
|
||||
if len(roundIncrements) != 0 {
|
||||
cd := firstCC.CreateCallDescriptor()
|
||||
cd.Increments = roundIncrements
|
||||
var response float64
|
||||
if err := self.rater.RefundRounding(cd, &response); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
var reply string
|
||||
|
||||
@@ -278,11 +278,14 @@ func (self *SMGeneric) ChargeEvent(gev SMGenericEvent, clnt *rpc2.Client) (maxDu
|
||||
}
|
||||
}
|
||||
cc.Round()
|
||||
cd := cc.CreateCallDescriptor()
|
||||
cd.Increments = cc.GetRoundIncrements()
|
||||
var response float64
|
||||
if err := self.rater.RefundRounding(cd, &response); err != nil {
|
||||
utils.Logger.Err(fmt.Sprintf("<SM> ERROR failed to refund rounding: %v", err))
|
||||
roundIncrements := cc.GetRoundIncrements()
|
||||
if len(roundIncrements) != 0 {
|
||||
cd := cc.CreateCallDescriptor()
|
||||
cd.Increments = roundIncrements
|
||||
var response float64
|
||||
if err := self.rater.RefundRounding(cd, &response); err != nil {
|
||||
utils.Logger.Err(fmt.Sprintf("<SM> ERROR failed to refund rounding: %v", err))
|
||||
}
|
||||
}
|
||||
|
||||
var reply string
|
||||
|
||||
Reference in New Issue
Block a user