Add SuppliersMaxCost in freeswtich and kaamailio , fixes #1039 , fixes #1036

This commit is contained in:
TeoV
2018-04-10 07:43:37 -04:00
committed by Dan Christian Bogos
parent c3f4846055
commit 734a551903
7 changed files with 40 additions and 9 deletions

View File

@@ -56,7 +56,8 @@ func (lcs *LeastCostSorter) SortSuppliers(prflID string, suppls []*Supplier,
utils.SupplierS, prflID, s.ID))
continue
}
if extraOpts.maxCost != 0 && costData[utils.Cost].(float64) > extraOpts.maxCost {
if extraOpts.maxCost != 0 &&
costData[utils.Cost].(float64) > extraOpts.maxCost {
continue
}
srtData := map[string]interface{}{
@@ -65,10 +66,11 @@ func (lcs *LeastCostSorter) SortSuppliers(prflID string, suppls []*Supplier,
for k, v := range costData {
srtData[k] = v
}
sortedSuppls.SortedSuppliers = append(sortedSuppls.SortedSuppliers, &SortedSupplier{
SupplierID: s.ID,
SortingData: srtData,
SupplierParameters: s.SupplierParameters})
sortedSuppls.SortedSuppliers = append(sortedSuppls.SortedSuppliers,
&SortedSupplier{
SupplierID: s.ID,
SortingData: srtData,
SupplierParameters: s.SupplierParameters})
}
if len(sortedSuppls.SortedSuppliers) == 0 {
return nil, utils.ErrNotFound