mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-15 21:29:52 +05:00
create incerements for getcost as well
This commit is contained in:
@@ -24,7 +24,6 @@ func init() {
|
||||
c := &CmdGetActions{
|
||||
name: "actions",
|
||||
rpcMethod: "ApierV2.GetActions",
|
||||
rpcParams: "",
|
||||
}
|
||||
commands[c.Name()] = c
|
||||
c.CommandExecuter = &CommandExecuter{c}
|
||||
@@ -34,7 +33,7 @@ func init() {
|
||||
type CmdGetActions struct {
|
||||
name string
|
||||
rpcMethod string
|
||||
rpcParams string
|
||||
rpcParams *StringWrapper
|
||||
*CommandExecuter
|
||||
}
|
||||
|
||||
@@ -47,6 +46,9 @@ func (self *CmdGetActions) RpcMethod() string {
|
||||
}
|
||||
|
||||
func (self *CmdGetActions) RpcParams(reset bool) interface{} {
|
||||
if reset || self.rpcParams == nil {
|
||||
self.rpcParams = &StringWrapper{}
|
||||
}
|
||||
return self.rpcParams
|
||||
}
|
||||
|
||||
|
||||
@@ -365,7 +365,7 @@ func (ub *Account) debitCreditBalance(cd *CallDescriptor, count bool, dryRun boo
|
||||
cc.Timespans = append(cc.Timespans, leftCC.Timespans...)
|
||||
}
|
||||
|
||||
//log.Printf("HERE: %+v %d", leftCC)
|
||||
//log.Printf("HERE: %+v", leftCC)
|
||||
if leftCC.Cost > 0 && goNegative {
|
||||
initialLength := len(cc.Timespans)
|
||||
cc.Timespans = append(cc.Timespans, leftCC.Timespans...)
|
||||
@@ -379,6 +379,7 @@ func (ub *Account) debitCreditBalance(cd *CallDescriptor, count bool, dryRun boo
|
||||
if len(leftCC.Timespans) > 0 && leftCC.Cost > 0 && !ub.AllowNegative && !dryRun {
|
||||
utils.Logger.Err(fmt.Sprintf("<Rater> Going negative on account %s with AllowNegative: false", cd.GetAccountKey()))
|
||||
}
|
||||
leftCC.Timespans.Decompress()
|
||||
for _, ts := range leftCC.Timespans {
|
||||
if ts.Increments == nil {
|
||||
ts.createIncrementsSlice()
|
||||
|
||||
@@ -143,6 +143,9 @@ func TestGetSpecialPricedSeconds(t *testing.T) {
|
||||
expected := 20 * time.Second
|
||||
if credit != 0 || seconds != expected || len(bucketList) != 2 || bucketList[0].Weight < bucketList[1].Weight {
|
||||
t.Log(seconds, credit, bucketList)
|
||||
for _, b := range bucketList {
|
||||
t.Logf("Balance: %+v", b)
|
||||
}
|
||||
t.Errorf("Expected %v was %v", expected, seconds)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -503,6 +503,7 @@ func (cd *CallDescriptor) getCost() (*CallCost, error) {
|
||||
cost := 0.0
|
||||
|
||||
for i, ts := range timespans {
|
||||
ts.createIncrementsSlice()
|
||||
// only add connect fee if this is the first/only call cost request
|
||||
//log.Printf("Interval: %+v", ts.RateInterval.Timing)
|
||||
if cd.LoopIndex == 0 && i == 0 && ts.RateInterval != nil {
|
||||
|
||||
@@ -574,7 +574,7 @@ func TestGetCostRoundingIssue(t *testing.T) {
|
||||
MaxCostSoFar: 0,
|
||||
}
|
||||
cc, err := cd.GetCost()
|
||||
expected := 0.17
|
||||
expected := 0.39
|
||||
if cc.Cost != expected || err != nil {
|
||||
t.Log(utils.ToIJSON(cc))
|
||||
t.Errorf("Expected %v was %+v", expected, cc)
|
||||
|
||||
Reference in New Issue
Block a user