diff --git a/engine/account.go b/engine/account.go index 009723680..6f8a6ef5b 100644 --- a/engine/account.go +++ b/engine/account.go @@ -110,6 +110,7 @@ func (ub *Account) debitBalanceAction(a *Action, reset bool) error { if b.IsExpired() { continue // just to be safe (cleaned expired balances above) } + b.account = ub if b.MatchFilter(a.Balance) { if reset { b.SetValue(0) diff --git a/engine/balances.go b/engine/balances.go index 147a8220e..69ea789c5 100644 --- a/engine/balances.go +++ b/engine/balances.go @@ -312,27 +312,27 @@ func (b *Balance) SetValue(amount float64) { accountId := "" allowNegative := "" disabled := "" - if b.account != nil { + if b.account != nil { // only publish modifications for balances with account set accountId = b.account.Id allowNegative = strconv.FormatBool(b.account.AllowNegative) disabled = strconv.FormatBool(b.account.Disabled) + Publish(CgrEvent{ + "EventName": utils.EVT_ACCOUNT_BALANCE_MODIFIED, + "Uuid": b.Uuid, + "Id": b.Id, + "Value": strconv.FormatFloat(b.Value, 'f', -1, 64), + "ExpirationDate": b.ExpirationDate.String(), + "Weight": strconv.FormatFloat(b.Weight, 'f', -1, 64), + "DestinationIds": b.DestinationIds, + "RatingSubject": b.RatingSubject, + "Category": b.Category, + "SharedGroup": b.SharedGroup, + "TimingIDs": b.TimingIDs, + "Account": accountId, + "AccountAllowNegative": allowNegative, + "AccountDisabled": disabled, + }) } - Publish(CgrEvent{ - "EventName": utils.EVT_ACCOUNT_BALANCE_MODIFIED, - "Uuid": b.Uuid, - "Id": b.Id, - "Value": strconv.FormatFloat(b.Value, 'f', -1, 64), - "ExpirationDate": b.ExpirationDate.String(), - "Weight": strconv.FormatFloat(b.Weight, 'f', -1, 64), - "DestinationIds": b.DestinationIds, - "RatingSubject": b.RatingSubject, - "Category": b.Category, - "SharedGroup": b.SharedGroup, - "TimingIDs": b.TimingIDs, - "Account": accountId, - "AccountAllowNegative": allowNegative, - "AccountDisabled": disabled, - }) } func (b *Balance) DebitUnits(cd *CallDescriptor, ub *Account, moneyBalances BalanceChain, count bool, dryRun bool) (cc *CallCost, err error) {