mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-14 12:49:54 +05:00
Merge branch 'master' of https://github.com/cgrates/cgrates
This commit is contained in:
@@ -144,7 +144,7 @@ func (self *ApierV1) SetAccount(attr utils.AttrSetAccount, reply *string) error
|
||||
ub = bal
|
||||
} else { // Not found in db, create it here
|
||||
ub = &engine.Account{
|
||||
Id: accID,
|
||||
ID: accID,
|
||||
}
|
||||
}
|
||||
if len(attr.ActionPlanId) != 0 {
|
||||
@@ -395,7 +395,7 @@ func (self *ApierV1) modifyBalance(aType string, attr *AttrAddBalance, reply *st
|
||||
if _, err := self.AccountDb.GetAccount(accID); err != nil {
|
||||
// create account if not exists
|
||||
account := &engine.Account{
|
||||
Id: accID,
|
||||
ID: accID,
|
||||
}
|
||||
if err := self.AccountDb.SetAccount(account); err != nil {
|
||||
*reply = err.Error()
|
||||
@@ -487,7 +487,7 @@ func (self *ApierV1) SetBalance(attr *AttrSetBalance, reply *string) error {
|
||||
if _, err := self.AccountDb.GetAccount(accID); err != nil {
|
||||
// create account if not exists
|
||||
account := &engine.Account{
|
||||
Id: accID,
|
||||
ID: accID,
|
||||
}
|
||||
if err := self.AccountDb.SetAccount(account); err != nil {
|
||||
*reply = err.Error()
|
||||
|
||||
@@ -41,15 +41,15 @@ func TestSetAccounts(t *testing.T) {
|
||||
cgrTenant := "cgrates.org"
|
||||
iscTenant := "itsyscom.com"
|
||||
b10 := &engine.Balance{Value: 10, Weight: 10}
|
||||
cgrAcnt1 := &engine.Account{Id: utils.ConcatenatedKey(cgrTenant, "account1"),
|
||||
cgrAcnt1 := &engine.Account{ID: utils.ConcatenatedKey(cgrTenant, "account1"),
|
||||
BalanceMap: map[string]engine.BalanceChain{utils.MONETARY + utils.OUT: engine.BalanceChain{b10}}}
|
||||
cgrAcnt2 := &engine.Account{Id: utils.ConcatenatedKey(cgrTenant, "account2"),
|
||||
cgrAcnt2 := &engine.Account{ID: utils.ConcatenatedKey(cgrTenant, "account2"),
|
||||
BalanceMap: map[string]engine.BalanceChain{utils.MONETARY + utils.OUT: engine.BalanceChain{b10}}}
|
||||
cgrAcnt3 := &engine.Account{Id: utils.ConcatenatedKey(cgrTenant, "account3"),
|
||||
cgrAcnt3 := &engine.Account{ID: utils.ConcatenatedKey(cgrTenant, "account3"),
|
||||
BalanceMap: map[string]engine.BalanceChain{utils.MONETARY + utils.OUT: engine.BalanceChain{b10}}}
|
||||
iscAcnt1 := &engine.Account{Id: utils.ConcatenatedKey(iscTenant, "account1"),
|
||||
iscAcnt1 := &engine.Account{ID: utils.ConcatenatedKey(iscTenant, "account1"),
|
||||
BalanceMap: map[string]engine.BalanceChain{utils.MONETARY + utils.OUT: engine.BalanceChain{b10}}}
|
||||
iscAcnt2 := &engine.Account{Id: utils.ConcatenatedKey(iscTenant, "account2"),
|
||||
iscAcnt2 := &engine.Account{ID: utils.ConcatenatedKey(iscTenant, "account2"),
|
||||
BalanceMap: map[string]engine.BalanceChain{utils.MONETARY + utils.OUT: engine.BalanceChain{b10}}}
|
||||
for _, account := range []*engine.Account{cgrAcnt1, cgrAcnt2, cgrAcnt3, iscAcnt1, iscAcnt2} {
|
||||
if err := apierAcntsAcntStorage.SetAccount(account); err != nil {
|
||||
|
||||
@@ -102,7 +102,7 @@ func (self *ApierV2) SetAccount(attr AttrSetAccount, reply *string) error {
|
||||
ub = bal
|
||||
} else { // Not found in db, create it here
|
||||
ub = &engine.Account{
|
||||
Id: accID,
|
||||
ID: accID,
|
||||
}
|
||||
}
|
||||
if attr.ActionPlanIDs != nil {
|
||||
|
||||
@@ -173,7 +173,7 @@ func (mig MigratorRC8) migrateAccounts() error {
|
||||
}
|
||||
// transfer data into new structurse
|
||||
newAcc := &engine.Account{
|
||||
Id: oldAcc.Id,
|
||||
ID: oldAcc.Id,
|
||||
BalanceMap: make(map[string]engine.BalanceChain, len(oldAcc.BalanceMap)),
|
||||
UnitCounters: make(engine.UnitCounters, len(oldAcc.UnitCounters)),
|
||||
ActionTriggers: make(engine.ActionTriggers, len(oldAcc.ActionTriggers)),
|
||||
@@ -181,12 +181,12 @@ func (mig MigratorRC8) migrateAccounts() error {
|
||||
Disabled: oldAcc.Disabled,
|
||||
}
|
||||
// fix id
|
||||
idElements := strings.Split(newAcc.Id, utils.CONCATENATED_KEY_SEP)
|
||||
idElements := strings.Split(newAcc.ID, utils.CONCATENATED_KEY_SEP)
|
||||
if len(idElements) != 3 {
|
||||
log.Printf("Malformed account ID %s", oldAcc.Id)
|
||||
continue
|
||||
}
|
||||
newAcc.Id = fmt.Sprintf("%s:%s", idElements[1], idElements[2])
|
||||
newAcc.ID = fmt.Sprintf("%s:%s", idElements[1], idElements[2])
|
||||
// balances
|
||||
balanceErr := false
|
||||
for oldBalKey, oldBalChain := range oldAcc.BalanceMap {
|
||||
@@ -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),
|
||||
@@ -344,7 +344,7 @@ func (mig MigratorRC8) migrateAccounts() error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := mig.db.Cmd("SET", utils.ACCOUNT_PREFIX+newAcc.Id, result).Err; err != nil {
|
||||
if err := mig.db.Cmd("SET", utils.ACCOUNT_PREFIX+newAcc.ID, result).Err; err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ Structure containing information about user's credit (minutes, cents, sms...).'
|
||||
This can represent a user or a shared group.
|
||||
*/
|
||||
type Account struct {
|
||||
Id string
|
||||
ID string
|
||||
BalanceMap map[string]BalanceChain
|
||||
UnitCounters UnitCounters
|
||||
ActionTriggers ActionTriggers
|
||||
@@ -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
|
||||
}
|
||||
@@ -142,12 +142,12 @@ func (acc *Account) setBalanceAction(a *Action) error {
|
||||
//than is problem
|
||||
utils.Logger.Warning(fmt.Sprintf("Could not get shared group: %v", sgID))
|
||||
} else {
|
||||
if _, found := sg.MemberIds[acc.Id]; !found {
|
||||
if _, found := sg.MemberIds[acc.ID]; !found {
|
||||
// add member and save
|
||||
if sg.MemberIds == nil {
|
||||
sg.MemberIds = make(utils.StringMap)
|
||||
}
|
||||
sg.MemberIds[acc.Id] = true
|
||||
sg.MemberIds[acc.ID] = true
|
||||
ratingStorage.SetSharedGroup(sg)
|
||||
}
|
||||
}
|
||||
@@ -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 {
|
||||
@@ -228,12 +228,12 @@ func (ub *Account) debitBalanceAction(a *Action, reset bool) error {
|
||||
//than is problem
|
||||
utils.Logger.Warning(fmt.Sprintf("Could not get shared group: %v", sgId))
|
||||
} else {
|
||||
if _, found := sg.MemberIds[ub.Id]; !found {
|
||||
if _, found := sg.MemberIds[ub.ID]; !found {
|
||||
// add member and save
|
||||
if sg.MemberIds == nil {
|
||||
sg.MemberIds = make(utils.StringMap)
|
||||
}
|
||||
sg.MemberIds[ub.Id] = true
|
||||
sg.MemberIds[ub.ID] = true
|
||||
ratingStorage.SetSharedGroup(sg)
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
@@ -487,7 +487,7 @@ func (ub *Account) debitCreditBalance(cd *CallDescriptor, count bool, dryRun boo
|
||||
defaultBalance := ub.GetDefaultMoneyBalance()
|
||||
defaultBalance.SubstractValue(cost)
|
||||
increment.BalanceInfo.MoneyBalanceUuid = defaultBalance.Uuid
|
||||
increment.BalanceInfo.AccountId = ub.Id
|
||||
increment.BalanceInfo.AccountId = ub.ID
|
||||
increment.paid = true
|
||||
if count {
|
||||
ub.countUnits(
|
||||
@@ -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)
|
||||
@@ -787,7 +787,7 @@ type TenantAccount struct {
|
||||
|
||||
func (acc *Account) Clone() *Account {
|
||||
newAcc := &Account{
|
||||
Id: acc.Id,
|
||||
ID: acc.ID,
|
||||
BalanceMap: make(map[string]BalanceChain, len(acc.BalanceMap)),
|
||||
UnitCounters: nil, // not used when cloned (dryRun)
|
||||
ActionTriggers: nil, // not used when cloned (dryRun)
|
||||
@@ -914,7 +914,7 @@ func (acc *Account) AsOldStructure() interface{} {
|
||||
}
|
||||
|
||||
result := &Account{
|
||||
Id: utils.OUT + ":" + acc.Id,
|
||||
Id: utils.OUT + ":" + acc.ID,
|
||||
BalanceMap: make(map[string]BalanceChain, len(acc.BalanceMap)),
|
||||
UnitCounters: make([]*UnitsCounter, len(acc.UnitCounters)),
|
||||
ActionTriggers: make(ActionTriggers, len(acc.ActionTriggers)),
|
||||
@@ -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,9 +83,9 @@ 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}}
|
||||
rifsBalance := &Account{Id: "other", BalanceMap: map[string]BalanceChain{utils.VOICE: BalanceChain{b1, b2}, utils.MONETARY: BalanceChain{&Balance{Value: 21}}}}
|
||||
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")
|
||||
if err != nil || !ub1.BalanceMap[utils.MONETARY].Equal(rifsBalance.BalanceMap[utils.MONETARY]) {
|
||||
@@ -95,9 +95,9 @@ 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}}
|
||||
ub1 := &Account{Id: "CUSTOMER_1:rif", BalanceMap: map[string]BalanceChain{utils.VOICE: BalanceChain{b1, b2}, utils.MONETARY: BalanceChain{&Balance{Value: 200}}}}
|
||||
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",
|
||||
Tenant: "vdf",
|
||||
@@ -118,11 +118,11 @@ 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",
|
||||
ID: "OUT:CUSTOMER_1:rif",
|
||||
BalanceMap: map[string]BalanceChain{
|
||||
utils.VOICE: BalanceChain{b1, b2},
|
||||
utils.MONETARY: BalanceChain{&Balance{Value: 21}},
|
||||
@@ -150,12 +150,12 @@ 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}}
|
||||
rifsBalance := &Account{Id: "other", BalanceMap: map[string]BalanceChain{utils.VOICE: BalanceChain{b1, b2}, utils.MONETARY: BalanceChain{&Balance{Value: 21}}}}
|
||||
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)
|
||||
if err != nil || rifsBalance.Id != result.Id ||
|
||||
result, err := accountingStorage.GetAccount(rifsBalance.ID)
|
||||
if err != nil || rifsBalance.ID != result.ID ||
|
||||
len(rifsBalance.BalanceMap[utils.VOICE]) < 2 || len(result.BalanceMap[utils.VOICE]) < 2 ||
|
||||
!(rifsBalance.BalanceMap[utils.VOICE][0].Equal(result.BalanceMap[utils.VOICE][0])) ||
|
||||
!(rifsBalance.BalanceMap[utils.VOICE][1].Equal(result.BalanceMap[utils.VOICE][1])) ||
|
||||
@@ -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",
|
||||
@@ -188,7 +188,7 @@ func TestDebitCreditZeroSecond(t *testing.T) {
|
||||
TOR: utils.VOICE,
|
||||
testCallcost: cc,
|
||||
}
|
||||
rifsBalance := &Account{Id: "other", BalanceMap: map[string]BalanceChain{utils.VOICE: BalanceChain{b1}, utils.MONETARY: BalanceChain{&Balance{Categories: utils.NewStringMap("0"), Value: 21}}}}
|
||||
rifsBalance := &Account{ID: "other", BalanceMap: map[string]BalanceChain{utils.VOICE: BalanceChain{b1}, utils.MONETARY: BalanceChain{&Balance{Categories: utils.NewStringMap("0"), Value: 21}}}}
|
||||
var err error
|
||||
cc, err = rifsBalance.debitCreditBalance(cd, false, false, true)
|
||||
if err != nil {
|
||||
@@ -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",
|
||||
@@ -228,7 +228,7 @@ func TestDebitCreditZeroMinute(t *testing.T) {
|
||||
TOR: utils.VOICE,
|
||||
testCallcost: cc,
|
||||
}
|
||||
rifsBalance := &Account{Id: "other", BalanceMap: map[string]BalanceChain{
|
||||
rifsBalance := &Account{ID: "other", BalanceMap: map[string]BalanceChain{
|
||||
utils.VOICE: BalanceChain{b1},
|
||||
utils.MONETARY: BalanceChain{&Balance{Value: 21}},
|
||||
}}
|
||||
@@ -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",
|
||||
@@ -275,7 +275,7 @@ func TestDebitCreditZeroMixedMinute(t *testing.T) {
|
||||
DurationIndex: cc.Timespans[0].GetDuration(),
|
||||
testCallcost: cc,
|
||||
}
|
||||
rifsBalance := &Account{Id: "other", BalanceMap: map[string]BalanceChain{
|
||||
rifsBalance := &Account{ID: "other", BalanceMap: map[string]BalanceChain{
|
||||
utils.VOICE: BalanceChain{b1, b2},
|
||||
utils.MONETARY: BalanceChain{&Balance{Value: 21}},
|
||||
}}
|
||||
@@ -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",
|
||||
@@ -327,7 +327,7 @@ func TestDebitCreditNoCredit(t *testing.T) {
|
||||
DurationIndex: cc.GetDuration(),
|
||||
testCallcost: cc,
|
||||
}
|
||||
rifsBalance := &Account{Id: "other", BalanceMap: map[string]BalanceChain{
|
||||
rifsBalance := &Account{ID: "other", BalanceMap: map[string]BalanceChain{
|
||||
utils.VOICE: BalanceChain{b1},
|
||||
}}
|
||||
var err error
|
||||
@@ -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",
|
||||
@@ -378,7 +378,7 @@ func TestDebitCreditHasCredit(t *testing.T) {
|
||||
DurationIndex: cc.GetDuration(),
|
||||
testCallcost: cc,
|
||||
}
|
||||
rifsBalance := &Account{Id: "other", BalanceMap: map[string]BalanceChain{
|
||||
rifsBalance := &Account{ID: "other", BalanceMap: map[string]BalanceChain{
|
||||
utils.VOICE: BalanceChain{b1},
|
||||
utils.MONETARY: BalanceChain{&Balance{Uuid: "moneya", Value: 110}},
|
||||
}}
|
||||
@@ -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",
|
||||
@@ -426,7 +426,7 @@ func TestDebitCreditSplitMinutesMoney(t *testing.T) {
|
||||
DurationIndex: cc.GetDuration(),
|
||||
testCallcost: cc,
|
||||
}
|
||||
rifsBalance := &Account{Id: "other", BalanceMap: map[string]BalanceChain{
|
||||
rifsBalance := &Account{ID: "other", BalanceMap: map[string]BalanceChain{
|
||||
utils.VOICE: BalanceChain{b1},
|
||||
utils.MONETARY: BalanceChain{&Balance{Uuid: "moneya", Value: 50}},
|
||||
}}
|
||||
@@ -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",
|
||||
@@ -479,7 +479,7 @@ func TestDebitCreditMoreTimespans(t *testing.T) {
|
||||
DurationIndex: cc.GetDuration(),
|
||||
testCallcost: cc,
|
||||
}
|
||||
rifsBalance := &Account{Id: "other", BalanceMap: map[string]BalanceChain{
|
||||
rifsBalance := &Account{ID: "other", BalanceMap: map[string]BalanceChain{
|
||||
utils.VOICE: BalanceChain{b1},
|
||||
}}
|
||||
var err error
|
||||
@@ -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",
|
||||
@@ -528,7 +528,7 @@ func TestDebitCreditMoreTimespansMixed(t *testing.T) {
|
||||
DurationIndex: cc.GetDuration(),
|
||||
testCallcost: cc,
|
||||
}
|
||||
rifsBalance := &Account{Id: "other", BalanceMap: map[string]BalanceChain{
|
||||
rifsBalance := &Account{ID: "other", BalanceMap: map[string]BalanceChain{
|
||||
utils.VOICE: BalanceChain{b1, b2},
|
||||
}}
|
||||
var err error
|
||||
@@ -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",
|
||||
@@ -578,7 +578,7 @@ func TestDebitCreditNoConectFeeCredit(t *testing.T) {
|
||||
DurationIndex: cc.GetDuration(),
|
||||
testCallcost: cc,
|
||||
}
|
||||
rifsBalance := &Account{Id: "other", BalanceMap: map[string]BalanceChain{
|
||||
rifsBalance := &Account{ID: "other", BalanceMap: map[string]BalanceChain{
|
||||
utils.VOICE: BalanceChain{b1},
|
||||
}}
|
||||
var err error
|
||||
@@ -622,7 +622,7 @@ func TestDebitCreditMoneyOnly(t *testing.T) {
|
||||
DurationIndex: cc.GetDuration(),
|
||||
testCallcost: cc,
|
||||
}
|
||||
rifsBalance := &Account{Id: "other", BalanceMap: map[string]BalanceChain{
|
||||
rifsBalance := &Account{ID: "other", BalanceMap: map[string]BalanceChain{
|
||||
utils.MONETARY: BalanceChain{&Balance{Uuid: "money", Value: 50}},
|
||||
}}
|
||||
var err error
|
||||
@@ -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",
|
||||
@@ -675,7 +675,7 @@ func TestDebitCreditSubjectMinutes(t *testing.T) {
|
||||
DurationIndex: cc.GetDuration(),
|
||||
testCallcost: cc,
|
||||
}
|
||||
rifsBalance := &Account{Id: "other", BalanceMap: map[string]BalanceChain{
|
||||
rifsBalance := &Account{ID: "other", BalanceMap: map[string]BalanceChain{
|
||||
utils.VOICE: BalanceChain{b1},
|
||||
utils.MONETARY: BalanceChain{&Balance{Uuid: "moneya", Value: 350}},
|
||||
}}
|
||||
@@ -730,8 +730,8 @@ func TestDebitCreditSubjectMoney(t *testing.T) {
|
||||
DurationIndex: cc.GetDuration(),
|
||||
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"}},
|
||||
rifsBalance := &Account{ID: "other", BalanceMap: map[string]BalanceChain{
|
||||
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)
|
||||
@@ -780,7 +780,7 @@ func TestDebitCreditSubjectMoney(t *testing.T) {
|
||||
DurationIndex: cc.GetDuration(),
|
||||
testCallcost: cc,
|
||||
}
|
||||
rifsBalance := &Account{Id: "other", BalanceMap: map[string]BalanceChain{
|
||||
rifsBalance := &Account{ID: "other", BalanceMap: map[string]BalanceChain{
|
||||
utils.VOICE: BalanceChain{b1},
|
||||
utils.MONETARY: BalanceChain{&Balance{Uuid: "moneya", Value: 19500, RatingSubject: "minu"}},
|
||||
}}
|
||||
@@ -809,9 +809,9 @@ func TestDebitCreditSubjectMoney(t *testing.T) {
|
||||
|
||||
func TestAccountdebitBalance(t *testing.T) {
|
||||
ub := &Account{
|
||||
Id: "rif",
|
||||
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}
|
||||
@@ -851,9 +851,9 @@ func TestAccountdebitBalance(t *testing.T) {
|
||||
func TestAccountdebitBalanceExists(t *testing.T) {
|
||||
|
||||
ub := &Account{
|
||||
Id: "rif",
|
||||
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),
|
||||
@@ -871,9 +871,9 @@ func TestAccountdebitBalanceExists(t *testing.T) {
|
||||
|
||||
func TestAccountAddMinuteNil(t *testing.T) {
|
||||
ub := &Account{
|
||||
Id: "rif",
|
||||
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 {
|
||||
@@ -920,8 +920,8 @@ 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}}}},
|
||||
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}}}},
|
||||
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"}},
|
||||
}
|
||||
@@ -944,8 +944,8 @@ 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}}}},
|
||||
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}}}},
|
||||
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"}},
|
||||
}
|
||||
@@ -957,7 +957,7 @@ func TestAccountExecuteTriggeredActionsBalance(t *testing.T) {
|
||||
|
||||
func TestAccountExecuteTriggeredActionsOrder(t *testing.T) {
|
||||
ub := &Account{
|
||||
Id: "TEST_UB_OREDER",
|
||||
ID: "TEST_UB_OREDER",
|
||||
BalanceMap: map[string]BalanceChain{utils.MONETARY: BalanceChain{&Balance{Directions: utils.NewStringMap(utils.OUT), Value: 100}}},
|
||||
UnitCounters: UnitCounters{utils.MONETARY: []*UnitCounter{&UnitCounter{Counters: CounterFilters{&CounterFilter{Value: 1, Filter: &BalanceFilter{Directions: utils.StringMapPointer(utils.NewStringMap(utils.OUT)), Type: utils.StringPointer(utils.MONETARY)}}}}}},
|
||||
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_ORDER"}},
|
||||
@@ -972,8 +972,8 @@ 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}}}},
|
||||
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}}}},
|
||||
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"},
|
||||
@@ -1000,8 +1000,8 @@ 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}}}},
|
||||
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", Balance: &BalanceFilter{Type: utils.StringPointer(utils.MONETARY), Directions: utils.StringMapPointer(utils.NewStringMap(utils.OUT))}, ThresholdValue: 10, ThresholdType: utils.TRIGGER_BALANCE_EXPIRED, ActionsId: "TEST_ACTIONS"},
|
||||
},
|
||||
@@ -1018,8 +1018,8 @@ 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}}}},
|
||||
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}}}},
|
||||
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"},
|
||||
},
|
||||
@@ -1036,8 +1036,8 @@ 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}}}},
|
||||
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}}}},
|
||||
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"},
|
||||
},
|
||||
@@ -1054,7 +1054,7 @@ func TestAccountExpActionTriggerExpired(t *testing.T) {
|
||||
|
||||
func TestCleanExpired(t *testing.T) {
|
||||
ub := &Account{
|
||||
Id: "TEST_UB_OREDER",
|
||||
ID: "TEST_UB_OREDER",
|
||||
BalanceMap: map[string]BalanceChain{utils.MONETARY: BalanceChain{
|
||||
&Balance{ExpirationDate: time.Now().Add(10 * time.Second)},
|
||||
&Balance{ExpirationDate: time.Date(2013, 7, 18, 14, 33, 0, 0, time.UTC)},
|
||||
@@ -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}},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -1181,14 +1181,14 @@ func TestDebitShared(t *testing.T) {
|
||||
DurationIndex: cc.GetDuration(),
|
||||
testCallcost: cc,
|
||||
}
|
||||
rif := &Account{Id: "rif", BalanceMap: map[string]BalanceChain{
|
||||
rif := &Account{ID: "rif", BalanceMap: map[string]BalanceChain{
|
||||
utils.MONETARY: BalanceChain{&Balance{Uuid: "moneya", Value: 0, SharedGroups: utils.NewStringMap("SG_TEST")}},
|
||||
}}
|
||||
groupie := &Account{Id: "groupie", BalanceMap: map[string]BalanceChain{
|
||||
groupie := &Account{ID: "groupie", BalanceMap: map[string]BalanceChain{
|
||||
utils.MONETARY: BalanceChain{&Balance{Uuid: "moneyc", Value: 130, SharedGroups: utils.NewStringMap("SG_TEST")}},
|
||||
}}
|
||||
|
||||
sg := &SharedGroup{Id: "SG_TEST", MemberIds: utils.NewStringMap(rif.Id, groupie.Id), AccountParameters: map[string]*SharingParameters{"*any": &SharingParameters{Strategy: STRATEGY_MINE_RANDOM}}}
|
||||
sg := &SharedGroup{Id: "SG_TEST", MemberIds: utils.NewStringMap(rif.ID, groupie.ID), AccountParameters: map[string]*SharingParameters{"*any": &SharingParameters{Strategy: STRATEGY_MINE_RANDOM}}}
|
||||
|
||||
accountingStorage.SetAccount(groupie)
|
||||
ratingStorage.SetSharedGroup(sg)
|
||||
@@ -1251,14 +1251,14 @@ func TestMaxDurationShared(t *testing.T) {
|
||||
DurationIndex: cc.GetDuration(),
|
||||
testCallcost: cc,
|
||||
}
|
||||
rif := &Account{Id: "rif", BalanceMap: map[string]BalanceChain{
|
||||
rif := &Account{ID: "rif", BalanceMap: map[string]BalanceChain{
|
||||
utils.MONETARY: BalanceChain{&Balance{Uuid: "moneya", Value: 0, SharedGroups: utils.NewStringMap("SG_TEST")}},
|
||||
}}
|
||||
groupie := &Account{Id: "groupie", BalanceMap: map[string]BalanceChain{
|
||||
groupie := &Account{ID: "groupie", BalanceMap: map[string]BalanceChain{
|
||||
utils.MONETARY: BalanceChain{&Balance{Uuid: "moneyc", Value: 130, SharedGroups: utils.NewStringMap("SG_TEST")}},
|
||||
}}
|
||||
|
||||
sg := &SharedGroup{Id: "SG_TEST", MemberIds: utils.NewStringMap(rif.Id, groupie.Id), AccountParameters: map[string]*SharingParameters{"*any": &SharingParameters{Strategy: STRATEGY_MINE_RANDOM}}}
|
||||
sg := &SharedGroup{Id: "SG_TEST", MemberIds: utils.NewStringMap(rif.ID, groupie.ID), AccountParameters: map[string]*SharingParameters{"*any": &SharingParameters{Strategy: STRATEGY_MINE_RANDOM}}}
|
||||
|
||||
accountingStorage.SetAccount(groupie)
|
||||
ratingStorage.SetSharedGroup(sg)
|
||||
@@ -1286,7 +1286,7 @@ func TestMaxDurationConnectFeeOnly(t *testing.T) {
|
||||
TOR: utils.VOICE,
|
||||
DurationIndex: 600,
|
||||
}
|
||||
rif := &Account{Id: "rif", BalanceMap: map[string]BalanceChain{
|
||||
rif := &Account{ID: "rif", BalanceMap: map[string]BalanceChain{
|
||||
utils.MONETARY: BalanceChain{&Balance{Uuid: "moneya", Value: 0.2}},
|
||||
}}
|
||||
|
||||
@@ -1324,8 +1324,8 @@ func TestDebitSMS(t *testing.T) {
|
||||
DurationIndex: cc.GetDuration(),
|
||||
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}}},
|
||||
rifsBalance := &Account{ID: "other", BalanceMap: map[string]BalanceChain{
|
||||
utils.SMS: BalanceChain{&Balance{Uuid: "testm", Value: 100, Weight: 5, DestinationIDs: utils.StringMap{"NAT": true}}},
|
||||
utils.MONETARY: BalanceChain{&Balance{Value: 21}},
|
||||
}}
|
||||
var err error
|
||||
@@ -1367,8 +1367,8 @@ func TestDebitGeneric(t *testing.T) {
|
||||
DurationIndex: cc.GetDuration(),
|
||||
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}}},
|
||||
rifsBalance := &Account{ID: "other", BalanceMap: map[string]BalanceChain{
|
||||
utils.GENERIC: BalanceChain{&Balance{Uuid: "testm", Value: 100, Weight: 5, DestinationIDs: utils.StringMap{"NAT": true}}},
|
||||
utils.MONETARY: BalanceChain{&Balance{Value: 21}},
|
||||
}}
|
||||
var err error
|
||||
@@ -1410,8 +1410,8 @@ func TestDebitGenericBalance(t *testing.T) {
|
||||
DurationIndex: cc.GetDuration(),
|
||||
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}}},
|
||||
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.MONETARY: BalanceChain{&Balance{Value: 21}},
|
||||
}}
|
||||
var err error
|
||||
@@ -1453,8 +1453,8 @@ func TestDebitGenericBalanceWithRatingSubject(t *testing.T) {
|
||||
DurationIndex: cc.GetDuration(),
|
||||
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"}},
|
||||
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.MONETARY: BalanceChain{&Balance{Value: 21}},
|
||||
}}
|
||||
var err error
|
||||
@@ -1503,8 +1503,8 @@ func TestDebitDataUnits(t *testing.T) {
|
||||
DurationIndex: cc.GetDuration(),
|
||||
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}}},
|
||||
rifsBalance := &Account{ID: "other", BalanceMap: map[string]BalanceChain{
|
||||
utils.DATA: BalanceChain{&Balance{Uuid: "testm", Value: 100, Weight: 5, DestinationIDs: utils.StringMap{"NAT": true}}},
|
||||
utils.MONETARY: BalanceChain{&Balance{Value: 21}},
|
||||
}}
|
||||
var err error
|
||||
@@ -1557,8 +1557,8 @@ func TestDebitDataMoney(t *testing.T) {
|
||||
DurationIndex: cc.GetDuration(),
|
||||
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}}},
|
||||
rifsBalance := &Account{ID: "other", BalanceMap: map[string]BalanceChain{
|
||||
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,10 +1752,10 @@ 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}}}}
|
||||
ub1 := &Account{ID: "other", BalanceMap: map[string]BalanceChain{utils.VOICE: BalanceChain{b1, b2}, utils.MONETARY: BalanceChain{&Balance{Value: 21}}}}
|
||||
cd := &CallDescriptor{
|
||||
Destination: "0723",
|
||||
}
|
||||
@@ -1766,19 +1766,19 @@ 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}}
|
||||
rifsBalance := &Account{Id: "other", BalanceMap: map[string]BalanceChain{utils.VOICE: BalanceChain{b1, b2}, utils.MONETARY: BalanceChain{&Balance{Value: 21}}}}
|
||||
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)
|
||||
accountingStorage.GetAccount(rifsBalance.Id)
|
||||
accountingStorage.GetAccount(rifsBalance.ID)
|
||||
}
|
||||
}
|
||||
|
||||
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}}
|
||||
ub1 := &Account{Id: "OUT:CUSTOMER_1:rif", BalanceMap: map[string]BalanceChain{utils.VOICE: BalanceChain{b1, b2}, utils.MONETARY: BalanceChain{&Balance{Value: 21}}}}
|
||||
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",
|
||||
}
|
||||
|
||||
@@ -161,7 +161,7 @@ func parseTemplateValue(rsrFlds utils.RSRFields, acnt *Account, action *Action)
|
||||
var err error
|
||||
var dta *utils.TenantAccount
|
||||
if acnt != nil {
|
||||
dta, err = utils.NewTAFromAccountKey(acnt.Id) // Account information should be valid
|
||||
dta, err = utils.NewTAFromAccountKey(acnt.ID) // Account information should be valid
|
||||
}
|
||||
if err != nil || acnt == nil {
|
||||
dta = new(utils.TenantAccount) // Init with empty values
|
||||
@@ -171,7 +171,7 @@ func parseTemplateValue(rsrFlds utils.RSRFields, acnt *Account, action *Action)
|
||||
for _, rsrFld := range rsrFlds {
|
||||
switch rsrFld.Id {
|
||||
case "AccountID":
|
||||
parsedValue += rsrFld.ParseValue(acnt.Id)
|
||||
parsedValue += rsrFld.ParseValue(acnt.ID)
|
||||
case "Directions":
|
||||
parsedValue += rsrFld.ParseValue(b.Directions.String())
|
||||
case utils.TENANT:
|
||||
@@ -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":
|
||||
@@ -469,7 +469,7 @@ func mailAsync(ub *Account, sq *StatsQueueTriggered, a *Action, acs Actions) err
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
message = []byte(fmt.Sprintf("To: %s\r\nSubject: [CGR Notification] Threshold hit on Balance: %s\r\n\r\nTime: \r\n\t%s\r\n\r\nBalance:\r\n\t%s\r\n\r\nYours faithfully,\r\nCGR Balance Monitor\r\n", toAddrStr, ub.Id, time.Now(), balJsn))
|
||||
message = []byte(fmt.Sprintf("To: %s\r\nSubject: [CGR Notification] Threshold hit on Balance: %s\r\n\r\nTime: \r\n\t%s\r\n\r\nBalance:\r\n\t%s\r\n\r\nYours faithfully,\r\nCGR Balance Monitor\r\n", toAddrStr, ub.ID, time.Now(), balJsn))
|
||||
} else if sq != nil {
|
||||
message = []byte(fmt.Sprintf("To: %s\r\nSubject: [CGR Notification] Threshold hit on StatsQueueId: %s\r\n\r\nTime: \r\n\t%s\r\n\r\nStatsQueueId:\r\n\t%s\r\n\r\nMetrics:\r\n\t%+v\r\n\r\nTrigger:\r\n\t%+v\r\n\r\nYours faithfully,\r\nCGR CDR Stats Monitor\r\n",
|
||||
toAddrStr, sq.Id, time.Now(), sq.Id, sq.Metrics, sq.Trigger))
|
||||
@@ -481,7 +481,7 @@ func mailAsync(ub *Account, sq *StatsQueueTriggered, a *Action, acs Actions) err
|
||||
break
|
||||
} else if i == 4 {
|
||||
if ub != nil {
|
||||
utils.Logger.Warning(fmt.Sprintf("<Triggers> WARNING: Failed emailing, params: [%s], error: [%s], BalanceId: %s", a.ExtraParameters, err.Error(), ub.Id))
|
||||
utils.Logger.Warning(fmt.Sprintf("<Triggers> WARNING: Failed emailing, params: [%s], error: [%s], BalanceId: %s", a.ExtraParameters, err.Error(), ub.ID))
|
||||
} else if sq != nil {
|
||||
utils.Logger.Warning(fmt.Sprintf("<Triggers> WARNING: Failed emailing, params: [%s], error: [%s], StatsQueueTriggeredId: %s", a.ExtraParameters, err.Error(), sq.Id))
|
||||
}
|
||||
@@ -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
|
||||
@@ -534,7 +534,7 @@ func setddestinations(ub *Account, sq *StatsQueueTriggered, a *Action, acs Actio
|
||||
func removeAccountAction(ub *Account, sq *StatsQueueTriggered, a *Action, acs Actions) error {
|
||||
var accID string
|
||||
if ub != nil {
|
||||
accID = ub.Id
|
||||
accID = ub.ID
|
||||
} else {
|
||||
accountInfo := struct {
|
||||
Tenant string
|
||||
@@ -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
|
||||
|
||||
@@ -53,7 +53,7 @@ func (at *ActionTrigger) Execute(ub *Account, sq *StatsQueueTriggered) (err erro
|
||||
}
|
||||
at.lastExecutionTime = time.Now()
|
||||
if ub != nil && ub.Disabled {
|
||||
return fmt.Errorf("User %s is disabled and there are triggers in action!", ub.Id)
|
||||
return fmt.Errorf("User %s is disabled and there are triggers in action!", ub.ID)
|
||||
}
|
||||
// does NOT need to Lock() because it is triggered from a method that took the Lock
|
||||
var aac Actions
|
||||
@@ -104,7 +104,7 @@ func (at *ActionTrigger) Execute(ub *Account, sq *StatsQueueTriggered) (err erro
|
||||
at.Executed = false
|
||||
}
|
||||
if !transactionFailed && ub != nil && !removeAccountActionFound {
|
||||
storageLogger.LogActionTrigger(ub.Id, utils.RATER_SOURCE, at, aac)
|
||||
storageLogger.LogActionTrigger(ub.ID, utils.RATER_SOURCE, at, aac)
|
||||
accountingStorage.SetAccount(ub)
|
||||
}
|
||||
return
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -692,8 +692,8 @@ 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")}}},
|
||||
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")}}},
|
||||
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}},
|
||||
}
|
||||
@@ -705,7 +705,7 @@ func TestActionResetTriggres(t *testing.T) {
|
||||
|
||||
func TestActionResetTriggresExecutesThem(t *testing.T) {
|
||||
ub := &Account{
|
||||
Id: "TEST_UB",
|
||||
ID: "TEST_UB",
|
||||
BalanceMap: map[string]BalanceChain{utils.MONETARY: BalanceChain{&Balance{Value: 10}}},
|
||||
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}},
|
||||
@@ -718,8 +718,8 @@ 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")}}},
|
||||
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")}}},
|
||||
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}},
|
||||
}
|
||||
@@ -731,8 +731,8 @@ 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")}}},
|
||||
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")}}},
|
||||
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}},
|
||||
}
|
||||
@@ -744,9 +744,9 @@ func TestActionSetPostpaid(t *testing.T) {
|
||||
|
||||
func TestActionSetPrepaid(t *testing.T) {
|
||||
ub := &Account{
|
||||
Id: "TEST_UB",
|
||||
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}},
|
||||
}
|
||||
@@ -758,9 +758,9 @@ func TestActionSetPrepaid(t *testing.T) {
|
||||
|
||||
func TestActionResetPrepaid(t *testing.T) {
|
||||
ub := &Account{
|
||||
Id: "TEST_UB",
|
||||
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}},
|
||||
}
|
||||
@@ -777,8 +777,8 @@ 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")}}},
|
||||
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")}}},
|
||||
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}},
|
||||
}
|
||||
@@ -793,8 +793,8 @@ 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")}}},
|
||||
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")}}},
|
||||
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}},
|
||||
}
|
||||
@@ -811,7 +811,7 @@ func TestActionTopupResetCredit(t *testing.T) {
|
||||
|
||||
func TestActionTopupValueFactor(t *testing.T) {
|
||||
ub := &Account{
|
||||
Id: "TEST_UB",
|
||||
ID: "TEST_UB",
|
||||
BalanceMap: map[string]BalanceChain{},
|
||||
}
|
||||
a := &Action{
|
||||
@@ -830,11 +830,11 @@ func TestActionTopupValueFactor(t *testing.T) {
|
||||
|
||||
func TestActionTopupResetCreditId(t *testing.T) {
|
||||
ub := &Account{
|
||||
Id: "TEST_UB",
|
||||
ID: "TEST_UB",
|
||||
BalanceMap: map[string]BalanceChain{
|
||||
utils.MONETARY: BalanceChain{
|
||||
&Balance{Value: 100},
|
||||
&Balance{Id: "TEST_B", Value: 15},
|
||||
&Balance{ID: "TEST_B", Value: 15},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -849,11 +849,11 @@ func TestActionTopupResetCreditId(t *testing.T) {
|
||||
|
||||
func TestActionTopupResetCreditNoId(t *testing.T) {
|
||||
ub := &Account{
|
||||
Id: "TEST_UB",
|
||||
ID: "TEST_UB",
|
||||
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)},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -868,10 +868,10 @@ func TestActionTopupResetCreditNoId(t *testing.T) {
|
||||
|
||||
func TestActionTopupResetMinutes(t *testing.T) {
|
||||
ub := &Account{
|
||||
Id: "TEST_UB",
|
||||
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}},
|
||||
}
|
||||
@@ -889,8 +889,8 @@ 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")}}},
|
||||
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")}}},
|
||||
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}},
|
||||
}
|
||||
@@ -907,8 +907,8 @@ 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")}}},
|
||||
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")}}},
|
||||
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}},
|
||||
}
|
||||
@@ -926,8 +926,8 @@ 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")}}},
|
||||
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")}}},
|
||||
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}},
|
||||
}
|
||||
@@ -944,8 +944,8 @@ 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")}}},
|
||||
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")}}},
|
||||
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}},
|
||||
}
|
||||
@@ -963,13 +963,13 @@ func TestActionDebitMinutes(t *testing.T) {
|
||||
|
||||
func TestActionResetAllCounters(t *testing.T) {
|
||||
ub := &Account{
|
||||
Id: "TEST_UB",
|
||||
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"), 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}},
|
||||
}
|
||||
@@ -994,11 +994,11 @@ func TestActionResetAllCounters(t *testing.T) {
|
||||
|
||||
func TestActionResetCounterOnlyDefault(t *testing.T) {
|
||||
ub := &Account{
|
||||
Id: "TEST_UB",
|
||||
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")}}},
|
||||
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)}}
|
||||
@@ -1026,9 +1026,9 @@ func TestActionResetCounterOnlyDefault(t *testing.T) {
|
||||
|
||||
func TestActionResetCounterCredit(t *testing.T) {
|
||||
ub := &Account{
|
||||
Id: "TEST_UB",
|
||||
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}},
|
||||
}
|
||||
@@ -1193,7 +1193,7 @@ func TestTopupActionLoaded(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestActionCdrlogEmpty(t *testing.T) {
|
||||
acnt := &Account{Id: "cgrates.org:dan2904"}
|
||||
acnt := &Account{ID: "cgrates.org:dan2904"}
|
||||
cdrlog := &Action{
|
||||
ActionType: CDRLOG,
|
||||
}
|
||||
@@ -1214,7 +1214,7 @@ func TestActionCdrlogEmpty(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestActionCdrlogWithParams(t *testing.T) {
|
||||
acnt := &Account{Id: "cgrates.org:dan2904"}
|
||||
acnt := &Account{ID: "cgrates.org:dan2904"}
|
||||
cdrlog := &Action{
|
||||
ActionType: CDRLOG,
|
||||
ExtraParameters: `{"ReqType":"^*pseudoprepaid","Subject":"^rif", "TOR":"~action_type:s/^\\*(.*)$/did_$1/"}`,
|
||||
@@ -1241,7 +1241,7 @@ func TestActionCdrlogWithParams(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestActionCdrLogParamsWithOverload(t *testing.T) {
|
||||
acnt := &Account{Id: "cgrates.org:dan2904"}
|
||||
acnt := &Account{ID: "cgrates.org:dan2904"}
|
||||
cdrlog := &Action{
|
||||
ActionType: CDRLOG,
|
||||
ExtraParameters: `{"Subject":"^rif","Destination":"^1234","ToR":"~ActionTag:s/^at(.)$/0$1/","AccountID":"~AccountID:s/^\\*(.*)$/$1/"}`,
|
||||
@@ -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"}})
|
||||
@@ -1318,7 +1318,7 @@ func TestActionSetDDestination(t *testing.T) {
|
||||
|
||||
func TestActionTransactionFuncType(t *testing.T) {
|
||||
err := accountingStorage.SetAccount(&Account{
|
||||
Id: "cgrates.org:trans",
|
||||
ID: "cgrates.org:trans",
|
||||
BalanceMap: map[string]BalanceChain{
|
||||
utils.MONETARY: BalanceChain{&Balance{
|
||||
Value: 10,
|
||||
@@ -1354,7 +1354,7 @@ func TestActionTransactionFuncType(t *testing.T) {
|
||||
|
||||
func TestActionTransactionBalanceType(t *testing.T) {
|
||||
err := accountingStorage.SetAccount(&Account{
|
||||
Id: "cgrates.org:trans",
|
||||
ID: "cgrates.org:trans",
|
||||
BalanceMap: map[string]BalanceChain{
|
||||
utils.MONETARY: BalanceChain{&Balance{
|
||||
Value: 10,
|
||||
@@ -1390,7 +1390,7 @@ func TestActionTransactionBalanceType(t *testing.T) {
|
||||
|
||||
func TestActionTransactionBalanceNotType(t *testing.T) {
|
||||
err := accountingStorage.SetAccount(&Account{
|
||||
Id: "cgrates.org:trans",
|
||||
ID: "cgrates.org:trans",
|
||||
BalanceMap: map[string]BalanceChain{
|
||||
utils.MONETARY: BalanceChain{&Balance{
|
||||
Value: 10,
|
||||
@@ -1426,7 +1426,7 @@ func TestActionTransactionBalanceNotType(t *testing.T) {
|
||||
|
||||
func TestActionWithExpireWithoutExpire(t *testing.T) {
|
||||
err := accountingStorage.SetAccount(&Account{
|
||||
Id: "cgrates.org:exp",
|
||||
ID: "cgrates.org:exp",
|
||||
BalanceMap: map[string]BalanceChain{
|
||||
utils.MONETARY: BalanceChain{&Balance{
|
||||
Value: 10,
|
||||
@@ -1470,7 +1470,7 @@ func TestActionWithExpireWithoutExpire(t *testing.T) {
|
||||
|
||||
func TestActionRemoveBalance(t *testing.T) {
|
||||
err := accountingStorage.SetAccount(&Account{
|
||||
Id: "cgrates.org:rembal",
|
||||
ID: "cgrates.org:rembal",
|
||||
BalanceMap: map[string]BalanceChain{
|
||||
utils.MONETARY: BalanceChain{
|
||||
&Balance{
|
||||
@@ -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"),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -1518,12 +1518,12 @@ func TestActionRemoveBalance(t *testing.T) {
|
||||
func TestActionTransferMonetaryDefault(t *testing.T) {
|
||||
err := accountingStorage.SetAccount(
|
||||
&Account{
|
||||
Id: "cgrates.org:trans",
|
||||
ID: "cgrates.org:trans",
|
||||
BalanceMap: map[string]BalanceChain{
|
||||
utils.MONETARY: BalanceChain{
|
||||
&Balance{
|
||||
Uuid: utils.GenUUID(),
|
||||
Id: utils.META_DEFAULT,
|
||||
ID: utils.META_DEFAULT,
|
||||
Value: 10,
|
||||
},
|
||||
&Balance{
|
||||
@@ -1574,12 +1574,12 @@ func TestActionTransferMonetaryDefault(t *testing.T) {
|
||||
func TestActionTransferMonetaryDefaultFilter(t *testing.T) {
|
||||
err := accountingStorage.SetAccount(
|
||||
&Account{
|
||||
Id: "cgrates.org:trans",
|
||||
ID: "cgrates.org:trans",
|
||||
BalanceMap: map[string]BalanceChain{
|
||||
utils.MONETARY: BalanceChain{
|
||||
&Balance{
|
||||
Uuid: utils.GenUUID(),
|
||||
Id: utils.META_DEFAULT,
|
||||
ID: utils.META_DEFAULT,
|
||||
Value: 10,
|
||||
Weight: 20,
|
||||
},
|
||||
@@ -1635,12 +1635,12 @@ func TestActionTransferMonetaryDefaultFilter(t *testing.T) {
|
||||
func TestActionConditionalTopup(t *testing.T) {
|
||||
err := accountingStorage.SetAccount(
|
||||
&Account{
|
||||
Id: "cgrates.org:cond",
|
||||
ID: "cgrates.org:cond",
|
||||
BalanceMap: map[string]BalanceChain{
|
||||
utils.MONETARY: BalanceChain{
|
||||
&Balance{
|
||||
Uuid: utils.GenUUID(),
|
||||
Id: utils.META_DEFAULT,
|
||||
ID: utils.META_DEFAULT,
|
||||
Value: 10,
|
||||
Weight: 20,
|
||||
},
|
||||
@@ -1699,12 +1699,12 @@ func TestActionConditionalTopup(t *testing.T) {
|
||||
func TestActionConditionalTopupNoMatch(t *testing.T) {
|
||||
err := accountingStorage.SetAccount(
|
||||
&Account{
|
||||
Id: "cgrates.org:cond",
|
||||
ID: "cgrates.org:cond",
|
||||
BalanceMap: map[string]BalanceChain{
|
||||
utils.MONETARY: BalanceChain{
|
||||
&Balance{
|
||||
Uuid: utils.GenUUID(),
|
||||
Id: utils.META_DEFAULT,
|
||||
ID: utils.META_DEFAULT,
|
||||
Value: 10,
|
||||
Weight: 20,
|
||||
},
|
||||
@@ -1762,7 +1762,7 @@ func TestActionConditionalTopupNoMatch(t *testing.T) {
|
||||
func TestActionConditionalTopupExistingBalance(t *testing.T) {
|
||||
err := accountingStorage.SetAccount(
|
||||
&Account{
|
||||
Id: "cgrates.org:cond",
|
||||
ID: "cgrates.org:cond",
|
||||
BalanceMap: map[string]BalanceChain{
|
||||
utils.MONETARY: BalanceChain{
|
||||
&Balance{
|
||||
@@ -1826,12 +1826,12 @@ func TestActionConditionalTopupExistingBalance(t *testing.T) {
|
||||
func TestActionConditionalDisabledIfNegative(t *testing.T) {
|
||||
err := accountingStorage.SetAccount(
|
||||
&Account{
|
||||
Id: "cgrates.org:af",
|
||||
ID: "cgrates.org:af",
|
||||
BalanceMap: map[string]BalanceChain{
|
||||
"*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"),
|
||||
@@ -1979,17 +1979,17 @@ func TestActionConditionalDisabledIfNegative(t *testing.T) {
|
||||
func TestActionSetBalance(t *testing.T) {
|
||||
err := accountingStorage.SetAccount(
|
||||
&Account{
|
||||
Id: "cgrates.org:setb",
|
||||
ID: "cgrates.org:setb",
|
||||
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
|
||||
}
|
||||
@@ -356,7 +356,7 @@ func (b *Balance) debitUnits(cd *CallDescriptor, ub *Account, moneyBalances Bala
|
||||
if b.GetValue() >= amount {
|
||||
b.SubstractValue(amount)
|
||||
inc.BalanceInfo.UnitBalanceUuid = b.Uuid
|
||||
inc.BalanceInfo.AccountId = ub.Id
|
||||
inc.BalanceInfo.AccountId = ub.ID
|
||||
inc.UnitInfo = &UnitInfo{cc.Destination, amount, cc.TOR}
|
||||
inc.Cost = 0
|
||||
inc.paid = true
|
||||
@@ -427,7 +427,7 @@ func (b *Balance) debitUnits(cd *CallDescriptor, ub *Account, moneyBalances Bala
|
||||
if strategy == utils.MAX_COST_FREE && cd.MaxCostSoFar >= maxCost {
|
||||
cost, inc.Cost = 0.0, 0.0
|
||||
inc.BalanceInfo.MoneyBalanceUuid = b.Uuid
|
||||
inc.BalanceInfo.AccountId = ub.Id
|
||||
inc.BalanceInfo.AccountId = ub.ID
|
||||
inc.paid = true
|
||||
if count {
|
||||
ub.countUnits(cost, utils.MONETARY, cc, b)
|
||||
@@ -445,7 +445,7 @@ func (b *Balance) debitUnits(cd *CallDescriptor, ub *Account, moneyBalances Bala
|
||||
if (cost == 0 || moneyBal != nil) && b.GetValue() >= amount {
|
||||
b.SubstractValue(amount)
|
||||
inc.BalanceInfo.UnitBalanceUuid = b.Uuid
|
||||
inc.BalanceInfo.AccountId = ub.Id
|
||||
inc.BalanceInfo.AccountId = ub.ID
|
||||
inc.UnitInfo = &UnitInfo{cc.Destination, amount, cc.TOR}
|
||||
if cost != 0 {
|
||||
inc.BalanceInfo.MoneyBalanceUuid = moneyBal.Uuid
|
||||
@@ -534,7 +534,7 @@ func (b *Balance) debitMoney(cd *CallDescriptor, ub *Account, moneyBalances Bala
|
||||
if strategy == utils.MAX_COST_FREE && cd.MaxCostSoFar >= maxCost {
|
||||
amount, inc.Cost = 0.0, 0.0
|
||||
inc.BalanceInfo.MoneyBalanceUuid = b.Uuid
|
||||
inc.BalanceInfo.AccountId = ub.Id
|
||||
inc.BalanceInfo.AccountId = ub.ID
|
||||
inc.paid = true
|
||||
if count {
|
||||
ub.countUnits(amount, utils.MONETARY, cc, b)
|
||||
@@ -549,7 +549,7 @@ func (b *Balance) debitMoney(cd *CallDescriptor, ub *Account, moneyBalances Bala
|
||||
b.SubstractValue(amount)
|
||||
cd.MaxCostSoFar += amount
|
||||
inc.BalanceInfo.MoneyBalanceUuid = b.Uuid
|
||||
inc.BalanceInfo.AccountId = ub.Id
|
||||
inc.BalanceInfo.AccountId = ub.ID
|
||||
inc.paid = true
|
||||
if count {
|
||||
ub.countUnits(amount, utils.MONETARY, cc, b)
|
||||
@@ -661,17 +661,17 @@ func (bc BalanceChain) SaveDirtyBalances(acc *Account) {
|
||||
disabled := ""
|
||||
if b.account != nil { // only publish modifications for balances with account set
|
||||
//utils.LogStack()
|
||||
accountId = b.account.Id
|
||||
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,
|
||||
"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(),
|
||||
@@ -683,9 +683,9 @@ func (bc BalanceChain) SaveDirtyBalances(acc *Account) {
|
||||
})
|
||||
}
|
||||
}
|
||||
if b.account != nil && b.account != acc && b.dirty && savedAccounts[b.account.Id] == false {
|
||||
if b.account != nil && b.account != acc && b.dirty && savedAccounts[b.account.ID] == false {
|
||||
accountingStorage.SetAccount(b.account)
|
||||
savedAccounts[b.account.Id] = true
|
||||
savedAccounts[b.account.ID] = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -150,13 +150,14 @@ type CallDescriptor struct {
|
||||
TOR string // used unit balances selector
|
||||
ExtraFields map[string]string // Extra fields, mostly used for user profile matching
|
||||
// session limits
|
||||
MaxRate float64
|
||||
MaxRateUnit time.Duration
|
||||
MaxCostSoFar float64
|
||||
CgrID string
|
||||
RunID string
|
||||
account *Account
|
||||
testCallcost *CallCost // testing purpose only!
|
||||
MaxRate float64
|
||||
MaxRateUnit time.Duration
|
||||
MaxCostSoFar float64
|
||||
CgrID string
|
||||
RunID string
|
||||
ForceDuration bool // for Max debit if less than duration return err
|
||||
account *Account
|
||||
testCallcost *CallCost // testing purpose only!
|
||||
}
|
||||
|
||||
func (cd *CallDescriptor) ValidateCallData() error {
|
||||
@@ -180,7 +181,7 @@ func (cd *CallDescriptor) getAccount() (ub *Account, err error) {
|
||||
cd.account, err = accountingStorage.GetAccount(cd.GetAccountKey())
|
||||
}
|
||||
if cd.account != nil && cd.account.Disabled {
|
||||
return nil, fmt.Errorf("User %s is disabled", cd.account.Id)
|
||||
return nil, fmt.Errorf("User %s is disabled", cd.account.ID)
|
||||
}
|
||||
return cd.account, err
|
||||
}
|
||||
@@ -728,9 +729,16 @@ func (cd *CallDescriptor) MaxDebit() (cc *CallCost, err error) {
|
||||
return nil, utils.ErrAccountNotFound
|
||||
} else {
|
||||
//log.Printf("ACC: %+v", account)
|
||||
if memberIds, err := account.GetUniqueSharedGroupMembers(cd); err == nil {
|
||||
if memberIDs, err := account.GetUniqueSharedGroupMembers(cd); err == nil {
|
||||
_, err = Guardian.Guard(func() (interface{}, error) {
|
||||
remainingDuration, err := cd.getMaxSessionDuration(account)
|
||||
if err != nil && cd.GetDuration() > 0 {
|
||||
return 0, err
|
||||
}
|
||||
// check ForceDuartion
|
||||
if cd.ForceDuration && !account.AllowNegative && remainingDuration < cd.GetDuration() {
|
||||
return 0, utils.ErrInsufficientCredit
|
||||
}
|
||||
//log.Print("AFTER MAX SESSION: ", cd)
|
||||
if err != nil || remainingDuration == 0 {
|
||||
cc = cd.CreateCallCost()
|
||||
@@ -758,7 +766,7 @@ func (cd *CallDescriptor) MaxDebit() (cc *CallCost, err error) {
|
||||
cc, err = cd.debit(account, false, true)
|
||||
//log.Print(balanceMap[0].Value, balanceMap[1].Value)
|
||||
return 0, err
|
||||
}, 0, memberIds.Slice()...)
|
||||
}, 0, memberIDs.Slice()...)
|
||||
if err != nil {
|
||||
return cc, err
|
||||
}
|
||||
|
||||
@@ -51,24 +51,24 @@ func populateDB() {
|
||||
}
|
||||
|
||||
minu := &Account{
|
||||
Id: "vdf:minu",
|
||||
ID: "vdf:minu",
|
||||
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",
|
||||
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{
|
||||
Id: "vdf:luna",
|
||||
ID: "vdf:luna",
|
||||
BalanceMap: map[string]BalanceChain{
|
||||
utils.MONETARY: BalanceChain{
|
||||
&Balance{Value: 0, Weight: 20},
|
||||
@@ -76,11 +76,11 @@ func populateDB() {
|
||||
}
|
||||
// this is added to test if csv load tests account will not overwrite balances
|
||||
minitsboy := &Account{
|
||||
Id: "vdf:minitsboy",
|
||||
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},
|
||||
@@ -88,14 +88,14 @@ func populateDB() {
|
||||
},
|
||||
}
|
||||
max := &Account{
|
||||
Id: "cgrates.org:max",
|
||||
ID: "cgrates.org:max",
|
||||
BalanceMap: map[string]BalanceChain{
|
||||
utils.MONETARY: BalanceChain{
|
||||
&Balance{Value: 11, Weight: 20},
|
||||
}},
|
||||
}
|
||||
money := &Account{
|
||||
Id: "cgrates.org:money",
|
||||
ID: "cgrates.org:money",
|
||||
BalanceMap: map[string]BalanceChain{
|
||||
utils.MONETARY: BalanceChain{
|
||||
&Balance{Value: 10000, Weight: 10},
|
||||
@@ -1271,6 +1271,31 @@ func TestMaxDebitZeroDefinedRate(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestMaxDebitForceDuration(t *testing.T) {
|
||||
ap, _ := ratingStorage.GetActionPlan("TOPUP10_AT", false)
|
||||
for _, at := range ap.ActionTimings {
|
||||
at.accountIDs = ap.AccountIDs
|
||||
at.Execute()
|
||||
}
|
||||
cd1 := &CallDescriptor{
|
||||
Direction: "*out",
|
||||
Category: "call",
|
||||
Tenant: "cgrates.org",
|
||||
Subject: "12345",
|
||||
Account: "12345",
|
||||
Destination: "447956",
|
||||
TimeStart: time.Date(2014, 3, 4, 6, 0, 0, 0, time.UTC),
|
||||
TimeEnd: time.Date(2014, 3, 4, 6, 1, 40, 0, time.UTC),
|
||||
LoopIndex: 0,
|
||||
DurationIndex: 0,
|
||||
ForceDuration: true,
|
||||
}
|
||||
_, err := cd1.MaxDebit()
|
||||
if err != utils.ErrInsufficientCredit {
|
||||
t.Fatal("Error forcing duration: ", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestMaxDebitZeroDefinedRateOnlyMinutes(t *testing.T) {
|
||||
ap, _ := ratingStorage.GetActionPlan("TOPUP10_AT", false)
|
||||
for _, at := range ap.ActionTimings {
|
||||
|
||||
@@ -1101,7 +1101,7 @@ func TestLoadAccountActions(t *testing.T) {
|
||||
}
|
||||
aa := csvr.accountActions["vdf:minitsboy"]
|
||||
expected := &Account{
|
||||
Id: "vdf:minitsboy",
|
||||
ID: "vdf:minitsboy",
|
||||
UnitCounters: UnitCounters{
|
||||
utils.VOICE: []*UnitCounter{
|
||||
&UnitCounter{
|
||||
@@ -1136,12 +1136,12 @@ func TestLoadAccountActions(t *testing.T) {
|
||||
t.Errorf("Error loading account action: %+v", utils.ToIJSON(aa.UnitCounters[utils.VOICE][0].Counters[0].Filter))
|
||||
}
|
||||
// test that it does not overwrite balances
|
||||
existing, err := accountingStorage.GetAccount(aa.Id)
|
||||
existing, err := accountingStorage.GetAccount(aa.ID)
|
||||
if err != nil || len(existing.BalanceMap) != 2 {
|
||||
t.Errorf("The account was not set before load: %+v", existing)
|
||||
}
|
||||
accountingStorage.SetAccount(aa)
|
||||
existing, err = accountingStorage.GetAccount(aa.Id)
|
||||
existing, err = accountingStorage.GetAccount(aa.ID)
|
||||
if err != nil || len(existing.BalanceMap) != 2 {
|
||||
t.Errorf("The set account altered the balances: %+v", existing)
|
||||
}
|
||||
|
||||
@@ -71,10 +71,10 @@ 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")}
|
||||
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}}}
|
||||
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 {
|
||||
t.Error(err)
|
||||
}
|
||||
@@ -435,10 +435,10 @@ 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)}
|
||||
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}
|
||||
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} {
|
||||
if err := accountingStorage.SetAccount(acnt); err != nil {
|
||||
t.Error(err)
|
||||
|
||||
@@ -51,7 +51,7 @@ type SharingParameters struct {
|
||||
|
||||
func (sg *SharedGroup) SortBalancesByStrategy(myBalance *Balance, bc BalanceChain) BalanceChain {
|
||||
sharingParameters := sg.AccountParameters[utils.ANY]
|
||||
if sp, hasParamsForAccount := sg.AccountParameters[myBalance.account.Id]; hasParamsForAccount {
|
||||
if sp, hasParamsForAccount := sg.AccountParameters[myBalance.account.ID]; hasParamsForAccount {
|
||||
sharingParameters = sp
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ func (sg *SharedGroup) GetBalances(destination, category, direction, balanceType
|
||||
// if len(sg.members) == 0 {
|
||||
for ubId := range sg.MemberIds {
|
||||
var nUb *Account
|
||||
if ubId == ub.Id { // skip the initiating user
|
||||
if ubId == ub.ID { // skip the initiating user
|
||||
nUb = ub
|
||||
} else {
|
||||
nUb, _ = accountingStorage.GetAccount(ubId)
|
||||
|
||||
@@ -52,7 +52,7 @@ func TestSharedSetGet(t *testing.T) {
|
||||
func TestSharedPopBalanceByStrategyLow(t *testing.T) {
|
||||
bc := BalanceChain{
|
||||
&Balance{Value: 2.0},
|
||||
&Balance{Uuid: "uuuu", Value: 1.0, account: &Account{Id: "test"}},
|
||||
&Balance{Uuid: "uuuu", Value: 1.0, account: &Account{ID: "test"}},
|
||||
&Balance{Value: 3.0},
|
||||
}
|
||||
sg := &SharedGroup{AccountParameters: map[string]*SharingParameters{
|
||||
@@ -68,7 +68,7 @@ func TestSharedPopBalanceByStrategyLow(t *testing.T) {
|
||||
|
||||
func TestSharedPopBalanceByStrategyHigh(t *testing.T) {
|
||||
bc := BalanceChain{
|
||||
&Balance{Uuid: "uuuu", Value: 2.0, account: &Account{Id: "test"}},
|
||||
&Balance{Uuid: "uuuu", Value: 2.0, account: &Account{ID: "test"}},
|
||||
&Balance{Value: 1.0},
|
||||
&Balance{Value: 3.0},
|
||||
}
|
||||
@@ -85,7 +85,7 @@ func TestSharedPopBalanceByStrategyHigh(t *testing.T) {
|
||||
|
||||
func TestSharedPopBalanceByStrategyMineHigh(t *testing.T) {
|
||||
bc := BalanceChain{
|
||||
&Balance{Uuid: "uuuu", Value: 2.0, account: &Account{Id: "test"}},
|
||||
&Balance{Uuid: "uuuu", Value: 2.0, account: &Account{ID: "test"}},
|
||||
&Balance{Value: 1.0},
|
||||
&Balance{Value: 3.0},
|
||||
}
|
||||
|
||||
@@ -464,7 +464,7 @@ func (ms *MapStorage) SetSharedGroup(sg *SharedGroup) (err error) {
|
||||
|
||||
func (ms *MapStorage) GetAccount(key string) (ub *Account, err error) {
|
||||
if values, ok := ms.dict[utils.ACCOUNT_PREFIX+key]; ok {
|
||||
ub = &Account{Id: key}
|
||||
ub = &Account{ID: key}
|
||||
err = ms.ms.Unmarshal(values, ub)
|
||||
} else {
|
||||
return nil, utils.ErrNotFound
|
||||
@@ -477,7 +477,7 @@ func (ms *MapStorage) SetAccount(ub *Account) (err error) {
|
||||
// UPDATE: if all balances expired and were cleaned it makes
|
||||
// sense to write empty balance map
|
||||
if len(ub.BalanceMap) == 0 {
|
||||
if ac, err := ms.GetAccount(ub.Id); err == nil && !ac.allBalancesExpired() {
|
||||
if ac, err := ms.GetAccount(ub.ID); err == nil && !ac.allBalancesExpired() {
|
||||
ac.ActionTriggers = ub.ActionTriggers
|
||||
ac.UnitCounters = ub.UnitCounters
|
||||
ac.AllowNegative = ub.AllowNegative
|
||||
@@ -486,7 +486,7 @@ func (ms *MapStorage) SetAccount(ub *Account) (err error) {
|
||||
}
|
||||
}
|
||||
result, err := ms.ms.Marshal(ub)
|
||||
ms.dict[utils.ACCOUNT_PREFIX+ub.Id] = result
|
||||
ms.dict[utils.ACCOUNT_PREFIX+ub.ID] = result
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -870,7 +870,7 @@ func (ms *MongoStorage) SetAccount(acc *Account) error {
|
||||
// UPDATE: if all balances expired and were cleaned it makes
|
||||
// sense to write empty balance map
|
||||
if len(acc.BalanceMap) == 0 {
|
||||
if ac, err := ms.GetAccount(acc.Id); err == nil && !ac.allBalancesExpired() {
|
||||
if ac, err := ms.GetAccount(acc.ID); err == nil && !ac.allBalancesExpired() {
|
||||
ac.ActionTriggers = acc.ActionTriggers
|
||||
ac.UnitCounters = acc.UnitCounters
|
||||
ac.AllowNegative = acc.AllowNegative
|
||||
@@ -878,7 +878,7 @@ func (ms *MongoStorage) SetAccount(acc *Account) error {
|
||||
acc = ac
|
||||
}
|
||||
}
|
||||
_, err := ms.db.C(colAcc).Upsert(bson.M{"id": acc.Id}, acc)
|
||||
_, err := ms.db.C(colAcc).Upsert(bson.M{"id": acc.ID}, acc)
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -621,7 +621,7 @@ func (rs *RedisStorage) GetAccount(key string) (*Account, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ub := &Account{Id: key}
|
||||
ub := &Account{ID: key}
|
||||
if err = rs.ms.Unmarshal(values, ub); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -633,7 +633,7 @@ func (rs *RedisStorage) SetAccount(ub *Account) (err error) {
|
||||
// UPDATE: if all balances expired and were cleaned it makes
|
||||
// sense to write empty balance map
|
||||
if len(ub.BalanceMap) == 0 {
|
||||
if ac, err := rs.GetAccount(ub.Id); err == nil && !ac.allBalancesExpired() {
|
||||
if ac, err := rs.GetAccount(ub.ID); err == nil && !ac.allBalancesExpired() {
|
||||
ac.ActionTriggers = ub.ActionTriggers
|
||||
ac.UnitCounters = ub.UnitCounters
|
||||
ac.AllowNegative = ub.AllowNegative
|
||||
@@ -642,7 +642,7 @@ func (rs *RedisStorage) SetAccount(ub *Account) (err error) {
|
||||
}
|
||||
}
|
||||
result, err := rs.ms.Marshal(ub)
|
||||
err = rs.db.Cmd("SET", utils.ACCOUNT_PREFIX+ub.Id, result).Err
|
||||
err = rs.db.Cmd("SET", utils.ACCOUNT_PREFIX+ub.ID, result).Err
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -327,9 +327,9 @@ func GetUB() *Account {
|
||||
var zeroTime time.Time
|
||||
zeroTime = zeroTime.UTC() // for deep equal to find location
|
||||
ub := &Account{
|
||||
Id: "rif",
|
||||
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},
|
||||
}
|
||||
|
||||
@@ -1086,7 +1086,7 @@ func (tpr *TpReader) LoadAccountActionsFiltered(qriedAA *TpAccountAction) error
|
||||
ub, err := tpr.accountingStorage.GetAccount(id)
|
||||
if err != nil {
|
||||
ub = &Account{
|
||||
Id: id,
|
||||
ID: id,
|
||||
}
|
||||
}
|
||||
ub.ActionTriggers = actionTriggers
|
||||
@@ -1121,7 +1121,7 @@ func (tpr *TpReader) LoadAccountActions() (err error) {
|
||||
}
|
||||
}
|
||||
ub := &Account{
|
||||
Id: aa.KeyId(),
|
||||
ID: aa.KeyId(),
|
||||
ActionTriggers: aTriggers,
|
||||
AllowNegative: aa.AllowNegative,
|
||||
Disabled: aa.Disabled,
|
||||
@@ -1763,7 +1763,7 @@ func (tpr *TpReader) WriteToDatabase(flush, verbose bool) (err error) {
|
||||
return err
|
||||
}
|
||||
if verbose {
|
||||
log.Println("\t", ub.Id)
|
||||
log.Println("\t", ub.ID)
|
||||
}
|
||||
}
|
||||
if verbose {
|
||||
|
||||
@@ -63,7 +63,7 @@ ENABLE_ACNT,*enable_account,,,,,,,,,,,,,,false,false,10`
|
||||
csvr.WriteToDatabase(false, false)
|
||||
ratingDbAcntActs.CacheRatingAll()
|
||||
acntDbAcntActs.CacheAccountingAll()
|
||||
expectAcnt := &engine.Account{Id: "cgrates.org:1"}
|
||||
expectAcnt := &engine.Account{ID: "cgrates.org:1"}
|
||||
if acnt, err := acntDbAcntActs.GetAccount("cgrates.org:1"); err != nil {
|
||||
t.Error(err)
|
||||
} else if acnt == nil {
|
||||
@@ -82,7 +82,7 @@ func TestAcntActsDisableAcnt(t *testing.T) {
|
||||
if err := at.Execute(); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
expectAcnt := &engine.Account{Id: "cgrates.org:1", Disabled: true}
|
||||
expectAcnt := &engine.Account{ID: "cgrates.org:1", Disabled: true}
|
||||
if acnt, err := acntDbAcntActs.GetAccount(acnt1Tag); err != nil {
|
||||
t.Error(err)
|
||||
} else if !reflect.DeepEqual(expectAcnt, acnt) {
|
||||
@@ -99,7 +99,7 @@ func TestAcntActsEnableAcnt(t *testing.T) {
|
||||
if err := at.Execute(); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
expectAcnt := &engine.Account{Id: "cgrates.org:1", Disabled: false}
|
||||
expectAcnt := &engine.Account{ID: "cgrates.org:1", Disabled: false}
|
||||
if acnt, err := acntDbAcntActs.GetAccount(acnt1Tag); err != nil {
|
||||
t.Error(err)
|
||||
} else if !reflect.DeepEqual(expectAcnt, acnt) {
|
||||
|
||||
@@ -1164,9 +1164,9 @@ func TestTutLocalSetAccount(t *testing.T) {
|
||||
t.Errorf("Accounts received: %+v", acnts)
|
||||
} else {
|
||||
acnt := acnts[0]
|
||||
dta, _ := utils.NewTAFromAccountKey(acnt.Id)
|
||||
dta, _ := utils.NewTAFromAccountKey(acnt.ID)
|
||||
if dta.Tenant != attrs.Tenant || dta.Account != attrs.Account {
|
||||
t.Error("Unexpected account id received: ", acnt.Id)
|
||||
t.Error("Unexpected account id received: ", acnt.ID)
|
||||
}
|
||||
if balances := acnt.BalanceMap["*monetary"]; len(balances) != 1 {
|
||||
t.Errorf("Unexpected balances found: %+v", balances)
|
||||
@@ -1194,9 +1194,9 @@ func TestTutLocalSetAccount(t *testing.T) {
|
||||
t.Errorf("Accounts received: %+v", acnts)
|
||||
} else {
|
||||
acnt := acnts[0]
|
||||
dta, _ := utils.NewTAFromAccountKey(acnt.Id)
|
||||
dta, _ := utils.NewTAFromAccountKey(acnt.ID)
|
||||
if dta.Tenant != attrs.Tenant || dta.Account != attrs.Account {
|
||||
t.Error("Unexpected account id received: ", acnt.Id)
|
||||
t.Error("Unexpected account id received: ", acnt.ID)
|
||||
}
|
||||
if balances := acnt.BalanceMap["*monetary"]; len(balances) != 1 {
|
||||
t.Errorf("Unexpected balances found: %+v", balances)
|
||||
@@ -1225,9 +1225,9 @@ func TestTutLocalSetAccount(t *testing.T) {
|
||||
t.Errorf("Accounts received: %+v", acnts)
|
||||
} else {
|
||||
acnt := acnts[0]
|
||||
dta, _ := utils.NewTAFromAccountKey(acnt.Id)
|
||||
dta, _ := utils.NewTAFromAccountKey(acnt.ID)
|
||||
if dta.Tenant != attrs.Tenant || dta.Account != attrs.Account {
|
||||
t.Error("Unexpected account id received: ", acnt.Id)
|
||||
t.Error("Unexpected account id received: ", acnt.ID)
|
||||
}
|
||||
if balances := acnt.BalanceMap["*monetary"]; len(balances) != 1 {
|
||||
t.Errorf("Unexpected balances found: %+v", balances)
|
||||
|
||||
@@ -29,7 +29,7 @@ var (
|
||||
ErrRatingPlanNotFound = errors.New("RATING_PLAN_NOT_FOUND")
|
||||
ErrAccountNotFound = errors.New("ACCOUNT_NOT_FOUND")
|
||||
ErrUserNotFound = errors.New("USER_NOT_FOUND")
|
||||
ErrCreditInsufficient = errors.New("CREDIT_INSUFFICIENT")
|
||||
ErrInsufficientCredit = errors.New("INSUFFICENT_CREDIT")
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
Reference in New Issue
Block a user