mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-21 23:28:44 +05:00
@@ -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
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user