Invoice documents
Retrieve the sealed invoice as accessible HTML, PDF, XRechnung or ZUGFeRD.
A sealed bill is data. The customer receives a document: who sends it and to whom, every line with the reason it is there, what changed since last month, the contract dates the law requires, how to pay, and the right to object. telco builds that document at the seal and stores it inside the sealed, hashed content. Every format renders that one frozen view:
| Format | For | What |
|---|---|---|
| HTML | Self-care, email, the back office | One self-contained page: lang="de", one h1, tables with captions and header cells, „Warum?" as a native disclosure, light and dark |
| Everyone | One file that is PDF/UA-1 and PDF/A-3b: tagged for screen readers and fit for the archive. Byte-identical on every rendering; stored at the first request | |
| ZUGFeRD | Business customers | The EN 16931 invoice (CII) embedded in that PDF |
| XRechnung | Public buyers (a Leitweg-ID on the account) | The EN 16931 invoice as UBL |
A customer who moves after the seal still sees the old address on the old bill; only the next bill shows the new one.
What every bill carries
| Field | Why |
|---|---|
| Issuer's name, summonable address, phone (landline or free), email, website | § 62 Abs. 1 TKG |
| A domestic agent for service, when the issuer is abroad | § 62 Abs. 1 Nr. 3 TKG |
| Tax number or USt-IdNr., number, date, service period, amounts per VAT rate | § 14 Abs. 4 UStG |
| Contract start, end of the minimum term, notice period, last day to cancel (consumers) | TK-TransparenzV § 4 |
| The right to object to single items within eight weeks, with the date | § 62 Abs. 4, § 67 Abs. 2 TKG |
| Transfer: IBAN, BIC, an ISO 11649 RF reference and a GiroCode | EPC069-12 |
| Direct debit: amount, date, mandate reference, creditor id, the IBAN masked | SEPA pre-notification |
The operator's data comes from TELCO_OPERATOR and is checked when a service starts; a missing field stops the start and names the field:
use telco_core::document::{Address, Issuer, TaxId};
let mut issuer = Issuer {
name: "Stadtwerke Musterstadt GmbH".into(),
address: Address::de("Am Werk 1", "12345", "Musterstadt"),
phone: "0800 1234567".into(),
email: "service@stadtwerke.example".into(),
web: "www.stadtwerke.example".into(),
tax_id: TaxId::VatId("DE123456789".into()),
agent: None,
iban: "DE02120300000000202051".into(),
bic: "BYLADEM1001".into(),
creditor_id: Some("DE98ZZZ09999999999".into()),
register: None,
accent: None,
};
assert!(issuer.validate().is_ok());
issuer.phone.clear();
let refusal = issuer.validate().unwrap_err();
assert_eq!((refusal.code, refusal.at.as_deref()), ("document.issuer-invalid", Some("phone")));
assert_eq!(refusal.rule, Some("DE-TKG-62-1-content"));Building a document
document::bill takes the sealed charges and totals plus what the seal reads from the account, and writes every sentence — renderers place strings, they never format a number or compute a date:
use std::collections::BTreeMap;
use telco_core::bill::{BillInput as Compose, PlanSlice, SubscriptionInput, compose};
use telco_core::contract::{Salutation, Terms};
use telco_core::document::{Address, BillInput, DocumentKind, Issuer, Payment, PaymentMethod, Recipient, TaxId, bill};
use time::macros::date;
# let book = telco_core::compile(&[("book.toml".to_owned(), br#"
# [book]
# id = "fibre"
# version = "2026-11"
# prices = "gross"
# currency = "EUR"
# [tax.standard]
# rates = [{ from = "2021-01-01", percent = "19" }]
# [plan.g1000]
# name = "Glasfaser 1000"
# tax = "standard"
# recurring.base = { label = "Glasfaser 1000", amount = "49.99" }
# "#.to_vec())])?;
# let issuer = Issuer { name: "Stadtwerke Musterstadt GmbH".into(), address: Address::de("Am Werk 1", "12345", "Musterstadt"),
# phone: "0800 1234567".into(), email: "service@stadtwerke.example".into(), web: "www.stadtwerke.example".into(),
# tax_id: TaxId::VatId("DE123456789".into()), agent: None, iban: "DE02120300000000202051".into(),
# bic: "BYLADEM1001".into(), creditor_id: None, register: None, accent: None };
let books = |r: &str| (r == "fibre@2026-11").then_some(&book);
let sub = SubscriptionInput {
id: "s1".into(),
active_from: Some(date!(2026 - 11 - 01)),
ends_on: None,
slices: vec![PlanSlice { plan: "g1000".into(), book_version: "fibre@2026-11".into(), from: date!(2026 - 11 - 01), to: None }],
};
let november = compose(&books, &Compose { period: "2026-11".parse()?, subscriptions: &[sub], usage: &[], billed_previous: &[] })?;
let customer = Recipient {
name: "Max Mustermann".into(),
address: Address::de("Hauptstraße 5", "12345", "Musterstadt"),
consumer: true,
salutation: Salutation::Du,
customer_number: "KD-000001".into(),
vat_id: None, buyer_reference: None, email: None,
};
let terms = Terms { consumer: true, start: date!(2026 - 11 - 01), initial_months: 24, notice_months: 1, renews: true };
let doc = bill(&BillInput {
kind: DocumentKind::Invoice,
number: "RE-2026-000001",
issued: date!(2026 - 11 - 01),
cites: None,
issuer: &issuer,
recipient: &customer,
payment: &PaymentMethod::Transfer,
payment_terms_days: 14,
charges: &november.charges,
totals: &november.totals,
products: &BTreeMap::from([("s1".to_owned(), "Glasfaser-Anschluss".to_owned())]),
contracts: &[terms],
previous: None,
period: "2026-11".parse()?,
next: None, // the seal sets the following month's estimate
})?;
assert_eq!(doc.headline, "Deine Rechnung für November 2026");
assert_eq!(doc.objection.until, date!(2026 - 12 - 27)); // eight weeks
assert!(doc.contracts[0].lines.iter().any(|l| l.contains("muss deine Kündigung spätestens am 30.09.2028")));
let Payment::Transfer { reference, girocode, .. } = &doc.payment else { unreachable!() };
assert!(reference.starts_with("RF") && reference.ends_with("RE2026000001"));
assert!(girocode.starts_with("BCD\n002\n1\nSCT\nBYLADEM1001\nStadtwerke Musterstadt GmbH\n"));
# Ok::<(), telco_core::Refusal>(())What changed
From the second bill on, the document opens with one deterministic sentence against the previous invoice: the difference and at most three causes by size, the rest counted — „Diese Rechnung ist 15,00 € höher als Ihre letzte Rechnung RE-2026-000002: „Glasfaser 2000“ statt „Glasfaser 1000“ (59,99 € statt 49,99 €, +10,00 €) und …". A line of the same item that only changed its name (a plan change, the next promotion month) is one cause, not a gone and a new line. Causes and rest always add up to the difference.
Credit notes are „Stornorechnungen"
A credit note cancels a bill. Its title is „Stornorechnung", it names the cancelled bill's number and date, and it is numbered ST-2026-000001. telco never prints „Gutschrift": in German VAT law that word means a self-billed invoice (§ 14 Abs. 2 Satz 5 UStG). As an e-invoice it is type 381 with positive amounts and BT-25.
E-invoices are validated before a number is spent
For a business account, the seal builds the e-invoice and validates it — as XRechnung when the account has a Leitweg-ID, else as EN 16931 — before the bill number is allocated. A bill that would not validate (an XRechnung without the buyer's invoice email, for instance) is held with the failed rules in a de.telco.bill.held event, and no number is consumed.
The renewal notice
Before a consumer contract renews tacitly, § 56 Abs. 3 TKG requires a notice on a durable medium. document::renewal_notice opens with the one action that matters:
use telco_core::contract::{Salutation, Terms};
use telco_core::document::{Address, Issuer, Recipient, TaxId, renewal_notice};
use time::macros::date;
# let issuer = Issuer { name: "Stadtwerke Musterstadt GmbH".into(), address: Address::de("Am Werk 1", "12345", "Musterstadt"),
# phone: "0800 1234567".into(), email: "service@stadtwerke.example".into(), web: "www.stadtwerke.example".into(),
# tax_id: TaxId::VatId("DE123456789".into()), agent: None, iban: "DE02120300000000202051".into(),
# bic: "BYLADEM1001".into(), creditor_id: None, register: None, accent: None };
# let customer = Recipient { name: "Erika Mustermann".into(), address: Address::de("Hauptstr. 1", "12345", "Musterstadt"),
# consumer: true, salutation: Salutation::Sie, customer_number: "KD-000002".into(), vat_id: None, buyer_reference: None, email: None };
let terms = Terms { consumer: true, start: date!(2026 - 10 - 01), initial_months: 24, notice_months: 1, renews: true };
let letter = renewal_notice(&issuer, &customer, &terms, false, date!(2028 - 07 - 15))?;
assert_eq!(
letter.opening,
"Wenn Sie Ihren Vertrag nicht verlängern möchten, muss Ihre Kündigung spätestens am 31.08.2028 bei uns eingehen."
);
// After the last day to cancel there is nothing left to prevent.
let late = renewal_notice(&issuer, &customer, &terms, false, date!(2028 - 09 - 01)).unwrap_err();
assert_eq!(late.code, "letter.not-applicable");
# Ok::<(), telco_core::Refusal>(())Rendering
The renderers live in the telco-render crate and are pure: html::bill, pdf::bill (Typst, in a sandbox that serves only the template, the data and bundled fonts — no packages, no network, no files) and einvoice::{xml, pdf}. Customer text reaches the page escaped and the PDF as data, never as markup.
Page one
The page answers „was muss ich tun, und warum so viel?" before the customer asks:
- The amount and the one thing to do come first — „Bitte überweisen Sie bis Montag, 19. Oktober — am schnellsten mit dem GiroCode unten.", or for a direct debit the day it is collected and „Sie müssen nichts tun." Links lead to the payment details, „Fälligkeit in den Kalender" and „Stimmt etwas nicht?".
- The first bill explains itself: a box names why it is higher (27 von 31 Tagen, einmalig: Bereitstellung, Aktionsrabatt) and what follows — „Ab November zahlen Sie voraussichtlich 29,97 € im Monat." The estimate is next month's advance charges as composed on the seal day, frozen with the document.
- „Warum?" shows the month as a strip of days with the billed ones marked, and says it in words for screen readers.
- What changed is a waterfall: the previous bill, each cause, the rest, this bill — bars that add up, with the diff sentence as their text.
- The contract is a line from its start to the end of the minimum term, the last day to cancel marked where it falls.
- The calendar entry is in the page (an iCalendar
data:link with the due or debit date and a reminder the day before): saving it sends nothing to anyone.
Light and dark follow the system; at 320 px the page is one column; it needs no script. Every graphic has a text equivalent, and the PDF still carries every legal field.
The live bill: GET /billing-accounts/{id}/open-bill/html renders the open month as the same page, marked „Vorschau — noch keine Rechnung", without a number, a payment request or a GiroCode, and never stores it.
In billd: GET /bills/{id}/html, /pdf and /xml; in contractd: GET /contracts/{id}/renewal-notice/html and /pdf (services).
The itemised bill (EVN, § 65 TKG) is a separate statement served by usaged. Fixed-line itemisation