diff --git a/apier/v1/suppliers_it_test.go b/apier/v1/suppliers_it_test.go
index fc7c770a6..73678b6e2 100644
--- a/apier/v1/suppliers_it_test.go
+++ b/apier/v1/suppliers_it_test.go
@@ -44,10 +44,10 @@ var sTestsSupplierSV1 = []func(t *testing.T){
testV1SplSLoadConfig,
testV1SplSInitDataDb,
testV1SplSResetStorDb,
- //testV1SplSStartEngine,
+ testV1SplSStartEngine,
testV1SplSRpcConn,
testV1SplSFromFolder,
- //testV1SplSGetWeightSuppliers,
+ testV1SplSGetWeightSuppliers,
testV1SplSGetLeastCostSuppliers,
testV1SplSStopEngine,
}
diff --git a/engine/spls_leastcost.go b/engine/spls_leastcost.go
index cca3dab3c..110596061 100644
--- a/engine/spls_leastcost.go
+++ b/engine/spls_leastcost.go
@@ -19,6 +19,8 @@ along with this program. If not, see
package engine
import (
+ "fmt"
+
"github.com/cgrates/cgrates/utils"
)
@@ -37,17 +39,22 @@ func (lcs *LeastCostSorter) SortSuppliers(prflID string,
suppls []*Supplier, ev *SupplierEvent) (sortedSuppls *SortedSuppliers, err error) {
sortedSuppls = &SortedSuppliers{ProfileID: prflID,
Sorting: lcs.sorting,
- SortedSuppliers: make([]*SortedSupplier, len(suppls))}
- for i, s := range suppls {
+ SortedSuppliers: make([]*SortedSupplier, 0)}
+ for _, s := range suppls {
ec, err := lcs.spS.costForEvent(ev, s.AccountIDs, s.RatingPlanIDs)
if err != nil {
return nil, err
+ } else if ec == nil {
+ utils.Logger.Warning(
+ fmt.Sprintf("<%s> profile: %s ignoring supplier with ID: %s, missing cost information",
+ utils.SupplierS, prflID, s.ID))
+ continue
}
- sortedSuppls.SortedSuppliers[i] = &SortedSupplier{
+ sortedSuppls.SortedSuppliers = append(sortedSuppls.SortedSuppliers, &SortedSupplier{
SupplierID: s.ID,
SortingData: map[string]interface{}{
utils.Weight: s.Weight,
- utils.Cost: ec.GetCost()}}
+ utils.Cost: ec.GetCost()}})
}
sortedSuppls.SortCost()
return
diff --git a/engine/suppliers.go b/engine/suppliers.go
index 0fd23cf0d..bd2b77f3e 100644
--- a/engine/suppliers.go
+++ b/engine/suppliers.go
@@ -19,7 +19,6 @@ along with this program. If not, see
package engine
import (
- "errors"
"fmt"
"sort"
"time"
@@ -229,7 +228,7 @@ func (spS *SupplierService) costForEvent(ev *SupplierEvent,
}
return NewEventCostFromCallCost(cc, "", ""), nil
}
- return nil, errors.New("no cost found")
+ return
}
// statMetrics will query a list of statIDs and return composed metric values