From af86bde715bfa1e798b6d8e222af6eb07c7315eb Mon Sep 17 00:00:00 2001 From: Radu Ioan Fericean Date: Tue, 20 Oct 2015 17:35:08 +0300 Subject: [PATCH] tests passing after account direction removal --- apier/v1/accounts.go | 19 ++++---- apier/v1/accounts_test.go | 10 ++--- apier/v1/apier.go | 6 +-- apier/v1/apier_local_test.go | 52 +++++++++++----------- apier/v1/tpaccountactions.go | 2 +- console/account_add.go | 2 +- console/account_remove.go | 2 +- console/accounts.go | 4 +- engine/actions_local_test.go | 6 +-- engine/actions_test.go | 28 ++++++------ engine/calldesc.go | 4 +- engine/calldesc_test.go | 22 ++++----- engine/loader_csv_test.go | 26 +++++------ engine/model_converters.go | 1 - engine/model_helpers.go | 1 - engine/model_helpers_test.go | 3 +- engine/models.go | 18 ++++---- engine/responder_test.go | 12 ++--- engine/storage_mongo_local_test.go | 8 ++-- engine/storage_mongo_tp.go | 12 ++--- engine/storage_mysql_local_test.go | 6 +-- engine/storage_psql_local_test.go | 6 +-- engine/storage_sql.go | 5 +-- engine/storage_test.go | 6 +-- general_tests/acntacts_test.go | 14 +++--- general_tests/auth_test.go | 4 +- general_tests/ddazmbl1_test.go | 8 ++-- general_tests/ddazmbl2_test.go | 8 ++-- general_tests/ddazmbl3_test.go | 8 ++-- general_tests/tutorial_fs_calls_test.go | 42 ++++++++--------- general_tests/tutorial_kam_calls_test.go | 40 ++++++++--------- general_tests/tutorial_local_test.go | 12 ++--- general_tests/tutorial_osips_calls_test.go | 40 ++++++++--------- utils/apitpdata.go | 28 +++++------- utils/consts.go | 2 +- utils/coreutils.go | 4 +- 36 files changed, 223 insertions(+), 248 deletions(-) diff --git a/apier/v1/accounts.go b/apier/v1/accounts.go index 2b18af8d0..f007f1537 100644 --- a/apier/v1/accounts.go +++ b/apier/v1/accounts.go @@ -52,7 +52,7 @@ func (self *ApierV1) GetAccountActionPlan(attrs AttrAcntAction, reply *[]*Accoun } for _, ats := range allATs { for _, at := range ats { - if utils.IsSliceMember(at.AccountIds, utils.AccountKey(attrs.Tenant, attrs.Account, attrs.Direction)) { + if utils.IsSliceMember(at.AccountIds, utils.AccountKey(attrs.Tenant, attrs.Account)) { accountATs = append(accountATs, &AccountActionTiming{Uuid: at.Uuid, ActionPlanId: at.Id, ActionsId: at.ActionsId, NextExecTime: at.GetNextStartTime(time.Now())}) } } @@ -87,7 +87,7 @@ func (self *ApierV1) RemActionTiming(attrs AttrRemActionTiming, reply *string) e } else if len(ats) == 0 { return 0, utils.ErrNotFound } - ats = engine.RemActionPlan(ats, attrs.ActionTimingId, utils.AccountKey(attrs.Tenant, attrs.Account, attrs.Direction)) + ats = engine.RemActionPlan(ats, attrs.ActionTimingId, utils.AccountKey(attrs.Tenant, attrs.Account)) if err := self.RatingDb.SetActionPlans(attrs.ActionPlanId, ats); err != nil { return 0, err } @@ -109,7 +109,7 @@ func (self *ApierV1) GetAccountActionTriggers(attrs AttrAcntAction, reply *engin if missing := utils.MissingStructFields(&attrs, []string{"Tenant", "Account", "Direction"}); len(missing) != 0 { return utils.NewErrMandatoryIeMissing(missing...) } - if balance, err := self.AccountDb.GetAccount(utils.AccountKey(attrs.Tenant, attrs.Account, attrs.Direction)); err != nil { + if balance, err := self.AccountDb.GetAccount(utils.AccountKey(attrs.Tenant, attrs.Account)); err != nil { return utils.NewErrServerError(err) } else { *reply = balance.ActionTriggers @@ -129,7 +129,7 @@ func (self *ApierV1) RemAccountActionTriggers(attrs AttrRemAcntActionTriggers, r if missing := utils.MissingStructFields(&attrs, []string{"Tenant", "Account", "Direction"}); len(missing) != 0 { return utils.NewErrMandatoryIeMissing(missing...) } - balanceId := utils.AccountKey(attrs.Tenant, attrs.Account, attrs.Direction) + balanceId := utils.AccountKey(attrs.Tenant, attrs.Account) _, err := engine.Guardian.Guard(func() (interface{}, error) { ub, err := self.AccountDb.GetAccount(balanceId) if err != nil { @@ -160,7 +160,7 @@ func (self *ApierV1) SetAccount(attr utils.AttrSetAccount, reply *string) error if missing := utils.MissingStructFields(&attr, []string{"Tenant", "Direction", "Account"}); len(missing) != 0 { return utils.NewErrMandatoryIeMissing(missing...) } - balanceId := utils.AccountKey(attr.Tenant, attr.Account, attr.Direction) + balanceId := utils.AccountKey(attr.Tenant, attr.Account) var ub *engine.Account var ats engine.ActionPlans _, err := engine.Guardian.Guard(func() (interface{}, error) { @@ -227,7 +227,7 @@ func (self *ApierV1) RemoveAccount(attr utils.AttrRemoveAccount, reply *string) if missing := utils.MissingStructFields(&attr, []string{"Tenant", "Direction", "Account"}); len(missing) != 0 { return utils.NewErrMandatoryIeMissing(missing...) } - accountId := utils.AccountKey(attr.Tenant, attr.Account, attr.Direction) + accountId := utils.AccountKey(attr.Tenant, attr.Account) _, err := engine.Guardian.Guard(func() (interface{}, error) { if err := self.AccountDb.RemoveAccount(accountId); err != nil { return 0, err @@ -246,13 +246,10 @@ func (self *ApierV1) GetAccounts(attr utils.AttrGetAccounts, reply *[]*engine.Ac if len(attr.Tenant) == 0 { return utils.NewErrMandatoryIeMissing("Tenanat") } - if len(attr.Direction) == 0 { - attr.Direction = utils.OUT - } var accountKeys []string var err error if len(attr.AccountIds) == 0 { - if accountKeys, err = self.AccountDb.GetKeysForPrefix(utils.ACCOUNT_PREFIX + utils.ConcatenatedKey(attr.Direction, attr.Tenant)); err != nil { + if accountKeys, err = self.AccountDb.GetKeysForPrefix(utils.ACCOUNT_PREFIX + utils.ConcatenatedKey(attr.Tenant)); err != nil { return err } } else { @@ -260,7 +257,7 @@ func (self *ApierV1) GetAccounts(attr utils.AttrGetAccounts, reply *[]*engine.Ac if len(acntId) == 0 { // Source of error returned from redis (key not found) continue } - accountKeys = append(accountKeys, utils.ACCOUNT_PREFIX+utils.ConcatenatedKey(attr.Direction, attr.Tenant, acntId)) + accountKeys = append(accountKeys, utils.ACCOUNT_PREFIX+utils.ConcatenatedKey(attr.Tenant, acntId)) } } if len(accountKeys) == 0 { diff --git a/apier/v1/accounts_test.go b/apier/v1/accounts_test.go index 474588c90..5c6a8604a 100644 --- a/apier/v1/accounts_test.go +++ b/apier/v1/accounts_test.go @@ -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(utils.OUT, 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(utils.OUT, 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(utils.OUT, 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(utils.OUT, 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(utils.OUT, 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 { diff --git a/apier/v1/apier.go b/apier/v1/apier.go index 34b196e65..b4e84c69a 100644 --- a/apier/v1/apier.go +++ b/apier/v1/apier.go @@ -104,7 +104,7 @@ func (self *ApierV1) GetRatingPlan(rplnId string, reply *engine.RatingPlan) erro // Get balance func (self *ApierV1) GetAccount(attr *utils.AttrGetAccount, reply *engine.Account) error { - tag := fmt.Sprintf("%s:%s:%s", attr.Direction, attr.Tenant, attr.Account) + tag := fmt.Sprintf("%s:%s", attr.Tenant, attr.Account) userBalance, err := self.AccountDb.GetAccount(tag) if err != nil { return err @@ -782,7 +782,7 @@ func (self *ApierV1) AddTriggeredAction(attr AttrAddActionTrigger, reply *string Executed: false, } - tag := utils.AccountKey(attr.Tenant, attr.Account, attr.BalanceDirection) + tag := utils.AccountKey(attr.Tenant, attr.Account) _, err = engine.Guardian.Guard(func() (interface{}, error) { userBalance, err := self.AccountDb.GetAccount(tag) if err != nil { @@ -852,7 +852,7 @@ func (self *ApierV1) ResetTriggeredActions(attr AttrResetTriggeredAction, reply ExtraParameters: string(extraParameters), } } - accID := utils.AccountKey(attr.Tenant, attr.Account, attr.Direction) + accID := utils.AccountKey(attr.Tenant, attr.Account) _, err := engine.Guardian.Guard(func() (interface{}, error) { acc, err := self.AccountDb.GetAccount(accID) if err != nil { diff --git a/apier/v1/apier_local_test.go b/apier/v1/apier_local_test.go index 19275a329..d30f24ab9 100644 --- a/apier/v1/apier_local_test.go +++ b/apier/v1/apier_local_test.go @@ -655,15 +655,15 @@ func TestApierTPAccountActions(t *testing.T) { } reply := "" aa1 := &utils.TPAccountActions{TPid: utils.TEST_SQL, LoadId: utils.TEST_SQL, Tenant: "cgrates.org", - Account: "1001", Direction: "*out", ActionPlanId: "PREPAID_10", ActionTriggersId: "STANDARD_TRIGGERS"} + Account: "1001", ActionPlanId: "PREPAID_10", ActionTriggersId: "STANDARD_TRIGGERS"} aa2 := &utils.TPAccountActions{TPid: utils.TEST_SQL, LoadId: utils.TEST_SQL, Tenant: "cgrates.org", - Account: "1002", Direction: "*out", ActionPlanId: "PREPAID_10", ActionTriggersId: "STANDARD_TRIGGERS"} + Account: "1002", ActionPlanId: "PREPAID_10", ActionTriggersId: "STANDARD_TRIGGERS"} aa3 := &utils.TPAccountActions{TPid: utils.TEST_SQL, LoadId: utils.TEST_SQL, Tenant: "cgrates.org", - Account: "1003", Direction: "*out", ActionPlanId: "PREPAID_10", ActionTriggersId: "STANDARD_TRIGGERS"} + Account: "1003", ActionPlanId: "PREPAID_10", ActionTriggersId: "STANDARD_TRIGGERS"} aa4 := &utils.TPAccountActions{TPid: utils.TEST_SQL, LoadId: utils.TEST_SQL, Tenant: "cgrates.org", - Account: "1004", Direction: "*out", ActionPlanId: "PREPAID_10", ActionTriggersId: "STANDARD_TRIGGERS"} + Account: "1004", ActionPlanId: "PREPAID_10", ActionTriggersId: "STANDARD_TRIGGERS"} aa5 := &utils.TPAccountActions{TPid: utils.TEST_SQL, LoadId: utils.TEST_SQL, Tenant: "cgrates.org", - Account: "1005", Direction: "*out", ActionPlanId: "PREPAID_10", ActionTriggersId: "STANDARD_TRIGGERS"} + Account: "1005", ActionPlanId: "PREPAID_10", ActionTriggersId: "STANDARD_TRIGGERS"} aaTst := new(utils.TPAccountActions) *aaTst = *aa1 aaTst.Account = utils.TEST_SQL @@ -784,7 +784,7 @@ func TestApierLoadAccountActions(t *testing.T) { return } reply := "" - aa1 := &utils.TPAccountActions{TPid: utils.TEST_SQL, LoadId: utils.TEST_SQL, Tenant: "cgrates.org", Account: "1001", Direction: "*out"} + aa1 := &utils.TPAccountActions{TPid: utils.TEST_SQL, LoadId: utils.TEST_SQL, Tenant: "cgrates.org", Account: "1001"} if err := rater.Call("ApierV1.LoadAccountActions", aa1, &reply); err != nil { t.Error("Got error on ApierV1.LoadAccountActions: ", err.Error()) } else if reply != "OK" { @@ -1093,7 +1093,7 @@ func TestApierSetAccount(t *testing.T) { return } reply := "" - attrs := &utils.AttrSetAccount{Tenant: "cgrates.org", Direction: "*out", Account: "dan7", ActionPlanId: "ATMS_1"} + attrs := &utils.AttrSetAccount{Tenant: "cgrates.org", Account: "dan7", ActionPlanId: "ATMS_1"} if err := rater.Call("ApierV1.SetAccount", attrs, &reply); err != nil { t.Error("Got error on ApierV1.SetAccount: ", err.Error()) } else if reply != "OK" { @@ -1154,36 +1154,36 @@ func TestApierGetAccount(t *testing.T) { return } var reply *engine.Account - attrs := &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "1001", Direction: "*out"} + attrs := &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "1001"} if err := rater.Call("ApierV1.GetAccount", attrs, &reply); err != nil { t.Error("Got error on ApierV1.GetAccount: ", err.Error()) - } else if reply.BalanceMap[utils.MONETARY+attrs.Direction].GetTotalValue() != 11.5 { // We expect 11.5 since we have added in the previous test 1.5 - t.Errorf("Calling ApierV1.GetBalance expected: 11.5, received: %f", reply.BalanceMap[utils.MONETARY+attrs.Direction].GetTotalValue()) + } else if reply.BalanceMap[utils.MONETARY].GetTotalValue() != 11.5 { // We expect 11.5 since we have added in the previous test 1.5 + t.Errorf("Calling ApierV1.GetBalance expected: 11.5, received: %f", reply.BalanceMap[utils.MONETARY].GetTotalValue()) } - attrs = &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "dan", Direction: "*out"} + attrs = &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "dan"} if err := rater.Call("ApierV1.GetAccount", attrs, &reply); err != nil { t.Error("Got error on ApierV1.GetAccount: ", err.Error()) - } else if reply.BalanceMap[utils.MONETARY+attrs.Direction].GetTotalValue() != 1.5 { - t.Errorf("Calling ApierV1.GetAccount expected: 1.5, received: %f", reply.BalanceMap[utils.MONETARY+attrs.Direction].GetTotalValue()) + } else if reply.BalanceMap[utils.MONETARY].GetTotalValue() != 1.5 { + t.Errorf("Calling ApierV1.GetAccount expected: 1.5, received: %f", reply.BalanceMap[utils.MONETARY].GetTotalValue()) } // The one we have topped up though executeAction - attrs = &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "dan2", Direction: "*out"} + attrs = &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "dan2"} if err := rater.Call("ApierV1.GetAccount", attrs, &reply); err != nil { t.Error("Got error on ApierV1.GetAccount: ", err.Error()) - } else if reply.BalanceMap[utils.MONETARY+attrs.Direction].GetTotalValue() != 11.5 { - t.Errorf("Calling ApierV1.GetAccount expected: 10, received: %f", reply.BalanceMap[utils.MONETARY+attrs.Direction].GetTotalValue()) + } else if reply.BalanceMap[utils.MONETARY].GetTotalValue() != 11.5 { + t.Errorf("Calling ApierV1.GetAccount expected: 10, received: %f", reply.BalanceMap[utils.MONETARY].GetTotalValue()) } - attrs = &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "dan3", Direction: "*out"} + attrs = &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "dan3"} if err := rater.Call("ApierV1.GetAccount", attrs, &reply); err != nil { t.Error("Got error on ApierV1.GetAccount: ", err.Error()) - } else if reply.BalanceMap[utils.MONETARY+attrs.Direction].GetTotalValue() != 3.6 { - t.Errorf("Calling ApierV1.GetAccount expected: 3.6, received: %f", reply.BalanceMap[utils.MONETARY+attrs.Direction].GetTotalValue()) + } else if reply.BalanceMap[utils.MONETARY].GetTotalValue() != 3.6 { + t.Errorf("Calling ApierV1.GetAccount expected: 3.6, received: %f", reply.BalanceMap[utils.MONETARY].GetTotalValue()) } - attrs = &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "dan6", Direction: "*out"} + attrs = &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "dan6"} if err := rater.Call("ApierV1.GetAccount", attrs, &reply); err != nil { t.Error("Got error on ApierV1.GetAccount: ", err.Error()) - } else if reply.BalanceMap[utils.MONETARY+attrs.Direction].GetTotalValue() != 1 { - t.Errorf("Calling ApierV1.GetAccount expected: 1, received: %f", reply.BalanceMap[utils.MONETARY+attrs.Direction].GetTotalValue()) + } else if reply.BalanceMap[utils.MONETARY].GetTotalValue() != 1 { + t.Errorf("Calling ApierV1.GetAccount expected: 1, received: %f", reply.BalanceMap[utils.MONETARY].GetTotalValue()) } } @@ -1193,7 +1193,7 @@ func TestApierTriggersExecute(t *testing.T) { return } reply := "" - attrs := &utils.AttrSetAccount{Tenant: "cgrates.org", Direction: "*out", Account: "dan8"} + attrs := &utils.AttrSetAccount{Tenant: "cgrates.org", Account: "dan8"} if err := rater.Call("ApierV1.SetAccount", attrs, &reply); err != nil { t.Error("Got error on ApierV1.SetAccount: ", err.Error()) } else if reply != "OK" { @@ -1289,11 +1289,11 @@ func TestApierGetAccountAfterLoad(t *testing.T) { return } var reply *engine.Account - attrs := &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "1001", Direction: "*out"} + attrs := &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "1001"} if err := rater.Call("ApierV1.GetAccount", attrs, &reply); err != nil { t.Error("Got error on ApierV1.GetAccount: ", err.Error()) - } else if reply.BalanceMap[utils.MONETARY+attrs.Direction].GetTotalValue() != 11 { - t.Errorf("Calling ApierV1.GetBalance expected: 11, received: %f", reply.BalanceMap[utils.MONETARY+attrs.Direction].GetTotalValue()) + } else if reply.BalanceMap[utils.MONETARY].GetTotalValue() != 11 { + t.Errorf("Calling ApierV1.GetBalance expected: 11, received: %f", reply.BalanceMap[utils.MONETARY].GetTotalValue()) } } diff --git a/apier/v1/tpaccountactions.go b/apier/v1/tpaccountactions.go index ab8bf2799..17990eff7 100644 --- a/apier/v1/tpaccountactions.go +++ b/apier/v1/tpaccountactions.go @@ -157,7 +157,7 @@ func (self *ApierV1) RemTPAccountActions(attrs AttrGetTPAccountActions, reply *s if err := aa.SetAccountActionId(attrs.AccountActionsId); err != nil { return err } - if err := self.StorDb.RemTpData(utils.TBL_TP_ACCOUNT_ACTIONS, aa.Tpid, map[string]string{"loadid": aa.Loadid, "direction": aa.Direction, "tenant": aa.Tenant, "account": aa.Account}); err != nil { + if err := self.StorDb.RemTpData(utils.TBL_TP_ACCOUNT_ACTIONS, aa.Tpid, map[string]string{"loadid": aa.Loadid, "tenant": aa.Tenant, "account": aa.Account}); err != nil { return utils.NewErrServerError(err) } else { *reply = "OK" diff --git a/console/account_add.go b/console/account_add.go index 315caa1b6..5875a4fce 100644 --- a/console/account_add.go +++ b/console/account_add.go @@ -47,7 +47,7 @@ func (self *CmdAddAccount) RpcMethod() string { func (self *CmdAddAccount) RpcParams(reset bool) interface{} { if reset || self.rpcParams == nil { - self.rpcParams = &utils.AttrSetAccount{Direction: utils.OUT} + self.rpcParams = &utils.AttrSetAccount{} } return self.rpcParams } diff --git a/console/account_remove.go b/console/account_remove.go index 10380d32f..da0ca5d7e 100644 --- a/console/account_remove.go +++ b/console/account_remove.go @@ -47,7 +47,7 @@ func (self *CmdRemoveAccount) RpcMethod() string { func (self *CmdRemoveAccount) RpcParams(reset bool) interface{} { if reset || self.rpcParams == nil { - self.rpcParams = &utils.AttrRemoveAccount{Direction: utils.OUT} + self.rpcParams = &utils.AttrRemoveAccount{} } return self.rpcParams } diff --git a/console/accounts.go b/console/accounts.go index 0e7ce79f9..f1d760fc3 100644 --- a/console/accounts.go +++ b/console/accounts.go @@ -27,7 +27,7 @@ func init() { c := &CmdGetAccounts{ name: "accounts", rpcMethod: "ApierV1.GetAccounts", - rpcParams: &utils.AttrGetAccounts{Direction: "*out"}, + rpcParams: &utils.AttrGetAccounts{}, } commands[c.Name()] = c c.CommandExecuter = &CommandExecuter{c} @@ -51,7 +51,7 @@ func (self *CmdGetAccounts) RpcMethod() string { func (self *CmdGetAccounts) RpcParams(reset bool) interface{} { if reset || self.rpcParams == nil { - self.rpcParams = &utils.AttrGetAccounts{Direction: "*out"} + self.rpcParams = &utils.AttrGetAccounts{} } return self.rpcParams } diff --git a/engine/actions_local_test.go b/engine/actions_local_test.go index b6da14eba..eea4919f8 100644 --- a/engine/actions_local_test.go +++ b/engine/actions_local_test.go @@ -84,14 +84,14 @@ func TestActionsLocalSetCdrlogActions(t *testing.T) { return } var reply string - attrsSetAccount := &utils.AttrSetAccount{Tenant: "cgrates.org", Direction: utils.OUT, Account: "dan2904"} + attrsSetAccount := &utils.AttrSetAccount{Tenant: "cgrates.org", Account: "dan2904"} if err := actsLclRpc.Call("ApierV1.SetAccount", attrsSetAccount, &reply); err != nil { t.Error("Got error on ApierV1.SetAccount: ", err.Error()) } else if reply != utils.OK { t.Errorf("Calling ApierV1.SetAccount received: %s", reply) } attrsAA := &utils.AttrSetActions{ActionsId: "ACTS_1", Actions: []*utils.TPAction{ - &utils.TPAction{Identifier: DEBIT, BalanceType: utils.MONETARY, Direction: attrsSetAccount.Direction, Units: 5.0, ExpiryTime: UNLIMITED, Weight: 20.0}, + &utils.TPAction{Identifier: DEBIT, BalanceType: utils.MONETARY, Units: 5.0, ExpiryTime: UNLIMITED, Weight: 20.0}, &utils.TPAction{Identifier: CDRLOG}, }} if err := actsLclRpc.Call("ApierV1.SetActions", attrsAA, &reply); err != nil && err.Error() != utils.ErrExists.Error() { @@ -99,7 +99,7 @@ func TestActionsLocalSetCdrlogActions(t *testing.T) { } else if reply != utils.OK { t.Errorf("Calling ApierV1.SetActions received: %s", reply) } - attrsEA := &utils.AttrExecuteAction{Direction: attrsSetAccount.Direction, Tenant: attrsSetAccount.Tenant, Account: attrsSetAccount.Account, ActionsId: attrsAA.ActionsId} + attrsEA := &utils.AttrExecuteAction{Tenant: attrsSetAccount.Tenant, Account: attrsSetAccount.Account, ActionsId: attrsAA.ActionsId} if err := actsLclRpc.Call("ApierV1.ExecuteAction", attrsEA, &reply); err != nil { t.Error("Got error on ApierV1.ExecuteAction: ", err.Error()) } else if reply != utils.OK { diff --git a/engine/actions_test.go b/engine/actions_test.go index b4a35883d..4ce0667ce 100644 --- a/engine/actions_test.go +++ b/engine/actions_test.go @@ -1065,7 +1065,7 @@ func TestActionMakeNegative(t *testing.T) { } func TestRemoveAction(t *testing.T) { - if _, err := accountingStorage.GetAccount("*out:cgrates.org:remo"); err != nil { + if _, err := accountingStorage.GetAccount("cgrates.org:remo"); err != nil { t.Errorf("account to be removed not found: %v", err) } a := &Action{ @@ -1073,19 +1073,19 @@ func TestRemoveAction(t *testing.T) { } at := &ActionPlan{ - AccountIds: []string{"*out:cgrates.org:remo"}, + AccountIds: []string{"cgrates.org:remo"}, actions: Actions{a}, } at.Execute() - afterUb, err := accountingStorage.GetAccount("*out:cgrates.org:remo") + afterUb, err := accountingStorage.GetAccount("cgrates.org:remo") if err == nil || afterUb != nil { t.Error("error removing account: ", err, afterUb) } } func TestTopupAction(t *testing.T) { - initialUb, _ := accountingStorage.GetAccount("*out:vdf:minu") + initialUb, _ := accountingStorage.GetAccount("vdf:minu") a := &Action{ ActionType: TOPUP, BalanceType: utils.MONETARY, @@ -1094,12 +1094,12 @@ func TestTopupAction(t *testing.T) { } at := &ActionPlan{ - AccountIds: []string{"*out:vdf:minu"}, + AccountIds: []string{"vdf:minu"}, actions: Actions{a}, } at.Execute() - afterUb, _ := accountingStorage.GetAccount("*out:vdf:minu") + afterUb, _ := accountingStorage.GetAccount("vdf:minu") initialValue := initialUb.BalanceMap[utils.MONETARY+utils.OUT].GetTotalValue() afterValue := afterUb.BalanceMap[utils.MONETARY+utils.OUT].GetTotalValue() if initialValue != 50 || afterValue != 75 { @@ -1108,7 +1108,7 @@ func TestTopupAction(t *testing.T) { } func TestTopupActionLoaded(t *testing.T) { - initialUb, _ := accountingStorage.GetAccount("*out:vdf:minitsboy") + initialUb, _ := accountingStorage.GetAccount("vdf:minitsboy") a := &Action{ ActionType: TOPUP, BalanceType: utils.MONETARY, @@ -1117,12 +1117,12 @@ func TestTopupActionLoaded(t *testing.T) { } at := &ActionPlan{ - AccountIds: []string{"*out:vdf:minitsboy"}, + AccountIds: []string{"vdf:minitsboy"}, actions: Actions{a}, } at.Execute() - afterUb, _ := accountingStorage.GetAccount("*out:vdf:minitsboy") + afterUb, _ := accountingStorage.GetAccount("vdf:minitsboy") initialValue := initialUb.BalanceMap[utils.MONETARY+utils.OUT].GetTotalValue() afterValue := afterUb.BalanceMap[utils.MONETARY+utils.OUT].GetTotalValue() if initialValue != 100 || afterValue != 125 { @@ -1133,7 +1133,7 @@ func TestTopupActionLoaded(t *testing.T) { } func TestActionCdrlogEmpty(t *testing.T) { - acnt := &Account{Id: "*out:cgrates.org:dan2904"} + acnt := &Account{Id: "cgrates.org:dan2904"} cdrlog := &Action{ ActionType: CDRLOG, } @@ -1154,7 +1154,7 @@ func TestActionCdrlogEmpty(t *testing.T) { } func TestActionCdrlogWithParams(t *testing.T) { - acnt := &Account{Id: "*out:cgrates.org:dan2904"} + acnt := &Account{Id: "cgrates.org:dan2904"} cdrlog := &Action{ ActionType: CDRLOG, ExtraParameters: `{"ReqType":"^*pseudoprepaid","Subject":"^rif", "TOR":"~action_type:s/^\\*(.*)$/did_$1/"}`, @@ -1181,7 +1181,7 @@ func TestActionCdrlogWithParams(t *testing.T) { } func TestActionCdrLogParamsWithOverload(t *testing.T) { - acnt := &Account{Id: "*out:cgrates.org:dan2904"} + acnt := &Account{Id: "cgrates.org:dan2904"} cdrlog := &Action{ ActionType: CDRLOG, ExtraParameters: `{"Subject":"^rif","Destination":"^1234","TOR":"~action_tag:s/^at(.)$/0$1/","AccountId":"~account_id:s/^\\*(.*)$/$1/"}`, @@ -1202,14 +1202,14 @@ func TestActionCdrLogParamsWithOverload(t *testing.T) { cdrs := make([]*StoredCdr, 0) json.Unmarshal([]byte(cdrlog.ExpirationString), &cdrs) expectedExtraFields := map[string]string{ - "AccountId": "out:cgrates.org:dan2904", + "AccountId": "cgrates.org:dan2904", } if len(cdrs) != 2 || cdrs[0].Subject != "rif" { t.Errorf("Wrong cdrlogs: %+v", cdrs[0]) } if !reflect.DeepEqual(cdrs[0].ExtraFields, expectedExtraFields) { - t.Errorf("Received extra_fields: %+v", cdrs[0].ExtraFields) + t.Errorf("Received extra_fields: %+v %+v", cdrs[0].ExtraFields, expectedExtraFields) } } diff --git a/engine/calldesc.go b/engine/calldesc.go index 0b69069bb..87609f7b2 100644 --- a/engine/calldesc.go +++ b/engine/calldesc.go @@ -321,7 +321,7 @@ func (cd *CallDescriptor) GetAccountKey() string { if cd.Account != "" { subj = cd.Account } - return utils.ConcatenatedKey(cd.Direction, cd.Tenant, subj) + return utils.ConcatenatedKey(cd.Tenant, subj) } // Splits the received timespan into sub time spans according to the activation periods intervals. @@ -600,7 +600,7 @@ func (origCD *CallDescriptor) getMaxSessionDuration(origAcc *Account) (time.Dura func (cd *CallDescriptor) GetMaxSessionDuration() (duration time.Duration, err error) { cd.account = nil // make sure it's not cached if account, err := cd.getAccount(); err != nil || account == nil { - utils.Logger.Err(fmt.Sprintf("Could not get user balance for <%s>: %s.", cd.GetAccountKey(), err.Error())) + utils.Logger.Err(fmt.Sprintf("Could not get account for <%s>: %s.", cd.GetAccountKey(), err.Error())) return 0, err } else { if memberIds, err := account.GetUniqueSharedGroupMembers(cd); err == nil { diff --git a/engine/calldesc_test.go b/engine/calldesc_test.go index 9c1aa542b..0e4fc746f 100644 --- a/engine/calldesc_test.go +++ b/engine/calldesc_test.go @@ -51,7 +51,7 @@ func populateDB() { } minu := &Account{ - Id: "*out:vdf:minu", + Id: "vdf:minu", BalanceMap: map[string]BalanceChain{ utils.MONETARY + utils.OUT: BalanceChain{&Balance{Value: 50}}, utils.VOICE + utils.OUT: BalanceChain{ @@ -60,7 +60,7 @@ func populateDB() { }}, } broker := &Account{ - Id: "*out:vdf:broker", + Id: "vdf:broker", BalanceMap: map[string]BalanceChain{ utils.VOICE + utils.OUT: BalanceChain{ &Balance{Value: 20, DestinationIds: "NAT", Weight: 10, RatingSubject: "rif"}, @@ -68,7 +68,7 @@ func populateDB() { }}, } luna := &Account{ - Id: "*out:vdf:luna", + Id: "vdf:luna", BalanceMap: map[string]BalanceChain{ utils.MONETARY + utils.OUT: BalanceChain{ &Balance{Value: 0, Weight: 20}, @@ -76,7 +76,7 @@ func populateDB() { } // this is added to test if csv load tests account will not overwrite balances minitsboy := &Account{ - Id: "*out:vdf:minitsboy", + Id: "vdf:minitsboy", BalanceMap: map[string]BalanceChain{ utils.VOICE + utils.OUT: BalanceChain{ &Balance{Value: 20, DestinationIds: "NAT", Weight: 10, RatingSubject: "rif"}, @@ -88,14 +88,14 @@ func populateDB() { }, } max := &Account{ - Id: "*out:cgrates.org:max", + Id: "cgrates.org:max", BalanceMap: map[string]BalanceChain{ utils.MONETARY + utils.OUT: BalanceChain{ &Balance{Value: 11, Weight: 20}, }}, } money := &Account{ - Id: "*out:cgrates.org:money", + Id: "cgrates.org:money", BalanceMap: map[string]BalanceChain{ utils.MONETARY + utils.OUT: BalanceChain{ &Balance{Value: 10000, Weight: 10}, @@ -725,7 +725,7 @@ func TestMaxDebitWithAccountShared(t *testing.T) { if len(balanceMap) != 1 || balanceMap[0].GetValue() != 0 { t.Errorf("Wrong shared balance debited: %+v", balanceMap[0]) } - other, err := accountingStorage.GetAccount("*out:vdf:empty10") + other, err := accountingStorage.GetAccount("vdf:empty10") if err != nil || other.BalanceMap[utils.MONETARY+utils.OUT][0].GetValue() != 7.5 { t.Errorf("Error debiting shared balance: %+v", other.BalanceMap[utils.MONETARY+utils.OUT][0]) } @@ -856,7 +856,7 @@ func TestMaxSesionTimeEmptyBalance(t *testing.T) { Account: "luna", Destination: "0723", } - acc, _ := accountingStorage.GetAccount("*out:vdf:luna") + acc, _ := accountingStorage.GetAccount("vdf:luna") allowedTime, err := cd.getMaxSessionDuration(acc) if err != nil || allowedTime != 0 { t.Error("Error get max session for 0 acount", err) @@ -874,7 +874,7 @@ func TestMaxSesionTimeEmptyBalanceAndNoCost(t *testing.T) { Account: "luna", Destination: "112", } - acc, _ := accountingStorage.GetAccount("*out:vdf:luna") + acc, _ := accountingStorage.GetAccount("vdf:luna") allowedTime, err := cd.getMaxSessionDuration(acc) if err != nil || allowedTime == 0 { t.Error("Error get max session for 0 acount", err) @@ -891,7 +891,7 @@ func TestMaxSesionTimeLong(t *testing.T) { Subject: "money", Destination: "0723", } - acc, _ := accountingStorage.GetAccount("*out:cgrates.org:money") + acc, _ := accountingStorage.GetAccount("cgrates.org:money") allowedTime, err := cd.getMaxSessionDuration(acc) if err != nil || allowedTime != cd.TimeEnd.Sub(cd.TimeStart) { t.Error("Error get max session for acount:", allowedTime, err) @@ -908,7 +908,7 @@ func TestMaxSesionTimeLongerThanMoney(t *testing.T) { Subject: "money", Destination: "0723", } - acc, _ := accountingStorage.GetAccount("*out:cgrates.org:money") + acc, _ := accountingStorage.GetAccount("cgrates.org:money") allowedTime, err := cd.getMaxSessionDuration(acc) expected, err := time.ParseDuration("2h46m40s") if err != nil || allowedTime != expected { diff --git a/engine/loader_csv_test.go b/engine/loader_csv_test.go index 794836b6c..7565a332f 100644 --- a/engine/loader_csv_test.go +++ b/engine/loader_csv_test.go @@ -190,16 +190,16 @@ CDRST2_WARN_ASR,,*min_asr,30,true,0,,,,,,,,,,,,5,CDRST_WARN_HTTP,10 CDRST2_WARN_ACD,,*min_acd,3,true,0,,,,,,,,,,,,5,CDRST_WARN_HTTP,10 ` accountActions = ` -vdf,minitsboy,*out,MORE_MINUTES,STANDARD_TRIGGER,, -cgrates.org,12345,*out,TOPUP10_AT,STANDARD_TRIGGERS,, -cgrates.org,123456,*out,TOPUP10_AT,STANDARD_TRIGGERS,, -cgrates.org,remo,*out,TOPUP10_AT,,, -vdf,empty0,*out,TOPUP_SHARED0_AT,,, -vdf,empty10,*out,TOPUP_SHARED10_AT,,, -vdf,emptyX,*out,TOPUP_EMPTY_AT,,, -vdf,emptyY,*out,TOPUP_EMPTY_AT,,, -vdf,post,*out,POST_AT,,, -cgrates.org,alodis,*out,TOPUP_EMPTY_AT,,true,true +vdf,minitsboy,MORE_MINUTES,STANDARD_TRIGGER,, +cgrates.org,12345,TOPUP10_AT,STANDARD_TRIGGERS,, +cgrates.org,123456,TOPUP10_AT,STANDARD_TRIGGERS,, +cgrates.org,remo,TOPUP10_AT,,, +vdf,empty0,TOPUP_SHARED0_AT,,, +vdf,empty10,TOPUP_SHARED10_AT,,, +vdf,emptyX,TOPUP_EMPTY_AT,,, +vdf,emptyY,TOPUP_EMPTY_AT,,, +vdf,post,POST_AT,,, +cgrates.org,alodis,TOPUP_EMPTY_AT,,true,true ` derivedCharges = ` @@ -970,7 +970,7 @@ func TestLoadActionTimings(t *testing.T) { expected := &ActionPlan{ Uuid: atm.Uuid, Id: "MORE_MINUTES", - AccountIds: []string{"*out:vdf:minitsboy"}, + AccountIds: []string{"vdf:minitsboy"}, Timing: &RateInterval{ Timing: &RITiming{ Years: utils.Years{2012}, @@ -1026,9 +1026,9 @@ func TestLoadAccountActions(t *testing.T) { if len(csvr.accountActions) != 10 { t.Error("Failed to load account actions: ", len(csvr.accountActions)) } - aa := csvr.accountActions["*out:vdf:minitsboy"] + aa := csvr.accountActions["vdf:minitsboy"] expected := &Account{ - Id: "*out:vdf:minitsboy", + Id: "vdf:minitsboy", ActionTriggers: csvr.actionsTriggers["STANDARD_TRIGGER"], } // set propper uuid diff --git a/engine/model_converters.go b/engine/model_converters.go index 48afbe762..325e2ec68 100644 --- a/engine/model_converters.go +++ b/engine/model_converters.go @@ -250,7 +250,6 @@ func APItoModelAccountAction(aa *utils.TPAccountActions) *TpAccountAction { return &TpAccountAction{ Tpid: aa.TPid, Loadid: aa.LoadId, - Direction: aa.Direction, Tenant: aa.Tenant, Account: aa.Account, ActionPlanTag: aa.ActionPlanId, diff --git a/engine/model_helpers.go b/engine/model_helpers.go index c1adc5a85..d5b2cf15c 100644 --- a/engine/model_helpers.go +++ b/engine/model_helpers.go @@ -456,7 +456,6 @@ func (tps TpAccountActions) GetAccountActions() (map[string]*utils.TPAccountActi LoadId: tpAa.Loadid, Tenant: tpAa.Tenant, Account: tpAa.Account, - Direction: tpAa.Direction, ActionPlanId: tpAa.ActionPlanTag, ActionTriggersId: tpAa.ActionTriggersTag, AllowNegative: tpAa.AllowNegative, diff --git a/engine/model_helpers_test.go b/engine/model_helpers_test.go index e19b13da3..013dd3e5d 100644 --- a/engine/model_helpers_test.go +++ b/engine/model_helpers_test.go @@ -614,12 +614,11 @@ func TestTPAccountActionsAsExportSlice(t *testing.T) { LoadId: "TEST_LOADID", Tenant: "cgrates.org", Account: "1001", - Direction: "*out", ActionPlanId: "PACKAGE_10_SHARED_A_5", ActionTriggersId: "STANDARD_TRIGGERS", } expectedSlc := [][]string{ - []string{"cgrates.org", "1001", "*out", "PACKAGE_10_SHARED_A_5", "STANDARD_TRIGGERS", "false", "false"}, + []string{"cgrates.org", "1001", "PACKAGE_10_SHARED_A_5", "STANDARD_TRIGGERS", "false", "false"}, } ms := APItoModelAccountAction(aa) var slc [][]string diff --git a/engine/models.go b/engine/models.go index c2698ce30..d54083baf 100644 --- a/engine/models.go +++ b/engine/models.go @@ -214,28 +214,26 @@ type TpAccountAction struct { Loadid string Tenant string `index:"0" re:"\w+\s*"` Account string `index:"1" re:"(\w+;?)+\s*"` - Direction string `index:"2" re:"\*out\s*"` - ActionPlanTag string `index:"3" re:"\w+\s*"` - ActionTriggersTag string `index:"4" re:"\w+\s*"` - AllowNegative bool `index:"5" re:""` - Disabled bool `index:"6" re:""` + ActionPlanTag string `index:"2" re:"\w+\s*"` + ActionTriggersTag string `index:"3" re:"\w+\s*"` + AllowNegative bool `index:"4" re:""` + Disabled bool `index:"5" re:""` CreatedAt time.Time } func (aa *TpAccountAction) SetAccountActionId(id string) error { ids := strings.Split(id, utils.CONCATENATED_KEY_SEP) - if len(ids) != 4 { + if len(ids) != 3 { return fmt.Errorf("Wrong TP Account Action Id: %s", id) } aa.Loadid = ids[0] - aa.Direction = ids[1] - aa.Tenant = ids[2] - aa.Account = ids[3] + aa.Tenant = ids[1] + aa.Account = ids[2] return nil } func (aa *TpAccountAction) GetAccountActionId() string { - return utils.AccountKey(aa.Tenant, aa.Account, aa.Direction) + return utils.AccountKey(aa.Tenant, aa.Account) } type TpSharedGroup struct { diff --git a/engine/responder_test.go b/engine/responder_test.go index 2bbf4e0a3..520320591 100644 --- a/engine/responder_test.go +++ b/engine/responder_test.go @@ -73,8 +73,8 @@ func TestResponderGetDerivedMaxSessionTime(t *testing.T) { } b10 := &Balance{Value: 10, Weight: 10, DestinationIds: "DE_TMOBILE"} b20 := &Balance{Value: 20, Weight: 10, DestinationIds: "DE_TMOBILE"} - rifsAccount := &Account{Id: utils.ConcatenatedKey(utils.OUT, testTenant, "rif"), BalanceMap: map[string]BalanceChain{utils.VOICE + utils.OUT: BalanceChain{b10}}} - dansAccount := &Account{Id: utils.ConcatenatedKey(utils.OUT, testTenant, "dan"), BalanceMap: map[string]BalanceChain{utils.VOICE + utils.OUT: BalanceChain{b20}}} + rifsAccount := &Account{Id: utils.ConcatenatedKey(testTenant, "rif"), BalanceMap: map[string]BalanceChain{utils.VOICE + utils.OUT: BalanceChain{b10}}} + dansAccount := &Account{Id: utils.ConcatenatedKey(testTenant, "dan"), BalanceMap: map[string]BalanceChain{utils.VOICE + utils.OUT: BalanceChain{b20}}} if err := accountingStorage.SetAccount(rifsAccount); err != nil { t.Error(err) } @@ -94,14 +94,14 @@ func TestResponderGetDerivedMaxSessionTime(t *testing.T) { t.Error("Error on setting DerivedChargers", err.Error()) } ratingStorage.CacheRatingAll() - if rifStoredAcnt, err := accountingStorage.GetAccount(utils.ConcatenatedKey(utils.OUT, testTenant, "rif")); err != nil { + if rifStoredAcnt, err := accountingStorage.GetAccount(utils.ConcatenatedKey(testTenant, "rif")); err != nil { t.Error(err) //} else if rifStoredAcnt.BalanceMap[utils.VOICE+utils.OUT].Equal(rifsAccount.BalanceMap[utils.VOICE+utils.OUT]) { // t.Errorf("Expected: %+v, received: %+v", rifsAccount.BalanceMap[utils.VOICE+utils.OUT][0], rifStoredAcnt.BalanceMap[utils.VOICE+utils.OUT][0]) } else if rifStoredAcnt.BalanceMap[utils.VOICE+utils.OUT][0].GetValue() != rifsAccount.BalanceMap[utils.VOICE+utils.OUT][0].GetValue() { t.Error("BalanceValue: ", rifStoredAcnt.BalanceMap[utils.VOICE+utils.OUT][0].GetValue()) } - if danStoredAcnt, err := accountingStorage.GetAccount(utils.ConcatenatedKey(utils.OUT, testTenant, "dan")); err != nil { + if danStoredAcnt, err := accountingStorage.GetAccount(utils.ConcatenatedKey(testTenant, "dan")); err != nil { t.Error(err) } else if danStoredAcnt.BalanceMap[utils.VOICE+utils.OUT][0].GetValue() != dansAccount.BalanceMap[utils.VOICE+utils.OUT][0].GetValue() { t.Error("BalanceValue: ", danStoredAcnt.BalanceMap[utils.VOICE+utils.OUT][0].GetValue()) @@ -430,8 +430,8 @@ func TestResponderGetLCR(t *testing.T) { } bRif12 := &Balance{Value: 40, Weight: 10, DestinationIds: dstDe.Id} bIvo12 := &Balance{Value: 60, Weight: 10, DestinationIds: dstDe.Id} - rif12sAccount := &Account{Id: utils.ConcatenatedKey(utils.OUT, "tenant12", "rif12"), BalanceMap: map[string]BalanceChain{utils.VOICE + utils.OUT: BalanceChain{bRif12}}, AllowNegative: true} - ivo12sAccount := &Account{Id: utils.ConcatenatedKey(utils.OUT, "tenant12", "ivo12"), BalanceMap: map[string]BalanceChain{utils.VOICE + utils.OUT: BalanceChain{bIvo12}}, AllowNegative: true} + rif12sAccount := &Account{Id: utils.ConcatenatedKey("tenant12", "rif12"), BalanceMap: map[string]BalanceChain{utils.VOICE + utils.OUT: BalanceChain{bRif12}}, AllowNegative: true} + ivo12sAccount := &Account{Id: utils.ConcatenatedKey("tenant12", "ivo12"), BalanceMap: map[string]BalanceChain{utils.VOICE + utils.OUT: BalanceChain{bIvo12}}, AllowNegative: true} for _, acnt := range []*Account{rif12sAccount, ivo12sAccount} { if err := accountingStorage.SetAccount(acnt); err != nil { t.Error(err) diff --git a/engine/storage_mongo_local_test.go b/engine/storage_mongo_local_test.go index b097c3471..f67de9c90 100644 --- a/engine/storage_mongo_local_test.go +++ b/engine/storage_mongo_local_test.go @@ -315,8 +315,7 @@ func TestMongoSetGetTpAccountActions(t *testing.T) { if !*testLocal { return } - aa := &utils.TPAccountActions{TPid: utils.TEST_SQL, Tenant: "cgrates.org", Account: "1001", - Direction: "*out", ActionPlanId: "PREPAID_10", ActionTriggersId: "STANDARD_TRIGGERS"} + aa := &utils.TPAccountActions{TPid: utils.TEST_SQL, Tenant: "cgrates.org", Account: "1001", ActionPlanId: "PREPAID_10", ActionTriggersId: "STANDARD_TRIGGERS"} maa := APItoModelAccountAction(aa) if err := mongoDb.SetTpAccountActions([]TpAccountAction{*maa}); err != nil { t.Error(err.Error()) @@ -386,8 +385,7 @@ func TestMongoRemoveTPData(t *testing.T) { t.Errorf("RatingProfiles different than 0: %+v", rps) } // Create AccountActions - aa := &utils.TPAccountActions{TPid: utils.TEST_SQL, LoadId: utils.TEST_SQL, Tenant: "cgrates.org", Account: "1001", - Direction: "*out", ActionPlanId: "PREPAID_10", ActionTriggersId: "STANDARD_TRIGGERS"} + aa := &utils.TPAccountActions{TPid: utils.TEST_SQL, LoadId: utils.TEST_SQL, Tenant: "cgrates.org", Account: "1001", ActionPlanId: "PREPAID_10", ActionTriggersId: "STANDARD_TRIGGERS"} maa := APItoModelAccountAction(aa) if err := mongoDb.SetTpAccountActions([]TpAccountAction{*maa}); err != nil { t.Error(err.Error()) @@ -398,7 +396,7 @@ func TestMongoRemoveTPData(t *testing.T) { t.Error("Could not create TPAccountActions") } // Remove AccountActions - if err := mongoDb.RemTpData(utils.TBL_TP_ACCOUNT_ACTIONS, aa.TPid, map[string]string{"loadid": aa.LoadId, "direction": aa.Direction, "tenant": aa.Tenant, "account": aa.Account}); err != nil { + if err := mongoDb.RemTpData(utils.TBL_TP_ACCOUNT_ACTIONS, aa.TPid, map[string]string{"loadid": aa.LoadId, "tenant": aa.Tenant, "account": aa.Account}); err != nil { t.Error(err.Error()) } if aas, err := mongoDb.GetTpAccountActions(maa); err != nil { diff --git a/engine/storage_mongo_tp.go b/engine/storage_mongo_tp.go index db606efaf..9a30c5287 100644 --- a/engine/storage_mongo_tp.go +++ b/engine/storage_mongo_tp.go @@ -336,9 +336,6 @@ func (ms *MongoStorage) GetTpActionTriggers(tpid, tag string) ([]TpActionTrigger func (ms *MongoStorage) GetTpAccountActions(tp *TpAccountAction) ([]TpAccountAction, error) { filter := bson.M{"tpid": tp.Tpid} - if tp.Direction != "" { - filter["direction"] = tp.Direction - } if tp.Tenant != "" { filter["tenant"] = tp.Tenant } @@ -672,11 +669,10 @@ func (ms *MongoStorage) SetTpAccountActions(tps []TpAccountAction) error { if found, _ := m[tp.GetAccountActionId()]; !found { m[tp.GetAccountActionId()] = true tx.Upsert(bson.M{ - "tpid": tp.Tpid, - "loadid": tp.Loadid, - "direction": tp.Direction, - "tenant": tp.Tenant, - "account": tp.Account}, tp) + "tpid": tp.Tpid, + "loadid": tp.Loadid, + "tenant": tp.Tenant, + "account": tp.Account}, tp) } } _, err := tx.Run() diff --git a/engine/storage_mysql_local_test.go b/engine/storage_mysql_local_test.go index 6000d307d..f7b0d4893 100644 --- a/engine/storage_mysql_local_test.go +++ b/engine/storage_mysql_local_test.go @@ -331,7 +331,7 @@ func TestMySQLSetGetTpAccountActions(t *testing.T) { return } aa := &utils.TPAccountActions{TPid: utils.TEST_SQL, Tenant: "cgrates.org", Account: "1001", - Direction: "*out", ActionPlanId: "PREPAID_10", ActionTriggersId: "STANDARD_TRIGGERS"} + ActionPlanId: "PREPAID_10", ActionTriggersId: "STANDARD_TRIGGERS"} maa := APItoModelAccountAction(aa) if err := mysqlDb.SetTpAccountActions([]TpAccountAction{*maa}); err != nil { t.Error(err.Error()) @@ -402,7 +402,7 @@ func TestMySQLRemoveTPData(t *testing.T) { } // Create AccountActions aa := &utils.TPAccountActions{TPid: utils.TEST_SQL, LoadId: utils.TEST_SQL, Tenant: "cgrates.org", Account: "1001", - Direction: "*out", ActionPlanId: "PREPAID_10", ActionTriggersId: "STANDARD_TRIGGERS"} + ActionPlanId: "PREPAID_10", ActionTriggersId: "STANDARD_TRIGGERS"} maa := APItoModelAccountAction(aa) if err := mysqlDb.SetTpAccountActions([]TpAccountAction{*maa}); err != nil { t.Error(err.Error()) @@ -413,7 +413,7 @@ func TestMySQLRemoveTPData(t *testing.T) { t.Error("Could not create TPAccountActions") } // Remove AccountActions - if err := mysqlDb.RemTpData(utils.TBL_TP_ACCOUNT_ACTIONS, aa.TPid, map[string]string{"loadid": aa.LoadId, "direction": aa.Direction, "tenant": aa.Tenant, "account": aa.Account}); err != nil { + if err := mysqlDb.RemTpData(utils.TBL_TP_ACCOUNT_ACTIONS, aa.TPid, map[string]string{"loadid": aa.LoadId, "tenant": aa.Tenant, "account": aa.Account}); err != nil { t.Error(err.Error()) } if aas, err := mysqlDb.GetTpAccountActions(maa); err != nil { diff --git a/engine/storage_psql_local_test.go b/engine/storage_psql_local_test.go index 765639dee..d015763b8 100644 --- a/engine/storage_psql_local_test.go +++ b/engine/storage_psql_local_test.go @@ -326,7 +326,7 @@ func TestPSQLSetGetTpAccountActions(t *testing.T) { return } aa := &utils.TPAccountActions{TPid: utils.TEST_SQL, Tenant: "cgrates.org", Account: "1001", - Direction: "*out", ActionPlanId: "PREPAID_10", ActionTriggersId: "STANDARD_TRIGGERS"} + ActionPlanId: "PREPAID_10", ActionTriggersId: "STANDARD_TRIGGERS"} maa := APItoModelAccountAction(aa) if err := psqlDb.SetTpAccountActions([]TpAccountAction{*maa}); err != nil { t.Error(err.Error()) @@ -397,7 +397,7 @@ func TestPSQLRemoveTPData(t *testing.T) { } // Create AccountActions aa := &utils.TPAccountActions{TPid: utils.TEST_SQL, LoadId: utils.TEST_SQL, Tenant: "cgrates.org", Account: "1001", - Direction: "*out", ActionPlanId: "PREPAID_10", ActionTriggersId: "STANDARD_TRIGGERS"} + ActionPlanId: "PREPAID_10", ActionTriggersId: "STANDARD_TRIGGERS"} maa := APItoModelAccountAction(aa) if err := psqlDb.SetTpAccountActions([]TpAccountAction{*maa}); err != nil { t.Error(err.Error()) @@ -408,7 +408,7 @@ func TestPSQLRemoveTPData(t *testing.T) { t.Error("Could not create TPAccountActions") } // Remove AccountActions - if err := psqlDb.RemTpData(utils.TBL_TP_ACCOUNT_ACTIONS, aa.TPid, map[string]string{"loadid": aa.LoadId, "direction": aa.Direction, "tenant": aa.Tenant, "account": aa.Account}); err != nil { + if err := psqlDb.RemTpData(utils.TBL_TP_ACCOUNT_ACTIONS, aa.TPid, map[string]string{"loadid": aa.LoadId, "tenant": aa.Tenant, "account": aa.Account}); err != nil { t.Error(err.Error()) } if aas, err := psqlDb.GetTpAccountActions(maa); err != nil { diff --git a/engine/storage_sql.go b/engine/storage_sql.go index 736615c41..9e550d066 100644 --- a/engine/storage_sql.go +++ b/engine/storage_sql.go @@ -546,7 +546,7 @@ func (self *SQLStorage) SetTpAccountActions(aas []TpAccountAction) error { for _, aa := range aas { if found, _ := m[aa.GetAccountActionId()]; !found { m[aa.GetAccountActionId()] = true - if err := tx.Where(&TpAccountAction{Tpid: aa.Tpid, Loadid: aa.Loadid, Direction: aa.Direction, Tenant: aa.Tenant, Account: aa.Account}).Delete(TpAccountAction{}).Error; err != nil { + if err := tx.Where(&TpAccountAction{Tpid: aa.Tpid, Loadid: aa.Loadid, Tenant: aa.Tenant, Account: aa.Account}).Delete(TpAccountAction{}).Error; err != nil { tx.Rollback() return err } @@ -1594,9 +1594,6 @@ func (self *SQLStorage) GetTpAccountActions(filter *TpAccountAction) ([]TpAccoun var tpAccActs []TpAccountAction q := self.db.Where("tpid = ?", filter.Tpid) - if len(filter.Direction) != 0 { - q = q.Where("direction = ?", filter.Direction) - } if len(filter.Tenant) != 0 { q = q.Where("tenant = ?", filter.Tenant) } diff --git a/engine/storage_test.go b/engine/storage_test.go index a2dbadbff..30326f600 100644 --- a/engine/storage_test.go +++ b/engine/storage_test.go @@ -238,7 +238,7 @@ func TestStorageCacheRemoveCachedAliases(t *testing.T) { } func TestStorageDisabledAccount(t *testing.T) { - acc, err := accountingStorage.GetAccount("*out:cgrates.org:alodis") + acc, err := accountingStorage.GetAccount("cgrates.org:alodis") if err != nil || acc == nil { t.Error("Error loading disabled user account: ", err, acc) } @@ -258,11 +258,11 @@ func TestStoreInterfaces(t *testing.T) { } func TestDifferentUuid(t *testing.T) { - a1, err := accountingStorage.GetAccount("*out:cgrates.org:12345") + a1, err := accountingStorage.GetAccount("cgrates.org:12345") if err != nil { t.Error("Error getting account: ", err) } - a2, err := accountingStorage.GetAccount("*out:cgrates.org:123456") + a2, err := accountingStorage.GetAccount("cgrates.org:123456") if err != nil { t.Error("Error getting account: ", err) } diff --git a/general_tests/acntacts_test.go b/general_tests/acntacts_test.go index e4348e98e..a0b8a1ff1 100644 --- a/general_tests/acntacts_test.go +++ b/general_tests/acntacts_test.go @@ -49,7 +49,7 @@ DISABLE_ACNT,*disable_account,,,,,,,,,,,,,false,10 ENABLE_ACNT,*enable_account,,,,,,,,,,,,,false,10` actionPlans := `TOPUP10_AT,TOPUP10_AC,ASAP,10` actionTriggers := `` - accountActions := `cgrates.org,1,*out,TOPUP10_AT,,,` + accountActions := `cgrates.org,1,TOPUP10_AT,,,` derivedCharges := `` cdrStats := `` users := `` @@ -62,8 +62,8 @@ ENABLE_ACNT,*enable_account,,,,,,,,,,,,,false,10` csvr.WriteToDatabase(false, false) ratingDbAcntActs.CacheRatingAll() acntDbAcntActs.CacheAccountingAll() - expectAcnt := &engine.Account{Id: "*out:cgrates.org:1"} - if acnt, err := acntDbAcntActs.GetAccount("*out:cgrates.org:1"); err != nil { + expectAcnt := &engine.Account{Id: "cgrates.org:1"} + if acnt, err := acntDbAcntActs.GetAccount("cgrates.org:1"); err != nil { t.Error(err) } else if acnt == nil { t.Error("No account created") @@ -73,7 +73,7 @@ ENABLE_ACNT,*enable_account,,,,,,,,,,,,,false,10` } func TestAcntActsDisableAcnt(t *testing.T) { - acnt1Tag := "*out:cgrates.org:1" + acnt1Tag := "cgrates.org:1" at := &engine.ActionPlan{ AccountIds: []string{acnt1Tag}, ActionsId: "DISABLE_ACNT", @@ -81,7 +81,7 @@ func TestAcntActsDisableAcnt(t *testing.T) { if err := at.Execute(); err != nil { t.Error(err) } - expectAcnt := &engine.Account{Id: "*out: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) { @@ -90,7 +90,7 @@ func TestAcntActsDisableAcnt(t *testing.T) { } func TestAcntActsEnableAcnt(t *testing.T) { - acnt1Tag := "*out:cgrates.org:1" + acnt1Tag := "cgrates.org:1" at := &engine.ActionPlan{ AccountIds: []string{acnt1Tag}, ActionsId: "ENABLE_ACNT", @@ -98,7 +98,7 @@ func TestAcntActsEnableAcnt(t *testing.T) { if err := at.Execute(); err != nil { t.Error(err) } - expectAcnt := &engine.Account{Id: "*out: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) { diff --git a/general_tests/auth_test.go b/general_tests/auth_test.go index def8b9aa5..a47948eb2 100644 --- a/general_tests/auth_test.go +++ b/general_tests/auth_test.go @@ -59,7 +59,7 @@ RP_ANY,DR_ANY_1CNT,*any,10` actions := `TOPUP10_AC,*topup_reset,,,*monetary,*out,,*any,,,*unlimited,,0,10,false,10` actionPlans := `TOPUP10_AT,TOPUP10_AC,*asap,10` actionTriggers := `` - accountActions := `cgrates.org,testauthpostpaid1,*out,TOPUP10_AT,,,` + accountActions := `cgrates.org,testauthpostpaid1,TOPUP10_AT,,,` derivedCharges := `` cdrStats := `` users := `` @@ -70,7 +70,7 @@ RP_ANY,DR_ANY_1CNT,*any,10` t.Fatal(err) } csvr.WriteToDatabase(false, false) - if acnt, err := acntDbAuth.GetAccount("*out:cgrates.org:testauthpostpaid1"); err != nil { + if acnt, err := acntDbAuth.GetAccount("cgrates.org:testauthpostpaid1"); err != nil { t.Error(err) } else if acnt == nil { t.Error("No account saved") diff --git a/general_tests/ddazmbl1_test.go b/general_tests/ddazmbl1_test.go index 901fc61c4..fea2490bc 100644 --- a/general_tests/ddazmbl1_test.go +++ b/general_tests/ddazmbl1_test.go @@ -58,7 +58,7 @@ TOPUP10_AC1,*topup_reset,,,*voice,*out,,DST_UK_Mobile_BIG5,discounted_minutes,,* actionPlans := `TOPUP10_AT,TOPUP10_AC,ASAP,10 TOPUP10_AT,TOPUP10_AC1,ASAP,10` actionTriggers := `` - accountActions := `cgrates.org,12344,*out,TOPUP10_AT,,,` + accountActions := `cgrates.org,12344,TOPUP10_AT,,,` derivedCharges := `` cdrStats := `` users := `` @@ -105,7 +105,7 @@ TOPUP10_AT,TOPUP10_AC1,ASAP,10` t.Fatal(err) } csvr.WriteToDatabase(false, false) - if acnt, err := acntDb.GetAccount("*out:cgrates.org:12344"); err != nil { + if acnt, err := acntDb.GetAccount("cgrates.org:12344"); err != nil { t.Error(err) } else if acnt == nil { t.Error("No account saved") @@ -131,7 +131,7 @@ TOPUP10_AT,TOPUP10_AC1,ASAP,10` func TestExecuteActions(t *testing.T) { scheduler.NewScheduler().LoadActionPlans(ratingDb) time.Sleep(time.Millisecond) // Give time to scheduler to topup the account - if acnt, err := acntDb.GetAccount("*out:cgrates.org:12344"); err != nil { + if acnt, err := acntDb.GetAccount("cgrates.org:12344"); err != nil { t.Error(err) } else if len(acnt.BalanceMap) != 2 { t.Error("Account does not have enough balances: ", acnt.BalanceMap) @@ -158,7 +158,7 @@ func TestDebit(t *testing.T) { } else if cc.Cost != 0.01 { t.Error("Wrong cost returned: ", cc.Cost) } - acnt, err := acntDb.GetAccount("*out:cgrates.org:12344") + acnt, err := acntDb.GetAccount("cgrates.org:12344") if err != nil { t.Error(err) } diff --git a/general_tests/ddazmbl2_test.go b/general_tests/ddazmbl2_test.go index d07c72cc5..a37fbac4e 100644 --- a/general_tests/ddazmbl2_test.go +++ b/general_tests/ddazmbl2_test.go @@ -58,7 +58,7 @@ TOPUP10_AC1,*topup_reset,,,*voice,*out,,DST_UK_Mobile_BIG5,discounted_minutes,,* actionPlans := `TOPUP10_AT,TOPUP10_AC,ASAP,10 TOPUP10_AT,TOPUP10_AC1,ASAP,10` actionTriggers := `` - accountActions := `cgrates.org,12345,*out,TOPUP10_AT,,,` + accountActions := `cgrates.org,12345,TOPUP10_AT,,,` derivedCharges := `` cdrStats := `` users := `` @@ -105,7 +105,7 @@ TOPUP10_AT,TOPUP10_AC1,ASAP,10` t.Fatal(err) } csvr.WriteToDatabase(false, false) - if acnt, err := acntDb2.GetAccount("*out:cgrates.org:12345"); err != nil { + if acnt, err := acntDb2.GetAccount("cgrates.org:12345"); err != nil { t.Error(err) } else if acnt == nil { t.Error("No account saved") @@ -130,7 +130,7 @@ TOPUP10_AT,TOPUP10_AC1,ASAP,10` func TestExecuteActions2(t *testing.T) { scheduler.NewScheduler().LoadActionPlans(ratingDb2) time.Sleep(time.Millisecond) // Give time to scheduler to topup the account - if acnt, err := acntDb2.GetAccount("*out:cgrates.org:12345"); err != nil { + if acnt, err := acntDb2.GetAccount("cgrates.org:12345"); err != nil { t.Error(err) } else if len(acnt.BalanceMap) != 2 { t.Error("Account does not have enough balances: ", acnt.BalanceMap) @@ -157,7 +157,7 @@ func TestDebit2(t *testing.T) { } else if cc.Cost != 0.01 { t.Error("Wrong cost returned: ", cc.Cost) } - acnt, err := acntDb2.GetAccount("*out:cgrates.org:12345") + acnt, err := acntDb2.GetAccount("cgrates.org:12345") if err != nil { t.Error(err) } diff --git a/general_tests/ddazmbl3_test.go b/general_tests/ddazmbl3_test.go index d1bd74029..70bf23a24 100644 --- a/general_tests/ddazmbl3_test.go +++ b/general_tests/ddazmbl3_test.go @@ -56,7 +56,7 @@ RP_UK,DR_UK_Mobile_BIG5,ALWAYS,10` actions := `TOPUP10_AC1,*topup_reset,,,*voice,*out,,DST_UK_Mobile_BIG5,discounted_minutes,,*unlimited,,40,10,false,10` actionPlans := `TOPUP10_AT,TOPUP10_AC1,ASAP,10` actionTriggers := `` - accountActions := `cgrates.org,12346,*out,TOPUP10_AT,,,` + accountActions := `cgrates.org,12346,TOPUP10_AT,,,` derivedCharges := `` cdrStats := `` users := `` @@ -103,7 +103,7 @@ RP_UK,DR_UK_Mobile_BIG5,ALWAYS,10` t.Fatal(err) } csvr.WriteToDatabase(false, false) - if acnt, err := acntDb3.GetAccount("*out:cgrates.org:12346"); err != nil { + if acnt, err := acntDb3.GetAccount("cgrates.org:12346"); err != nil { t.Error(err) } else if acnt == nil { t.Error("No account saved") @@ -128,7 +128,7 @@ RP_UK,DR_UK_Mobile_BIG5,ALWAYS,10` func TestExecuteActions3(t *testing.T) { scheduler.NewScheduler().LoadActionPlans(ratingDb3) time.Sleep(time.Millisecond) // Give time to scheduler to topup the account - if acnt, err := acntDb3.GetAccount("*out:cgrates.org:12346"); err != nil { + if acnt, err := acntDb3.GetAccount("cgrates.org:12346"); err != nil { t.Error(err) } else if len(acnt.BalanceMap) != 1 { t.Error("Account does not have enough balances: ", acnt.BalanceMap) @@ -153,7 +153,7 @@ func TestDebit3(t *testing.T) { } else if cc.Cost != 0.01 { t.Error("Wrong cost returned: ", cc.Cost) } - acnt, err := acntDb3.GetAccount("*out:cgrates.org:12346") + acnt, err := acntDb3.GetAccount("cgrates.org:12346") if err != nil { t.Error(err) } diff --git a/general_tests/tutorial_fs_calls_test.go b/general_tests/tutorial_fs_calls_test.go index 8ad231481..e0ffb95e7 100644 --- a/general_tests/tutorial_fs_calls_test.go +++ b/general_tests/tutorial_fs_calls_test.go @@ -137,37 +137,37 @@ func TestTutFsCallsAccountsBefore(t *testing.T) { return } var reply *engine.Account - attrs := &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "1001", Direction: "*out"} + attrs := &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "1001"} if err := tutFsCallsRpc.Call("ApierV1.GetAccount", attrs, &reply); err != nil { t.Error("Got error on ApierV1.GetAccount: ", err.Error()) - } else if reply.BalanceMap[utils.MONETARY+attrs.Direction].GetTotalValue() != 10.0 { // Make sure we debitted - t.Errorf("Calling ApierV1.GetBalance received: %f", reply.BalanceMap[utils.MONETARY+attrs.Direction].GetTotalValue()) + } else if reply.BalanceMap[utils.MONETARY].GetTotalValue() != 10.0 { // Make sure we debitted + t.Errorf("Calling ApierV1.GetBalance received: %f", reply.BalanceMap[utils.MONETARY].GetTotalValue()) } - attrs = &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "1002", Direction: "*out"} + attrs = &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "1002"} if err := tutFsCallsRpc.Call("ApierV1.GetAccount", attrs, &reply); err != nil { t.Error("Got error on ApierV1.GetAccount: ", err.Error()) - } else if reply.BalanceMap[utils.MONETARY+attrs.Direction].GetTotalValue() != 10.0 { // Make sure we debitted - t.Errorf("Calling ApierV1.GetBalance received: %f", reply.BalanceMap[utils.MONETARY+attrs.Direction].GetTotalValue()) + } else if reply.BalanceMap[utils.MONETARY].GetTotalValue() != 10.0 { // Make sure we debitted + t.Errorf("Calling ApierV1.GetBalance received: %f", reply.BalanceMap[utils.MONETARY].GetTotalValue()) } - attrs = &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "1003", Direction: "*out"} + attrs = &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "1003"} if err := tutFsCallsRpc.Call("ApierV1.GetAccount", attrs, &reply); err != nil { t.Error("Got error on ApierV1.GetAccount: ", err.Error()) - } else if reply.BalanceMap[utils.MONETARY+attrs.Direction].GetTotalValue() != 10.0 { // Make sure we debitted - t.Errorf("Calling ApierV1.GetBalance received: %f", reply.BalanceMap[utils.MONETARY+attrs.Direction].GetTotalValue()) + } else if reply.BalanceMap[utils.MONETARY].GetTotalValue() != 10.0 { // Make sure we debitted + t.Errorf("Calling ApierV1.GetBalance received: %f", reply.BalanceMap[utils.MONETARY].GetTotalValue()) } - attrs = &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "1004", Direction: "*out"} + attrs = &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "1004"} if err := tutFsCallsRpc.Call("ApierV1.GetAccount", attrs, &reply); err != nil { t.Error("Got error on ApierV1.GetAccount: ", err.Error()) - } else if reply.BalanceMap[utils.MONETARY+attrs.Direction].GetTotalValue() != 10.0 { // Make sure we debitted - t.Errorf("Calling ApierV1.GetBalance received: %f", reply.BalanceMap[utils.MONETARY+attrs.Direction].GetTotalValue()) + } else if reply.BalanceMap[utils.MONETARY].GetTotalValue() != 10.0 { // Make sure we debitted + t.Errorf("Calling ApierV1.GetBalance received: %f", reply.BalanceMap[utils.MONETARY].GetTotalValue()) } - attrs = &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "1007", Direction: "*out"} + attrs = &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "1007"} if err := tutFsCallsRpc.Call("ApierV1.GetAccount", attrs, &reply); err != nil { t.Error("Got error on ApierV1.GetAccount: ", err.Error()) - } else if reply.BalanceMap[utils.MONETARY+attrs.Direction].GetTotalValue() != 0.0 { // Make sure we debitted - t.Errorf("Calling ApierV1.GetBalance received: %f", reply.BalanceMap[utils.MONETARY+attrs.Direction].GetTotalValue()) + } else if reply.BalanceMap[utils.MONETARY].GetTotalValue() != 0.0 { // Make sure we debitted + t.Errorf("Calling ApierV1.GetBalance received: %f", reply.BalanceMap[utils.MONETARY].GetTotalValue()) } - attrs = &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "1005", Direction: "*out"} + attrs = &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "1005"} if err := tutFsCallsRpc.Call("ApierV1.GetAccount", attrs, &reply); err == nil || !strings.HasSuffix(err.Error(), "does not exist") { t.Error("Got error on ApierV1.GetAccount: %v", err) } @@ -315,11 +315,11 @@ func TestTutFsCallsAccount1001(t *testing.T) { } time.Sleep(time.Duration(70) * time.Second) // Allow calls to finish before start querying the results var reply *engine.Account - attrs := &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "1001", Direction: "*out"} + attrs := &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "1001"} if err := tutFsCallsRpc.Call("ApierV1.GetAccount", attrs, &reply); err != nil { t.Error("Got error on ApierV1.GetAccount: ", err.Error()) - } else if reply.BalanceMap[utils.MONETARY+attrs.Direction].GetTotalValue() == 10.0 { // Make sure we debitted - t.Errorf("Calling ApierV1.GetBalance received: %f", reply.BalanceMap[utils.MONETARY+attrs.Direction].GetTotalValue()) + } else if reply.BalanceMap[utils.MONETARY].GetTotalValue() == 10.0 { // Make sure we debitted + t.Errorf("Calling ApierV1.GetBalance received: %f", reply.BalanceMap[utils.MONETARY].GetTotalValue()) } else if reply.Disabled == true { t.Error("Account disabled") } @@ -535,7 +535,7 @@ func TestTutFsCallsAccountFraud1001(t *testing.T) { return } var reply string - attrAddBlnc := &v1.AttrAddBalance{Tenant: "cgrates.org", Account: "1001", BalanceType: "*monetary", Direction: "*out", Value: 101} + attrAddBlnc := &v1.AttrAddBalance{Tenant: "cgrates.org", Account: "1001", BalanceType: "*monetary", Value: 101} if err := tutFsCallsRpc.Call("ApierV1.AddBalance", attrAddBlnc, &reply); err != nil { t.Error("Got error on ApierV1.AddBalance: ", err.Error()) } else if reply != "OK" { @@ -549,7 +549,7 @@ func TestTutFsCallsAccountDisabled1001(t *testing.T) { return } var reply *engine.Account - attrs := &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "1001", Direction: "*out"} + attrs := &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "1001"} if err := tutFsCallsRpc.Call("ApierV1.GetAccount", attrs, &reply); err != nil { t.Error("Got error on ApierV1.GetAccount: ", err.Error()) } else if reply.Disabled == false { diff --git a/general_tests/tutorial_kam_calls_test.go b/general_tests/tutorial_kam_calls_test.go index 0cade7da6..d8e1ac8a8 100644 --- a/general_tests/tutorial_kam_calls_test.go +++ b/general_tests/tutorial_kam_calls_test.go @@ -137,37 +137,37 @@ func TestTutKamCallsAccountsBefore(t *testing.T) { return } var reply *engine.Account - attrs := &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "1001", Direction: "*out"} + attrs := &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "1001"} if err := tutKamCallsRpc.Call("ApierV1.GetAccount", attrs, &reply); err != nil { t.Error("Got error on ApierV1.GetAccount: ", err.Error()) - } else if reply.BalanceMap[utils.MONETARY+attrs.Direction].GetTotalValue() != 10.0 { // Make sure we debitted - t.Errorf("Calling ApierV1.GetBalance received: %f", reply.BalanceMap[utils.MONETARY+attrs.Direction].GetTotalValue()) + } else if reply.BalanceMap[utils.MONETARY].GetTotalValue() != 10.0 { // Make sure we debitted + t.Errorf("Calling ApierV1.GetBalance received: %f", reply.BalanceMap[utils.MONETARY].GetTotalValue()) } - attrs = &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "1002", Direction: "*out"} + attrs = &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "1002"} if err := tutKamCallsRpc.Call("ApierV1.GetAccount", attrs, &reply); err != nil { t.Error("Got error on ApierV1.GetAccount: ", err.Error()) - } else if reply.BalanceMap[utils.MONETARY+attrs.Direction].GetTotalValue() != 10.0 { // Make sure we debitted - t.Errorf("Calling ApierV1.GetBalance received: %f", reply.BalanceMap[utils.MONETARY+attrs.Direction].GetTotalValue()) + } else if reply.BalanceMap[utils.MONETARY].GetTotalValue() != 10.0 { // Make sure we debitted + t.Errorf("Calling ApierV1.GetBalance received: %f", reply.BalanceMap[utils.MONETARY].GetTotalValue()) } - attrs = &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "1003", Direction: "*out"} + attrs = &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "1003"} if err := tutKamCallsRpc.Call("ApierV1.GetAccount", attrs, &reply); err != nil { t.Error("Got error on ApierV1.GetAccount: ", err.Error()) - } else if reply.BalanceMap[utils.MONETARY+attrs.Direction].GetTotalValue() != 10.0 { // Make sure we debitted - t.Errorf("Calling ApierV1.GetBalance received: %f", reply.BalanceMap[utils.MONETARY+attrs.Direction].GetTotalValue()) + } else if reply.BalanceMap[utils.MONETARY].GetTotalValue() != 10.0 { // Make sure we debitted + t.Errorf("Calling ApierV1.GetBalance received: %f", reply.BalanceMap[utils.MONETARY].GetTotalValue()) } - attrs = &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "1004", Direction: "*out"} + attrs = &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "1004"} if err := tutKamCallsRpc.Call("ApierV1.GetAccount", attrs, &reply); err != nil { t.Error("Got error on ApierV1.GetAccount: ", err.Error()) - } else if reply.BalanceMap[utils.MONETARY+attrs.Direction].GetTotalValue() != 10.0 { // Make sure we debitted - t.Errorf("Calling ApierV1.GetBalance received: %f", reply.BalanceMap[utils.MONETARY+attrs.Direction].GetTotalValue()) + } else if reply.BalanceMap[utils.MONETARY].GetTotalValue() != 10.0 { // Make sure we debitted + t.Errorf("Calling ApierV1.GetBalance received: %f", reply.BalanceMap[utils.MONETARY].GetTotalValue()) } - attrs = &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "1007", Direction: "*out"} + attrs = &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "1007"} if err := tutKamCallsRpc.Call("ApierV1.GetAccount", attrs, &reply); err != nil { t.Error("Got error on ApierV1.GetAccount: ", err.Error()) - } else if reply.BalanceMap[utils.MONETARY+attrs.Direction].GetTotalValue() != 0.0 { // Make sure we debitted - t.Errorf("Calling ApierV1.GetBalance received: %f", reply.BalanceMap[utils.MONETARY+attrs.Direction].GetTotalValue()) + } else if reply.BalanceMap[utils.MONETARY].GetTotalValue() != 0.0 { // Make sure we debitted + t.Errorf("Calling ApierV1.GetBalance received: %f", reply.BalanceMap[utils.MONETARY].GetTotalValue()) } - attrs = &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "1005", Direction: "*out"} + attrs = &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "1005"} if err := tutKamCallsRpc.Call("ApierV1.GetAccount", attrs, &reply); err == nil || !strings.HasSuffix(err.Error(), "does not exist") { t.Error("Got error on ApierV1.GetAccount: %v", err) } @@ -315,11 +315,11 @@ func TestTutKamCallsAccount1001(t *testing.T) { } time.Sleep(time.Duration(70) * time.Second) // Allow calls to finish before start querying the results var reply *engine.Account - attrs := &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "1001", Direction: "*out"} + attrs := &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "1001"} if err := tutKamCallsRpc.Call("ApierV1.GetAccount", attrs, &reply); err != nil { t.Error("Got error on ApierV1.GetAccount: ", err.Error()) - } else if reply.BalanceMap[utils.MONETARY+attrs.Direction].GetTotalValue() == 10.0 { // Make sure we debitted - t.Errorf("Calling ApierV1.GetBalance received: %f", reply.BalanceMap[utils.MONETARY+attrs.Direction].GetTotalValue()) + } else if reply.BalanceMap[utils.MONETARY].GetTotalValue() == 10.0 { // Make sure we debitted + t.Errorf("Calling ApierV1.GetBalance received: %f", reply.BalanceMap[utils.MONETARY].GetTotalValue()) } else if reply.Disabled == true { t.Error("Account disabled") } @@ -549,7 +549,7 @@ func TestTutKamCallsAccountDisabled1001(t *testing.T) { return } var reply *engine.Account - attrs := &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "1001", Direction: "*out"} + attrs := &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "1001"} if err := tutKamCallsRpc.Call("ApierV1.GetAccount", attrs, &reply); err != nil { t.Error("Got error on ApierV1.GetAccount: ", err.Error()) } else if reply.Disabled == false { diff --git a/general_tests/tutorial_local_test.go b/general_tests/tutorial_local_test.go index d4e404915..2c72e35de 100644 --- a/general_tests/tutorial_local_test.go +++ b/general_tests/tutorial_local_test.go @@ -1085,7 +1085,7 @@ func TestTutLocalSetAccount(t *testing.T) { return } var reply string - attrs := &utils.AttrSetAccount{Tenant: "cgrates.org", Direction: "*out", Account: "tutacnt1", ActionPlanId: "PACKAGE_10", ActionTriggersId: "STANDARD_TRIGGERS"} + attrs := &utils.AttrSetAccount{Tenant: "cgrates.org", Account: "tutacnt1", ActionPlanId: "PACKAGE_10", ActionTriggersId: "STANDARD_TRIGGERS"} if err := tutLocalRpc.Call("ApierV1.SetAccount", attrs, &reply); err != nil { t.Error("Got error on ApierV1.SetAccount: ", err.Error()) } else if reply != "OK" { @@ -1099,14 +1099,14 @@ func TestTutLocalSetAccount(t *testing.T) { Limit int // Limit number of items retrieved } var acnts []*engine.Account - if err := tutLocalRpc.Call("ApierV1.GetAccounts", utils.AttrGetAccounts{Tenant: attrs.Tenant, Direction: attrs.Direction, AccountIds: []string{attrs.Account}}, &acnts); err != nil { + if err := tutLocalRpc.Call("ApierV1.GetAccounts", utils.AttrGetAccounts{Tenant: attrs.Tenant, AccountIds: []string{attrs.Account}}, &acnts); err != nil { t.Error(err) } else if len(acnts) != 1 { t.Errorf("Accounts received: %+v", acnts) } else { acnt := acnts[0] dta, _ := utils.NewDTAFromAccountKey(acnt.Id) - if dta.Direction != attrs.Direction || dta.Tenant != attrs.Tenant || dta.Account != attrs.Account { + if dta.Tenant != attrs.Tenant || dta.Account != attrs.Account { t.Error("Unexpected account id received: ", acnt.Id) } if balances := acnt.BalanceMap["*monetary*out"]; len(balances) != 1 { @@ -1122,20 +1122,20 @@ func TestTutLocalSetAccount(t *testing.T) { t.Error("Disabled should not be set") } } - attrs = &utils.AttrSetAccount{Tenant: "cgrates.org", Direction: "*out", Account: "tutacnt1", AllowNegative: utils.BoolPointer(true), Disabled: utils.BoolPointer(true)} + attrs = &utils.AttrSetAccount{Tenant: "cgrates.org", Account: "tutacnt1", AllowNegative: utils.BoolPointer(true), Disabled: utils.BoolPointer(true)} if err := tutLocalRpc.Call("ApierV1.SetAccount", attrs, &reply); err != nil { t.Error("Got error on ApierV1.SetAccount: ", err.Error()) } else if reply != "OK" { t.Errorf("Calling ApierV1.SetAccount received: %s", reply) } - if err := tutLocalRpc.Call("ApierV1.GetAccounts", utils.AttrGetAccounts{Tenant: attrs.Tenant, Direction: attrs.Direction, AccountIds: []string{attrs.Account}}, &acnts); err != nil { + if err := tutLocalRpc.Call("ApierV1.GetAccounts", utils.AttrGetAccounts{Tenant: attrs.Tenant, AccountIds: []string{attrs.Account}}, &acnts); err != nil { t.Error(err) } else if len(acnts) != 1 { t.Errorf("Accounts received: %+v", acnts) } else { acnt := acnts[0] dta, _ := utils.NewDTAFromAccountKey(acnt.Id) - if dta.Direction != attrs.Direction || dta.Tenant != attrs.Tenant || dta.Account != attrs.Account { + if dta.Tenant != attrs.Tenant || dta.Account != attrs.Account { t.Error("Unexpected account id received: ", acnt.Id) } if balances := acnt.BalanceMap["*monetary*out"]; len(balances) != 1 { diff --git a/general_tests/tutorial_osips_calls_test.go b/general_tests/tutorial_osips_calls_test.go index 5f1bcafe3..7de2b56df 100644 --- a/general_tests/tutorial_osips_calls_test.go +++ b/general_tests/tutorial_osips_calls_test.go @@ -137,37 +137,37 @@ func TestTutOsipsCallsAccountsBefore(t *testing.T) { return } var reply *engine.Account - attrs := &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "1001", Direction: "*out"} + attrs := &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "1001"} if err := tutOsipsCallsRpc.Call("ApierV1.GetAccount", attrs, &reply); err != nil { t.Error("Got error on ApierV1.GetAccount: ", err.Error()) - } else if reply.BalanceMap[utils.MONETARY+attrs.Direction].GetTotalValue() != 10.0 { // Make sure we debitted - t.Errorf("Calling ApierV1.GetBalance received: %f", reply.BalanceMap[utils.MONETARY+attrs.Direction].GetTotalValue()) + } else if reply.BalanceMap[utils.MONETARY].GetTotalValue() != 10.0 { // Make sure we debitted + t.Errorf("Calling ApierV1.GetBalance received: %f", reply.BalanceMap[utils.MONETARY].GetTotalValue()) } - attrs = &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "1002", Direction: "*out"} + attrs = &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "1002"} if err := tutOsipsCallsRpc.Call("ApierV1.GetAccount", attrs, &reply); err != nil { t.Error("Got error on ApierV1.GetAccount: ", err.Error()) - } else if reply.BalanceMap[utils.MONETARY+attrs.Direction].GetTotalValue() != 10.0 { // Make sure we debitted - t.Errorf("Calling ApierV1.GetBalance received: %f", reply.BalanceMap[utils.MONETARY+attrs.Direction].GetTotalValue()) + } else if reply.BalanceMap[utils.MONETARY].GetTotalValue() != 10.0 { // Make sure we debitted + t.Errorf("Calling ApierV1.GetBalance received: %f", reply.BalanceMap[utils.MONETARY].GetTotalValue()) } - attrs = &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "1003", Direction: "*out"} + attrs = &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "1003"} if err := tutOsipsCallsRpc.Call("ApierV1.GetAccount", attrs, &reply); err != nil { t.Error("Got error on ApierV1.GetAccount: ", err.Error()) - } else if reply.BalanceMap[utils.MONETARY+attrs.Direction].GetTotalValue() != 10.0 { // Make sure we debitted - t.Errorf("Calling ApierV1.GetBalance received: %f", reply.BalanceMap[utils.MONETARY+attrs.Direction].GetTotalValue()) + } else if reply.BalanceMap[utils.MONETARY].GetTotalValue() != 10.0 { // Make sure we debitted + t.Errorf("Calling ApierV1.GetBalance received: %f", reply.BalanceMap[utils.MONETARY].GetTotalValue()) } - attrs = &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "1004", Direction: "*out"} + attrs = &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "1004"} if err := tutOsipsCallsRpc.Call("ApierV1.GetAccount", attrs, &reply); err != nil { t.Error("Got error on ApierV1.GetAccount: ", err.Error()) - } else if reply.BalanceMap[utils.MONETARY+attrs.Direction].GetTotalValue() != 10.0 { // Make sure we debitted - t.Errorf("Calling ApierV1.GetBalance received: %f", reply.BalanceMap[utils.MONETARY+attrs.Direction].GetTotalValue()) + } else if reply.BalanceMap[utils.MONETARY].GetTotalValue() != 10.0 { // Make sure we debitted + t.Errorf("Calling ApierV1.GetBalance received: %f", reply.BalanceMap[utils.MONETARY].GetTotalValue()) } - attrs = &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "1007", Direction: "*out"} + attrs = &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "1007"} if err := tutOsipsCallsRpc.Call("ApierV1.GetAccount", attrs, &reply); err != nil { t.Error("Got error on ApierV1.GetAccount: ", err.Error()) - } else if reply.BalanceMap[utils.MONETARY+attrs.Direction].GetTotalValue() != 0.0 { // Make sure we debitted - t.Errorf("Calling ApierV1.GetBalance received: %f", reply.BalanceMap[utils.MONETARY+attrs.Direction].GetTotalValue()) + } else if reply.BalanceMap[utils.MONETARY].GetTotalValue() != 0.0 { // Make sure we debitted + t.Errorf("Calling ApierV1.GetBalance received: %f", reply.BalanceMap[utils.MONETARY].GetTotalValue()) } - attrs = &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "1005", Direction: "*out"} + attrs = &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "1005"} if err := tutOsipsCallsRpc.Call("ApierV1.GetAccount", attrs, &reply); err == nil || !strings.HasSuffix(err.Error(), "does not exist") { t.Error("Got error on ApierV1.GetAccount: %v", err) } @@ -315,11 +315,11 @@ func TestTutOsipsCallsAccount1001(t *testing.T) { } time.Sleep(time.Duration(70) * time.Second) // Allow calls to finish before start querying the results var reply *engine.Account - attrs := &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "1001", Direction: "*out"} + attrs := &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "1001"} if err := tutOsipsCallsRpc.Call("ApierV1.GetAccount", attrs, &reply); err != nil { t.Error("Got error on ApierV1.GetAccount: ", err.Error()) - } else if reply.BalanceMap[utils.MONETARY+attrs.Direction].GetTotalValue() == 10.0 { // Make sure we debitted - t.Errorf("Calling ApierV1.GetBalance received: %f", reply.BalanceMap[utils.MONETARY+attrs.Direction].GetTotalValue()) + } else if reply.BalanceMap[utils.MONETARY].GetTotalValue() == 10.0 { // Make sure we debitted + t.Errorf("Calling ApierV1.GetBalance received: %f", reply.BalanceMap[utils.MONETARY].GetTotalValue()) } else if reply.Disabled == true { t.Error("Account disabled") } @@ -549,7 +549,7 @@ func TestTutOsipsCallsAccountDisabled1001(t *testing.T) { return } var reply *engine.Account - attrs := &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "1001", Direction: "*out"} + attrs := &utils.AttrGetAccount{Tenant: "cgrates.org", Account: "1001"} if err := tutOsipsCallsRpc.Call("ApierV1.GetAccount", attrs, &reply); err != nil { t.Error("Got error on ApierV1.GetAccount: ", err.Error()) } else if reply.Disabled == false { diff --git a/utils/apitpdata.go b/utils/apitpdata.go index 69442c171..48a564e51 100644 --- a/utils/apitpdata.go +++ b/utils/apitpdata.go @@ -496,10 +496,10 @@ func NewTPAccountActionsFromKeyId(tpid, loadId, keyId string) (*TPAccountActions // *out:cgrates.org:1001 s := strings.Split(keyId, ":") // [*out cgrates.org 1001] - if len(s) != 3 { + if len(s) != 2 { return nil, fmt.Errorf("Cannot parse key %s into AccountActions", keyId) } - return &TPAccountActions{TPid: tpid, LoadId: loadId, Direction: s[0], Tenant: s[1], Account: s[2]}, nil + return &TPAccountActions{TPid: tpid, LoadId: loadId, Tenant: s[0], Account: s[1]}, nil } type TPAccountActions struct { @@ -507,7 +507,6 @@ type TPAccountActions struct { LoadId string // LoadId, used to group actions on a load Tenant string // Tenant's Id Account string // Account name - Direction string // Traffic direction ActionPlanId string // Id of ActionPlan profile to use ActionTriggersId string // Id of ActionTriggers profile to use AllowNegative bool @@ -516,13 +515,11 @@ type TPAccountActions struct { // Returns the id used in some nosql dbs (eg: redis) func (self *TPAccountActions) KeyId() string { - return fmt.Sprintf("%s:%s:%s", self.Direction, self.Tenant, self.Account) + return fmt.Sprintf("%s:%s", self.Tenant, self.Account) } func (aa *TPAccountActions) GetAccountActionsId() string { return aa.LoadId + - CONCATENATED_KEY_SEP + - aa.Direction + CONCATENATED_KEY_SEP + aa.Tenant + CONCATENATED_KEY_SEP + @@ -531,25 +528,22 @@ func (aa *TPAccountActions) GetAccountActionsId() string { func (aa *TPAccountActions) SetAccountActionsId(id string) error { ids := strings.Split(id, CONCATENATED_KEY_SEP) - if len(ids) != 4 { + if len(ids) != 3 { return fmt.Errorf("Wrong TP Account Action Id: %s", id) } aa.LoadId = ids[0] - aa.Direction = ids[1] - aa.Tenant = ids[2] - aa.Account = ids[3] + aa.Tenant = ids[1] + aa.Account = ids[2] return nil } type AttrGetAccount struct { - Tenant string - Account string - Direction string + Tenant string + Account string } type AttrGetAccounts struct { Tenant string - Direction string AccountIds []string Offset int // Set the item offset Limit int // Limit number of items retrieved @@ -1112,7 +1106,6 @@ type AttrExecuteAction struct { type AttrSetAccount struct { Tenant string - Direction string Account string ActionPlanId string ActionTriggersId string @@ -1121,9 +1114,8 @@ type AttrSetAccount struct { } type AttrRemoveAccount struct { - Tenant string - Direction string - Account string + Tenant string + Account string } type AttrGetSMASessions struct { diff --git a/utils/consts.go b/utils/consts.go index 1dc57e1ae..ce4326b46 100644 --- a/utils/consts.go +++ b/utils/consts.go @@ -172,7 +172,7 @@ const ( RATING_PROFILE_PREFIX = "rpf_" ACTION_PREFIX = "act_" SHARED_GROUP_PREFIX = "shg_" - ACCOUNT_PREFIX = "act_" + ACCOUNT_PREFIX = "acc_" DESTINATION_PREFIX = "dst_" LCR_PREFIX = "lcr_" DERIVEDCHARGERS_PREFIX = "dcs_" diff --git a/utils/coreutils.go b/utils/coreutils.go index f8ef29531..630fbe139 100644 --- a/utils/coreutils.go +++ b/utils/coreutils.go @@ -238,8 +238,8 @@ func ParseDurationWithSecs(durStr string) (time.Duration, error) { } } -func AccountKey(tenant, account, direction string) string { - return fmt.Sprintf("%s:%s:%s", direction, tenant, account) +func AccountKey(tenant, account string) string { + return fmt.Sprintf("%s:%s", tenant, account) } // returns the minimum duration between the two