How to re-rate existing CDRs

112 views
Skip to first unread message

Jacek Konieczny

unread,
May 25, 2021, 4:21:03 AM5/25/21
to CGRateS
Hi,

This seems like quite a normal use case, but I cannot find any info how to actually do that.

I am using CGRateS for real-time rating, for cost monitoring and abuse prevention. But at the end of the billing period I'll take all the CDRs to make the invoices. Congressionally I may need to correct the tariff for the final billing. How can I process the CDRs already in the StroDB and re-rate them with current/chosen tariff? Preferably in the same CGRateS instance, which is still doing real-time rating for new calls.

Greets,
Jacek

Alexandru Tripon

unread,
May 28, 2021, 4:40:03 AM5/28/21
to cgr...@googlegroups.com

--
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 on the web visit https://groups.google.com/d/msgid/cgrates/8606b9a8-cdc9-4b89-8f7d-94c8ffe12db3n%40googlegroups.com.

Jacek Konieczny

unread,
Jun 11, 2021, 3:51:32 AM6/11/21
to CGRateS
CDRsV1.RateCDRs() seems to be what I was looking for. However it fails for me, as it tries to re-insert the CDRs into the database instead of updating existing entries which causes database errors:

[30-1] 2021-06-11 09:42:01.717 CEST [12664] cgrates@cgrates ERROR:  duplicate key value violates unique constraint "cdrs_cgrid_run_id_key"

Is anything I can do except some database hacking (triggers to replace those inserts with update, or something)?

Jacek Konieczny

unread,
Jun 11, 2021, 4:28:22 AM6/11/21
to CGRateS
False alarm. CGRateS does UPDATE when the insert fails. It just updates the record with the very same date that was there before, even though my rating profiles are completely different that they were when the original CDR was generated.

I have set 'Flags' to: ["*rerate", "*chargers:false"], how to disable a flag there was not obvious at all.
Reply all
Reply to author
Forward
0 new messages