Skip to content

Telecom billing: how to test charge calculation

B2Bnetwork team · · 6 min

IT in telecom

In brief

Testing billing at a telecom operator means verifying the whole path from the usage record to the invoice: mediation, rating, recurring charges, discounts, tax, and the invoice itself. Three techniques work best: an independent calculation model that the system's output is compared against, separate tests of edge cases (billing cycle boundary, a tariff change mid-cycle, daylight saving time changes, late records), and parallel rating before every major tariff or system change.

How an operator calculates charges

An operator's billing is a chain of several systems, and an error can arise at any link. In simplified form it looks like this:

StageWhat happensExample error
Mediationcollects usage records from the network, discards duplicates, normalizes the formata record lost on restart or counted twice
Ratingassigns a price to each event according to the customer's offera call to a landline rated as a call to a mobile number
Online chargingreduces the customer's prepaid balance and bundles in real timethe service is not blocked when funds run out
Recurring chargingsubscriptions, charges for additional services, prorationa full subscription fee for a partial month
Invoicesums the line items, calculates tax, produces the documenta different amount on the invoice than in the customer's app

Online charging, used among other things for prepaid cards, has for years been based on the Diameter protocol and the Credit-Control application described by the IETF (today in RFC 8506). In the 5G network, the 3GPP organization described this role as the CHF function, which the network talks to through an API. For a tester this means two kinds of tests: of the interface between the network and the charging system, and of the pricing logic in the system itself.

Where charging errors come from

Billing errors rarely come from a simple mistake in a price. More often they are born at the intersection of rules:

  • The billing cycle boundary. A call started at 23:58 on the last day of the cycle and ended after midnight has to land on the right invoice.
  • An offer change mid-cycle. Subscription proration, carrying over unused bundles, the fee for the change.
  • The order in which bundles are used up. When a customer has a bundle from the subscription and a purchased add-on bundle, a rule says which is used first.
  • Rounding. Charging per second, per minute, or per started data block gives different amounts for the same call.
  • Daylight saving time changes. On the night of the clock change, one hour occurs twice or not at all, which breaks time-of-day tariffs.
  • Late records. Records from roaming or from partners arrive after the cycle is closed and must go onto the next invoice according to a clear rule.
  • Combining discounts. Two percentage discounts applied one after the other give a different result than their sum applied once.

An independent calculation model

Billing output is hard to judge by eye, so a tester needs their own source of truth. A simple model works well, for example a script or spreadsheet that calculates charges directly from the tariff description, without the billing system's code. The system's output is compared against the model's output for every test case.

An example calculation, with illustrative amounts: a customer has a subscription for 60 PLN in a 30-day cycle and from day 15 moves to an offer for 90 PLN. If the terms provide for daily proration, the model calculates:

  • days 1–14 on the old offer: 60 PLN × 14/30 = 28 PLN,
  • days 15–30 on the new offer: 90 PLN × 16/30 = 48 PLN,
  • total for the cycle: 76 PLN.

If the system shows 90 PLN or 75 PLN, the difference immediately points to which rule to check: day counting, the day the change takes effect, or rounding. The model has to be written by someone who knows the offer terms, not by the author of the billing code, because otherwise both places will repeat the same misunderstanding.

Edge cases worth separate tests

Beyond cases from everyday sales, it is worth having a fixed set of tests that you run on every tariff change:

  1. Activating and deactivating a service on the first and last day of the cycle.
  2. Changing the offer several times in one cycle.
  3. Suspending a service and restoring it.
  4. Exhausting a bundle in the middle of a single data session.
  5. Calls on the night of the clock change and around midnight.
  6. Records dated before the cycle closed that arrive after it.
  7. A customer with several numbers on one account and a shared discount.
  8. An invoice correction and its effect on the next cycle.

These cases are well suited to automation, because once the data and the expected results from the model are prepared, they can be run after every change. The approach described in the article Risk-based testing helps decide what to test first.

Parallel rating and testing during tariff changes

When replacing a billing system or making a major price list change, the best test is parallel rating. For one or several cycles, the new system calculates charges for the same customers as the old one, and the results are compared account by account. Every difference is either an error or a deliberate rule change, and you need to be able to say which.

Besides correctness, time matters. A billing run for millions of accounts has to fit within the planned window before invoice dispatch starts. That is why a performance test of the billing run is a standing part of preparing for a change, as in the scenario Billing system performance testing during a tariff change.

Each run also benefits from a record count reconciliation: as many records as entered mediation must come out as rated, rejected, or deferred, with no remainder. We write more about the place of billing among an operator's systems in the article BSS and OSS systems. Billing testing, automation, and performance testing are carried out by B2Bnetwork engineers (What we do).

Questions and answers

How does online charging differ from offline charging?

Online charging works in real time: the system checks the balance before or during the service and can block it when funds run out. This is how prepaid cards and data limits work. Offline charging processes usage records after the fact, usually in batches, and the result appears on the invoice for the cycle.

How many test cases are needed for one tariff change?

There is no single number. The set should cover every pricing rule of the changed offer, its interactions with other offers and discounts, and a fixed list of edge cases such as the cycle boundary and a mid-cycle offer change. A decision table helps: every combination of conditions that yields a different price gets at least one case.

Can production data be used for billing tests?

It is better not to use copies of real customers' data, because they contain personal data and call history. In parallel rating, calculations on production data are run in an environment with production-grade safeguards. In ordinary tests, synthetic data works better, prepared to cover all offers and edge cases.

How do you check that mediation does not lose records?

By reconciling the counts at the input and output of each stage: records received from the network, accepted, rejected as invalid, rejected as duplicates, and passed to rating. The sum must match for every file or every batch. It is also good to trigger a mediation restart during processing and check that no records were lost or counted twice.

What it looks like in a project

Changing an operator's systems? Talk to an engineer who has done it in night windows.

Let's talk

Read more: IT in telecom