renamed *exp_balance in *balance_expired

This commit is contained in:
Radu Ioan Fericean
2015-11-10 12:46:50 +02:00
parent 9b9cdb860d
commit 83bced074c
3 changed files with 5 additions and 6 deletions

View File

@@ -100,7 +100,6 @@ func (ub *Account) debitBalanceAction(a *Action, reset bool) error {
}
found := false
id := a.BalanceType
ub.CleanExpiredBalances()
for _, b := range ub.BalanceMap[id] {
if b.IsExpired() {
continue // just to be safe (cleaned expired balances above)
@@ -172,7 +171,6 @@ func (ub *Account) enableDisableBalanceAction(a *Action) error {
}
found := false
id := a.BalanceType
ub.CleanExpiredBalances()
for _, b := range ub.BalanceMap[id] {
if b.MatchFilter(a.Balance, false) {
b.Disabled = a.Balance.Disabled
@@ -501,7 +499,7 @@ func (ub *Account) executeActionTriggers(a *Action) {
}
} else { // BALANCE
for _, b := range ub.BalanceMap[at.BalanceType] {
if !b.dirty && at.ThresholdType != utils.TRIGGER_EXP_BALANCE { // do not check clean balances
if !b.dirty && at.ThresholdType != utils.TRIGGER_BALANCE_EXPIRED { // do not check clean balances
continue
}
switch at.ThresholdType {
@@ -514,7 +512,7 @@ func (ub *Account) executeActionTriggers(a *Action) {
if b.MatchActionTrigger(at) && b.GetValue() <= at.ThresholdValue {
at.Execute(ub, nil)
}
case utils.TRIGGER_EXP_BALANCE:
case utils.TRIGGER_BALANCE_EXPIRED:
if b.MatchActionTrigger(at) && b.IsExpired() {
at.Execute(ub, nil)
}
@@ -522,6 +520,7 @@ func (ub *Account) executeActionTriggers(a *Action) {
}
}
}
ub.CleanExpiredBalances()
}
// Mark all action trigers as ready for execution

View File

@@ -970,7 +970,7 @@ func TestAccountExpActionTrigger(t *testing.T) {
Id: "TEST_UB",
BalanceMap: map[string]BalanceChain{utils.MONETARY: BalanceChain{&Balance{Directions: utils.NewStringMap(utils.OUT), Value: 100, ExpirationDate: time.Date(2015, time.November, 9, 9, 48, 0, 0, time.UTC)}}, utils.VOICE: BalanceChain{&Balance{Value: 10, Weight: 20, DestinationIds: utils.StringMap{"NAT": true}, Directions: utils.StringMap{utils.OUT: true}}, &Balance{Weight: 10, DestinationIds: utils.StringMap{"RET": true}}}},
ActionTriggers: ActionTriggers{
&ActionTrigger{Id: "check expired balances", BalanceType: utils.MONETARY, BalanceDirections: utils.StringMap{utils.OUT: true}, ThresholdValue: 10, ThresholdType: utils.TRIGGER_EXP_BALANCE, ActionsId: "TEST_ACTIONS"},
&ActionTrigger{Id: "check expired balances", BalanceType: utils.MONETARY, BalanceDirections: utils.StringMap{utils.OUT: true}, ThresholdValue: 10, ThresholdType: utils.TRIGGER_BALANCE_EXPIRED, ActionsId: "TEST_ACTIONS"},
},
}
ub.executeActionTriggers(nil)

View File

@@ -253,7 +253,7 @@ const (
TRIGGER_MAX_BALANCE_COUNTER = "*max_balance_counter"
TRIGGER_MIN_BALANCE = "*min_balance"
TRIGGER_MAX_BALANCE = "*max_balance"
TRIGGER_EXP_BALANCE = "*exp_balance"
TRIGGER_BALANCE_EXPIRED = "*balance_expired"
)
var (