SMG SessionTimers considering LastUsed, generating also CDR

This commit is contained in:
DanB
2016-04-11 20:31:01 +02:00
parent 5a102384e3
commit d40a9193e6
2 changed files with 7 additions and 2 deletions

View File

@@ -426,7 +426,7 @@ func TestSMGDataTTLExpired(t *testing.T) {
t.Errorf("Expected: %f, received: %f", eAcntVal, acnt.BalanceMap[utils.DATA].GetTotalValue())
}
time.Sleep(50 * time.Millisecond)
eAcntVal = 49999897600.000000
eAcntVal = 49999887360.000000
if err := smgRPC.Call("ApierV2.GetAccount", attrs, &acnt); err != nil {
t.Error(err)
} else if acnt.BalanceMap[utils.DATA].GetTotalValue() != eAcntVal {

View File

@@ -65,7 +65,12 @@ func (self *SMGeneric) indexSession(uuid string, s *SMGSession) {
go func() {
select {
case <-timer.C:
self.sessionEnd(uuid, 0)
totalUsage := s.TotalUsage() + self.cgrCfg.SmGenericConfig.SessionTTL
self.sessionEnd(uuid, totalUsage)
cdr := s.eventStart.AsStoredCdr(self.cgrCfg, self.timezone)
cdr.Usage = totalUsage
var reply string
self.cdrsrv.ProcessCdr(cdr, &reply)
case <-endChan:
timer.Stop()
}