Add protection for cdr Usage smaller than 0

This commit is contained in:
TeoV
2018-11-18 05:04:25 -05:00
committed by Dan Christian Bogos
parent 01955bb612
commit 8c8f1370e8

View File

@@ -217,6 +217,9 @@ func (self *CdrServer) processCdr(cdr *CDR) (err error) {
if len(self.cgrCfg.CdrsCfg().CDRSOnlineCDRExports) != 0 { // Replicate raw CDR
self.replicateCDRs([]*CDR{cdr})
}
if cdr.Usage < time.Duration(0) {
cdr.Usage = time.Duration(0)
}
if self.rals != nil && !cdr.PreRated { // CDRs not rated will be processed by Rating
go self.deriveRateStoreStatsReplicate(cdr, self.cgrCfg.CdrsCfg().CDRSStoreCdrs,
true, len(self.cgrCfg.CdrsCfg().CDRSOnlineCDRExports) != 0)
@@ -405,6 +408,9 @@ func (self *CdrServer) rateCDR(cdr *CDR) ([]*CDR, error) {
if cdr.RequestType == utils.META_NONE {
return nil, nil
}
if cdr.Usage < 0 {
cdr.Usage = time.Duration(0)
}
cdr.ExtraInfo = "" // Clean previous ExtraInfo, useful when re-rating
var cdrsRated []*CDR
_, hasLastUsed := cdr.ExtraFields[utils.LastUsed]