Updating tutorial2 files with Chargers and Attributes for it

This commit is contained in:
DanB
2020-02-05 19:59:19 +01:00
parent ffef415e8c
commit bf91053656
8 changed files with 45 additions and 12 deletions

View File

@@ -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 <PER_CALL> *voice balance valid to destination <DST_10> with special rates <RPF_SPECIAL_BLC> 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 <PER_CALL> *voice balance valid to destination <DST_10> with special rates <RPF_SPECIAL_BLC> 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 <FREE_MINS> 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 <FREE_MINS> 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 <FREE_SMSes> *sms balance to 100 units and priority 20 in balance chain
TOPUP_RST_100_SMS,*topup_reset,,,FREE_SMSes,*sms,,,,,,,100,20,,,10
1 #ActionsId[0],Action[1],ExtraParameters[2],Filter[3],BalanceId[4],BalanceType[5],Categories[6],DestinationIds[7],RatingSubject[8],SharedGroup[9],ExpiryTime[10],TimingIds[11],Units[12],BalanceWeight[13],BalanceBlocker[14],BalanceDisabled[15],Weight[16]
3 TOPUP_RST_MONETARY_10,*topup_reset,,,*default,*monetary,,,,,,,10,10,,,10
4 # TOPUP_RST_5M_VOICE resets the special <PER_CALL> *voice balance valid to destination <DST_10> with special rates <RPF_SPECIAL_BLC> to 10m # TOPUP_RST_10M_VOICE resets the special <PER_CALL> *voice balance valid to destination <DST_10> with special rates <RPF_SPECIAL_BLC> to 10m
5 TOPUP_RST_5M_VOICE,*topup_reset,,,PER_CALL,*voice,,DST_10,RPF_SPECIAL_BLC,,,,10m,10,,,10 TOPUP_RST_10M_VOICE,*topup_reset,,,PER_CALL,*voice,,DST_10,RPF_SPECIAL_BLC,,,,10m,10,,,10
6 # TOPUP_RST_10M_VOICE resets *voice balance <FREE_MINS> with 0 costs rounded up to minute to 5m and priority 20 # TOPUP_RST_5M_VOICE resets *voice balance <FREE_MINS> with 0 costs rounded up to minute to 5m and priority 20
7 TOPUP_RST_10M_VOICE,*topup_reset,,,FREE_MINS,*voice,,,*zero1m,,,,5m,20,,,10 TOPUP_RST_5M_VOICE,*topup_reset,,,FREE_MINS,*voice,,,*zero1m,,,,5m,20,,,10
8 # TOPUP_RST_100_SMS resets the <FREE_SMSes> *sms balance to 100 units and priority 20 in balance chain
9 TOPUP_RST_100_SMS,*topup_reset,,,FREE_SMSes,*sms,,,,,,,100,20,,,10
10 # TOPUP_BONUS_10SMS adds 10 units to <BONUS_SMSes> balance valid on DST_50 destination and priority 30 in balance chain
11 TOPUP_BONUS_10SMS,*topup,,,BONUS_SMSes,*sms,,DST_50,,,,,10,30,,,10
12 # TOPUP_RST_1024_DATA resets the <FREE_DATA> *data balance to 1024 units with priority 20 in the balance chain
13 TOPUP_RST_1024_DATA,*topup_reset,,,FREE_DATA,*data,,,,,,,1024,20,,,10

View File

@@ -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 <auth>
1 # Tenant,ID,Contexts,FilterIDs,ActivationInterval,AttributeFilterIDs,Path,Type,Value,Blocker,Weight
2 # ATTR_CRG_SUPPLIER1 replaces Category->supplier1 and RequestType->*constant for *sessions and *cdrs events # CRG_RESELLER1 replaces Category->reseller1 and RequestType->*rated for *sessions and *cdrs events
3 cgrates.org,ATTR_CRG_SUPPLIER1,*sessions;*cdrs,,,,*req.Category,*constant,supplier1,false,0 cgrates.org,ATTR_CRG_SUPPLIER1,*sessions;*cdrs,,,,*req.Category,*constant,reseller1,false,0
4 cgrates.org,ATTR_CRG_SUPPLIER1,,,,,*req.RequestType,*constant,*rated,,
5 # ATTR_1001_AUTH returns the Password value for the account 1001 in context <auth>
6 cgrates.org,ATTR_1001_AUTH,auth,*string:~*req.Account:1001,,,*req.Password,*constant,CGRateS.org,false,20
7 cgrates.org,ATTR_1002_AUTH,auth,*string:~*req.Account:1002,,,*req.Password,*constant,CGRateS.org,false,20

View File

@@ -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
1 # Tenant,ID,FilterIDs,ActivationInterval,RunID,AttributeIDs,Weight
3 cgrates.org,CGR_DEFAULT,,,*default,*none,0
4 # CGR_SUPPLIER1 creates an additional CDR for calculating supplier costs # CGR_RESELLER1 creates an additional CDR for calculating reseller costs
5 # uses ATTR_CRG_SUPPLIER1 to replace Category and RequestType in events # uses ATTR_CRG_RESELLER1 to replace Category and RequestType in events
6 cgrates.org,CRG_SUPPPLIER1,,,SUPPLIER1,ATTR_CRG_SUPPLIER1,0 cgrates.org,CRG_RESELLER1,,,reseller1,ATTR_CRG_RESELLER1,1
7
8

View File

@@ -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,,
DR_1CNT,*any,RT_1CNT,*up,4,,
DR_10CNT,*any,RT_10CNT,*up,4,,
1 #ID DestinationsID RatesID RoundingMethod RoundingDecimals MaxCost MaxCostStrategy
9 DR_ANY_1024_1 *any RT_1024_1 *up 4
10 DR_1002_10C1 DST_1002 RT_10C1 *up 4
11 DR_10_20C1 DST_10 RT_20C1 *up 4
12 DR_1CNT *any RT_1CNT *up 4
13 DR_10CNT *any RT_10CNT *up 4

View File

@@ -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
1 #ID,ConnectFee,Rate,RateUnit,RateIncrement,GroupIntervalStart
24
25
26
27
28
29

View File

@@ -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
RP_1CNT,DR_1CNT,*any,0
RP_10CNT,DR_10CNT,*any,0
1 #ID DestinationRatesID TimingID Weight
11 RP_DATA DR_ANY_1024_1 *any 10
12 RP_SMS DR_1002_10C1 *any 10
13 RP_SMS DR_10_20C1 *any 10
14 RP_1CNT DR_1CNT *any 0
15 RP_10CNT DR_10CNT *any 0

View File

@@ -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,
1 #Tenant #Tenant,Category,Subject,ActivationTime,RatingPlanID,FallbackSubject Category Subject ActivationTime RatingPlanID FallbackSubject
4 cgrates.org cgrates.org,call,RPF_SPECIAL_BLC,2019-03-01T00:00:00Z,RP_SPECIAL_BLC, call RPF_SPECIAL_BLC 2019-03-01T00:00:00Z RP_SPECIAL_BLC
5 cgrates.org cgrates.org,data,*any,2019-03-01T00:00:00Z,RP_DATA, data *any 2019-03-01T00:00:00Z RP_DATA
6 cgrates.org cgrates.org,sms,*any,2019-03-01T00:00:00Z,RP_SMS, sms *any 2019-03-01T00:00:00Z RP_SMS
7 cgrates.org # reseller1 will pay 0.1 per call, independent of duration supplier1 *any 2019-03-01T00:00:00Z RP_1CNT
8 cgrates.org,reseller1,*any,2019-03-01T00:00:00Z,RP_10CNT,
9

View File

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