Trim fldPath Increments before retrieving one of its fields

This commit is contained in:
ionutboangiu
2023-11-14 06:14:43 -05:00
committed by Dan Christian Bogos
parent 42892eff01
commit 7eeab045a3
2 changed files with 6 additions and 1 deletions

View File

@@ -1094,7 +1094,7 @@ func (ec *EventCost) getChargesForPath(fldPath []string, chr *ChargingInterval)
if fldPath[1] == utils.Accounting {
return ec.getAcountingForPath(fldPath[2:], ec.Accounting[incr.AccountingID])
}
return incr.FieldAsInterface(fldPath)
return incr.FieldAsInterface(fldPath[1:])
}
func (ec *EventCost) getRatingForPath(fldPath []string, rating *RatingUnit) (val any, err error) {

View File

@@ -3822,6 +3822,11 @@ func TestECAsDataProvider3(t *testing.T) {
fields: []string{"Charges[1]", "Increments[0]", "Accounting", "Balance", "Type"},
exp: "*monetary",
},
{
name: "IncrementCost",
fields: []string{"Charges[0]", "Increments[2]", "Cost"},
exp: "0.01",
},
{
name: "DestinationPrefix",
fields: []string{"Charges[2]", "Rating", "RatingFilter", "DestinationPrefix"},