diff --git a/apier/v1/apier.go b/apier/v1/apier.go index d045ffe25..6ef9928a1 100644 --- a/apier/v1/apier.go +++ b/apier/v1/apier.go @@ -21,12 +21,13 @@ package apier import ( "errors" "fmt" + "path" + "github.com/cgrates/cgrates/cache2go" "github.com/cgrates/cgrates/config" "github.com/cgrates/cgrates/engine" "github.com/cgrates/cgrates/scheduler" "github.com/cgrates/cgrates/utils" - "path" ) const ( @@ -93,8 +94,11 @@ type AttrAddBalance struct { BalanceId string Direction string Value float64 - Weight float64 - Overwrite bool // When true it will reset if the balance is already there + //ExpirationDate time.Time + //RateSubject string + DestinationId string + Weight float64 + Overwrite bool // When true it will reset if the balance is already there } func (self *ApierV1) AddBalance(attr *AttrAddBalance, reply *string) error { @@ -120,8 +124,20 @@ func (self *ApierV1) AddBalance(attr *AttrAddBalance, reply *string) error { if attr.Overwrite { aType = engine.TOPUP_RESET } - at.SetActions(engine.Actions{&engine.Action{ActionType: aType, BalanceId: attr.BalanceId, Direction: attr.Direction, - Balance: &engine.Balance{Value: attr.Value, Weight: attr.Weight}}}) + at.SetActions(engine.Actions{ + &engine.Action{ + ActionType: aType, + BalanceId: attr.BalanceId, + Direction: attr.Direction, + Balance: &engine.Balance{ + Value: attr.Value, + //ExpirationDate: attr.ExpirationDate, + //RateSubject: attr.RateSubject, + DestinationId: attr.DestinationId, + Weight: attr.Weight, + }, + }, + }) if err := at.Execute(); err != nil { *reply = err.Error() return err diff --git a/console/add_balance.go b/console/add_balance.go index 918430df0..2fdb0a17f 100644 --- a/console/add_balance.go +++ b/console/add_balance.go @@ -39,7 +39,7 @@ type CmdAddBalance struct { // name should be exec's name func (self *CmdAddBalance) Usage(name string) string { - return fmt.Sprintf("\n\tUsage: cgr-console [cfg_opts...{-h}] add_balance [ [ [overwrite]]]") + return fmt.Sprintf("\n\tUsage: cgr-console [cfg_opts...{-h}] add_balance [monetary|sms|internet|internet_time|minutes [ [ [overwrite]]]]") } // set param defaults @@ -60,14 +60,16 @@ func (self *CmdAddBalance) FromArgs(args []string) error { self.defaults() self.rpcParams.Tenant = args[2] self.rpcParams.Account = args[3] - self.rpcParams.Direction = args[4] - value, err := strconv.ParseFloat(args[5], 64) + value, err := strconv.ParseFloat(args[4], 64) if err != nil { return err } self.rpcParams.Value = value + if len(args) > 5 { + self.rpcParams.BalanceId = args[5] + } if len(args) > 6 { - self.rpcParams.BalanceId = args[6] + self.rpcParams.DestinationId = args[6] } if len(args) > 7 { if self.rpcParams.Weight, err = strconv.ParseFloat(args[7], 64); err != nil { diff --git a/engine/balances.go b/engine/balances.go index 439b7caac..e3f642fbb 100644 --- a/engine/balances.go +++ b/engine/balances.go @@ -32,10 +32,10 @@ type Balance struct { Value float64 ExpirationDate time.Time Weight float64 - GroupIds []string - DestinationId string - RateSubject string - precision int + //GroupIds []string + DestinationId string + RateSubject string + precision int } func (b *Balance) Equal(o *Balance) bool {