mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
return callcost with -1 cost on error
This commit is contained in:
@@ -22,6 +22,7 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
@@ -1221,6 +1222,7 @@ func (arrp *AttrRemoveRatingProfile) GetId() (result string) {
|
||||
}
|
||||
|
||||
func (self *ApierV1) RemoveRatingProfile(attr AttrRemoveRatingProfile, reply *string) error {
|
||||
log.Printf("ATTR: %+v", attr)
|
||||
if attr.Direction == "" {
|
||||
attr.Direction = utils.OUT
|
||||
}
|
||||
@@ -1230,6 +1232,7 @@ func (self *ApierV1) RemoveRatingProfile(attr AttrRemoveRatingProfile, reply *st
|
||||
return utils.ErrMandatoryIeMissing
|
||||
}
|
||||
_, err := engine.Guardian.Guard(func() (interface{}, error) {
|
||||
log.Print("RPID: ", attr.GetId())
|
||||
err := self.RatingDb.RemoveRatingProfile(attr.GetId())
|
||||
if err != nil {
|
||||
return 0, err
|
||||
|
||||
@@ -427,7 +427,7 @@ func (cd *CallDescriptor) GetCost() (*CallCost, error) {
|
||||
cd.account = nil // make sure it's not cached
|
||||
cc, err := cd.getCost()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return cc, err
|
||||
}
|
||||
|
||||
cost := 0.0
|
||||
|
||||
@@ -387,6 +387,17 @@ func TestSubjectNotFound(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestSubjectNotFoundCostNegativeOne(t *testing.T) {
|
||||
t1 := time.Date(2013, time.February, 1, 17, 30, 0, 0, time.UTC)
|
||||
t2 := time.Date(2013, time.February, 1, 18, 30, 0, 0, time.UTC)
|
||||
cd := &CallDescriptor{Direction: "*out", Category: "0", Tenant: "cgrates.org", Subject: "not_exiting", Destination: "025740532", TimeStart: t1, TimeEnd: t2}
|
||||
result, _ := cd.GetCost()
|
||||
if result.Cost != -1 || result.GetConnectFee() != 0 {
|
||||
//t.Logf("%+v", result.Timespans[0].RateInterval)
|
||||
t.Errorf("Expected -1 was %v", result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestMultipleRatingPlans(t *testing.T) {
|
||||
t1 := time.Date(2012, time.February, 8, 17, 30, 0, 0, time.UTC)
|
||||
t2 := time.Date(2012, time.February, 8, 18, 30, 0, 0, time.UTC)
|
||||
|
||||
@@ -312,7 +312,7 @@ func (self *CdrServer) getCostFromRater(storedCdr *StoredCdr) (*CallCost, error)
|
||||
err = self.rater.GetCost(cd, cc)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return cc, err
|
||||
}
|
||||
return cc, nil
|
||||
}
|
||||
|
||||
@@ -105,10 +105,11 @@ func (rs *Responder) GetCost(arg *CallDescriptor, reply *CallCost) (err error) {
|
||||
r, e := Guardian.Guard(func() (interface{}, error) {
|
||||
return arg.GetCost()
|
||||
}, 0, arg.GetAccountKey())
|
||||
if r != nil {
|
||||
*reply = *r.(*CallCost)
|
||||
}
|
||||
if e != nil {
|
||||
return e
|
||||
} else if r != nil {
|
||||
*reply = *r.(*CallCost)
|
||||
}
|
||||
}
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user