Zero quantity rates as zero. The minimum charge does not turn a zero-length event into a billable one.
Rating and plans
How rating works
Increments, minimums, prefixes, versions and rounding.
6 min read
The order of operations
- 1Find the plan versionThe version that was effective at the event's timestamp — not the one that is live now. This is what makes last month reproducible.
- 2Find the tariff lineAmong the lines for this event type, take the longest match_key that is a prefix of the matched property.
- 3Round up to the incrementceil(quantity ÷ increment) × increment. 60s billing means a 61-second call bills 120 seconds.
- 4Apply the minimummax(rounded, minimum). A 5-second call on a 30-second minimum bills 30 seconds.
- 5Multiply by the rateFull precision throughout. Rounding happens once, at the end.
- 6Round half-even to four decimal placesBanker's rounding, applied only to the final amount. Intermediate values are never rounded.
Plan versions
Plans are never edited in place. A correction creates a new version with its own effective-from date. If a period has no version covering it, events in that gap are held in an unrated state and surfaced — never silently unbilled and never guessed at.