Currency Agnostic Reporting

85 views
Skip to first unread message

simba masamba

unread,
Aug 10, 2026, 9:33:12 AMAug 10
to cgr...@googlegroups.com
Good day Team,

So I understand that CGRates is currency agnostic. However, I have a scenario where I have rateplans in 2 different currencies. I was able to report and calculate costs for one currency fine but however my reports are inaccurate when I created a rate plan with another currency as it is still feeding into the main / old report.
How do I :

1. Tag subs with a currency / any better way such that I can split costs and calculate accurately based on one currency and another?
2. Can I apply this tag to old /legacy subscribers so that I can refer to this tag in future.
3. How can I safely achieve this?

BR,

Simba

simba masamba

unread,
Aug 10, 2026, 9:33:18 AMAug 10
to cgr...@googlegroups.com, sup...@itsyscom.com
Good day Team,

Still struggling with this, I would appreciate any help I can get.
Thank you.

gezim....@itsyscom.com

unread,
Aug 10, 2026, 11:30:24 AMAug 10
to CGRateS
Hi Simba,

Before i suggest an approach, a few questions to understand your setup.

1. Is the currency setup  only per subscriber (each sub always billed in one currency), or can events for the same subscriber be rated in both currencies?

2. Does a "report" mean a CDR ?

3. What combination of Tenant, Category and Subject are you using in RatingProfile, since that is used to filter RatingPlans.

Also please provide us with some sample events along with your tariffplans.

Thanks,
Gezim.

simba masamba

unread,
Aug 12, 2026, 11:25:59 AMAug 12
to cgr...@googlegroups.com
hi Gezim,

I truly appreciate you taking the time to respond to my question - thanks.

I will answer your questions per point:
1. Subs are rated & billed in only 1 currency at any moment.
2. YES report means CDR - though I create the reports using a separate application but off the CDR entries and fields.
3. can you come again on this question

Below is a sample cgrates event for context: (please note I need approval first to send you any data )

   AccessInformation:
   Account: 263123456789
   AnswerTime: 0001-01-01T00:00:00Z
   CGRID: 8a9fab988754bd651e02982c857222b43515a446
   CallType:
   Category: call
   Cost: 0.0000
   Destination: 26389782314
   DestinationID: {}
   DestinationPrefix: {}
   IMSChargingId: 60559de306e08486e74c1d5595dda218
   OriginID: 0gQAAC8WAAACBAAALxYAALCBhcq57LZYKsjQmnuR/786PGVfR7UpKbI+0bxHNPTJ+JV87V4smPfBolFQJamoDzjm9zYaxMuoMgrRnuWUzyE-@IP-Address
   RatePlanID: {}
   ReleaseCode:
   RequestType: *prepaid
   RunID: *default
   SetupTime: 2026-08-12T09:35:40Z
   Subject: 263123456789
   TOR: *voice
   Tenant: lab.poc.test
   Usage: 0

Using the event above as an example, I want a way that I can see that this is an event in Pounds / Euros and I can craft reports in my external application nicely.

BR,

Simba



--
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 view this discussion visit https://groups.google.com/d/msgid/cgrates/2a3554a2-1aa4-47cc-9e51-284cd2f640c5n%40googlegroups.com.

gezim....@itsyscom.com

unread,
Aug 17, 2026, 9:42:01 AMAug 17
to CGRateS
Hi Simba,

You can split this by using Category as a switch to pick the correct RatingPlan per currency .
CGRateS looks up which RatingPlan to use for a call via the key Tenant + Category + Subject in your RatingProfile.
So for each value of Category it can resolve to a different RatingPlan for the same account.

You can use example as below:
RatingProfiles.csv
#Tenant,Category,Subject,ActivationTime,RatingPlanId,RatesFallbackSubject
cgrates.org,call_usd,*any,2018-01-01T00:00:00Z,RP_USD,
cgrates.org,call_eur,*any,2018-01-14T00:00:00Z,RP_EUR,

Depending on how you generate your events, you can set Category value directly at creation or using Attributes to alter it.
Then in  CDRs you can use Category field (call_usd or call_eur) directly to filter based on currency for your reports.
If you are using balances  the Category filter can be used there as well to debit and keep record of balances for different currencies.
Feel free to ask if you have any further questions!

Thanks,
Gezim.

simba masamba

unread,
Aug 25, 2026, 3:32:13 PMAug 25
to cgr...@googlegroups.com
hi Gezim,

Thank you for your response - I appreciate it.

Can you expand on this please: " you can set Category value directly at creation or using Attributes to alter it "
Which one is the simpler / better approach and any links to documentation of how I can set this up?

In my events, the "category" field is set to simply "call", not confident how to alter this to e.g. "call_usd"

PS: I am not an expert in CGR - sorry for the many questions.

Regards,

Simba

Armir Veliaj

unread,
Aug 27, 2026, 4:38:23 AMAug 27
to CGRateS
Hi Simba,

As Gezim is on vacation, please check the answer below.

Setting the Category directly at creation depends on your switch and how you generate events, but you can alternatively use Attributes, as in this example:


#Tenant,ID,Contexts,FilterIDs,ActivationInterval,AttributeFilterIDs,Path,Type,Value,Blocker,Weight
cgrates.org,ATTR_USD_ACCOUNTS,*sessions;*cdrs,*prefix:~*req.Account:263,,,,,,false,10
cgrates.org,ATTR_USD_ACCOUNTS,,,,,*req.Category,*constant,call_usd,,
cgrates.org,ATTR_EUR_ACCOUNTS,*sessions;*cdrs,*prefix:~*req.Account:44,,,,,,false,10
cgrates.org,ATTR_EUR_ACCOUNTS,,,,,*req.Category,*constant,call_eur,,


So, based on the account, the Category gets altered by AttributeS from call to call_usd or call_eur.

You need to make sure that you have the AttributeS connections configured in the SessionS section of the config file, including the index fields in the AttributeS configuration.

For the docs, you can check this link:
https://cgrates.readthedocs.io/en/latest/index.html

The most relevant sections for your case are:
Attributes: https://cgrates.readthedocs.io/en/latest/attributes.html#id2
Rating Profiles: https://cgrates.readthedocs.io/en/latest/rals.html#ratingprofile

Hope it helps.

Thanks,
Armir

simba masamba

unread,
Sep 7, 2026, 12:22:36 PMSep 7
to cgr...@googlegroups.com
Hi Gezim,

May you kindly respond to the above whenever you are free please.

Thanks.

simba masamba

unread,
Sep 7, 2026, 12:22:44 PMSep 7
to cgr...@googlegroups.com
Hi Armir,
This makes alot of sense. Many thanks, let me read and lab it up but I get the logic of it and know what to do.

I appreciate.



simba masamba

unread,
Sep 7, 2026, 12:23:34 PMSep 7
to cgr...@googlegroups.com
Hi Amir,

I have read and understood your steps and indeed it worked. Thank you.

I face a scalability issue. Since random numbers (and not all) will need to have this Attribute profile, this will mean that the FilterIDs will need to be constantly updated.
My setup is such that my IMS core talks Diameter to CGRates via a diameter node. I have attached a sample event for your reference.
Question is:

1. Is there a way then to send a parameter via Diameter to notify CGRates that this subscriber will use a RP_EUR rateplan? from source
2. Or is there a way I can assign this tag randomly to numbers with no pattern such that the CGREvent includes something like the below:

{"id":5,"result":[{"ChargerSProfile":"DEFAULT","AttributeSProfiles":["ATTR_RP_USD"],"AlteredFields":["*req.RunID","*req.RatePlan","*req.Currency"],"CGREvent":{"Tenant":"voice.lab.test.net","ID":"event2","Time":null,"Event":{"Account":"263442352821","Category":"call","Currency":"USD","Destination":"263001001234","OriginID":"sim-call-001","RatePlan":"RP_USD","RequestType":"*rated","RunID":"","Subject":"263442352821","ToR":"*monetary","Usage":"60s"}}}],"error":null}

I am 'toying' around the thought that I use sequential blocks for DID allocation for new customers but existing customers might want to change rate plans and I will be in a fix in tracking these numbers.

Help please - thanks

Sample Diameter Event.txt

Armir Veliaj

unread,
Sep 9, 2026, 11:49:58 AMSep 9
to CGRateS
Hi Simba,

Following up on your other two questions:

1.Yes, this can be done via request_processors in the DiameterAgent. If your IMS core sends an AVP carrying the currency or rate plan information, you can configure a template to map that AVP directly into *req.Category (or another CGREvent field).

The DiameterAgent documentation may also be helpful here:
https://cgrates.readthedocs.io/en/latest/diamagent.html#diameteragent

2.The second approach is also possible. Instead of using a *prefix filter, you can use a *string filter with an explicit list of Accounts.  
Whether this is the better approach depends on your specific scenario, especially how frequently the subscriber lists change.

Thanks,
Armir

simba masamba

unread,
Sep 9, 2026, 2:02:58 PMSep 9
to cgr...@googlegroups.com
hi Armir,

Many thanks to your responses on my issue - I got it working thanks to you and Gezim.

BR,

Simba

Reply all
Reply to author
Forward
0 new messages