diff --git a/apier/v1/rateprofiles_it_test.go b/apier/v1/rateprofiles_it_test.go index d00f07815..ee2b097b7 100644 --- a/apier/v1/rateprofiles_it_test.go +++ b/apier/v1/rateprofiles_it_test.go @@ -147,9 +147,9 @@ func testV1RatePrfVerifyRateProfile(t *testing.T) { MaxCostStrategy: "*free", Rates: map[string]*engine.Rate{ "RT_WEEK": &engine.Rate{ - ID: "RT_WEEK", - Weight: 0, - ActivationStart: "* * * * 1-5", + ID: "RT_WEEK", + Weight: 0, + ActivationTime: "* * * * 1-5", IntervalRates: []*engine.IntervalRate{ &engine.IntervalRate{ IntervalStart: time.Duration(0 * time.Second), @@ -166,9 +166,9 @@ func testV1RatePrfVerifyRateProfile(t *testing.T) { }, }, "RT_WEEKEND": &engine.Rate{ - ID: "RT_WEEKEND", - Weight: 10, - ActivationStart: "* * * * 0,6", + ID: "RT_WEEKEND", + Weight: 10, + ActivationTime: "* * * * 0,6", IntervalRates: []*engine.IntervalRate{ &engine.IntervalRate{ IntervalStart: time.Duration(0 * time.Second), @@ -179,9 +179,9 @@ func testV1RatePrfVerifyRateProfile(t *testing.T) { }, }, "RT_CHRISTMAS": &engine.Rate{ - ID: "RT_CHRISTMAS", - Weight: 30, - ActivationStart: "* * 24 12 *", + ID: "RT_CHRISTMAS", + Weight: 30, + ActivationTime: "* * 24 12 *", IntervalRates: []*engine.IntervalRate{ &engine.IntervalRate{ IntervalStart: time.Duration(0 * time.Second), @@ -223,9 +223,9 @@ func testV1RatePrfSetRateProfileRates(t *testing.T) { MaxCostStrategy: "*free", Rates: map[string]*engine.Rate{ "RT_WEEK": &engine.Rate{ - ID: "RT_WEEK", - Weight: 0, - ActivationStart: "* * * * 1-5", + ID: "RT_WEEK", + Weight: 0, + ActivationTime: "* * * * 1-5", IntervalRates: []*engine.IntervalRate{ &engine.IntervalRate{ IntervalStart: time.Duration(0 * time.Second), @@ -253,9 +253,9 @@ func testV1RatePrfSetRateProfileRates(t *testing.T) { ID: "RP1", Rates: map[string]*engine.Rate{ "RT_WEEK": &engine.Rate{ - ID: "RT_WEEK", - Weight: 0, - ActivationStart: "* * * * 1-5", + ID: "RT_WEEK", + Weight: 0, + ActivationTime: "* * * * 1-5", IntervalRates: []*engine.IntervalRate{ &engine.IntervalRate{ IntervalStart: time.Duration(0 * time.Second), @@ -272,9 +272,9 @@ func testV1RatePrfSetRateProfileRates(t *testing.T) { }, }, "RT_WEEKEND": &engine.Rate{ - ID: "RT_WEEKEND", - Weight: 10, - ActivationStart: "* * * * 0,6", + ID: "RT_WEEKEND", + Weight: 10, + ActivationTime: "* * * * 0,6", IntervalRates: []*engine.IntervalRate{ &engine.IntervalRate{ IntervalStart: time.Duration(0 * time.Second), @@ -285,9 +285,9 @@ func testV1RatePrfSetRateProfileRates(t *testing.T) { }, }, "RT_CHRISTMAS": &engine.Rate{ - ID: "RT_CHRISTMAS", - Weight: 30, - ActivationStart: "* * 24 12 *", + ID: "RT_CHRISTMAS", + Weight: 30, + ActivationTime: "* * 24 12 *", IntervalRates: []*engine.IntervalRate{ &engine.IntervalRate{ IntervalStart: time.Duration(0 * time.Second), @@ -322,9 +322,9 @@ func testV1RatePrfSetRateProfileRates(t *testing.T) { MaxCostStrategy: "*free", Rates: map[string]*engine.Rate{ "RT_WEEK": &engine.Rate{ - ID: "RT_WEEK", - Weight: 0, - ActivationStart: "* * * * 1-5", + ID: "RT_WEEK", + Weight: 0, + ActivationTime: "* * * * 1-5", IntervalRates: []*engine.IntervalRate{ &engine.IntervalRate{ IntervalStart: time.Duration(0 * time.Second), @@ -341,9 +341,9 @@ func testV1RatePrfSetRateProfileRates(t *testing.T) { }, }, "RT_WEEKEND": &engine.Rate{ - ID: "RT_WEEKEND", - Weight: 10, - ActivationStart: "* * * * 0,6", + ID: "RT_WEEKEND", + Weight: 10, + ActivationTime: "* * * * 0,6", IntervalRates: []*engine.IntervalRate{ &engine.IntervalRate{ IntervalStart: time.Duration(0 * time.Second), @@ -354,9 +354,9 @@ func testV1RatePrfSetRateProfileRates(t *testing.T) { }, }, "RT_CHRISTMAS": &engine.Rate{ - ID: "RT_CHRISTMAS", - Weight: 30, - ActivationStart: "* * 24 12 *", + ID: "RT_CHRISTMAS", + Weight: 30, + ActivationTime: "* * 24 12 *", IntervalRates: []*engine.IntervalRate{ &engine.IntervalRate{ IntervalStart: time.Duration(0 * time.Second), @@ -393,9 +393,9 @@ func testV1RatePrfRemoveRateProfileRates(t *testing.T) { MaxCostStrategy: "*free", Rates: map[string]*engine.Rate{ "RT_WEEK": &engine.Rate{ - ID: "RT_WEEK", - Weight: 0, - ActivationStart: "* * * * 1-5", + ID: "RT_WEEK", + Weight: 0, + ActivationTime: "* * * * 1-5", IntervalRates: []*engine.IntervalRate{ &engine.IntervalRate{ IntervalStart: time.Duration(0 * time.Second), @@ -412,9 +412,9 @@ func testV1RatePrfRemoveRateProfileRates(t *testing.T) { }, }, "RT_WEEKEND": &engine.Rate{ - ID: "RT_WEEKEND", - Weight: 10, - ActivationStart: "* * * * 0,6", + ID: "RT_WEEKEND", + Weight: 10, + ActivationTime: "* * * * 0,6", IntervalRates: []*engine.IntervalRate{ &engine.IntervalRate{ IntervalStart: time.Duration(0 * time.Second), @@ -425,9 +425,9 @@ func testV1RatePrfRemoveRateProfileRates(t *testing.T) { }, }, "RT_CHRISTMAS": &engine.Rate{ - ID: "RT_CHRISTMAS", - Weight: 30, - ActivationStart: "* * 24 12 *", + ID: "RT_CHRISTMAS", + Weight: 30, + ActivationTime: "* * 24 12 *", IntervalRates: []*engine.IntervalRate{ &engine.IntervalRate{ IntervalStart: time.Duration(0 * time.Second), @@ -474,9 +474,9 @@ func testV1RatePrfRemoveRateProfileRates(t *testing.T) { MaxCostStrategy: "*free", Rates: map[string]*engine.Rate{ "RT_WEEK": &engine.Rate{ - ID: "RT_WEEK", - Weight: 0, - ActivationStart: "* * * * 1-5", + ID: "RT_WEEK", + Weight: 0, + ActivationTime: "* * * * 1-5", IntervalRates: []*engine.IntervalRate{ &engine.IntervalRate{ IntervalStart: time.Duration(0 * time.Second), @@ -493,9 +493,9 @@ func testV1RatePrfRemoveRateProfileRates(t *testing.T) { }, }, "RT_CHRISTMAS": &engine.Rate{ - ID: "RT_CHRISTMAS", - Weight: 30, - ActivationStart: "* * 24 12 *", + ID: "RT_CHRISTMAS", + Weight: 30, + ActivationTime: "* * 24 12 *", IntervalRates: []*engine.IntervalRate{ &engine.IntervalRate{ IntervalStart: time.Duration(0 * time.Second), diff --git a/apier/v1/remote_it_test.go b/apier/v1/remote_it_test.go index b743b665c..b550b2321 100644 --- a/apier/v1/remote_it_test.go +++ b/apier/v1/remote_it_test.go @@ -727,9 +727,9 @@ func testInternalRemoteITGetRouteProfile(t *testing.T) { MaxCostStrategy: "*free", Rates: map[string]*engine.Rate{ "RT_WEEK": &engine.Rate{ - ID: "RT_WEEK", - Weight: 0, - ActivationStart: "* * * * 1-5", + ID: "RT_WEEK", + Weight: 0, + ActivationTime: "* * * * 1-5", IntervalRates: []*engine.IntervalRate{ &engine.IntervalRate{ IntervalStart: time.Duration(0 * time.Second), @@ -746,9 +746,9 @@ func testInternalRemoteITGetRouteProfile(t *testing.T) { }, }, "RT_WEEKEND": &engine.Rate{ - ID: "RT_WEEKEND", - Weight: 10, - ActivationStart: "* * * * 0,6", + ID: "RT_WEEKEND", + Weight: 10, + ActivationTime: "* * * * 0,6", IntervalRates: []*engine.IntervalRate{ &engine.IntervalRate{ IntervalStart: time.Duration(0 * time.Second), @@ -759,9 +759,9 @@ func testInternalRemoteITGetRouteProfile(t *testing.T) { }, }, "RT_CHRISTMAS": &engine.Rate{ - ID: "RT_CHRISTMAS", - Weight: 30, - ActivationStart: "* * 24 12 *", + ID: "RT_CHRISTMAS", + Weight: 30, + ActivationTime: "* * 24 12 *", IntervalRates: []*engine.IntervalRate{ &engine.IntervalRate{ IntervalStart: time.Duration(0 * time.Second), diff --git a/apier/v1/replicate_it_test.go b/apier/v1/replicate_it_test.go index 9ec093097..257119981 100644 --- a/apier/v1/replicate_it_test.go +++ b/apier/v1/replicate_it_test.go @@ -1365,9 +1365,9 @@ func testInternalReplicateITRateProfile(t *testing.T) { MaxCostStrategy: "*free", Rates: map[string]*engine.Rate{ "RT_WEEK": &engine.Rate{ - ID: "RT_WEEK", - Weight: 0, - ActivationStart: "* * * * 1-5", + ID: "RT_WEEK", + Weight: 0, + ActivationTime: "* * * * 1-5", IntervalRates: []*engine.IntervalRate{ &engine.IntervalRate{ IntervalStart: time.Duration(0 * time.Second), @@ -1384,9 +1384,9 @@ func testInternalReplicateITRateProfile(t *testing.T) { }, }, "RT_WEEKEND": &engine.Rate{ - ID: "RT_WEEKEND", - Weight: 10, - ActivationStart: "* * * * 0,6", + ID: "RT_WEEKEND", + Weight: 10, + ActivationTime: "* * * * 0,6", IntervalRates: []*engine.IntervalRate{ &engine.IntervalRate{ IntervalStart: time.Duration(0 * time.Second), @@ -1397,9 +1397,9 @@ func testInternalReplicateITRateProfile(t *testing.T) { }, }, "RT_CHRISTMAS": &engine.Rate{ - ID: "RT_CHRISTMAS", - Weight: 30, - ActivationStart: "* * 24 12 *", + ID: "RT_CHRISTMAS", + Weight: 30, + ActivationTime: "* * 24 12 *", IntervalRates: []*engine.IntervalRate{ &engine.IntervalRate{ IntervalStart: time.Duration(0 * time.Second), diff --git a/data/storage/mysql/create_tariffplan_tables.sql b/data/storage/mysql/create_tariffplan_tables.sql index a4f97890a..8c4e20a71 100644 --- a/data/storage/mysql/create_tariffplan_tables.sql +++ b/data/storage/mysql/create_tariffplan_tables.sql @@ -490,7 +490,7 @@ CREATE TABLE tp_rate_profiles ( `max_cost_strategy` varchar(64) NOT NULL, `rate_id` varchar(32) NOT NULL, `rate_filter_ids` varchar(64) NOT NULL, - `rate_activation_start` varchar(64) NOT NULL, + `rate_activation_time` varchar(64) NOT NULL, `route_weight` decimal(8,2) NOT NULL, `rate_blocker` BOOLEAN NOT NULL, `rate_interval_start` varchar(64) NOT NULL, diff --git a/data/storage/postgres/create_tariffplan_tables.sql b/data/storage/postgres/create_tariffplan_tables.sql index 26c08d518..661a46883 100644 --- a/data/storage/postgres/create_tariffplan_tables.sql +++ b/data/storage/postgres/create_tariffplan_tables.sql @@ -476,7 +476,7 @@ CREATE INDEX tp_routes_unique ON tp_routes ("tpid", "tenant", "id", "max_cost_strategy" VARCHAR(64) NOT NULL, "rate_id" VARCHAR(64) NOT NULL, "rate_filter_ids" VARCHAR(64) NOT NULL, - "rate_activation_start" VARCHAR(64) NOT NULL, + "rate_activation_time" VARCHAR(64) NOT NULL, "rate_weight" decimal(8,2) NOT NULL, "rate_blocker" BOOLEAN NOT NULL, "rate_interval_start" VARCHAR(64) NOT NULL, diff --git a/engine/loader_csv_test.go b/engine/loader_csv_test.go index 7fbdba06e..a0976731b 100644 --- a/engine/loader_csv_test.go +++ b/engine/loader_csv_test.go @@ -1427,9 +1427,9 @@ func TestLoadRateProfiles(t *testing.T) { MaxCostStrategy: "*free", Rates: map[string]*utils.TPRate{ "RT_WEEK": &utils.TPRate{ - ID: "RT_WEEK", - Weight: 0, - ActivationStart: "* * * * 1-5", + ID: "RT_WEEK", + Weight: 0, + ActivationTime: "* * * * 1-5", IntervalRates: []*utils.TPIntervalRate{ &utils.TPIntervalRate{ IntervalStart: "0s", @@ -1446,9 +1446,9 @@ func TestLoadRateProfiles(t *testing.T) { }, }, "RT_WEEKEND": &utils.TPRate{ - ID: "RT_WEEKEND", - Weight: 10, - ActivationStart: "* * * * 0,6", + ID: "RT_WEEKEND", + Weight: 10, + ActivationTime: "* * * * 0,6", IntervalRates: []*utils.TPIntervalRate{ &utils.TPIntervalRate{ IntervalStart: "0s", @@ -1459,9 +1459,9 @@ func TestLoadRateProfiles(t *testing.T) { }, }, "RT_CHRISTMAS": &utils.TPRate{ - ID: "RT_CHRISTMAS", - Weight: 30, - ActivationStart: "* * 24 12 *", + ID: "RT_CHRISTMAS", + Weight: 30, + ActivationTime: "* * 24 12 *", IntervalRates: []*utils.TPIntervalRate{ &utils.TPIntervalRate{ IntervalStart: "0s", diff --git a/engine/model_helpers.go b/engine/model_helpers.go index 9ab03df73..85f0442cf 100644 --- a/engine/model_helpers.go +++ b/engine/model_helpers.go @@ -3046,7 +3046,7 @@ func (tps RateProfileMdls) AsTPRateProfile() (result []*utils.TPRateProfile) { rate.FilterIDs = append(rate.FilterIDs, rateFilterSplit...) } if tp.RateActivationStart != utils.EmptyString { - rate.ActivationStart = tp.RateActivationStart + rate.ActivationTime = tp.RateActivationStart } if tp.RateWeight != 0 { rate.Weight = tp.RateWeight @@ -3169,7 +3169,7 @@ func APItoModelTPRateProfile(tPrf *utils.TPRateProfile) (mdls RateProfileMdls) { mdl.RateFilterIDs += val } mdl.RateWeight = rate.Weight - mdl.RateActivationStart = rate.ActivationStart + mdl.RateActivationStart = rate.ActivationTime mdl.RateBlocker = rate.Blocker } @@ -3209,12 +3209,12 @@ func APItoRateProfile(tpRp *utils.TPRateProfile, timezone string) (rp *RateProfi } for key, rate := range tpRp.Rates { rp.Rates[key] = &Rate{ - ID: rate.ID, - Weight: rate.Weight, - Blocker: rate.Blocker, - FilterIDs: rate.FilterIDs, - ActivationStart: rate.ActivationStart, - IntervalRates: make([]*IntervalRate, len(rate.IntervalRates)), + ID: rate.ID, + Weight: rate.Weight, + Blocker: rate.Blocker, + FilterIDs: rate.FilterIDs, + ActivationTime: rate.ActivationTime, + IntervalRates: make([]*IntervalRate, len(rate.IntervalRates)), } for i, iRate := range rate.IntervalRates { rp.Rates[key].IntervalRates[i] = new(IntervalRate) @@ -3251,12 +3251,12 @@ func RateProfileToAPI(rp *RateProfile) (tpRp *utils.TPRateProfile) { for key, rate := range rp.Rates { tpRp.Rates[key] = &utils.TPRate{ - ID: rate.ID, - Weight: rate.Weight, - Blocker: rate.Blocker, - FilterIDs: rate.FilterIDs, - ActivationStart: rate.ActivationStart, - IntervalRates: make([]*utils.TPIntervalRate, len(rate.IntervalRates)), + ID: rate.ID, + Weight: rate.Weight, + Blocker: rate.Blocker, + FilterIDs: rate.FilterIDs, + ActivationTime: rate.ActivationTime, + IntervalRates: make([]*utils.TPIntervalRate, len(rate.IntervalRates)), } for i, iRate := range rate.IntervalRates { tpRp.Rates[key].IntervalRates[i] = &utils.TPIntervalRate{ diff --git a/engine/model_helpers_test.go b/engine/model_helpers_test.go index 8b126dc3e..53fa7ad23 100644 --- a/engine/model_helpers_test.go +++ b/engine/model_helpers_test.go @@ -252,6 +252,110 @@ func TestMapTPTimings(t *testing.T) { } } +func TestMapTPRates(t *testing.T) { + s := []*utils.TPRateRALs{} + eOut := map[string]*utils.TPRateRALs{} + if rcv, err := MapTPRates(s); err != nil { + t.Error(err) + } else if !reflect.DeepEqual(eOut, rcv) { + t.Errorf("Expecting: %+v, received: %+v", utils.ToJSON(eOut), utils.ToJSON(rcv)) + } + + s = []*utils.TPRateRALs{ + &utils.TPRateRALs{ + ID: "ID", + TPid: "TPid", + RateSlots: []*utils.RateSlot{ + { + ConnectFee: 0.100, + Rate: 0.200, + RateUnit: "60", + RateIncrement: "60", + GroupIntervalStart: "0"}, + { + ConnectFee: 0.0, + Rate: 0.1, + RateUnit: "1", + RateIncrement: "60", + GroupIntervalStart: "60"}, + }, + }, + } + eOut = map[string]*utils.TPRateRALs{ + "ID": { + TPid: "TPid", + ID: "ID", + RateSlots: []*utils.RateSlot{ + { + ConnectFee: 0.1, + Rate: 0.2, + RateUnit: "60", + RateIncrement: "60", + GroupIntervalStart: "0", + }, { + ConnectFee: 0, + Rate: 0.1, + RateUnit: "1", + RateIncrement: "60", + GroupIntervalStart: "60", + }, + }, + }, + } + if rcv, err := MapTPRates(s); err != nil { + t.Error(err) + } else if !reflect.DeepEqual(eOut, rcv) { + t.Errorf("Expecting: %+v, received: %+v", utils.ToJSON(eOut), utils.ToJSON(rcv)) + } + + s = []*utils.TPRateRALs{ + &utils.TPRateRALs{ + ID: "", + TPid: "", + RateSlots: []*utils.RateSlot{ + {ConnectFee: 0.8}, + {ConnectFee: 0.7}, + }, + }, + } + eOut = map[string]*utils.TPRateRALs{ + "": { + TPid: "", + ID: "", + RateSlots: []*utils.RateSlot{ + {ConnectFee: 0.8}, + {ConnectFee: 0.7}, + }, + }, + } + if rcv, err := MapTPRates(s); err != nil { + t.Error(err) + } else if !reflect.DeepEqual(eOut, rcv) { + t.Errorf("Expecting: %+v, received: %+v", utils.ToJSON(eOut), utils.ToJSON(rcv)) + } + s = []*utils.TPRateRALs{ + &utils.TPRateRALs{ + ID: "SameID", + TPid: "", + RateSlots: []*utils.RateSlot{ + {ConnectFee: 0.8}, + {ConnectFee: 0.7}, + }, + }, + &utils.TPRateRALs{ + ID: "SameID", + TPid: "", + RateSlots: []*utils.RateSlot{ + {ConnectFee: 0.9}, + {ConnectFee: 0.1}, + }, + }, + } + if _, err := MapTPRates(s); err == nil || err.Error() != "Non unique ID SameID" { + t.Error(err) + } +} + func TestAPItoModelTimings(t *testing.T) { ts := []*utils.ApierTPTiming{} eOut := TpTimings{} @@ -2873,9 +2977,9 @@ func TestRateProfileToAPI(t *testing.T) { MaxCostStrategy: "*free", Rates: map[string]*Rate{ "RT_WEEK": &Rate{ - ID: "RT_WEEK", - Weight: 0, - ActivationStart: "* * * * 1-5", + ID: "RT_WEEK", + Weight: 0, + ActivationTime: "* * * * 1-5", IntervalRates: []*IntervalRate{ &IntervalRate{ IntervalStart: time.Duration(0 * time.Second), @@ -2892,9 +2996,9 @@ func TestRateProfileToAPI(t *testing.T) { }, }, "RT_WEEKEND": &Rate{ - ID: "RT_WEEKEND", - Weight: 10, - ActivationStart: "* * * * 0,6", + ID: "RT_WEEKEND", + Weight: 10, + ActivationTime: "* * * * 0,6", IntervalRates: []*IntervalRate{ &IntervalRate{ IntervalStart: time.Duration(0 * time.Second), @@ -2905,9 +3009,9 @@ func TestRateProfileToAPI(t *testing.T) { }, }, "RT_CHRISTMAS": &Rate{ - ID: "RT_CHRISTMAS", - Weight: 30, - ActivationStart: "* * 24 12 *", + ID: "RT_CHRISTMAS", + Weight: 30, + ActivationTime: "* * 24 12 *", IntervalRates: []*IntervalRate{ &IntervalRate{ IntervalStart: time.Duration(0 * time.Second), @@ -2933,9 +3037,9 @@ func TestRateProfileToAPI(t *testing.T) { MaxCostStrategy: "*free", Rates: map[string]*utils.TPRate{ "RT_WEEK": &utils.TPRate{ - ID: "RT_WEEK", - Weight: 0, - ActivationStart: "* * * * 1-5", + ID: "RT_WEEK", + Weight: 0, + ActivationTime: "* * * * 1-5", IntervalRates: []*utils.TPIntervalRate{ &utils.TPIntervalRate{ IntervalStart: "0s", @@ -2952,9 +3056,9 @@ func TestRateProfileToAPI(t *testing.T) { }, }, "RT_WEEKEND": &utils.TPRate{ - ID: "RT_WEEKEND", - Weight: 10, - ActivationStart: "* * * * 0,6", + ID: "RT_WEEKEND", + Weight: 10, + ActivationTime: "* * * * 0,6", IntervalRates: []*utils.TPIntervalRate{ &utils.TPIntervalRate{ IntervalStart: "0s", @@ -2965,9 +3069,9 @@ func TestRateProfileToAPI(t *testing.T) { }, }, "RT_CHRISTMAS": &utils.TPRate{ - ID: "RT_CHRISTMAS", - Weight: 30, - ActivationStart: "* * 24 12 *", + ID: "RT_CHRISTMAS", + Weight: 30, + ActivationTime: "* * 24 12 *", IntervalRates: []*utils.TPIntervalRate{ &utils.TPIntervalRate{ IntervalStart: "0s", @@ -2998,9 +3102,9 @@ func TestAPIToRateProfile(t *testing.T) { MaxCostStrategy: "*free", Rates: map[string]*Rate{ "RT_WEEK": &Rate{ - ID: "RT_WEEK", - Weight: 0, - ActivationStart: "* * * * 1-5", + ID: "RT_WEEK", + Weight: 0, + ActivationTime: "* * * * 1-5", IntervalRates: []*IntervalRate{ &IntervalRate{ IntervalStart: time.Duration(0 * time.Second), @@ -3017,9 +3121,9 @@ func TestAPIToRateProfile(t *testing.T) { }, }, "RT_WEEKEND": &Rate{ - ID: "RT_WEEKEND", - Weight: 10, - ActivationStart: "* * * * 0,6", + ID: "RT_WEEKEND", + Weight: 10, + ActivationTime: "* * * * 0,6", IntervalRates: []*IntervalRate{ &IntervalRate{ IntervalStart: time.Duration(0 * time.Second), @@ -3030,9 +3134,9 @@ func TestAPIToRateProfile(t *testing.T) { }, }, "RT_CHRISTMAS": &Rate{ - ID: "RT_CHRISTMAS", - Weight: 30, - ActivationStart: "* * 24 12 *", + ID: "RT_CHRISTMAS", + Weight: 30, + ActivationTime: "* * 24 12 *", IntervalRates: []*IntervalRate{ &IntervalRate{ IntervalStart: time.Duration(0 * time.Second), @@ -3058,9 +3162,9 @@ func TestAPIToRateProfile(t *testing.T) { MaxCostStrategy: "*free", Rates: map[string]*utils.TPRate{ "RT_WEEK": &utils.TPRate{ - ID: "RT_WEEK", - Weight: 0, - ActivationStart: "* * * * 1-5", + ID: "RT_WEEK", + Weight: 0, + ActivationTime: "* * * * 1-5", IntervalRates: []*utils.TPIntervalRate{ &utils.TPIntervalRate{ IntervalStart: "0s", @@ -3077,9 +3181,9 @@ func TestAPIToRateProfile(t *testing.T) { }, }, "RT_WEEKEND": &utils.TPRate{ - ID: "RT_WEEKEND", - Weight: 10, - ActivationStart: "* * * * 0,6", + ID: "RT_WEEKEND", + Weight: 10, + ActivationTime: "* * * * 0,6", IntervalRates: []*utils.TPIntervalRate{ &utils.TPIntervalRate{ IntervalStart: "0s", @@ -3090,9 +3194,9 @@ func TestAPIToRateProfile(t *testing.T) { }, }, "RT_CHRISTMAS": &utils.TPRate{ - ID: "RT_CHRISTMAS", - Weight: 30, - ActivationStart: "* * 24 12 *", + ID: "RT_CHRISTMAS", + Weight: 30, + ActivationTime: "* * 24 12 *", IntervalRates: []*utils.TPIntervalRate{ &utils.TPIntervalRate{ IntervalStart: "0s", @@ -3126,9 +3230,9 @@ func TestAPItoModelTPRateProfile(t *testing.T) { MaxCostStrategy: "*free", Rates: map[string]*utils.TPRate{ "RT_WEEK": &utils.TPRate{ - ID: "RT_WEEK", - Weight: 0, - ActivationStart: "* * * * 1-5", + ID: "RT_WEEK", + Weight: 0, + ActivationTime: "* * * * 1-5", IntervalRates: []*utils.TPIntervalRate{ &utils.TPIntervalRate{ IntervalStart: "0s", @@ -3325,9 +3429,9 @@ func TestAsTPRateProfile(t *testing.T) { MaxCostStrategy: "*free", Rates: map[string]*utils.TPRate{ "RT_WEEK": &utils.TPRate{ - ID: "RT_WEEK", - Weight: 0, - ActivationStart: "* * * * 1-5", + ID: "RT_WEEK", + Weight: 0, + ActivationTime: "* * * * 1-5", IntervalRates: []*utils.TPIntervalRate{ &utils.TPIntervalRate{ IntervalStart: "1m", diff --git a/engine/rateprofile.go b/engine/rateprofile.go index 2a7cb2f50..34575c81c 100644 --- a/engine/rateprofile.go +++ b/engine/rateprofile.go @@ -63,18 +63,18 @@ func (rp *RateProfile) Compile() (err error) { // Route defines rate related information used within a RateProfile type Rate struct { - ID string // RateID - FilterIDs []string // RateFilterIDs - ActivationStart string //TPActivationInterval have ATime and ETime as strings - Weight float64 // RateWeight will decide the winner per interval start - Blocker bool // RateBlocker will make this rate recurrent, deactivating further intervals - IntervalRates []*IntervalRate + ID string // RateID + FilterIDs []string // RateFilterIDs + ActivationTime string //TPActivationInterval have ATime and ETime as strings + Weight float64 // RateWeight will decide the winner per interval start + Blocker bool // RateBlocker will make this rate recurrent, deactivating further intervals + IntervalRates []*IntervalRate aTime cron.Schedule // compiled version of activation time as cron.Schedule interface } func (rt *Rate) Compile() (err error) { - aTime := rt.ActivationStart + aTime := rt.ActivationTime if aTime == utils.EmptyString { aTime = "* * * * *" } diff --git a/loaders/loader_test.go b/loaders/loader_test.go index 8bbb6c8b9..8e27ca514 100644 --- a/loaders/loader_test.go +++ b/loaders/loader_test.go @@ -1345,9 +1345,9 @@ func TestLoaderProcessRateProfile(t *testing.T) { MaxCostStrategy: "*free", Rates: map[string]*engine.Rate{ "RT_WEEK": &engine.Rate{ - ID: "RT_WEEK", - Weight: 0, - ActivationStart: "* * * * 1-5", + ID: "RT_WEEK", + Weight: 0, + ActivationTime: "* * * * 1-5", IntervalRates: []*engine.IntervalRate{ &engine.IntervalRate{ IntervalStart: time.Duration(0 * time.Second), @@ -1364,9 +1364,9 @@ func TestLoaderProcessRateProfile(t *testing.T) { }, }, "RT_WEEKEND": &engine.Rate{ - ID: "RT_WEEKEND", - Weight: 10, - ActivationStart: "* * * * 0,6", + ID: "RT_WEEKEND", + Weight: 10, + ActivationTime: "* * * * 0,6", IntervalRates: []*engine.IntervalRate{ &engine.IntervalRate{ IntervalStart: time.Duration(0 * time.Second), @@ -1377,9 +1377,9 @@ func TestLoaderProcessRateProfile(t *testing.T) { }, }, "RT_CHRISTMAS": &engine.Rate{ - ID: "RT_CHRISTMAS", - Weight: 30, - ActivationStart: "* * 24 12 *", + ID: "RT_CHRISTMAS", + Weight: 30, + ActivationTime: "* * 24 12 *", IntervalRates: []*engine.IntervalRate{ &engine.IntervalRate{ IntervalStart: time.Duration(0 * time.Second), @@ -1532,9 +1532,9 @@ cgrates.org,RP1,,,,,,,,,,RT_CHRISTMAS,,* * 24 12 *,30,false,0s,0.06,1m,1s MaxCostStrategy: "*free", Rates: map[string]*engine.Rate{ "RT_WEEK": &engine.Rate{ - ID: "RT_WEEK", - Weight: 0, - ActivationStart: "* * * * 1-5", + ID: "RT_WEEK", + Weight: 0, + ActivationTime: "* * * * 1-5", IntervalRates: []*engine.IntervalRate{ &engine.IntervalRate{ IntervalStart: time.Duration(0 * time.Second), @@ -1591,9 +1591,9 @@ cgrates.org,RP1,,,,,,,,,,RT_CHRISTMAS,,* * 24 12 *,30,false,0s,0.06,1m,1s MaxCostStrategy: "*free", Rates: map[string]*engine.Rate{ "RT_WEEK": &engine.Rate{ - ID: "RT_WEEK", - Weight: 0, - ActivationStart: "* * * * 1-5", + ID: "RT_WEEK", + Weight: 0, + ActivationTime: "* * * * 1-5", IntervalRates: []*engine.IntervalRate{ &engine.IntervalRate{ IntervalStart: time.Duration(0 * time.Second), @@ -1610,9 +1610,9 @@ cgrates.org,RP1,,,,,,,,,,RT_CHRISTMAS,,* * 24 12 *,30,false,0s,0.06,1m,1s }, }, "RT_WEEKEND": &engine.Rate{ - ID: "RT_WEEKEND", - Weight: 10, - ActivationStart: "* * * * 0,6", + ID: "RT_WEEKEND", + Weight: 10, + ActivationTime: "* * * * 0,6", IntervalRates: []*engine.IntervalRate{ &engine.IntervalRate{ IntervalStart: time.Duration(0 * time.Second), @@ -1623,9 +1623,9 @@ cgrates.org,RP1,,,,,,,,,,RT_CHRISTMAS,,* * 24 12 *,30,false,0s,0.06,1m,1s }, }, "RT_CHRISTMAS": &engine.Rate{ - ID: "RT_CHRISTMAS", - Weight: 30, - ActivationStart: "* * 24 12 *", + ID: "RT_CHRISTMAS", + Weight: 30, + ActivationTime: "* * 24 12 *", IntervalRates: []*engine.IntervalRate{ &engine.IntervalRate{ IntervalStart: time.Duration(0 * time.Second), @@ -1687,9 +1687,9 @@ func TestLoaderRemoveRateProfileRates(t *testing.T) { MaxCostStrategy: "*free", Rates: map[string]*engine.Rate{ "RT_WEEK": &engine.Rate{ - ID: "RT_WEEK", - Weight: 0, - ActivationStart: "* * * * 1-5", + ID: "RT_WEEK", + Weight: 0, + ActivationTime: "* * * * 1-5", IntervalRates: []*engine.IntervalRate{ &engine.IntervalRate{ IntervalStart: time.Duration(0 * time.Second), @@ -1706,9 +1706,9 @@ func TestLoaderRemoveRateProfileRates(t *testing.T) { }, }, "RT_WEEKEND": &engine.Rate{ - ID: "RT_WEEKEND", - Weight: 10, - ActivationStart: "* * * * 0,6", + ID: "RT_WEEKEND", + Weight: 10, + ActivationTime: "* * * * 0,6", IntervalRates: []*engine.IntervalRate{ &engine.IntervalRate{ IntervalStart: time.Duration(0 * time.Second), @@ -1719,9 +1719,9 @@ func TestLoaderRemoveRateProfileRates(t *testing.T) { }, }, "RT_CHRISTMAS": &engine.Rate{ - ID: "RT_CHRISTMAS", - Weight: 30, - ActivationStart: "* * 24 12 *", + ID: "RT_CHRISTMAS", + Weight: 30, + ActivationTime: "* * 24 12 *", IntervalRates: []*engine.IntervalRate{ &engine.IntervalRate{ IntervalStart: time.Duration(0 * time.Second), @@ -1749,9 +1749,9 @@ func TestLoaderRemoveRateProfileRates(t *testing.T) { MaxCostStrategy: "*free", Rates: map[string]*engine.Rate{ "RT_WEEK": &engine.Rate{ - ID: "RT_WEEK", - Weight: 0, - ActivationStart: "* * * * 1-5", + ID: "RT_WEEK", + Weight: 0, + ActivationTime: "* * * * 1-5", IntervalRates: []*engine.IntervalRate{ &engine.IntervalRate{ IntervalStart: time.Duration(0 * time.Second), @@ -1768,9 +1768,9 @@ func TestLoaderRemoveRateProfileRates(t *testing.T) { }, }, "RT_WEEKEND": &engine.Rate{ - ID: "RT_WEEKEND", - Weight: 10, - ActivationStart: "* * * * 0,6", + ID: "RT_WEEKEND", + Weight: 10, + ActivationTime: "* * * * 0,6", IntervalRates: []*engine.IntervalRate{ &engine.IntervalRate{ IntervalStart: time.Duration(0 * time.Second), @@ -1781,9 +1781,9 @@ func TestLoaderRemoveRateProfileRates(t *testing.T) { }, }, "RT_CHRISTMAS": &engine.Rate{ - ID: "RT_CHRISTMAS", - Weight: 30, - ActivationStart: "* * 24 12 *", + ID: "RT_CHRISTMAS", + Weight: 30, + ActivationTime: "* * 24 12 *", IntervalRates: []*engine.IntervalRate{ &engine.IntervalRate{ IntervalStart: time.Duration(0 * time.Second), @@ -1841,9 +1841,9 @@ cgrates.org,RP1, MaxCostStrategy: "*free", Rates: map[string]*engine.Rate{ "RT_WEEK": &engine.Rate{ - ID: "RT_WEEK", - Weight: 0, - ActivationStart: "* * * * 1-5", + ID: "RT_WEEK", + Weight: 0, + ActivationTime: "* * * * 1-5", IntervalRates: []*engine.IntervalRate{ &engine.IntervalRate{ IntervalStart: time.Duration(0 * time.Second), @@ -1860,9 +1860,9 @@ cgrates.org,RP1, }, }, "RT_CHRISTMAS": &engine.Rate{ - ID: "RT_CHRISTMAS", - Weight: 30, - ActivationStart: "* * 24 12 *", + ID: "RT_CHRISTMAS", + Weight: 30, + ActivationTime: "* * 24 12 *", IntervalRates: []*engine.IntervalRate{ &engine.IntervalRate{ IntervalStart: time.Duration(0 * time.Second), @@ -1914,9 +1914,9 @@ cgrates.org,RP1, MaxCostStrategy: "*free", Rates: map[string]*engine.Rate{ "RT_WEEK": &engine.Rate{ - ID: "RT_WEEK", - Weight: 0, - ActivationStart: "* * * * 1-5", + ID: "RT_WEEK", + Weight: 0, + ActivationTime: "* * * * 1-5", IntervalRates: []*engine.IntervalRate{ &engine.IntervalRate{ IntervalStart: time.Duration(0 * time.Second), diff --git a/rates/librates_test.go b/rates/librates_test.go index ca342f282..c5cfe8da2 100644 --- a/rates/librates_test.go +++ b/rates/librates_test.go @@ -39,9 +39,9 @@ func TestOrderRatesOnIntervals(t *testing.T) { } rt0.Compile() rtChristmas := &engine.Rate{ - ID: "RT_CHRISTMAS", - ActivationStart: "* * 24 12 *", - Weight: 50, + ID: "RT_CHRISTMAS", + ActivationTime: "* * 24 12 *", + Weight: 50, IntervalRates: []*engine.IntervalRate{ { IntervalStart: time.Duration(0), diff --git a/utils/apitpdata.go b/utils/apitpdata.go index e009c861f..3bdc20d7a 100755 --- a/utils/apitpdata.go +++ b/utils/apitpdata.go @@ -1454,12 +1454,12 @@ type TPRateProfile struct { } type TPRate struct { - ID string // RateID - FilterIDs []string // RateFilterIDs - ActivationStart string - Weight float64 // RateWeight will decide the winner per interval start - Blocker bool // RateBlocker will make this rate recurrent, deactivating further intervals - IntervalRates []*TPIntervalRate + ID string // RateID + FilterIDs []string // RateFilterIDs + ActivationTime string + Weight float64 // RateWeight will decide the winner per interval start + Blocker bool // RateBlocker will make this rate recurrent, deactivating further intervals + IntervalRates []*TPIntervalRate } type TPIntervalRate struct {