diff --git a/engine/account.go b/engine/account.go index a83a99dcc..3ce64f10c 100644 --- a/engine/account.go +++ b/engine/account.go @@ -602,17 +602,6 @@ func (acc *Account) CleanExpiredBalances() { } } -func (acc *Account) allBalancesExpired() bool { - for _, bm := range acc.BalanceMap { - for i := 0; i < len(bm); i++ { - if !bm[i].IsExpired() { - return false - } - } - } - return true -} - // returns the shared groups that this user balance belnongs to func (acc *Account) GetSharedGroups() (groups []string) { for _, balanceChain := range acc.BalanceMap { diff --git a/engine/account_test.go b/engine/account_test.go index e579232c8..84c6afae9 100644 --- a/engine/account_test.go +++ b/engine/account_test.go @@ -90,7 +90,7 @@ func TestAccountStorageStoreRestore(t *testing.T) { ub1, err := accountingStorage.GetAccount("other") if err != nil || !ub1.BalanceMap[utils.MONETARY].Equal(rifsBalance.BalanceMap[utils.MONETARY]) { t.Log("UB: ", ub1) - t.Errorf("Expected %v was %v", rifsBalance.BalanceMap[utils.MONETARY], ub1.BalanceMap[utils.MONETARY]) + t.Errorf("Expected %v was %v", rifsBalance, ub1) } } diff --git a/engine/storage_map.go b/engine/storage_map.go index da13aec99..76b695484 100644 --- a/engine/storage_map.go +++ b/engine/storage_map.go @@ -456,18 +456,6 @@ func (ms *MapStorage) GetAccount(key string) (ub *Account, err error) { } func (ms *MapStorage) SetAccount(ub *Account) (err error) { - // never override existing account with an empty one - // UPDATE: if all balances expired and were clean it makes - // sense to write empty balance map - if len(ub.BalanceMap) == 0 { - if ac, err := ms.GetAccount(ub.Id); err == nil && !ac.allBalancesExpired() { - ac.ActionTriggers = ub.ActionTriggers - ac.UnitCounters = ub.UnitCounters - ac.AllowNegative = ub.AllowNegative - ac.Disabled = ub.Disabled - ub = ac - } - } result, err := ms.ms.Marshal(ub) ms.dict[utils.ACCOUNT_PREFIX+ub.Id] = result return diff --git a/engine/storage_mongo.go b/engine/storage_mongo.go index 3edad9cc9..5450d063d 100644 --- a/engine/storage_mongo.go +++ b/engine/storage_mongo.go @@ -732,18 +732,6 @@ func (ms *MongoStorage) GetAccount(key string) (result *Account, err error) { } func (ms *MongoStorage) SetAccount(acc *Account) error { - // never override existing account with an empty one - // UPDATE: if all balances expired and were cleaned it makes - // sense to write empty balance map - if len(acc.BalanceMap) == 0 { - if ac, err := ms.GetAccount(acc.Id); err == nil && !ac.allBalancesExpired() { - ac.ActionTriggers = acc.ActionTriggers - ac.UnitCounters = acc.UnitCounters - ac.AllowNegative = acc.AllowNegative - ac.Disabled = acc.Disabled - acc = ac - } - } _, err := ms.db.C(colAcc).Upsert(bson.M{"id": acc.Id}, acc) return err } diff --git a/engine/storage_redis.go b/engine/storage_redis.go index ca959daa9..7c434df3b 100644 --- a/engine/storage_redis.go +++ b/engine/storage_redis.go @@ -366,7 +366,7 @@ func (rs *RedisStorage) HasData(category, subject string) (bool, error) { i, err := rs.db.Cmd("EXISTS", category+subject).Int() return i == 1, err } - return false, errors.New("Unsupported category in HasData") + return false, errors.New("unsupported HasData category") } func (rs *RedisStorage) GetRatingPlan(key string, skipCache bool) (rp *RatingPlan, err error) { @@ -588,18 +588,6 @@ func (rs *RedisStorage) GetAccount(key string) (ub *Account, err error) { } func (rs *RedisStorage) SetAccount(ub *Account) (err error) { - // never override existing account with an empty one - // UPDATE: if all balances expired and were cleaned it makes - // sense to write empty balance map - if len(ub.BalanceMap) == 0 { - if ac, err := rs.GetAccount(ub.Id); err == nil && !ac.allBalancesExpired() { - ac.ActionTriggers = ub.ActionTriggers - ac.UnitCounters = ub.UnitCounters - ac.AllowNegative = ub.AllowNegative - ac.Disabled = ub.Disabled - ub = ac - } - } result, err := rs.ms.Marshal(ub) err = rs.db.Cmd("SET", utils.ACCOUNT_PREFIX+ub.Id, result).Err return