Query costs for 0 duration prepaid calls in CDRS, fixes #290

This commit is contained in:
DanB
2015-11-18 09:24:23 +01:00
parent 578954eec5
commit 2ee6802d4c
2 changed files with 7 additions and 11 deletions

View File

@@ -316,9 +316,6 @@ func (self *CdrServer) deriveCdrs(storedCdr *StoredCdr) ([]*StoredCdr, error) {
// Retrive the cost from engine
func (self *CdrServer) getCostFromRater(storedCdr *StoredCdr) (*CallCost, error) {
//if storedCdr.Usage == time.Duration(0) { // failed call, nil cost
// return nil, nil // No costs present, better than empty call cost since could lead us to 0 costs
//}
cc := new(CallCost)
var err error
cd := &CallDescriptor{
@@ -349,7 +346,7 @@ func (self *CdrServer) getCostFromRater(storedCdr *StoredCdr) (*CallCost, error)
func (self *CdrServer) rateCDR(storedCdr *StoredCdr) error {
var qryCC *CallCost
var err error
if utils.IsSliceMember([]string{utils.META_PREPAID, utils.PREPAID}, storedCdr.ReqType) { // ToDo: Get rid of PREPAID as soon as we don't want to support it backwards
if utils.IsSliceMember([]string{utils.META_PREPAID, utils.PREPAID}, storedCdr.ReqType) && storedCdr.Usage != 0 { // ToDo: Get rid of PREPAID as soon as we don't want to support it backwards
// Should be previously calculated and stored in DB
delay := utils.Fib()
for i := 0; i < 4; i++ {

View File

@@ -204,9 +204,6 @@ func (sm *FSSessionManager) onChannelHangupComplete(ev engine.Event) {
if ev.GetReqType(utils.META_DEFAULT) == utils.META_NONE { // Do not process this request
return
}
if sm.cfg.CreateCdr {
go sm.ProcessCdr(ev.AsStoredCdr(config.CgrConfig().DefaultTimezone))
}
var s *Session
for i := 0; i < 2; i++ { // Protect us against concurrency, wait a couple of seconds for the answer to be populated before we process hangup
s = sm.sessions.getSession(ev.GetUUID())
@@ -215,11 +212,13 @@ func (sm *FSSessionManager) onChannelHangupComplete(ev engine.Event) {
}
time.Sleep(time.Duration(i+1) * time.Second)
}
if s == nil { // Not handled by us
return
if s != nil { // Handled by us, cleanup here
if err := sm.sessions.removeSession(s, ev); err != nil {
utils.Logger.Err(err.Error())
}
}
if err := sm.sessions.removeSession(s, ev); err != nil {
utils.Logger.Err(err.Error())
if sm.cfg.CreateCdr {
sm.ProcessCdr(ev.AsStoredCdr(config.CgrConfig().DefaultTimezone))
}
}