telco

Write a price book

Define recurring charges, one-off fees, usage, allowances and discounts in a versioned TOML tariff.

On this page

A price book is a directory. book.toml holds the header, the tax table and the usage kinds; plans and golden tests may live in any *.toml below it — by convention plans/ and tests/. Keys are English, labels are German because they are printed on the bill. Unknown keys are refused, with the nearest valid key as a suggestion, so a typo never silently drops a price.

Amounts are strings ("49.99"): a float never exists, not even while parsing.

The header and the tax table

[book]
id       = "example-fibre"
version  = "2026-11"          # printed in every explanation
prices   = "gross"            # gross: consumer prices incl. VAT · net: business prices
currency = "EUR"

[tax.standard]
rates = [
  { from = "2007-01-01", percent = "19" },
  { from = "2020-07-01", percent = "16" },
  { from = "2021-01-01", percent = "19" },
]

Rates carry the date they start, so re-rating December 2020 uses 16 %, and a month that crosses a change is split at the change date.

Usage kinds

A kind is what a usage record is: a destination class for voice, data, SMS, counted events. It has a label and a measure — seconds, bytes or count.

[kind.calls-mobile]
label   = "Anrufe in Mobilfunknetze"
measure = "seconds"

[kind.calls-eu]
label   = "Anrufe ins EU-Ausland"
measure = "seconds"
eu      = "call"                # checked against the EU cap (0,19 €/min excl. VAT)

eu = "call" or eu = "sms" marks regulated intra-EU communications; a book whose price for them exceeds the cap of Regulation (EU) 2015/2120 Art. 5a is refused. In a gross book the price is converted to net first.

A plan

[plan.glasfaser-1000]
name     = "Glasfaser 1000"
tax      = "standard"
included = ["calls-landline"]   # a flat: rated at zero, still traced

[plan.glasfaser-1000.recurring.base]   # monthly, billed in advance, prorated by day
label  = "Glasfaser 1000"
amount = "49.99"

[plan.glasfaser-1000.one-off.setup]    # billed in the month of the contract start
label  = "Bereitstellung"
amount = "69.99"
on     = "start"                       # or "end"

[plan.glasfaser-1000.discount.welcome]
label  = "Aktionsrabatt"
amount = "-30.00"                      # or: percent = "10"
scope  = "base"                        # a recurring item, or "recurring" for all
months = 3                             # month 1 is the month the contract starts

[plan.glasfaser-1000.usage.calls-mobile]
label = "Anrufe in Mobilfunknetze"
price = "0.19"
per   = "1 min"
round = "60/60"

Unit rounding (the Takt)

Every usage charge states how one event's quantity is rounded, and the bill prints it:

roundMeaning
"60/60"at least 60 s, then whole minutes
"60/1"at least 60 s, then per second
"1/1"per second
"1 KB"data rounded up to whole KB (1 000 bytes; KiB for 1 024)
"none"no rounding (counts)

The price is per per and applied pro rata to the rounded quantity: 1,5 GB at 2,00 € per GB is 3,00 €. Money is never rounded per event — only the line is.

Allowances and tiers

[plan.smart-25.allowance.data]
label = "Inklusivvolumen 25 GB"
kinds = ["data"]
units = "25 GB"

[plan.smart-25.usage.data]
label = "Datenvolumen über 25 GB"
price = "2.00"
per   = "1 GB"
round = "1 KB"

[plan.daten-flex.usage.data]
label = "Datenvolumen"
per   = "1 GB"
round = "1 MB"
tiers = [
  { up_to = "1 GB", price = "3.00" },
  { price = "1.00" },               # the last tier is open-ended
]

Allowances are drawn in date order on rounded units; tiers apply to the cumulative billable units of the month.

Limits

A book has at most 256 files of 1 MiB each, 1 000 plans and 64 tiers per charge, and amounts of at most 10¹². Anything beyond is refused before it is parsed.

The example-api@2026-11 book includes 100 calls and prices each additional call at €0.10. Its golden case rates 150 calls at €5.00. The same book supplies live grants to a network gateway. Online charging

Download Markdown