mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-17 22:29:55 +05:00
renamed Id to ID in balance
This commit is contained in:
@@ -206,12 +206,12 @@ func (mig MigratorRC8) migrateAccounts() error {
|
||||
}
|
||||
newAcc.BalanceMap[newBalKey][index] = &engine.Balance{
|
||||
Uuid: oldBal.Uuid,
|
||||
Id: oldBal.Id,
|
||||
ID: oldBal.Id,
|
||||
Value: oldBal.Value,
|
||||
Directions: utils.ParseStringMap(newBalDirection),
|
||||
ExpirationDate: oldBal.ExpirationDate,
|
||||
Weight: oldBal.Weight,
|
||||
DestinationIds: utils.ParseStringMap(oldBal.DestinationIds),
|
||||
DestinationIDs: utils.ParseStringMap(oldBal.DestinationIds),
|
||||
RatingSubject: oldBal.RatingSubject,
|
||||
Categories: utils.ParseStringMap(oldBal.Category),
|
||||
SharedGroups: utils.ParseStringMap(oldBal.SharedGroup),
|
||||
|
||||
@@ -109,7 +109,7 @@ func (acc *Account) setBalanceAction(a *Action) error {
|
||||
continue
|
||||
}
|
||||
if (a.Balance.Uuid != nil && b.Uuid == *a.Balance.Uuid) ||
|
||||
(a.Balance.ID != nil && b.Id == *a.Balance.ID) {
|
||||
(a.Balance.ID != nil && b.ID == *a.Balance.ID) {
|
||||
previousSharedGroups = b.SharedGroups
|
||||
balance = b
|
||||
found = true
|
||||
@@ -125,7 +125,7 @@ func (acc *Account) setBalanceAction(a *Action) error {
|
||||
}
|
||||
|
||||
if a.Balance.ID != nil && *a.Balance.ID == utils.META_DEFAULT {
|
||||
balance.Id = utils.META_DEFAULT
|
||||
balance.ID = utils.META_DEFAULT
|
||||
if a.Balance.Value != nil {
|
||||
balance.Value = *a.Balance.Value
|
||||
}
|
||||
@@ -196,9 +196,9 @@ func (ub *Account) debitBalanceAction(a *Action, reset bool) error {
|
||||
if !found {
|
||||
// check if the Id is *default (user trying to create the default balance)
|
||||
// use only it's value value
|
||||
if bClone.Id == utils.META_DEFAULT {
|
||||
if bClone.ID == utils.META_DEFAULT {
|
||||
bClone = &Balance{
|
||||
Id: utils.META_DEFAULT,
|
||||
ID: utils.META_DEFAULT,
|
||||
Value: -bClone.GetValue(),
|
||||
}
|
||||
} else {
|
||||
@@ -300,12 +300,12 @@ func (ub *Account) getBalancesForPrefix(prefix, category, direction, tor string,
|
||||
continue
|
||||
}
|
||||
b.account = ub
|
||||
if len(b.DestinationIds) > 0 && b.DestinationIds[utils.ANY] == false {
|
||||
if len(b.DestinationIDs) > 0 && b.DestinationIDs[utils.ANY] == false {
|
||||
for _, p := range utils.SplitPrefix(prefix, MIN_PREFIX_MATCH) {
|
||||
if x, err := cache2go.Get(utils.DESTINATION_PREFIX + p); err == nil {
|
||||
destIds := x.(map[interface{}]struct{})
|
||||
for dId, _ := range destIds {
|
||||
if b.DestinationIds[dId.(string)] == true {
|
||||
if b.DestinationIDs[dId.(string)] == true {
|
||||
b.precision = len(p)
|
||||
usefulBalances = append(usefulBalances, b)
|
||||
break
|
||||
@@ -497,7 +497,7 @@ func (ub *Account) debitCreditBalance(cd *CallDescriptor, count bool, dryRun boo
|
||||
&Balance{
|
||||
Directions: utils.StringMap{leftCC.Direction: true},
|
||||
Value: cost,
|
||||
DestinationIds: utils.NewStringMap(leftCC.Destination),
|
||||
DestinationIDs: utils.NewStringMap(leftCC.Destination),
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -523,7 +523,7 @@ func (ub *Account) GetDefaultMoneyBalance() *Balance {
|
||||
// create default balance
|
||||
defaultBalance := &Balance{
|
||||
Uuid: utils.GenUUID(),
|
||||
Id: utils.META_DEFAULT,
|
||||
ID: utils.META_DEFAULT,
|
||||
} // minimum weight
|
||||
if ub.BalanceMap == nil {
|
||||
ub.BalanceMap = make(map[string]BalanceChain)
|
||||
@@ -960,9 +960,9 @@ func (acc *Account) AsOldStructure() interface{} {
|
||||
Recurrent: at.Recurrent,
|
||||
MinSleep: at.MinSleep,
|
||||
BalanceType: at.Balance.GetType(),
|
||||
BalanceId: b.Id,
|
||||
BalanceId: b.ID,
|
||||
BalanceDirection: b.Directions.String(),
|
||||
BalanceDestinationIds: b.DestinationIds.String(),
|
||||
BalanceDestinationIds: b.DestinationIDs.String(),
|
||||
BalanceWeight: b.Weight,
|
||||
BalanceExpirationDate: b.ExpirationDate,
|
||||
BalanceTimingTags: b.TimingIDs.String(),
|
||||
@@ -983,11 +983,11 @@ func (acc *Account) AsOldStructure() interface{} {
|
||||
for i, b := range values {
|
||||
result.BalanceMap[key][i] = &Balance{
|
||||
Uuid: b.Uuid,
|
||||
Id: b.Id,
|
||||
Id: b.ID,
|
||||
Value: b.Value,
|
||||
ExpirationDate: b.ExpirationDate,
|
||||
Weight: b.Weight,
|
||||
DestinationIds: b.DestinationIds.String(),
|
||||
DestinationIds: b.DestinationIDs.String(),
|
||||
RatingSubject: b.RatingSubject,
|
||||
Category: b.Categories.String(),
|
||||
SharedGroup: b.SharedGroups.String(),
|
||||
|
||||
@@ -83,8 +83,8 @@ func TestBalanceChainStoreRestore(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAccountStorageStoreRestore(t *testing.T) {
|
||||
b1 := &Balance{Value: 10, Weight: 10, DestinationIds: utils.StringMap{"NAT": true}}
|
||||
b2 := &Balance{Value: 100, Weight: 20, DestinationIds: utils.StringMap{"RET": true}}
|
||||
b1 := &Balance{Value: 10, Weight: 10, DestinationIDs: utils.StringMap{"NAT": true}}
|
||||
b2 := &Balance{Value: 100, Weight: 20, DestinationIDs: utils.StringMap{"RET": true}}
|
||||
rifsBalance := &Account{Id: "other", BalanceMap: map[string]BalanceChain{utils.VOICE: BalanceChain{b1, b2}, utils.MONETARY: BalanceChain{&Balance{Value: 21}}}}
|
||||
accountingStorage.SetAccount(rifsBalance)
|
||||
ub1, err := accountingStorage.GetAccount("other")
|
||||
@@ -95,8 +95,8 @@ func TestAccountStorageStoreRestore(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetSecondsForPrefix(t *testing.T) {
|
||||
b1 := &Balance{Value: 10, Weight: 10, DestinationIds: utils.StringMap{"NAT": true}}
|
||||
b2 := &Balance{Value: 100, Weight: 20, DestinationIds: utils.StringMap{"RET": true}}
|
||||
b1 := &Balance{Value: 10, Weight: 10, DestinationIDs: utils.StringMap{"NAT": true}}
|
||||
b2 := &Balance{Value: 100, Weight: 20, DestinationIDs: utils.StringMap{"RET": true}}
|
||||
ub1 := &Account{Id: "CUSTOMER_1:rif", BalanceMap: map[string]BalanceChain{utils.VOICE: BalanceChain{b1, b2}, utils.MONETARY: BalanceChain{&Balance{Value: 200}}}}
|
||||
cd := &CallDescriptor{
|
||||
Category: "0",
|
||||
@@ -118,8 +118,8 @@ func TestGetSecondsForPrefix(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetSpecialPricedSeconds(t *testing.T) {
|
||||
b1 := &Balance{Value: 10, Weight: 10, DestinationIds: utils.StringMap{"NAT": true}, RatingSubject: "minu"}
|
||||
b2 := &Balance{Value: 100, Weight: 20, DestinationIds: utils.StringMap{"RET": true}, RatingSubject: "minu"}
|
||||
b1 := &Balance{Value: 10, Weight: 10, DestinationIDs: utils.StringMap{"NAT": true}, RatingSubject: "minu"}
|
||||
b2 := &Balance{Value: 100, Weight: 20, DestinationIDs: utils.StringMap{"RET": true}, RatingSubject: "minu"}
|
||||
|
||||
ub1 := &Account{
|
||||
Id: "OUT:CUSTOMER_1:rif",
|
||||
@@ -150,8 +150,8 @@ func TestGetSpecialPricedSeconds(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAccountStorageStore(t *testing.T) {
|
||||
b1 := &Balance{Value: 10, Weight: 10, DestinationIds: utils.StringMap{"NAT": true}}
|
||||
b2 := &Balance{Value: 100, Weight: 20, DestinationIds: utils.StringMap{"RET": true}}
|
||||
b1 := &Balance{Value: 10, Weight: 10, DestinationIDs: utils.StringMap{"NAT": true}}
|
||||
b2 := &Balance{Value: 100, Weight: 20, DestinationIDs: utils.StringMap{"RET": true}}
|
||||
rifsBalance := &Account{Id: "other", BalanceMap: map[string]BalanceChain{utils.VOICE: BalanceChain{b1, b2}, utils.MONETARY: BalanceChain{&Balance{Value: 21}}}}
|
||||
accountingStorage.SetAccount(rifsBalance)
|
||||
result, err := accountingStorage.GetAccount(rifsBalance.Id)
|
||||
@@ -165,7 +165,7 @@ func TestAccountStorageStore(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDebitCreditZeroSecond(t *testing.T) {
|
||||
b1 := &Balance{Uuid: "testb", Value: 10, Weight: 10, DestinationIds: utils.StringMap{"NAT": true}, RatingSubject: "*zero1s"}
|
||||
b1 := &Balance{Uuid: "testb", Value: 10, Weight: 10, DestinationIDs: utils.StringMap{"NAT": true}, RatingSubject: "*zero1s"}
|
||||
cc := &CallCost{
|
||||
Direction: utils.OUT,
|
||||
Destination: "0723045326",
|
||||
@@ -205,7 +205,7 @@ func TestDebitCreditZeroSecond(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDebitCreditZeroMinute(t *testing.T) {
|
||||
b1 := &Balance{Uuid: "testb", Value: 70, Weight: 10, DestinationIds: utils.StringMap{"NAT": true}, RatingSubject: "*zero1m"}
|
||||
b1 := &Balance{Uuid: "testb", Value: 70, Weight: 10, DestinationIDs: utils.StringMap{"NAT": true}, RatingSubject: "*zero1m"}
|
||||
cc := &CallCost{
|
||||
Direction: utils.OUT,
|
||||
Destination: "0723045326",
|
||||
@@ -250,8 +250,8 @@ func TestDebitCreditZeroMinute(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDebitCreditZeroMixedMinute(t *testing.T) {
|
||||
b1 := &Balance{Uuid: "testm", Value: 70, Weight: 5, DestinationIds: utils.StringMap{"NAT": true}, RatingSubject: "*zero1m"}
|
||||
b2 := &Balance{Uuid: "tests", Value: 10, Weight: 10, DestinationIds: utils.StringMap{"NAT": true}, RatingSubject: "*zero1s"}
|
||||
b1 := &Balance{Uuid: "testm", Value: 70, Weight: 5, DestinationIDs: utils.StringMap{"NAT": true}, RatingSubject: "*zero1m"}
|
||||
b2 := &Balance{Uuid: "tests", Value: 10, Weight: 10, DestinationIDs: utils.StringMap{"NAT": true}, RatingSubject: "*zero1s"}
|
||||
cc := &CallCost{
|
||||
Direction: utils.OUT,
|
||||
Destination: "0723045326",
|
||||
@@ -298,7 +298,7 @@ func TestDebitCreditZeroMixedMinute(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDebitCreditNoCredit(t *testing.T) {
|
||||
b1 := &Balance{Uuid: "testb", Value: 70, Weight: 10, DestinationIds: utils.StringMap{"NAT": true}, RatingSubject: "*zero1m"}
|
||||
b1 := &Balance{Uuid: "testb", Value: 70, Weight: 10, DestinationIDs: utils.StringMap{"NAT": true}, RatingSubject: "*zero1m"}
|
||||
cc := &CallCost{
|
||||
Direction: utils.OUT,
|
||||
Destination: "0723045326",
|
||||
@@ -349,7 +349,7 @@ func TestDebitCreditNoCredit(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDebitCreditHasCredit(t *testing.T) {
|
||||
b1 := &Balance{Uuid: "testb", Value: 70, Weight: 10, DestinationIds: utils.StringMap{"NAT": true}, RatingSubject: "*zero1m"}
|
||||
b1 := &Balance{Uuid: "testb", Value: 70, Weight: 10, DestinationIDs: utils.StringMap{"NAT": true}, RatingSubject: "*zero1m"}
|
||||
cc := &CallCost{
|
||||
Direction: utils.OUT,
|
||||
Destination: "0723045326",
|
||||
@@ -402,7 +402,7 @@ func TestDebitCreditHasCredit(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDebitCreditSplitMinutesMoney(t *testing.T) {
|
||||
b1 := &Balance{Uuid: "testb", Value: 10, Weight: 10, DestinationIds: utils.StringMap{"NAT": true}, RatingSubject: "*zero1s"}
|
||||
b1 := &Balance{Uuid: "testb", Value: 10, Weight: 10, DestinationIDs: utils.StringMap{"NAT": true}, RatingSubject: "*zero1s"}
|
||||
cc := &CallCost{
|
||||
Direction: utils.OUT,
|
||||
Destination: "0723045326",
|
||||
@@ -450,7 +450,7 @@ func TestDebitCreditSplitMinutesMoney(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDebitCreditMoreTimespans(t *testing.T) {
|
||||
b1 := &Balance{Uuid: "testb", Value: 150, Weight: 10, DestinationIds: utils.StringMap{"NAT": true}, RatingSubject: "*zero1m"}
|
||||
b1 := &Balance{Uuid: "testb", Value: 150, Weight: 10, DestinationIDs: utils.StringMap{"NAT": true}, RatingSubject: "*zero1m"}
|
||||
cc := &CallCost{
|
||||
Direction: utils.OUT,
|
||||
Destination: "0723045326",
|
||||
@@ -498,8 +498,8 @@ func TestDebitCreditMoreTimespans(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDebitCreditMoreTimespansMixed(t *testing.T) {
|
||||
b1 := &Balance{Uuid: "testb", Value: 70, Weight: 10, DestinationIds: utils.StringMap{"NAT": true}, RatingSubject: "*zero1m"}
|
||||
b2 := &Balance{Uuid: "testa", Value: 150, Weight: 5, DestinationIds: utils.StringMap{"NAT": true}, RatingSubject: "*zero1s"}
|
||||
b1 := &Balance{Uuid: "testb", Value: 70, Weight: 10, DestinationIDs: utils.StringMap{"NAT": true}, RatingSubject: "*zero1m"}
|
||||
b2 := &Balance{Uuid: "testa", Value: 150, Weight: 5, DestinationIDs: utils.StringMap{"NAT": true}, RatingSubject: "*zero1s"}
|
||||
cc := &CallCost{
|
||||
Direction: utils.OUT,
|
||||
Destination: "0723045326",
|
||||
@@ -548,7 +548,7 @@ func TestDebitCreditMoreTimespansMixed(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDebitCreditNoConectFeeCredit(t *testing.T) {
|
||||
b1 := &Balance{Uuid: "testb", Value: 70, Weight: 10, DestinationIds: utils.StringMap{"NAT": true}, RatingSubject: "*zero1m"}
|
||||
b1 := &Balance{Uuid: "testb", Value: 70, Weight: 10, DestinationIDs: utils.StringMap{"NAT": true}, RatingSubject: "*zero1m"}
|
||||
cc := &CallCost{
|
||||
Direction: utils.OUT,
|
||||
Destination: "0723045326",
|
||||
@@ -647,7 +647,7 @@ func TestDebitCreditMoneyOnly(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDebitCreditSubjectMinutes(t *testing.T) {
|
||||
b1 := &Balance{Uuid: "testb", Categories: utils.NewStringMap("0"), Value: 250, Weight: 10, DestinationIds: utils.StringMap{"NAT": true}, RatingSubject: "minu"}
|
||||
b1 := &Balance{Uuid: "testb", Categories: utils.NewStringMap("0"), Value: 250, Weight: 10, DestinationIDs: utils.StringMap{"NAT": true}, RatingSubject: "minu"}
|
||||
cc := &CallCost{
|
||||
Tenant: "vdf",
|
||||
Category: "0",
|
||||
@@ -731,7 +731,7 @@ func TestDebitCreditSubjectMoney(t *testing.T) {
|
||||
testCallcost: cc,
|
||||
}
|
||||
rifsBalance := &Account{Id: "other", BalanceMap: map[string]BalanceChain{
|
||||
utils.MONETARY: BalanceChain{&Balance{Uuid: "moneya", Value: 75, DestinationIds: utils.StringMap{"NAT": true}, RatingSubject: "minu"}},
|
||||
utils.MONETARY: BalanceChain{&Balance{Uuid: "moneya", Value: 75, DestinationIDs: utils.StringMap{"NAT": true}, RatingSubject: "minu"}},
|
||||
}}
|
||||
var err error
|
||||
cc, err = rifsBalance.debitCreditBalance(cd, false, false, true)
|
||||
@@ -811,7 +811,7 @@ func TestAccountdebitBalance(t *testing.T) {
|
||||
ub := &Account{
|
||||
Id: "rif",
|
||||
AllowNegative: true,
|
||||
BalanceMap: map[string]BalanceChain{utils.SMS: BalanceChain{&Balance{Value: 14}}, utils.DATA: BalanceChain{&Balance{Value: 1204}}, utils.VOICE: BalanceChain{&Balance{Weight: 20, DestinationIds: utils.StringMap{"NAT": true}}, &Balance{Weight: 10, DestinationIds: utils.StringMap{"RET": true}}}},
|
||||
BalanceMap: map[string]BalanceChain{utils.SMS: BalanceChain{&Balance{Value: 14}}, utils.DATA: BalanceChain{&Balance{Value: 1204}}, utils.VOICE: BalanceChain{&Balance{Weight: 20, DestinationIDs: utils.StringMap{"NAT": true}}, &Balance{Weight: 10, DestinationIDs: utils.StringMap{"RET": true}}}},
|
||||
}
|
||||
newMb := &BalanceFilter{
|
||||
Type: utils.StringPointer(utils.VOICE),
|
||||
@@ -821,7 +821,7 @@ func TestAccountdebitBalance(t *testing.T) {
|
||||
}
|
||||
a := &Action{Balance: newMb}
|
||||
ub.debitBalanceAction(a, false)
|
||||
if len(ub.BalanceMap[utils.VOICE]) != 3 || !ub.BalanceMap[utils.VOICE][2].DestinationIds.Equal(*newMb.DestinationIDs) {
|
||||
if len(ub.BalanceMap[utils.VOICE]) != 3 || !ub.BalanceMap[utils.VOICE][2].DestinationIDs.Equal(*newMb.DestinationIDs) {
|
||||
t.Errorf("Error adding minute bucket! %d %+v %+v", len(ub.BalanceMap[utils.VOICE]), ub.BalanceMap[utils.VOICE][2], newMb)
|
||||
}
|
||||
}
|
||||
@@ -830,12 +830,12 @@ func TestAccountdebitBalance(t *testing.T) {
|
||||
ub := &Account{
|
||||
Id: "rif",
|
||||
AllowNegative: true,
|
||||
BalanceMap: map[string]BalanceChain{utils.SMS: BalanceChain{&Balance{Value: 14}}, utils.DATA: BalanceChain{&Balance{Value: 1204}}, utils.VOICE: BalanceChain{&Balance{Weight: 20, DestinationIds: utils.StringMap{"NAT": true}, Directions: utils.NewStringMap(utils.OUT)}, &Balance{Weight: 10, DestinationIds: utils.StringMap{"RET": true}}}},
|
||||
BalanceMap: map[string]BalanceChain{utils.SMS: BalanceChain{&Balance{Value: 14}}, utils.DATA: BalanceChain{&Balance{Value: 1204}}, utils.VOICE: BalanceChain{&Balance{Weight: 20, DestinationIDs: utils.StringMap{"NAT": true}, Directions: utils.NewStringMap(utils.OUT)}, &Balance{Weight: 10, DestinationIDs: utils.StringMap{"RET": true}}}},
|
||||
}
|
||||
newMb := &BalanceFilter{
|
||||
Type: utils.StringPointer(utils.VOICE),
|
||||
Weight: utils.Float64Pointer(20),
|
||||
DestinationIds: utils.StringMapPointer(utils.StringMap{"NAT": true}),
|
||||
DestinationIDs: utils.StringMapPointer(utils.StringMap{"NAT": true}),
|
||||
Directions: utils.StringMapPointer(utils.NewStringMap(utils.OUT)),
|
||||
}
|
||||
a := &Action{Balance: newMb}
|
||||
@@ -853,7 +853,7 @@ func TestAccountdebitBalanceExists(t *testing.T) {
|
||||
ub := &Account{
|
||||
Id: "rif",
|
||||
AllowNegative: true,
|
||||
BalanceMap: map[string]BalanceChain{utils.SMS: BalanceChain{&Balance{Value: 14}}, utils.DATA: BalanceChain{&Balance{Value: 1024}}, utils.VOICE: BalanceChain{&Balance{Value: 15, Weight: 20, DestinationIds: utils.StringMap{"NAT": true}, Directions: utils.NewStringMap(utils.OUT)}, &Balance{Weight: 10, DestinationIds: utils.StringMap{"RET": true}}}},
|
||||
BalanceMap: map[string]BalanceChain{utils.SMS: BalanceChain{&Balance{Value: 14}}, utils.DATA: BalanceChain{&Balance{Value: 1024}}, utils.VOICE: BalanceChain{&Balance{Value: 15, Weight: 20, DestinationIDs: utils.StringMap{"NAT": true}, Directions: utils.NewStringMap(utils.OUT)}, &Balance{Weight: 10, DestinationIDs: utils.StringMap{"RET": true}}}},
|
||||
}
|
||||
newMb := &BalanceFilter{
|
||||
Value: utils.Float64Pointer(-10),
|
||||
@@ -873,7 +873,7 @@ func TestAccountAddMinuteNil(t *testing.T) {
|
||||
ub := &Account{
|
||||
Id: "rif",
|
||||
AllowNegative: true,
|
||||
BalanceMap: map[string]BalanceChain{utils.SMS: BalanceChain{&Balance{Value: 14}}, utils.DATA: BalanceChain{&Balance{Value: 1024}}, utils.VOICE: BalanceChain{&Balance{Weight: 20, DestinationIds: utils.StringMap{"NAT": true}}, &Balance{Weight: 10, DestinationIds: utils.StringMap{"RET": true}}}},
|
||||
BalanceMap: map[string]BalanceChain{utils.SMS: BalanceChain{&Balance{Value: 14}}, utils.DATA: BalanceChain{&Balance{Value: 1024}}, utils.VOICE: BalanceChain{&Balance{Weight: 20, DestinationIDs: utils.StringMap{"NAT": true}}, &Balance{Weight: 10, DestinationIDs: utils.StringMap{"RET": true}}}},
|
||||
}
|
||||
ub.debitBalanceAction(nil, false)
|
||||
if len(ub.BalanceMap[utils.VOICE]) != 2 {
|
||||
@@ -921,7 +921,7 @@ func TestAccountAddMinutBucketEmpty(t *testing.T) {
|
||||
func TestAccountExecuteTriggeredActions(t *testing.T) {
|
||||
ub := &Account{
|
||||
Id: "TEST_UB",
|
||||
BalanceMap: map[string]BalanceChain{utils.MONETARY: BalanceChain{&Balance{Directions: utils.NewStringMap(utils.OUT), Value: 100}}, 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}}}},
|
||||
BalanceMap: map[string]BalanceChain{utils.MONETARY: BalanceChain{&Balance{Directions: utils.NewStringMap(utils.OUT), Value: 100}}, 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}}}},
|
||||
UnitCounters: UnitCounters{utils.MONETARY: []*UnitCounter{&UnitCounter{Counters: CounterFilters{&CounterFilter{Value: 1, Filter: &BalanceFilter{Type: utils.StringPointer(utils.MONETARY), Directions: utils.StringMapPointer(utils.StringMap{utils.OUT: true})}}}}}},
|
||||
ActionTriggers: ActionTriggers{&ActionTrigger{Balance: &BalanceFilter{Type: utils.StringPointer(utils.MONETARY), Directions: utils.StringMapPointer(utils.NewStringMap(utils.OUT))}, ThresholdValue: 2, ThresholdType: utils.TRIGGER_MAX_EVENT_COUNTER, ActionsId: "TEST_ACTIONS"}},
|
||||
}
|
||||
@@ -945,7 +945,7 @@ func TestAccountExecuteTriggeredActions(t *testing.T) {
|
||||
func TestAccountExecuteTriggeredActionsBalance(t *testing.T) {
|
||||
ub := &Account{
|
||||
Id: "TEST_UB",
|
||||
BalanceMap: map[string]BalanceChain{utils.MONETARY: BalanceChain{&Balance{Directions: utils.NewStringMap(utils.OUT), Value: 100}}, utils.VOICE: BalanceChain{&Balance{Directions: utils.NewStringMap(utils.OUT), Value: 10, Weight: 20, DestinationIds: utils.StringMap{"NAT": true}}, &Balance{Directions: utils.NewStringMap(utils.OUT), Weight: 10, DestinationIds: utils.StringMap{"RET": true}}}},
|
||||
BalanceMap: map[string]BalanceChain{utils.MONETARY: BalanceChain{&Balance{Directions: utils.NewStringMap(utils.OUT), Value: 100}}, utils.VOICE: BalanceChain{&Balance{Directions: utils.NewStringMap(utils.OUT), Value: 10, Weight: 20, DestinationIDs: utils.StringMap{"NAT": true}}, &Balance{Directions: utils.NewStringMap(utils.OUT), Weight: 10, DestinationIDs: utils.StringMap{"RET": true}}}},
|
||||
UnitCounters: UnitCounters{utils.MONETARY: []*UnitCounter{&UnitCounter{Counters: CounterFilters{&CounterFilter{Filter: &BalanceFilter{Type: utils.StringPointer(utils.MONETARY), Directions: utils.StringMapPointer(utils.NewStringMap(utils.OUT))}, Value: 1.0}}}}},
|
||||
ActionTriggers: ActionTriggers{&ActionTrigger{Balance: &BalanceFilter{Type: utils.StringPointer(utils.MONETARY), Directions: utils.StringMapPointer(utils.NewStringMap(utils.OUT))}, ThresholdValue: 100, ThresholdType: utils.TRIGGER_MIN_EVENT_COUNTER, ActionsId: "TEST_ACTIONS"}},
|
||||
}
|
||||
@@ -973,7 +973,7 @@ func TestAccountExecuteTriggeredActionsOrder(t *testing.T) {
|
||||
func TestAccountExecuteTriggeredDayWeek(t *testing.T) {
|
||||
ub := &Account{
|
||||
Id: "TEST_UB",
|
||||
BalanceMap: map[string]BalanceChain{utils.MONETARY: BalanceChain{&Balance{Directions: utils.NewStringMap(utils.OUT), Value: 100}}, 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}}}},
|
||||
BalanceMap: map[string]BalanceChain{utils.MONETARY: BalanceChain{&Balance{Directions: utils.NewStringMap(utils.OUT), Value: 100}}, 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{UniqueID: "day_trigger", Balance: &BalanceFilter{Type: utils.StringPointer(utils.MONETARY), Directions: utils.StringMapPointer(utils.NewStringMap(utils.OUT))}, ThresholdValue: 10, ThresholdType: utils.TRIGGER_MAX_EVENT_COUNTER, ActionsId: "TEST_ACTIONS"},
|
||||
&ActionTrigger{UniqueID: "week_trigger", Balance: &BalanceFilter{Type: utils.StringPointer(utils.MONETARY), Directions: utils.StringMapPointer(utils.NewStringMap(utils.OUT))}, ThresholdValue: 100, ThresholdType: utils.TRIGGER_MAX_EVENT_COUNTER, ActionsId: "TEST_ACTIONS"},
|
||||
@@ -1001,7 +1001,7 @@ func TestAccountExecuteTriggeredDayWeek(t *testing.T) {
|
||||
func TestAccountExpActionTrigger(t *testing.T) {
|
||||
ub := &Account{
|
||||
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}}}},
|
||||
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", Balance: &BalanceFilter{Type: utils.StringPointer(utils.MONETARY), Directions: utils.StringMapPointer(utils.NewStringMap(utils.OUT))}, ThresholdValue: 10, ThresholdType: utils.TRIGGER_BALANCE_EXPIRED, ActionsId: "TEST_ACTIONS"},
|
||||
},
|
||||
@@ -1019,7 +1019,7 @@ func TestAccountExpActionTrigger(t *testing.T) {
|
||||
func TestAccountExpActionTriggerNotActivated(t *testing.T) {
|
||||
ub := &Account{
|
||||
Id: "TEST_UB",
|
||||
BalanceMap: map[string]BalanceChain{utils.MONETARY: BalanceChain{&Balance{Directions: utils.NewStringMap(utils.OUT), Value: 100}}, 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}}}},
|
||||
BalanceMap: map[string]BalanceChain{utils.MONETARY: BalanceChain{&Balance{Directions: utils.NewStringMap(utils.OUT), Value: 100}}, 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", ActivationDate: time.Date(2116, 2, 5, 18, 0, 0, 0, time.UTC), Balance: &BalanceFilter{Type: utils.StringPointer(utils.MONETARY), Directions: utils.StringMapPointer(utils.NewStringMap(utils.OUT))}, ThresholdValue: 10, ThresholdType: utils.TRIGGER_BALANCE_EXPIRED, ActionsId: "TEST_ACTIONS"},
|
||||
},
|
||||
@@ -1037,7 +1037,7 @@ func TestAccountExpActionTriggerNotActivated(t *testing.T) {
|
||||
func TestAccountExpActionTriggerExpired(t *testing.T) {
|
||||
ub := &Account{
|
||||
Id: "TEST_UB",
|
||||
BalanceMap: map[string]BalanceChain{utils.MONETARY: BalanceChain{&Balance{Directions: utils.NewStringMap(utils.OUT), Value: 100}}, 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}}}},
|
||||
BalanceMap: map[string]BalanceChain{utils.MONETARY: BalanceChain{&Balance{Directions: utils.NewStringMap(utils.OUT), Value: 100}}, 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", ExpirationDate: time.Date(2016, 2, 4, 18, 0, 0, 0, time.UTC), Balance: &BalanceFilter{Type: utils.StringPointer(utils.MONETARY), Directions: utils.StringMapPointer(utils.NewStringMap(utils.OUT))}, ThresholdValue: 10, ThresholdType: utils.TRIGGER_BALANCE_EXPIRED, ActionsId: "TEST_ACTIONS"},
|
||||
},
|
||||
@@ -1134,8 +1134,8 @@ func TestAccountRefund(t *testing.T) {
|
||||
&Balance{Uuid: "moneya", Value: 100},
|
||||
},
|
||||
utils.VOICE: BalanceChain{
|
||||
&Balance{Uuid: "minutea", Value: 10, Weight: 20, DestinationIds: utils.StringMap{"NAT": true}},
|
||||
&Balance{Uuid: "minuteb", Value: 10, DestinationIds: utils.StringMap{"RET": true}},
|
||||
&Balance{Uuid: "minutea", Value: 10, Weight: 20, DestinationIDs: utils.StringMap{"NAT": true}},
|
||||
&Balance{Uuid: "minuteb", Value: 10, DestinationIDs: utils.StringMap{"RET": true}},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -1325,7 +1325,7 @@ func TestDebitSMS(t *testing.T) {
|
||||
testCallcost: cc,
|
||||
}
|
||||
rifsBalance := &Account{Id: "other", BalanceMap: map[string]BalanceChain{
|
||||
utils.SMS: BalanceChain{&Balance{Uuid: "testm", Value: 100, Weight: 5, DestinationIds: utils.StringMap{"NAT": true}}},
|
||||
utils.SMS: BalanceChain{&Balance{Uuid: "testm", Value: 100, Weight: 5, DestinationIDs: utils.StringMap{"NAT": true}}},
|
||||
utils.MONETARY: BalanceChain{&Balance{Value: 21}},
|
||||
}}
|
||||
var err error
|
||||
@@ -1368,7 +1368,7 @@ func TestDebitGeneric(t *testing.T) {
|
||||
testCallcost: cc,
|
||||
}
|
||||
rifsBalance := &Account{Id: "other", BalanceMap: map[string]BalanceChain{
|
||||
utils.GENERIC: BalanceChain{&Balance{Uuid: "testm", Value: 100, Weight: 5, DestinationIds: utils.StringMap{"NAT": true}}},
|
||||
utils.GENERIC: BalanceChain{&Balance{Uuid: "testm", Value: 100, Weight: 5, DestinationIDs: utils.StringMap{"NAT": true}}},
|
||||
utils.MONETARY: BalanceChain{&Balance{Value: 21}},
|
||||
}}
|
||||
var err error
|
||||
@@ -1411,7 +1411,7 @@ func TestDebitGenericBalance(t *testing.T) {
|
||||
testCallcost: cc,
|
||||
}
|
||||
rifsBalance := &Account{Id: "other", BalanceMap: map[string]BalanceChain{
|
||||
utils.GENERIC: BalanceChain{&Balance{Uuid: "testm", Value: 100, Weight: 5, DestinationIds: utils.StringMap{"NAT": true}, Factor: ValueFactor{utils.VOICE: 60.0}}},
|
||||
utils.GENERIC: BalanceChain{&Balance{Uuid: "testm", Value: 100, Weight: 5, DestinationIDs: utils.StringMap{"NAT": true}, Factor: ValueFactor{utils.VOICE: 60.0}}},
|
||||
utils.MONETARY: BalanceChain{&Balance{Value: 21}},
|
||||
}}
|
||||
var err error
|
||||
@@ -1454,7 +1454,7 @@ func TestDebitGenericBalanceWithRatingSubject(t *testing.T) {
|
||||
testCallcost: cc,
|
||||
}
|
||||
rifsBalance := &Account{Id: "other", BalanceMap: map[string]BalanceChain{
|
||||
utils.GENERIC: BalanceChain{&Balance{Uuid: "testm", Value: 100, Weight: 5, DestinationIds: utils.StringMap{"NAT": true}, Factor: ValueFactor{utils.VOICE: 60.0}, RatingSubject: "free"}},
|
||||
utils.GENERIC: BalanceChain{&Balance{Uuid: "testm", Value: 100, Weight: 5, DestinationIDs: utils.StringMap{"NAT": true}, Factor: ValueFactor{utils.VOICE: 60.0}, RatingSubject: "free"}},
|
||||
utils.MONETARY: BalanceChain{&Balance{Value: 21}},
|
||||
}}
|
||||
var err error
|
||||
@@ -1504,7 +1504,7 @@ func TestDebitDataUnits(t *testing.T) {
|
||||
testCallcost: cc,
|
||||
}
|
||||
rifsBalance := &Account{Id: "other", BalanceMap: map[string]BalanceChain{
|
||||
utils.DATA: BalanceChain{&Balance{Uuid: "testm", Value: 100, Weight: 5, DestinationIds: utils.StringMap{"NAT": true}}},
|
||||
utils.DATA: BalanceChain{&Balance{Uuid: "testm", Value: 100, Weight: 5, DestinationIDs: utils.StringMap{"NAT": true}}},
|
||||
utils.MONETARY: BalanceChain{&Balance{Value: 21}},
|
||||
}}
|
||||
var err error
|
||||
@@ -1558,7 +1558,7 @@ func TestDebitDataMoney(t *testing.T) {
|
||||
testCallcost: cc,
|
||||
}
|
||||
rifsBalance := &Account{Id: "other", BalanceMap: map[string]BalanceChain{
|
||||
utils.DATA: BalanceChain{&Balance{Uuid: "testm", Value: 0, Weight: 5, DestinationIds: utils.StringMap{"NAT": true}}},
|
||||
utils.DATA: BalanceChain{&Balance{Uuid: "testm", Value: 0, Weight: 5, DestinationIDs: utils.StringMap{"NAT": true}}},
|
||||
utils.MONETARY: BalanceChain{&Balance{Value: 160}},
|
||||
}}
|
||||
var err error
|
||||
@@ -1752,8 +1752,8 @@ func TestAccountDoubleInitCounters(t *testing.T) {
|
||||
|
||||
func BenchmarkGetSecondForPrefix(b *testing.B) {
|
||||
b.StopTimer()
|
||||
b1 := &Balance{Value: 10, Weight: 10, DestinationIds: utils.StringMap{"NAT": true}}
|
||||
b2 := &Balance{Value: 100, Weight: 20, DestinationIds: utils.StringMap{"RET": true}}
|
||||
b1 := &Balance{Value: 10, Weight: 10, DestinationIDs: utils.StringMap{"NAT": true}}
|
||||
b2 := &Balance{Value: 100, Weight: 20, DestinationIDs: utils.StringMap{"RET": true}}
|
||||
|
||||
ub1 := &Account{Id: "other", BalanceMap: map[string]BalanceChain{utils.VOICE: BalanceChain{b1, b2}, utils.MONETARY: BalanceChain{&Balance{Value: 21}}}}
|
||||
cd := &CallDescriptor{
|
||||
@@ -1766,8 +1766,8 @@ func BenchmarkGetSecondForPrefix(b *testing.B) {
|
||||
}
|
||||
|
||||
func BenchmarkAccountStorageStoreRestore(b *testing.B) {
|
||||
b1 := &Balance{Value: 10, Weight: 10, DestinationIds: utils.StringMap{"NAT": true}}
|
||||
b2 := &Balance{Value: 100, Weight: 20, DestinationIds: utils.StringMap{"RET": true}}
|
||||
b1 := &Balance{Value: 10, Weight: 10, DestinationIDs: utils.StringMap{"NAT": true}}
|
||||
b2 := &Balance{Value: 100, Weight: 20, DestinationIDs: utils.StringMap{"RET": true}}
|
||||
rifsBalance := &Account{Id: "other", BalanceMap: map[string]BalanceChain{utils.VOICE: BalanceChain{b1, b2}, utils.MONETARY: BalanceChain{&Balance{Value: 21}}}}
|
||||
for i := 0; i < b.N; i++ {
|
||||
accountingStorage.SetAccount(rifsBalance)
|
||||
@@ -1776,8 +1776,8 @@ func BenchmarkAccountStorageStoreRestore(b *testing.B) {
|
||||
}
|
||||
|
||||
func BenchmarkGetSecondsForPrefix(b *testing.B) {
|
||||
b1 := &Balance{Value: 10, Weight: 10, DestinationIds: utils.StringMap{"NAT": true}}
|
||||
b2 := &Balance{Value: 100, Weight: 20, DestinationIds: utils.StringMap{"RET": true}}
|
||||
b1 := &Balance{Value: 10, Weight: 10, DestinationIDs: utils.StringMap{"NAT": true}}
|
||||
b2 := &Balance{Value: 100, Weight: 20, DestinationIDs: utils.StringMap{"RET": true}}
|
||||
ub1 := &Account{Id: "OUT:CUSTOMER_1:rif", BalanceMap: map[string]BalanceChain{utils.VOICE: BalanceChain{b1, b2}, utils.MONETARY: BalanceChain{&Balance{Value: 21}}}}
|
||||
cd := &CallDescriptor{
|
||||
Destination: "0723",
|
||||
|
||||
@@ -187,11 +187,11 @@ func parseTemplateValue(rsrFlds utils.RSRFields, acnt *Account, action *Action)
|
||||
case "BalanceUUID":
|
||||
parsedValue += rsrFld.ParseValue(b.Uuid)
|
||||
case "BalanceID":
|
||||
parsedValue += rsrFld.ParseValue(b.Id)
|
||||
parsedValue += rsrFld.ParseValue(b.ID)
|
||||
case "BalanceValue":
|
||||
parsedValue += rsrFld.ParseValue(strconv.FormatFloat(b.GetValue(), 'f', -1, 64))
|
||||
case "DestinationIDs":
|
||||
parsedValue += rsrFld.ParseValue(b.DestinationIds.String())
|
||||
parsedValue += rsrFld.ParseValue(b.DestinationIDs.String())
|
||||
case "ExtraParameters":
|
||||
parsedValue += rsrFld.ParseValue(action.ExtraParameters)
|
||||
case "RatingSubject":
|
||||
@@ -497,7 +497,7 @@ func setddestinations(ub *Account, sq *StatsQueueTriggered, a *Action, acs Actio
|
||||
var ddcDestId string
|
||||
for _, bchain := range ub.BalanceMap {
|
||||
for _, b := range bchain {
|
||||
for destId := range b.DestinationIds {
|
||||
for destId := range b.DestinationIDs {
|
||||
if strings.HasPrefix(destId, "*ddc") {
|
||||
ddcDestId = destId
|
||||
break
|
||||
@@ -622,7 +622,7 @@ func transferMonetaryDefaultAction(acc *Account, sq *StatsQueueTriggered, a *Act
|
||||
bChain := acc.BalanceMap[utils.MONETARY]
|
||||
for _, balance := range bChain {
|
||||
if balance.Uuid != defaultBalance.Uuid &&
|
||||
balance.Id != defaultBalance.Id && // extra caution
|
||||
balance.ID != defaultBalance.ID && // extra caution
|
||||
balance.MatchFilter(a.Balance, false) {
|
||||
if balance.Value > 0 {
|
||||
defaultBalance.Value += balance.Value
|
||||
|
||||
@@ -142,7 +142,7 @@ func (at *ActionTrigger) Match(a *Action) bool {
|
||||
|
||||
func (at *ActionTrigger) CreateBalance() *Balance {
|
||||
b := at.Balance.CreateBalance()
|
||||
b.Id = at.UniqueID
|
||||
b.ID = at.UniqueID
|
||||
return b
|
||||
}
|
||||
|
||||
|
||||
@@ -693,7 +693,7 @@ func TestActionTriggers(t *testing.T) {
|
||||
func TestActionResetTriggres(t *testing.T) {
|
||||
ub := &Account{
|
||||
Id: "TEST_UB",
|
||||
BalanceMap: map[string]BalanceChain{utils.MONETARY: BalanceChain{&Balance{Value: 10}}, utils.VOICE: BalanceChain{&Balance{Value: 10, Weight: 20, DestinationIds: utils.NewStringMap("NAT")}, &Balance{Weight: 10, DestinationIds: utils.NewStringMap("RET")}}},
|
||||
BalanceMap: map[string]BalanceChain{utils.MONETARY: BalanceChain{&Balance{Value: 10}}, utils.VOICE: BalanceChain{&Balance{Value: 10, Weight: 20, DestinationIDs: utils.NewStringMap("NAT")}, &Balance{Weight: 10, DestinationIDs: utils.NewStringMap("RET")}}},
|
||||
UnitCounters: UnitCounters{utils.MONETARY: []*UnitCounter{&UnitCounter{Counters: CounterFilters{&CounterFilter{Value: 1}}}}},
|
||||
ActionTriggers: ActionTriggers{&ActionTrigger{Balance: &BalanceFilter{Type: utils.StringPointer(utils.MONETARY)}, ThresholdValue: 2, ActionsId: "TEST_ACTIONS", Executed: true}, &ActionTrigger{Balance: &BalanceFilter{Type: utils.StringPointer(utils.MONETARY)}, ThresholdValue: 2, ActionsId: "TEST_ACTIONS", Executed: true}},
|
||||
}
|
||||
@@ -719,7 +719,7 @@ func TestActionResetTriggresExecutesThem(t *testing.T) {
|
||||
func TestActionResetTriggresActionFilter(t *testing.T) {
|
||||
ub := &Account{
|
||||
Id: "TEST_UB",
|
||||
BalanceMap: map[string]BalanceChain{utils.MONETARY: BalanceChain{&Balance{Value: 10}}, utils.VOICE: BalanceChain{&Balance{Value: 10, Weight: 20, DestinationIds: utils.NewStringMap("NAT")}, &Balance{Weight: 10, DestinationIds: utils.NewStringMap("RET")}}},
|
||||
BalanceMap: map[string]BalanceChain{utils.MONETARY: BalanceChain{&Balance{Value: 10}}, utils.VOICE: BalanceChain{&Balance{Value: 10, Weight: 20, DestinationIDs: utils.NewStringMap("NAT")}, &Balance{Weight: 10, DestinationIDs: utils.NewStringMap("RET")}}},
|
||||
UnitCounters: UnitCounters{utils.MONETARY: []*UnitCounter{&UnitCounter{Counters: CounterFilters{&CounterFilter{Value: 1}}}}},
|
||||
ActionTriggers: ActionTriggers{&ActionTrigger{Balance: &BalanceFilter{Type: utils.StringPointer(utils.MONETARY)}, ThresholdValue: 2, ActionsId: "TEST_ACTIONS", Executed: true}, &ActionTrigger{Balance: &BalanceFilter{Type: utils.StringPointer(utils.MONETARY)}, ThresholdValue: 2, ActionsId: "TEST_ACTIONS", Executed: true}},
|
||||
}
|
||||
@@ -732,7 +732,7 @@ func TestActionResetTriggresActionFilter(t *testing.T) {
|
||||
func TestActionSetPostpaid(t *testing.T) {
|
||||
ub := &Account{
|
||||
Id: "TEST_UB",
|
||||
BalanceMap: map[string]BalanceChain{utils.MONETARY: BalanceChain{&Balance{Value: 100}}, utils.VOICE: BalanceChain{&Balance{Value: 10, Weight: 20, DestinationIds: utils.NewStringMap("NAT")}, &Balance{Weight: 10, DestinationIds: utils.NewStringMap("RET")}}},
|
||||
BalanceMap: map[string]BalanceChain{utils.MONETARY: BalanceChain{&Balance{Value: 100}}, utils.VOICE: BalanceChain{&Balance{Value: 10, Weight: 20, DestinationIDs: utils.NewStringMap("NAT")}, &Balance{Weight: 10, DestinationIDs: utils.NewStringMap("RET")}}},
|
||||
UnitCounters: UnitCounters{utils.MONETARY: []*UnitCounter{&UnitCounter{Counters: CounterFilters{&CounterFilter{Value: 1}}}}},
|
||||
ActionTriggers: ActionTriggers{&ActionTrigger{Balance: &BalanceFilter{Type: utils.StringPointer(utils.MONETARY)}, ThresholdValue: 2, ActionsId: "TEST_ACTIONS", Executed: true}, &ActionTrigger{Balance: &BalanceFilter{Type: utils.StringPointer(utils.MONETARY)}, ThresholdValue: 2, ActionsId: "TEST_ACTIONS", Executed: true}},
|
||||
}
|
||||
@@ -746,7 +746,7 @@ func TestActionSetPrepaid(t *testing.T) {
|
||||
ub := &Account{
|
||||
Id: "TEST_UB",
|
||||
AllowNegative: true,
|
||||
BalanceMap: map[string]BalanceChain{utils.MONETARY: BalanceChain{&Balance{Value: 100}}, utils.VOICE: BalanceChain{&Balance{Value: 10, Weight: 20, DestinationIds: utils.NewStringMap("NAT")}, &Balance{Weight: 10, DestinationIds: utils.NewStringMap("RET")}}},
|
||||
BalanceMap: map[string]BalanceChain{utils.MONETARY: BalanceChain{&Balance{Value: 100}}, utils.VOICE: BalanceChain{&Balance{Value: 10, Weight: 20, DestinationIDs: utils.NewStringMap("NAT")}, &Balance{Weight: 10, DestinationIDs: utils.NewStringMap("RET")}}},
|
||||
UnitCounters: UnitCounters{utils.MONETARY: []*UnitCounter{&UnitCounter{Counters: CounterFilters{&CounterFilter{Value: 1}}}}},
|
||||
ActionTriggers: ActionTriggers{&ActionTrigger{Balance: &BalanceFilter{Type: utils.StringPointer(utils.MONETARY)}, ThresholdValue: 2, ActionsId: "TEST_ACTIONS", Executed: true}, &ActionTrigger{Balance: &BalanceFilter{Type: utils.StringPointer(utils.MONETARY)}, ThresholdValue: 2, ActionsId: "TEST_ACTIONS", Executed: true}},
|
||||
}
|
||||
@@ -760,7 +760,7 @@ func TestActionResetPrepaid(t *testing.T) {
|
||||
ub := &Account{
|
||||
Id: "TEST_UB",
|
||||
AllowNegative: true,
|
||||
BalanceMap: map[string]BalanceChain{utils.MONETARY: BalanceChain{&Balance{Value: 100}}, utils.VOICE: BalanceChain{&Balance{Value: 10, Weight: 20, DestinationIds: utils.NewStringMap("NAT")}, &Balance{Weight: 10, DestinationIds: utils.NewStringMap("RET")}}},
|
||||
BalanceMap: map[string]BalanceChain{utils.MONETARY: BalanceChain{&Balance{Value: 100}}, utils.VOICE: BalanceChain{&Balance{Value: 10, Weight: 20, DestinationIDs: utils.NewStringMap("NAT")}, &Balance{Weight: 10, DestinationIDs: utils.NewStringMap("RET")}}},
|
||||
UnitCounters: UnitCounters{utils.MONETARY: []*UnitCounter{&UnitCounter{Counters: CounterFilters{&CounterFilter{Value: 1}}}}},
|
||||
ActionTriggers: ActionTriggers{&ActionTrigger{Balance: &BalanceFilter{Type: utils.StringPointer(utils.SMS)}, ThresholdValue: 2, ActionsId: "TEST_ACTIONS", Executed: true}, &ActionTrigger{Balance: &BalanceFilter{Type: utils.StringPointer(utils.SMS)}, ThresholdValue: 2, ActionsId: "TEST_ACTIONS", Executed: true}},
|
||||
}
|
||||
@@ -778,7 +778,7 @@ func TestActionResetPrepaid(t *testing.T) {
|
||||
func TestActionResetPostpaid(t *testing.T) {
|
||||
ub := &Account{
|
||||
Id: "TEST_UB",
|
||||
BalanceMap: map[string]BalanceChain{utils.MONETARY: BalanceChain{&Balance{Value: 100}}, utils.VOICE: BalanceChain{&Balance{Value: 10, Weight: 20, DestinationIds: utils.NewStringMap("NAT")}, &Balance{Weight: 10, DestinationIds: utils.NewStringMap("RET")}}},
|
||||
BalanceMap: map[string]BalanceChain{utils.MONETARY: BalanceChain{&Balance{Value: 100}}, utils.VOICE: BalanceChain{&Balance{Value: 10, Weight: 20, DestinationIDs: utils.NewStringMap("NAT")}, &Balance{Weight: 10, DestinationIDs: utils.NewStringMap("RET")}}},
|
||||
UnitCounters: UnitCounters{utils.MONETARY: []*UnitCounter{&UnitCounter{Counters: CounterFilters{&CounterFilter{Value: 1}}}}},
|
||||
ActionTriggers: ActionTriggers{&ActionTrigger{Balance: &BalanceFilter{Type: utils.StringPointer(utils.SMS)}, ThresholdValue: 2, ActionsId: "TEST_ACTIONS", Executed: true}, &ActionTrigger{Balance: &BalanceFilter{Type: utils.StringPointer(utils.SMS)}, ThresholdValue: 2, ActionsId: "TEST_ACTIONS", Executed: true}},
|
||||
}
|
||||
@@ -794,7 +794,7 @@ func TestActionResetPostpaid(t *testing.T) {
|
||||
func TestActionTopupResetCredit(t *testing.T) {
|
||||
ub := &Account{
|
||||
Id: "TEST_UB",
|
||||
BalanceMap: map[string]BalanceChain{utils.MONETARY: BalanceChain{&Balance{Directions: utils.NewStringMap(utils.OUT), Value: 100}}, utils.VOICE: BalanceChain{&Balance{Value: 10, Weight: 20, DestinationIds: utils.NewStringMap("NAT")}, &Balance{Weight: 10, DestinationIds: utils.NewStringMap("RET")}}},
|
||||
BalanceMap: map[string]BalanceChain{utils.MONETARY: BalanceChain{&Balance{Directions: utils.NewStringMap(utils.OUT), Value: 100}}, utils.VOICE: BalanceChain{&Balance{Value: 10, Weight: 20, DestinationIDs: utils.NewStringMap("NAT")}, &Balance{Weight: 10, DestinationIDs: utils.NewStringMap("RET")}}},
|
||||
UnitCounters: UnitCounters{utils.MONETARY: []*UnitCounter{&UnitCounter{Counters: CounterFilters{&CounterFilter{Value: 1, Filter: &BalanceFilter{Directions: utils.StringMapPointer(utils.NewStringMap(utils.OUT))}}}}}},
|
||||
ActionTriggers: ActionTriggers{&ActionTrigger{Balance: &BalanceFilter{Type: utils.StringPointer(utils.MONETARY), Directions: utils.StringMapPointer(utils.NewStringMap(utils.OUT))}, ThresholdValue: 2, ActionsId: "TEST_ACTIONS", Executed: true}, &ActionTrigger{Balance: &BalanceFilter{Type: utils.StringPointer(utils.MONETARY), Directions: utils.StringMapPointer(utils.NewStringMap(utils.OUT))}, ThresholdValue: 2, ActionsId: "TEST_ACTIONS", Executed: true}},
|
||||
}
|
||||
@@ -834,7 +834,7 @@ func TestActionTopupResetCreditId(t *testing.T) {
|
||||
BalanceMap: map[string]BalanceChain{
|
||||
utils.MONETARY: BalanceChain{
|
||||
&Balance{Value: 100},
|
||||
&Balance{Id: "TEST_B", Value: 15},
|
||||
&Balance{ID: "TEST_B", Value: 15},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -853,7 +853,7 @@ func TestActionTopupResetCreditNoId(t *testing.T) {
|
||||
BalanceMap: map[string]BalanceChain{
|
||||
utils.MONETARY: BalanceChain{
|
||||
&Balance{Value: 100, Directions: utils.NewStringMap(utils.OUT)},
|
||||
&Balance{Id: "TEST_B", Value: 15, Directions: utils.NewStringMap(utils.OUT)},
|
||||
&Balance{ID: "TEST_B", Value: 15, Directions: utils.NewStringMap(utils.OUT)},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -871,7 +871,7 @@ func TestActionTopupResetMinutes(t *testing.T) {
|
||||
Id: "TEST_UB",
|
||||
BalanceMap: map[string]BalanceChain{
|
||||
utils.MONETARY: BalanceChain{&Balance{Value: 100}},
|
||||
utils.VOICE: BalanceChain{&Balance{Value: 10, Weight: 20, DestinationIds: utils.NewStringMap("NAT"), Directions: utils.NewStringMap(utils.OUT)}, &Balance{Weight: 10, DestinationIds: utils.NewStringMap("RET")}}},
|
||||
utils.VOICE: BalanceChain{&Balance{Value: 10, Weight: 20, DestinationIDs: utils.NewStringMap("NAT"), Directions: utils.NewStringMap(utils.OUT)}, &Balance{Weight: 10, DestinationIDs: utils.NewStringMap("RET")}}},
|
||||
UnitCounters: UnitCounters{utils.MONETARY: []*UnitCounter{&UnitCounter{Counters: CounterFilters{&CounterFilter{Value: 1, Filter: &BalanceFilter{Directions: utils.StringMapPointer(utils.NewStringMap(utils.OUT))}}}}}},
|
||||
ActionTriggers: ActionTriggers{&ActionTrigger{Balance: &BalanceFilter{Type: utils.StringPointer(utils.MONETARY), Directions: utils.StringMapPointer(utils.NewStringMap(utils.OUT))}, ThresholdValue: 2, ActionsId: "TEST_ACTIONS", Executed: true}, &ActionTrigger{Balance: &BalanceFilter{Type: utils.StringPointer(utils.MONETARY), Directions: utils.StringMapPointer(utils.NewStringMap(utils.OUT))}, ThresholdValue: 2, ActionsId: "TEST_ACTIONS", Executed: true}},
|
||||
}
|
||||
@@ -890,7 +890,7 @@ func TestActionTopupResetMinutes(t *testing.T) {
|
||||
func TestActionTopupCredit(t *testing.T) {
|
||||
ub := &Account{
|
||||
Id: "TEST_UB",
|
||||
BalanceMap: map[string]BalanceChain{utils.MONETARY: BalanceChain{&Balance{Value: 100}}, utils.VOICE: BalanceChain{&Balance{Value: 10, Weight: 20, DestinationIds: utils.NewStringMap("NAT"), Directions: utils.NewStringMap(utils.OUT)}, &Balance{Weight: 10, DestinationIds: utils.NewStringMap("RET")}}},
|
||||
BalanceMap: map[string]BalanceChain{utils.MONETARY: BalanceChain{&Balance{Value: 100}}, utils.VOICE: BalanceChain{&Balance{Value: 10, Weight: 20, DestinationIDs: utils.NewStringMap("NAT"), Directions: utils.NewStringMap(utils.OUT)}, &Balance{Weight: 10, DestinationIDs: utils.NewStringMap("RET")}}},
|
||||
UnitCounters: UnitCounters{utils.MONETARY: []*UnitCounter{&UnitCounter{Counters: CounterFilters{&CounterFilter{Value: 1, Filter: &BalanceFilter{Directions: utils.StringMapPointer(utils.NewStringMap(utils.OUT))}}}}}},
|
||||
ActionTriggers: ActionTriggers{&ActionTrigger{Balance: &BalanceFilter{Type: utils.StringPointer(utils.MONETARY), Directions: utils.StringMapPointer(utils.NewStringMap(utils.OUT))}, ThresholdValue: 2, ActionsId: "TEST_ACTIONS", Executed: true}, &ActionTrigger{Balance: &BalanceFilter{Type: utils.StringPointer(utils.MONETARY), Directions: utils.StringMapPointer(utils.NewStringMap(utils.OUT))}, ThresholdValue: 2, ActionsId: "TEST_ACTIONS", Executed: true}},
|
||||
}
|
||||
@@ -908,7 +908,7 @@ func TestActionTopupCredit(t *testing.T) {
|
||||
func TestActionTopupMinutes(t *testing.T) {
|
||||
ub := &Account{
|
||||
Id: "TEST_UB",
|
||||
BalanceMap: map[string]BalanceChain{utils.MONETARY: BalanceChain{&Balance{Value: 100}}, utils.VOICE: BalanceChain{&Balance{Value: 10, Weight: 20, DestinationIds: utils.NewStringMap("NAT"), Directions: utils.NewStringMap(utils.OUT)}, &Balance{Weight: 10, DestinationIds: utils.NewStringMap("RET")}}},
|
||||
BalanceMap: map[string]BalanceChain{utils.MONETARY: BalanceChain{&Balance{Value: 100}}, utils.VOICE: BalanceChain{&Balance{Value: 10, Weight: 20, DestinationIDs: utils.NewStringMap("NAT"), Directions: utils.NewStringMap(utils.OUT)}, &Balance{Weight: 10, DestinationIDs: utils.NewStringMap("RET")}}},
|
||||
UnitCounters: UnitCounters{utils.MONETARY: []*UnitCounter{&UnitCounter{Counters: CounterFilters{&CounterFilter{Value: 1}}}}},
|
||||
ActionTriggers: ActionTriggers{&ActionTrigger{Balance: &BalanceFilter{Type: utils.StringPointer(utils.MONETARY)}, ThresholdValue: 2, ActionsId: "TEST_ACTIONS", Executed: true}, &ActionTrigger{Balance: &BalanceFilter{Type: utils.StringPointer(utils.MONETARY)}, ThresholdValue: 2, ActionsId: "TEST_ACTIONS", Executed: true}},
|
||||
}
|
||||
@@ -927,7 +927,7 @@ func TestActionTopupMinutes(t *testing.T) {
|
||||
func TestActionDebitCredit(t *testing.T) {
|
||||
ub := &Account{
|
||||
Id: "TEST_UB",
|
||||
BalanceMap: map[string]BalanceChain{utils.MONETARY: BalanceChain{&Balance{Value: 100}}, utils.VOICE: BalanceChain{&Balance{Value: 10, Weight: 20, DestinationIds: utils.NewStringMap("NAT")}, &Balance{Weight: 10, DestinationIds: utils.NewStringMap("RET")}}},
|
||||
BalanceMap: map[string]BalanceChain{utils.MONETARY: BalanceChain{&Balance{Value: 100}}, utils.VOICE: BalanceChain{&Balance{Value: 10, Weight: 20, DestinationIDs: utils.NewStringMap("NAT")}, &Balance{Weight: 10, DestinationIDs: utils.NewStringMap("RET")}}},
|
||||
UnitCounters: UnitCounters{utils.MONETARY: []*UnitCounter{&UnitCounter{Counters: CounterFilters{&CounterFilter{Value: 1, Filter: &BalanceFilter{Directions: utils.StringMapPointer(utils.NewStringMap(utils.OUT))}}}}}},
|
||||
ActionTriggers: ActionTriggers{&ActionTrigger{Balance: &BalanceFilter{Type: utils.StringPointer(utils.MONETARY), Directions: utils.StringMapPointer(utils.NewStringMap(utils.OUT))}, ThresholdValue: 2, ActionsId: "TEST_ACTIONS", Executed: true}, &ActionTrigger{Balance: &BalanceFilter{Type: utils.StringPointer(utils.MONETARY), Directions: utils.StringMapPointer(utils.NewStringMap(utils.OUT))}, ThresholdValue: 2, ActionsId: "TEST_ACTIONS", Executed: true}},
|
||||
}
|
||||
@@ -945,7 +945,7 @@ func TestActionDebitCredit(t *testing.T) {
|
||||
func TestActionDebitMinutes(t *testing.T) {
|
||||
ub := &Account{
|
||||
Id: "TEST_UB",
|
||||
BalanceMap: map[string]BalanceChain{utils.MONETARY: BalanceChain{&Balance{Value: 100}}, utils.VOICE: BalanceChain{&Balance{Value: 10, Weight: 20, DestinationIds: utils.NewStringMap("NAT"), Directions: utils.NewStringMap(utils.OUT)}, &Balance{Weight: 10, DestinationIds: utils.NewStringMap("RET")}}},
|
||||
BalanceMap: map[string]BalanceChain{utils.MONETARY: BalanceChain{&Balance{Value: 100}}, utils.VOICE: BalanceChain{&Balance{Value: 10, Weight: 20, DestinationIDs: utils.NewStringMap("NAT"), Directions: utils.NewStringMap(utils.OUT)}, &Balance{Weight: 10, DestinationIDs: utils.NewStringMap("RET")}}},
|
||||
UnitCounters: UnitCounters{utils.MONETARY: []*UnitCounter{&UnitCounter{Counters: CounterFilters{&CounterFilter{Value: 1}}}}},
|
||||
ActionTriggers: ActionTriggers{&ActionTrigger{Balance: &BalanceFilter{Type: utils.StringPointer(utils.MONETARY)}, ThresholdValue: 2, ActionsId: "TEST_ACTIONS", Executed: true}, &ActionTrigger{Balance: &BalanceFilter{Type: utils.StringPointer(utils.MONETARY)}, ThresholdValue: 2, ActionsId: "TEST_ACTIONS", Executed: true}},
|
||||
}
|
||||
@@ -968,8 +968,8 @@ func TestActionResetAllCounters(t *testing.T) {
|
||||
BalanceMap: map[string]BalanceChain{
|
||||
utils.MONETARY: BalanceChain{&Balance{Value: 100}},
|
||||
utils.VOICE: BalanceChain{
|
||||
&Balance{Value: 10, Weight: 20, DestinationIds: utils.NewStringMap("NAT"), Directions: utils.NewStringMap(utils.OUT)},
|
||||
&Balance{Weight: 10, DestinationIds: utils.NewStringMap("RET"), Directions: utils.NewStringMap(utils.OUT)}}},
|
||||
&Balance{Value: 10, Weight: 20, DestinationIDs: utils.NewStringMap("NAT"), Directions: utils.NewStringMap(utils.OUT)},
|
||||
&Balance{Weight: 10, DestinationIDs: utils.NewStringMap("RET"), Directions: utils.NewStringMap(utils.OUT)}}},
|
||||
|
||||
ActionTriggers: ActionTriggers{&ActionTrigger{ThresholdType: utils.TRIGGER_MAX_EVENT_COUNTER, ThresholdValue: 2, Balance: &BalanceFilter{Type: utils.StringPointer(utils.MONETARY), DestinationIDs: utils.StringMapPointer(utils.NewStringMap("NAT")), Weight: utils.Float64Pointer(20)}, ActionsId: "TEST_ACTIONS", Executed: true}},
|
||||
}
|
||||
@@ -998,7 +998,7 @@ func TestActionResetCounterOnlyDefault(t *testing.T) {
|
||||
AllowNegative: true,
|
||||
BalanceMap: map[string]BalanceChain{
|
||||
utils.MONETARY: BalanceChain{&Balance{Value: 100}},
|
||||
utils.VOICE: BalanceChain{&Balance{Value: 10, Weight: 20, DestinationIds: utils.NewStringMap("NAT")}, &Balance{Weight: 10, DestinationIds: utils.NewStringMap("RET")}}},
|
||||
utils.VOICE: BalanceChain{&Balance{Value: 10, Weight: 20, DestinationIDs: utils.NewStringMap("NAT")}, &Balance{Weight: 10, DestinationIDs: utils.NewStringMap("RET")}}},
|
||||
ActionTriggers: ActionTriggers{&ActionTrigger{Balance: &BalanceFilter{Type: utils.StringPointer(utils.MONETARY)}, ThresholdType: utils.TRIGGER_MAX_EVENT_COUNTER, ThresholdValue: 2, ActionsId: "TEST_ACTIONS", Executed: true}},
|
||||
}
|
||||
a := &Action{Balance: &BalanceFilter{Type: utils.StringPointer(utils.MONETARY)}}
|
||||
@@ -1028,7 +1028,7 @@ func TestActionResetCounterCredit(t *testing.T) {
|
||||
ub := &Account{
|
||||
Id: "TEST_UB",
|
||||
AllowNegative: true,
|
||||
BalanceMap: map[string]BalanceChain{utils.MONETARY: BalanceChain{&Balance{Value: 100}}, utils.VOICE: BalanceChain{&Balance{Value: 10, Weight: 20, DestinationIds: utils.NewStringMap("NAT")}, &Balance{Weight: 10, DestinationIds: utils.NewStringMap("RET")}}},
|
||||
BalanceMap: map[string]BalanceChain{utils.MONETARY: BalanceChain{&Balance{Value: 100}}, utils.VOICE: BalanceChain{&Balance{Value: 10, Weight: 20, DestinationIDs: utils.NewStringMap("NAT")}, &Balance{Weight: 10, DestinationIDs: utils.NewStringMap("RET")}}},
|
||||
UnitCounters: UnitCounters{utils.MONETARY: []*UnitCounter{&UnitCounter{Counters: CounterFilters{&CounterFilter{Value: 1, Filter: &BalanceFilter{Directions: utils.StringMapPointer(utils.NewStringMap(utils.OUT))}}}}}, utils.SMS: []*UnitCounter{&UnitCounter{Counters: CounterFilters{&CounterFilter{Value: 1, Filter: &BalanceFilter{Directions: utils.StringMapPointer(utils.NewStringMap(utils.OUT))}}}}}},
|
||||
ActionTriggers: ActionTriggers{&ActionTrigger{Balance: &BalanceFilter{Type: utils.StringPointer(utils.MONETARY), Directions: utils.StringMapPointer(utils.NewStringMap(utils.OUT))}, ThresholdValue: 2, ActionsId: "TEST_ACTIONS", Executed: true}},
|
||||
}
|
||||
@@ -1274,7 +1274,7 @@ func TestActionCdrLogParamsWithOverload(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestActionSetDDestination(t *testing.T) {
|
||||
acc := &Account{BalanceMap: map[string]BalanceChain{utils.MONETARY: BalanceChain{&Balance{DestinationIds: utils.NewStringMap("*ddc_test")}}}}
|
||||
acc := &Account{BalanceMap: map[string]BalanceChain{utils.MONETARY: BalanceChain{&Balance{DestinationIDs: utils.NewStringMap("*ddc_test")}}}}
|
||||
origD := &Destination{Id: "*ddc_test", Prefixes: []string{"111", "222"}}
|
||||
ratingStorage.SetDestination(origD)
|
||||
ratingStorage.CacheRatingPrefixValues(map[string][]string{utils.DESTINATION_PREFIX: []string{utils.DESTINATION_PREFIX + "*ddc_test"}})
|
||||
@@ -1478,12 +1478,12 @@ func TestActionRemoveBalance(t *testing.T) {
|
||||
},
|
||||
&Balance{
|
||||
Value: 10,
|
||||
DestinationIds: utils.NewStringMap("NAT", "RET"),
|
||||
DestinationIDs: utils.NewStringMap("NAT", "RET"),
|
||||
ExpirationDate: time.Date(2025, time.November, 11, 22, 39, 0, 0, time.UTC),
|
||||
},
|
||||
&Balance{
|
||||
Value: 10,
|
||||
DestinationIds: utils.NewStringMap("NAT", "RET"),
|
||||
DestinationIDs: utils.NewStringMap("NAT", "RET"),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -1523,7 +1523,7 @@ func TestActionTransferMonetaryDefault(t *testing.T) {
|
||||
utils.MONETARY: BalanceChain{
|
||||
&Balance{
|
||||
Uuid: utils.GenUUID(),
|
||||
Id: utils.META_DEFAULT,
|
||||
ID: utils.META_DEFAULT,
|
||||
Value: 10,
|
||||
},
|
||||
&Balance{
|
||||
@@ -1579,7 +1579,7 @@ func TestActionTransferMonetaryDefaultFilter(t *testing.T) {
|
||||
utils.MONETARY: BalanceChain{
|
||||
&Balance{
|
||||
Uuid: utils.GenUUID(),
|
||||
Id: utils.META_DEFAULT,
|
||||
ID: utils.META_DEFAULT,
|
||||
Value: 10,
|
||||
Weight: 20,
|
||||
},
|
||||
@@ -1640,7 +1640,7 @@ func TestActionConditionalTopup(t *testing.T) {
|
||||
utils.MONETARY: BalanceChain{
|
||||
&Balance{
|
||||
Uuid: utils.GenUUID(),
|
||||
Id: utils.META_DEFAULT,
|
||||
ID: utils.META_DEFAULT,
|
||||
Value: 10,
|
||||
Weight: 20,
|
||||
},
|
||||
@@ -1704,7 +1704,7 @@ func TestActionConditionalTopupNoMatch(t *testing.T) {
|
||||
utils.MONETARY: BalanceChain{
|
||||
&Balance{
|
||||
Uuid: utils.GenUUID(),
|
||||
Id: utils.META_DEFAULT,
|
||||
ID: utils.META_DEFAULT,
|
||||
Value: 10,
|
||||
Weight: 20,
|
||||
},
|
||||
@@ -1831,7 +1831,7 @@ func TestActionConditionalDisabledIfNegative(t *testing.T) {
|
||||
"*data": BalanceChain{
|
||||
&Balance{
|
||||
Uuid: "fc927edb-1bd6-425e-a2a3-9fd8bafaa524",
|
||||
Id: "for_v3hsillmilld500m_data_500_m",
|
||||
ID: "for_v3hsillmilld500m_data_500_m",
|
||||
Value: 5.242,
|
||||
Weight: 10,
|
||||
RatingSubject: "for_v3hsillmilld500m_data_forfait",
|
||||
@@ -1843,17 +1843,17 @@ func TestActionConditionalDisabledIfNegative(t *testing.T) {
|
||||
"*monetary": BalanceChain{
|
||||
&Balance{
|
||||
Uuid: "9fa1847a-f36a-41a7-8ec0-dfaab370141e",
|
||||
Id: "*default",
|
||||
ID: "*default",
|
||||
Value: -1.95001,
|
||||
},
|
||||
},
|
||||
"*sms": BalanceChain{
|
||||
&Balance{
|
||||
Uuid: "d348d15d-2988-4ee4-b847-6a552f94e2ec",
|
||||
Id: "for_v3hsillmilld500m_mms_ill",
|
||||
ID: "for_v3hsillmilld500m_mms_ill",
|
||||
Value: 20000,
|
||||
Weight: 10,
|
||||
DestinationIds: utils.StringMap{
|
||||
DestinationIDs: utils.StringMap{
|
||||
"FRANCE_NATIONAL": true,
|
||||
},
|
||||
Categories: utils.StringMap{
|
||||
@@ -1864,10 +1864,10 @@ func TestActionConditionalDisabledIfNegative(t *testing.T) {
|
||||
},
|
||||
&Balance{
|
||||
Uuid: "f4643517-31f6-4199-980f-04cf535471ed",
|
||||
Id: "for_v3hsillmilld500m_sms_ill",
|
||||
ID: "for_v3hsillmilld500m_sms_ill",
|
||||
Value: 20000,
|
||||
Weight: 10,
|
||||
DestinationIds: utils.StringMap{
|
||||
DestinationIDs: utils.StringMap{
|
||||
"FRANCE_NATIONAL": true,
|
||||
},
|
||||
Categories: utils.StringMap{
|
||||
@@ -1878,10 +1878,10 @@ func TestActionConditionalDisabledIfNegative(t *testing.T) {
|
||||
"*voice": BalanceChain{
|
||||
&Balance{
|
||||
Uuid: "079ab190-77f4-44f3-9c6f-3a0dd1a59dfd",
|
||||
Id: "for_v3hsillmilld500m_voice_3_h",
|
||||
ID: "for_v3hsillmilld500m_voice_3_h",
|
||||
Value: 10800,
|
||||
Weight: 10,
|
||||
DestinationIds: utils.StringMap{
|
||||
DestinationIDs: utils.StringMap{
|
||||
"FRANCE_NATIONAL": true,
|
||||
},
|
||||
Categories: utils.StringMap{
|
||||
@@ -1897,7 +1897,7 @@ func TestActionConditionalDisabledIfNegative(t *testing.T) {
|
||||
|
||||
a1 := &Action{
|
||||
ActionType: "*set_balance",
|
||||
Filter: "{\"*and\":[{\"Value\":{\"*lt\":0}},{\"Id\":{\"*eq\":\"*default\"}}]}",
|
||||
Filter: "{\"*and\":[{\"Value\":{\"*lt\":0}},{\"ID\":{\"*eq\":\"*default\"}}]}",
|
||||
Balance: &BalanceFilter{
|
||||
Type: utils.StringPointer("*sms"),
|
||||
ID: utils.StringPointer("for_v3hsillmilld500m_sms_ill"),
|
||||
@@ -1907,7 +1907,7 @@ func TestActionConditionalDisabledIfNegative(t *testing.T) {
|
||||
}
|
||||
a2 := &Action{
|
||||
ActionType: "*set_balance",
|
||||
Filter: "{\"*and\":[{\"Value\":{\"*lt\":0}},{\"Id\":{\"*eq\":\"*default\"}}]}",
|
||||
Filter: "{\"*and\":[{\"Value\":{\"*lt\":0}},{\"ID\":{\"*eq\":\"*default\"}}]}",
|
||||
Balance: &BalanceFilter{
|
||||
Type: utils.StringPointer("*sms"),
|
||||
ID: utils.StringPointer("for_v3hsillmilld500m_mms_ill"),
|
||||
@@ -1919,7 +1919,7 @@ func TestActionConditionalDisabledIfNegative(t *testing.T) {
|
||||
}
|
||||
a3 := &Action{
|
||||
ActionType: "*set_balance",
|
||||
Filter: "{\"*and\":[{\"Value\":{\"*lt\":0}},{\"Id\":{\"*eq\":\"*default\"}}]}",
|
||||
Filter: "{\"*and\":[{\"Value\":{\"*lt\":0}},{\"ID\":{\"*eq\":\"*default\"}}]}",
|
||||
Balance: &BalanceFilter{
|
||||
Type: utils.StringPointer("*sms"),
|
||||
ID: utils.StringPointer("for_v3hsillmilld500m_sms_ill"),
|
||||
@@ -1931,7 +1931,7 @@ func TestActionConditionalDisabledIfNegative(t *testing.T) {
|
||||
}
|
||||
a4 := &Action{
|
||||
ActionType: "*set_balance",
|
||||
Filter: "{\"*and\":[{\"Value\":{\"*lt\":0}},{\"Id\":{\"*eq\":\"*default\"}}]}",
|
||||
Filter: "{\"*and\":[{\"Value\":{\"*lt\":0}},{\"ID\":{\"*eq\":\"*default\"}}]}",
|
||||
Balance: &BalanceFilter{
|
||||
Type: utils.StringPointer("*data"),
|
||||
Uuid: utils.StringPointer("fc927edb-1bd6-425e-a2a3-9fd8bafaa524"),
|
||||
@@ -1943,7 +1943,7 @@ func TestActionConditionalDisabledIfNegative(t *testing.T) {
|
||||
}
|
||||
a5 := &Action{
|
||||
ActionType: "*set_balance",
|
||||
Filter: "{\"*and\":[{\"Value\":{\"*lt\":0}},{\"Id\":{\"*eq\":\"*default\"}}]}",
|
||||
Filter: "{\"*and\":[{\"Value\":{\"*lt\":0}},{\"ID\":{\"*eq\":\"*default\"}}]}",
|
||||
Balance: &BalanceFilter{
|
||||
Type: utils.StringPointer("*voice"),
|
||||
ID: utils.StringPointer("for_v3hsillmilld500m_voice_3_h"),
|
||||
@@ -1983,13 +1983,13 @@ func TestActionSetBalance(t *testing.T) {
|
||||
BalanceMap: map[string]BalanceChain{
|
||||
utils.MONETARY: BalanceChain{
|
||||
&Balance{
|
||||
Id: "m1",
|
||||
ID: "m1",
|
||||
Uuid: utils.GenUUID(),
|
||||
Value: 1,
|
||||
Weight: 10,
|
||||
},
|
||||
&Balance{
|
||||
Id: "m2",
|
||||
ID: "m2",
|
||||
Uuid: utils.GenUUID(),
|
||||
Value: 6,
|
||||
Weight: 20,
|
||||
@@ -1997,13 +1997,13 @@ func TestActionSetBalance(t *testing.T) {
|
||||
},
|
||||
utils.VOICE: BalanceChain{
|
||||
&Balance{
|
||||
Id: "v1",
|
||||
ID: "v1",
|
||||
Uuid: utils.GenUUID(),
|
||||
Value: 10,
|
||||
Weight: 10,
|
||||
},
|
||||
&Balance{
|
||||
Id: "v2",
|
||||
ID: "v2",
|
||||
Uuid: utils.GenUUID(),
|
||||
Value: 100,
|
||||
Weight: 20,
|
||||
|
||||
@@ -29,12 +29,12 @@ type BalanceFilter struct {
|
||||
func (bp *BalanceFilter) CreateBalance() *Balance {
|
||||
b := &Balance{
|
||||
Uuid: bp.GetUuid(),
|
||||
Id: bp.GetID(),
|
||||
ID: bp.GetID(),
|
||||
Value: bp.GetValue(),
|
||||
Directions: bp.GetDirections(),
|
||||
ExpirationDate: bp.GetExpirationDate(),
|
||||
Weight: bp.GetWeight(),
|
||||
DestinationIds: bp.GetDestinationIDs(),
|
||||
DestinationIDs: bp.GetDestinationIDs(),
|
||||
RatingSubject: bp.GetRatingSubject(),
|
||||
Categories: bp.GetCategories(),
|
||||
SharedGroups: bp.GetSharedGroups(),
|
||||
@@ -112,8 +112,8 @@ func (bp *BalanceFilter) LoadFromBalance(b *Balance) *BalanceFilter {
|
||||
if b.Uuid != "" {
|
||||
bp.Uuid = &b.Uuid
|
||||
}
|
||||
if b.Id != "" {
|
||||
bp.ID = &b.Id
|
||||
if b.ID != "" {
|
||||
bp.ID = &b.ID
|
||||
}
|
||||
if b.Value != 0 {
|
||||
bp.Value = &b.Value
|
||||
@@ -127,8 +127,8 @@ func (bp *BalanceFilter) LoadFromBalance(b *Balance) *BalanceFilter {
|
||||
if b.Weight != 0 {
|
||||
bp.Weight = &b.Weight
|
||||
}
|
||||
if len(b.DestinationIds) != 0 {
|
||||
bp.DestinationIDs = &b.DestinationIds
|
||||
if len(b.DestinationIDs) != 0 {
|
||||
bp.DestinationIDs = &b.DestinationIDs
|
||||
}
|
||||
if b.RatingSubject != "" {
|
||||
bp.RatingSubject = &b.RatingSubject
|
||||
@@ -300,7 +300,7 @@ func (bf *BalanceFilter) ModifyBalance(b *Balance) {
|
||||
b.Categories = *bf.Categories
|
||||
}
|
||||
if bf.DestinationIDs != nil {
|
||||
b.DestinationIds = *bf.DestinationIDs
|
||||
b.DestinationIDs = *bf.DestinationIDs
|
||||
}
|
||||
if bf.SharedGroups != nil {
|
||||
b.SharedGroups = *bf.SharedGroups
|
||||
|
||||
@@ -33,12 +33,12 @@ import (
|
||||
// Can hold different units as seconds or monetary
|
||||
type Balance struct {
|
||||
Uuid string //system wide unique
|
||||
Id string // account wide unique
|
||||
ID string // account wide unique
|
||||
Value float64
|
||||
Directions utils.StringMap
|
||||
ExpirationDate time.Time
|
||||
Weight float64
|
||||
DestinationIds utils.StringMap
|
||||
DestinationIDs utils.StringMap
|
||||
RatingSubject string
|
||||
Categories utils.StringMap
|
||||
SharedGroups utils.StringMap
|
||||
@@ -53,17 +53,17 @@ type Balance struct {
|
||||
}
|
||||
|
||||
func (b *Balance) Equal(o *Balance) bool {
|
||||
if len(b.DestinationIds) == 0 {
|
||||
b.DestinationIds = utils.StringMap{utils.ANY: true}
|
||||
if len(b.DestinationIDs) == 0 {
|
||||
b.DestinationIDs = utils.StringMap{utils.ANY: true}
|
||||
}
|
||||
if len(o.DestinationIds) == 0 {
|
||||
o.DestinationIds = utils.StringMap{utils.ANY: true}
|
||||
if len(o.DestinationIDs) == 0 {
|
||||
o.DestinationIDs = utils.StringMap{utils.ANY: true}
|
||||
}
|
||||
return b.Uuid == o.Uuid &&
|
||||
b.Id == o.Id &&
|
||||
b.ID == o.ID &&
|
||||
b.ExpirationDate.Equal(o.ExpirationDate) &&
|
||||
b.Weight == o.Weight &&
|
||||
b.DestinationIds.Equal(o.DestinationIds) &&
|
||||
b.DestinationIDs.Equal(o.DestinationIDs) &&
|
||||
b.Directions.Equal(o.Directions) &&
|
||||
b.RatingSubject == o.RatingSubject &&
|
||||
b.Categories.Equal(o.Categories) &&
|
||||
@@ -80,13 +80,13 @@ func (b *Balance) MatchFilter(o *BalanceFilter, skipIds bool) bool {
|
||||
return b.Uuid == *o.Uuid
|
||||
}
|
||||
if !skipIds && o.ID != nil && *o.ID != "" {
|
||||
return b.Id == *o.ID
|
||||
return b.ID == *o.ID
|
||||
}
|
||||
return (o.ExpirationDate == nil || b.ExpirationDate.Equal(*o.ExpirationDate)) &&
|
||||
(o.Weight == nil || b.Weight == *o.Weight) &&
|
||||
(o.Blocker == nil || b.Blocker == *o.Blocker) &&
|
||||
(o.Disabled == nil || b.Disabled == *o.Disabled) &&
|
||||
(o.DestinationIDs == nil || b.DestinationIds.Includes(*o.DestinationIDs)) &&
|
||||
(o.DestinationIDs == nil || b.DestinationIDs.Includes(*o.DestinationIDs)) &&
|
||||
(o.Directions == nil || b.Directions.Includes(*o.Directions)) &&
|
||||
(o.Categories == nil || b.Categories.Includes(*o.Categories)) &&
|
||||
(o.TimingIDs == nil || b.TimingIDs.Includes(*o.TimingIDs)) &&
|
||||
@@ -102,13 +102,13 @@ func (b *Balance) HardMatchFilter(o *BalanceFilter, skipIds bool) bool {
|
||||
return b.Uuid == *o.Uuid
|
||||
}
|
||||
if !skipIds && o.ID != nil && *o.ID != "" {
|
||||
return b.Id == *o.ID
|
||||
return b.ID == *o.ID
|
||||
}
|
||||
return (o.ExpirationDate == nil || b.ExpirationDate.Equal(*o.ExpirationDate)) &&
|
||||
(o.Weight == nil || b.Weight == *o.Weight) &&
|
||||
(o.Blocker == nil || b.Blocker == *o.Blocker) &&
|
||||
(o.Disabled == nil || b.Disabled == *o.Disabled) &&
|
||||
(o.DestinationIDs == nil || b.DestinationIds.Equal(*o.DestinationIDs)) &&
|
||||
(o.DestinationIDs == nil || b.DestinationIDs.Equal(*o.DestinationIDs)) &&
|
||||
(o.Directions == nil || b.Directions.Equal(*o.Directions)) &&
|
||||
(o.Categories == nil || b.Categories.Equal(*o.Categories)) &&
|
||||
(o.TimingIDs == nil || b.TimingIDs.Equal(*o.TimingIDs)) &&
|
||||
@@ -118,7 +118,7 @@ func (b *Balance) HardMatchFilter(o *BalanceFilter, skipIds bool) bool {
|
||||
|
||||
// the default balance has standard Id
|
||||
func (b *Balance) IsDefault() bool {
|
||||
return b.Id == utils.META_DEFAULT
|
||||
return b.ID == utils.META_DEFAULT
|
||||
}
|
||||
|
||||
func (b *Balance) IsExpired() bool {
|
||||
@@ -150,15 +150,15 @@ func (b *Balance) MatchCategory(category string) bool {
|
||||
}
|
||||
|
||||
func (b *Balance) HasDestination() bool {
|
||||
return len(b.DestinationIds) > 0 && b.DestinationIds[utils.ANY] == false
|
||||
return len(b.DestinationIDs) > 0 && b.DestinationIDs[utils.ANY] == false
|
||||
}
|
||||
|
||||
func (b *Balance) HasDirection() bool {
|
||||
return len(b.Directions) > 0
|
||||
}
|
||||
|
||||
func (b *Balance) MatchDestination(destinationId string) bool {
|
||||
return !b.HasDestination() || b.DestinationIds[destinationId] == true
|
||||
func (b *Balance) MatchDestination(destinationID string) bool {
|
||||
return !b.HasDestination() || b.DestinationIDs[destinationID] == true
|
||||
}
|
||||
|
||||
func (b *Balance) MatchActionTrigger(at *ActionTrigger) bool {
|
||||
@@ -171,7 +171,7 @@ func (b *Balance) Clone() *Balance {
|
||||
}
|
||||
n := &Balance{
|
||||
Uuid: b.Uuid,
|
||||
Id: b.Id,
|
||||
ID: b.ID,
|
||||
Value: b.Value, // this value is in seconds
|
||||
ExpirationDate: b.ExpirationDate,
|
||||
Weight: b.Weight,
|
||||
@@ -184,8 +184,8 @@ func (b *Balance) Clone() *Balance {
|
||||
Disabled: b.Disabled,
|
||||
dirty: b.dirty,
|
||||
}
|
||||
if b.DestinationIds != nil {
|
||||
n.DestinationIds = b.DestinationIds.Clone()
|
||||
if b.DestinationIDs != nil {
|
||||
n.DestinationIDs = b.DestinationIDs.Clone()
|
||||
}
|
||||
if b.Directions != nil {
|
||||
n.Directions = b.Directions.Clone()
|
||||
@@ -193,14 +193,14 @@ func (b *Balance) Clone() *Balance {
|
||||
return n
|
||||
}
|
||||
|
||||
func (b *Balance) getMatchingPrefixAndDestId(dest string) (prefix, destId string) {
|
||||
if len(b.DestinationIds) != 0 && b.DestinationIds[utils.ANY] == false {
|
||||
func (b *Balance) getMatchingPrefixAndDestID(dest string) (prefix, destId string) {
|
||||
if len(b.DestinationIDs) != 0 && b.DestinationIDs[utils.ANY] == false {
|
||||
for _, p := range utils.SplitPrefix(dest, MIN_PREFIX_MATCH) {
|
||||
if x, err := cache2go.Get(utils.DESTINATION_PREFIX + p); err == nil {
|
||||
destIds := x.(map[interface{}]struct{})
|
||||
for dId, _ := range destIds {
|
||||
if b.DestinationIds[dId.(string)] == true {
|
||||
return p, dId.(string)
|
||||
destIDs := x.(map[interface{}]struct{})
|
||||
for dID := range destIDs {
|
||||
if b.DestinationIDs[dID.(string)] == true {
|
||||
return p, dID.(string)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -331,7 +331,7 @@ func (b *Balance) debitUnits(cd *CallDescriptor, ub *Account, moneyBalances Bala
|
||||
},
|
||||
},
|
||||
}
|
||||
prefix, destid := b.getMatchingPrefixAndDestId(cd.Destination)
|
||||
prefix, destid := b.getMatchingPrefixAndDestID(cd.Destination)
|
||||
if prefix == "" {
|
||||
prefix = cd.Destination
|
||||
}
|
||||
@@ -667,11 +667,11 @@ func (bc BalanceChain) SaveDirtyBalances(acc *Account) {
|
||||
Publish(CgrEvent{
|
||||
"EventName": utils.EVT_ACCOUNT_BALANCE_MODIFIED,
|
||||
"Uuid": b.Uuid,
|
||||
"Id": b.Id,
|
||||
"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.String(),
|
||||
"DestinationIDs": b.DestinationIDs.String(),
|
||||
"Directions": b.Directions.String(),
|
||||
"RatingSubject": b.RatingSubject,
|
||||
"Categories": b.Categories.String(),
|
||||
|
||||
@@ -80,16 +80,16 @@ func TestBalanceSortWeightLess(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestBalanceEqual(t *testing.T) {
|
||||
mb1 := &Balance{Weight: 1, precision: 1, RatingSubject: "1", DestinationIds: utils.StringMap{}}
|
||||
mb2 := &Balance{Weight: 1, precision: 1, RatingSubject: "1", DestinationIds: utils.StringMap{}}
|
||||
mb3 := &Balance{Weight: 1, precision: 1, RatingSubject: "2", DestinationIds: utils.StringMap{}}
|
||||
mb1 := &Balance{Weight: 1, precision: 1, RatingSubject: "1", DestinationIDs: utils.StringMap{}}
|
||||
mb2 := &Balance{Weight: 1, precision: 1, RatingSubject: "1", DestinationIDs: utils.StringMap{}}
|
||||
mb3 := &Balance{Weight: 1, precision: 1, RatingSubject: "2", DestinationIDs: utils.StringMap{}}
|
||||
if !mb1.Equal(mb2) || mb2.Equal(mb3) {
|
||||
t.Error("Equal failure!", mb1 == mb2, mb3)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBalanceMatchFilter(t *testing.T) {
|
||||
mb1 := &Balance{Weight: 1, precision: 1, RatingSubject: "1", DestinationIds: utils.StringMap{}}
|
||||
mb1 := &Balance{Weight: 1, precision: 1, RatingSubject: "1", DestinationIDs: utils.StringMap{}}
|
||||
mb2 := &BalanceFilter{Weight: utils.Float64Pointer(1), RatingSubject: nil, DestinationIDs: nil}
|
||||
if !mb1.MatchFilter(mb2, false) {
|
||||
t.Errorf("Match filter failure: %+v == %+v", mb1, mb2)
|
||||
@@ -97,7 +97,7 @@ func TestBalanceMatchFilter(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestBalanceMatchFilterEmpty(t *testing.T) {
|
||||
mb1 := &Balance{Weight: 1, precision: 1, RatingSubject: "1", DestinationIds: utils.StringMap{}}
|
||||
mb1 := &Balance{Weight: 1, precision: 1, RatingSubject: "1", DestinationIDs: utils.StringMap{}}
|
||||
mb2 := &BalanceFilter{}
|
||||
if !mb1.MatchFilter(mb2, false) {
|
||||
t.Errorf("Match filter failure: %+v == %+v", mb1, mb2)
|
||||
@@ -105,7 +105,7 @@ func TestBalanceMatchFilterEmpty(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestBalanceMatchFilterId(t *testing.T) {
|
||||
mb1 := &Balance{Id: "T1", Weight: 2, precision: 2, RatingSubject: "2", DestinationIds: utils.NewStringMap("NAT")}
|
||||
mb1 := &Balance{ID: "T1", Weight: 2, precision: 2, RatingSubject: "2", DestinationIDs: utils.NewStringMap("NAT")}
|
||||
mb2 := &BalanceFilter{ID: utils.StringPointer("T1"), Weight: utils.Float64Pointer(1), RatingSubject: utils.StringPointer("1"), DestinationIDs: nil}
|
||||
if !mb1.MatchFilter(mb2, false) {
|
||||
t.Errorf("Match filter failure: %+v == %+v", mb1, mb2)
|
||||
@@ -113,7 +113,7 @@ func TestBalanceMatchFilterId(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestBalanceMatchFilterDiffId(t *testing.T) {
|
||||
mb1 := &Balance{Id: "T1", Weight: 1, precision: 1, RatingSubject: "1", DestinationIds: utils.StringMap{}}
|
||||
mb1 := &Balance{ID: "T1", Weight: 1, precision: 1, RatingSubject: "1", DestinationIDs: utils.StringMap{}}
|
||||
mb2 := &BalanceFilter{ID: utils.StringPointer("T2"), Weight: utils.Float64Pointer(1), RatingSubject: utils.StringPointer("1"), DestinationIDs: nil}
|
||||
if mb1.MatchFilter(mb2, false) {
|
||||
t.Errorf("Match filter failure: %+v != %+v", mb1, mb2)
|
||||
@@ -121,7 +121,7 @@ func TestBalanceMatchFilterDiffId(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestBalanceClone(t *testing.T) {
|
||||
mb1 := &Balance{Value: 1, Weight: 2, RatingSubject: "test", DestinationIds: utils.NewStringMap("5")}
|
||||
mb1 := &Balance{Value: 1, Weight: 2, RatingSubject: "test", DestinationIDs: utils.NewStringMap("5")}
|
||||
mb2 := mb1.Clone()
|
||||
if mb1 == mb2 || !mb1.Equal(mb2) {
|
||||
t.Errorf("Cloning failure: \n%+v\n%+v", mb1, mb2)
|
||||
@@ -130,19 +130,19 @@ func TestBalanceClone(t *testing.T) {
|
||||
|
||||
func TestBalanceMatchActionTriggerId(t *testing.T) {
|
||||
at := &ActionTrigger{Balance: &BalanceFilter{ID: utils.StringPointer("test")}}
|
||||
b := &Balance{Id: "test"}
|
||||
b := &Balance{ID: "test"}
|
||||
if !b.MatchActionTrigger(at) {
|
||||
t.Errorf("Error matching action trigger: %+v %+v", b, at)
|
||||
}
|
||||
b.Id = "test1"
|
||||
b.ID = "test1"
|
||||
if b.MatchActionTrigger(at) {
|
||||
t.Errorf("Error matching action trigger: %+v %+v", b, at)
|
||||
}
|
||||
b.Id = ""
|
||||
b.ID = ""
|
||||
if b.MatchActionTrigger(at) {
|
||||
t.Errorf("Error matching action trigger: %+v %+v", b, at)
|
||||
}
|
||||
b.Id = "test"
|
||||
b.ID = "test"
|
||||
at.Balance.ID = nil
|
||||
if !b.MatchActionTrigger(at) {
|
||||
t.Errorf("Error matching action trigger: %+v %+v", b, at)
|
||||
@@ -151,19 +151,19 @@ func TestBalanceMatchActionTriggerId(t *testing.T) {
|
||||
|
||||
func TestBalanceMatchActionTriggerDestination(t *testing.T) {
|
||||
at := &ActionTrigger{Balance: &BalanceFilter{DestinationIDs: utils.StringMapPointer(utils.NewStringMap("test"))}}
|
||||
b := &Balance{DestinationIds: utils.NewStringMap("test")}
|
||||
b := &Balance{DestinationIDs: utils.NewStringMap("test")}
|
||||
if !b.MatchActionTrigger(at) {
|
||||
t.Errorf("Error matching action trigger: %+v %+v", b, at)
|
||||
}
|
||||
b.DestinationIds = utils.NewStringMap("test1")
|
||||
b.DestinationIDs = utils.NewStringMap("test1")
|
||||
if b.MatchActionTrigger(at) {
|
||||
t.Errorf("Error matching action trigger: %+v %+v", b, at)
|
||||
}
|
||||
b.DestinationIds = utils.NewStringMap("")
|
||||
b.DestinationIDs = utils.NewStringMap("")
|
||||
if b.MatchActionTrigger(at) {
|
||||
t.Errorf("Error matching action trigger: %+v %+v", b, at)
|
||||
}
|
||||
b.DestinationIds = utils.NewStringMap("test")
|
||||
b.DestinationIDs = utils.NewStringMap("test")
|
||||
at.Balance.DestinationIDs = nil
|
||||
if !b.MatchActionTrigger(at) {
|
||||
t.Errorf("Error matching action trigger: %+v %+v", b, at)
|
||||
@@ -238,7 +238,7 @@ func TestBalanceIsDefault(t *testing.T) {
|
||||
if b.IsDefault() {
|
||||
t.Errorf("Balance should not be default: %+v", b)
|
||||
}
|
||||
b = &Balance{Id: utils.META_DEFAULT}
|
||||
b = &Balance{ID: utils.META_DEFAULT}
|
||||
if !b.IsDefault() {
|
||||
t.Errorf("Balance should be default: %+v", b)
|
||||
}
|
||||
|
||||
@@ -55,16 +55,16 @@ func populateDB() {
|
||||
BalanceMap: map[string]BalanceChain{
|
||||
utils.MONETARY: BalanceChain{&Balance{Value: 50}},
|
||||
utils.VOICE: BalanceChain{
|
||||
&Balance{Value: 200, DestinationIds: utils.NewStringMap("NAT"), Weight: 10},
|
||||
&Balance{Value: 100, DestinationIds: utils.NewStringMap("RET"), Weight: 20},
|
||||
&Balance{Value: 200, DestinationIDs: utils.NewStringMap("NAT"), Weight: 10},
|
||||
&Balance{Value: 100, DestinationIDs: utils.NewStringMap("RET"), Weight: 20},
|
||||
}},
|
||||
}
|
||||
broker := &Account{
|
||||
Id: "vdf:broker",
|
||||
BalanceMap: map[string]BalanceChain{
|
||||
utils.VOICE: BalanceChain{
|
||||
&Balance{Value: 20, DestinationIds: utils.NewStringMap("NAT"), Weight: 10, RatingSubject: "rif"},
|
||||
&Balance{Value: 100, DestinationIds: utils.NewStringMap("RET"), Weight: 20},
|
||||
&Balance{Value: 20, DestinationIDs: utils.NewStringMap("NAT"), Weight: 10, RatingSubject: "rif"},
|
||||
&Balance{Value: 100, DestinationIDs: utils.NewStringMap("RET"), Weight: 20},
|
||||
}},
|
||||
}
|
||||
luna := &Account{
|
||||
@@ -79,8 +79,8 @@ func populateDB() {
|
||||
Id: "vdf:minitsboy",
|
||||
BalanceMap: map[string]BalanceChain{
|
||||
utils.VOICE: BalanceChain{
|
||||
&Balance{Value: 20, DestinationIds: utils.NewStringMap("NAT"), Weight: 10, RatingSubject: "rif"},
|
||||
&Balance{Value: 100, DestinationIds: utils.NewStringMap("RET"), Weight: 20},
|
||||
&Balance{Value: 20, DestinationIDs: utils.NewStringMap("NAT"), Weight: 10, RatingSubject: "rif"},
|
||||
&Balance{Value: 100, DestinationIDs: utils.NewStringMap("RET"), Weight: 20},
|
||||
},
|
||||
utils.MONETARY: BalanceChain{
|
||||
&Balance{Value: 100, Weight: 10},
|
||||
|
||||
@@ -71,8 +71,8 @@ func TestResponderGetDerivedMaxSessionTime(t *testing.T) {
|
||||
if err := ratingStorage.SetDestination(deTMobile); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
b10 := &Balance{Value: 10, Weight: 10, DestinationIds: utils.NewStringMap("DE_TMOBILE")}
|
||||
b20 := &Balance{Value: 20, Weight: 10, DestinationIds: utils.NewStringMap("DE_TMOBILE")}
|
||||
b10 := &Balance{Value: 10, Weight: 10, DestinationIDs: utils.NewStringMap("DE_TMOBILE")}
|
||||
b20 := &Balance{Value: 20, Weight: 10, DestinationIDs: utils.NewStringMap("DE_TMOBILE")}
|
||||
rifsAccount := &Account{Id: utils.ConcatenatedKey(testTenant, "rif"), BalanceMap: map[string]BalanceChain{utils.VOICE: BalanceChain{b10}}}
|
||||
dansAccount := &Account{Id: utils.ConcatenatedKey(testTenant, "dan"), BalanceMap: map[string]BalanceChain{utils.VOICE: BalanceChain{b20}}}
|
||||
if err := accountingStorage.SetAccount(rifsAccount); err != nil {
|
||||
@@ -435,8 +435,8 @@ func TestResponderGetLCR(t *testing.T) {
|
||||
} else if !reflect.DeepEqual(eLcLcr.SupplierCosts, lcrLc.SupplierCosts) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", eLcLcr.SupplierCosts, lcrLc.SupplierCosts)
|
||||
}
|
||||
bRif12 := &Balance{Value: 40, Weight: 10, DestinationIds: utils.NewStringMap(dstDe.Id)}
|
||||
bIvo12 := &Balance{Value: 60, Weight: 10, DestinationIds: utils.NewStringMap(dstDe.Id)}
|
||||
bRif12 := &Balance{Value: 40, Weight: 10, DestinationIDs: utils.NewStringMap(dstDe.Id)}
|
||||
bIvo12 := &Balance{Value: 60, Weight: 10, DestinationIDs: utils.NewStringMap(dstDe.Id)}
|
||||
rif12sAccount := &Account{Id: utils.ConcatenatedKey("tenant12", "rif12"), BalanceMap: map[string]BalanceChain{utils.VOICE: BalanceChain{bRif12}}, AllowNegative: true}
|
||||
ivo12sAccount := &Account{Id: utils.ConcatenatedKey("tenant12", "ivo12"), BalanceMap: map[string]BalanceChain{utils.VOICE: BalanceChain{bIvo12}}, AllowNegative: true}
|
||||
for _, acnt := range []*Account{rif12sAccount, ivo12sAccount} {
|
||||
|
||||
@@ -329,7 +329,7 @@ func GetUB() *Account {
|
||||
ub := &Account{
|
||||
Id: "rif",
|
||||
AllowNegative: true,
|
||||
BalanceMap: map[string]BalanceChain{utils.SMS: BalanceChain{&Balance{Value: 14, ExpirationDate: zeroTime}}, utils.DATA: BalanceChain{&Balance{Value: 1024, ExpirationDate: zeroTime}}, utils.VOICE: BalanceChain{&Balance{Weight: 20, DestinationIds: utils.NewStringMap("NAT")}, &Balance{Weight: 10, DestinationIds: utils.NewStringMap("RET")}}},
|
||||
BalanceMap: map[string]BalanceChain{utils.SMS: BalanceChain{&Balance{Value: 14, ExpirationDate: zeroTime}}, utils.DATA: BalanceChain{&Balance{Value: 1024, ExpirationDate: zeroTime}}, utils.VOICE: BalanceChain{&Balance{Weight: 20, DestinationIDs: utils.NewStringMap("NAT")}, &Balance{Weight: 10, DestinationIDs: utils.NewStringMap("RET")}}},
|
||||
UnitCounters: UnitCounters{utils.SMS: []*UnitCounter{uc, uc}},
|
||||
ActionTriggers: ActionTriggers{at, at, at},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user