From 7eeab045a3aec334df4b5636e77bbf19f69370ca Mon Sep 17 00:00:00 2001 From: ionutboangiu Date: Tue, 14 Nov 2023 06:14:43 -0500 Subject: [PATCH] Trim fldPath Increments before retrieving one of its fields --- engine/eventcost.go | 2 +- engine/eventcost_test.go | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/engine/eventcost.go b/engine/eventcost.go index b6a6232c3..ad16b5fe4 100644 --- a/engine/eventcost.go +++ b/engine/eventcost.go @@ -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) { diff --git a/engine/eventcost_test.go b/engine/eventcost_test.go index 086eef588..4e4cb2987 100644 --- a/engine/eventcost_test.go +++ b/engine/eventcost_test.go @@ -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"},