Fix for setBalance not checking actionTriggers on default balance

This commit is contained in:
DanB
2016-10-13 11:16:41 +02:00
parent 992543872a
commit 39b601780a
2 changed files with 3 additions and 3 deletions

View File

@@ -140,7 +140,6 @@ func TestApierV2itSetAccountActionTriggers(t *testing.T) {
GroupID: utils.StringPointer("MONITOR_MAX_BALANCE"),
ThresholdType: utils.StringPointer(utils.TRIGGER_MAX_BALANCE),
ThresholdValue: utils.Float64Pointer(50),
BalanceID: utils.StringPointer(utils.META_DEFAULT),
BalanceType: utils.StringPointer(utils.MONETARY),
ActionsID: utils.StringPointer("DISABLE_ACCOUNT"),
}
@@ -186,8 +185,8 @@ func TestApierV2itFraudMitigation(t *testing.T) {
t.Error(err)
} else if len(acnt.BalanceMap) != 1 || acnt.BalanceMap[utils.MONETARY][0].Value != 60.0 {
t.Errorf("Unexpected balance received: %+v", acnt.BalanceMap[utils.MONETARY][0])
//} else if !acnt.Disabled {
// t.Fatalf("Received account: %+v", acnt)
} else if !acnt.Disabled {
t.Fatalf("Received account: %+v", acnt)
}
attrSetAcnt := AttrSetAccount{
Tenant: "cgrates.org",

View File

@@ -127,6 +127,7 @@ func (acc *Account) setBalanceAction(a *Action) error {
balance.ID = utils.META_DEFAULT
if a.Balance.Value != nil {
balance.Value = a.Balance.GetValue()
balance.SetDirty() // Mark the balance as dirty since we have modified and it should be checked by action triggers
}
} else {
a.Balance.ModifyBalance(balance)