Handle missing RatingPlanIDs for SuplierS HighestCost and LeastCost sorting . fixes #1389

This commit is contained in:
Trial97
2019-02-14 17:19:35 +02:00
committed by Dan Christian Bogos
parent f939753cbd
commit 4a9da1cb1a
2 changed files with 16 additions and 0 deletions

View File

@@ -19,6 +19,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
package engine
import (
"fmt"
"github.com/cgrates/cgrates/utils"
)
@@ -39,6 +41,12 @@ func (hcs *HightCostSorter) SortSuppliers(prflID string, suppls []*Supplier,
Sorting: hcs.sorting,
SortedSuppliers: make([]*SortedSupplier, 0)}
for _, s := range suppls {
if len(s.RatingPlanIDs) == 0 {
utils.Logger.Warning(
fmt.Sprintf("<%s> RatingPlanIDs is empty for suplier with ID: %s",
utils.SupplierS, s.ID))
return nil, utils.NewErrMandatoryIeMissing("RatingPlanIDs")
}
if srtSpl, pass, err := hcs.spS.populateSortingData(ev, s, extraOpts); err != nil {
return nil, err
} else if pass && srtSpl != nil {

View File

@@ -19,6 +19,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
package engine
import (
"fmt"
"github.com/cgrates/cgrates/utils"
)
@@ -39,6 +41,12 @@ func (lcs *LeastCostSorter) SortSuppliers(prflID string, suppls []*Supplier,
Sorting: lcs.sorting,
SortedSuppliers: make([]*SortedSupplier, 0)}
for _, s := range suppls {
if len(s.RatingPlanIDs) == 0 {
utils.Logger.Warning(
fmt.Sprintf("<%s> RatingPlanIDs is empty for suplier with ID: %s",
utils.SupplierS, s.ID))
return nil, utils.NewErrMandatoryIeMissing("RatingPlanIDs")
}
if srtSpl, pass, err := lcs.spS.populateSortingData(ev, s, extraOpts); err != nil {
return nil, err
} else if pass && srtSpl != nil {