diff --git a/apier/v1/apier.go b/apier/v1/apier.go
index ffdfbd17e..f7d3940f0 100644
--- a/apier/v1/apier.go
+++ b/apier/v1/apier.go
@@ -204,23 +204,6 @@ func (self *ApierV1) LoadDestination(attrs AttrLoadDestination, reply *string) e
return nil
}
-// Load derived chargers from storDb into dataDb.
-func (self *ApierV1) LoadDerivedChargers(attrs utils.TPDerivedChargers, reply *string) error {
- if len(attrs.TPid) == 0 {
- return utils.NewErrMandatoryIeMissing("TPid")
- }
- dbReader := engine.NewTpReader(self.DataManager.DataDB(), self.StorDb,
- attrs.TPid, self.Config.GeneralCfg().DefaultTimezone)
- if err := dbReader.LoadDerivedChargersFiltered(&attrs, true); err != nil {
- return utils.NewErrServerError(err)
- }
- if err := self.DataManager.CacheDataFromDB(utils.DERIVEDCHARGERS_PREFIX, []string{attrs.GetDerivedChargersKey()}, true); err != nil {
- return utils.NewErrServerError(err)
- }
- *reply = OK
- return nil
-}
-
type AttrLoadRatingPlan struct {
TPid string
RatingPlanId string
@@ -311,7 +294,6 @@ func (self *ApierV1) LoadTariffPlanFromStorDb(attrs AttrLoadTpFromStorDb, reply
utils.REVERSE_DESTINATION_PREFIX,
utils.ACTION_PLAN_PREFIX,
utils.AccountActionPlansPrefix,
- utils.DERIVEDCHARGERS_PREFIX,
} {
loadedIDs, _ := dbReader.GetLoadedIds(prfx)
if err := self.DataManager.CacheDataFromDB(prfx, loadedIDs, true); err != nil {
@@ -747,10 +729,6 @@ func (self *ApierV1) ReloadCache(attrs utils.AttrReloadCache, reply *string) (er
if err = self.reloadCache(utils.SHARED_GROUP_PREFIX, attrs.SharedGroupIDs); err != nil {
return
}
- // DerivedChargers
- if err = self.reloadCache(utils.DERIVEDCHARGERS_PREFIX, attrs.DerivedChargerIDs); err != nil {
- return
- }
// ResourceProfiles
if err = self.reloadCache(utils.ResourceProfilesPrefix, attrs.ResourceProfileIDs); err != nil {
return
@@ -850,11 +828,6 @@ func (self *ApierV1) LoadCache(args utils.AttrReloadCache, reply *string) (err e
} else {
sgIDs = *args.SharedGroupIDs
}
- if args.DerivedChargerIDs == nil {
- dcIDs = nil
- } else {
- dcIDs = *args.DerivedChargerIDs
- }
if args.ResourceProfileIDs == nil {
rspIDs = nil
} else {
@@ -945,7 +918,6 @@ func (self *ApierV1) FlushCache(args utils.AttrReloadCache, reply *string) (err
flushCache(utils.CacheActionPlans, args.ActionPlanIDs)
flushCache(utils.CacheActionTriggers, args.ActionTriggerIDs)
flushCache(utils.CacheSharedGroups, args.SharedGroupIDs)
- flushCache(utils.CacheDerivedChargers, args.DerivedChargerIDs)
flushCache(utils.CacheResourceProfiles, args.ResourceProfileIDs)
flushCache(utils.CacheResources, args.ResourceIDs)
flushCache(utils.CacheStatQueues, args.StatsQueueIDs)
@@ -972,7 +944,6 @@ func (self *ApierV1) GetCacheStats(attrs utils.AttrCacheStats, reply *utils.Cach
cs.ActionPlans = len(engine.Cache.GetItemIDs(utils.CacheActionPlans, ""))
cs.AccountActionPlans = len(engine.Cache.GetItemIDs(utils.CacheAccountActionPlans, ""))
cs.SharedGroups = len(engine.Cache.GetItemIDs(utils.CacheSharedGroups, ""))
- cs.DerivedChargers = len(engine.Cache.GetItemIDs(utils.CacheDerivedChargers, ""))
cs.ResourceProfiles = len(engine.Cache.GetItemIDs(utils.CacheResourceProfiles, ""))
cs.Resources = len(engine.Cache.GetItemIDs(utils.CacheResources, ""))
cs.StatQueues = len(engine.Cache.GetItemIDs(utils.CacheStatQueues, ""))
@@ -1061,12 +1032,6 @@ func (v1 *ApierV1) GetCacheKeys(args utils.ArgsCacheKeys, reply *utils.ArgsCache
reply.SharedGroupIDs = &ids
}
}
- if args.DerivedChargerIDs != nil {
- ids := getCacheKeys(utils.CacheDerivedChargers, args.DerivedChargerIDs, args.Paginator)
- if len(ids) != 0 {
- reply.DerivedChargerIDs = &ids
- }
- }
if args.ResourceProfileIDs != nil {
ids := getCacheKeys(utils.CacheResourceProfiles, args.ResourceProfileIDs, args.Paginator)
if len(ids) != 0 {
@@ -1164,7 +1129,6 @@ func (self *ApierV1) LoadTariffPlanFromFolder(attrs utils.AttrLoadTpFromFolder,
path.Join(attrs.FolderPath, utils.ACTION_PLANS_CSV),
path.Join(attrs.FolderPath, utils.ACTION_TRIGGERS_CSV),
path.Join(attrs.FolderPath, utils.ACCOUNT_ACTIONS_CSV),
- path.Join(attrs.FolderPath, utils.DERIVED_CHARGERS_CSV),
path.Join(attrs.FolderPath, utils.ResourcesCsv),
path.Join(attrs.FolderPath, utils.StatsCsv),
path.Join(attrs.FolderPath, utils.ThresholdsCsv),
@@ -1197,7 +1161,6 @@ func (self *ApierV1) LoadTariffPlanFromFolder(attrs utils.AttrLoadTpFromFolder,
utils.REVERSE_DESTINATION_PREFIX,
utils.ACTION_PLAN_PREFIX,
utils.AccountActionPlansPrefix,
- utils.DERIVEDCHARGERS_PREFIX,
} {
loadedIDs, _ := loader.GetLoadedIds(prfx)
if err := self.DataManager.CacheDataFromDB(prfx, loadedIDs, true); err != nil {
diff --git a/apier/v1/apier_it_test.go b/apier/v1/apier_it_test.go
index ccd40f5db..0095fb3c0 100644
--- a/apier/v1/apier_it_test.go
+++ b/apier/v1/apier_it_test.go
@@ -1336,7 +1336,6 @@ func TestApierResetDataAfterLoadFromFolder(t *testing.T) {
rcvStats.Actions != 13 ||
rcvStats.ActionPlans != 7 ||
rcvStats.SharedGroups != 0 ||
- rcvStats.DerivedChargers != 3 ||
rcvStats.ResourceProfiles != 3 ||
rcvStats.Resources != 3 {
t.Errorf("Expecting: %+v, received: %+v", expStats, rcvStats)
@@ -1533,49 +1532,6 @@ func TestApierGetCallCostLog(t *testing.T) {
}
}
-func TestApierITSetDC(t *testing.T) {
- dcs1 := []*utils.DerivedCharger{
- {RunID: "extra1", RequestTypeField: "^prepaid", DirectionField: "*default", TenantField: "*default", CategoryField: "*default",
- AccountField: "rif", SubjectField: "rif", DestinationField: "*default", SetupTimeField: "*default", AnswerTimeField: "*default", UsageField: "*default"},
- {RunID: "extra2", RequestTypeField: "*default", DirectionField: "*default", TenantField: "*default", CategoryField: "*default",
- AccountField: "ivo", SubjectField: "ivo", DestinationField: "*default", SetupTimeField: "*default", AnswerTimeField: "*default", UsageField: "*default"},
- }
- attrs := AttrSetDerivedChargers{Direction: "*out", Tenant: "cgrates.org", Category: "call", Account: "dan", Subject: "dan", DerivedChargers: dcs1, Overwrite: true}
- var reply string
- if err := rater.Call("ApierV1.SetDerivedChargers", attrs, &reply); err != nil {
- t.Error("Unexpected error", err.Error())
- } else if reply != utils.OK {
- t.Error("Unexpected reply returned", reply)
- }
-}
-
-func TestApierITGetDC(t *testing.T) {
- attrs := utils.AttrDerivedChargers{Tenant: "cgrates.org", Category: "call", Direction: "*out", Account: "dan", Subject: "dan"}
- eDcs := utils.DerivedChargers{DestinationIDs: utils.NewStringMap(),
- Chargers: []*utils.DerivedCharger{
- {RunID: "extra1", RequestTypeField: "^prepaid", DirectionField: "*default", TenantField: "*default", CategoryField: "*default",
- AccountField: "rif", SubjectField: "rif", DestinationField: "*default", SetupTimeField: "*default", AnswerTimeField: "*default", UsageField: "*default"},
- {RunID: "extra2", RequestTypeField: "*default", DirectionField: "*default", TenantField: "*default", CategoryField: "*default",
- AccountField: "ivo", SubjectField: "ivo", DestinationField: "*default", SetupTimeField: "*default", AnswerTimeField: "*default", UsageField: "*default"},
- }}
- var dcs utils.DerivedChargers
- if err := rater.Call("ApierV1.GetDerivedChargers", attrs, &dcs); err != nil {
- t.Error("Unexpected error", err.Error())
- } else if !reflect.DeepEqual(dcs, eDcs) {
- t.Errorf("Expecting: %v, received: %v", eDcs, dcs)
- }
-}
-
-func TestApierITRemDC(t *testing.T) {
- attrs := utils.AttrDerivedChargers{Tenant: "cgrates.org", Category: "call", Direction: "*out", Account: "dan", Subject: "dan"}
- var reply string
- if err := rater.Call("ApierV1.RemDerivedChargers", attrs, &reply); err != nil {
- t.Error("Unexpected error", err.Error())
- } else if reply != utils.OK {
- t.Error("Unexpected reply returned", reply)
- }
-}
-
func TestApierITSetDestination(t *testing.T) {
attrs := utils.AttrSetDestination{Id: "TEST_SET_DESTINATION", Prefixes: []string{"+4986517174963", "+4986517174960"}}
var reply string
diff --git a/apier/v1/auth.go b/apier/v1/auth.go
index 58d695c59..0b995cd64 100644
--- a/apier/v1/auth.go
+++ b/apier/v1/auth.go
@@ -50,12 +50,12 @@ func (self *ApierV1) GetMaxUsage(usageRecord engine.UsageRecord, maxUsage *int64
usageRecord.Usage = strconv.FormatFloat(
self.Config.MaxCallDuration.Seconds(), 'f', -1, 64)
}
- storedCdr, err := usageRecord.AsCDR(self.Config.GeneralCfg().DefaultTimezone)
+ cd, err := usageRecord.AsCallDescriptor(self.Config.GeneralCfg().DefaultTimezone, false)
if err != nil {
return utils.NewErrServerError(err)
}
var maxDur time.Duration
- if err := self.Responder.GetDerivedMaxSessionTime(storedCdr, &maxDur); err != nil {
+ if err := self.Responder.GetMaxSessionTime(cd, &maxDur); err != nil {
return err
}
if maxDur == time.Duration(-1) {
diff --git a/apier/v1/derivedcharging.go b/apier/v1/derivedcharging.go
deleted file mode 100644
index 1c8193ed9..000000000
--- a/apier/v1/derivedcharging.go
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-package v1
-
-import (
- "fmt"
- "strings"
-
- "github.com/cgrates/cgrates/engine"
- "github.com/cgrates/cgrates/utils"
-)
-
-// Get DerivedChargers applying to our call, appends general configured to account specific ones if that is configured
-func (self *ApierV1) GetDerivedChargers(attrs utils.AttrDerivedChargers, reply *utils.DerivedChargers) (err error) {
- if missing := utils.MissingStructFields(&attrs, []string{"Tenant", "Direction", "Account", "Subject"}); len(missing) != 0 {
- return utils.NewErrMandatoryIeMissing(missing...)
- }
- if hDc, err := engine.HandleGetDerivedChargers(self.DataManager, &attrs); err != nil {
- return utils.NewErrServerError(err)
- } else if hDc != nil {
- *reply = *hDc
- }
- return nil
-}
-
-type AttrSetDerivedChargers struct {
- Direction, Tenant, Category, Account, Subject, DestinationIds string
- DerivedChargers []*utils.DerivedCharger
- Overwrite bool // Do not overwrite if present in redis
-}
-
-func (self *ApierV1) SetDerivedChargers(attrs AttrSetDerivedChargers, reply *string) (err error) {
- if len(attrs.DerivedChargers) == 0 {
- return utils.NewErrMandatoryIeMissing("DerivedChargers")
- }
- if len(attrs.Direction) == 0 {
- attrs.Direction = utils.OUT
- }
- if len(attrs.Tenant) == 0 {
- attrs.Tenant = utils.ANY
- }
- if len(attrs.Category) == 0 {
- attrs.Category = utils.ANY
- }
- if len(attrs.Account) == 0 {
- attrs.Account = utils.ANY
- }
- if len(attrs.Subject) == 0 {
- attrs.Subject = utils.ANY
- }
- for _, dc := range attrs.DerivedChargers {
- if _, err = utils.ParseRSRFields(dc.RunFilters, utils.INFIELD_SEP); err != nil { // Make sure rules are OK before loading in db
- return fmt.Errorf("%s:%s", utils.ErrParserError.Error(), err.Error())
- }
- }
- dcKey := utils.DerivedChargersKey(attrs.Direction, attrs.Tenant, attrs.Category, attrs.Account, attrs.Subject)
- if !attrs.Overwrite {
- if exists, err := self.DataManager.HasData(utils.DERIVEDCHARGERS_PREFIX, dcKey, ""); err != nil {
- return utils.NewErrServerError(err)
- } else if exists {
- return utils.ErrExists
- }
- }
- dstIds := strings.Split(attrs.DestinationIds, utils.INFIELD_SEP)
- dcs := &utils.DerivedChargers{DestinationIDs: utils.NewStringMap(dstIds...), Chargers: attrs.DerivedChargers}
- if err := self.DataManager.DataDB().SetDerivedChargers(dcKey, dcs, utils.NonTransactional); err != nil {
- return utils.NewErrServerError(err)
- }
- if err := self.DataManager.CacheDataFromDB(utils.DERIVEDCHARGERS_PREFIX, []string{dcKey}, true); err != nil {
- return utils.NewErrServerError(err)
- }
- *reply = utils.OK
- return nil
-}
-
-type AttrRemDerivedChargers struct {
- Direction, Tenant, Category, Account, Subject string
-}
-
-func (self *ApierV1) RemDerivedChargers(attrs AttrRemDerivedChargers, reply *string) error {
- if len(attrs.Direction) == 0 {
- attrs.Direction = utils.OUT
- }
- if len(attrs.Tenant) == 0 {
- attrs.Tenant = utils.ANY
- }
- if len(attrs.Category) == 0 {
- attrs.Category = utils.ANY
- }
- if len(attrs.Account) == 0 {
- attrs.Account = utils.ANY
- }
- if len(attrs.Subject) == 0 {
- attrs.Subject = utils.ANY
- }
- if err := self.DataManager.DataDB().SetDerivedChargers(utils.DerivedChargersKey(attrs.Direction, attrs.Tenant, attrs.Category, attrs.Account, attrs.Subject), nil, utils.NonTransactional); err != nil {
- return utils.NewErrServerError(err)
- }
- if err := self.DataManager.CacheDataFromDB(utils.DERIVEDCHARGERS_PREFIX,
- []string{utils.DerivedChargersKey(attrs.Direction, attrs.Tenant, attrs.Category, attrs.Account, attrs.Subject)}, true); err != nil {
- return utils.NewErrServerError(err)
- }
- *reply = utils.OK
- return nil
-}
diff --git a/apier/v1/derivedcharging_test.go b/apier/v1/derivedcharging_test.go
deleted file mode 100644
index d24f94c1a..000000000
--- a/apier/v1/derivedcharging_test.go
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-package v1
-
-import (
- "reflect"
- "testing"
-
- "github.com/cgrates/cgrates/config"
- "github.com/cgrates/cgrates/engine"
- "github.com/cgrates/cgrates/utils"
-)
-
-var apierDcT *ApierV1
-
-func init() {
- dataStorage, _ := engine.NewMapStorage()
- cfg, _ := config.NewDefaultCGRConfig()
- apierDcT = &ApierV1{DataManager: engine.NewDataManager(dataStorage), Config: cfg}
-}
-
-/*
-func TestGetEmptyDC(t *testing.T) {
- attrs := utils.AttrDerivedChargers{Tenant: "cgrates.org", Category: "call", Direction: "*out", Account: "dan", Subject: "dan"}
- var dcs utils.DerivedChargers
- if err := apierDcT.GetDerivedChargers(attrs, &dcs); err != nil {
- t.Error("Unexpected error", err.Error())
- } else if !reflect.DeepEqual(dcs, apierDcT.Config.DerivedChargers) {
- t.Error("Returned DerivedChargers not matching the configured ones")
- }
-}
-*/
-
-func TestSetDC(t *testing.T) {
- dcs1 := []*utils.DerivedCharger{
- &utils.DerivedCharger{RunID: "extra1", RequestTypeField: "^prepaid", DirectionField: "*default", TenantField: "*default", CategoryField: "*default",
- AccountField: "rif", SubjectField: "rif", DestinationField: "*default", SetupTimeField: "*default", AnswerTimeField: "*default", UsageField: "*default"},
- &utils.DerivedCharger{RunID: "extra2", RequestTypeField: "*default", DirectionField: "*default", TenantField: "*default", CategoryField: "*default",
- AccountField: "ivo", SubjectField: "ivo", DestinationField: "*default", SetupTimeField: "*default", AnswerTimeField: "*default", UsageField: "*default"},
- }
- attrs := AttrSetDerivedChargers{Direction: "*out", Tenant: "cgrates.org", Category: "call", Account: "dan", Subject: "dan", DerivedChargers: dcs1}
- var reply string
- if err := apierDcT.SetDerivedChargers(attrs, &reply); err != nil {
- t.Error("Unexpected error", err.Error())
- } else if reply != utils.OK {
- t.Error("Unexpected reply returned", reply)
- }
-}
-
-func TestGetDC(t *testing.T) {
- attrs := utils.AttrDerivedChargers{Tenant: "cgrates.org", Category: "call", Direction: "*out", Account: "dan", Subject: "dan"}
- eDcs := utils.DerivedChargers{DestinationIDs: utils.NewStringMap(),
- Chargers: []*utils.DerivedCharger{
- &utils.DerivedCharger{RunID: "extra1", RequestTypeField: "^prepaid", DirectionField: "*default", TenantField: "*default", CategoryField: "*default",
- AccountField: "rif", SubjectField: "rif", DestinationField: "*default", SetupTimeField: "*default", AnswerTimeField: "*default", UsageField: "*default"},
- &utils.DerivedCharger{RunID: "extra2", RequestTypeField: "*default", DirectionField: "*default", TenantField: "*default", CategoryField: "*default",
- AccountField: "ivo", SubjectField: "ivo", DestinationField: "*default", SetupTimeField: "*default", AnswerTimeField: "*default", UsageField: "*default"},
- }}
- var dcs utils.DerivedChargers
- if err := apierDcT.GetDerivedChargers(attrs, &dcs); err != nil {
- t.Error("Unexpected error", err.Error())
- } else if !reflect.DeepEqual(dcs, eDcs) {
- t.Errorf("Expecting: %v, received: %v", eDcs.DestinationIDs, dcs.DestinationIDs)
- }
-}
-
-func TestRemDC(t *testing.T) {
- attrs := AttrRemDerivedChargers{Direction: "*out", Tenant: "cgrates.org", Category: "call", Account: "dan", Subject: "dan"}
- var reply string
- if err := apierDcT.RemDerivedChargers(attrs, &reply); err != nil {
- t.Error("Unexpected error", err.Error())
- } else if reply != utils.OK {
- t.Error("Unexpected reply returned", reply)
- }
-}
-
-/*
-func TestGetEmptyDC2(t *testing.T) {
- attrs := utils.AttrDerivedChargers{Tenant: "cgrates.org", Category: "call", Direction: "*out", Account: "dan", Subject: "dan"}
- var dcs utils.DerivedChargers
- if err := apierDcT.GetDerivedChargers(attrs, &dcs); err != nil {
- t.Error("Unexpected error", err.Error())
- } else if !reflect.DeepEqual(dcs, apierDcT.Config.DerivedChargers) {
- t.Error("Returned DerivedChargers not matching the configured ones")
- }
-}
-*/
diff --git a/apier/v1/precache_it_test.go b/apier/v1/precache_it_test.go
index 429ce543c..27d847abb 100644
--- a/apier/v1/precache_it_test.go
+++ b/apier/v1/precache_it_test.go
@@ -163,10 +163,6 @@ func testPrecacheGetCacheStatsBeforeLoad(t *testing.T) {
Items: 0,
Groups: 0,
},
- "derived_chargers": {
- Items: 0,
- Groups: 0,
- },
"destinations": {
Items: 0,
Groups: 0,
@@ -327,10 +323,6 @@ func testPrecacheGetCacheStatsAfterRestart(t *testing.T) {
Items: 0,
Groups: 0,
},
- "derived_chargers": {
- Items: 1, // expected to have 1 item
- Groups: 0,
- },
"destinations": {
Items: 5,
Groups: 0,
diff --git a/apier/v1/tpderivedcharges.go b/apier/v1/tpderivedcharges.go
deleted file mode 100644
index 5b91289ef..000000000
--- a/apier/v1/tpderivedcharges.go
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-package v1
-
-import (
- "github.com/cgrates/cgrates/engine"
- "github.com/cgrates/cgrates/utils"
-)
-
-// Creates a new DerivedCharges profile within a tariff plan
-func (self *ApierV1) SetTPDerivedChargers(attrs utils.TPDerivedChargers, reply *string) error {
- if missing := utils.MissingStructFields(&attrs, []string{"TPid", "Direction", "Tenant", "Category", "Account", "Subject"}); len(missing) != 0 {
- return utils.NewErrMandatoryIeMissing(missing...)
- }
- if err := self.StorDb.SetTPDerivedChargers([]*utils.TPDerivedChargers{&attrs}); err != nil {
- return utils.NewErrServerError(err)
- }
- *reply = utils.OK
- return nil
-}
-
-type AttrGetTPDerivedChargers struct {
- TPid string // Tariff plan id
- DerivedChargersId string // DerivedCharge id
-}
-
-// Queries specific DerivedCharge on tariff plan
-func (self *ApierV1) GetTPDerivedChargers(attrs AttrGetTPDerivedChargers, reply *utils.TPDerivedChargers) error {
- if missing := utils.MissingStructFields(&attrs, []string{"TPid", "DerivedChargersId"}); len(missing) != 0 { //Params missing
- return utils.NewErrMandatoryIeMissing(missing...)
- }
- filter := &utils.TPDerivedChargers{TPid: attrs.TPid}
- filter.SetDerivedChargersId(attrs.DerivedChargersId)
- if dcs, err := self.StorDb.GetTPDerivedChargers(filter); err != nil {
- if err.Error() != utils.ErrNotFound.Error() {
- err = utils.NewErrServerError(err)
- }
- return err
- } else {
- *reply = *dcs[0]
- }
- return nil
-}
-
-type AttrGetTPDerivedChargeIds struct {
- TPid string // Tariff plan id
- utils.Paginator
-}
-
-// Queries DerivedCharges identities on specific tariff plan.
-func (self *ApierV1) GetTPDerivedChargerIds(attrs AttrGetTPDerivedChargeIds, reply *[]string) error {
- if missing := utils.MissingStructFields(&attrs, []string{"TPid"}); len(missing) != 0 { //Params missing
- return utils.NewErrMandatoryIeMissing(missing...)
- }
- if ids, err := self.StorDb.GetTpTableIds(attrs.TPid, utils.TBLTPDerivedChargers, utils.TPDistinctIds{"loadid", "direction", "tenant", "category", "account", "subject"}, nil, &attrs.Paginator); err != nil {
- if err.Error() != utils.ErrNotFound.Error() {
- err = utils.NewErrServerError(err)
- }
- return err
- } else {
- *reply = ids
- }
- return nil
-}
-
-// Removes specific DerivedCharges on Tariff plan
-func (self *ApierV1) RemTPDerivedChargers(attrs AttrGetTPDerivedChargers, reply *string) error {
- if missing := utils.MissingStructFields(&attrs, []string{"TPid", "DerivedChargesId"}); len(missing) != 0 { //Params missing
- return utils.NewErrMandatoryIeMissing(missing...)
- }
- tmpDc := engine.TpDerivedCharger{}
- if err := tmpDc.SetDerivedChargersId(attrs.DerivedChargersId); err != nil {
- return err
- }
- if err := self.StorDb.RemTpData(utils.TBLTPDerivedChargers, attrs.TPid, map[string]string{"loadid": tmpDc.Loadid, "direction": tmpDc.Direction, "tenant": tmpDc.Tenant, "category": tmpDc.Category, "account": tmpDc.Account, "subject": tmpDc.Subject}); err != nil {
- return utils.NewErrServerError(err)
- } else {
- *reply = utils.OK
- }
- return nil
-}
diff --git a/apier/v1/tpderivedcharges_it_test.go b/apier/v1/tpderivedcharges_it_test.go
deleted file mode 100644
index 59091e761..000000000
--- a/apier/v1/tpderivedcharges_it_test.go
+++ /dev/null
@@ -1,312 +0,0 @@
-// +build offline_tp
-
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-package v1
-
-import (
- "net/rpc"
- "net/rpc/jsonrpc"
- "path"
- "reflect"
- "testing"
-
- "github.com/cgrates/cgrates/config"
- "github.com/cgrates/cgrates/engine"
- "github.com/cgrates/cgrates/utils"
-)
-
-var (
- tpDerivedChargersCfgPath string
- tpDerivedChargersCfg *config.CGRConfig
- tpDerivedChargersRPC *rpc.Client
- tpDerivedChargersDataDir = "/usr/share/cgrates"
- tpDerivedChargers *utils.TPDerivedChargers
- tpDerivedChargersDelay int
- tpDerivedChargersConfigDIR string //run tests for specific configuration
- tpDerivedChargersID = "LoadID:*out:cgrates.org:call:1001:1001"
-)
-
-var sTestsTPDerivedChargers = []func(t *testing.T){
- testTPDerivedChargersInitCfg,
- testTPDerivedChargersResetStorDb,
- testTPDerivedChargersStartEngine,
- testTPDerivedChargersRpcConn,
- testTPDerivedChargersGetTPDerivedChargersBeforeSet,
- testTPDerivedChargersSetTPDerivedChargers,
- testTPDerivedChargersGetTPDerivedChargersAfterSet,
- testTPDerivedChargersGetTPDerivedChargerIds,
- testTPDerivedChargersUpdateTPDerivedChargers,
- testTPDerivedChargersGetTPDerivedChargersAfterUpdate,
- testTPDerivedChargersRemTPDerivedChargers,
- testTPDerivedChargersGetTPDerivedChargersAfterRemove,
- testTPDerivedChargersKillEngine,
-}
-
-//Test start here
-func TestTPDerivedChargersITMySql(t *testing.T) {
- tpDerivedChargersConfigDIR = "tutmysql"
- for _, stest := range sTestsTPDerivedChargers {
- t.Run(tpDerivedChargersConfigDIR, stest)
- }
-}
-
-func TestTPDerivedChargersITMongo(t *testing.T) {
- tpDerivedChargersConfigDIR = "tutmongo"
- for _, stest := range sTestsTPDerivedChargers {
- t.Run(tpDerivedChargersConfigDIR, stest)
- }
-}
-
-func TestTPDerivedChargersITPG(t *testing.T) {
- tpDerivedChargersConfigDIR = "tutpostgres"
- for _, stest := range sTestsTPDerivedChargers {
- t.Run(tpDerivedChargersConfigDIR, stest)
- }
-}
-
-func testTPDerivedChargersInitCfg(t *testing.T) {
- var err error
- tpDerivedChargersCfgPath = path.Join(tpDerivedChargersDataDir, "conf", "samples", tpDerivedChargersConfigDIR)
- tpDerivedChargersCfg, err = config.NewCGRConfigFromFolder(tpDerivedChargersCfgPath)
- if err != nil {
- t.Error(err)
- }
- tpDerivedChargersCfg.DataFolderPath = tpDerivedChargersDataDir // Share DataFolderPath through config towards StoreDb for Flush()
- config.SetCgrConfig(tpDerivedChargersCfg)
- switch tpDerivedChargersConfigDIR {
- case "tutmongo": // Mongo needs more time to reset db, need to investigate
- tpDerivedChargersDelay = 2000
- default:
- tpDerivedChargersDelay = 1000
- }
-}
-
-// Wipe out the cdr database
-func testTPDerivedChargersResetStorDb(t *testing.T) {
- if err := engine.InitStorDb(tpDerivedChargersCfg); err != nil {
- t.Fatal(err)
- }
-}
-
-// Start CGR Engine
-func testTPDerivedChargersStartEngine(t *testing.T) {
- if _, err := engine.StopStartEngine(tpDerivedChargersCfgPath, tpDerivedChargersDelay); err != nil {
- t.Fatal(err)
- }
-}
-
-// Connect rpc client to rater
-func testTPDerivedChargersRpcConn(t *testing.T) {
- var err error
- tpDerivedChargersRPC, err = jsonrpc.Dial("tcp", tpDerivedChargersCfg.ListenCfg().RPCJSONListen) // We connect over JSON so we can also troubleshoot if needed
- if err != nil {
- t.Fatal(err)
- }
-}
-
-func testTPDerivedChargersGetTPDerivedChargersBeforeSet(t *testing.T) {
- var reply *utils.TPDerivedChargers
- if err := tpDerivedChargersRPC.Call("ApierV1.GetTPDerivedChargers",
- &AttrGetTPDerivedChargers{TPid: "TPD", DerivedChargersId: tpDerivedChargersID}, &reply); err == nil || err.Error() != utils.ErrNotFound.Error() {
- t.Error(err)
- }
-
-}
-
-func testTPDerivedChargersSetTPDerivedChargers(t *testing.T) {
- tpDerivedChargers = &utils.TPDerivedChargers{
- TPid: "TPD",
- LoadId: "LoadID",
- Direction: "*out",
- Tenant: "cgrates.org",
- Category: "call",
- Account: "1001",
- Subject: "1001",
- DestinationIds: "",
- DerivedChargers: []*utils.TPDerivedCharger{
- &utils.TPDerivedCharger{
- RunId: "derived_run1",
- RunFilters: "",
- ReqTypeField: "^*rated",
- DirectionField: "*default",
- TenantField: "*default",
- CategoryField: "*default",
- AccountField: "*default",
- SubjectField: "^1002",
- DestinationField: "*default",
- SetupTimeField: "*default",
- PddField: "*default",
- AnswerTimeField: "*default",
- UsageField: "*default",
- SupplierField: "*default",
- DisconnectCauseField: "*default",
- CostField: "*default",
- RatedField: "*default",
- },
- },
- }
- var result string
- if err := tpDerivedChargersRPC.Call("ApierV1.SetTPDerivedChargers", tpDerivedChargers, &result); err != nil {
- t.Error(err)
- } else if result != utils.OK {
- t.Error("Unexpected reply returned", result)
- }
-}
-
-func testTPDerivedChargersGetTPDerivedChargersAfterSet(t *testing.T) {
- var reply *utils.TPDerivedChargers
- if err := tpDerivedChargersRPC.Call("ApierV1.GetTPDerivedChargers",
- &AttrGetTPDerivedChargers{TPid: "TPD", DerivedChargersId: tpDerivedChargersID}, &reply); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(tpDerivedChargers.TPid, reply.TPid) {
- t.Errorf("Expecting : %+v, received: %+v", tpDerivedChargers.TPid, reply.TPid)
- } else if !reflect.DeepEqual(tpDerivedChargers.LoadId, reply.LoadId) {
- t.Errorf("Expecting : %+v, received: %+v", tpDerivedChargers.LoadId, reply.LoadId)
- } else if !reflect.DeepEqual(tpDerivedChargers.Direction, reply.Direction) {
- t.Errorf("Expecting : %+v, received: %+v", tpDerivedChargers.Direction, reply.Direction)
- } else if !reflect.DeepEqual(tpDerivedChargers.Tenant, reply.Tenant) {
- t.Errorf("Expecting : %+v, received: %+v", tpDerivedChargers.Tenant, reply.Tenant)
- } else if !reflect.DeepEqual(tpDerivedChargers.Category, reply.Category) {
- t.Errorf("Expecting : %+v, received: %+v", tpDerivedChargers.Category, reply.Category)
- } else if !reflect.DeepEqual(tpDerivedChargers.Account, reply.Account) {
- t.Errorf("Expecting : %+v, received: %+v", tpDerivedChargers.Account, reply.Account)
- } else if !reflect.DeepEqual(tpDerivedChargers.Subject, reply.Subject) {
- t.Errorf("Expecting : %+v, received: %+v", tpDerivedChargers.Subject, reply.Subject)
- } else if !reflect.DeepEqual(tpDerivedChargers.DestinationIds, reply.DestinationIds) {
- t.Errorf("Expecting : %+v, received: %+v", tpDerivedChargers.DestinationIds, reply.DestinationIds)
- } else if !reflect.DeepEqual(len(tpDerivedChargers.DerivedChargers), len(reply.DerivedChargers)) {
- t.Errorf("Expecting : %+v, received: %+v", len(tpDerivedChargers.DerivedChargers), len(reply.DerivedChargers))
- }
-
-}
-
-func testTPDerivedChargersGetTPDerivedChargerIds(t *testing.T) {
- var result []string
- expectedTPID := []string{"LoadID:*out:cgrates.org:call:1001:1001"}
- if err := tpDerivedChargersRPC.Call("ApierV1.GetTPDerivedChargerIds",
- &AttrGetTPDerivedChargeIds{TPid: "TPD"}, &result); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(expectedTPID, result) {
- t.Errorf("Expecting: %+v, received: %+v", expectedTPID, result)
- }
-
-}
-
-func testTPDerivedChargersUpdateTPDerivedChargers(t *testing.T) {
- tpDerivedChargers.DerivedChargers = []*utils.TPDerivedCharger{
- &utils.TPDerivedCharger{
- RunId: "derived_run1",
- RunFilters: "",
- ReqTypeField: "^*rated",
- DirectionField: "*default",
- TenantField: "*default",
- CategoryField: "*default",
- AccountField: "*default",
- SubjectField: "^1002",
- DestinationField: "*default",
- SetupTimeField: "*default",
- PddField: "*default",
- AnswerTimeField: "*default",
- UsageField: "*default",
- SupplierField: "*default",
- DisconnectCauseField: "*default",
- CostField: "*default",
- RatedField: "*default",
- },
- &utils.TPDerivedCharger{
- RunId: "derived_run2",
- RunFilters: "",
- ReqTypeField: "^*rated",
- DirectionField: "*default",
- TenantField: "*default",
- CategoryField: "*default",
- AccountField: "*default",
- SubjectField: "^1003",
- DestinationField: "*default",
- SetupTimeField: "*default",
- PddField: "*default",
- AnswerTimeField: "*default",
- UsageField: "*default",
- SupplierField: "*default",
- DisconnectCauseField: "*default",
- CostField: "*default",
- RatedField: "*default",
- },
- }
- var result string
- if err := tpDerivedChargersRPC.Call("ApierV1.SetTPDerivedChargers", tpDerivedChargers, &result); err != nil {
- t.Error(err)
- } else if result != utils.OK {
- t.Error("Unexpected reply returned", result)
- }
-
-}
-
-func testTPDerivedChargersGetTPDerivedChargersAfterUpdate(t *testing.T) {
- var reply *utils.TPDerivedChargers
- if err := tpDerivedChargersRPC.Call("ApierV1.GetTPDerivedChargers",
- &AttrGetTPDerivedChargers{TPid: "TPD", DerivedChargersId: tpDerivedChargersID}, &reply); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(tpDerivedChargers.TPid, reply.TPid) {
- t.Errorf("Expecting : %+v, received: %+v", tpDerivedChargers.TPid, reply.TPid)
- } else if !reflect.DeepEqual(tpDerivedChargers.LoadId, reply.LoadId) {
- t.Errorf("Expecting : %+v, received: %+v", tpDerivedChargers.LoadId, reply.LoadId)
- } else if !reflect.DeepEqual(tpDerivedChargers.Direction, reply.Direction) {
- t.Errorf("Expecting : %+v, received: %+v", tpDerivedChargers.Direction, reply.Direction)
- } else if !reflect.DeepEqual(tpDerivedChargers.Tenant, reply.Tenant) {
- t.Errorf("Expecting : %+v, received: %+v", tpDerivedChargers.Tenant, reply.Tenant)
- } else if !reflect.DeepEqual(tpDerivedChargers.Category, reply.Category) {
- t.Errorf("Expecting : %+v, received: %+v", tpDerivedChargers.Category, reply.Category)
- } else if !reflect.DeepEqual(tpDerivedChargers.Account, reply.Account) {
- t.Errorf("Expecting : %+v, received: %+v", tpDerivedChargers.Account, reply.Account)
- } else if !reflect.DeepEqual(tpDerivedChargers.Subject, reply.Subject) {
- t.Errorf("Expecting : %+v, received: %+v", tpDerivedChargers.Subject, reply.Subject)
- } else if !reflect.DeepEqual(tpDerivedChargers.DestinationIds, reply.DestinationIds) {
- t.Errorf("Expecting : %+v, received: %+v", tpDerivedChargers.DestinationIds, reply.DestinationIds)
- } else if !reflect.DeepEqual(len(tpDerivedChargers.DerivedChargers), len(reply.DerivedChargers)) {
- t.Errorf("Expecting : %+v, received: %+v", len(tpDerivedChargers.DerivedChargers), len(reply.DerivedChargers))
- }
-
-}
-
-func testTPDerivedChargersRemTPDerivedChargers(t *testing.T) {
- var resp string
- if err := tpDerivedChargersRPC.Call("ApierV1.RemTPDerivedChargers",
- &AttrGetTPDerivedChargers{TPid: "TPD", DerivedChargersId: tpDerivedChargersID}, &resp); err != nil {
- t.Error(err)
- } else if resp != utils.OK {
- t.Error("Unexpected reply returned", resp)
- }
-
-}
-
-func testTPDerivedChargersGetTPDerivedChargersAfterRemove(t *testing.T) {
- var reply *utils.TPDerivedChargers
- if err := tpDerivedChargersRPC.Call("ApierV1.GetTPDerivedChargers",
- &AttrGetTPDerivedChargers{TPid: "TPD", DerivedChargersId: tpDerivedChargersID}, &reply); err == nil || err.Error() != utils.ErrNotFound.Error() {
- t.Error(err)
- }
-}
-
-func testTPDerivedChargersKillEngine(t *testing.T) {
- if err := engine.KillEngine(tpDerivedChargersDelay); err != nil {
- t.Error(err)
- }
-}
diff --git a/apier/v1/versions_it_test.go b/apier/v1/versions_it_test.go
index 7c467752f..86775b7e2 100644
--- a/apier/v1/versions_it_test.go
+++ b/apier/v1/versions_it_test.go
@@ -105,7 +105,7 @@ func testVrsRpcConn(t *testing.T) {
func testVrsDataDB(t *testing.T) {
var result engine.Versions
expectedVrs := engine.Versions{"ActionTriggers": 2,
- "Actions": 2, "DerivedChargers": 1, "RQF": 1, "ReverseDestinations": 1, "Attributes": 2, "RatingPlan": 1,
+ "Actions": 2, "RQF": 1, "ReverseDestinations": 1, "Attributes": 2, "RatingPlan": 1,
"RatingProfile": 1, "User": 1, "Accounts": 3, "ActionPlans": 2, "Chargers": 1,
"Destinations": 1, "SharedGroups": 2, "Stats": 2, "Resource": 1,
"Subscribers": 1, "Suppliers": 1, "Thresholds": 3, "Timing": 1}
@@ -118,9 +118,9 @@ func testVrsDataDB(t *testing.T) {
func testVrsStorDB(t *testing.T) {
var result engine.Versions
- expectedVrs := engine.Versions{"TpDerivedChargers": 1, "TpDestinations": 1, "TpResource": 1, "TpThresholds": 1,
+ expectedVrs := engine.Versions{"TpDestinations": 1, "TpResource": 1, "TpThresholds": 1,
"TpActions": 1, "TpDestinationRates": 1, "TpFilters": 1, "TpRates": 1, "CDRs": 2, "TpActionTriggers": 1, "TpRatingPlans": 1,
- "TpSharedGroups": 1, "TpSuppliers": 1, "SessionSCosts": 3, "TpDerivedCharges": 1, "TpRatingProfiles": 1, "TpStats": 1, "TpTiming": 1,
+ "TpSharedGroups": 1, "TpSuppliers": 1, "SessionSCosts": 3, "TpRatingProfiles": 1, "TpStats": 1, "TpTiming": 1,
"CostDetails": 2, "TpAccountActions": 1, "TpActionPlans": 1, "TpChargers": 1, "TpRatingProfile": 1,
"TpRatingPlan": 1, "TpResources": 1}
if err := vrsRPC.Call("ApierV1.GetStorDBVersions", "", &result); err != nil {
diff --git a/apier/v2/apier.go b/apier/v2/apier.go
index 6ad19aa63..5f9371b85 100644
--- a/apier/v2/apier.go
+++ b/apier/v2/apier.go
@@ -85,31 +85,6 @@ func (self *ApierV2) LoadAccountActions(attrs AttrLoadAccountActions, reply *str
return nil
}
-type AttrLoadDerivedChargers struct {
- TPid string
- DerivedChargersId string
-}
-
-// Load derived chargers from storDb into dataDb.
-func (self *ApierV2) LoadDerivedChargers(attrs AttrLoadDerivedChargers, reply *string) error {
- if len(attrs.TPid) == 0 {
- return utils.NewErrMandatoryIeMissing("TPid")
- }
- tpDc := &utils.TPDerivedChargers{TPid: attrs.TPid}
- tpDc.SetDerivedChargersId(attrs.DerivedChargersId)
- dbReader := engine.NewTpReader(self.DataManager.DataDB(), self.StorDb,
- attrs.TPid, self.Config.GeneralCfg().DefaultTimezone)
- if err := dbReader.LoadDerivedChargersFiltered(tpDc, true); err != nil {
- return utils.NewErrServerError(err)
- }
- if err := self.DataManager.CacheDataFromDB(utils.DERIVEDCHARGERS_PREFIX,
- []string{attrs.DerivedChargersId}, true); err != nil {
- return utils.NewErrServerError(err)
- }
- *reply = v1.OK
- return nil
-}
-
func (self *ApierV2) LoadTariffPlanFromFolder(attrs utils.AttrLoadTpFromFolder, reply *utils.LoadInstance) error {
if len(attrs.FolderPath) == 0 {
return fmt.Errorf("%s:%s", utils.ErrMandatoryIeMissing.Error(), "FolderPath")
@@ -135,7 +110,6 @@ func (self *ApierV2) LoadTariffPlanFromFolder(attrs utils.AttrLoadTpFromFolder,
path.Join(attrs.FolderPath, utils.ACTION_PLANS_CSV),
path.Join(attrs.FolderPath, utils.ACTION_TRIGGERS_CSV),
path.Join(attrs.FolderPath, utils.ACCOUNT_ACTIONS_CSV),
- path.Join(attrs.FolderPath, utils.DERIVED_CHARGERS_CSV),
path.Join(attrs.FolderPath, utils.ResourcesCsv),
path.Join(attrs.FolderPath, utils.StatsCsv),
path.Join(attrs.FolderPath, utils.ThresholdsCsv),
@@ -169,7 +143,6 @@ func (self *ApierV2) LoadTariffPlanFromFolder(attrs utils.AttrLoadTpFromFolder,
utils.REVERSE_DESTINATION_PREFIX,
utils.ACTION_PLAN_PREFIX,
utils.AccountActionPlansPrefix,
- utils.DERIVEDCHARGERS_PREFIX,
} {
loadedIDs, _ := loader.GetLoadedIds(prfx)
if err := self.DataManager.CacheDataFromDB(prfx, loadedIDs, true); err != nil {
diff --git a/cmd/cgr-engine/rater.go b/cmd/cgr-engine/rater.go
index 2d1770b3d..d410f4414 100755
--- a/cmd/cgr-engine/rater.go
+++ b/cmd/cgr-engine/rater.go
@@ -51,7 +51,6 @@ func startRater(internalRaterChan chan rpcclient.RpcClientConnection, cacheS *en
<-cacheS.GetPrecacheChannel(utils.CacheAccountActionPlans)
<-cacheS.GetPrecacheChannel(utils.CacheActionTriggers)
<-cacheS.GetPrecacheChannel(utils.CacheSharedGroups)
- <-cacheS.GetPrecacheChannel(utils.CacheDerivedChargers)
}()
var thdS *rpcclient.RpcClientPool
diff --git a/cmd/cgr-loader/cgr-loader.go b/cmd/cgr-loader/cgr-loader.go
index 791abc3aa..b9394d689 100755
--- a/cmd/cgr-loader/cgr-loader.go
+++ b/cmd/cgr-loader/cgr-loader.go
@@ -95,11 +95,11 @@ var (
flushStorDB = flag.Bool("flush_stordb", false, "Remove tariff plan data for id from the database")
remove = flag.Bool("remove", false, "Will remove instead of adding data from DB")
- err error
- dm *engine.DataManager
- storDb engine.LoadStorage
- cacheS, userS rpcclient.RpcClientConnection
- loader engine.LoadReader
+ err error
+ dm *engine.DataManager
+ storDb engine.LoadStorage
+ cacheS rpcclient.RpcClientConnection
+ loader engine.LoadReader
)
func main() {
@@ -288,7 +288,6 @@ func main() {
path.Join(*dataPath, utils.ACTION_PLANS_CSV),
path.Join(*dataPath, utils.ACTION_TRIGGERS_CSV),
path.Join(*dataPath, utils.ACCOUNT_ACTIONS_CSV),
- path.Join(*dataPath, utils.DERIVED_CHARGERS_CSV),
path.Join(*dataPath, utils.ResourcesCsv),
path.Join(*dataPath, utils.StatsCsv),
path.Join(*dataPath, utils.ThresholdsCsv),
@@ -330,7 +329,7 @@ func main() {
if err := tpReader.WriteToDatabase(*flush, *verbose, *disableReverse); err != nil {
log.Fatal("Could not write to database: ", err)
}
- var dstIds, revDstIDs, rplIds, rpfIds, actIds, aapIDs, shgIds, dcsIds, rspIDs, resIDs,
+ var dstIds, revDstIDs, rplIds, rpfIds, actIds, aapIDs, shgIds, rspIDs, resIDs,
aatIDs, stqIDs, stqpIDs, trsIDs, trspfIDs, flrIDs, spfIDs, apfIDs, chargerIDs, dppIDs []string
if cacheS != nil {
dstIds, _ = tpReader.GetLoadedIds(utils.DESTINATION_PREFIX)
@@ -340,7 +339,6 @@ func main() {
actIds, _ = tpReader.GetLoadedIds(utils.ACTION_PREFIX)
aapIDs, _ = tpReader.GetLoadedIds(utils.AccountActionPlansPrefix)
shgIds, _ = tpReader.GetLoadedIds(utils.SHARED_GROUP_PREFIX)
- dcsIds, _ = tpReader.GetLoadedIds(utils.DERIVEDCHARGERS_PREFIX)
rspIDs, _ = tpReader.GetLoadedIds(utils.ResourceProfilesPrefix)
resIDs, _ = tpReader.GetLoadedIds(utils.ResourcesPrefix)
aatIDs, _ = tpReader.GetLoadedIds(utils.ACTION_TRIGGER_PREFIX)
@@ -375,7 +373,6 @@ func main() {
ActionPlanIDs: &aps,
AccountActionPlanIDs: &aapIDs,
SharedGroupIDs: &shgIds,
- DerivedChargerIDs: &dcsIds,
ResourceProfileIDs: &rspIDs,
ResourceIDs: &resIDs,
ActionTriggerIDs: &aatIDs,
diff --git a/config/config_defaults.go b/config/config_defaults.go
index 0a8516bbe..0bbcebf55 100755
--- a/config/config_defaults.go
+++ b/config/config_defaults.go
@@ -126,7 +126,6 @@ const CGRATES_CFG_JSON = `
"account_action_plans": {"limit": -1, "ttl": "", "static_ttl": false, "precache": false}, // account action plans index caching
"action_triggers": {"limit": -1, "ttl": "", "static_ttl": false, "precache": false}, // action triggers caching
"shared_groups": {"limit": -1, "ttl": "", "static_ttl": false, "precache": false}, // shared groups caching
- "derived_chargers": {"limit": -1, "ttl": "", "static_ttl": false, "precache": false}, // derived charging rule caching
"timings": {"limit": -1, "ttl": "", "static_ttl": false, "precache": false}, // timings caching
"resource_profiles": {"limit": -1, "ttl": "", "static_ttl": false, "precache": false}, // control resource profiles caching
"resources": {"limit": -1, "ttl": "", "static_ttl": false, "precache": false}, // control resources caching
diff --git a/config/config_json_test.go b/config/config_json_test.go
index 721de2995..0c5b0b630 100755
--- a/config/config_json_test.go
+++ b/config/config_json_test.go
@@ -98,9 +98,6 @@ func TestCacheJsonCfg(t *testing.T) {
utils.CacheSharedGroups: &CacheParamJsonCfg{Limit: utils.IntPointer(-1),
Ttl: utils.StringPointer(""), Static_ttl: utils.BoolPointer(false),
Precache: utils.BoolPointer(false)},
- utils.CacheDerivedChargers: &CacheParamJsonCfg{Limit: utils.IntPointer(-1),
- Ttl: utils.StringPointer(""), Static_ttl: utils.BoolPointer(false),
- Precache: utils.BoolPointer(false)},
utils.CacheTimings: &CacheParamJsonCfg{Limit: utils.IntPointer(-1),
Ttl: utils.StringPointer(""), Static_ttl: utils.BoolPointer(false),
Precache: utils.BoolPointer(false)},
diff --git a/config/config_test.go b/config/config_test.go
index cea5b1792..10ee2741d 100755
--- a/config/config_test.go
+++ b/config/config_test.go
@@ -667,8 +667,6 @@ func TestCgrCfgJSONDefaultsCacheCFG(t *testing.T) {
TTL: time.Duration(0), StaticTTL: false, Precache: false},
utils.CacheSharedGroups: &CacheParamCfg{Limit: -1,
TTL: time.Duration(0), StaticTTL: false, Precache: false},
- utils.CacheDerivedChargers: &CacheParamCfg{Limit: -1,
- TTL: time.Duration(0), StaticTTL: false, Precache: false},
utils.CacheTimings: &CacheParamCfg{Limit: -1,
TTL: time.Duration(0), StaticTTL: false, Precache: false},
utils.CacheResourceProfiles: &CacheParamCfg{Limit: -1,
diff --git a/data/conf/cgrates/cgrates.json b/data/conf/cgrates/cgrates.json
index 805dcfa06..a051eb773 100644
--- a/data/conf/cgrates/cgrates.json
+++ b/data/conf/cgrates/cgrates.json
@@ -105,7 +105,6 @@
// "account_action_plans": {"limit": -1, "ttl": "", "static_ttl": false, "precache": false}, // account action plans index caching
// "action_triggers": {"limit": -1, "ttl": "", "static_ttl": false, "precache": false}, // action triggers caching
// "shared_groups": {"limit": -1, "ttl": "", "static_ttl": false, "precache": false}, // shared groups caching
-// "derived_chargers": {"limit": -1, "ttl": "", "static_ttl": false, "precache": false}, // derived charging rule caching
// "timings": {"limit": -1, "ttl": "", "static_ttl": false, "precache": false}, // timings caching
// "resource_profiles": {"limit": -1, "ttl": "", "static_ttl": false, "precache": false}, // control resource profiles caching
// "resources": {"limit": -1, "ttl": "", "static_ttl": false, "precache": false}, // control resources caching
diff --git a/data/conf/samples/acc_balance_keep/cgrates.json b/data/conf/samples/acc_balance_keep/cgrates.json
index ab9b89fb0..e1c11d4b2 100644
--- a/data/conf/samples/acc_balance_keep/cgrates.json
+++ b/data/conf/samples/acc_balance_keep/cgrates.json
@@ -41,7 +41,6 @@
"shared_groups": {"limit": 10000, "ttl":"0s", "precache": true},
"aliases": {"limit": 10000, "ttl":"0s", "precache": true},
"reverse_aliases": {"limit": 10000, "ttl":"0s", "precache": true},
- "derived_chargers": {"limit": 10000, "ttl":"0s", "precache": true},
"resource_profiles": {"limit": 10000, "ttl":"0s", "precache": true},
"resources": {"limit": 10000, "ttl":"0s", "precache": true},
"statqueues": {"limit": 10000, "ttl":"0s", "precache": true},
diff --git a/data/conf/samples/apier/apier.json b/data/conf/samples/apier/apier.json
index 4a65f18e8..bec74b10c 100644
--- a/data/conf/samples/apier/apier.json
+++ b/data/conf/samples/apier/apier.json
@@ -20,7 +20,6 @@
"account_action_plans": {"limit": 10000, "ttl":"0s", "precache": true},
"action_triggers": {"limit": 10000, "ttl":"0s", "precache": true},
"shared_groups": {"limit": 10000, "ttl":"0s", "precache": true},
- "derived_chargers": {"limit": 10000, "ttl":"0s", "precache": true},
"resource_profiles": {"limit": 10000, "ttl":"0s", "precache": true},
"resources": {"limit": 10000, "ttl":"0s", "precache": true},
"statqueues": {"limit": 10000, "ttl":"0s", "precache": true},
diff --git a/data/conf/samples/cdrewithfilter/cgrates.json b/data/conf/samples/cdrewithfilter/cgrates.json
index 86c0eeff5..483e30875 100755
--- a/data/conf/samples/cdrewithfilter/cgrates.json
+++ b/data/conf/samples/cdrewithfilter/cgrates.json
@@ -38,7 +38,6 @@
"account_action_plans": {"limit": 10000, "ttl":"0s", "precache": true},
"action_triggers": {"limit": 10000, "ttl":"0s", "precache": true},
"shared_groups": {"limit": 10000, "ttl":"0s", "precache": true},
- "derived_chargers": {"limit": 10000, "ttl":"0s", "precache": true},
"resource_profiles": {"limit": 10000, "ttl":"0s", "precache": true},
"resources": {"limit": 10000, "ttl":"0s", "precache": true},
"statqueues": {"limit": 10000, "ttl":"0s", "precache": true},
diff --git a/data/conf/samples/mongoatlas/cgrates.json b/data/conf/samples/mongoatlas/cgrates.json
index e80d5311d..08c029807 100755
--- a/data/conf/samples/mongoatlas/cgrates.json
+++ b/data/conf/samples/mongoatlas/cgrates.json
@@ -45,7 +45,6 @@
"account_action_plans": {"limit": 10000, "ttl":"0s", "precache": true},
"action_triggers": {"limit": 10000, "ttl":"0s", "precache": true},
"shared_groups": {"limit": 10000, "ttl":"0s", "precache": true},
- "derived_chargers": {"limit": 10000, "ttl":"0s", "precache": true},
"resource_profiles": {"limit": 10000, "ttl":"0s", "precache": true},
"resources": {"limit": 10000, "ttl":"0s", "precache": true},
"statqueues": {"limit": 10000, "ttl":"0s", "precache": true},
diff --git a/data/conf/samples/mongoreplica/cgrates.json b/data/conf/samples/mongoreplica/cgrates.json
index 92e98f27d..f51c6aa41 100755
--- a/data/conf/samples/mongoreplica/cgrates.json
+++ b/data/conf/samples/mongoreplica/cgrates.json
@@ -46,7 +46,6 @@
"account_action_plans": {"limit": 10000, "ttl":"0s", "precache": true},
"action_triggers": {"limit": 10000, "ttl":"0s", "precache": true},
"shared_groups": {"limit": 10000, "ttl":"0s", "precache": true},
- "derived_chargers": {"limit": 10000, "ttl":"0s", "precache": true},
"resource_profiles": {"limit": 10000, "ttl":"0s", "precache": true},
"resources": {"limit": 10000, "ttl":"0s", "precache": true},
"statqueues": {"limit": 10000, "ttl":"0s", "precache": true},
diff --git a/data/conf/samples/smgeneric/cgrates.json b/data/conf/samples/smgeneric/cgrates.json
index 6b413c6ee..835c9ec0c 100644
--- a/data/conf/samples/smgeneric/cgrates.json
+++ b/data/conf/samples/smgeneric/cgrates.json
@@ -29,7 +29,6 @@
"account_action_plans": {"limit": 10000, "ttl":"0s", "precache": true},
"action_triggers": {"limit": 10000, "ttl":"0s", "precache": true},
"shared_groups": {"limit": 10000, "ttl":"0s", "precache": true},
- "derived_chargers": {"limit": 10000, "ttl":"0s", "precache": true},
"resource_profiles": {"limit": 10000, "ttl":"0s", "precache": true},
"resources": {"limit": 10000, "ttl":"0s", "precache": true},
"statqueues": {"limit": 10000, "ttl":"0s", "precache": true},
diff --git a/data/conf/samples/tutmongo/cgrates.json b/data/conf/samples/tutmongo/cgrates.json
index 6e454344d..118e6ef6a 100644
--- a/data/conf/samples/tutmongo/cgrates.json
+++ b/data/conf/samples/tutmongo/cgrates.json
@@ -39,7 +39,6 @@
"account_action_plans": {"limit": 10000, "ttl":"0s", "precache": true},
"action_triggers": {"limit": 10000, "ttl":"0s", "precache": true},
"shared_groups": {"limit": 10000, "ttl":"0s", "precache": true},
- "derived_chargers": {"limit": 10000, "ttl":"0s", "precache": true},
"resource_profiles": {"limit": 10000, "ttl":"0s", "precache": true},
"resources": {"limit": 10000, "ttl":"0s", "precache": true},
"statqueues": {"limit": 10000, "ttl":"0s", "precache": true},
diff --git a/data/conf/samples/tutmongojson/cgrates.json b/data/conf/samples/tutmongojson/cgrates.json
index abc199f8b..fa7044d27 100644
--- a/data/conf/samples/tutmongojson/cgrates.json
+++ b/data/conf/samples/tutmongojson/cgrates.json
@@ -40,7 +40,6 @@
"account_action_plans": {"limit": 10000, "ttl":"0s", "precache": true},
"action_triggers": {"limit": 10000, "ttl":"0s", "precache": true},
"shared_groups": {"limit": 10000, "ttl":"0s", "precache": true},
- "derived_chargers": {"limit": 10000, "ttl":"0s", "precache": true},
"resource_profiles": {"limit": 10000, "ttl":"0s", "precache": true},
"resources": {"limit": 10000, "ttl":"0s", "precache": true},
"statqueues": {"limit": 10000, "ttl":"0s", "precache": true},
diff --git a/data/conf/samples/tutmongonew/cgrates.json b/data/conf/samples/tutmongonew/cgrates.json
index e6d934e80..7458ca1ee 100644
--- a/data/conf/samples/tutmongonew/cgrates.json
+++ b/data/conf/samples/tutmongonew/cgrates.json
@@ -39,7 +39,6 @@
"account_action_plans": {"limit": 10000, "ttl":"0s", "precache": true},
"action_triggers": {"limit": 10000, "ttl":"0s", "precache": true},
"shared_groups": {"limit": 10000, "ttl":"0s", "precache": true},
- "derived_chargers": {"limit": 10000, "ttl":"0s", "precache": true},
"resource_profiles": {"limit": 10000, "ttl":"0s", "precache": true},
"resources": {"limit": 10000, "ttl":"0s", "precache": true},
"statqueues": {"limit": 10000, "ttl":"0s", "precache": true},
diff --git a/data/conf/samples/tutmysql/cgrates.json b/data/conf/samples/tutmysql/cgrates.json
index db0e5ac53..4db45849f 100644
--- a/data/conf/samples/tutmysql/cgrates.json
+++ b/data/conf/samples/tutmysql/cgrates.json
@@ -35,7 +35,6 @@
"account_action_plans": {"limit": 10000, "ttl":"0s", "precache": true},
"action_triggers": {"limit": 10000, "ttl":"0s", "precache": true},
"shared_groups": {"limit": 10000, "ttl":"0s", "precache": true},
- "derived_chargers": {"limit": 10000, "ttl":"0s", "precache": true},
"resource_profiles": {"limit": 10000, "ttl":"0s", "precache": true},
"resources": {"limit": 10000, "ttl":"0s", "precache": true},
"statqueues": {"limit": 10000, "ttl":"0s", "precache": true},
diff --git a/data/conf/samples/tutmysqljson/cgrates.json b/data/conf/samples/tutmysqljson/cgrates.json
index d355fd31c..88eeb07c5 100644
--- a/data/conf/samples/tutmysqljson/cgrates.json
+++ b/data/conf/samples/tutmysqljson/cgrates.json
@@ -37,7 +37,6 @@
"account_action_plans": {"limit": 10000, "ttl":"0s", "precache": true},
"action_triggers": {"limit": 10000, "ttl":"0s", "precache": true},
"shared_groups": {"limit": 10000, "ttl":"0s", "precache": true},
- "derived_chargers": {"limit": 10000, "ttl":"0s", "precache": true},
"resource_profiles": {"limit": 10000, "ttl":"0s", "precache": true},
"resources": {"limit": 10000, "ttl":"0s", "precache": true},
"statqueues": {"limit": 10000, "ttl":"0s", "precache": true},
diff --git a/data/storage/mysql/create_tariffplan_tables.sql b/data/storage/mysql/create_tariffplan_tables.sql
index 5f68abbe3..6990887da 100644
--- a/data/storage/mysql/create_tariffplan_tables.sql
+++ b/data/storage/mysql/create_tariffplan_tables.sql
@@ -242,62 +242,6 @@ CREATE TABLE `tp_account_actions` (
UNIQUE KEY `unique_tp_account` (`tpid`,`loadid`,`tenant`,`account`)
);
---
--- Table structure for table `tp_derived_chargers`
---
-
-DROP TABLE IF EXISTS tp_derived_chargers;
-CREATE TABLE tp_derived_chargers (
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `tpid` varchar(64) NOT NULL,
- `loadid` varchar(64) NOT NULL,
- `direction` varchar(8) NOT NULL,
- `tenant` varchar(64) NOT NULL,
- `category` varchar(32) NOT NULL,
- `account` varchar(64) NOT NULL,
- `subject` varchar(64) NOT NULL,
- `destination_ids` varchar(64) NOT NULL,
- `runid` varchar(24) NOT NULL,
- `run_filters` varchar(256) NOT NULL,
- `req_type_field` varchar(64) NOT NULL,
- `direction_field` varchar(64) NOT NULL,
- `tenant_field` varchar(64) NOT NULL,
- `category_field` varchar(64) NOT NULL,
- `account_field` varchar(64) NOT NULL,
- `subject_field` varchar(64) NOT NULL,
- `destination_field` varchar(64) NOT NULL,
- `setup_time_field` varchar(64) NOT NULL,
- `pdd_field` varchar(64) NOT NULL,
- `answer_time_field` varchar(64) NOT NULL,
- `usage_field` varchar(64) NOT NULL,
- `supplier_field` varchar(64) NOT NULL,
- `disconnect_cause_field` varchar(64) NOT NULL,
- `rated_field` varchar(64) NOT NULL,
- `cost_field` varchar(64) NOT NULL,
- `created_at` TIMESTAMP,
- PRIMARY KEY (`id`),
- KEY `tpid` (`tpid`)
-);
-
---
--- Table structure for table `tp_users`
---
-
-DROP TABLE IF EXISTS tp_users;
-CREATE TABLE tp_users (
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `tpid` varchar(64) NOT NULL,
- `tenant` varchar(64) NOT NULL,
- `user_name` varchar(64) NOT NULL,
- `masked` BOOLEAN NOT NULL,
- `attribute_name` varchar(64) NOT NULL,
- `attribute_value` varchar(64) NOT NULL,
- `weight` DECIMAL(8,2) NOT NULL,
- `created_at` TIMESTAMP,
- PRIMARY KEY (`id`),
- KEY `tpid` (`tpid`)
-);
-
--
-- Table structure for table `tp_resources`
--
diff --git a/data/storage/postgres/create_tariffplan_tables.sql b/data/storage/postgres/create_tariffplan_tables.sql
index 0f9f915f0..490907cbe 100644
--- a/data/storage/postgres/create_tariffplan_tables.sql
+++ b/data/storage/postgres/create_tariffplan_tables.sql
@@ -238,43 +238,6 @@ CREATE INDEX tpaccountactions_tpid_idx ON tp_account_actions (tpid);
CREATE INDEX tpaccountactions_idx ON tp_account_actions (tpid,loadid,tenant,account);
---
--- Table structure for table `tp_derived_chargers`
---
-
-DROP TABLE IF EXISTS tp_derived_chargers;
-CREATE TABLE tp_derived_chargers (
- id SERIAL PRIMARY KEY,
- tpid VARCHAR(64) NOT NULL,
- loadid VARCHAR(64) NOT NULL,
- direction VARCHAR(8) NOT NULL,
- tenant VARCHAR(64) NOT NULL,
- category VARCHAR(32) NOT NULL,
- account VARCHAR(64) NOT NULL,
- subject VARCHAR(64) NOT NULL,
- destination_ids VARCHAR(64) NOT NULL,
- runid VARCHAR(24) NOT NULL,
- run_filters VARCHAR(256) NOT NULL,
- req_type_field VARCHAR(64) NOT NULL,
- direction_field VARCHAR(64) NOT NULL,
- tenant_field VARCHAR(64) NOT NULL,
- category_field VARCHAR(64) NOT NULL,
- account_field VARCHAR(64) NOT NULL,
- subject_field VARCHAR(64) NOT NULL,
- destination_field VARCHAR(64) NOT NULL,
- setup_time_field VARCHAR(64) NOT NULL,
- pdd_field VARCHAR(64) NOT NULL,
- answer_time_field VARCHAR(64) NOT NULL,
- usage_field VARCHAR(64) NOT NULL,
- supplier_field VARCHAR(64) NOT NULL,
- disconnect_cause_field VARCHAR(64) NOT NULL,
- rated_field VARCHAR(64) NOT NULL,
- cost_field VARCHAR(64) NOT NULL,
- created_at TIMESTAMP WITH TIME ZONE
-);
-CREATE INDEX tpderivedchargers_tpid_idx ON tp_derived_chargers (tpid);
-CREATE INDEX tpderivedchargers_idx ON tp_derived_chargers (tpid,loadid,direction,tenant,category,account,subject);
-
--
-- Table structure for table `tp_resources`
--
diff --git a/data/tariffplans/oldtutorial/Aliases.csv b/data/tariffplans/oldtutorial/Aliases.csv
deleted file mode 100644
index 7b966debf..000000000
--- a/data/tariffplans/oldtutorial/Aliases.csv
+++ /dev/null
@@ -1,3 +0,0 @@
-#Direction,Tenant,Category,Account,Subject,DestinationId,Context,Target,Original,Alias,Weight
-*out,cgrates.org,call,1006,1006,*any,*rating,Subject,1006,1001,10
-*out,cgrates.org,call,1006,1006,*any,*rating,Account,1006,1002,10
diff --git a/data/tariffplans/oldtutorial/DerivedChargers.csv b/data/tariffplans/oldtutorial/DerivedChargers.csv
deleted file mode 100644
index f0b405f7d..000000000
--- a/data/tariffplans/oldtutorial/DerivedChargers.csv
+++ /dev/null
@@ -1,2 +0,0 @@
-#Direction[0],Tenant[1],Category[2],Account[3],Subject[4],DestinationIds[5],RunId[6],RunFilter[7],ReqTypeField[8],DirectionField[9],TenantField[10],CategoryField[11],AccountField[12],SubjectField[13],DestinationField[14],SetupTimeField[15],PddField[16],AnswerTimeField[17],UsageField[18],SupplierField[19],DisconnectCause[20],RatedField[21],CostField[22]
-*out,cgrates.org,call,1001,1001,,derived_run1,,^*rated,*default,*default,*default,*default,^1002,*default,*default,*default,*default,*default,*default,*default,*default,*default
diff --git a/data/tariffplans/oldtutorial/Users.csv b/data/tariffplans/oldtutorial/Users.csv
deleted file mode 100644
index 63b36ff9f..000000000
--- a/data/tariffplans/oldtutorial/Users.csv
+++ /dev/null
@@ -1,22 +0,0 @@
-#Tenant[0],UserName[1],Masked[2],AttributeName[3],AttributeValue[4],Weight[5]
-cgrates.org,1001,,SysUserName,danb,10
-cgrates.org,1001,,SysPassword,hisPass321,10
-cgrates.org,1001,,Cli,+4986517174963,10
-cgrates.org,1001,,Account,1001,10
-cgrates.org,1001,,Subject,1001,10
-cgrates.org,1001,,Uuid,388539dfd4f5cefee8f488b78c6c244b9e19138e,10
-cgrates.org,1001,,SubscriberId,1001,10
-cgrates.org,1001,,RequestType,*prepaid,10
-cgrates.org,1002,,SysUserName,rif,10
-cgrates.org,1002,,RifAttr,RifVal,10
-cgrates.org,1002,,Account,1002,10
-cgrates.org,1002,,Subject,1002,10
-cgrates.org,1002,,Uuid,27f37edec0670fa34cf79076b80ef5021e39c5b5,10
-cgrates.org,1002,,SubscriberId,1002,10
-cgrates.org,1004,,SysUserName,danb4,10
-cgrates.org,1004,,SysPassword,hisPass321,10
-cgrates.org,1004,,Cli,+4986517174964,10
-cgrates.org,1004,,Account,1004,10
-cgrates.org,1004,,Subject,1004,10
-cgrates.org,1004,,RequestType,*rated,10
-cgrates.org,1004,,SubscriberId,1004,10
diff --git a/data/tariffplans/testtp/Aliases.csv b/data/tariffplans/testtp/Aliases.csv
deleted file mode 100644
index 411504160..000000000
--- a/data/tariffplans/testtp/Aliases.csv
+++ /dev/null
@@ -1,3 +0,0 @@
-#Direction,Tenant,Category,Account,Subject,DestinationId,Context,Target,Original,Alias,Weight
-*out,cgrates.org,call,1006,1006,*any,*rating,Subject,1006,1001,10
-*out,cgrates.org,call,1006,1006,*any,*rating,Account,1006,1002,10
diff --git a/data/tariffplans/testtp/DerivedChargers.csv b/data/tariffplans/testtp/DerivedChargers.csv
deleted file mode 100644
index 5493da35d..000000000
--- a/data/tariffplans/testtp/DerivedChargers.csv
+++ /dev/null
@@ -1,6 +0,0 @@
-#Direction[0],Tenant[1],Category[2],Account[3],Subject[4],DestinationIds[5],RunId[6],RunFilter[7],ReqTypeField[8],DirectionField[9],TenantField[10],CategoryField[11],AccountField[12],SubjectField[13],DestinationField[14],SetupTimeField[15],PddField[16],AnswerTimeField[17],UsageField[18],SupplierField[19],DisconnectCause[20],RatedField[21],CostField[22]
-*out,cgrates.org,call,dan,dan,,extra1,,^prepaid,,,,^rif,^rif,,,,,^1s,*default,*default,*default,*default
-*out,cgrates.org,call,dan,dan,,extra2,,,,,,^ivo,^ivo,,,,,,*default,*default,*default,*default
-*out,cgrates.org,call,dan,dan,,extra3,~filterhdr1:s/(.+)/special_run3/,,,,,^runusr3,^runusr3,,,,,,*default,*default,*default,*default
-*out,cgrates.org,call,dan,*any,,extra1,,,,,,^rif2,^rif2,,,,,,*default,*default,*default,*default
-*out,cgrates.org,call,1011,1011,GERMANY,extra1,,,,,,,,^+4915,,,,,*default,*default,*default,*default
\ No newline at end of file
diff --git a/data/tariffplans/testtp/Users.csv b/data/tariffplans/testtp/Users.csv
deleted file mode 100644
index 006652ff9..000000000
--- a/data/tariffplans/testtp/Users.csv
+++ /dev/null
@@ -1,19 +0,0 @@
-#Tenant[0],UserName[1],Maksed[2],AttributeName[3],AttributeValue[4],Weight[5]
-cgrates.org,1001,,SysUserName,danb,10
-cgrates.org,1001,,SysPassword,hisPass321,10
-cgrates.org,1001,,Cli,+4986517174963,10
-cgrates.org,1001,,Account,1001,10
-cgrates.org,1001,,Subject,1001,10
-cgrates.org,1001,,Uuid,388539dfd4f5cefee8f488b78c6c244b9e19138e,10
-cgrates.org,1001,,ReqType,*prepaid,10
-cgrates.org,1002,,SysUserName,rif,10
-cgrates.org,1002,,RifAttr,RifVal,10
-cgrates.org,1002,,Account,1002,10
-cgrates.org,1002,,Subject,1002,10
-cgrates.org,1002,,Uuid,27f37edec0670fa34cf79076b80ef5021e39c5b5,10
-cgrates.org,1004,,SysUserName,danb4,10
-cgrates.org,1004,,SysPassword,hisPass321,10
-cgrates.org,1004,,Cli,+4986517174964,10
-cgrates.org,1004,,Account,1004,10
-cgrates.org,1004,,Subject,1004,10
-cgrates.org,1004,,ReqType,*rated,10
diff --git a/engine/caches.go b/engine/caches.go
index 513110ad8..eb0b420ba 100644
--- a/engine/caches.go
+++ b/engine/caches.go
@@ -43,7 +43,6 @@ var precachedPartitions = []string{
utils.CacheAccountActionPlans,
utils.CacheActionTriggers,
utils.CacheSharedGroups,
- utils.CacheDerivedChargers,
utils.CacheResourceProfiles,
utils.CacheResources,
utils.CacheEventResources,
diff --git a/engine/datamanager.go b/engine/datamanager.go
index e30b6bc18..39f5d3967 100644
--- a/engine/datamanager.go
+++ b/engine/datamanager.go
@@ -77,7 +77,6 @@ func (dm *DataManager) LoadDataDBCache(dstIDs, rvDstIDs, rplIDs, rpfIDs, actIDs,
utils.AccountActionPlansPrefix: aaPlIDs,
utils.ACTION_TRIGGER_PREFIX: atrgIDs,
utils.SHARED_GROUP_PREFIX: sgIDs,
- utils.DERIVEDCHARGERS_PREFIX: dcIDs,
utils.ResourceProfilesPrefix: rpIDs,
utils.ResourcesPrefix: resIDs,
utils.StatQueuePrefix: stqIDs,
@@ -135,7 +134,6 @@ func (dm *DataManager) CacheDataFromDB(prfx string, ids []string, mustBeCached b
utils.AccountActionPlansPrefix,
utils.ACTION_TRIGGER_PREFIX,
utils.SHARED_GROUP_PREFIX,
- utils.DERIVEDCHARGERS_PREFIX,
utils.ResourceProfilesPrefix,
utils.TimingsPrefix,
utils.ResourcesPrefix,
@@ -202,8 +200,6 @@ func (dm *DataManager) CacheDataFromDB(prfx string, ids []string, mustBeCached b
_, err = dm.GetActionTriggers(dataID, true, utils.NonTransactional)
case utils.SHARED_GROUP_PREFIX:
_, err = dm.GetSharedGroup(dataID, true, utils.NonTransactional)
- case utils.DERIVEDCHARGERS_PREFIX:
- _, err = dm.GetDerivedChargers(dataID, true, utils.NonTransactional)
case utils.ResourceProfilesPrefix:
tntID := utils.NewTenantID(dataID)
_, err = dm.GetResourceProfile(tntID.Tenant, tntID.ID, false, true, utils.NonTransactional)
@@ -802,38 +798,6 @@ func (dm *DataManager) RemoveSharedGroup(id, transactionID string) (err error) {
return
}
-func (dm *DataManager) GetDerivedChargers(key string, skipCache bool,
- transactionID string) (dcs *utils.DerivedChargers, err error) {
- if !skipCache {
- if x, ok := Cache.Get(utils.CacheDerivedChargers, key); ok {
- if x != nil {
- return x.(*utils.DerivedChargers), nil
- }
- return nil, utils.ErrNotFound
- }
- }
- dcs, err = dm.DataDB().GetDerivedChargersDrv(key)
- if err != nil {
- if err == utils.ErrNotFound {
- Cache.Set(utils.CacheDerivedChargers, key, nil, nil,
- cacheCommit(transactionID), transactionID)
- }
- return nil, err
- }
- Cache.Set(utils.CacheDerivedChargers, key, dcs, nil,
- cacheCommit(transactionID), transactionID)
- return
-}
-
-func (dm *DataManager) RemoveDerivedChargers(id, transactionID string) (err error) {
- if err = dm.DataDB().RemoveDerivedChargersDrv(id, transactionID); err != nil {
- return
- }
- Cache.Remove(utils.CacheDerivedChargers, id,
- cacheCommit(transactionID), transactionID)
- return
-}
-
func (dm *DataManager) GetActions(key string, skipCache bool, transactionID string) (as Actions, err error) {
if !skipCache {
if x, err := Cache.GetCloned(utils.CacheActions, key); err != nil {
diff --git a/engine/handler_derivedcharging.go b/engine/handler_derivedcharging.go
deleted file mode 100644
index 259df0cd7..000000000
--- a/engine/handler_derivedcharging.go
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-package engine
-
-import "github.com/cgrates/cgrates/utils"
-
-// Handles retrieving of DerivedChargers profile based on longest match from DataDb
-func HandleGetDerivedChargers(dm *DataManager, attrs *utils.AttrDerivedChargers) (*utils.DerivedChargers, error) {
- dcs := &utils.DerivedChargers{}
- strictKey := utils.DerivedChargersKey(attrs.Direction, attrs.Tenant, attrs.Category, attrs.Account, attrs.Subject)
- anySubjKey := utils.DerivedChargersKey(attrs.Direction, attrs.Tenant, attrs.Category, attrs.Account, utils.ANY)
- anyAcntKey := utils.DerivedChargersKey(attrs.Direction, attrs.Tenant, attrs.Category, utils.ANY, utils.ANY)
- anyCategKey := utils.DerivedChargersKey(attrs.Direction, attrs.Tenant, utils.ANY, utils.ANY, utils.ANY)
- anyTenantKey := utils.DerivedChargersKey(attrs.Direction, utils.ANY, utils.ANY, utils.ANY, utils.ANY)
- for _, dcKey := range []string{strictKey, anySubjKey, anyAcntKey, anyCategKey, anyTenantKey} {
- if dcsDb, err := dm.GetDerivedChargers(dcKey, false, utils.NonTransactional); err != nil && err != utils.ErrNotFound {
- return nil, err
- } else if dcsDb != nil && DerivedChargersMatchesDest(dcsDb, attrs.Destination) {
- dcs = dcsDb
- break
- }
- }
- return dcs, nil
-}
-
-func DerivedChargersMatchesDest(dcs *utils.DerivedChargers, dest string) bool {
- if len(dcs.DestinationIDs) == 0 || dcs.DestinationIDs[utils.ANY] {
- return true
- }
- // check destination ids
- for _, p := range utils.SplitPrefix(dest, MIN_PREFIX_MATCH) {
- if destIDs, err := dm.DataDB().GetReverseDestination(p, false, utils.NonTransactional); err == nil {
- for _, dId := range destIDs {
- includeDest, found := dcs.DestinationIDs[dId]
- if found {
- return includeDest
- }
- }
- }
- }
- return false
-}
diff --git a/engine/handler_derivedcharging_test.go b/engine/handler_derivedcharging_test.go
deleted file mode 100644
index 8861664c6..000000000
--- a/engine/handler_derivedcharging_test.go
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-package engine
-
-import (
- "testing"
-
- "github.com/cgrates/cgrates/utils"
-)
-
-/*
-var cfgDcT *config.CGRConfig
-var dataDB DataDB
-
-func init() {
- cfgDcT, _ = config.NewDefaultCGRConfig()
- if DEBUG {
- dataDB, _ = NewMapStorage()
- } else {
- dataDB, _ = NewRedisStorage("127.0.0.1:6379", 13, "", utils.MSGPACK)
- }
- dataDB.CacheAccounting(nil, nil, nil, nil)
-}
-
-
-// Accounting db has no DerivedChargers nor configured defaults
-func TestHandleGetEmptyDC(t *testing.T) {
- attrs := utils.AttrDerivedChargers{Tenant: "cgrates.org", Category: "call", Direction: "*out", Account: "test2", Subject: "test2"}
- if dcs, err := HandleGetDerivedChargers(dataDB, attrs); err != nil {
- t.Error("Unexpected error", err.Error())
- } else if !reflect.DeepEqual(dcs, cfgDcT.DerivedChargers) {
- t.Error("Returned DerivedChargers not matching the configured ones")
- }
-}
-
-// Accounting db has no DerivedChargers, configured defaults
-func TestHandleGetConfiguredDC(t *testing.T) {
- cfgedDC := utils.DerivedChargers{&utils.DerivedCharger{RunId: "responder1", ReqTypeField: "test", DirectionField: "test", TenantField: "test",
- CategoryField: "test", AccountField: "test", SubjectField: "test", DestinationField: "test", SetupTimeField: "test", AnswerTimeField: "test", UsageField: "test"}}
- cfgDcT.DerivedChargers = cfgedDC
- attrs := utils.AttrDerivedChargers{Tenant: "cgrates.org", Category: "call", Direction: "*out", Account: "test3", Subject: "test3"}
- if dcs, err := HandleGetDerivedChargers(dataDB, cfgDcT, attrs); err != nil {
- t.Error("Unexpected error", err.Error())
- } else if !reflect.DeepEqual(dcs, cfgedDC) {
- t.Error("Returned DerivedChargers not matching the configured ones")
- }
-}
-
-// Receive composed derived chargers
-func TestHandleGetStoredDC(t *testing.T) {
- keyCharger1 := utils.DerivedChargersKey("*out", "cgrates.org", "call", "rif", "rif")
- charger1 := utils.DerivedChargers{
- &utils.DerivedCharger{RunId: "extra1", ReqTypeField: "^prepaid", DirectionField: "*default", TenantField: "*default", CategoryField: "*default",
- AccountField: "rif", SubjectField: "rif", DestinationField: "*default", SetupTimeField: "*default", AnswerTimeField: "*default", UsageField: "*default"},
- &utils.DerivedCharger{RunId: "extra2", ReqTypeField: "*default", DirectionField: "*default", TenantField: "*default", CategoryField: "*default",
- AccountField: "ivo", SubjectField: "ivo", DestinationField: "*default", SetupTimeField: "*default", AnswerTimeField: "*default", UsageField: "*default"},
- }
- if err := dataDB.SetDerivedChargers(keyCharger1, charger1); err != nil {
- t.Error("Error on setDerivedChargers", err.Error())
- }
- // Expected Charger should have default configured values added
- expCharger1 := append(charger1, &utils.DerivedCharger{RunId: "responder1", ReqTypeField: "test", DirectionField: "test", TenantField: "test",
- CategoryField: "test", AccountField: "test", SubjectField: "test", DestinationField: "test", SetupTimeField: "test", AnswerTimeField: "test", UsageField: "test"})
- dataDB.CacheAccounting(nil, nil, nil, nil)
- attrs := utils.AttrDerivedChargers{Tenant: "cgrates.org", Category: "call", Direction: "*out", Account: "rif", Subject: "rif"}
- if dcs, err := HandleGetDerivedChargers(dataDB, cfgDcT, attrs); err != nil {
- t.Error("Unexpected error", err.Error())
- } else if !reflect.DeepEqual(dcs, expCharger1) {
- t.Error("Returned DerivedChargers not matching the configured ones")
- }
- cfgDcT.CombinedDerivedChargers = false
- if dcs, err := HandleGetDerivedChargers(dataDB, cfgDcT, attrs); err != nil {
- t.Error("Unexpected error", err.Error())
- } else if !reflect.DeepEqual(dcs, charger1) {
- t.Error("Returned DerivedChargers not matching the configured ones")
- }
-}
-*/
-
-func TestHandleDeivedChargersMatchDestRet(t *testing.T) {
- dcs := &utils.DerivedChargers{
- DestinationIDs: utils.NewStringMap("RET"),
- }
- if !DerivedChargersMatchesDest(dcs, "0723045326") {
- t.Error("Derived charger failed to match dest")
- }
-}
-
-func TestHandleDeivedChargersMatchDestNat(t *testing.T) {
- dcs := &utils.DerivedChargers{
- DestinationIDs: utils.NewStringMap("NAT"),
- }
- if !DerivedChargersMatchesDest(dcs, "0723045326") {
- t.Error("Derived charger failed to match dest")
- }
-}
-
-func TestHandleDeivedChargersMatchDestNatRet(t *testing.T) {
- dcs := &utils.DerivedChargers{
- DestinationIDs: utils.NewStringMap("NAT", "RET"),
- }
- if !DerivedChargersMatchesDest(dcs, "0723045326") {
- t.Error("Derived charger failed to match dest")
- }
-}
-
-func TestHandleDeivedChargersMatchDestSpec(t *testing.T) {
- dcs := &utils.DerivedChargers{
- DestinationIDs: utils.NewStringMap("NAT", "SPEC"),
- }
- if !DerivedChargersMatchesDest(dcs, "0723045326") {
- t.Error("Derived charger failed to match dest")
- }
-}
-
-func TestHandleDeivedChargersMatchDestNegativeSpec(t *testing.T) {
- dcs := &utils.DerivedChargers{
- DestinationIDs: utils.NewStringMap("NAT", "!SPEC"),
- }
- if DerivedChargersMatchesDest(dcs, "0723045326") {
- t.Error("Derived charger failed to match dest")
- }
-}
diff --git a/engine/libtest.go b/engine/libtest.go
index 41c6ccc03..5d4718e69 100644
--- a/engine/libtest.go
+++ b/engine/libtest.go
@@ -135,7 +135,6 @@ func LoadTariffPlanFromFolder(tpPath, timezone string, dm *DataManager, disable_
path.Join(tpPath, utils.ACTION_PLANS_CSV),
path.Join(tpPath, utils.ACTION_TRIGGERS_CSV),
path.Join(tpPath, utils.ACCOUNT_ACTIONS_CSV),
- path.Join(tpPath, utils.DERIVED_CHARGERS_CSV),
path.Join(tpPath, utils.ResourcesCsv),
path.Join(tpPath, utils.StatsCsv),
diff --git a/engine/loader_csv_test.go b/engine/loader_csv_test.go
index 3c88e52c4..93aaa1891 100644
--- a/engine/loader_csv_test.go
+++ b/engine/loader_csv_test.go
@@ -219,13 +219,6 @@ cgrates.org,expo,EXP_AT,,false,false
cgrates.org,expnoexp,,,false,false
cgrates.org,vf,,,false,false
cgrates.org,round,TOPUP10_AT,,false,false
-`
-
- derivedCharges = `
-#Direction,Tenant,Category,Account,Subject,DestinationIds,RunId,RunFilter,RequestTypeField,DirectionField,TenantField,TorField,AccountField,SubjectField,DestinationField,SetupTimeField,PddField,AnswerTimeField,UsageField,SupplierField,DisconnectCauseField,CostField,RatedField
-*out,cgrates.org,call,dan,dan,,extra1,^filteredHeader1/filterValue1/,^prepaid,,,,rif,rif,,,,,,,,,
-*out,cgrates.org,call,dan,dan,,extra2,,,,,,ivo,ivo,,,,,,,,,
-*out,cgrates.org,call,dan,*any,,extra1,,,,,,rif2,rif2,,,,,,,,,
`
resProfiles = `
#Tenant[0],Id[1],FilterIDs[2],ActivationInterval[3],TTL[4],Limit[5],AllocationMessage[6],Blocker[7],Stored[8],Weight[9],Thresholds[10]
@@ -282,7 +275,7 @@ var csvr *TpReader
func init() {
csvr = NewTpReader(dm.dataDB, NewStringCSVStorage(',', destinations, timings, rates, destinationRates,
ratingPlans, ratingProfiles, sharedGroups, actions, actionPlans, actionTriggers,
- accountActions, derivedCharges, resProfiles, stats, thresholds,
+ accountActions, resProfiles, stats, thresholds,
filters, sppProfiles, attributeProfiles, chargerProfiles, dispatcherProfiles), testTPID, "")
if err := csvr.LoadDestinations(); err != nil {
@@ -318,9 +311,6 @@ func init() {
if err := csvr.LoadAccountActions(); err != nil {
log.Print("error in LoadAccountActions:", err)
}
- if err := csvr.LoadDerivedChargers(); err != nil {
- log.Print("error in LoadDerivedChargers:", err)
- }
if err := csvr.LoadFilters(); err != nil {
log.Print("error in LoadFilter:", err)
}
@@ -1195,38 +1185,6 @@ func TestLoadAccountActions(t *testing.T) {
}
}
-func TestLoadDerivedChargers(t *testing.T) {
- if len(csvr.derivedChargers) != 2 {
- t.Error("Failed to load derivedChargers: ", csvr.derivedChargers)
- }
- expCharger1 := &utils.DerivedChargers{
- DestinationIDs: nil,
- Chargers: []*utils.DerivedCharger{
- &utils.DerivedCharger{RunID: "extra1", RunFilters: "^filteredHeader1/filterValue1/",
- RequestTypeField: "^prepaid", DirectionField: utils.META_DEFAULT,
- TenantField: utils.META_DEFAULT, CategoryField: utils.META_DEFAULT,
- AccountField: "rif", SubjectField: "rif", DestinationField: utils.META_DEFAULT,
- SetupTimeField: utils.META_DEFAULT, PDDField: utils.META_DEFAULT,
- AnswerTimeField: utils.META_DEFAULT, UsageField: utils.META_DEFAULT,
- SupplierField: utils.META_DEFAULT, DisconnectCauseField: utils.META_DEFAULT,
- CostField: utils.META_DEFAULT, PreRatedField: utils.META_DEFAULT},
- &utils.DerivedCharger{RunID: "extra2", RequestTypeField: utils.META_DEFAULT,
- DirectionField: utils.META_DEFAULT, TenantField: utils.META_DEFAULT,
- CategoryField: utils.META_DEFAULT, AccountField: "ivo",
- SubjectField: "ivo", DestinationField: utils.META_DEFAULT,
- SetupTimeField: utils.META_DEFAULT, PDDField: utils.META_DEFAULT,
- AnswerTimeField: utils.META_DEFAULT, UsageField: utils.META_DEFAULT,
- SupplierField: utils.META_DEFAULT, DisconnectCauseField: utils.META_DEFAULT,
- CostField: utils.META_DEFAULT, PreRatedField: utils.META_DEFAULT},
- }}
- keyCharger1 := utils.DerivedChargersKey("*out", "cgrates.org", "call", "dan", "dan")
-
- if !csvr.derivedChargers[keyCharger1].Equal(expCharger1) {
- t.Errorf("Expecting: %+v, received: %+v",
- expCharger1.Chargers[0], csvr.derivedChargers[keyCharger1].Chargers[0])
- }
-}
-
func TestLoadResourceProfiles(t *testing.T) {
eResProfiles := map[utils.TenantID]*utils.TPResource{
utils.TenantID{Tenant: "cgrates.org", ID: "ResGroup21"}: &utils.TPResource{
diff --git a/engine/loader_it_test.go b/engine/loader_it_test.go
index fc061a681..d5927c142 100644
--- a/engine/loader_it_test.go
+++ b/engine/loader_it_test.go
@@ -107,7 +107,6 @@ func TestLoaderITRemoveLoad(t *testing.T) {
path.Join(*dataDir, "tariffplans", *tpCsvScenario, utils.ACTION_PLANS_CSV),
path.Join(*dataDir, "tariffplans", *tpCsvScenario, utils.ACTION_TRIGGERS_CSV),
path.Join(*dataDir, "tariffplans", *tpCsvScenario, utils.ACCOUNT_ACTIONS_CSV),
- path.Join(*dataDir, "tariffplans", *tpCsvScenario, utils.DERIVED_CHARGERS_CSV),
path.Join(*dataDir, "tariffplans", *tpCsvScenario, utils.ResourcesCsv),
path.Join(*dataDir, "tariffplans", *tpCsvScenario, utils.StatsCsv),
path.Join(*dataDir, "tariffplans", *tpCsvScenario, utils.ThresholdsCsv),
@@ -148,9 +147,6 @@ func TestLoaderITRemoveLoad(t *testing.T) {
if err = loader.LoadAccountActions(); err != nil {
t.Error("Failed loading account actions: ", err.Error())
}
- if err = loader.LoadDerivedChargers(); err != nil {
- t.Error("Failed loading derived chargers: ", err.Error())
- }
if err = loader.LoadFilters(); err != nil {
t.Error("Failed loading filters: ", err.Error())
}
@@ -203,7 +199,6 @@ func TestLoaderITLoadFromCSV(t *testing.T) {
path.Join(*dataDir, "tariffplans", *tpCsvScenario, utils.ACTION_PLANS_CSV),
path.Join(*dataDir, "tariffplans", *tpCsvScenario, utils.ACTION_TRIGGERS_CSV),
path.Join(*dataDir, "tariffplans", *tpCsvScenario, utils.ACCOUNT_ACTIONS_CSV),
- path.Join(*dataDir, "tariffplans", *tpCsvScenario, utils.DERIVED_CHARGERS_CSV),
path.Join(*dataDir, "tariffplans", *tpCsvScenario, utils.ResourcesCsv),
path.Join(*dataDir, "tariffplans", *tpCsvScenario, utils.StatsCsv),
path.Join(*dataDir, "tariffplans", *tpCsvScenario, utils.ThresholdsCsv),
@@ -244,9 +239,6 @@ func TestLoaderITLoadFromCSV(t *testing.T) {
if err = loader.LoadAccountActions(); err != nil {
t.Error("Failed loading account actions: ", err.Error())
}
- if err = loader.LoadDerivedChargers(); err != nil {
- t.Error("Failed loading derived chargers: ", err.Error())
- }
if err = loader.LoadFilters(); err != nil {
t.Error("Failed loading filters: ", err.Error())
}
@@ -367,16 +359,6 @@ func TestLoaderITWriteToDatabase(t *testing.T) {
}
}
- for k, dcs := range loader.derivedChargers {
- rcv, err := loader.dm.GetDerivedChargers(k, true, utils.NonTransactional)
- if err != nil {
- t.Error("Failed GetDerivedChargers: ", err.Error())
- }
- if !reflect.DeepEqual(dcs.DestinationIDs, rcv.DestinationIDs) {
- t.Errorf("Expecting: %v, received: %v", dcs.DestinationIDs, rcv.DestinationIDs)
- }
- }
-
for tenantid, rl := range loader.resProfiles {
rcv, err := loader.dm.GetResourceProfile(tenantid.Tenant, tenantid.ID, false, false, utils.NonTransactional)
if err != nil {
@@ -530,9 +512,6 @@ func TestLoaderITLoadFromStorDb(t *testing.T) {
if err := loader.LoadAccountActions(); err != nil && err.Error() != utils.NotFoundCaps {
t.Error("Failed loading account actions: ", err.Error())
}
- if err := loader.LoadDerivedChargers(); err != nil && err.Error() != utils.NotFoundCaps {
- t.Error("Failed loading derived chargers: ", err.Error())
- }
}
func TestLoaderITLoadIndividualProfiles(t *testing.T) {
@@ -562,19 +541,6 @@ func TestLoaderITLoadIndividualProfiles(t *testing.T) {
}
}
}
- // Load derived chargers
- loadId = utils.CSV_LOAD + "_" + utils.TEST_SQL
- if dcs, err := storDb.GetTPDerivedChargers(&utils.TPDerivedChargers{TPid: utils.TEST_SQL, LoadId: loadId}); err != nil {
- t.Fatal("Could not retrieve derived chargers, error: ", err.Error())
- } else if len(dcs) == 0 {
- t.Fatal("Could not retrieve derived chargers")
- } else {
- for _, d := range dcs {
- if err := loader.LoadDerivedChargersFiltered(d, true); err != nil {
- t.Fatalf("Could not load derived charger with id: %s, error: %s", d.GetDerivedChargesId(), err.Error())
- }
- }
- }
// Load account actions
if aas, err := storDb.GetTPAccountActions(&utils.TPAccountActions{TPid: utils.TEST_SQL, LoadId: loadId}); err != nil {
diff --git a/engine/model_helpers.go b/engine/model_helpers.go
index cb630718c..3d2344623 100644
--- a/engine/model_helpers.go
+++ b/engine/model_helpers.go
@@ -1121,121 +1121,6 @@ func APItoModelAccountActions(aas []*utils.TPAccountActions) (result TpAccountAc
return result
}
-type TpDerivedChargers []TpDerivedCharger
-
-func (tps TpDerivedChargers) AsMapDerivedChargers() (map[string]*utils.TPDerivedChargers, error) {
- result := make(map[string]*utils.TPDerivedChargers)
- for _, tp := range tps {
- dcs := &utils.TPDerivedChargers{
- TPid: tp.Tpid,
- LoadId: tp.Loadid,
- Direction: tp.Direction,
- Tenant: tp.Tenant,
- Category: tp.Category,
- Account: tp.Account,
- Subject: tp.Subject,
- DestinationIds: tp.DestinationIds,
- }
- tag := dcs.GetDerivedChargesId()
- if _, hasIt := result[tag]; !hasIt {
- result[tag] = dcs
- }
- dc := &utils.TPDerivedCharger{
- RunId: ValueOrDefault(tp.Runid, utils.META_DEFAULT),
- RunFilters: tp.RunFilters,
- ReqTypeField: ValueOrDefault(tp.ReqTypeField, utils.META_DEFAULT),
- DirectionField: ValueOrDefault(tp.DirectionField, utils.META_DEFAULT),
- TenantField: ValueOrDefault(tp.TenantField, utils.META_DEFAULT),
- CategoryField: ValueOrDefault(tp.CategoryField, utils.META_DEFAULT),
- AccountField: ValueOrDefault(tp.AccountField, utils.META_DEFAULT),
- SubjectField: ValueOrDefault(tp.SubjectField, utils.META_DEFAULT),
- DestinationField: ValueOrDefault(tp.DestinationField, utils.META_DEFAULT),
- SetupTimeField: ValueOrDefault(tp.SetupTimeField, utils.META_DEFAULT),
- PddField: ValueOrDefault(tp.PddField, utils.META_DEFAULT),
- AnswerTimeField: ValueOrDefault(tp.AnswerTimeField, utils.META_DEFAULT),
- UsageField: ValueOrDefault(tp.UsageField, utils.META_DEFAULT),
- SupplierField: ValueOrDefault(tp.SupplierField, utils.META_DEFAULT),
- DisconnectCauseField: ValueOrDefault(tp.DisconnectCauseField, utils.META_DEFAULT),
- CostField: ValueOrDefault(tp.CostField, utils.META_DEFAULT),
- RatedField: ValueOrDefault(tp.RatedField, utils.META_DEFAULT),
- }
- result[tag].DerivedChargers = append(result[tag].DerivedChargers, dc)
- }
- return result, nil
-}
-
-func (tps TpDerivedChargers) AsTPDerivedChargers() (result []*utils.TPDerivedChargers, err error) {
- if atps, err := tps.AsMapDerivedChargers(); err != nil {
- return nil, err
- } else {
- for _, tp := range atps {
- result = append(result, tp)
- }
- return result, nil
- }
-}
-
-func MapTPDerivedChargers(s []*utils.TPDerivedChargers) (map[string]*utils.TPDerivedChargers, error) {
- result := make(map[string]*utils.TPDerivedChargers)
- for _, e := range s {
- if _, found := result[e.GetDerivedChargesId()]; !found {
- result[e.GetDerivedChargesId()] = e
- } else {
- return nil, fmt.Errorf("Non unique ID %+v", e.GetDerivedChargesId())
- }
- }
- return result, nil
-}
-
-func APItoModelDerivedCharger(dcs *utils.TPDerivedChargers) (result TpDerivedChargers) {
- for _, dc := range dcs.DerivedChargers {
- result = append(result, TpDerivedCharger{
- Tpid: dcs.TPid,
- Loadid: dcs.LoadId,
- Direction: dcs.Direction,
- Tenant: dcs.Tenant,
- Category: dcs.Category,
- Account: dcs.Account,
- Subject: dcs.Subject,
- Runid: dc.RunId,
- RunFilters: dc.RunFilters,
- ReqTypeField: dc.ReqTypeField,
- DirectionField: dc.DirectionField,
- TenantField: dc.TenantField,
- CategoryField: dc.CategoryField,
- AccountField: dc.AccountField,
- SubjectField: dc.SubjectField,
- PddField: dc.PddField,
- DestinationField: dc.DestinationField,
- SetupTimeField: dc.SetupTimeField,
- AnswerTimeField: dc.AnswerTimeField,
- UsageField: dc.UsageField,
- SupplierField: dc.SupplierField,
- DisconnectCauseField: dc.DisconnectCauseField,
- CostField: dc.CostField,
- RatedField: dc.RatedField,
- })
- }
- return
-}
-
-func APItoModelDerivedChargers(dcs []*utils.TPDerivedChargers) (result TpDerivedChargers) {
- for _, dc := range dcs {
- for _, sdc := range APItoModelDerivedCharger(dc) {
- result = append(result, sdc)
- }
- }
- return result
-}
-
-// ValueOrDefault is used to populate empty values with *any or *default if value missing
-func ValueOrDefault(val string, deflt string) string {
- if len(val) == 0 {
- val = deflt
- }
- return val
-}
-
type TpResources []*TpResource
func (tps TpResources) AsTPResources() (result []*utils.TPResource) {
diff --git a/engine/model_helpers_test.go b/engine/model_helpers_test.go
index 65535ec6f..7e435c034 100644
--- a/engine/model_helpers_test.go
+++ b/engine/model_helpers_test.go
@@ -418,78 +418,6 @@ func TestTPSharedGroupsAsExportSlice(t *testing.T) {
}
}
-//#Direction,Tenant,Category,Account,Subject,RunId,RunFilter,ReqTypeField,DirectionField,TenantField,CategoryField,AccountField,SubjectField,DestinationField,SetupTimeField,AnswerTimeField,UsageField
-//*out,cgrates.org,call,1001,1001,derived_run1,,^rated,*default,*default,*default,*default,^1002,*default,*default,*default,*default
-func TestTPDerivedChargersAsExportSlice(t *testing.T) {
- dcs := &utils.TPDerivedChargers{
- TPid: "TEST_TPID",
- LoadId: "TEST_LOADID",
- Direction: "*out",
- Tenant: "cgrates.org",
- Category: "call",
- Account: "1001",
- Subject: "1001",
- DerivedChargers: []*utils.TPDerivedCharger{
- &utils.TPDerivedCharger{
- RunId: "derived_run1",
- RunFilters: "",
- ReqTypeField: "^rated",
- DirectionField: utils.META_DEFAULT,
- TenantField: utils.META_DEFAULT,
- CategoryField: utils.META_DEFAULT,
- AccountField: utils.META_DEFAULT,
- SubjectField: "^1002",
- DestinationField: utils.META_DEFAULT,
- SetupTimeField: utils.META_DEFAULT,
- PddField: utils.META_DEFAULT,
- AnswerTimeField: utils.META_DEFAULT,
- UsageField: utils.META_DEFAULT,
- SupplierField: utils.META_DEFAULT,
- DisconnectCauseField: utils.META_DEFAULT,
- CostField: utils.META_DEFAULT,
- RatedField: utils.META_DEFAULT,
- },
- &utils.TPDerivedCharger{
- RunId: "derived_run2",
- RunFilters: "",
- ReqTypeField: "^rated",
- DirectionField: utils.META_DEFAULT,
- TenantField: utils.META_DEFAULT,
- CategoryField: utils.META_DEFAULT,
- AccountField: "^1002",
- SubjectField: utils.META_DEFAULT,
- DestinationField: utils.META_DEFAULT,
- SetupTimeField: utils.META_DEFAULT,
- PddField: utils.META_DEFAULT,
- AnswerTimeField: utils.META_DEFAULT,
- UsageField: utils.META_DEFAULT,
- SupplierField: utils.META_DEFAULT,
- DisconnectCauseField: utils.META_DEFAULT,
- RatedField: utils.META_DEFAULT,
- CostField: utils.META_DEFAULT,
- },
- },
- }
- expectedSlc := [][]string{
- []string{"*out", "cgrates.org", "call", "1001", "1001", "",
- "derived_run1", "", "^rated", utils.META_DEFAULT, utils.META_DEFAULT, utils.META_DEFAULT, utils.META_DEFAULT, "^1002", utils.META_DEFAULT, utils.META_DEFAULT, utils.META_DEFAULT, utils.META_DEFAULT, utils.META_DEFAULT, utils.META_DEFAULT, utils.META_DEFAULT, utils.META_DEFAULT, utils.META_DEFAULT},
- []string{"*out", "cgrates.org", "call", "1001", "1001", "",
- "derived_run2", "", "^rated", utils.META_DEFAULT, utils.META_DEFAULT, utils.META_DEFAULT, "^1002", utils.META_DEFAULT, utils.META_DEFAULT, utils.META_DEFAULT, utils.META_DEFAULT, utils.META_DEFAULT, utils.META_DEFAULT, utils.META_DEFAULT, utils.META_DEFAULT, utils.META_DEFAULT, utils.META_DEFAULT},
- }
- ms := APItoModelDerivedCharger(dcs)
- var slc [][]string
- for _, m := range ms {
- lc, err := csvDump(m)
- if err != nil {
- t.Error("Error dumping to csv: ", err)
- }
- slc = append(slc, lc)
- }
- if !reflect.DeepEqual(expectedSlc, slc) {
- t.Errorf("Expecting: %+v, received: %+v", expectedSlc, slc)
- }
-}
-
func TestTPActionTriggersAsExportSlice(t *testing.T) {
ap := &utils.TPActionPlan{
TPid: "TEST_TPID",
diff --git a/engine/models.go b/engine/models.go
index 8c9aefa55..ec1ce9639 100644
--- a/engine/models.go
+++ b/engine/models.go
@@ -212,80 +212,6 @@ type TpSharedGroup struct {
CreatedAt time.Time
}
-type TpDerivedCharger struct {
- Id int64
- Tpid string
- Loadid string
- Direction string `index:"0" re:"\*out"`
- Tenant string `index:"1" re:"[0-9A-Za-z_\.]+\s*"`
- Category string `index:"2" re:"\w+\s*"`
- Account string `index:"3" re:"\w+\s*"`
- Subject string `index:"4" re:"\*any\s*|\w+\s*"`
- DestinationIds string `index:"5" re:""`
- Runid string `index:"6" re:"\w+\s*"`
- RunFilters string `index:"7" re:"[~^]*[0-9A-Za-z_/:().+]+\s*"`
- ReqTypeField string `index:"8" re:"\*default\s*|[~^*]*[0-9A-Za-z_/:().+]+\s*"`
- DirectionField string `index:"9" re:"\*default\s*|[~^]*[0-9A-Za-z_/:().+]+\s*"`
- TenantField string `index:"10" re:"\*default\s*|[~^]*[0-9A-Za-z_/:().+]+\s*"`
- CategoryField string `index:"11" re:"\*default\s*|[~^]*[0-9A-Za-z_/:().+]+\s*"`
- AccountField string `index:"12" re:"\*default\s*|[~^]*[0-9A-Za-z_/:().+]+\s*"`
- SubjectField string `index:"13" re:"\*default\s*|[~^]*[0-9A-Za-z_/:().+]+\s*"`
- DestinationField string `index:"14" re:"\*default\s*|[~^]*[0-9A-Za-z_/:().+]+\s*"`
- SetupTimeField string `index:"15" re:"\*default\s*|[~^]*[0-9A-Za-z_/:().+]+\s*"`
- PddField string `index:"16" re:"\*default\s*|[~^]*[0-9A-Za-z_/:().+]+\s*"`
- AnswerTimeField string `index:"17" re:"\*default\s*|[~^]*[0-9A-Za-z_/:().+]+\s*"`
- UsageField string `index:"18" re:"\*default\s*|[~^]*[0-9A-Za-z_/:().+]+\s*"`
- SupplierField string `index:"19" re:"\*default\s*|[~^]*[0-9A-Za-z_/:().+]+\s*"`
- DisconnectCauseField string `index:"20" re:"\*default\s*|[~^]*[0-9A-Za-z_/:().+]+\s*"`
- RatedField string `index:"21" re:"\*default\s*|[~^]*[0-9A-Za-z_/:().+]+\s*"`
- CostField string `index:"22" re:"\*default\s*|[~^]*[0-9A-Za-z_/:().+]+\s*"`
- CreatedAt time.Time
-}
-
-func (tpdc *TpDerivedCharger) SetDerivedChargersId(id string) error {
- ids := strings.Split(id, utils.CONCATENATED_KEY_SEP)
- if len(ids) != 6 {
- return fmt.Errorf("Wrong TP Derived Charger Id: %s", id)
- }
- tpdc.Loadid = ids[0]
- tpdc.Direction = ids[1]
- tpdc.Tenant = ids[2]
- tpdc.Category = ids[3]
- tpdc.Account = ids[4]
- tpdc.Subject = ids[5]
- return nil
-}
-
-func (tpdc *TpDerivedCharger) GetDerivedChargersId() string {
- return utils.ConcatenatedKey(tpdc.Loadid, tpdc.Direction, tpdc.Tenant, tpdc.Category, tpdc.Account, tpdc.Subject)
-}
-
-type TpUser struct {
- Id int64
- Tpid string
- Tenant string `index:"0" re:""`
- UserName string `index:"1" re:""`
- Masked bool `index:"2" re:""`
- AttributeName string `index:"3" re:""`
- AttributeValue string `index:"4" re:""`
- Weight float64 `index:"5" re:""`
- CreatedAt time.Time
-}
-
-func (tu *TpUser) GetId() string {
- return utils.ConcatenatedKey(tu.Tenant, tu.UserName)
-}
-
-func (tu *TpUser) SetId(id string) error {
- vals := strings.Split(id, utils.CONCATENATED_KEY_SEP)
- if len(vals) != 2 {
- return utils.ErrInvalidKey
- }
- tu.Tenant = vals[0]
- tu.UserName = vals[1]
- return nil
-}
-
type TpResource struct {
PK uint `gorm:"primary_key"`
Tpid string
diff --git a/engine/onstor_it_test.go b/engine/onstor_it_test.go
index 1303e426d..9d0c36582 100644
--- a/engine/onstor_it_test.go
+++ b/engine/onstor_it_test.go
@@ -42,12 +42,10 @@ var (
var sTestsOnStorIT = []func(t *testing.T){
testOnStorITFlush,
testOnStorITIsDBEmpty,
- testOnStorITSetGetDerivedCharges,
testOnStorITCacheDestinations,
testOnStorITCacheReverseDestinations,
testOnStorITCacheActionPlan,
testOnStorITCacheAccountActionPlans,
- testOnStorITCacheDerivedChargers,
// ToDo: test cache flush for a prefix
// ToDo: testOnStorITLoadAccountingCache
@@ -137,46 +135,6 @@ func testOnStorITIsDBEmpty(t *testing.T) {
}
}
-func testOnStorITSetGetDerivedCharges(t *testing.T) {
- keyCharger1 := utils.ConcatenatedKey("*out", "cgrates.org", "call", "dan", "dan")
- if _, err := onStor.GetDerivedChargers(keyCharger1, true, utils.NonTransactional); err == nil {
- t.Error("DC exists")
- }
- charger1 := &utils.DerivedChargers{DestinationIDs: make(utils.StringMap),
- Chargers: []*utils.DerivedCharger{
- {RunID: "extra1", RequestTypeField: "^prepaid", DirectionField: "*default", TenantField: "*default", CategoryField: "*default",
- AccountField: "rif", SubjectField: "rif", DestinationField: "*default", SetupTimeField: "*default", AnswerTimeField: "*default", UsageField: "*default"},
- {RunID: "extra2", RequestTypeField: "*default", DirectionField: "*default", TenantField: "*default", CategoryField: "*default",
- AccountField: "ivo", SubjectField: "ivo", DestinationField: "*default", SetupTimeField: "*default", AnswerTimeField: "*default", UsageField: "*default"},
- }}
- if err := onStor.DataDB().SetDerivedChargers(keyCharger1, charger1, utils.NonTransactional); err != nil {
- t.Error("Error on setting DerivedChargers", err.Error())
- }
- // Retrieve from db
- if rcvCharger, err := onStor.GetDerivedChargers(keyCharger1, true, utils.NonTransactional); err != nil {
- t.Error("Error when retrieving DerivedCHarger", err.Error())
- } else if !reflect.DeepEqual(rcvCharger, charger1) {
- for i, eChrg := range charger1.Chargers {
- if !reflect.DeepEqual(eChrg, rcvCharger.Chargers[i]) {
- t.Logf("Expecting: %+v, received: %+v", eChrg, rcvCharger.Chargers[i])
- }
- }
- t.Errorf("Expecting %v, received: %v", charger1, rcvCharger)
- }
- // Retrieve from cache
- if rcvCharger, err := onStor.GetDerivedChargers(keyCharger1, false, utils.NonTransactional); err != nil {
- t.Error("Error when retrieving DerivedCHarger", err.Error())
- } else if !reflect.DeepEqual(rcvCharger, charger1) {
- t.Errorf("Expecting %v, received: %v", charger1, rcvCharger)
- }
- if err := onStor.RemoveDerivedChargers(keyCharger1, utils.NonTransactional); err != nil {
- t.Error(err)
- }
- if _, rcvErr := onStor.GetDerivedChargers(keyCharger1, false, utils.NonTransactional); rcvErr != utils.ErrNotFound {
- t.Error(rcvErr)
- }
-}
-
func testOnStorITCacheDestinations(t *testing.T) {
if err := onStor.CacheDataFromDB("INVALID", nil, false); err == nil || err.Error() != utils.UnsupportedCachePrefix {
t.Error(err)
@@ -345,36 +303,6 @@ func testOnStorITCacheActionTriggers(t *testing.T) {
}
}
-func testOnStorITCacheDerivedChargers(t *testing.T) {
- dcs := &utils.DerivedChargers{
- DestinationIDs: make(utils.StringMap),
- Chargers: []*utils.DerivedCharger{
- {RunID: "extra1", RunFilters: "^filteredHeader1/filterValue1/", RequestTypeField: "^prepaid", DirectionField: utils.META_DEFAULT,
- TenantField: utils.META_DEFAULT, CategoryField: utils.META_DEFAULT, AccountField: "rif", SubjectField: "rif", DestinationField: utils.META_DEFAULT,
- SetupTimeField: utils.META_DEFAULT, PDDField: utils.META_DEFAULT, AnswerTimeField: utils.META_DEFAULT, UsageField: utils.META_DEFAULT,
- SupplierField: utils.META_DEFAULT, DisconnectCauseField: utils.META_DEFAULT, CostField: utils.META_DEFAULT, PreRatedField: utils.META_DEFAULT},
- {RunID: "extra2", RequestTypeField: utils.META_DEFAULT, DirectionField: utils.META_DEFAULT, TenantField: utils.META_DEFAULT,
- CategoryField: utils.META_DEFAULT, AccountField: "ivo", SubjectField: "ivo", DestinationField: utils.META_DEFAULT,
- SetupTimeField: utils.META_DEFAULT, PDDField: utils.META_DEFAULT, AnswerTimeField: utils.META_DEFAULT, UsageField: utils.META_DEFAULT,
- SupplierField: utils.META_DEFAULT, DisconnectCauseField: utils.META_DEFAULT, CostField: utils.META_DEFAULT, PreRatedField: utils.META_DEFAULT},
- }}
- keyDCS := utils.ConcatenatedKey("*out", "itsyscom.com", "call", "dan", "dan")
- if err := onStor.DataDB().SetDerivedChargers(keyDCS, dcs, utils.NonTransactional); err != nil {
- t.Error(err)
- }
- if _, hasIt := Cache.Get(utils.CacheDerivedChargers, keyDCS); hasIt {
- t.Error("Already in cache")
- }
- if err := onStor.CacheDataFromDB(utils.DERIVEDCHARGERS_PREFIX, []string{keyDCS}, false); err != nil {
- t.Error(err)
- }
- if itm, hasIt := Cache.Get(utils.CacheDerivedChargers, keyDCS); !hasIt {
- t.Error("Did not cache")
- } else if rcv := itm.(*utils.DerivedChargers); !reflect.DeepEqual(dcs, rcv) {
- t.Errorf("Expecting: %+v, received: %+v", dcs, rcv)
- }
-}
-
func testOnStorITHasData(t *testing.T) {
rp := &RatingPlan{
Id: "HasData",
diff --git a/engine/responder.go b/engine/responder.go
index 7dfa10c2f..ce78fc3ad 100644
--- a/engine/responder.go
+++ b/engine/responder.go
@@ -33,7 +33,6 @@ import (
// Individual session run
type SessionRun struct {
RequestType string
- DerivedCharger *utils.DerivedCharger // Needed in reply
CallDescriptor *CallDescriptor
CallCosts []*CallCost
}
@@ -206,174 +205,6 @@ func (rs *Responder) GetMaxSessionTime(arg *CallDescriptor, reply *time.Duration
return
}
-// Returns MaxSessionTime for an event received in sessions, considering DerivedCharging for it
-func (rs *Responder) GetDerivedMaxSessionTime(ev *CDR, reply *time.Duration) (err error) {
- cacheKey := utils.GET_DERIV_MAX_SESS_TIME + ev.CGRID + ev.RunID
- if item, err := rs.getCache().Get(cacheKey); err == nil && item != nil {
- if item.Value != nil {
- *reply = *(item.Value.(*time.Duration))
- }
- return item.Err
- }
- if ev.Subject == "" {
- ev.Subject = ev.Account
- }
- if !rs.usageAllowed(ev.ToR, ev.Usage) {
- return utils.ErrMaxUsageExceeded
- }
- maxCallDuration := time.Duration(-1.0)
- attrsDC := &utils.AttrDerivedChargers{Tenant: ev.Tenant,
- Category: ev.Category, Direction: utils.OUT,
- Account: ev.Account, Subject: ev.Subject}
- dcs := &utils.DerivedChargers{}
- if err := rs.GetDerivedChargers(attrsDC, dcs); err != nil {
- rs.getCache().Cache(cacheKey, &utils.ResponseCacheItem{Err: err})
- return err
- }
- dcs, _ = dcs.AppendDefaultRun()
- for _, dc := range dcs.Chargers {
- runFilters, _ := utils.ParseRSRFields(dc.RunFilters, utils.INFIELD_SEP)
- matchingAllFilters := true
- for _, dcRunFilter := range runFilters {
- if _, err := ev.FieldAsStringWithRSRField(dcRunFilter); err != nil {
- matchingAllFilters = false
- break
- }
- }
- if !matchingAllFilters { // Do not process the derived charger further if not all filters were matched
- continue
- }
- forkedCDR, err := ev.ForkCdr(dc.RunID, utils.NewRSRFieldMustCompile(dc.RequestTypeField),
- utils.NewRSRFieldMustCompile(dc.TenantField), utils.NewRSRFieldMustCompile(dc.CategoryField),
- utils.NewRSRFieldMustCompile(dc.AccountField), utils.NewRSRFieldMustCompile(dc.SubjectField),
- utils.NewRSRFieldMustCompile(dc.DestinationField), utils.NewRSRFieldMustCompile(dc.SetupTimeField),
- utils.NewRSRFieldMustCompile(dc.AnswerTimeField), utils.NewRSRFieldMustCompile(dc.UsageField),
- utils.NewRSRFieldMustCompile(dc.PreRatedField), utils.NewRSRFieldMustCompile(dc.CostField),
- nil, false, rs.Timezone)
- if err != nil {
- return err
- }
- if !utils.IsSliceMember([]string{utils.META_PREPAID, utils.PREPAID,
- utils.META_PSEUDOPREPAID, utils.PSEUDOPREPAID},
- forkedCDR.RequestType) { // Only consider prepaid and pseudoprepaid for MaxSessionTime
- continue
- }
- if forkedCDR.Usage == 0 {
- forkedCDR.Usage = config.CgrConfig().MaxCallDuration
- }
- setupTime := forkedCDR.SetupTime
- if setupTime.IsZero() {
- setupTime = forkedCDR.AnswerTime
- }
- cd := &CallDescriptor{
- CgrID: forkedCDR.CGRID,
- RunID: forkedCDR.RunID,
- TOR: forkedCDR.ToR,
- Tenant: forkedCDR.Tenant,
- Category: forkedCDR.Category,
- Subject: forkedCDR.Subject,
- Account: forkedCDR.Account,
- Destination: forkedCDR.Destination,
- TimeStart: setupTime,
- TimeEnd: setupTime.Add(forkedCDR.Usage),
- }
- var remainingDuration time.Duration
- err = rs.GetMaxSessionTime(cd, &remainingDuration)
- if err != nil {
- *reply = time.Duration(0)
- rs.getCache().Cache(cacheKey, &utils.ResponseCacheItem{Err: err})
- return err
- }
- // Set maxCallDuration, smallest out of all forked sessions
- if maxCallDuration == time.Duration(-1) { // first time we set it /not initialized yet
- maxCallDuration = remainingDuration
- } else if maxCallDuration > remainingDuration {
- maxCallDuration = remainingDuration
- }
- }
- *reply = maxCallDuration
- rs.getCache().Cache(cacheKey, &utils.ResponseCacheItem{Value: reply})
- return nil
-}
-
-// Used by SM to get all the prepaid CallDescriptors attached to a session
-func (rs *Responder) GetSessionRuns(ev *CDR, sRuns *[]*SessionRun) (err error) {
- cacheKey := utils.GET_SESS_RUNS_CACHE_PREFIX + ev.CGRID
- if item, err := rs.getCache().Get(cacheKey); err == nil && item != nil {
- if item.Value != nil {
- *sRuns = *(item.Value.(*[]*SessionRun))
- }
- return item.Err
- }
- if ev.Subject == "" {
- ev.Subject = ev.Account
- }
- //utils.Logger.Info(fmt.Sprintf("DC before: %+v", ev))
- attrsDC := &utils.AttrDerivedChargers{Tenant: ev.Tenant,
- Category: ev.Category, Direction: utils.OUT,
- Account: ev.Account, Subject: ev.Subject,
- Destination: ev.Destination}
- //utils.Logger.Info(fmt.Sprintf("Derived chargers for: %+v", attrsDC))
- dcs := &utils.DerivedChargers{}
- if err := rs.GetDerivedChargers(attrsDC, dcs); err != nil {
- rs.getCache().Cache(cacheKey, &utils.ResponseCacheItem{
- Err: err,
- })
- return err
- }
- dcs, _ = dcs.AppendDefaultRun()
- //utils.Logger.Info(fmt.Sprintf("DCS: %v", len(dcs.Chargers)))
- sesRuns := make([]*SessionRun, 0)
- for _, dc := range dcs.Chargers {
- forkedCDR, err := ev.ForkCdr(dc.RunID, utils.NewRSRFieldMustCompile(dc.RequestTypeField),
- utils.NewRSRFieldMustCompile(dc.TenantField), utils.NewRSRFieldMustCompile(dc.CategoryField),
- utils.NewRSRFieldMustCompile(dc.AccountField), utils.NewRSRFieldMustCompile(dc.SubjectField),
- utils.NewRSRFieldMustCompile(dc.DestinationField), utils.NewRSRFieldMustCompile(dc.SetupTimeField),
- utils.NewRSRFieldMustCompile(dc.AnswerTimeField), utils.NewRSRFieldMustCompile(dc.UsageField),
- utils.NewRSRFieldMustCompile(dc.PreRatedField), utils.NewRSRFieldMustCompile(dc.CostField),
- nil, false, rs.Timezone)
- if err != nil {
- return err
- }
- startTime := forkedCDR.AnswerTime
- if startTime.IsZero() { // AnswerTime not parsable, try SetupTime
- startTime = forkedCDR.SetupTime
- }
- cd := &CallDescriptor{
- CgrID: forkedCDR.CGRID,
- RunID: forkedCDR.RunID,
- TOR: forkedCDR.ToR,
- Tenant: forkedCDR.Tenant,
- Category: forkedCDR.Category,
- Subject: forkedCDR.Subject,
- Account: forkedCDR.Account,
- Destination: forkedCDR.Destination,
- TimeStart: startTime,
- TimeEnd: startTime.Add(forkedCDR.Usage),
- ExtraFields: ev.ExtraFields}
- if flagsStr, hasFlags := ev.ExtraFields[utils.CGRFlags]; hasFlags { // Force duration from extra fields
- flags := utils.StringMapFromSlice(strings.Split(flagsStr, utils.INFIELD_SEP))
- if _, hasFD := flags[utils.FlagForceDuration]; hasFD {
- cd.ForceDuration = true
- }
- }
- sesRuns = append(sesRuns, &SessionRun{RequestType: forkedCDR.RequestType, DerivedCharger: dc, CallDescriptor: cd})
- }
- //utils.Logger.Info(fmt.Sprintf("RUNS: %v", len(sesRuns)))
- *sRuns = sesRuns
- rs.getCache().Cache(cacheKey, &utils.ResponseCacheItem{Value: sRuns})
- return nil
-}
-
-func (rs *Responder) GetDerivedChargers(attrs *utils.AttrDerivedChargers, dcs *utils.DerivedChargers) error {
- if dcsH, err := HandleGetDerivedChargers(dm, attrs); err != nil {
- return err
- } else if dcsH != nil {
- *dcs = *dcsH
- }
- return nil
-}
-
func (rs *Responder) Status(arg string, reply *map[string]interface{}) (err error) {
if arg != "" { // Introduce delay in answer, used in some automated tests
if delay, err := utils.ParseDurationWithNanosecs(arg); err == nil {
diff --git a/engine/responder_test.go b/engine/responder_test.go
index 60b8d6392..4c99636c4 100644
--- a/engine/responder_test.go
+++ b/engine/responder_test.go
@@ -36,201 +36,6 @@ func init() {
rsponder = &Responder{MaxComputedUsage: cfg.RalsCfg().RALsMaxComputedUsage}
}
-// Test internal abilites of GetDerivedChargers
-func TestResponderGetDerivedChargers(t *testing.T) {
- cfgedDC := &utils.DerivedChargers{DestinationIDs: utils.StringMap{}, Chargers: []*utils.DerivedCharger{{RunID: "responder1",
- RequestTypeField: utils.META_DEFAULT, DirectionField: "test", TenantField: "test",
- CategoryField: "test", AccountField: "test", SubjectField: "test", DestinationField: "test", SetupTimeField: "test", AnswerTimeField: "test", UsageField: "test"}}}
- attrs := &utils.AttrDerivedChargers{Tenant: "cgrates.org", Category: "call", Direction: "*out", Account: "responder_test", Subject: "responder_test"}
- if err := dm.DataDB().SetDerivedChargers(utils.DerivedChargersKey(utils.OUT, utils.ANY, utils.ANY, utils.ANY, utils.ANY), cfgedDC, utils.NonTransactional); err != nil {
- t.Error(err)
- }
- dcs := &utils.DerivedChargers{}
- if err := rsponder.GetDerivedChargers(attrs, dcs); err != nil {
- t.Error("Unexpected error", err.Error())
- } else if !reflect.DeepEqual(dcs, cfgedDC) {
- t.Errorf("Expecting: %v, received: %v ", cfgedDC, dcs)
- }
-}
-
-func TestResponderGetDerivedMaxSessionTime(t *testing.T) {
- testTenant := "vdf"
- cdr := &CDR{CGRID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()),
- OrderID: 123, ToR: utils.VOICE, OriginID: "dsafdsaf", OriginHost: "192.168.1.1", Source: "test",
- RequestType: utils.META_RATED, Tenant: testTenant, Category: "call", Account: "dan", Subject: "dan",
- Destination: "1002", SetupTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC),
- AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC),
- RunID: utils.DEFAULT_RUNID, Usage: time.Duration(10) * time.Second,
- ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"},
- Cost: 1.01}
- var maxSessionTime time.Duration
- if err := rsponder.GetDerivedMaxSessionTime(cdr, &maxSessionTime); err != nil {
- t.Error(err)
- } else if maxSessionTime != time.Duration(-1) {
- t.Error("Unexpected maxSessionTime received: ", maxSessionTime)
- }
- deTMobile := &Destination{Id: "DE_TMOBILE",
- Prefixes: []string{"+49151", "+49160", "+49170", "+49171", "+49175"}}
- if err := dm.DataDB().SetDestination(deTMobile, utils.NonTransactional); err != nil {
- t.Error(err)
- }
- if err := dm.DataDB().SetReverseDestination(deTMobile, utils.NonTransactional); err != nil {
- t.Error(err)
- }
- b10 := &Balance{Value: 10 * float64(time.Second),
- Weight: 10, DestinationIDs: utils.NewStringMap("DE_TMOBILE")}
- b20 := &Balance{Value: 20 * float64(time.Second),
- Weight: 10, DestinationIDs: utils.NewStringMap("DE_TMOBILE")}
- rifsAccount := &Account{ID: utils.ConcatenatedKey(testTenant, "rif"),
- BalanceMap: map[string]Balances{
- utils.VOICE: {b10}}}
- dansAccount := &Account{ID: utils.ConcatenatedKey(testTenant, "dan"),
- BalanceMap: map[string]Balances{utils.VOICE: {b20}}}
- if err := dm.DataDB().SetAccount(rifsAccount); err != nil {
- t.Error(err)
- }
- if err := dm.DataDB().SetAccount(dansAccount); err != nil {
- t.Error(err)
- }
- keyCharger1 := utils.ConcatenatedKey("*out", testTenant, "call", "dan", "dan")
- charger1 := &utils.DerivedChargers{Chargers: []*utils.DerivedCharger{
- {RunID: "extra1", RequestTypeField: "^" + utils.META_PREPAID, DirectionField: "*default", TenantField: "*default", CategoryField: "*default",
- AccountField: "^dan", SubjectField: "^dan", DestinationField: "^+49151708707", SetupTimeField: "*default", AnswerTimeField: "*default", UsageField: "*default"},
- {RunID: "extra2", RequestTypeField: "*default", DirectionField: "*default", TenantField: "*default", CategoryField: "*default",
- AccountField: "^ivo", SubjectField: "^ivo", DestinationField: "*default", SetupTimeField: "*default", AnswerTimeField: "*default", UsageField: "*default"},
- {RunID: "extra3", RequestTypeField: "^" + utils.META_PSEUDOPREPAID, DirectionField: "*default", TenantField: "*default", CategoryField: "*default",
- AccountField: "^rif", SubjectField: "^rif", DestinationField: "^+49151708707", SetupTimeField: "*default", AnswerTimeField: "*default", UsageField: "*default"},
- }}
- if err := dm.DataDB().SetDerivedChargers(keyCharger1, charger1, utils.NonTransactional); err != nil {
- t.Error("Error on setting DerivedChargers", err.Error())
- }
- if rifStoredAcnt, err := dm.DataDB().GetAccount(utils.ConcatenatedKey(testTenant, "rif")); err != nil {
- t.Error(err)
- //} else if rifStoredAcnt.BalanceMap[utils.VOICE].Equal(rifsAccount.BalanceMap[utils.VOICE]) {
- // t.Errorf("Expected: %+v, received: %+v", rifsAccount.BalanceMap[utils.VOICE][0], rifStoredAcnt.BalanceMap[utils.VOICE][0])
- } else if rifStoredAcnt.BalanceMap[utils.VOICE][0].GetValue() != rifsAccount.BalanceMap[utils.VOICE][0].GetValue() {
- t.Error("BalanceValue: ", rifStoredAcnt.BalanceMap[utils.VOICE][0].GetValue())
- }
- if danStoredAcnt, err := dm.DataDB().GetAccount(utils.ConcatenatedKey(testTenant, "dan")); err != nil {
- t.Error(err)
- } else if danStoredAcnt.BalanceMap[utils.VOICE][0].GetValue() != dansAccount.BalanceMap[utils.VOICE][0].GetValue() {
- t.Error("BalanceValue: ", danStoredAcnt.BalanceMap[utils.VOICE][0].GetValue())
- }
- dcs := &utils.DerivedChargers{}
- attrs := &utils.AttrDerivedChargers{Tenant: testTenant, Category: "call", Direction: "*out", Account: "dan", Subject: "dan"}
- if err := rsponder.GetDerivedChargers(attrs, dcs); err != nil {
- t.Error("Unexpected error", err.Error())
- } else if !reflect.DeepEqual(dcs.Chargers, charger1.Chargers) {
- t.Errorf("Expecting: %+v, received: %+v ", charger1, dcs)
- }
- if err := rsponder.GetDerivedMaxSessionTime(cdr, &maxSessionTime); err != nil {
- t.Error(err)
- } else if maxSessionTime != 1e+10 { // Smallest one, 10 seconds
- t.Error("Unexpected maxSessionTime received: ", maxSessionTime)
- }
-}
-
-func TestResponderGetSessionRuns(t *testing.T) {
- testTenant := "vdf"
- cdr := &CDR{CGRID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()),
- OrderID: 123, ToR: utils.VOICE, OriginID: "dsafdsaf",
- OriginHost: "192.168.1.1", Source: "test", RequestType: utils.META_PREPAID,
- Tenant: testTenant, Category: "call", Account: "dan2", Subject: "dan2",
- Destination: "1002", SetupTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC),
- AnswerTime: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC),
- RunID: utils.DEFAULT_RUNID, Usage: time.Duration(10) * time.Second,
- ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"}, Cost: 1.01}
- keyCharger1 := utils.ConcatenatedKey("*out", testTenant, "call", "dan2", "dan2")
- dfDC := &utils.DerivedCharger{
- RunID: utils.DEFAULT_RUNID, RequestTypeField: utils.META_DEFAULT,
- DirectionField: utils.META_DEFAULT, TenantField: utils.META_DEFAULT,
- CategoryField: utils.META_DEFAULT, AccountField: utils.META_DEFAULT,
- SubjectField: utils.META_DEFAULT, DestinationField: utils.META_DEFAULT,
- SetupTimeField: utils.META_DEFAULT, PDDField: utils.META_DEFAULT,
- AnswerTimeField: utils.META_DEFAULT, UsageField: utils.META_DEFAULT,
- SupplierField: utils.META_DEFAULT, DisconnectCauseField: utils.META_DEFAULT,
- CostField: utils.META_DEFAULT, PreRatedField: utils.META_DEFAULT}
- extra1DC := &utils.DerivedCharger{
- RunID: "extra1", RequestTypeField: "^" + utils.META_PREPAID,
- DirectionField: utils.META_DEFAULT, TenantField: utils.META_DEFAULT,
- CategoryField: "^0", AccountField: "^minitsboy", SubjectField: "^rif",
- DestinationField: "^0256", SetupTimeField: utils.META_DEFAULT,
- PDDField: utils.META_DEFAULT, AnswerTimeField: utils.META_DEFAULT,
- UsageField: utils.META_DEFAULT, SupplierField: utils.META_DEFAULT}
- extra2DC := &utils.DerivedCharger{
- RunID: "extra2", RequestTypeField: utils.META_DEFAULT,
- DirectionField: utils.META_DEFAULT, TenantField: utils.META_DEFAULT,
- CategoryField: utils.META_DEFAULT, AccountField: "^ivo", SubjectField: "^ivo",
- DestinationField: utils.META_DEFAULT, SetupTimeField: utils.META_DEFAULT,
- AnswerTimeField: utils.META_DEFAULT, UsageField: utils.META_DEFAULT,
- SupplierField: utils.META_DEFAULT}
- extra3DC := &utils.DerivedCharger{
- RunID: "extra3", RequestTypeField: "^" + utils.META_PSEUDOPREPAID,
- DirectionField: utils.META_DEFAULT, TenantField: utils.META_DEFAULT,
- CategoryField: "^0", AccountField: "^minu",
- SubjectField: "^rif", DestinationField: "^0256",
- SetupTimeField: utils.META_DEFAULT, PDDField: utils.META_DEFAULT,
- AnswerTimeField: utils.META_DEFAULT, UsageField: utils.META_DEFAULT,
- SupplierField: utils.META_DEFAULT, DisconnectCauseField: utils.META_DEFAULT}
- charger1 := &utils.DerivedChargers{Chargers: []*utils.DerivedCharger{extra1DC, extra2DC, extra3DC}}
- if err := dm.DataDB().SetDerivedChargers(keyCharger1, charger1,
- utils.NonTransactional); err != nil {
- t.Error("Error on setting DerivedChargers", err.Error())
- }
- sesRuns := make([]*SessionRun, 0)
- eSRuns := []*SessionRun{
- {RequestType: utils.META_PREPAID,
- DerivedCharger: extra1DC,
- CallDescriptor: &CallDescriptor{
- CgrID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()),
- RunID: "extra1", Category: "0",
- Tenant: "vdf", Subject: "rif",
- Account: "minitsboy",
- Destination: "0256",
- TimeStart: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC),
- TimeEnd: time.Date(2013, 11, 7, 8, 42, 36, 0, time.UTC),
- TOR: utils.VOICE,
- ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"}}},
- {RequestType: utils.META_PREPAID,
- DerivedCharger: extra2DC,
- CallDescriptor: &CallDescriptor{
- CgrID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()),
- RunID: "extra2", Category: "call",
- Tenant: "vdf", Subject: "ivo",
- Account: "ivo", Destination: "1002",
- TimeStart: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC),
- TimeEnd: time.Date(2013, 11, 7, 8, 42, 36, 0, time.UTC),
- TOR: utils.VOICE,
- ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"}}},
- {RequestType: utils.META_PSEUDOPREPAID,
- DerivedCharger: extra3DC,
- CallDescriptor: &CallDescriptor{
- CgrID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()),
- RunID: "extra3", Category: "0",
- Tenant: "vdf", Subject: "rif",
- Account: "minu", Destination: "0256",
- TimeStart: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC),
- TimeEnd: time.Date(2013, 11, 7, 8, 42, 36, 0, time.UTC),
- TOR: utils.VOICE,
- ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"}}},
- {RequestType: utils.META_PREPAID,
- DerivedCharger: dfDC,
- CallDescriptor: &CallDescriptor{
- CgrID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()),
- RunID: "*default", Category: "call",
- Tenant: "vdf", Subject: "dan2",
- Account: "dan2", Destination: "1002",
- TimeStart: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC),
- TimeEnd: time.Date(2013, 11, 7, 8, 42, 36, 0, time.UTC),
- TOR: utils.VOICE,
- ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"}}}}
- if err := rsponder.GetSessionRuns(cdr, &sesRuns); err != nil {
- t.Error(err)
- } else if !reflect.DeepEqual(eSRuns, sesRuns) {
- t.Errorf("Expecting: %s, received: %s", utils.ToJSON(eSRuns), utils.ToJSON(sesRuns))
- }
-}
-
func TestResponderGobSMCost(t *testing.T) {
cc := &CallCost{
Category: "generic",
diff --git a/engine/storage_csv.go b/engine/storage_csv.go
index 38cd2ba74..978626cc8 100644
--- a/engine/storage_csv.go
+++ b/engine/storage_csv.go
@@ -35,8 +35,7 @@ type CSVStorage struct {
destinationsFn, ratesFn, destinationratesFn, timingsFn,
destinationratetimingsFn, ratingprofilesFn,
sharedgroupsFn, actionsFn, actiontimingsFn, actiontriggersFn,
- accountactionsFn, derivedChargersFn,
- resProfilesFn, statsFn, thresholdsFn,
+ accountactionsFn, resProfilesFn, statsFn, thresholdsFn,
filterFn, suppProfilesFn, attributeProfilesFn,
chargerProfilesFn, dispatcherProfilesFn string
}
@@ -45,7 +44,7 @@ func NewFileCSVStorage(sep rune,
destinationsFn, timingsFn, ratesFn, destinationratesFn,
destinationratetimingsFn, ratingprofilesFn, sharedgroupsFn,
actionsFn, actiontimingsFn, actiontriggersFn, accountactionsFn,
- derivedChargersFn, resProfilesFn, statsFn, thresholdsFn,
+ resProfilesFn, statsFn, thresholdsFn,
filterFn, suppProfilesFn, attributeProfilesFn,
chargerProfilesFn, dispatcherProfilesFn string) *CSVStorage {
return &CSVStorage{
@@ -62,7 +61,6 @@ func NewFileCSVStorage(sep rune,
actiontimingsFn: actiontimingsFn,
actiontriggersFn: actiontriggersFn,
accountactionsFn: accountactionsFn,
- derivedChargersFn: derivedChargersFn,
resProfilesFn: resProfilesFn,
statsFn: statsFn,
thresholdsFn: thresholdsFn,
@@ -78,8 +76,7 @@ func NewStringCSVStorage(sep rune,
destinationsFn, timingsFn, ratesFn, destinationratesFn,
destinationratetimingsFn, ratingprofilesFn, sharedgroupsFn,
actionsFn, actiontimingsFn, actiontriggersFn,
- accountactionsFn, derivedChargersFn,
- resProfilesFn, statsFn,
+ accountactionsFn, resProfilesFn, statsFn,
thresholdsFn, filterFn, suppProfilesFn,
attributeProfilesFn, chargerProfilesFn,
dispatcherProfilesFn string) *CSVStorage {
@@ -87,8 +84,8 @@ func NewStringCSVStorage(sep rune,
ratesFn, destinationratesFn, destinationratetimingsFn,
ratingprofilesFn, sharedgroupsFn, actionsFn,
actiontimingsFn, actiontriggersFn, accountactionsFn,
- derivedChargersFn, resProfilesFn, statsFn,
- thresholdsFn, filterFn, suppProfilesFn, attributeProfilesFn,
+ resProfilesFn, statsFn, thresholdsFn, filterFn,
+ suppProfilesFn, attributeProfilesFn,
chargerProfilesFn, dispatcherProfilesFn)
c.readerFunc = openStringCSVStorage
return c
@@ -464,41 +461,6 @@ func (csvs *CSVStorage) GetTPAccountActions(filter *utils.TPAccountActions) ([]*
}
}
-func (csvs *CSVStorage) GetTPDerivedChargers(filter *utils.TPDerivedChargers) ([]*utils.TPDerivedChargers, error) {
- csvReader, fp, err := csvs.readerFunc(csvs.derivedChargersFn, csvs.sep, getColumnCount(TpDerivedCharger{}))
- if err != nil {
- //log.Print("Could not load derivedChargers file: ", err)
- // allow writing of the other values
- return nil, nil
- }
- if fp != nil {
- defer fp.Close()
- }
- var tpDerivedChargers TpDerivedChargers
- for record, err := csvReader.Read(); err != io.EOF; record, err = csvReader.Read() {
- if err != nil {
- log.Printf("bad line in %s, %s\n", csvs.derivedChargersFn, err.Error())
- return nil, err
- }
- if tp, err := csvLoad(TpDerivedCharger{}, record); err != nil {
- log.Print("error loading derived charger: ", err)
- return nil, err
- } else {
- dc := tp.(TpDerivedCharger)
- if filter != nil {
- dc.Tpid = filter.TPid
- dc.Loadid = filter.LoadId
- }
- tpDerivedChargers = append(tpDerivedChargers, dc)
- }
- }
- if dcs, err := tpDerivedChargers.AsTPDerivedChargers(); err != nil {
- return nil, err
- } else {
- return dcs, nil
- }
-}
-
func (csvs *CSVStorage) GetTPResources(tpid, tenant, id string) ([]*utils.TPResource, error) {
csvReader, fp, err := csvs.readerFunc(csvs.resProfilesFn, csvs.sep, getColumnCount(TpResource{}))
if err != nil {
diff --git a/engine/storage_interface.go b/engine/storage_interface.go
index 21b1e59e9..2eff8c2ac 100644
--- a/engine/storage_interface.go
+++ b/engine/storage_interface.go
@@ -61,9 +61,6 @@ type DataDB interface {
SetReverseDestination(*Destination, string) error
GetReverseDestination(string, bool, string) ([]string, error)
UpdateReverseDestination(*Destination, *Destination, string) error
- GetDerivedChargersDrv(string) (*utils.DerivedChargers, error)
- SetDerivedChargers(string, *utils.DerivedChargers, string) error
- RemoveDerivedChargersDrv(id, transactionID string) (err error)
GetActionsDrv(string) (Actions, error)
SetActionsDrv(string, Actions) error
RemoveActionsDrv(string) error
@@ -169,7 +166,6 @@ type LoadReader interface {
GetTPRatingPlans(string, string, *utils.Paginator) ([]*utils.TPRatingPlan, error)
GetTPRatingProfiles(*utils.TPRatingProfile) ([]*utils.TPRatingProfile, error)
GetTPSharedGroups(string, string) ([]*utils.TPSharedGroups, error)
- GetTPDerivedChargers(*utils.TPDerivedChargers) ([]*utils.TPDerivedChargers, error)
GetTPActions(string, string) ([]*utils.TPActions, error)
GetTPActionPlans(string, string) ([]*utils.TPActionPlan, error)
GetTPActionTriggers(string, string) ([]*utils.TPActionTriggers, error)
@@ -193,7 +189,6 @@ type LoadWriter interface {
SetTPRatingPlans([]*utils.TPRatingPlan) error
SetTPRatingProfiles([]*utils.TPRatingProfile) error
SetTPSharedGroups([]*utils.TPSharedGroups) error
- SetTPDerivedChargers([]*utils.TPDerivedChargers) error
SetTPActions([]*utils.TPActions) error
SetTPActionPlans([]*utils.TPActionPlan) error
SetTPActionTriggers([]*utils.TPActionTriggers) error
diff --git a/engine/storage_map_datadb.go b/engine/storage_map_datadb.go
index a4fde16e8..a8e4cabef 100644
--- a/engine/storage_map_datadb.go
+++ b/engine/storage_map_datadb.go
@@ -189,7 +189,7 @@ func (ms *MapStorage) HasDataDrv(category, subject, tenant string) (bool, error)
defer ms.mu.RUnlock()
switch category {
case utils.DESTINATION_PREFIX, utils.RATING_PLAN_PREFIX, utils.RATING_PROFILE_PREFIX,
- utils.ACTION_PREFIX, utils.ACTION_PLAN_PREFIX, utils.ACCOUNT_PREFIX, utils.DERIVEDCHARGERS_PREFIX:
+ utils.ACTION_PREFIX, utils.ACTION_PLAN_PREFIX, utils.ACCOUNT_PREFIX:
_, exists := ms.dict[category+subject]
return exists, nil
case utils.ResourcesPrefix, utils.ResourceProfilesPrefix, utils.StatQueuePrefix,
@@ -797,44 +797,6 @@ func (ms *MapStorage) PopTask() (t *Task, err error) {
return
}
-func (ms *MapStorage) GetDerivedChargersDrv(key string) (dcs *utils.DerivedChargers, err error) {
- ms.mu.RLock()
- defer ms.mu.RUnlock()
- if values, ok := ms.dict[utils.DERIVEDCHARGERS_PREFIX+key]; ok {
- err = ms.ms.Unmarshal(values, &dcs)
- } else {
- return nil, utils.ErrNotFound
- }
- return
-}
-
-func (ms *MapStorage) SetDerivedChargers(key string,
- dcs *utils.DerivedChargers, transactionID string) error {
- ms.mu.Lock()
- defer ms.mu.Unlock()
- cCommit := cacheCommit(transactionID)
- if dcs == nil || len(dcs.Chargers) == 0 {
- delete(ms.dict, utils.DERIVEDCHARGERS_PREFIX+key)
- Cache.Remove(utils.CacheDerivedChargers, key,
- cCommit, transactionID)
- return nil
- }
- result, err := ms.ms.Marshal(dcs)
- ms.dict[utils.DERIVEDCHARGERS_PREFIX+key] = result
- Cache.Remove(utils.CacheDerivedChargers, key,
- cCommit, transactionID)
- return err
-}
-
-func (ms *MapStorage) RemoveDerivedChargersDrv(id, transactionID string) (err error) {
- ms.mu.Lock()
- defer ms.mu.Unlock()
- cCommit := cacheCommit(transactionID)
- delete(ms.dict, id)
- Cache.Remove(utils.CacheDerivedChargers, id, cCommit, transactionID)
- return
-}
-
func (ms *MapStorage) SetSMCost(smCost *SMCost) error {
ms.mu.Lock()
defer ms.mu.Unlock()
diff --git a/engine/storage_map_stordb.go b/engine/storage_map_stordb.go
index 1d262a4a1..4ddd43345 100755
--- a/engine/storage_map_stordb.go
+++ b/engine/storage_map_stordb.go
@@ -52,9 +52,6 @@ func (ms *MapStorage) GetTPRatingProfiles(filter *utils.TPRatingProfile) (rProfi
func (ms *MapStorage) GetTPSharedGroups(tpid, id string) (sGroups []*utils.TPSharedGroups, err error) {
return nil, utils.ErrNotImplemented
}
-func (ms *MapStorage) GetTPDerivedChargers(*utils.TPDerivedChargers) (dCharges []*utils.TPDerivedChargers, err error) {
- return nil, utils.ErrNotImplemented
-}
func (ms *MapStorage) GetTPActions(tpid, id string) (actions []*utils.TPActions, err error) {
return nil, utils.ErrNotImplemented
}
@@ -117,10 +114,6 @@ func (ms *MapStorage) SetTPRatingProfiles(ratingProfiles []*utils.TPRatingProfil
func (ms *MapStorage) SetTPSharedGroups(groups []*utils.TPSharedGroups) (err error) {
return utils.ErrNotImplemented
}
-
-func (ms *MapStorage) SetTPDerivedChargers(dc []*utils.TPDerivedChargers) (err error) {
- return utils.ErrNotImplemented
-}
func (ms *MapStorage) SetTPActions(acts []*utils.TPActions) (err error) {
return utils.ErrNotImplemented
}
diff --git a/engine/storage_mongo_datadb.go b/engine/storage_mongo_datadb.go
index a10d9f53a..f8e11de01 100644
--- a/engine/storage_mongo_datadb.go
+++ b/engine/storage_mongo_datadb.go
@@ -55,7 +55,6 @@ const (
colRpf = "rating_profiles"
colAcc = "accounts"
colShg = "shared_groups"
- colDcs = "derived_chargers"
colPbs = "pubsub"
colLht = "load_history"
colVer = "versions"
@@ -238,7 +237,7 @@ func (ms *MongoStorage) GetContext() context.Context {
func (ms *MongoStorage) EnsureIndexes() (err error) {
if ms.storageType == utils.DataDB {
for _, col := range []string{colAct, colApl, colAAp, colAtr,
- colDcs, colRpl, colDst, colRds, colLht} {
+ colRpl, colDst, colRds, colLht} {
if err = ms.EnusureIndex(col, true, "key"); err != nil {
return
}
@@ -271,16 +270,6 @@ func (ms *MongoStorage) EnsureIndexes() (err error) {
return
}
- if err = ms.EnusureIndex(utils.TBLTPDerivedChargers, true, "tpid", "tenant",
- "category", "subject", "account", "loadid"); err != nil {
- return
- }
-
- if err = ms.EnusureIndex(utils.TBLTPDerivedChargers, true, "tpid", "direction",
- "tenant", "account", "loadid"); err != nil {
- return
- }
-
if err = ms.EnusureIndex(utils.CDRsTBL, true, CGRIDLow, RunIDLow,
OriginIDLow); err != nil {
return
@@ -323,7 +312,6 @@ func (ms *MongoStorage) getColNameForPrefix(prefix string) (string, bool) {
utils.RATING_PROFILE_PREFIX: colRpf,
utils.ACCOUNT_PREFIX: colAcc,
utils.SHARED_GROUP_PREFIX: colShg,
- utils.DERIVEDCHARGERS_PREFIX: colDcs,
utils.PUBSUB_SUBSCRIBERS_PREFIX: colPbs,
utils.LOADINST_KEY: colLht,
utils.VERSION_PREFIX: colVer,
@@ -568,8 +556,6 @@ func (ms *MongoStorage) GetKeysForPrefix(prefix string) (result []string, err er
result, err = ms.getField(sctx, colAtr, utils.ACTION_TRIGGER_PREFIX, subject, "key")
case utils.SHARED_GROUP_PREFIX:
result, err = ms.getField(sctx, colShg, utils.SHARED_GROUP_PREFIX, subject, "id")
- case utils.DERIVEDCHARGERS_PREFIX:
- result, err = ms.getField(sctx, colDcs, utils.DERIVEDCHARGERS_PREFIX, subject, "key")
case utils.ACCOUNT_PREFIX:
result, err = ms.getField(sctx, colAcc, utils.ACCOUNT_PREFIX, subject, "id")
case utils.ResourceProfilesPrefix:
@@ -1544,63 +1530,6 @@ func (ms *MongoStorage) PopTask() (t *Task, err error) {
return v.Task, nil
}
-func (ms *MongoStorage) GetDerivedChargersDrv(key string) (dcs *utils.DerivedChargers, err error) {
- var kv struct {
- Key string
- Value *utils.DerivedChargers
- }
- if err = ms.client.UseSession(ms.ctx, func(sctx mongo.SessionContext) (err error) {
- cur := ms.getCol(colDcs).FindOne(sctx, bson.M{"key": key})
- if err := cur.Decode(&kv); err != nil {
- if err == mongo.ErrNoDocuments {
- return utils.ErrNotFound
- }
- return err
- }
- return nil
- }); err != nil {
- return nil, err
- }
- return kv.Value, nil
-}
-
-func (ms *MongoStorage) SetDerivedChargers(key string,
- dcs *utils.DerivedChargers, transactionID string) (err error) {
- cCommit := cacheCommit(transactionID)
- if dcs == nil || len(dcs.Chargers) == 0 {
- if err = ms.client.UseSession(ms.ctx, func(sctx mongo.SessionContext) (err error) {
- _, err = ms.getCol(colDcs).DeleteOne(sctx, bson.M{"key": key})
- return err
- }); err != nil {
- return err
- }
- Cache.Remove(utils.CacheDerivedChargers, key, cCommit, transactionID)
- return nil
- }
- return ms.client.UseSession(ms.ctx, func(sctx mongo.SessionContext) (err error) {
- _, err = ms.getCol(colDcs).UpdateOne(sctx, bson.M{"key": key},
- bson.M{"$set": struct {
- Key string
- Value *utils.DerivedChargers
- }{Key: key, Value: dcs}},
- options.Update().SetUpsert(true),
- )
- return err
- })
-}
-
-func (ms *MongoStorage) RemoveDerivedChargersDrv(id, transactionID string) (err error) {
- cCommit := cacheCommit(transactionID)
- if err = ms.client.UseSession(ms.ctx, func(sctx mongo.SessionContext) (err error) {
- _, err = ms.getCol(colDcs).DeleteOne(sctx, bson.M{"key": id})
- return err
- }); err != nil {
- return err
- }
- Cache.Remove(utils.CacheDerivedChargers, id, cCommit, transactionID)
- return nil
-}
-
func (ms *MongoStorage) GetResourceProfileDrv(tenant, id string) (rp *ResourceProfile, err error) {
rp = new(ResourceProfile)
err = ms.client.UseSession(ms.ctx, func(sctx mongo.SessionContext) (err error) {
diff --git a/engine/storage_mongo_stordb.go b/engine/storage_mongo_stordb.go
index 158cf75eb..e169bf64d 100644
--- a/engine/storage_mongo_stordb.go
+++ b/engine/storage_mongo_stordb.go
@@ -431,47 +431,6 @@ func (ms *MongoStorage) GetTPStats(tpid, tenant, id string) ([]*utils.TPStats, e
})
return results, err
}
-func (ms *MongoStorage) GetTPDerivedChargers(tp *utils.TPDerivedChargers) ([]*utils.TPDerivedChargers, error) {
- filter := bson.M{"tpid": tp.TPid}
- if tp.Direction != "" {
- filter["direction"] = tp.Direction
- }
- if tp.Tenant != "" {
- filter["tenant"] = tp.Tenant
- }
- if tp.Category != "" {
- filter["category"] = tp.Category
- }
- if tp.Subject != "" {
- filter["subject"] = tp.Subject
- }
- if tp.Account != "" {
- filter["account"] = tp.Account
- }
- if tp.LoadId != "" {
- filter["loadid"] = tp.LoadId
- }
- var results []*utils.TPDerivedChargers
- err := ms.client.UseSession(ms.ctx, func(sctx mongo.SessionContext) (err error) {
- cur, err := ms.getCol(utils.TBLTPDerivedChargers).Find(sctx, filter)
- if err != nil {
- return err
- }
- for cur.Next(sctx) {
- var el utils.TPDerivedChargers
- err := cur.Decode(&el)
- if err != nil {
- return err
- }
- results = append(results, &el)
- }
- if len(results) == 0 {
- return utils.ErrNotFound
- }
- return cur.Close(sctx)
- })
- return results, err
-}
func (ms *MongoStorage) GetTPActions(tpid, id string) ([]*utils.TPActions, error) {
filter := bson.M{"tpid": tpid}
@@ -781,33 +740,6 @@ func (ms *MongoStorage) SetTPSharedGroups(tps []*utils.TPSharedGroups) error {
})
}
-func (ms *MongoStorage) SetTPDerivedChargers(tps []*utils.TPDerivedChargers) error {
- if len(tps) == 0 {
- return nil
- }
- m := make(map[string]bool)
- return ms.client.UseSession(ms.ctx, func(sctx mongo.SessionContext) (err error) {
- for _, tp := range tps {
- if found, _ := m[tp.Direction]; !found {
- m[tp.Direction] = true
- if _, err := ms.getCol(utils.TBLTPDerivedChargers).DeleteMany(sctx, bson.M{
- "tpid": tp.TPid,
- "direction": tp.Direction,
- "tenant": tp.Tenant,
- "category": tp.Category,
- "account": tp.Account,
- "subject": tp.Subject}); err != nil {
- return err
- }
- }
- if _, err := ms.getCol(utils.TBLTPDerivedChargers).InsertOne(sctx, tp); err != nil {
- return err
- }
- }
- return nil
- })
-}
-
func (ms *MongoStorage) SetTPActions(tps []*utils.TPActions) error {
if len(tps) == 0 {
return nil
diff --git a/engine/storage_redis.go b/engine/storage_redis.go
index f1e15c9c6..c977f07ca 100644
--- a/engine/storage_redis.go
+++ b/engine/storage_redis.go
@@ -335,7 +335,7 @@ func (rs *RedisStorage) GetKeysForPrefix(prefix string) ([]string, error) {
func (rs *RedisStorage) HasDataDrv(category, subject, tenant string) (bool, error) {
switch category {
case utils.DESTINATION_PREFIX, utils.RATING_PLAN_PREFIX, utils.RATING_PROFILE_PREFIX,
- utils.ACTION_PREFIX, utils.ACTION_PLAN_PREFIX, utils.ACCOUNT_PREFIX, utils.DERIVEDCHARGERS_PREFIX:
+ utils.ACTION_PREFIX, utils.ACTION_PLAN_PREFIX, utils.ACCOUNT_PREFIX:
i, err := rs.Cmd("EXISTS", category+subject).Int()
return i == 1, err
case utils.ResourcesPrefix, utils.ResourceProfilesPrefix, utils.StatQueuePrefix,
@@ -1042,51 +1042,6 @@ func (rs *RedisStorage) PopTask() (t *Task, err error) {
return
}
-func (rs *RedisStorage) GetDerivedChargersDrv(key string) (dcs *utils.DerivedChargers, err error) {
- key = utils.DERIVEDCHARGERS_PREFIX + key
- var values []byte
- if values, err = rs.Cmd("GET", key).Bytes(); err != nil {
- if err == redis.ErrRespNil { // did not find the destination
- err = utils.ErrNotFound
- }
- return
- }
- if err = rs.ms.Unmarshal(values, &dcs); err != nil {
- return
- }
- return
-}
-
-func (rs *RedisStorage) SetDerivedChargers(key string,
- dcs *utils.DerivedChargers, transactionID string) (err error) {
- cCommit := cacheCommit(transactionID)
- if dcs == nil || len(dcs.Chargers) == 0 {
- if err = rs.Cmd("DEL", utils.DERIVEDCHARGERS_PREFIX+key).Err; err != nil {
- return
- }
- Cache.Remove(utils.CacheDerivedChargers, key,
- cCommit, transactionID)
- return
- }
- var marshaled []byte
- if marshaled, err = rs.ms.Marshal(dcs); err != nil {
- return
- }
- if err = rs.Cmd("SET", utils.DERIVEDCHARGERS_PREFIX+key, marshaled).Err; err != nil {
- return
- }
- return
-}
-
-func (rs *RedisStorage) RemoveDerivedChargersDrv(id, transactionID string) (err error) {
- cCommit := cacheCommit(transactionID)
- if err = rs.Cmd("DEL", utils.DERIVEDCHARGERS_PREFIX+id).Err; err != nil {
- return err
- }
- Cache.Remove(utils.CacheDerivedChargers, id, cCommit, transactionID)
- return
-}
-
func (rs *RedisStorage) GetResourceProfileDrv(tenant, id string) (rsp *ResourceProfile, err error) {
key := utils.ResourceProfilesPrefix + utils.ConcatenatedKey(tenant, id)
var values []byte
diff --git a/engine/storage_sql.go b/engine/storage_sql.go
index a6d797aa2..d4f43df73 100644
--- a/engine/storage_sql.go
+++ b/engine/storage_sql.go
@@ -105,8 +105,7 @@ func (self *SQLStorage) IsDBEmpty() (resp bool, err error) {
utils.TBLTPTimings, utils.TBLTPDestinations, utils.TBLTPRates,
utils.TBLTPDestinationRates, utils.TBLTPRatingPlans, utils.TBLTPRateProfiles,
utils.TBLTPSharedGroups, utils.TBLTPActions, utils.TBLTPActionTriggers,
- utils.TBLTPAccountActions, utils.TBLTPDerivedChargers,
- utils.TBLTPResources, utils.TBLTPStats, utils.TBLTPThresholds,
+ utils.TBLTPAccountActions, utils.TBLTPResources, utils.TBLTPStats, utils.TBLTPThresholds,
utils.TBLTPFilters, utils.SessionCostsTBL, utils.CDRsTBL, utils.TBLTPActionPlans,
utils.TBLVersions, utils.TBLTPSuppliers, utils.TBLTPAttributes, utils.TBLTPChargers,
}
@@ -127,7 +126,7 @@ func (self *SQLStorage) GetTpIds(colName string) ([]string, error) {
qryStr := fmt.Sprintf(" (SELECT tpid FROM %s)", colName)
if colName == "" {
qryStr = fmt.Sprintf(
- "(SELECT tpid FROM %s) UNION (SELECT tpid FROM %s) UNION (SELECT tpid FROM %s) UNION (SELECT tpid FROM %s) UNION (SELECT tpid FROM %s) UNION (SELECT tpid FROM %s) UNION (SELECT tpid FROM %s) UNION (SELECT tpid FROM %s) UNION (SELECT tpid FROM %s) UNION (SELECT tpid FROM %s) UNION (SELECT tpid FROM %s) UNION (SELECT tpid FROM %s) UNION (SELECT tpid FROM %s) UNION (SELECT tpid FROM %s) UNION (SELECT tpid FROM %s) UNION (SELECT tpid FROM %s) UNION (SELECT tpid FROM %s) UNION (SELECT tpid FROM %s) UNION (SELECT tpid FROM %s) UNION (SELECT tpid FROM %s)",
+ "(SELECT tpid FROM %s) UNION (SELECT tpid FROM %s) UNION (SELECT tpid FROM %s) UNION (SELECT tpid FROM %s) UNION (SELECT tpid FROM %s) UNION (SELECT tpid FROM %s) UNION (SELECT tpid FROM %s) UNION (SELECT tpid FROM %s) UNION (SELECT tpid FROM %s) UNION (SELECT tpid FROM %s) UNION (SELECT tpid FROM %s) UNION (SELECT tpid FROM %s) UNION (SELECT tpid FROM %s) UNION (SELECT tpid FROM %s) UNION (SELECT tpid FROM %s) UNION (SELECT tpid FROM %s) UNION (SELECT tpid FROM %s) UNION (SELECT tpid FROM %s) UNION (SELECT tpid FROM %s)",
utils.TBLTPTimings,
utils.TBLTPDestinations,
utils.TBLTPRates,
@@ -138,7 +137,6 @@ func (self *SQLStorage) GetTpIds(colName string) ([]string, error) {
utils.TBLTPActions,
utils.TBLTPActionTriggers,
utils.TBLTPAccountActions,
- utils.TBLTPDerivedChargers,
utils.TBLTPResources,
utils.TBLTPStats,
utils.TBLTPThresholds,
@@ -237,8 +235,8 @@ func (self *SQLStorage) RemTpData(table, tpid string, args map[string]string) er
utils.TBLTPDestinationRates, utils.TBLTPRatingPlans, utils.TBLTPRateProfiles,
utils.TBLTPSharedGroups, utils.TBLTPActions, utils.TBLTPActionPlans,
utils.TBLTPActionTriggers, utils.TBLTPAccountActions,
- utils.TBLTPDerivedChargers, utils.TBLTPResources,
- utils.TBLTPStats, utils.TBLTPFilters, utils.TBLTPSuppliers, utils.TBLTPAttributes,
+ utils.TBLTPResources, utils.TBLTPStats, utils.TBLTPFilters,
+ utils.TBLTPSuppliers, utils.TBLTPAttributes,
utils.TBLTPChargers, utils.TBLTPDispatchers} {
if err := tx.Table(tblName).Where("tpid = ?", tpid).Delete(nil).Error; err != nil {
tx.Rollback()
@@ -428,39 +426,6 @@ func (self *SQLStorage) SetTPSharedGroups(sgs []*utils.TPSharedGroups) error {
return nil
}
-func (self *SQLStorage) SetTPDerivedChargers(sgs []*utils.TPDerivedChargers) error {
- if len(sgs) == 0 {
- return nil //Nothing to set
- }
- m := make(map[string]bool)
- tx := self.db.Begin()
- for _, dCharger := range sgs {
- dcKey := dCharger.GetDerivedChargersKey()
- if found, _ := m[dcKey]; !found {
- m[dcKey] = true
- if err := tx.Where(TpDerivedCharger{
- Tpid: dCharger.TPid,
- Direction: dCharger.Direction,
- Tenant: dCharger.Tenant,
- Category: dCharger.Category,
- Account: dCharger.Account,
- Subject: dCharger.Subject,
- }).Delete(TpDerivedCharger{}).Error; err != nil {
- tx.Rollback()
- return err
- }
- }
- for _, d := range APItoModelDerivedCharger(dCharger) {
- if err := tx.Save(&d).Error; err != nil {
- tx.Rollback()
- return err
- }
- }
- }
- tx.Commit()
- return nil
-}
-
func (self *SQLStorage) SetTPActions(acts []*utils.TPActions) error {
if len(acts) == 0 {
return nil //Nothing to set
@@ -1355,40 +1320,6 @@ func (self *SQLStorage) GetTPAccountActions(filter *utils.TPAccountActions) ([]*
}
}
-func (self *SQLStorage) GetTPDerivedChargers(filter *utils.TPDerivedChargers) ([]*utils.TPDerivedChargers, error) {
- var tpDerivedChargers TpDerivedChargers
- 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)
- }
- if len(filter.Account) != 0 {
- q = q.Where("account = ?", filter.Account)
- }
- if len(filter.Category) != 0 {
- q = q.Where("category = ?", filter.Category)
- }
- if len(filter.Subject) != 0 {
- q = q.Where("subject = ?", filter.Subject)
- }
- if len(filter.LoadId) != 0 {
- q = q.Where("loadid = ?", filter.LoadId)
- }
- if err := q.Find(&tpDerivedChargers).Error; err != nil {
- return nil, err
- }
- if dcs, err := tpDerivedChargers.AsTPDerivedChargers(); err != nil {
- return nil, err
- } else {
- if len(dcs) == 0 {
- return dcs, utils.ErrNotFound
- }
- return dcs, nil
- }
-}
-
func (self *SQLStorage) GetTPResources(tpid, tenant, id string) ([]*utils.TPResource, error) {
var rls TpResources
q := self.db.Where("tpid = ?", tpid)
diff --git a/engine/stordb_it_test.go b/engine/stordb_it_test.go
index 10141ecc0..f49b338a0 100644
--- a/engine/stordb_it_test.go
+++ b/engine/stordb_it_test.go
@@ -52,7 +52,6 @@ var sTestsStorDBit = []func(t *testing.T){
testStorDBitCRUDTpActionPlans,
testStorDBitCRUDTpActionTriggers,
testStorDBitCRUDTpAccountActions,
- testStorDBitCRUDTpDerivedChargers,
testStorDBitCRUDTpResources,
testStorDBitCRUDTpStats,
testStorDBitCRUDCDRs,
@@ -983,114 +982,6 @@ func testStorDBitCRUDTpAccountActions(t *testing.T) {
}
}
-func testStorDBitCRUDTpDerivedChargers(t *testing.T) {
- // READ
- var filter = utils.TPDerivedChargers{
- TPid: "testTPid",
- }
- if _, err := storDB.GetTPDerivedChargers(&filter); err != utils.ErrNotFound {
- t.Error(err)
- }
- // WRITE
- var snd = []*utils.TPDerivedChargers{
- {
- TPid: "testTPid",
- LoadId: "TEST_LOADID",
- Direction: "*out",
- Tenant: "cgrates.org",
- Category: "call",
- Account: "1000",
- Subject: "test",
- DestinationIds: "",
- DerivedChargers: []*utils.TPDerivedCharger{
- {
- RunId: "default",
- RunFilters: "test",
- ReqTypeField: "test",
- DirectionField: "test",
- TenantField: "test",
- CategoryField: "test",
- AccountField: "test",
- SubjectField: "test",
- DestinationField: "^+49151708707",
- SetupTimeField: "test",
- PddField: "~pdd:s/sip:(.+)/$1/",
- AnswerTimeField: "~answertime2:s/sip:(.+)/$1/",
- UsageField: "test",
- SupplierField: "~supplier2:s/(.+)/$1/",
- DisconnectCauseField: "test",
- CostField: "1",
- RatedField: "0",
- },
- },
- },
- {
- TPid: "testTPid",
- LoadId: "TEST_LOADID2",
- Direction: "*out",
- Tenant: "cgrates.org",
- Category: "call",
- Account: "1000",
- Subject: "test",
- DestinationIds: "",
- DerivedChargers: []*utils.TPDerivedCharger{
- {
- RunId: "default",
- RunFilters: "test",
- ReqTypeField: "test",
- DirectionField: "test",
- TenantField: "test",
- CategoryField: "test",
- AccountField: "test",
- SubjectField: "test",
- DestinationField: "^+49151708707",
- SetupTimeField: "test",
- PddField: "~pdd:s/sip:(.+)/$1/",
- AnswerTimeField: "~answertime2:s/sip:(.+)/$1/",
- UsageField: "test",
- SupplierField: "~supplier2:s/(.+)/$1/",
- DisconnectCauseField: "test",
- CostField: "1",
- RatedField: "0",
- },
- },
- },
- }
- if err := storDB.SetTPDerivedChargers(snd); err != nil {
- t.Error(err)
- }
- // READ
- if rcv, err := storDB.GetTPDerivedChargers(&filter); err != nil {
- t.Error(err)
- } else {
- if !(reflect.DeepEqual(snd[0], rcv[0]) || reflect.DeepEqual(snd[0], rcv[1])) {
- t.Errorf("\nExpecting:\n%+v\nReceived:\n%+v\n||\n%+v", utils.ToIJSON(snd[0]), utils.ToIJSON(rcv[0]), utils.ToIJSON(rcv[1]))
- }
- }
- // UPDATE
- snd[0].DerivedChargers[0].CostField = "test"
- snd[1].DerivedChargers[0].CostField = "test"
- if err := storDB.SetTPDerivedChargers(snd); err != nil {
- t.Error(err)
- }
- // READ
- if rcv, err := storDB.GetTPDerivedChargers(&filter); err != nil {
- t.Error(err)
- } else {
- if !(reflect.DeepEqual(snd[0], rcv[0]) || reflect.DeepEqual(snd[0], rcv[1])) {
- t.Errorf("\nExpecting:\n%+v\nReceived:\n%+v\n||\n%+v", utils.ToIJSON(snd[0]), utils.ToIJSON(rcv[0]), utils.ToIJSON(rcv[1]))
- }
- }
- // REMOVE
- if err := storDB.RemTpData("", "testTPid", nil); err != nil {
- t.Error(err)
- }
- // READ
- if _, err := storDB.GetTPDerivedChargers(&filter); err != utils.ErrNotFound {
- t.Error(err)
- }
-}
-
func testStorDBitCRUDTpResources(t *testing.T) {
// READ
if _, err := storDB.GetTPResources("testTPid", "", ""); err != utils.ErrNotFound {
diff --git a/engine/tpexporter.go b/engine/tpexporter.go
index bf92b706c..d9582dfb0 100644
--- a/engine/tpexporter.go
+++ b/engine/tpexporter.go
@@ -207,17 +207,6 @@ func (self *TPExporter) Run() error {
toExportMap[utils.ACCOUNT_ACTIONS_CSV] = append(toExportMap[utils.ACCOUNT_ACTIONS_CSV], sdModel)
}
- storDataDerivedCharges, err := self.storDb.GetTPDerivedChargers(&utils.TPDerivedChargers{TPid: self.tpID})
- if err != nil && err.Error() != utils.ErrNotFound.Error() {
- return err
- }
- for _, sd := range storDataDerivedCharges {
- sdModels := APItoModelDerivedCharger(sd)
- for _, sdModel := range sdModels {
- toExportMap[utils.DERIVED_CHARGERS_CSV] = append(toExportMap[utils.DERIVED_CHARGERS_CSV], sdModel)
- }
- }
-
storDataResources, err := self.storDb.GetTPResources(self.tpID, "", "")
if err != nil && err.Error() != utils.ErrNotFound.Error() {
return err
diff --git a/engine/tpimporter_csv.go b/engine/tpimporter_csv.go
index 59e28e5d7..eec7b76e9 100644
--- a/engine/tpimporter_csv.go
+++ b/engine/tpimporter_csv.go
@@ -52,7 +52,6 @@ var fileHandlers = map[string]func(*TPCSVImporter, string) error{
utils.ACTION_PLANS_CSV: (*TPCSVImporter).importActionTimings,
utils.ACTION_TRIGGERS_CSV: (*TPCSVImporter).importActionTriggers,
utils.ACCOUNT_ACTIONS_CSV: (*TPCSVImporter).importAccountActions,
- utils.DERIVED_CHARGERS_CSV: (*TPCSVImporter).importDerivedChargers,
utils.ResourcesCsv: (*TPCSVImporter).importResources,
utils.StatsCsv: (*TPCSVImporter).importStats,
utils.ThresholdsCsv: (*TPCSVImporter).importThresholds,
@@ -76,7 +75,6 @@ func (self *TPCSVImporter) Run() error {
path.Join(self.DirPath, utils.ACTION_PLANS_CSV),
path.Join(self.DirPath, utils.ACTION_TRIGGERS_CSV),
path.Join(self.DirPath, utils.ACCOUNT_ACTIONS_CSV),
- path.Join(self.DirPath, utils.DERIVED_CHARGERS_CSV),
path.Join(self.DirPath, utils.ResourcesCsv),
path.Join(self.DirPath, utils.StatsCsv),
path.Join(self.DirPath, utils.ThresholdsCsv),
@@ -276,25 +274,6 @@ func (self *TPCSVImporter) importAccountActions(fn string) error {
return self.StorDb.SetTPAccountActions(tps)
}
-func (self *TPCSVImporter) importDerivedChargers(fn string) error {
- if self.Verbose {
- log.Printf("Processing file: <%s> ", fn)
- }
- tps, err := self.csvr.GetTPDerivedChargers(nil)
- if err != nil {
- return err
- }
- loadId := utils.CSV_LOAD //Autogenerate rating profile id
- if self.ImportId != "" {
- loadId += "_" + self.ImportId
- }
- for i := 0; i < len(tps); i++ {
- tps[i].TPid = self.TPid
- tps[i].LoadId = loadId
- }
- return self.StorDb.SetTPDerivedChargers(tps)
-}
-
func (self *TPCSVImporter) importResources(fn string) error {
if self.Verbose {
log.Printf("Processing file: <%s> ", fn)
diff --git a/engine/tpreader.go b/engine/tpreader.go
index 74b03267b..baaee2614 100644
--- a/engine/tpreader.go
+++ b/engine/tpreader.go
@@ -45,7 +45,6 @@ type TpReader struct {
ratingPlans map[string]*RatingPlan
ratingProfiles map[string]*RatingProfile
sharedGroups map[string]*SharedGroup
- derivedChargers map[string]*utils.DerivedChargers
resProfiles map[utils.TenantID]*utils.TPResource
sqProfiles map[utils.TenantID]*utils.TPStats
thProfiles map[utils.TenantID]*utils.TPThreshold
@@ -125,7 +124,6 @@ func (tpr *TpReader) Init() {
tpr.ratingProfiles = make(map[string]*RatingProfile)
tpr.sharedGroups = make(map[string]*SharedGroup)
tpr.accountActions = make(map[string]*Account)
- tpr.derivedChargers = make(map[string]*utils.DerivedChargers)
tpr.resProfiles = make(map[utils.TenantID]*utils.TPResource)
tpr.sqProfiles = make(map[utils.TenantID]*utils.TPStats)
tpr.thProfiles = make(map[utils.TenantID]*utils.TPThreshold)
@@ -1100,48 +1098,6 @@ func (tpr *TpReader) LoadAccountActions() (err error) {
return nil
}
-func (tpr *TpReader) LoadDerivedChargersFiltered(filter *utils.TPDerivedChargers, save bool) (err error) {
- tps, err := tpr.lr.GetTPDerivedChargers(filter)
- if err != nil {
- return err
- }
- storDcs, err := MapTPDerivedChargers(tps)
- if err != nil {
- return err
- }
- for _, tpDcs := range storDcs {
- tag := tpDcs.GetDerivedChargersKey()
- if _, hasIt := tpr.derivedChargers[tag]; !hasIt {
- tpr.derivedChargers[tag] = &utils.DerivedChargers{
- DestinationIDs: make(utils.StringMap),
- Chargers: make([]*utils.DerivedCharger, 0),
- } // Load object map since we use this method also from LoadDerivedChargers
- }
- for _, tpDc := range tpDcs.DerivedChargers {
- dc, err := utils.NewDerivedCharger(tpDc.RunId, tpDc.RunFilters, tpDc.ReqTypeField, tpDc.DirectionField, tpDc.TenantField, tpDc.CategoryField,
- tpDc.AccountField, tpDc.SubjectField, tpDc.DestinationField, tpDc.SetupTimeField, tpDc.PddField, tpDc.AnswerTimeField, tpDc.UsageField, tpDc.SupplierField,
- tpDc.DisconnectCauseField, tpDc.RatedField, tpDc.CostField)
- if err != nil {
- return err
- }
- tpr.derivedChargers[tag].DestinationIDs.Copy(utils.ParseStringMap(tpDcs.DestinationIds))
- tpr.derivedChargers[tag].Chargers = append(tpr.derivedChargers[tag].Chargers, dc)
- }
- }
- if save {
- for dcsKey, dcs := range tpr.derivedChargers {
- if err := tpr.dm.DataDB().SetDerivedChargers(dcsKey, dcs, utils.NonTransactional); err != nil {
- return err
- }
- }
- }
- return nil
-}
-
-func (tpr *TpReader) LoadDerivedChargers() (err error) {
- return tpr.LoadDerivedChargersFiltered(&utils.TPDerivedChargers{TPid: tpr.tpid}, false)
-}
-
func (tpr *TpReader) LoadResourceProfilesFiltered(tag string) (err error) {
rls, err := tpr.lr.GetTPResources(tpr.tpid, "", tag)
if err != nil {
@@ -1361,9 +1317,6 @@ func (tpr *TpReader) LoadAll() (err error) {
if err = tpr.LoadAccountActions(); err != nil && err.Error() != utils.NotFoundCaps {
return
}
- if err = tpr.LoadDerivedChargers(); err != nil && err.Error() != utils.NotFoundCaps {
- return
- }
if err = tpr.LoadFilters(); err != nil && err.Error() != utils.NotFoundCaps {
return
}
@@ -1557,18 +1510,6 @@ func (tpr *TpReader) WriteToDatabase(flush, verbose, disable_reverse bool) (err
log.Println("\t", ub.ID)
}
}
- if verbose {
- log.Print("Derived Chargers:")
- }
- for key, dcs := range tpr.derivedChargers {
- err = tpr.dm.DataDB().SetDerivedChargers(key, dcs, utils.NonTransactional)
- if err != nil {
- return err
- }
- if verbose {
- log.Print("\t", key)
- }
- }
if verbose {
log.Print("Filters:")
}
@@ -1822,8 +1763,6 @@ func (tpr *TpReader) ShowStatistics() {
log.Print("Action triggers: ", len(tpr.actionsTriggers))
// account actions
log.Print("Account actions: ", len(tpr.accountActions))
- // derivedChargers
- log.Print("Derived Chargers: ", len(tpr.derivedChargers))
// resource profiles
log.Print("ResourceProfiles: ", len(tpr.resProfiles))
// stats
@@ -1901,14 +1840,6 @@ func (tpr *TpReader) GetLoadedIds(categ string) ([]string, error) {
i++
}
return keys, nil
- case utils.DERIVEDCHARGERS_PREFIX: // derived chargers
- keys := make([]string, len(tpr.derivedChargers))
- i := 0
- for k := range tpr.derivedChargers {
- keys[i] = k
- i++
- }
- return keys, nil
case utils.SHARED_GROUP_PREFIX:
keys := make([]string, len(tpr.sharedGroups))
i := 0
@@ -2099,18 +2030,6 @@ func (tpr *TpReader) RemoveFromDatabase(verbose, disable_reverse bool) (err erro
log.Println("\t", ub.ID)
}
}
- if verbose {
- log.Print("Derived Chargers:")
- }
- for key := range tpr.derivedChargers {
- err = tpr.dm.RemoveDerivedChargers(key, utils.NonTransactional)
- if err != nil {
- return err
- }
- if verbose {
- log.Print("\t", key)
- }
- }
if verbose {
log.Print("Filters:")
}
diff --git a/engine/version.go b/engine/version.go
index 7271bb86b..920c64ad7 100644
--- a/engine/version.go
+++ b/engine/version.go
@@ -149,7 +149,6 @@ func CurrentDataDBVersions() Versions {
utils.RQF: 1,
utils.Resource: 1,
utils.Subscribers: 1,
- utils.DerivedChargersV: 2,
utils.Destinations: 1,
utils.ReverseDestinations: 1,
utils.RatingPlan: 1,
@@ -171,7 +170,6 @@ func CurrentStorDBVersions() Versions {
utils.TpAccountActionsV: 1,
utils.TpActionPlans: 1,
utils.TpActions: 1,
- utils.TpDerivedCharges: 1,
utils.TpThresholds: 1,
utils.TpSuppliers: 1,
utils.TpStats: 1,
@@ -181,7 +179,6 @@ func CurrentStorDBVersions() Versions {
utils.TpRates: 1,
utils.TpTiming: 1,
utils.TpResource: 1,
- utils.TpDerivedChargersV: 1,
utils.TpDestinations: 1,
utils.TpRatingPlan: 1,
utils.TpRatingProfile: 1,
diff --git a/general_tests/acntacts_test.go b/general_tests/acntacts_test.go
index 3623e89f1..1ba139e4a 100644
--- a/general_tests/acntacts_test.go
+++ b/general_tests/acntacts_test.go
@@ -47,7 +47,6 @@ ENABLE_ACNT,*enable_account,,,,,,,,,,,,,false,false,10`
actionPlans := `TOPUP10_AT,TOPUP10_AC,ASAP,10`
actionTriggers := ``
accountActions := `cgrates.org,1,TOPUP10_AT,,,`
- derivedCharges := ``
resLimits := ``
stats := ``
thresholds := ``
@@ -57,7 +56,7 @@ ENABLE_ACNT,*enable_account,,,,,,,,,,,,,false,false,10`
chargerProfiles := ``
csvr := engine.NewTpReader(dbAcntActs.DataDB(), engine.NewStringCSVStorage(',', destinations, timings,
rates, destinationRates, ratingPlans, ratingProfiles, sharedGroups,
- actions, actionPlans, actionTriggers, accountActions, derivedCharges,
+ actions, actionPlans, actionTriggers, accountActions,
resLimits, stats, thresholds, filters, suppliers, attrProfiles, chargerProfiles, ``), "", "")
if err := csvr.LoadAll(); err != nil {
t.Fatal(err)
diff --git a/general_tests/auth_test.go b/general_tests/auth_test.go
index d445bdb91..16400eb97 100644
--- a/general_tests/auth_test.go
+++ b/general_tests/auth_test.go
@@ -55,7 +55,6 @@ cgrates.org,call,*any,2013-01-06T00:00:00Z,RP_ANY,`
actionPlans := `TOPUP10_AT,TOPUP10_AC,*asap,10`
actionTriggers := ``
accountActions := `cgrates.org,testauthpostpaid1,TOPUP10_AT,,,`
- derivedCharges := ``
resLimits := ``
stats := ``
thresholds := ``
@@ -65,7 +64,7 @@ cgrates.org,call,*any,2013-01-06T00:00:00Z,RP_ANY,`
chargerProfiles := ``
csvr := engine.NewTpReader(dbAuth.DataDB(), engine.NewStringCSVStorage(',', destinations, timings, rates, destinationRates,
ratingPlans, ratingProfiles, sharedGroups, actions, actionPlans, actionTriggers, accountActions,
- derivedCharges, resLimits, stats, thresholds, filters, suppliers, attrProfiles, chargerProfiles, ``), "", "")
+ resLimits, stats, thresholds, filters, suppliers, attrProfiles, chargerProfiles, ``), "", "")
if err := csvr.LoadAll(); err != nil {
t.Fatal(err)
}
@@ -96,48 +95,49 @@ cgrates.org,call,*any,2013-01-06T00:00:00Z,RP_ANY,`
}
func TestAuthPostpaidNoAcnt(t *testing.T) {
- cdr := &engine.CDR{ToR: utils.VOICE, RequestType: utils.META_PREPAID, Tenant: "cgrates.org",
+ cdr := &engine.UsageRecord{ToR: utils.VOICE, RequestType: utils.META_PREPAID, Tenant: "cgrates.org",
Category: "call", Account: "nonexistent", Subject: "testauthpostpaid1",
- Destination: "4986517174963", SetupTime: time.Date(2015, 8, 27, 11, 26, 0, 0, time.UTC)}
- var maxSessionTime time.Duration
- if err := rsponder.GetDerivedMaxSessionTime(cdr, &maxSessionTime); err != utils.ErrAccountNotFound {
+ Destination: "4986517174963", SetupTime: time.Date(2015, 8, 27, 11, 26, 0, 0, time.UTC).String()}
+ cd, err := cdr.AsCallDescriptor("", false)
+ if err != nil {
t.Error(err)
}
-}
-
-func TestAuthPostpaidNoDestination(t *testing.T) {
- // Test subject which does not have destination attached
- cdr := &engine.CDR{ToR: utils.VOICE, RequestType: utils.META_PREPAID, Tenant: "cgrates.org",
- Category: "call", Account: "testauthpostpaid1", Subject: "testauthpostpaid1",
- Destination: "441231234", SetupTime: time.Date(2015, 8, 27, 11, 26, 0, 0, time.UTC)}
var maxSessionTime time.Duration
- if err := rsponder.GetDerivedMaxSessionTime(cdr, &maxSessionTime); err == nil {
- t.Error("Expecting error for destination not allowed to subject")
+ if err := rsponder.GetMaxSessionTime(cd, &maxSessionTime); err != utils.ErrAccountNotFound {
+ t.Error(err)
}
}
func TestAuthPostpaidFallbackDest(t *testing.T) {
// Test subject which has fallback for destination
- cdr := &engine.CDR{ToR: utils.VOICE, RequestType: utils.META_POSTPAID, Tenant: "cgrates.org",
+ cdr := &engine.UsageRecord{ToR: utils.VOICE, RequestType: utils.META_POSTPAID, Tenant: "cgrates.org",
Category: "call", Account: "testauthpostpaid1", Subject: "testauthpostpaid2",
- Destination: "441231234", SetupTime: time.Date(2015, 8, 27, 11, 26, 0, 0, time.UTC)}
- var maxSessionTime time.Duration
- if err := rsponder.GetDerivedMaxSessionTime(cdr, &maxSessionTime); err != nil {
+ Destination: "441231234", SetupTime: time.Date(2015, 8, 27, 11, 26, 0, 0, time.UTC).String()}
+ cd, err := cdr.AsCallDescriptor("", false)
+ if err != nil {
t.Error(err)
- } else if maxSessionTime != time.Duration(-1) {
+ }
+ var maxSessionTime time.Duration
+ if err = rsponder.GetMaxSessionTime(cd, &maxSessionTime); err != nil {
+ t.Error(err)
+ } else if maxSessionTime != time.Duration(0) {
t.Error("Unexpected maxSessionTime received: ", maxSessionTime)
}
}
func TestAuthPostpaidWithDestination(t *testing.T) {
// Test subject which does not have destination attached
- cdr := &engine.CDR{ToR: utils.VOICE, RequestType: utils.META_POSTPAID, Tenant: "cgrates.org",
+ cdr := &engine.UsageRecord{ToR: utils.VOICE, RequestType: utils.META_POSTPAID, Tenant: "cgrates.org",
Category: "call", Account: "testauthpostpaid1", Subject: "testauthpostpaid1",
- Destination: "4986517174963", SetupTime: time.Date(2015, 8, 27, 11, 26, 0, 0, time.UTC)}
- var maxSessionTime time.Duration
- if err := rsponder.GetDerivedMaxSessionTime(cdr, &maxSessionTime); err != nil {
+ Destination: "4986517174963", SetupTime: time.Date(2015, 8, 27, 11, 26, 0, 0, time.UTC).String()}
+ cd, err := cdr.AsCallDescriptor("", false)
+ if err != nil {
t.Error(err)
- } else if maxSessionTime != time.Duration(-1) {
+ }
+ var maxSessionTime time.Duration
+ if err := rsponder.GetMaxSessionTime(cd, &maxSessionTime); err != nil {
+ t.Error(err)
+ } else if maxSessionTime != time.Duration(0) {
t.Error("Unexpected maxSessionTime received: ", maxSessionTime)
}
}
diff --git a/general_tests/costs1_test.go b/general_tests/costs1_test.go
index 3b52cb9cf..d36a407d4 100644
--- a/general_tests/costs1_test.go
+++ b/general_tests/costs1_test.go
@@ -51,7 +51,7 @@ RP_SMS1,DR_SMS_1,ALWAYS,10`
cgrates.org,data,*any,2012-01-01T00:00:00Z,RP_DATA1,
cgrates.org,sms,*any,2012-01-01T00:00:00Z,RP_SMS1,`
csvr := engine.NewTpReader(dataDB.DataDB(), engine.NewStringCSVStorage(',', dests, timings, rates, destinationRates, ratingPlans, ratingProfiles,
- "", "", "", "", "", "", "", "", "", "", "", "", "", ""), "", "")
+ "", "", "", "", "", "", "", "", "", "", "", "", ""), "", "")
if err := csvr.LoadTimings(); err != nil {
t.Fatal(err)
diff --git a/general_tests/datachrg1_test.go b/general_tests/datachrg1_test.go
index 17a29807c..8deea831f 100644
--- a/general_tests/datachrg1_test.go
+++ b/general_tests/datachrg1_test.go
@@ -42,7 +42,7 @@ DR_DATA_2,*any,RT_DATA_1c,*up,4,0,`
RP_DATA1,DR_DATA_2,TM2,10`
ratingProfiles := `cgrates.org,data,*any,2012-01-01T00:00:00Z,RP_DATA1,`
csvr := engine.NewTpReader(dataDB.DataDB(), engine.NewStringCSVStorage(',', "", timings, rates, destinationRates, ratingPlans, ratingProfiles,
- "", "", "", "", "", "", "", "", "", "", "", "", "", ""), "", "")
+ "", "", "", "", "", "", "", "", "", "", "", "", ""), "", "")
if err := csvr.LoadTimings(); err != nil {
t.Fatal(err)
}
diff --git a/general_tests/ddazmbl1_test.go b/general_tests/ddazmbl1_test.go
index b59b9d9ca..fb307e564 100644
--- a/general_tests/ddazmbl1_test.go
+++ b/general_tests/ddazmbl1_test.go
@@ -54,7 +54,6 @@ TOPUP10_AC1,*topup_reset,,,,*voice,,DST_UK_Mobile_BIG5,discounted_minutes,,*unli
TOPUP10_AT,TOPUP10_AC1,ASAP,10`
actionTriggers := ``
accountActions := `cgrates.org,12344,TOPUP10_AT,,,`
- derivedCharges := ``
resLimits := ``
stats := ``
thresholds := ``
@@ -66,8 +65,8 @@ TOPUP10_AT,TOPUP10_AC1,ASAP,10`
engine.NewStringCSVStorage(',', destinations, timings, rates,
destinationRates, ratingPlans, ratingProfiles,
sharedGroups, actions, actionPlans, actionTriggers, accountActions,
- derivedCharges, resLimits, stats,
- thresholds, filters, suppliers, attrProfiles, chargerProfiles, ``), "", "")
+ resLimits, stats, thresholds, filters, suppliers,
+ attrProfiles, chargerProfiles, ``), "", "")
if err := csvr.LoadDestinations(); err != nil {
t.Fatal(err)
}
@@ -101,9 +100,6 @@ TOPUP10_AT,TOPUP10_AC1,ASAP,10`
if err := csvr.LoadAccountActions(); err != nil {
t.Fatal(err)
}
- if err := csvr.LoadDerivedChargers(); err != nil {
- t.Fatal(err)
- }
csvr.WriteToDatabase(false, false, false)
if acnt, err := dataDB.DataDB().GetAccount("cgrates.org:12344"); err != nil {
t.Error(err)
diff --git a/general_tests/ddazmbl2_test.go b/general_tests/ddazmbl2_test.go
index 944481e78..859e4e1c7 100644
--- a/general_tests/ddazmbl2_test.go
+++ b/general_tests/ddazmbl2_test.go
@@ -54,7 +54,6 @@ TOPUP10_AC1,*topup_reset,,,,*voice,,DST_UK_Mobile_BIG5,discounted_minutes,,*unli
TOPUP10_AT,TOPUP10_AC1,ASAP,10`
actionTriggers := ``
accountActions := `cgrates.org,12345,TOPUP10_AT,,,`
- derivedCharges := ``
resLimits := ``
stats := ``
thresholds := ``
@@ -64,7 +63,7 @@ TOPUP10_AT,TOPUP10_AC1,ASAP,10`
chargerProfiles := ``
csvr := engine.NewTpReader(dataDB2.DataDB(), engine.NewStringCSVStorage(',', destinations, timings,
rates, destinationRates, ratingPlans, ratingProfiles, sharedGroups, actions, actionPlans,
- actionTriggers, accountActions, derivedCharges, resLimits,
+ actionTriggers, accountActions, resLimits,
stats, thresholds, filters, suppliers, attrProfiles, chargerProfiles, ``), "", "")
if err := csvr.LoadDestinations(); err != nil {
t.Fatal(err)
@@ -99,9 +98,6 @@ TOPUP10_AT,TOPUP10_AC1,ASAP,10`
if err := csvr.LoadAccountActions(); err != nil {
t.Fatal(err)
}
- if err := csvr.LoadDerivedChargers(); err != nil {
- t.Fatal(err)
- }
csvr.WriteToDatabase(false, false, false)
if acnt, err := dataDB2.DataDB().GetAccount("cgrates.org:12345"); err != nil {
t.Error(err)
diff --git a/general_tests/ddazmbl3_test.go b/general_tests/ddazmbl3_test.go
index 7e132a450..0845264ad 100644
--- a/general_tests/ddazmbl3_test.go
+++ b/general_tests/ddazmbl3_test.go
@@ -52,7 +52,6 @@ cgrates.org,call,discounted_minutes,2013-01-06T00:00:00Z,RP_UK_Mobile_BIG5_PKG,`
actionPlans := `TOPUP10_AT,TOPUP10_AC1,ASAP,10`
actionTriggers := ``
accountActions := `cgrates.org,12346,TOPUP10_AT,,,`
- derivedCharges := ``
resLimits := ``
stats := ``
thresholds := ``
@@ -62,7 +61,7 @@ cgrates.org,call,discounted_minutes,2013-01-06T00:00:00Z,RP_UK_Mobile_BIG5_PKG,`
chargerProfiles := ``
csvr := engine.NewTpReader(dataDB3.DataDB(), engine.NewStringCSVStorage(',', destinations, timings, rates,
destinationRates, ratingPlans, ratingProfiles, sharedGroups, actions, actionPlans, actionTriggers,
- accountActions, derivedCharges, resLimits, stats,
+ accountActions, resLimits, stats,
thresholds, filters, suppliers, attrProfiles, chargerProfiles, ``), "", "")
if err := csvr.LoadDestinations(); err != nil {
t.Fatal(err)
@@ -97,9 +96,7 @@ cgrates.org,call,discounted_minutes,2013-01-06T00:00:00Z,RP_UK_Mobile_BIG5_PKG,`
if err := csvr.LoadAccountActions(); err != nil {
t.Fatal(err)
}
- if err := csvr.LoadDerivedChargers(); err != nil {
- t.Fatal(err)
- }
+
csvr.WriteToDatabase(false, false, false)
if acnt, err := dataDB3.DataDB().GetAccount("cgrates.org:12346"); err != nil {
t.Error(err)
diff --git a/general_tests/smschrg1_test.go b/general_tests/smschrg1_test.go
index 3d65dc079..211e80f24 100644
--- a/general_tests/smschrg1_test.go
+++ b/general_tests/smschrg1_test.go
@@ -40,7 +40,7 @@ func TestSMSLoadCsvTpSmsChrg1(t *testing.T) {
ratingPlans := `RP_SMS1,DR_SMS_1,ALWAYS,10`
ratingProfiles := `cgrates.org,sms,*any,2012-01-01T00:00:00Z,RP_SMS1,`
csvr := engine.NewTpReader(dataDB.DataDB(), engine.NewStringCSVStorage(',', "", timings, rates, destinationRates, ratingPlans, ratingProfiles,
- "", "", "", "", "", "", "", "", "", "", "", "", "", ""), "", "")
+ "", "", "", "", "", "", "", "", "", "", "", "", ""), "", "")
if err := csvr.LoadTimings(); err != nil {
t.Fatal(err)
}
diff --git a/general_tests/suretax_it_test.go b/general_tests/suretax_it_test.go
index f98b91199..67f917a9f 100644
--- a/general_tests/suretax_it_test.go
+++ b/general_tests/suretax_it_test.go
@@ -98,7 +98,7 @@ func TestSTILoadTariffPlanFromFolder(t *testing.T) {
// Check loaded stats
func TestSTICacheStats(t *testing.T) {
var rcvStats *utils.CacheStats
- expectedStats := &utils.CacheStats{Destinations: 1, RatingPlans: 1, RatingProfiles: 1, DerivedChargers: 1}
+ expectedStats := &utils.CacheStats{Destinations: 1, RatingPlans: 1, RatingProfiles: 1}
var args utils.AttrCacheStats
if err := stiRpc.Call("ApierV2.GetCacheStats", args, &rcvStats); err != nil {
t.Error("Got error on ApierV2.GetCacheStats: ", err.Error())
diff --git a/general_tests/tut_smgeneric_it_test.go b/general_tests/tut_smgeneric_it_test.go
index 7c6d0479b..571b18faa 100644
--- a/general_tests/tut_smgeneric_it_test.go
+++ b/general_tests/tut_smgeneric_it_test.go
@@ -99,7 +99,7 @@ func TestTutSMGCacheStats(t *testing.T) {
}
var rcvStats *utils.CacheStats
expectedStats := &utils.CacheStats{Destinations: 5, ReverseDestinations: 7, RatingPlans: 4, RatingProfiles: 5,
- Actions: 9, ActionPlans: 4, AccountActionPlans: 5, SharedGroups: 1, DerivedChargers: 1, ResourceProfiles: 3,
+ Actions: 9, ActionPlans: 4, AccountActionPlans: 5, SharedGroups: 1, ResourceProfiles: 3,
Resources: 3, StatQueues: 1, StatQueueProfiles: 1, Thresholds: 7, ThresholdProfiles: 7, Filters: 16,
SupplierProfiles: 3, AttributeProfiles: 1}
var args utils.AttrCacheStats
diff --git a/migrator/derived_chargers.go b/migrator/derived_chargers.go
index d9a1ce386..76f3ad883 100644
--- a/migrator/derived_chargers.go
+++ b/migrator/derived_chargers.go
@@ -204,7 +204,7 @@ func (m *Migrator) migrateV1DerivedChargers() (err error) {
return
}
// All done, update version wtih current one
- vrs := engine.Versions{utils.DerivedChargersV: engine.CurrentDataDBVersions()[utils.DerivedChargersV]}
+ vrs := engine.Versions{utils.DerivedChargersV: 0}
if err = m.dmOut.DataManager().DataDB().SetVersions(vrs, false); err != nil {
return utils.NewCGRError(utils.Migrator,
utils.ServerErrorCaps,
@@ -214,6 +214,7 @@ func (m *Migrator) migrateV1DerivedChargers() (err error) {
return
}
+/*
func (m *Migrator) migrateCurrentDerivedChargers() (err error) {
var ids []string
ids, err = m.dmIN.DataManager().DataDB().GetKeysForPrefix(utils.DERIVEDCHARGERS_PREFIX)
@@ -237,34 +238,37 @@ func (m *Migrator) migrateCurrentDerivedChargers() (err error) {
}
return
}
+*/
func (m *Migrator) migrateDerivedChargers() (err error) {
- var vrs engine.Versions
- current := engine.CurrentDataDBVersions()
- vrs, err = m.dmIN.DataManager().DataDB().GetVersions("")
- if err != nil {
- return utils.NewCGRError(utils.Migrator,
- utils.ServerErrorCaps,
- err.Error(),
- fmt.Sprintf("error: <%s> when querying oldDataDB for versions", err.Error()))
- } else if len(vrs) == 0 {
- return utils.NewCGRError(utils.Migrator,
- utils.MandatoryIEMissingCaps,
- utils.UndefinedVersion,
- "version number is not defined for DerivedChargers model")
- }
+ return m.migrateV1DerivedChargers()
+ /*
+ var vrs engine.Versions
+ current := engine.CurrentDataDBVersions()
+ vrs, err = m.dmIN.DataManager().DataDB().GetVersions("")
+ if err != nil {
+ return utils.NewCGRError(utils.Migrator,
+ utils.ServerErrorCaps,
+ err.Error(),
+ fmt.Sprintf("error: <%s> when querying oldDataDB for versions", err.Error()))
+ } else if len(vrs) == 0 {
+ return utils.NewCGRError(utils.Migrator,
+ utils.MandatoryIEMissingCaps,
+ utils.UndefinedVersion,
+ "version number is not defined for DerivedChargers model")
+ }
- switch vrs[utils.DerivedChargersV] {
- case 1:
- return m.migrateV1DerivedChargers()
- case current[utils.DerivedChargersV]:
- if m.sameDataDB {
+ switch vrs[utils.DerivedChargersV] {
+ case 1:
+ case current[utils.DerivedChargersV]:
+ if m.sameDataDB {
+ return
+ }
+ if err := m.migrateCurrentDerivedChargers(); err != nil {
+ return err
+ }
return
}
- if err := m.migrateCurrentDerivedChargers(); err != nil {
- return err
- }
return
- }
- return
+ */
}
diff --git a/migrator/derived_chargers_it_test.go b/migrator/derived_chargers_it_test.go
index 4a7aa0ff7..67197eddf 100644
--- a/migrator/derived_chargers_it_test.go
+++ b/migrator/derived_chargers_it_test.go
@@ -222,7 +222,7 @@ func testDCITMigrateAndMove(t *testing.T) {
//check if version was updated
if vrs, err := dcMigrator.dmOut.DataManager().DataDB().GetVersions(""); err != nil {
t.Error(err)
- } else if vrs[utils.DerivedChargersV] != 2 {
+ } else if vrs[utils.DerivedChargersV] != 0 {
t.Errorf("Unexpected version returned: %d", vrs[utils.DerivedChargersV])
}
//check if derivch was migrate correctly
diff --git a/migrator/migrator.go b/migrator/migrator.go
index 08c832fdd..d9f3799e4 100755
--- a/migrator/migrator.go
+++ b/migrator/migrator.go
@@ -154,8 +154,6 @@ func (m *Migrator) Migrate(taskIDs []string) (err error, stats map[string]int) {
err = m.migrateTPactionplans()
case utils.MetaTpActions:
err = m.migrateTPactions()
- case utils.MetaTpDerivedChargers:
- err = m.migrateTPderivedchargers()
case utils.MetaTpThresholds:
err = m.migrateTPthresholds()
case utils.MetaTpSuppliers:
@@ -264,9 +262,6 @@ func (m *Migrator) Migrate(taskIDs []string) (err error, stats map[string]int) {
if err := m.migrateTPactions(); err != nil {
log.Print("ERROR: ", utils.MetaTpActions, " ", err)
}
- if err := m.migrateTPderivedchargers(); err != nil {
- log.Print("ERROR: ", utils.MetaTpDerivedChargers, " ", err)
- }
if err := m.migrateTPthresholds(); err != nil {
log.Print("ERROR: ", utils.MetaTpThresholds, " ", err)
}
@@ -291,9 +286,6 @@ func (m *Migrator) Migrate(taskIDs []string) (err error, stats map[string]int) {
if err := m.migrateTpTimings(); err != nil {
log.Print("ERROR: ", utils.MetaTpTimings, " ", err)
}
- if err := m.migrateTPderivedchargers(); err != nil {
- log.Print("ERROR: ", utils.MetaTpDerivedChargersV, " ", err)
- }
if err := m.migrateTPDestinations(); err != nil {
log.Print("ERROR: ", utils.MetaTpDestinations, " ", err)
}
diff --git a/migrator/sessions_costs.go b/migrator/session_costs.go
similarity index 94%
rename from migrator/sessions_costs.go
rename to migrator/session_costs.go
index be5962117..79ff91991 100644
--- a/migrator/sessions_costs.go
+++ b/migrator/session_costs.go
@@ -104,17 +104,18 @@ func (m *Migrator) migrateV2SessionSCosts() (err error) {
if err == utils.ErrNoMoreData {
break
}
- if v2Cost != nil {
- smCost := v2Cost.V2toV3Cost()
- if m.dryRun != true {
- if err = m.storDBOut.StorDB().SetSMCost(smCost); err != nil {
- return err
- }
- if err = m.storDBIn.remV2SMCost(v2Cost); err != nil {
- return err
- }
- m.stats[utils.SessionSCosts] += 1
+ if v2Cost == nil {
+ break
+ }
+ smCost := v2Cost.V2toV3Cost()
+ if m.dryRun != true {
+ if err = m.storDBOut.StorDB().SetSMCost(smCost); err != nil {
+ return err
}
+ if err = m.storDBIn.remV2SMCost(v2Cost); err != nil {
+ return err
+ }
+ m.stats[utils.SessionSCosts] += 1
}
}
if m.dryRun != true {
diff --git a/migrator/sessions_costs_it_test.go b/migrator/session_costs_it_test.go
similarity index 100%
rename from migrator/sessions_costs_it_test.go
rename to migrator/session_costs_it_test.go
diff --git a/migrator/tp_derived_chargers.go b/migrator/tp_derived_chargers.go
deleted file mode 100644
index cb2edea29..000000000
--- a/migrator/tp_derived_chargers.go
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-package migrator
-
-import (
- "fmt"
-
- "github.com/cgrates/cgrates/engine"
- "github.com/cgrates/cgrates/utils"
-)
-
-func (m *Migrator) migrateCurrentTPderivedchargers() (err error) {
- tpids, err := m.storDBIn.StorDB().GetTpIds(utils.TBLTPDerivedChargers)
- if err != nil {
- return err
- }
-
- for _, tpid := range tpids {
-
- derivedChargers, err := m.storDBIn.StorDB().GetTPDerivedChargers(&utils.TPDerivedChargers{TPid: tpid})
- if err != nil {
- return err
- }
- if derivedChargers != nil {
- if m.dryRun != true {
- if err := m.storDBOut.StorDB().SetTPDerivedChargers(derivedChargers); err != nil {
- return err
- }
- for _, der := range derivedChargers {
- if err := m.storDBIn.StorDB().RemTpData(utils.TBLTPDerivedChargers,
- der.TPid, map[string]string{"loadid": der.LoadId, "direction": der.Direction,
- "tenant": der.Tenant, "category": der.Category, "account": der.Account, "subject": der.Subject}); err != nil {
- return err
- }
- }
- m.stats[utils.TpDerivedCharges] += 1
- }
- }
- }
- return
-}
-
-func (m *Migrator) migrateTPderivedchargers() (err error) {
- var vrs engine.Versions
- current := engine.CurrentStorDBVersions()
- vrs, err = m.storDBOut.StorDB().GetVersions("")
- if err != nil {
- return utils.NewCGRError(utils.Migrator,
- utils.ServerErrorCaps,
- err.Error(),
- fmt.Sprintf("error: <%s> when querying oldDataDB for versions", err.Error()))
- } else if len(vrs) == 0 {
- return utils.NewCGRError(utils.Migrator,
- utils.MandatoryIEMissingCaps,
- utils.UndefinedVersion,
- "version number is not defined for ActionTriggers model")
- }
- switch vrs[utils.TpDerivedCharges] {
- case current[utils.TpDerivedCharges]:
- if m.sameStorDB {
- return
- }
- if err := m.migrateCurrentTPderivedchargers(); err != nil {
- return err
- }
- return
- }
- return
-}
diff --git a/migrator/tp_derived_chargers_it_test.go b/migrator/tp_derived_chargers_it_test.go
deleted file mode 100644
index 94d3954dc..000000000
--- a/migrator/tp_derived_chargers_it_test.go
+++ /dev/null
@@ -1,174 +0,0 @@
-// +build integration
-
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-package migrator
-
-import (
- "log"
- "path"
- "reflect"
- "testing"
-
- "github.com/cgrates/cgrates/config"
- "github.com/cgrates/cgrates/engine"
- "github.com/cgrates/cgrates/utils"
-)
-
-var (
- tpDrChgPathIn string
- tpDrChgPathOut string
- tpDrChgCfgIn *config.CGRConfig
- tpDrChgCfgOut *config.CGRConfig
- tpDrChgMigrator *Migrator
- tpDerivedChargers []*utils.TPDerivedChargers
- tpDerivedChargersID = "LoadID:*out:cgrates.org:call:1001:1001"
-)
-
-var sTestsTpDrChgIT = []func(t *testing.T){
- testTpDrChgITConnect,
- testTpDrChgITFlush,
- testTpDrChgITPopulate,
- testTpDrChgITMove,
- testTpDrChgITCheckData,
-}
-
-func TestTpDrChgMove(t *testing.T) {
- for _, stest := range sTestsTpDrChgIT {
- t.Run("TestTpDrChgMove", stest)
- }
-}
-
-func testTpDrChgITConnect(t *testing.T) {
- var err error
- tpDrChgPathIn = path.Join(*dataDir, "conf", "samples", "tutmongo")
- tpDrChgCfgIn, err = config.NewCGRConfigFromFolder(tpDrChgPathIn)
- if err != nil {
- t.Fatal(err)
- }
- tpDrChgPathOut = path.Join(*dataDir, "conf", "samples", "tutmysql")
- tpDrChgCfgOut, err = config.NewCGRConfigFromFolder(tpDrChgPathOut)
- if err != nil {
- t.Fatal(err)
- }
- storDBIn, err := NewMigratorStorDB(tpDrChgCfgIn.StorDbCfg().StorDBType,
- tpDrChgCfgIn.StorDbCfg().StorDBHost, tpDrChgCfgIn.StorDbCfg().StorDBPort,
- tpDrChgCfgIn.StorDbCfg().StorDBName, tpDrChgCfgIn.StorDbCfg().StorDBUser,
- tpDrChgCfgIn.StorDbCfg().StorDBPass,
- config.CgrConfig().StorDbCfg().StorDBMaxOpenConns,
- config.CgrConfig().StorDbCfg().StorDBMaxIdleConns,
- config.CgrConfig().StorDbCfg().StorDBConnMaxLifetime,
- config.CgrConfig().StorDbCfg().StorDBCDRSIndexes)
- if err != nil {
- log.Fatal(err)
- }
- storDBOut, err := NewMigratorStorDB(tpDrChgCfgOut.StorDbCfg().StorDBType,
- tpDrChgCfgOut.StorDbCfg().StorDBHost, tpDrChgCfgOut.StorDbCfg().StorDBPort,
- tpDrChgCfgOut.StorDbCfg().StorDBName, tpDrChgCfgOut.StorDbCfg().StorDBUser,
- tpDrChgCfgOut.StorDbCfg().StorDBPass,
- config.CgrConfig().StorDbCfg().StorDBMaxOpenConns,
- config.CgrConfig().StorDbCfg().StorDBMaxIdleConns,
- config.CgrConfig().StorDbCfg().StorDBConnMaxLifetime,
- config.CgrConfig().StorDbCfg().StorDBCDRSIndexes)
- if err != nil {
- log.Fatal(err)
- }
- tpDrChgMigrator, err = NewMigrator(nil, nil, storDBIn, storDBOut, false, false, false)
- if err != nil {
- log.Fatal(err)
- }
-}
-
-func testTpDrChgITFlush(t *testing.T) {
- if err := tpDrChgMigrator.storDBIn.StorDB().Flush(
- path.Join(tpDrChgCfgIn.DataFolderPath, "storage", tpDrChgCfgIn.StorDbCfg().StorDBType)); err != nil {
- t.Error(err)
- }
-
- if err := tpDrChgMigrator.storDBOut.StorDB().Flush(
- path.Join(tpDrChgCfgOut.DataFolderPath, "storage", tpDrChgCfgOut.StorDbCfg().StorDBType)); err != nil {
- t.Error(err)
- }
-}
-
-func testTpDrChgITPopulate(t *testing.T) {
- tpDerivedChargers = []*utils.TPDerivedChargers{
- {
- TPid: "TPD",
- LoadId: "LoadID",
- Direction: "*out",
- Tenant: "cgrates.org",
- Category: "call",
- Account: "1001",
- Subject: "1001",
- DestinationIds: "",
- DerivedChargers: []*utils.TPDerivedCharger{
- {
- RunId: "derived_run1",
- RunFilters: "",
- ReqTypeField: "^*rated",
- DirectionField: "*default",
- TenantField: "*default",
- CategoryField: "*default",
- AccountField: "*default",
- SubjectField: "^1002",
- DestinationField: "*default",
- SetupTimeField: "*default",
- PddField: "*default",
- AnswerTimeField: "*default",
- UsageField: "*default",
- SupplierField: "*default",
- DisconnectCauseField: "*default",
- CostField: "*default",
- RatedField: "*default",
- },
- },
- },
- }
- if err := tpDrChgMigrator.storDBIn.StorDB().SetTPDerivedChargers(tpDerivedChargers); err != nil {
- t.Error("Error when setting TpDerivedChargers ", err.Error())
- }
- currentVersion := engine.CurrentStorDBVersions()
- if err := tpDrChgMigrator.storDBOut.StorDB().SetVersions(currentVersion, false); err != nil {
- t.Error("Error when setting version for TpDerivedChargers ", err.Error())
- }
-}
-
-func testTpDrChgITMove(t *testing.T) {
- err, _ := tpDrChgMigrator.Migrate([]string{utils.MetaTpDerivedChargers})
- if err != nil {
- t.Error("Error when migrating TpDerivedChargers ", err.Error())
- }
-}
-
-func testTpDrChgITCheckData(t *testing.T) {
- filter := &utils.TPDerivedChargers{TPid: tpDerivedChargers[0].TPid}
- result, err := tpDrChgMigrator.storDBOut.StorDB().GetTPDerivedChargers(filter)
- if err != nil {
- t.Error("Error when getting TpDerivedChargers ", err.Error())
- }
- if !reflect.DeepEqual(tpDerivedChargers[0], result[0]) {
- t.Errorf("Expecting: %+v, received: %+v",
- utils.ToJSON(tpDerivedChargers[0]), utils.ToJSON(result[0]))
- }
- result, err = tpDrChgMigrator.storDBIn.StorDB().GetTPDerivedChargers(filter)
- if err != utils.ErrNotFound {
- t.Error(err)
- }
-}
diff --git a/migrator/user_it_test.go b/migrator/user_it_test.go
index 346c47a82..c303cda2b 100644
--- a/migrator/user_it_test.go
+++ b/migrator/user_it_test.go
@@ -195,7 +195,7 @@ func testUsrITMigrateAndMove(t *testing.T) {
//check if version was updated
if vrs, err := usrMigrator.dmOut.DataManager().DataDB().GetVersions(""); err != nil {
t.Error(err)
- } else if vrs[utils.User] != 2 {
+ } else if vrs[utils.User] != 0 {
t.Errorf("Unexpected version returned: %d", vrs[utils.User])
}
//check if user was migrate correctly
diff --git a/utils/apitpdata.go b/utils/apitpdata.go
index 7a68aae0c..83f90aec8 100755
--- a/utils/apitpdata.go
+++ b/utils/apitpdata.go
@@ -353,72 +353,6 @@ type TPSharedGroup struct {
RatingSubject string
}
-type TPDerivedChargers struct {
- TPid string
- LoadId string
- Direction string
- Tenant string
- Category string
- Account string
- Subject string
- DestinationIds string
- DerivedChargers []*TPDerivedCharger
-}
-
-type TPDerivedCharger struct {
- RunId string
- RunFilters string
- ReqTypeField string
- DirectionField string
- TenantField string
- CategoryField string
- AccountField string
- SubjectField string
- DestinationField string
- SetupTimeField string
- PddField string
- AnswerTimeField string
- UsageField string
- SupplierField string
- DisconnectCauseField string
- CostField string
- RatedField string
-}
-
-// Key used in dataDb to identify DerivedChargers set
-func (tpdc *TPDerivedChargers) GetDerivedChargersKey() string {
- return DerivedChargersKey(tpdc.Direction, tpdc.Tenant, tpdc.Category, tpdc.Account, tpdc.Subject)
-
-}
-
-func (tpdc *TPDerivedChargers) GetDerivedChargesId() string {
- return tpdc.LoadId +
- CONCATENATED_KEY_SEP +
- tpdc.Direction +
- CONCATENATED_KEY_SEP +
- tpdc.Tenant +
- CONCATENATED_KEY_SEP +
- tpdc.Category +
- CONCATENATED_KEY_SEP +
- tpdc.Account +
- CONCATENATED_KEY_SEP +
- tpdc.Subject
-}
-
-func (tpdc *TPDerivedChargers) SetDerivedChargersId(id string) error {
- ids := strings.Split(id, CONCATENATED_KEY_SEP)
- if len(ids) != 6 {
- return fmt.Errorf("Wrong TP Derived Charge Id: %s", id)
- }
- tpdc.LoadId = ids[0]
- tpdc.Direction = ids[1]
- tpdc.Tenant = ids[2]
- tpdc.Category = ids[3]
- tpdc.Account = ids[4]
- tpdc.Subject = ids[5]
- return nil
-}
-
type TPActionPlan struct {
TPid string // Tariff plan id
ID string // ActionPlan id
@@ -528,7 +462,6 @@ type ArgsCache struct {
AccountActionPlanIDs *[]string
ActionTriggerIDs *[]string
SharedGroupIDs *[]string
- DerivedChargerIDs *[]string
ResourceProfileIDs *[]string
ResourceIDs *[]string
StatsQueueIDs *[]string
@@ -568,7 +501,6 @@ type CacheStats struct {
ActionPlans int
AccountActionPlans int
SharedGroups int
- DerivedChargers int
ResourceProfiles int
Resources int
StatQueues int
@@ -754,10 +686,6 @@ type AttrGetDestination struct {
Id string
}
-type AttrDerivedChargers struct {
- Direction, Tenant, Category, Account, Subject, Destination string
-}
-
func NewTAFromAccountKey(accountKey string) (*TenantAccount, error) {
accountSplt := strings.Split(accountKey, CONCATENATED_KEY_SEP)
if len(accountSplt) != 2 {
diff --git a/utils/consts.go b/utils/consts.go
index b829e7195..b3d753939 100755
--- a/utils/consts.go
+++ b/utils/consts.go
@@ -60,7 +60,6 @@ var (
CacheAccountActionPlans: AccountActionPlansPrefix,
CacheActionTriggers: ACTION_TRIGGER_PREFIX,
CacheSharedGroups: SHARED_GROUP_PREFIX,
- CacheDerivedChargers: DERIVEDCHARGERS_PREFIX,
CacheResourceProfiles: ResourceProfilesPrefix,
CacheResources: ResourcesPrefix,
CacheEventResources: EventResourcesPrefix,
@@ -613,7 +612,6 @@ const (
MetaTpAccountActions = "*tp_account_actions"
MetaTpActionPlans = "*tp_action_plans"
MetaTpActions = "*tp_actions"
- MetaTpDerivedChargers = "*tp_derived_charges"
MetaTpThresholds = "*tp_thresholds"
MetaTpSuppliers = "*tp_suppliers"
MetaTpStats = "*tp_stats"
@@ -623,7 +621,6 @@ const (
MetaTpRates = "*tp_rates"
MetaTpTimings = "*tp_timings"
MetaTpResource = "*tp_resources"
- MetaTpDerivedChargersV = "*tp_derived_chargers"
MetaTpCdrStats = "*tp_cdrstats"
MetaTpDestinations = "*tp_destinations"
MetaTpRatingPlan = "*tp_rating_plans"
@@ -649,7 +646,6 @@ const (
TpAccountActionsV = "TpAccountActions"
TpActionPlans = "TpActionPlans"
TpActions = "TpActions"
- TpDerivedCharges = "TpDerivedCharges"
TpThresholds = "TpThresholds"
TpSuppliers = "TpSuppliers"
TpStats = "TpStats"
@@ -659,7 +655,6 @@ const (
TpRates = "TpRates"
TpTiming = "TpTiming"
TpResource = "TpResource"
- TpDerivedChargersV = "TpDerivedChargers"
TpCdrStats = "TpCdrStats"
TpDestinations = "TpDestinations"
TpRatingPlan = "TpRatingPlan"
@@ -868,7 +863,6 @@ const (
ACTION_PLANS_CSV = "ActionPlans.csv"
ACTION_TRIGGERS_CSV = "ActionTriggers.csv"
ACCOUNT_ACTIONS_CSV = "AccountActions.csv"
- DERIVED_CHARGERS_CSV = "DerivedChargers.csv"
ResourcesCsv = "Resources.csv"
StatsCsv = "Stats.csv"
ThresholdsCsv = "Thresholds.csv"
@@ -892,7 +886,6 @@ const (
TBLTPActionPlans = "tp_action_plans"
TBLTPActionTriggers = "tp_action_triggers"
TBLTPAccountActions = "tp_account_actions"
- TBLTPDerivedChargers = "tp_derived_chargers"
TBLTPResources = "tp_resources"
TBLTPStats = "tp_stats"
TBLTPThresholds = "tp_thresholds"
@@ -918,7 +911,6 @@ const (
CacheAccountActionPlans = "account_action_plans"
CacheActionTriggers = "action_triggers"
CacheSharedGroups = "shared_groups"
- CacheDerivedChargers = "derived_chargers"
CacheResources = "resources"
CacheResourceProfiles = "resource_profiles"
CacheTimings = "timings"
diff --git a/utils/derivedchargers.go b/utils/derivedchargers.go
deleted file mode 100644
index bbc907751..000000000
--- a/utils/derivedchargers.go
+++ /dev/null
@@ -1,228 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-
-package utils
-
-import (
- "errors"
- "strings"
-)
-
-// Wraps regexp compiling in case of rsr fields
-func NewDerivedCharger(runId, runFilters, reqTypeFld, dirFld, tenantFld, catFld, acntFld, subjFld, dstFld, sTimeFld, pddFld, aTimeFld, durFld,
- supplFld, dCauseFld, preRatedFld, costFld string) (dc *DerivedCharger, err error) {
- if len(runId) == 0 {
- return nil, errors.New("Empty run id field")
- }
- dc = &DerivedCharger{RunID: runId}
- dc.RunFilters = runFilters
- if strings.HasPrefix(dc.RunFilters, REGEXP_PREFIX) || strings.HasPrefix(dc.RunFilters, STATIC_VALUE_PREFIX) {
- if dc.rsrRunFilters, err = ParseRSRFields(dc.RunFilters, INFIELD_SEP); err != nil {
- return nil, err
- }
- }
- dc.RequestTypeField = reqTypeFld
- if strings.HasPrefix(dc.RequestTypeField, REGEXP_PREFIX) || strings.HasPrefix(dc.RequestTypeField, STATIC_VALUE_PREFIX) {
- if dc.rsrRequestTypeField, err = NewRSRField(dc.RequestTypeField); err != nil {
- return nil, err
- }
- }
- dc.DirectionField = dirFld
- if strings.HasPrefix(dc.DirectionField, REGEXP_PREFIX) || strings.HasPrefix(dc.DirectionField, STATIC_VALUE_PREFIX) {
- if dc.rsrDirectionField, err = NewRSRField(dc.DirectionField); err != nil {
- return nil, err
- }
- }
- dc.TenantField = tenantFld
- if strings.HasPrefix(dc.TenantField, REGEXP_PREFIX) || strings.HasPrefix(dc.TenantField, STATIC_VALUE_PREFIX) {
- if dc.rsrTenantField, err = NewRSRField(dc.TenantField); err != nil {
- return nil, err
- }
- }
- dc.CategoryField = catFld
- if strings.HasPrefix(dc.CategoryField, REGEXP_PREFIX) || strings.HasPrefix(dc.CategoryField, STATIC_VALUE_PREFIX) {
- if dc.rsrCategoryField, err = NewRSRField(dc.CategoryField); err != nil {
- return nil, err
- }
- }
- dc.AccountField = acntFld
- if strings.HasPrefix(dc.AccountField, REGEXP_PREFIX) || strings.HasPrefix(dc.AccountField, STATIC_VALUE_PREFIX) {
- if dc.rsrAccountField, err = NewRSRField(dc.AccountField); err != nil {
- return nil, err
- }
- }
- dc.SubjectField = subjFld
- if strings.HasPrefix(dc.SubjectField, REGEXP_PREFIX) || strings.HasPrefix(dc.SubjectField, STATIC_VALUE_PREFIX) {
- if dc.rsrSubjectField, err = NewRSRField(dc.SubjectField); err != nil {
- return nil, err
- }
- }
- dc.DestinationField = dstFld
- if strings.HasPrefix(dc.DestinationField, REGEXP_PREFIX) || strings.HasPrefix(dc.DestinationField, STATIC_VALUE_PREFIX) {
- if dc.rsrDestinationField, err = NewRSRField(dc.DestinationField); err != nil {
- return nil, err
- }
- }
- dc.SetupTimeField = sTimeFld
- if strings.HasPrefix(dc.SetupTimeField, REGEXP_PREFIX) || strings.HasPrefix(dc.SetupTimeField, STATIC_VALUE_PREFIX) {
- if dc.rsrSetupTimeField, err = NewRSRField(dc.SetupTimeField); err != nil {
- return nil, err
- }
- }
- dc.PDDField = pddFld
- if strings.HasPrefix(dc.PDDField, REGEXP_PREFIX) || strings.HasPrefix(dc.PDDField, STATIC_VALUE_PREFIX) {
- if dc.rsrPddField, err = NewRSRField(dc.PDDField); err != nil {
- return nil, err
- }
- }
- dc.AnswerTimeField = aTimeFld
- if strings.HasPrefix(dc.AnswerTimeField, REGEXP_PREFIX) || strings.HasPrefix(dc.AnswerTimeField, STATIC_VALUE_PREFIX) {
- if dc.rsrAnswerTimeField, err = NewRSRField(dc.AnswerTimeField); err != nil {
- return nil, err
- }
- }
- dc.UsageField = durFld
- if strings.HasPrefix(dc.UsageField, REGEXP_PREFIX) || strings.HasPrefix(dc.UsageField, STATIC_VALUE_PREFIX) {
- if dc.rsrUsageField, err = NewRSRField(dc.UsageField); err != nil {
- return nil, err
- }
- }
- dc.SupplierField = supplFld
- if strings.HasPrefix(dc.SupplierField, REGEXP_PREFIX) || strings.HasPrefix(dc.SupplierField, STATIC_VALUE_PREFIX) {
- if dc.rsrSupplierField, err = NewRSRField(dc.SupplierField); err != nil {
- return nil, err
- }
- }
- dc.DisconnectCauseField = dCauseFld
- if strings.HasPrefix(dc.DisconnectCauseField, REGEXP_PREFIX) || strings.HasPrefix(dc.DisconnectCauseField, STATIC_VALUE_PREFIX) {
- if dc.rsrDisconnectCauseField, err = NewRSRField(dc.DisconnectCauseField); err != nil {
- return nil, err
- }
- }
- dc.PreRatedField = preRatedFld
- if strings.HasPrefix(dc.PreRatedField, REGEXP_PREFIX) || strings.HasPrefix(dc.PreRatedField, STATIC_VALUE_PREFIX) {
- if dc.rsrPreRatedField, err = NewRSRField(dc.PreRatedField); err != nil {
- return nil, err
- }
- }
- dc.CostField = costFld
- if strings.HasPrefix(dc.CostField, REGEXP_PREFIX) || strings.HasPrefix(dc.CostField, STATIC_VALUE_PREFIX) {
- if dc.rsrCostField, err = NewRSRField(dc.CostField); err != nil {
- return nil, err
- }
- }
- return dc, nil
-}
-
-type DerivedCharger struct {
- RunID string // Unique runId in the chain
- RunFilters string // Only run the charger if all the filters match
- RequestTypeField string // Field containing request type info, number in case of csv source, '^' as prefix in case of static values
- DirectionField string // Field containing direction info
- TenantField string // Field containing tenant info
- CategoryField string // Field containing tor info
- AccountField string // Field containing account information
- SubjectField string // Field containing subject information
- DestinationField string // Field containing destination information
- SetupTimeField string // Field containing setup time information
- PDDField string // Field containing setup time information
- AnswerTimeField string // Field containing answer time information
- UsageField string // Field containing usage information
- SupplierField string // Field containing supplier information
- DisconnectCauseField string // Field containing disconnect cause information
- CostField string // Field containing cost information
- PreRatedField string // Field marking rated request in CDR
- rsrRunFilters []*RSRField // Storage for compiled Regexp in case of RSRFields
- rsrRequestTypeField *RSRField
- rsrDirectionField *RSRField
- rsrTenantField *RSRField
- rsrCategoryField *RSRField
- rsrAccountField *RSRField
- rsrSubjectField *RSRField
- rsrDestinationField *RSRField
- rsrSetupTimeField *RSRField
- rsrPddField *RSRField
- rsrAnswerTimeField *RSRField
- rsrUsageField *RSRField
- rsrSupplierField *RSRField
- rsrDisconnectCauseField *RSRField
- rsrCostField *RSRField
- rsrPreRatedField *RSRField
-}
-
-func (dc *DerivedCharger) Equal(other *DerivedCharger) bool {
- return dc.RunID == other.RunID &&
- dc.RunFilters == other.RunFilters &&
- dc.RequestTypeField == other.RequestTypeField &&
- dc.DirectionField == other.DirectionField &&
- dc.TenantField == other.TenantField &&
- dc.CategoryField == other.CategoryField &&
- dc.AccountField == other.AccountField &&
- dc.SubjectField == other.SubjectField &&
- dc.DestinationField == other.DestinationField &&
- dc.SetupTimeField == other.SetupTimeField &&
- dc.PDDField == other.PDDField &&
- dc.AnswerTimeField == other.AnswerTimeField &&
- dc.UsageField == other.UsageField &&
- dc.SupplierField == other.SupplierField &&
- dc.DisconnectCauseField == other.DisconnectCauseField &&
- dc.CostField == other.CostField &&
- dc.PreRatedField == other.PreRatedField
-}
-
-func DerivedChargersKey(direction, tenant, category, account, subject string) string {
- return ConcatenatedKey(direction, tenant, category, account, subject)
-}
-
-type DerivedChargers struct {
- DestinationIDs StringMap
- Chargers []*DerivedCharger
-}
-
-// Precheck that RunId is unique
-func (dcs *DerivedChargers) Append(dc *DerivedCharger) (*DerivedChargers, error) {
- if dc.RunID == DEFAULT_RUNID {
- return nil, errors.New("Reserved RunId")
- }
- for _, dcLocal := range dcs.Chargers {
- if dcLocal.RunID == dc.RunID {
- return nil, errors.New("Duplicated RunId")
- }
- }
- dcs.Chargers = append(dcs.Chargers, dc)
- return dcs, nil
-}
-
-func (dcs *DerivedChargers) AppendDefaultRun() (*DerivedChargers, error) {
- dcDf, _ := NewDerivedCharger(DEFAULT_RUNID, "", META_DEFAULT, META_DEFAULT,
- META_DEFAULT, META_DEFAULT, META_DEFAULT,
- META_DEFAULT, META_DEFAULT, META_DEFAULT, META_DEFAULT, META_DEFAULT,
- META_DEFAULT, META_DEFAULT, META_DEFAULT, META_DEFAULT, META_DEFAULT)
- dcs.Chargers = append(dcs.Chargers, dcDf)
- return dcs, nil
-}
-
-func (dcs *DerivedChargers) Equal(other *DerivedChargers) bool {
- dcs.DestinationIDs.Equal(other.DestinationIDs)
- for i, dc := range dcs.Chargers {
- if !dc.Equal(other.Chargers[i]) {
- return false
- }
- }
- return true
-}
diff --git a/utils/derivedchargers_test.go b/utils/derivedchargers_test.go
deleted file mode 100644
index ea7606142..000000000
--- a/utils/derivedchargers_test.go
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
-Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
-Copyright (C) ITsysCOM GmbH
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see
-*/
-package utils
-
-import (
- "reflect"
- "testing"
-)
-
-func TestAppendDerivedChargers(t *testing.T) {
- var err error
-
- dcs := &DerivedChargers{Chargers: make([]*DerivedCharger, 0)}
- if _, err := dcs.Append(&DerivedCharger{RunID: DEFAULT_RUNID}); err == nil {
- t.Error("Failed to detect using of the default RunID")
- }
- if dcs, err = dcs.Append(&DerivedCharger{RunID: "FIRST_RunID"}); err != nil {
- t.Error("Failed to add RunID")
- } else if len(dcs.Chargers) != 1 {
- t.Error("Unexpected number of items inside DerivedChargers configuration", len(dcs.Chargers))
- }
- if dcs, err = dcs.Append(&DerivedCharger{RunID: "SECOND_RunID"}); err != nil {
- t.Error("Failed to add RunID")
- } else if len(dcs.Chargers) != 2 {
- t.Error("Unexpected number of items inside DerivedChargers configuration", len(dcs.Chargers))
- }
- if _, err := dcs.Append(&DerivedCharger{RunID: "SECOND_RunID"}); err == nil {
- t.Error("Failed to detect duplicate RunID")
- }
-}
-
-func TestNewDerivedCharger(t *testing.T) {
- edc1 := &DerivedCharger{
- RunID: "test1",
- RunFilters: "",
- RequestTypeField: "reqtype1",
- DirectionField: "direction1",
- TenantField: "tenant1",
- CategoryField: "tor1",
- AccountField: "account1",
- SubjectField: "subject1",
- DestinationField: "destination1",
- SetupTimeField: "setuptime1",
- PDDField: "pdd1",
- AnswerTimeField: "answertime1",
- UsageField: "duration1",
- SupplierField: "supplier1",
- DisconnectCauseField: "NORMAL_CLEARING",
- PreRatedField: "rated1",
- CostField: "cost1",
- }
- if dc1, err := NewDerivedCharger("test1", "", "reqtype1", "direction1", "tenant1", "tor1", "account1", "subject1", "destination1",
- "setuptime1", "pdd1", "answertime1", "duration1", "supplier1", "NORMAL_CLEARING", "rated1", "cost1"); err != nil {
- t.Error("Unexpected error", err.Error())
- } else if !reflect.DeepEqual(edc1, dc1) {
- t.Errorf("Expecting: %v, received: %v", edc1, dc1)
- }
- edc2 := &DerivedCharger{
- RunID: "test2",
- RunFilters: "^cdr_source/tdm_cdrs/",
- RequestTypeField: "~reqtype2:s/sip:(.+)/$1/",
- DirectionField: "~direction2:s/sip:(.+)/$1/",
- TenantField: "~tenant2:s/sip:(.+)/$1/",
- CategoryField: "~tor2:s/sip:(.+)/$1/",
- AccountField: "~account2:s/sip:(.+)/$1/",
- SubjectField: "~subject2:s/sip:(.+)/$1/",
- DestinationField: "~destination2:s/sip:(.+)/$1/",
- SetupTimeField: "~setuptime2:s/sip:(.+)/$1/",
- PDDField: "~pdd:s/sip:(.+)/$1/",
- AnswerTimeField: "~answertime2:s/sip:(.+)/$1/",
- UsageField: "~duration2:s/sip:(.+)/$1/",
- SupplierField: "~supplier2:s/(.+)/$1/",
- DisconnectCauseField: "~cgr_disconnect:s/(.+)/$1/",
- CostField: "~cgr_cost:s/(.+)/$1/",
- PreRatedField: "~cgr_rated:s/(.+)/$1/",
- }
- edc2.rsrRunFilters, _ = ParseRSRFields("^cdr_source/tdm_cdrs/", INFIELD_SEP)
- edc2.rsrRequestTypeField, _ = NewRSRField("~reqtype2:s/sip:(.+)/$1/")
- edc2.rsrDirectionField, _ = NewRSRField("~direction2:s/sip:(.+)/$1/")
- edc2.rsrTenantField, _ = NewRSRField("~tenant2:s/sip:(.+)/$1/")
- edc2.rsrCategoryField, _ = NewRSRField("~tor2:s/sip:(.+)/$1/")
- edc2.rsrAccountField, _ = NewRSRField("~account2:s/sip:(.+)/$1/")
- edc2.rsrSubjectField, _ = NewRSRField("~subject2:s/sip:(.+)/$1/")
- edc2.rsrDestinationField, _ = NewRSRField("~destination2:s/sip:(.+)/$1/")
- edc2.rsrSetupTimeField, _ = NewRSRField("~setuptime2:s/sip:(.+)/$1/")
- edc2.rsrPddField, _ = NewRSRField("~pdd:s/sip:(.+)/$1/")
- edc2.rsrAnswerTimeField, _ = NewRSRField("~answertime2:s/sip:(.+)/$1/")
- edc2.rsrUsageField, _ = NewRSRField("~duration2:s/sip:(.+)/$1/")
- edc2.rsrSupplierField, _ = NewRSRField("~supplier2:s/(.+)/$1/")
- edc2.rsrDisconnectCauseField, _ = NewRSRField("~cgr_disconnect:s/(.+)/$1/")
- edc2.rsrCostField, _ = NewRSRField("~cgr_cost:s/(.+)/$1/")
- edc2.rsrPreRatedField, _ = NewRSRField("~cgr_rated:s/(.+)/$1/")
- if dc2, err := NewDerivedCharger("test2",
- "^cdr_source/tdm_cdrs/",
- "~reqtype2:s/sip:(.+)/$1/",
- "~direction2:s/sip:(.+)/$1/",
- "~tenant2:s/sip:(.+)/$1/",
- "~tor2:s/sip:(.+)/$1/",
- "~account2:s/sip:(.+)/$1/",
- "~subject2:s/sip:(.+)/$1/",
- "~destination2:s/sip:(.+)/$1/",
- "~setuptime2:s/sip:(.+)/$1/",
- "~pdd:s/sip:(.+)/$1/",
- "~answertime2:s/sip:(.+)/$1/",
- "~duration2:s/sip:(.+)/$1/",
- "~supplier2:s/(.+)/$1/",
- "~cgr_disconnect:s/(.+)/$1/",
- "~cgr_rated:s/(.+)/$1/",
- "~cgr_cost:s/(.+)/$1/"); err != nil {
- t.Error("Unexpected error", err)
- } else if !reflect.DeepEqual(edc2, dc2) {
- t.Errorf("Expecting: %v, received: %v", edc2, dc2)
- }
-}
-
-func TestDerivedChargersKey(t *testing.T) {
- if dcKey := DerivedChargersKey("*out", "cgrates.org", "call", "dan", "dan"); dcKey != "*out:cgrates.org:call:dan:dan" {
- t.Error("Unexpected derived chargers key: ", dcKey)
- }
-}
-
-func TestAppendDefaultRun(t *testing.T) {
- dc1 := &DerivedChargers{}
- dcDf := &DerivedCharger{RunID: DEFAULT_RUNID, RunFilters: "", RequestTypeField: META_DEFAULT, DirectionField: META_DEFAULT,
- TenantField: META_DEFAULT, CategoryField: META_DEFAULT, AccountField: META_DEFAULT, SubjectField: META_DEFAULT,
- DestinationField: META_DEFAULT, SetupTimeField: META_DEFAULT, PDDField: META_DEFAULT, AnswerTimeField: META_DEFAULT, UsageField: META_DEFAULT, SupplierField: META_DEFAULT,
- DisconnectCauseField: META_DEFAULT, CostField: META_DEFAULT, PreRatedField: META_DEFAULT}
- eDc1 := &DerivedChargers{Chargers: []*DerivedCharger{dcDf}}
- if dc1, _ = dc1.AppendDefaultRun(); !reflect.DeepEqual(dc1, eDc1) {
- t.Errorf("Expecting: %+v, received: %+v", eDc1.Chargers[0], dc1.Chargers[0])
- }
- dc2 := &DerivedChargers{Chargers: []*DerivedCharger{
- &DerivedCharger{RunID: "extra1", RunFilters: "", RequestTypeField: "reqtype2", DirectionField: META_DEFAULT, TenantField: META_DEFAULT, CategoryField: META_DEFAULT,
- AccountField: "rif", SubjectField: "rif", DestinationField: META_DEFAULT, SetupTimeField: META_DEFAULT, PDDField: META_DEFAULT, AnswerTimeField: META_DEFAULT, UsageField: META_DEFAULT,
- DisconnectCauseField: META_DEFAULT},
- &DerivedCharger{RunID: "extra2", RequestTypeField: META_DEFAULT, DirectionField: META_DEFAULT, TenantField: META_DEFAULT, CategoryField: META_DEFAULT,
- AccountField: "ivo", SubjectField: "ivo", DestinationField: META_DEFAULT, SetupTimeField: META_DEFAULT, PDDField: META_DEFAULT, AnswerTimeField: META_DEFAULT,
- UsageField: META_DEFAULT, SupplierField: META_DEFAULT, DisconnectCauseField: META_DEFAULT}},
- }
- eDc2 := &DerivedChargers{}
- eDc2.Chargers = append(dc2.Chargers, dcDf)
- if dc2, _ = dc2.AppendDefaultRun(); !reflect.DeepEqual(dc2, eDc2) {
- t.Errorf("Expecting: %+v, received: %+v", eDc2.Chargers, dc2.Chargers)
- }
-}