Tiered Prcing:

197 views
Skip to first unread message

వెంకటేష్ ఎన్నల

unread,
Aug 30, 2018, 2:59:44 PM8/30/18
to CGRateS
Hi Dan,

Hope you are going good.

I am researching CGrateS to see if we can use this to implement a tiered pricing scheme for rating the cdrs in our system.
For example customers first 60min calls will be rated 10c/min ... and then next 120min calls will be rated 8c/min... and next 240min calls will be rated 5c/min.

Is implementing this possible in CGrateS ? If yes you can point me to the specific topic in the documentation.

Thanks.

DanB

unread,
Aug 31, 2018, 11:30:35 AM8/31/18
to cgr...@googlegroups.com
Hi enna...@gmail.com,

All good here, thanks!

Tiered pricing should be pretty straight forward in CGRateS with using
balance counters for each level.

All you need to configure is different balance for each level and
attach them the pricing through the use of RatingSubject. You
prioritize the balances via BalanceWeight parameter.

You can find an example of attaching special prices to a balance in old
tutorial here:

https://github.com/cgrates/cgrates/blob/master/data/tariffplans/oldtutorial/Actions.csv#L4

https://github.com/cgrates/cgrates/blob/master/data/tariffplans/oldtutorial/RatingProfiles.csv#L4

Good luck!

DanB
> --
> You received this message because you are subscribed to the Google
> Groups "CGRateS" group.
> To unsubscribe from this group and stop receiving emails from it,
> send an email to cgrates+u...@googlegroups.com.
> To post to this group, send email to cgr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/cgrates/1c7c0b9e-7a5d-4d39-bb00-4ba9232489d2%40googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.

వెంకటేష్ ఎన్నల

unread,
Aug 31, 2018, 11:38:34 AM8/31/18
to CGRateS
Thanks Dan.

వెంకటేష్ ఎన్నల

unread,
Sep 17, 2018, 1:48:13 AM9/17/18
to CGRateS
Hi Dan,

Thanks for previous replay. I am new to cgrates and read good amount of documentation.
Also read the oldtutorial which you pointed out multiple times to understand the concept better. But still I need to understand a lot, so excuse me if I am asking something basic.

Basically I tried to attach a 120s voice balance to a new account, but was unsuccessful. Once I am successful with this I will do the scenario with 2 balances which I mentioned in the initial post.

Added the following config:

AccountActions.csv 
cgrates.org,1008,PACKAGE_1008,,,

ActionPlans.csv 
PACKAGE_1008,BAL_VOICE_120S,*asap,10

Actions.csv  ( I used reset counter action here .. because I dont want top up after its used.. instead the next balance will be used)
BAL_VOICE_120S,*reset_counter,,,,*voice,*out,,DST_1003,SPECIAL_1003,,*unlimited,,120s,20,false,false,10


RatingProfiles.csv
*out,cgrates.org,call,SPECIAL_1003,2014-01-14T00:00:00Z,RP_SPECIAL_1003,,

RatingPlans.csv 
RP_SPECIAL_1003,DR_SPECIAL_1003,*any,10

DestinationRates.csv 
DR_SPECIAL_1003,DST_1003,RT_1CNT_PER_SEC,*up,4,0,


After loading I tried to check the balances for Account 1008 and its not returned any balances. Its still returning proper balances for tutorial account 1001 though.
Appreciate you help.

Thanks,
Venkatesh Ennala.


On Thursday, August 30, 2018 at 2:59:44 PM UTC-4, వెంకటేష్ ఎన్నల wrote:

DanB

unread,
Sep 17, 2018, 3:55:04 AM9/17/18
to cgr...@googlegroups.com
Hi Venkatesh,

In your Actions.csv you should have a *topup or *topup_reset in order
to create balance. The action you have used, *reset_counter is used to
reset counters used by ActionTriggers

You can find samples in oldtutorial here:

https://github.com/cgrates/cgrates/blob/master/data/tariffplans/oldtutorial/Actions.csv#L5

DanB

On Sun, 2018-09-16 at 22:48 -0700, వెంకటేష్ ఎన్నల wrote:
> Hi Dan,
>
> --
> You received this message because you are subscribed to the Google
> Groups "CGRateS" group.
> To unsubscribe from this group and stop receiving emails from it,
> send an email to cgrates+u...@googlegroups.com.
> To post to this group, send email to cgr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/cgrates/aeb0783e-f642-4dcc-ac95-c747e223fdec%40googlegroups.com

వెంకటేష్ ఎన్నల

unread,
Sep 17, 2018, 10:57:42 AM9/17/18
to CGRateS
Thanks Dan,

I change the config with topup_reset.

AccountActions.csv 
cgrates.org,1008,PACKAGE_1008,,,

ActionPlans.csv 
PACKAGE_1008,BAL_VOICE_120S,*asap,10

Actions.csv  ( I used reset counter action here .. because I dont want top up after its used.. instead the next balance will be used)
BAL_VOICE_120S,*topup_reset,,,,*voice,*out,,DST_1003,SPECIAL_1003,,*unlimited,,120s,20,false,false,10


RatingProfiles.csv
*out,cgrates.org,call,SPECIAL_1003,2014-01-14T00:00:00Z,RP_SPECIAL_1003,,

RatingPlans.csv 
RP_SPECIAL_1003,DR_SPECIAL_1003,*any,10

DestinationRates.csv 
DR_SPECIAL_1003,DST_1003,RT_1CNT_PER_SEC,*up,4,0,

Now Account 1008 is showing voice balance of 120s tied to destination 1003.


When I try to get the cost of call for this account to destination 1003. For some reason its taking default rating plan RP_RETAIL1 to calculate the cost and not considering the balance added.

Account Balance:
cgr-console 'accounts Tenant="cgrates.org" AccountIds=["1008"]'
[
 {
  "ID": "cgrates.org:1008",
  "BalanceMap": {
   "*voice": [
    {
     "Uuid": "261736ca-40a4-4441-85da-0411ae2b5d74",
     "ID": "",
     "Value": 120000000000,
     "Directions": {
      "*out": true
     },
     "ExpirationDate": "0001-01-01T00:00:00Z",
     "Weight": 20,
     "DestinationIDs": {
      "DST_1003": true
     },
     "RatingSubject": "SPECIAL_1003",
     "Categories": {},
     "SharedGroups": {},
     "Timings": [],
     "TimingIDs": {},
     "Disabled": false,
     "Factor": {},
     "Blocker": false
    }
   ]
  },
  "UnitCounters": {},
  "ActionTriggers": [],
  "AllowNegative": false,
  "Disabled": false
 }
]

Call Cost:
cgr-console 'cost Category="call" Tenant="cgrates.org" Destination="1003" AnswerTime="2014-08-04T13:00:00Z" Usage="20s" Account="1008"'
( also tried with subject like below)
cgr-console 'cost Category="call" Tenant="cgrates.org" Destination="1003" AnswerTime="2014-08-04T13:00:00Z" Usage="20s" Subject="1008"'

{
 "CGRID": "",
 "RunID": "",
 "StartTime": "2014-08-04T13:00:00Z",
 "Usage": 30000000000,
 "Cost": 0.2,
 "Charges": [
  {
   "RatingID": "085f3a9",
   "Increments": [
    {
     "Usage": 30000000000,
     "Cost": 0.2,
     "AccountingID": "",
     "CompressFactor": 1
    }
   ],
   "CompressFactor": 1
  }
 ],
 "AccountSummary": null,
 "Rating": {
  "085f3a9": {
   "ConnectFee": 0.8,
   "RoundingMethod": "*up",
   "RoundingDecimals": 4,
   "MaxCost": 0,
   "MaxCostStrategy": "",
   "TimingID": "f37c592",
   "RatesID": "124bb24",
   "RatingFiltersID": "a95c67d"
  }
 },
 "Accounting": {},
 "RatingFilters": {
  "a95c67d": {
   "DestinationID": "DST_FS",
   "DestinationPrefix": "10",
   "RatingPlanID": "RP_RETAIL1",
   "Subject": "*out:cgrates.org:call:*any"
  }
 },
 "Rates": {
  "124bb24": [
   {
    "GroupIntervalStart": 0,
    "Value": 0.4,
    "RateIncrement": 30000000000,
    "RateUnit": 60000000000
   },
   {
    "GroupIntervalStart": 60000000000,
    "Value": 0.2,
    "RateIncrement": 10000000000,
    "RateUnit": 60000000000
   }
  ]
 },
 "Timings": {
  "f37c592": {
   "Years": [],
   "Months": [],
   "MonthDays": [],
   "WeekDays": [
    1,
    2,
    3,
    4,
    5
   ],
   "StartTime": "08:00:00"
  }
 }
}

Thanks,
Venkatesh Ennala.



On Thursday, August 30, 2018 at 2:59:44 PM UTC-4, వెంకటేష్ ఎన్నల wrote:

DanB

unread,
Sep 17, 2018, 11:02:41 AM9/17/18
to cgr...@googlegroups.com
Venkatesh,

The cost command only queries rating (no accounting). For accounting to
be considered, see "maxusage" command.

DanB
> --
> You received this message because you are subscribed to the Google
> Groups "CGRateS" group.
> To unsubscribe from this group and stop receiving emails from it,
> send an email to cgrates+u...@googlegroups.com.
> To post to this group, send email to cgr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/cgrates/cf282991-ce10-41bd-aa02-28a541557185%40googlegroups.com

వెంకటేష్ ఎన్నల

unread,
Sep 17, 2018, 11:19:37 AM9/17/18
to CGRateS
Dan,

Thanks for pointing me to mxausage command.
But I was not looking for accounting information. I was checking if its rating with the properly defined rate which is RP_SPECIAL_1003.

Using the help of my colleague passing the subject SPECIAL_1003 tied it to proper rate plan.
cgr-console 'cost Category="call" Tenant="cgrates.org" Subject="SPECIAL_1003" Destination="1003" AnswerTime="2014-08-04T13:00:00Z" Usage="20s"'

But if account has two balances with different rates attached to each of them ... not sure how to achieve it other passing changed subject after balance 1 is expired.
Can I can two balances with same subject with different rates ?

Thanks,
Venkatesh Ennala.

DanB

unread,
Sep 17, 2018, 11:42:39 AM9/17/18
to cgr...@googlegroups.com
Venkatesh,

You should create in that case 2 different rating subjects at attach
rates to them in ratingProfiles.

DanB
> https://groups.google.com/d/msgid/cgrates/771bca79-2b95-4a1a-847e-a86078813788%40googlegroups.com

వెంకటేష్ ఎన్నల

unread,
Sep 17, 2018, 11:50:19 AM9/17/18
to CGRateS
If I have 2 different rating subjects and attaches 2 different rates to them in rating profits.

Is this how I need to send my CDRS for processing ?

Send CDR for processing:
check if Balance1 expired ..
  if expired .. check if Balance2 is expired
      if not send CDR with subject balance2 rating for processing.
  if not send CDR with subject balance1 rating for processing.
 
Thanks,
Venkatesh Ennala.

DanB

unread,
Sep 17, 2018, 12:03:18 PM9/17/18
to cgr...@googlegroups.com
Venkatesh,

You need to configure different ExpiryTime or different Weight. Once
the first balance is not anymore valid, the second one will be
considered automatically. No need for you to do much.

DanB

వెంకటేష్ ఎన్నల

unread,
Sep 17, 2018, 12:22:38 PM9/17/18
to CGRateS
Sorry I wrongly framed my question.

If I have 2 different rating subjects and attached 2 different rates to them in rating profits.

Is this how I need to send my CDRS for processing ?

Send CDR for processing:
check if Balance1 is fully used ..
  if used .. check if Balance2 is fully used
      if not send CDR with subject balance2 rating for processing.
  if not send CDR with subject balance1 rating for processing.

This is waht I am trying to acheive BTW:

Account 1008 will have 2 voice balances for destination 1003.
First Balance with rate the call with one rating plan.
Once the first balance is fully used calls to this destination will be rated with second balance with another rating plan.

DanB

unread,
Sep 17, 2018, 12:25:27 PM9/17/18
to cgr...@googlegroups.com
Venkatesh,

My answer still stays:

* You send the CDR independent of what you have configured in the
balances.
* The balances will interact with the CDR changing automatically the
rating subject based on the one you configure for them.

So all you need to configure is an account with different balances
(each with different subject and different weight prioritising them).
If account is matched and balance has units, that Subject will be used,
instead of the one you put in your CDR.

DanB
> --
> You received this message because you are subscribed to the Google
> Groups "CGRateS" group.
> To unsubscribe from this group and stop receiving emails from it,
> send an email to cgrates+u...@googlegroups.com.
> To post to this group, send email to cgr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/cgrates/1268c883-ae6f-4cce-a22f-d616f0d27a97%40googlegroups.com

వెంకటేష్ ఎన్నల

unread,
Sep 18, 2018, 1:16:36 PM9/18/18
to CGRateS
Thank you Dan. I was able to set two voice balances for the account with different rates.

When I sent a new cdr for processing using CdrsV1.ProcessCdr it did rate with proper rate .. but it was not deducting the balance. May be I need to use different method for it ?
I tried to use debitUsage method .. but it was adding default monetary balance and putting it to negative by deducting the voice minutes.

Thanks,
Venkat.

DanB

unread,
Sep 18, 2018, 1:21:33 PM9/18/18
to cgr...@googlegroups.com
Hi Venkat,

You should use as RequestType in your CDR "*pseudoprepaid" or
"*postpaid" if you are sending CDR via ProcessCDR API.

DanB
> https://groups.google.com/d/msgid/cgrates/db417e75-3e0a-4f7d-bc93-bb63adcf7051%40googlegroups.com

వెంకటేష్ ఎన్నల

unread,
Sep 19, 2018, 2:41:47 PM9/19/18
to CGRateS
Thanks Dan. It worked.
Reply all
Reply to author
Forward
0 new messages