mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-25 09:08:45 +05:00
return callcost with -1 cost on error
This commit is contained in:
@@ -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