Rename Factor field to Factors in BalanceSummaries

This commit is contained in:
ionutboangiu
2024-03-22 15:16:50 -04:00
committed by Dan Christian Bogos
parent ea9b6ae83d
commit 45066b2d2f
6 changed files with 21 additions and 17 deletions

View File

@@ -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))

View File

@@ -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:])
}
}

View File

@@ -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",
},
{