mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-17 06:09:53 +05:00
Fix ApierV1.GetAccount and GetAccounts to display old account format properly
This commit is contained in:
@@ -19,6 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
package v1
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math"
|
||||
"regexp"
|
||||
"strings"
|
||||
@@ -282,3 +283,15 @@ func (self *ApierV1) GetAccounts(attr utils.AttrGetAccounts, reply *[]interface{
|
||||
*reply = retAccounts
|
||||
return nil
|
||||
}
|
||||
|
||||
// Get balance
|
||||
func (self *ApierV1) GetAccount(attr *utils.AttrGetAccount, reply *interface{}) error {
|
||||
tag := fmt.Sprintf("%s:%s", attr.Tenant, attr.Account)
|
||||
userBalance, err := self.AccountDb.GetAccount(tag)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
*reply = userBalance.AsOldStructure()
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -102,18 +102,6 @@ func (self *ApierV1) GetRatingPlan(rplnId string, reply *engine.RatingPlan) erro
|
||||
return nil
|
||||
}
|
||||
|
||||
// Get balance
|
||||
func (self *ApierV1) GetAccount(attr *utils.AttrGetAccount, reply *engine.Account) error {
|
||||
tag := fmt.Sprintf("%s:%s", attr.Tenant, attr.Account)
|
||||
userBalance, err := self.AccountDb.GetAccount(tag)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
*reply = *userBalance
|
||||
return nil
|
||||
}
|
||||
|
||||
type AttrAddBalance struct {
|
||||
Tenant string
|
||||
Account string
|
||||
@@ -126,7 +114,7 @@ type AttrAddBalance struct {
|
||||
RatingSubject string
|
||||
DestinationIds string
|
||||
Weight float64
|
||||
SharedGroups string
|
||||
SharedGroups string
|
||||
Overwrite bool // When true it will reset if the balance is already there
|
||||
Disabled bool
|
||||
}
|
||||
@@ -171,7 +159,7 @@ func (self *ApierV1) AddBalance(attr *AttrAddBalance, reply *string) error {
|
||||
Directions: utils.ParseStringMap(attr.Directions),
|
||||
DestinationIds: utils.ParseStringMap(attr.DestinationIds),
|
||||
Weight: attr.Weight,
|
||||
SharedGroups: utils.ParseStringMap(attr.SharedGroups),
|
||||
SharedGroups: utils.ParseStringMap(attr.SharedGroups),
|
||||
Disabled: attr.Disabled,
|
||||
},
|
||||
},
|
||||
@@ -210,7 +198,7 @@ func (self *ApierV1) EnableDisableBalance(attr *AttrAddBalance, reply *string) e
|
||||
Directions: utils.ParseStringMap(attr.Directions),
|
||||
DestinationIds: utils.ParseStringMap(attr.DestinationIds),
|
||||
Weight: attr.Weight,
|
||||
SharedGroups: utils.ParseStringMap(attr.SharedGroups),
|
||||
SharedGroups: utils.ParseStringMap(attr.SharedGroups),
|
||||
Disabled: attr.Disabled,
|
||||
},
|
||||
},
|
||||
@@ -621,7 +609,7 @@ func (self *ApierV1) SetActions(attrs utils.AttrSetActions, reply *string) error
|
||||
Directions: utils.ParseStringMap(apiAct.Directions),
|
||||
DestinationIds: utils.ParseStringMap(apiAct.DestinationIds),
|
||||
RatingSubject: apiAct.RatingSubject,
|
||||
SharedGroups: utils.ParseStringMap(apiAct.SharedGroups),
|
||||
SharedGroups: utils.ParseStringMap(apiAct.SharedGroups),
|
||||
},
|
||||
}
|
||||
storeActions[idx] = a
|
||||
|
||||
@@ -759,7 +759,7 @@ func (acc *Account) AsOldStructure() interface{} {
|
||||
}
|
||||
|
||||
result := &Account{
|
||||
Id: acc.Id,
|
||||
Id: "*out:" + acc.Id,
|
||||
BalanceMap: make(map[string]BalanceChain, len(acc.BalanceMap)),
|
||||
UnitCounters: make([]*UnitsCounter, len(acc.UnitCounters)),
|
||||
ActionTriggers: make(ActionTriggers, len(acc.ActionTriggers)),
|
||||
|
||||
Reference in New Issue
Block a user