This commit is contained in:
DanB
2016-01-20 18:01:01 +01:00
2 changed files with 9 additions and 0 deletions

View File

@@ -63,6 +63,9 @@ func (cc *CallCost) GetDuration() (td time.Duration) {
}
func (cc *CallCost) UpdateRatedUsage() time.Duration {
if cc == nil {
return 0
}
totalDuration := cc.GetDuration()
cc.RatedUsage = totalDuration.Seconds()
return totalDuration

View File

@@ -175,6 +175,9 @@ func (self *CdrServer) processCdr(cdr *CDR) (err error) {
cdr.RunID = utils.MetaRaw
}
if self.cgrCfg.CDRSStoreCdrs { // Store RawCDRs, this we do sync so we can reply with the status
if cdr.CostDetails != nil {
cdr.CostDetails.UpdateRatedUsage()
}
if err := self.cdrDb.SetCDR(cdr, false); err != nil { // Only original CDR stored in primary table, no derived
utils.Logger.Err(fmt.Sprintf("<CDRS> Storing primary CDR %+v, got error: %s", cdr, err.Error()))
return err // Error is propagated back and we don't continue processing the CDR if we cannot store it
@@ -231,6 +234,9 @@ func (self *CdrServer) rateStoreStatsReplicate(cdr *CDR, sendToStats bool) error
}
if self.cgrCfg.CDRSStoreCdrs { // Store CDRs
// Store RatedCDR
if cdr.CostDetails != nil {
cdr.CostDetails.UpdateRatedUsage()
}
if err := self.cdrDb.SetCDR(cdr, true); err != nil {
utils.Logger.Err(fmt.Sprintf("<CDRS> Storing rated CDR %+v, got error: %s", cdr, err.Error()))
}