returning -SYSTEM_ERROR

in reference to #277
This commit is contained in:
Radu Ioan Fericean
2015-11-11 22:30:17 +02:00
parent 5aef2fa85d
commit 709d5f06ce
2 changed files with 27 additions and 3 deletions

View File

@@ -696,12 +696,12 @@ func (cd *CallDescriptor) MaxDebit() (cc *CallCost, err error) {
} else {
//log.Printf("ACC: %+v", account)
if memberIds, err := account.GetUniqueSharedGroupMembers(cd); err == nil {
Guardian.Guard(func() (interface{}, error) {
_, err = Guardian.Guard(func() (interface{}, error) {
remainingDuration, err := cd.getMaxSessionDuration(account)
//log.Print("AFTER MAX SESSION: ", cd)
if err != nil || remainingDuration == 0 {
cc = cd.CreateCallCost()
if cd.GetDuration() == 0 {
cc = cd.CreateCallCost()
// add RatingInfo
err := cd.LoadRatingPlans()
if err == nil && len(cd.RatingInfos) > 0 {
@@ -714,7 +714,6 @@ func (cd *CallDescriptor) MaxDebit() (cc *CallCost, err error) {
}
return cc, nil
}
cc, err = new(CallCost), fmt.Errorf("no more credit: %v", err)
return 0, err
}
//log.Print("Remaining: ", remainingDuration)
@@ -727,6 +726,9 @@ func (cd *CallDescriptor) MaxDebit() (cc *CallCost, err error) {
//log.Print(balanceMap[0].Value, balanceMap[1].Value)
return 0, err
}, 0, memberIds...)
if err != nil {
return cc, err
}
} else {
return nil, err
}

View File

@@ -663,6 +663,28 @@ func TestMaxDebitRatingInfoOnZeroTime(t *testing.T) {
}
}
func TestMaxDebitUnknowDest(t *testing.T) {
ap, _ := ratingStorage.GetActionPlans("TOPUP10_AT", false)
for _, at := range ap {
at.Execute()
}
cd := &CallDescriptor{
Direction: "*out",
Category: "call",
Tenant: "cgrates.org",
Subject: "dy",
Account: "dy",
Destination: "9999999999",
TimeStart: time.Date(2015, 10, 26, 13, 29, 27, 0, time.UTC),
TimeEnd: time.Date(2015, 10, 26, 13, 29, 29, 0, time.UTC),
MaxCostSoFar: 0,
}
cc, err := cd.MaxDebit()
if err == nil {
t.Errorf("Bad error reported %+v: %v", cc, err)
}
}
func TestGetCostMaxDebitRoundingIssue(t *testing.T) {
ap, _ := ratingStorage.GetActionPlans("TOPUP10_AT", false)
for _, at := range ap {