diff --git a/data/tariffplans/tutorial2/Actions.csv b/data/tariffplans/tutorial2/Actions.csv index ae15e2a37..7dc625fb5 100644 --- a/data/tariffplans/tutorial2/Actions.csv +++ b/data/tariffplans/tutorial2/Actions.csv @@ -3,11 +3,11 @@ # TOPUP_RST_MONETARY_10 resets the <*default> <*monetary> balance to 10 units TOPUP_RST_MONETARY_10,*topup_reset,,,*default,*monetary,,,,,,,10,10,,,10 -# TOPUP_RST_5M_VOICE resets the special *voice balance valid to destination with special rates to 10m -TOPUP_RST_5M_VOICE,*topup_reset,,,PER_CALL,*voice,,DST_10,RPF_SPECIAL_BLC,,,,10m,10,,,10 +# TOPUP_RST_10M_VOICE resets the special *voice balance valid to destination with special rates to 10m +TOPUP_RST_10M_VOICE,*topup_reset,,,PER_CALL,*voice,,DST_10,RPF_SPECIAL_BLC,,,,10m,10,,,10 -# TOPUP_RST_10M_VOICE resets *voice balance with 0 costs rounded up to minute to 5m and priority 20 -TOPUP_RST_10M_VOICE,*topup_reset,,,FREE_MINS,*voice,,,*zero1m,,,,5m,20,,,10 +# TOPUP_RST_5M_VOICE resets *voice balance with 0 costs rounded up to minute to 5m and priority 20 +TOPUP_RST_5M_VOICE,*topup_reset,,,FREE_MINS,*voice,,,*zero1m,,,,5m,20,,,10 # TOPUP_RST_100_SMS resets the *sms balance to 100 units and priority 20 in balance chain TOPUP_RST_100_SMS,*topup_reset,,,FREE_SMSes,*sms,,,,,,,100,20,,,10 diff --git a/data/tariffplans/tutorial2/Attributes.csv b/data/tariffplans/tutorial2/Attributes.csv index bb841477c..51b0feab1 100644 --- a/data/tariffplans/tutorial2/Attributes.csv +++ b/data/tariffplans/tutorial2/Attributes.csv @@ -1,7 +1,7 @@ # Tenant,ID,Contexts,FilterIDs,ActivationInterval,AttributeFilterIDs,Path,Type,Value,Blocker,Weight -# ATTR_CRG_SUPPLIER1 replaces Category->supplier1 and RequestType->*constant for *sessions and *cdrs events -cgrates.org,ATTR_CRG_SUPPLIER1,*sessions;*cdrs,,,,*req.Category,*constant,supplier1,false,0 +# CRG_RESELLER1 replaces Category->reseller1 and RequestType->*rated for *sessions and *cdrs events +cgrates.org,ATTR_CRG_SUPPLIER1,*sessions;*cdrs,,,,*req.Category,*constant,reseller1,false,0 cgrates.org,ATTR_CRG_SUPPLIER1,,,,,*req.RequestType,*constant,*rated,, # ATTR_1001_AUTH returns the Password value for the account 1001 in context diff --git a/data/tariffplans/tutorial2/Chargers.csv b/data/tariffplans/tutorial2/Chargers.csv index 20ebeb42b..4343b8c7a 100644 --- a/data/tariffplans/tutorial2/Chargers.csv +++ b/data/tariffplans/tutorial2/Chargers.csv @@ -3,6 +3,6 @@ # CGR_DEFAULT is the default charger for events cgrates.org,CGR_DEFAULT,,,*default,*none,0 -# CGR_SUPPLIER1 creates an additional CDR for calculating supplier costs -# uses ATTR_CRG_SUPPLIER1 to replace Category and RequestType in events -cgrates.org,CRG_SUPPPLIER1,,,SUPPLIER1,ATTR_CRG_SUPPLIER1,0 +# CGR_RESELLER1 creates an additional CDR for calculating reseller costs +# uses ATTR_CRG_RESELLER1 to replace Category and RequestType in events +cgrates.org,CRG_RESELLER1,,,reseller1,ATTR_CRG_RESELLER1,1 diff --git a/data/tariffplans/tutorial2/DestinationRates.csv b/data/tariffplans/tutorial2/DestinationRates.csv index df2733801..d50ab9a2d 100644 --- a/data/tariffplans/tutorial2/DestinationRates.csv +++ b/data/tariffplans/tutorial2/DestinationRates.csv @@ -9,4 +9,5 @@ DR_ANY_10C_CN,*any,RT_10C_CN,*up,4,, DR_ANY_1024_1,*any,RT_1024_1,*up,4,, DR_1002_10C1,DST_1002,RT_10C1,*up,4,, DR_10_20C1,DST_10,RT_20C1,*up,4,, -DR_1CNT,*any,RT_1CNT,*up,4,, \ No newline at end of file +DR_1CNT,*any,RT_1CNT,*up,4,, +DR_10CNT,*any,RT_10CNT,*up,4,, \ No newline at end of file diff --git a/data/tariffplans/tutorial2/Rates.csv b/data/tariffplans/tutorial2/Rates.csv index 9390417e1..0cc47ee69 100644 --- a/data/tariffplans/tutorial2/Rates.csv +++ b/data/tariffplans/tutorial2/Rates.csv @@ -24,3 +24,6 @@ RT_20C1,0,0.2,1,1,0 # RT_1CNT charges 0.01 units of cost for each 1s of usage RT_1CNT,0,0.01,1s,1s,0 + +# RT_10CNT charges 0.1 units of cost for each call connected +RT_10CNT,0.1,0,1s,1s,0 diff --git a/data/tariffplans/tutorial2/RatingPlans.csv b/data/tariffplans/tutorial2/RatingPlans.csv index 6f2954983..7220236ef 100644 --- a/data/tariffplans/tutorial2/RatingPlans.csv +++ b/data/tariffplans/tutorial2/RatingPlans.csv @@ -11,4 +11,5 @@ RP_SPECIAL_BLC,DR_ANY_10C_CN,*any,10 RP_DATA,DR_ANY_1024_1,*any,10 RP_SMS,DR_1002_10C1,*any,10 RP_SMS,DR_10_20C1,*any,10 -RP_1CNT,DR_1CNT,*any,0 \ No newline at end of file +RP_1CNT,DR_1CNT,*any,0 +RP_10CNT,DR_10CNT,*any,0 \ No newline at end of file diff --git a/data/tariffplans/tutorial2/RatingProfiles.csv b/data/tariffplans/tutorial2/RatingProfiles.csv index 3166eafd9..93893aefe 100644 --- a/data/tariffplans/tutorial2/RatingProfiles.csv +++ b/data/tariffplans/tutorial2/RatingProfiles.csv @@ -4,4 +4,6 @@ cgrates.org,call,1001,2019-03-01T00:00:00Z,RP_1001,*any cgrates.org,call,RPF_SPECIAL_BLC,2019-03-01T00:00:00Z,RP_SPECIAL_BLC, cgrates.org,data,*any,2019-03-01T00:00:00Z,RP_DATA, cgrates.org,sms,*any,2019-03-01T00:00:00Z,RP_SMS, -cgrates.org,supplier1,*any,2019-03-01T00:00:00Z,RP_1CNT, + +# reseller1 will pay 0.1 per call, independent of duration +cgrates.org,reseller1,*any,2019-03-01T00:00:00Z,RP_10CNT, diff --git a/general_tests/tutorial2_it_test.go b/general_tests/tutorial2_it_test.go index 4c31428d2..6297a638d 100644 --- a/general_tests/tutorial2_it_test.go +++ b/general_tests/tutorial2_it_test.go @@ -266,6 +266,32 @@ func testTutGetCost(t *testing.T) { } else if *rply.Cost != 0.1 { t.Errorf("Unexpected cost received: %f", *rply.Cost) } + // reseller1 pricing for 1001->1002 + attrs = v1.AttrGetCost{ + Subject: "1001", + Destination: "1002", + AnswerTime: "*now", + Usage: "45s", + Category: "reseller1", + } + if err := tutRpc.Call(utils.APIerSv1GetCost, attrs, &rply); err != nil { + t.Error("Unexpected nil error received: ", err.Error()) + } else if *rply.Cost != 0.1 { + t.Errorf("Unexpected cost received: %f", *rply.Cost) + } + // reseller1 pricing for 1001->1002 duration independent + attrs = v1.AttrGetCost{ + Subject: "1001", + Destination: "1002", + AnswerTime: "*now", + Usage: "10m45s", + Category: "reseller1", + } + if err := tutRpc.Call(utils.APIerSv1GetCost, attrs, &rply); err != nil { + t.Error("Unexpected nil error received: ", err.Error()) + } else if *rply.Cost != 0.1 { + t.Errorf("Unexpected cost received: %f", *rply.Cost) + } } func testTutAccounts(t *testing.T) {