mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-15 21:29:52 +05:00
renamed *periodic to *incremental
This commit is contained in:
@@ -30,14 +30,14 @@ func ParseBalanceFilterValue(val string) (*ValueFormula, error) {
|
||||
type valueFormula func(map[string]interface{}) float64
|
||||
|
||||
const (
|
||||
PERIODIC = "*periodic"
|
||||
INCREMENTAL = "*incremental"
|
||||
)
|
||||
|
||||
var ValueFormulas = map[string]valueFormula{
|
||||
PERIODIC: periodicFormula,
|
||||
INCREMENTAL: incrementalFormula,
|
||||
}
|
||||
|
||||
func periodicFormula(params map[string]interface{}) float64 {
|
||||
func incrementalFormula(params map[string]interface{}) float64 {
|
||||
// check parameters
|
||||
unitsInterface, unitsFound := params["Units"]
|
||||
intervalInterface, intervalFound := params["Interval"]
|
||||
|
||||
@@ -11,7 +11,7 @@ func TestValueFormulaDayWeek(t *testing.T) {
|
||||
if err := json.Unmarshal([]byte(`{"Units":10, "Interval":"week", "Increment":"day"}`), ¶ms); err != nil {
|
||||
t.Error("error unmarshalling params: ", err)
|
||||
}
|
||||
if x := periodicFormula(params); x != 10/7.0 {
|
||||
if x := incrementalFormula(params); x != 10/7.0 {
|
||||
t.Error("error caclulating value using formula: ", x)
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,7 @@ func TestValueFormulaDayMonth(t *testing.T) {
|
||||
t.Error("error unmarshalling params: ", err)
|
||||
}
|
||||
now := time.Now()
|
||||
if x := periodicFormula(params); x != 10/DaysInMonth(now.Year(), now.Month()) {
|
||||
if x := incrementalFormula(params); x != 10/DaysInMonth(now.Year(), now.Month()) {
|
||||
t.Error("error caclulating value using formula: ", x)
|
||||
}
|
||||
}
|
||||
@@ -33,7 +33,7 @@ func TestValueFormulaDayYear(t *testing.T) {
|
||||
t.Error("error unmarshalling params: ", err)
|
||||
}
|
||||
now := time.Now()
|
||||
if x := periodicFormula(params); x != 10/DaysInYear(now.Year()) {
|
||||
if x := incrementalFormula(params); x != 10/DaysInYear(now.Year()) {
|
||||
t.Error("error caclulating value using formula: ", x)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user