diff --git a/engine/action.go b/engine/action.go index 2f79ec33b..2b380b34d 100644 --- a/engine/action.go +++ b/engine/action.go @@ -1263,7 +1263,7 @@ func resetAccountCDR(ub *Account, action *Action, acts Actions, fltrS *FilterS, Value: &utils.ValueFormula{Static: bsum.Value}, Weight: &bsum.Weight, Disabled: &bsum.Disabled, - Factor: &bsum.Factor, + Factor: &bsum.Factors, }, }, fltrS); err != nil { utils.Logger.Warning(fmt.Sprintf("<%s> Error %s setting balance %s for account: %s", utils.Actions, err, bsum.UUID, account)) diff --git a/engine/balances.go b/engine/balances.go index 119aec1b6..ee7ef1b95 100644 --- a/engine/balances.go +++ b/engine/balances.go @@ -688,7 +688,7 @@ func (b *Balance) AsBalanceSummary(typ string) *BalanceSummary { Value: b.Value, Weight: b.Weight, Disabled: b.Disabled, - Factor: b.Factor, + Factors: b.Factor, } if bd.ID == "" { bd.ID = b.Uuid @@ -801,7 +801,7 @@ type BalanceSummary struct { Value float64 Weight float64 `json:",omitempty"` Disabled bool - Factor ValueFactor `json:",omitempty"` + Factors ValueFactor `json:",omitempty"` } // BalanceSummaries is a list of BalanceSummaries @@ -840,11 +840,11 @@ func (bl *BalanceSummary) FieldAsInterface(fldPath []string) (val any, err error return bl.Disabled, nil case utils.Initial: return bl.Initial, nil - case utils.Factor: + case utils.Factors: if len(fldPath) == 1 { - return bl.Factor, nil + return bl.Factors, nil } - return bl.Factor.FieldAsInterface(fldPath[1:]) + return bl.Factors.FieldAsInterface(fldPath[1:]) } } diff --git a/engine/eventcost_test.go b/engine/eventcost_test.go index 48fcdc2dc..2ff705ab2 100644 --- a/engine/eventcost_test.go +++ b/engine/eventcost_test.go @@ -112,7 +112,7 @@ var testEC = &EventCost{ Initial: 60, Weight: 20, Disabled: false, - Factor: ValueFactor{ + Factors: ValueFactor{ "factor2": 2, "factor3": 3, }, @@ -125,7 +125,7 @@ var testEC = &EventCost{ Weight: 0, Initial: 60, Disabled: false, - Factor: ValueFactor{ + Factors: ValueFactor{ "factor2": 2, }, }, @@ -137,7 +137,7 @@ var testEC = &EventCost{ Weight: 10, Initial: 250, Disabled: true, - Factor: ValueFactor{ + Factors: ValueFactor{ "factor4": 4, "factor5": 5, }, @@ -2542,7 +2542,7 @@ func TestECSyncKeys(t *testing.T) { Initial: 60, Weight: 20, Disabled: false, - Factor: ValueFactor{ + Factors: ValueFactor{ "factor2": 2, "factor3": 3, }, @@ -2555,7 +2555,7 @@ func TestECSyncKeys(t *testing.T) { Initial: 60, Weight: 0, Disabled: false, - Factor: ValueFactor{ + Factors: ValueFactor{ "factor2": 2, }, }, @@ -2567,7 +2567,7 @@ func TestECSyncKeys(t *testing.T) { Initial: 250, Weight: 10, Disabled: true, - Factor: ValueFactor{ + Factors: ValueFactor{ "factor4": 4, "factor5": 5, }, @@ -3901,12 +3901,12 @@ func TestECAsDataProvider3(t *testing.T) { }, { name: "Factor map", - fields: []string{"Charges[0]", "Increments[3]", "Accounting", "Balance", "Factor"}, + fields: []string{"Charges[0]", "Increments[3]", "Accounting", "Balance", "Factors"}, exp: `{"factor4":4,"factor5":5}`, }, { name: "Factor value", - fields: []string{"Charges[0]", "Increments[3]", "Accounting", "Balance", "Factor", "factor4"}, + fields: []string{"Charges[0]", "Increments[3]", "Accounting", "Balance", "Factors", "factor4"}, exp: "4", }, { @@ -4081,12 +4081,12 @@ func TestECAsDataProvider3(t *testing.T) { }, { name: "Factor map through ExtraCharge", - fields: []string{"Charges[0]", "Increments[3]", "Accounting", "ExtraCharge", "Balance", "Factor"}, + fields: []string{"Charges[0]", "Increments[3]", "Accounting", "ExtraCharge", "Balance", "Factors"}, exp: `{"factor2":2,"factor3":3}`, }, { name: "Factor value through ExtraCharge", - fields: []string{"Charges[0]", "Increments[3]", "Accounting", "ExtraCharge", "Balance", "Factor", "factor3"}, + fields: []string{"Charges[0]", "Increments[3]", "Accounting", "ExtraCharge", "Balance", "Factors", "factor3"}, exp: "3", }, { diff --git a/general_tests/balance_it_test.go b/general_tests/balance_it_test.go index 5db5fc0de..5c737ff6a 100644 --- a/general_tests/balance_it_test.go +++ b/general_tests/balance_it_test.go @@ -431,7 +431,7 @@ cgrates.org,call,1001,2014-01-14T00:00:00Z,RP_ANY,`, if monetaryBalanceValue != 4. { t.Errorf("unexpected balance value: expected %v, received %v", 4., monetaryBalanceValue) } - smsBalanceFactor, err := cdrs[0].CostDetails.FieldAsInterface([]string{"AccountSummary", "BalanceSummaries[0]", "Factor", "smsFactor"}) + smsBalanceFactor, err := cdrs[0].CostDetails.FieldAsInterface([]string{"AccountSummary", "BalanceSummaries[0]", "Factors", "smsFactor"}) if err != nil { t.Fatalf("could not retrieve *sms balance factor: %v", err) } diff --git a/general_tests/sessionpause_it_test.go b/general_tests/sessionpause_it_test.go index 3c5ed6361..40ebb0996 100644 --- a/general_tests/sessionpause_it_test.go +++ b/general_tests/sessionpause_it_test.go @@ -469,6 +469,7 @@ func testSesPauseItInitPause(t *testing.T) { Type: "*monetary", Initial: 10, Value: 9.8, + Weight: 10, }}, }, Rating: engine.Rating{ @@ -664,6 +665,7 @@ func testSesPauseItInitUpdatePause(t *testing.T) { Type: "*monetary", Initial: 9.8, Value: 9.6, + Weight: 10, }}, }, Rating: engine.Rating{ @@ -861,6 +863,7 @@ func testSesPauseItUpdatePause(t *testing.T) { Type: "*monetary", Initial: 9.6, Value: 9., + Weight: 10, }}, }, Rating: engine.Rating{ diff --git a/utils/consts.go b/utils/consts.go index f3f04d0ee..1f3f07853 100644 --- a/utils/consts.go +++ b/utils/consts.go @@ -877,6 +877,7 @@ const ( UnitFactors = "UnitFactors" CostIncrements = "CostIncrements" Factor = "Factor" + Factors = "Factors" Method = "Method" Static = "Static" Params = "Params"