Skip to content

Recalculate CDRs after a rate correction

If calls were billed with a wrong price, for example after a mistake in a rate upload, you can reprice them. You create a rerate task for an account, a reseller or vendor connections and a period, upload the correct rates to the task, and the switch recalculates the CDRs and corrects the balances. This tutorial corrects the price of one destination for one account. Allow 20 minutes, plus the processing time.

The example: account example-telecom was billed 0.0500 per minute instead of 0.0150 for prefix 4420 between 3 and 13 May.

  • You are logged in as the root customer with Administrator access. Rerate CDRs is available to the root customer only.
  • You know whose calls to recalculate: one account, the accounts of all customers, one reseller or all resellers, or one or more connections of a vendor.
  • You know the period and the correct Prefix, Interval 1, Interval N, Price 1 and Price N.
  • You have downloaded the affected CDRs, so that you can compare before and after. A rerate cannot be undone.

A rerate task uses only the rates you upload to it, not the tariff. Correct the rate in the tariff (for a vendor, in the termination route) first, so that new calls are billed correctly. See Rates.

  1. Open Tools & Debugs → Rerate CDRs.
  2. Select what to recalculate. Choosing one of them clears the others:
    • Account: one account, or All for every account. Recalculates the account CDRs and the account balances.
    • Reseller: one reseller, or All for every reseller. Recalculates what the reseller pays you and the reseller balance.
    • Vendor, then one or more entries in Vendor Connection: recalculates the vendor CDRs of those connections and the vendor balance.
  3. For the example, enter example-telecom in Account.
  4. Enter Period From 2026-05-03 00:00 and Period To 2026-05-14 00:00. Times are in the time zone of your web user.
  5. Set Recalculate Time to an off-peak time if the period has many calls. now starts as soon as rates are uploaded.
  6. Enter a note in Notepad, for example Fix 4420 upload of 3 May.
  7. Enter Notification Email List, a comma-separated list of addresses that get an e-mail when the task starts and when it finishes.
  8. Click Add.
Screenshot "tutorials/rerate-cdrs" has not been generated yet — see scripts/screenshots/screens.yml.

Result: the task appears in the list with a red status: Pending, no rates uploaded. A task never runs without rates.

  1. Click Get Template in the row of the task. You get an empty Recalculate_Rates file with the columns Action [A|D|U|S|SA], Id, Prefix, Country, Interval 1, Interval N, Price 1 and Price N.

  2. Add one row per prefix with A in the action column. For the example:

    Action [A|D|U|S|SA] Id Prefix Country Interval 1 Interval N Price 1 Price N
    A 4420 60 60 0.0150 0.0150
  3. Click Upload Rates in the row of the task and choose the file.

  4. Check the message: Upload has completed successfully with the number of rows processed, recognized and added. Rows that fail come back as a Recalculate Rates errors file with an error message per row.

Result: the status changes to Pending. Upload Rates is now disabled and Get Rates downloads the rates of the task. To change them, delete the task and create a new one.

The switch checks for due tasks every 10 minutes and runs one task at a time. For each matching CDR with a duration above zero it replaces the prefix, intervals and prices, recalculates the cost with the CDR’s own connect fee, free seconds, grace period and post-call surcharge, and adds the difference to the balance. Commissions of the account’s calls are recalculated too.

While the task runs, its status is In Progress. When it finishes, the status is Completed and Message shows a summary: how many accounts (or customers, or connections) were recalculated, the total change, the minutes and the number of calls.

  1. Open Reports → Call Records (CDRs) for example-telecom and the period.
  2. Check that the calls to 4420… show the new price and cost.
  3. Open the account and check that the balance changed by the total in Message.