diff --git a/apier/v1/routes_with_rates_it_test.go b/apier/v1/routes_with_rates_it_test.go index c622da73d..f94acc903 100644 --- a/apier/v1/routes_with_rates_it_test.go +++ b/apier/v1/routes_with_rates_it_test.go @@ -39,7 +39,7 @@ var ( testV1RouteSWithRateSRpcConn, testV1RouteSWithRateSFromFolder, testV1RouteSWithRateSGetRoutes, - //testV1RouteSWithRateSAccountWithRateProfile, //need to be discussed + testV1RouteSWithRateSAccountWithRateProfile, //need to be discussed testV1RouteSWithRateSStopEngine, } ) @@ -165,7 +165,6 @@ func testV1RouteSWithRateSGetRoutes(t *testing.T) { } } -/* func testV1RouteSWithRateSAccountWithRateProfile(t *testing.T) { routePrf = &RouteWithCache{ RouteProfile: &engine.RouteProfile{ @@ -250,10 +249,10 @@ func testV1RouteSWithRateSAccountWithRateProfile(t *testing.T) { { RouteID: "RouteWithAccAndRatePrf", SortingData: map[string]interface{}{ - utils.Account: "AccWithVoice", - "Cost": 0.0, - "MaxUsage": 30000000000.0, - utils.Weight: 20.0, + utils.Account: "AccWithVoice", + utils.Cost: 0.0, + utils.CapMaxUsage: 30000000000.0, + utils.Weight: 20.0, }, }, { @@ -302,8 +301,8 @@ func testV1RouteSWithRateSAccountWithRateProfile(t *testing.T) { RouteID: "RouteWithAccAndRatePrf", SortingData: map[string]interface{}{ utils.Account: "AccWithVoice", - "Cost": 0.6, - "MaxUsage": 30000000000.0, + utils.Cost: 0.6, + utils.CapMaxUsage: 30000000000.0, utils.RateProfileMatched: "RT_ANY2CNT_SEC", utils.Weight: 20.0, }, @@ -311,7 +310,7 @@ func testV1RouteSWithRateSAccountWithRateProfile(t *testing.T) { { RouteID: "RouteWithRP", SortingData: map[string]interface{}{ - "Cost": 0.6, + utils.Cost: 0.6, utils.RateProfileMatched: "RT_ANY1CNT_SEC", utils.Weight: 10.0, }, @@ -363,7 +362,7 @@ func testV1RouteSWithRateSAccountWithRateProfile(t *testing.T) { SortingData: map[string]interface{}{ utils.Account: "AccWithVoice", utils.Cost: 0.62, - "MaxUsage": 30000000000.0, + utils.CapMaxUsage: 30000000000.0, utils.RateProfileMatched: "RT_ANY2CNT_SEC", utils.Weight: 20.0, }, @@ -380,7 +379,6 @@ func testV1RouteSWithRateSAccountWithRateProfile(t *testing.T) { } } -*/ func testV1RouteSWithRateSStopEngine(t *testing.T) { if err := engine.KillEngine(100); err != nil { diff --git a/data/tariffplans/routes_with_rates/DestinationRates.csv b/data/tariffplans/routes_with_rates/DestinationRates.csv new file mode 100644 index 000000000..ad8f0a539 --- /dev/null +++ b/data/tariffplans/routes_with_rates/DestinationRates.csv @@ -0,0 +1,2 @@ +#Id,DestinationId,RatesTag,RoundingMethod,RoundingDecimals,MaxCost,MaxCostStrategy +DR_ANY_1CNT,*any,RT_1CNT,*up,5,0, \ No newline at end of file diff --git a/data/tariffplans/routes_with_rates/Rates.csv b/data/tariffplans/routes_with_rates/Rates.csv new file mode 100644 index 000000000..1e52c1789 --- /dev/null +++ b/data/tariffplans/routes_with_rates/Rates.csv @@ -0,0 +1,2 @@ +#Id,ConnectFee,Rate,RateUnit,RateIncrement,GroupIntervalStart +RT_1CNT,0,0.01,60s,1s,0s \ No newline at end of file diff --git a/data/tariffplans/routes_with_rates/RatingPlans.csv b/data/tariffplans/routes_with_rates/RatingPlans.csv new file mode 100644 index 000000000..d84767576 --- /dev/null +++ b/data/tariffplans/routes_with_rates/RatingPlans.csv @@ -0,0 +1,2 @@ +#Id,DestinationRatesId,TimingTag,Weight +RP_TESTIT1,DR_ANY_1CNT,*any,10 \ No newline at end of file diff --git a/data/tariffplans/routes_with_rates/RatingProfiles.csv b/data/tariffplans/routes_with_rates/RatingProfiles.csv new file mode 100644 index 000000000..cbf294394 --- /dev/null +++ b/data/tariffplans/routes_with_rates/RatingProfiles.csv @@ -0,0 +1,2 @@ +#Tenant,Category,Subject,ActivationTime,RatingPlanId,RatesFallbackSubject +cgrates.org,*routes,*any,2018-01-01T00:00:00Z,RP_TESTIT1, diff --git a/engine/routes.go b/engine/routes.go index 7176c9ab0..4d3d62f0e 100644 --- a/engine/routes.go +++ b/engine/routes.go @@ -262,8 +262,8 @@ func (rpS *RouteService) costForEvent(ev *utils.CGREvent, } if usage > accountMaxUsage { // remain usage needs to be covered by rating plans - if len(rpIDs) == 0 { - return nil, fmt.Errorf("no rating plans defined for remaining usage") + if len(rpIDs) == 0 && len(rtPrfIDs) == 0 { + return nil, fmt.Errorf("no rating plans or rate profiles defined for remaining usage") } // update the setup time and the usage sTime = sTime.Add(accountMaxUsage) @@ -278,7 +278,7 @@ func (rpS *RouteService) costForEvent(ev *utils.CGREvent, if accountMaxUsage == 0 || accountMaxUsage < initialUsage { var rateRply RateProfileCost - if len(rpS.cgrcfg.RouteSCfg().RateSConns) != 0 && len(rtPrfIDs) != 0 { + if len(rpS.cgrcfg.RouteSCfg().RateSConns) != 0 { if err := rpS.connMgr.Call(rpS.cgrcfg.RouteSCfg().RateSConns, nil, utils.RateSv1CostForEvent, &utils.ArgsCostForEvent{ RateProfileIDs: rtPrfIDs,