mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-13 11:06:25 +05:00
apply aliases/users before derived charging
This commit is contained in:
@@ -262,6 +262,20 @@ func (self *CdrServer) deriveCdrs(cdr *CDR) ([]*CDR, error) {
|
||||
if cdr.RunID != utils.MetaRaw { // Only derive *raw CDRs
|
||||
return cdrRuns, nil
|
||||
}
|
||||
if err := LoadAlias(&AttrMatchingAlias{
|
||||
Destination: cdr.Destination,
|
||||
Direction: cdr.Direction,
|
||||
Tenant: cdr.Tenant,
|
||||
Category: cdr.Category,
|
||||
Account: cdr.Account,
|
||||
Subject: cdr.Subject,
|
||||
Context: utils.ALIAS_CONTEXT_RATING,
|
||||
}, cdr, utils.EXTRA_FIELDS); err != nil && err != utils.ErrNotFound {
|
||||
return nil, err
|
||||
}
|
||||
if err := LoadUserProfile(cdr, utils.EXTRA_FIELDS); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
attrsDC := &utils.AttrDerivedChargers{Tenant: cdr.Tenant, Category: cdr.Category, Direction: cdr.Direction,
|
||||
Account: cdr.Account, Subject: cdr.Subject, Destination: cdr.Destination}
|
||||
var dcs utils.DerivedChargers
|
||||
|
||||
@@ -419,7 +419,7 @@ func (rs *Responder) GetSessionRuns(ev *CDR, sRuns *[]*SessionRun) error {
|
||||
return err
|
||||
}
|
||||
attrsDC := &utils.AttrDerivedChargers{Tenant: ev.GetTenant(utils.META_DEFAULT), Category: ev.GetCategory(utils.META_DEFAULT), Direction: ev.GetDirection(utils.META_DEFAULT),
|
||||
Account: ev.GetAccount(utils.META_DEFAULT), Subject: ev.GetSubject(utils.META_DEFAULT)}
|
||||
Account: ev.GetAccount(utils.META_DEFAULT), Subject: ev.GetSubject(utils.META_DEFAULT), Destination: ev.GetDestination(utils.META_DEFAULT)}
|
||||
dcs := &utils.DerivedChargers{}
|
||||
if err := rs.GetDerivedChargers(attrsDC, dcs); err != nil {
|
||||
rs.getCache().Cache(utils.GET_SESS_RUNS_CACHE_PREFIX+ev.CGRID, &cache2go.CacheItem{
|
||||
|
||||
@@ -95,6 +95,7 @@ func (self *SMGeneric) sessionStart(evStart SMGenericEvent, connId string) error
|
||||
s := &SMGSession{eventStart: evStart, connId: connId, runId: sessionRun.DerivedCharger.RunID, timezone: self.timezone,
|
||||
rater: self.rater, cdrsrv: self.cdrsrv, cd: sessionRun.CallDescriptor}
|
||||
self.indexSession(sessionId, s)
|
||||
utils.Logger.Info(fmt.Sprintf("<SMGeneric> Starting session: %s, runId: %s", sessionId, s.runId))
|
||||
if self.cgrCfg.SmGenericConfig.DebitInterval != 0 {
|
||||
s.stopDebit = stopDebitChan
|
||||
go s.debitLoop(self.cgrCfg.SmGenericConfig.DebitInterval)
|
||||
@@ -116,6 +117,7 @@ func (self *SMGeneric) sessionEnd(sessionId string, usage time.Duration) error {
|
||||
return nil, nil // Did not find the session so no need to close it anymore
|
||||
}
|
||||
for idx, s := range ss {
|
||||
utils.Logger.Info(fmt.Sprintf("<SMGeneric> Ending session: %s, runId: %s", sessionId, s.runId))
|
||||
if idx == 0 && s.stopDebit != nil {
|
||||
close(s.stopDebit) // Stop automatic debits
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user