mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-21 15:18:44 +05:00
Updated AccountSummary in EventCost
This commit is contained in:
committed by
Dan Christian Bogos
parent
d0da699c36
commit
872a82c32f
@@ -1176,12 +1176,41 @@ func (as *AccountSummary) UpdateInitialValue(old *AccountSummary) {
|
||||
return
|
||||
}
|
||||
for _, initialBal := range old.BalanceSummaries {
|
||||
removed := true
|
||||
for _, currentBal := range as.BalanceSummaries {
|
||||
if currentBal.UUID == initialBal.UUID {
|
||||
currentBal.Initial = initialBal.Initial
|
||||
removed = false
|
||||
break
|
||||
}
|
||||
}
|
||||
if removed { // add back the expired balances
|
||||
initialBal.Value = 0 // it expired so lose all the values
|
||||
initialBal.Initial = 0 // only keep track of it in this
|
||||
as.BalanceSummaries = append(as.BalanceSummaries, initialBal)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// SetInitialValue set initial balance value
|
||||
func (as *AccountSummary) SetInitialValue(old *AccountSummary) {
|
||||
if old == nil {
|
||||
return
|
||||
}
|
||||
for _, initialBal := range old.BalanceSummaries {
|
||||
removed := true
|
||||
for _, currentBal := range as.BalanceSummaries {
|
||||
if currentBal.UUID == initialBal.UUID {
|
||||
currentBal.Initial = initialBal.Value
|
||||
removed = false
|
||||
break
|
||||
}
|
||||
}
|
||||
if removed { // add back the expired balances
|
||||
initialBal.Value = 0 // it expired so lose all the values
|
||||
initialBal.Initial = 0 // only keep track of it in this
|
||||
as.BalanceSummaries = append(as.BalanceSummaries, initialBal)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,6 @@ const (
|
||||
)
|
||||
|
||||
var (
|
||||
debitPeriod = 10 * time.Second
|
||||
globalRoundingDecimals = 6
|
||||
rpSubjectPrefixMatching bool
|
||||
rpSubjectPrefixMatchingMutex sync.RWMutex // used to reload rpSubjectPrefixMatching
|
||||
@@ -777,7 +776,6 @@ func (cd *CallDescriptor) Debit() (cc *CallCost, err error) {
|
||||
}
|
||||
return err
|
||||
}, config.CgrConfig().GeneralCfg().LockingTimeout, lkIDs...)
|
||||
return
|
||||
}, config.CgrConfig().GeneralCfg().LockingTimeout, utils.AccountPrefix+cd.GetAccountKey())
|
||||
return
|
||||
}
|
||||
@@ -1001,14 +999,7 @@ func (cd *CallDescriptor) AccountSummary(initialAcnt *AccountSummary) *AccountSu
|
||||
return nil
|
||||
}
|
||||
acntSummary := cd.account.AsAccountSummary()
|
||||
for _, initialBal := range initialAcnt.BalanceSummaries {
|
||||
for _, currentBal := range acntSummary.BalanceSummaries {
|
||||
if currentBal.UUID == initialBal.UUID {
|
||||
currentBal.Initial = initialBal.Value
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
acntSummary.SetInitialValue(initialAcnt)
|
||||
return acntSummary
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user