# Quittio E-invoicing for PHP and Laravel. Quittio creates, validates, reads and renders electronic invoices based on the European standard EN 16931 – ZUGFeRD/Factur-X, XRechnung, UBL and Peppol BIS from one data model. The core runs in any PHP application; the Laravel integration adds facade, configuration and commands. [Get started](getting-started.md) [Formats and profiles](formats.md) --- Germany is the first market; everything country-specific (VAT rates, legal texts, XRechnung) lives in country packs, so the core stays country-neutral. > **Status:** version 1.1. The public API changes only in major releases ([Versioning and compatibility](compatibility.md)). The legal wording of the country pack Germany was reviewed by a tax adviser in October 2026; Quittio is no tax or legal advice (see the legal review and the disclaimer in the README). ## Packages | Package | Purpose | |---|---| | `quittio/core` | Country-neutral core: EN 16931 data model, calculation, profiles, CII and UBL writers/readers, ZUGFeRD/Factur-X PDF/A-3, validation. Usable without Laravel. | | `quittio/laravel` | Laravel integration: facade, configuration, Blade templates, commands, testing helpers. | | `quittio/country-de` | Country pack for Germany: UStG mandatory fields, tax presets, XRechnung profiles and BR-DE rules, DIN 5008 letter layouts. | | `quittio/country-at`, `quittio/country-be`, `quittio/country-ch`, `quittio/country-fr` | Country packs for Austria, Belgium, Switzerland and France, not reviewed by a tax adviser yet: see [Austria](country-at.md), [Belgium](country-be.md), [Switzerland](country-ch.md) and [France](country-fr.md). | | `quittio/quittio` | Everything in one package: core, Laravel integration and the country pack Germany. | | `quittio/managed` | Managed layer (commercial licence, not released yet): issuer profiles, drafts, gapless numbering, archive with hashes, cancellations and corrections, mail delivery, audit log, retention. | ## Requirements - PHP 8.3 or newer with `ctype`, `dom`, `gd`, `libxml`, `mbstring`, `xmlwriter`, `zlib`; `intl` recommended, `zip` for `quittio:schemas:download` - Laravel 13 (only for `quittio/laravel`) - Optional: Java 11+ for the KoSIT validator, veraPDF or Docker for PDF/A checks, `opis/json-schema` for JSON input validation ## Supported formats | Format | Content | |---|---| | `zugferd` / `factur-x` | PDF/A-3 with embedded CII XML (profiles MINIMUM to EXTENDED, XRECHNUNG) | | `xrechnung-cii`, `xrechnung-ubl` | XRechnung 3.0 as plain XML | | `cii`, `ubl` | Plain CII or UBL 2.1 XML in any profile | | `peppol` | UBL according to Peppol BIS Billing 3.0 | | `pdf`, `html`, `json` | PDF without XML, HTML preview, normalised data model | ## Quick example ```php use Quittio\Core\Builder\Party; use Quittio\Core\Enums\UnitCode; use Quittio\Laravel\Facades\Quittio; $result = Quittio::invoice() // seller and bank account from config/quittio.php ->number('RE-2026-0042') ->deliveryDate('2026-09-30') ->buyer(Party::make('Kunde AG') // or a model: ->buyer($customer) ->vatId('DE987654321') ->address('Bahnhofstraße 5', '54321', 'Beispielstadt', 'DE')) ->line('Web development', netPrice: '95.00', quantity: 24, unit: UnitCode::Hour) ->line('Hosting', netPrice: '49.00') // quantity 1, VAT 19 % by default ->dueInDays(14) ->render(); // ZUGFeRD: PDF/A-3 with embedded XML $result->pdf(); $result->save('invoices', '2026/'); $result->cancel('ST-2026-0001', reason: 'Charged twice'); // the cancellation, rendered ``` ## Documentation New to Quittio? Follow [Getting started](getting-started.md); new to e-invoicing? Read [E-invoicing basics](concepts.md) first. | Topic | Content | |---|---| | [Getting started](getting-started.md) | Installation, your company in the configuration, a first invoice, rendering, cancellation, use without Laravel | | [E-invoicing basics](concepts.md) | EN 16931, CII and UBL, ZUGFeRD, XRechnung, Peppol, profiles, rule codes, which format you need, German terms | | [Examples](examples.md) | Complete examples: service invoices, VAT rates, online shops, small businesses, XRechnung, customers abroad, final invoices, cancellations, orders, drafts, reminders, incoming invoices | | [Building invoices](building-invoices.md) | Every builder method: parties, lines, VAT, payment, references, calculation, cancellations, data model | | [Formats and profiles](formats.md) | Output formats, the automatic format choice, embedded files and XMP | | [Validation](validation.md) | What is checked (levels L1 to L7), error messages, KoSIT and veraPDF | | [Templates and design](templates.md) | Logo, colours, texts, partials, own templates, view model, letter layouts, fonts | | [Quotes and other documents](documents.md) | Quotes, order confirmations, delivery notes, proforma invoices, reminders, statements | | [Reading incoming invoices](reading.md) | XML and PDF input, findings, limits | | [Laravel integration](laravel.md) | Facade, rendering, storage, queue, events, mail, Blade templates, preview | | [Configuration](configuration.md) | Every key of `config/quittio.php` | | [Artisan commands](commands.md) | All commands and publish tags | | [Testing](testing.md) | Fake, assertions, factories, scenarios | | [Country packs](country-packs.md) | The German pack: tax presets, rules, XRechnung, reminders; writing a pack | | [Austria](country-at.md), [Belgium](country-be.md), [Switzerland](country-ch.md), [France](country-fr.md) | The other country packs: presets, rules, formats, payment QR codes, default interest | | [Managed layer](managed.md) | Preview of the unreleased package: issuer profiles, customers, numbering, archive, cancellations and corrections, delivery, audit log, immutability, retention | | [Troubleshooting](troubleshooting.md) | Common errors with cause and fix | | [FAQ](faq.md) | Sending, the German e-invoicing obligation, Java, temporary files, queued invoices | | [Field reference](field-reference.md) | Every field of the data model with BT, cardinality and XML paths (generated) | | API reference | Every public class and method with its parameters and doc comment (generated) | | [AI assistants](ai.md) | llms.txt, the MCP server of this documentation, Laravel Boost guidelines and skill | ## Licence Open core: `quittio/core`, `quittio/laravel`, the country packs `quittio/country-de`, `-at`, `-be`, `-ch`, `-fr` and `quittio/quittio` are released under the MIT licence. The Managed layer `quittio/managed` will be commercially licensed; it is not released yet. # Getting started In this tutorial you install Quittio, enter your company once and then create, render and cancel a first invoice. It takes about 15 minutes. If e-invoices, ZUGFeRD or XRechnung are new to you, read [E-invoicing basics](concepts.md) first (5 minutes); you can also start right away and look terms up there. You need PHP 8.3 or newer and, for the Laravel integration, Laravel 13. Without Laravel, switch the code blocks to PHP; [Without Laravel](#without-laravel) describes the setup of the core. ## Installation ```bash laravel composer require quittio/quittio # core, Laravel integration and country pack Germany php artisan quittio:install # publishes config/quittio.php (and config/quittio/countries/de.php for Germany) ``` ```bash plain composer require quittio/core quittio/country-de # core and country pack Germany ``` ## Set up your company Every invoice names the seller: your company. You enter it once in `config/quittio.php`; `Quittio::invoice()` then adds it to every invoice. Without Laravel there is no configuration file: you pass the seller and its bank account to `Quittio::create()`, and `$quittio->invoice()` adds them to every invoice; the plain PHP code on this page uses this instance `$quittio`. The keys you need first: ```php laravel // config/quittio.php (excerpt) 'seller' => [ 'name' => env('QUITTIO_SELLER_NAME'), // e.g. Muster GmbH 'vat_id' => env('QUITTIO_SELLER_VAT_ID'), // e.g. DE123456789 'tax_number' => env('QUITTIO_SELLER_TAX_NUMBER'), // e.g. 12/345/67890 'address' => ['line1' => 'Hauptstraße 1', 'postcode' => '12345', 'city' => 'Musterstadt', 'country' => 'DE'], 'contact' => ['name' => 'Max Muster', 'phone' => '+49 123 456789', 'email' => 'rechnung@muster.de'], 'electronic_address' => ['value' => 'rechnung@muster.de', 'scheme' => 'EM'], 'bank_accounts' => [ ['iban' => 'DE02120300000000202051', 'bic' => 'BYLADEM1001', 'name' => 'Muster GmbH'], ], // ... ], ``` ```php plain use Quittio\Core\Builder\InvoiceBuilder; use Quittio\Core\Builder\Party; use Quittio\Core\Quittio; use Quittio\Core\Tax\CountryDefaultVat; use Quittio\Country\DE\CountryDE; $quittio = Quittio::create([ 'seller' => Party::make('Muster GmbH') ->vatId('DE123456789') ->taxNumber('12/345/67890') ->address('Hauptstraße 1', '12345', 'Musterstadt', 'DE') ->contact('Max Muster', '+49 123 456789', 'rechnung@muster.de') ->electronicAddress('rechnung@muster.de', 'EM'), 'bank_account' => ['iban' => 'DE02120300000000202051', 'bic' => 'BYLADEM1001', 'name' => 'Muster GmbH'], 'due_days' => 14, // payment target for invoices without one ], [new CountryDE]); InvoiceBuilder::useDefaultVat(new CountryDefaultVat($quittio->countries())); // lines without vat(): 19 % ``` | Key | Needed | Why | |---|---|---| | `name`, `address` | Always | German invoices must name the seller with the full address | | `vat_id` or `tax_number` | Always | German invoices must show one of them; the VAT identification number (USt-IdNr.) is preferred | | `contact`, `bank_accounts`, `electronic_address` | Recommended | Printed on the invoice or written to the XML; required for XRechnung (public buyers). The first account with an IBAN is used; without Laravel, one account as `bank_account` | | `small_business` | Small businesses only | `true` (or `QUITTIO_SELLER_SMALL_BUSINESS=true`) marks every invoice as small business invoice without VAT (German Kleinunternehmer); without Laravel, `'small_business' => true` in `Quittio::create()` | A seller without VAT identification number (e.g. a small business with a tax number only) also needs a trade register number (`legal_registration`) or another identifier (`identifiers`, as `[['value' => '…', 'scheme' => null]]`), because EN 16931 requires one of them (rule `BR-CO-26`). Every other key, such as logo, colours, default VAT and payment target, is explained in [Configuration](configuration.md) and in the comments of `config/quittio.php`. To see the PDF design with sample data: ```bash php artisan quittio:preview --scenario=simple # storage/app/quittio/preview/simple.pdf ``` ## Building an invoice Start an invoice with `Quittio::invoice()`, add what is specific to this invoice, and end with `render()`. Without Laravel, start with `$quittio->invoice()` in the same way: ```php laravel use Quittio\Core\Builder\Party; use Quittio\Core\Enums\UnitCode; use Quittio\Country\DE\Tax\VatPreset; use Quittio\Laravel\Facades\Quittio; $result = Quittio::invoice() // your company from config/quittio.php ->number('RE-2026-0042') ->deliveryDate('2026-09-30') // date of supply, mandatory in Germany ->buyer(Party::make('Kunde AG') ->vatId('DE987654321') ->address('Bahnhofstraße 5', '54321', 'Beispielstadt', 'DE')) ->line('Web development', netPrice: '95.00', quantity: 24, unit: UnitCode::Hour, description: 'Customer portal, sprint 3') ->line('Hosting', netPrice: '49.00', unit: UnitCode::Month) ->line('Handbook of VAT law', netPrice: '39.00', vat: VatPreset::Reduced) ->dueInDays(14)->cashDiscount(days: 7, percent: '2.00') ->render(); return $result->download(); // or $result->save('invoices', '2026/') ``` ```php plain use Quittio\Core\Builder\Party; use Quittio\Core\Enums\UnitCode; use Quittio\Country\DE\Tax\VatPreset; $result = $quittio->invoice() // your company from Quittio::create() ->number('RE-2026-0042') ->deliveryDate('2026-09-30') // date of supply, mandatory in Germany ->buyer(Party::make('Kunde AG') ->vatId('DE987654321') ->address('Bahnhofstraße 5', '54321', 'Beispielstadt', 'DE')) ->line('Web development', netPrice: '95.00', quantity: 24, unit: UnitCode::Hour, description: 'Customer portal, sprint 3') ->line('Hosting', netPrice: '49.00', unit: UnitCode::Month) ->line('Handbook of VAT law', netPrice: '39.00', vat: VatPreset::Reduced) ->dueInDays(14)->cashDiscount(days: 7, percent: '2.00') ->render(); $result->save(__DIR__.'/invoices/2026/'); // invoices/2026/Rechnung_RE-2026-0042.pdf ``` What the lines do: - `number()` is your invoice number. The invoice date is today unless you call `issueDate('2026-10-03')`. Gapless numbering is your application's job, or that of the [Managed layer](managed.md). - `deliveryDate()` is the date the goods were delivered or the service was performed. German invoices must state it, even when it is the invoice date. - `buyer()` is your customer. `Party::make()` takes the name; add the address and, for businesses, the VAT identification number. You can also pass your own customer model ([Application models](#application-models)). - `line()` adds a line with a name and named values. `netPrice` is the price per unit without VAT. Without `quantity` the quantity is 1; without `vat` the line gets the standard rate of your country (19 % in Germany). The third line uses the reduced rate of 7 %. - `dueInDays(14)` sets the payment target, `cashDiscount()` an early payment discount (Skonto). - `render()` calculates totals and VAT, checks the invoice, chooses the format and produces the PDF and the XML ([Rendering](#rendering)). Totals and VAT are always calculated by Quittio; you never pass them in. Amounts and quantities are strings (`'95.00'`), because floating point numbers cannot store every amount exactly; floats are rejected. Rounding follows EN 16931: half up, two decimals for amounts, VAT per rate. ### One way to write it Every part of an invoice has one usual form. The documentation and the examples use these forms; the other forms exist for special cases and are explained in [Building invoices](building-invoices.md). | You need | Write | |---|---| | A line with price, quantity, unit, VAT or description | `->line('Hosting', netPrice: '49.00', quantity: 12, unit: UnitCode::Month)`. Without `quantity` it is 1, without `vat` the [default VAT](building-invoices.md#default-vat) applies (19 % for a German seller). | | A line with more than that: item number, line discount, list price, period, sub lines, line group | `->line(Line::make('Pump', netPrice: '1450.00', quantity: 2)->sellerId('P-200'))`. `Line::make()` takes the same named values as `line()` and returns the line builder for the other methods. | | Many lines from your data | `->lines($order->items)` with models that implement `ProvidesInvoiceLine`, or `->lines($rows)` with arrays such as `['name' => 'Hosting', 'netPrice' => '49.00']` | | The customer | `->buyer($customer)` with a model that implements `ProvidesParty`, otherwise `->buyer(Party::make('Kunde AG')->address(…))` | | Payment terms | `->dueInDays(14)->cashDiscount(days: 7, percent: '2.00')` | | The result | `->render()` for PDF and XML, `->build()` for the data only, e.g. to store a draft | The seller comes from the configuration; set it in code only for another company (see [Starting invoices](laravel.md#starting-invoices)). Without Laravel it comes from `Quittio::create()` in the same way. References, notes, further parties, allowances and charges, direct debit, attachments, gross prices and all other options are described in [Building invoices](building-invoices.md); the German VAT presets (`VatPreset::Standard`, `Reduced`, `ReverseChargeEu` …) in [Tax presets](country-packs.md#tax-presets). ### Application models Your own models can provide invoice data through three contracts in `Quittio\Core\Contracts`: `ProvidesParty` (`fillParty(PartyBuilder $party)`, e.g. a customer as buyer), `ProvidesInvoiceLine` (`fillLine(LineBuilder $line)`, e.g. order items) and `ProvidesInvoiceData` (`toInvoiceData()`, e.g. an order for `Quittio::make($order)`). ```php laravel use Quittio\Core\Builder\PartyBuilder; use Quittio\Core\Contracts\ProvidesParty; use Quittio\Laravel\Facades\Quittio; class User extends Authenticatable implements ProvidesParty { public function fillParty(PartyBuilder $party): void { $party->name($this->company ?? $this->name) ->vatId($this->vat_id) ->address($this->street, $this->postcode, $this->city, $this->country) ->electronicAddress($this->email, 'EM'); } } $invoice = Quittio::invoice() ->buyer($user) // ProvidesParty ->lines($order->items) // items implement ProvidesInvoiceLine // ... ->build(); ``` ```php plain use Quittio\Core\Builder\PartyBuilder; use Quittio\Core\Contracts\ProvidesParty; class Customer implements ProvidesParty { public function fillParty(PartyBuilder $party): void { $party->name($this->company ?? $this->name) ->vatId($this->vat_id) ->address($this->street, $this->postcode, $this->city, $this->country) ->electronicAddress($this->email, 'EM'); } } $invoice = $quittio->invoice() ->buyer($customer) // ProvidesParty ->lines($order->items) // items implement ProvidesInvoiceLine // ... ->build(); ``` The invoice keeps a copy of these values; changing the model later does not change invoices that were already built. More in [Application models](building-invoices.md#application-models); to store invoices and link them to the user (`HasInvoices` trait, `$user->invoices()`), see [Customers and references](managed.md#customers-and-references) in the Managed layer. ## Rendering `render()` without argument chooses the format for you: for a German seller ZUGFeRD for businesses (a PDF with the XML inside), XRechnung for public authorities and a plain PDF for consumers ([Which format do I need?](concepts.md#which-format-do-i-need)). Name a format when a customer asks for one: ```php laravel $result = Quittio::invoice() ->number('RE-2026-0043') ->deliveryDate('2026-09-30') ->buyer(Party::make('Stadt Beispielstadt') ->address('Rathausplatz 1', '54321', 'Beispielstadt', 'DE') ->electronicAddress('rechnung@beispielstadt.de', 'EM')) // XRechnung needs it ->buyerReference('04011000-12345-03') // Leitweg-ID of the authority ->line('Consulting', netPrice: '120.00') ->render('xrechnung-cii'); ``` ```php plain $result = $quittio->invoice() ->number('RE-2026-0043') ->deliveryDate('2026-09-30') ->buyer(Party::make('Stadt Beispielstadt') ->address('Rathausplatz 1', '54321', 'Beispielstadt', 'DE') ->electronicAddress('rechnung@beispielstadt.de', 'EM')) // XRechnung needs it ->buyerReference('04011000-12345-03') // Leitweg-ID of the authority ->line('Consulting', netPrice: '120.00') ->render('xrechnung-cii'); ``` The result holds everything that was produced: ```php laravel $result->pdf(); // the PDF (PDF/A-3 with embedded XML for ZUGFeRD) $result->xml(); // the XML $result->filename(); // Rechnung_RE-2026-0042.pdf $result->validation(); // findings of the validation, including warnings $result->save('invoices', '2026/'); // to a filesystem disk and path return $result->download(); // or ->stream(), or return $result Mail::to($customer)->send(new YourInvoiceMail($result)); // your Mailable; the result is Attachable ``` ```php plain $result->pdf(); // the PDF (PDF/A-3 with embedded XML for ZUGFeRD) $result->xml(); // the XML $result->filename(); // Rechnung_RE-2026-0042.pdf $result->validation(); // findings of the validation, including warnings $result->save('/path/to/invoices/2026/'); // to a local directory or file header('Content-Type: '.$result->mimeType()); // send it to the browser header('Content-Disposition: attachment; filename="'.$result->filename().'"'); echo $result->contents(); $email->attach($result->contents(), $result->filename(), $result->mimeType()); // e.g. a Symfony Mailer Email ``` Every render calculates, validates and renders. An invalid invoice throws a `ValidationException` that names the rule, the field and how to fix it ([Troubleshooting](troubleshooting.md)). For invoice data you built earlier (`->build()` instead of `->render()`), or for more control, use `Quittio::make()` (without Laravel `$quittio->make()`): ```php laravel use Quittio\Laravel\Facades\Quittio; $result = Quittio::make($invoice)->render(); // format chosen automatically $result = Quittio::make($invoice)->format('zugferd')->locale('en')->render(); // format and language $result = Quittio::make($invoice)->formats(['zugferd', 'xrechnung-cii'])->render(); // several formats at once $result->as('xrechnung-cii')->xml(); Quittio::make($invoice)->queue()->save('invoices', '2026/'); // render in a queue job ``` ```php plain $result = $quittio->make($invoice)->render(); // format chosen automatically $result = $quittio->make($invoice)->format('zugferd')->locale('en')->render(); // format and language $result = $quittio->make($invoice)->formats(['zugferd', 'xrechnung-cii'])->render(); // several formats at once $result->as('xrechnung-cii')->xml(); ``` All formats and profiles are described in [Formats and profiles](formats.md); storage, downloads, queues, events and mail in [Laravel integration](laravel.md). ## Cancellation An issued invoice is never changed or deleted. To cancel it, you issue a cancellation invoice (German Stornorechnung): a new invoice with its own number that refers to the original and reverses its amounts. ```php laravel $cancellation = $result->cancel('ST-2026-0001', reason: 'Charged twice'); // rendered, in the formats of $result ``` ```php plain $cancellation = $quittio->make($quittio->cancellation($result->data(), 'ST-2026-0001', reason: 'Charged twice')) ->formats($result->formats())->render(); // in the formats of $result ``` For an invoice you stored as data, build the cancellation and render it: ```php laravel $cancellation = Quittio::make(Quittio::cancellation($original, 'ST-2026-0001', reason: 'Charged twice'))->render(); ``` ```php plain $cancellation = $quittio->make($quittio->cancellation($original, 'ST-2026-0001', reason: 'Charged twice'))->render(); ``` `$original` is the issued, calculated invoice, e.g. `$result->data()` or `InvoiceData::fromJson()` of what you stored. In Germany the cancellation is a credit note with positive amounts by default (type code 381); `strategy: 'negative_invoice'` produces an invoice with negative amounts instead (type code 380, also `corrections.cancellation_strategy`). Both are permitted in Germany; the document is called "Stornorechnung" (cancellation invoice), never "Gutschrift" (which means a self-billed invoice in German law). `lines:` cancels part of an invoice (whole lines, quantities or amounts): ```php laravel $part = $result->cancel('ST-2026-0002', lines: [ ['line' => '1', 'quantity' => '1'], ['line' => '2', 'amount' => '40.00'], ]); ``` ```php plain $part = $quittio->make($quittio->cancellation($result->data(), 'ST-2026-0002', lines: [ ['line' => '1', 'quantity' => '1'], ['line' => '2', 'amount' => '40.00'], ]))->formats($result->formats())->render(); ``` When an invoice is cancelled in several parts, pass the earlier parts as `history:`, so that the VAT of all parts adds up exactly to the VAT of the original. Strategies, partial cancellations and the history are described in [Cancellations and corrections](building-invoices.md#cancellations-and-corrections); the Managed layer keeps the history itself ([Managed layer](managed.md#cancellations-and-corrections)). ## Without Laravel The core (`quittio/core`, plus a country pack such as `quittio/country-de`) works in any PHP application. The code blocks above show it when you switch them to PHP; this section sums up the setup. Create an instance with `Quittio\Core\Quittio::create()`; there is no configuration file, so the seller and its bank account are passed there and the default VAT is registered once. `$quittio->invoice()` then starts invoices like `Quittio::invoice()` in Laravel: ```php use Quittio\Core\Builder\InvoiceBuilder; use Quittio\Core\Builder\Party; use Quittio\Core\Quittio; use Quittio\Core\Tax\CountryDefaultVat; use Quittio\Country\DE\CountryDE; $quittio = Quittio::create([ 'seller' => Party::make('Muster GmbH')->vatId('DE123456789')->address('Hauptstraße 1', '12345', 'Musterstadt', 'DE'), 'bank_account' => ['iban' => 'DE02120300000000202051'], 'validation' => ['mode' => 'error', 'levels' => ['L1', 'L2', 'L3', 'L4', 'L7']], 'pdf' => ['b2c_embed_xml' => false], ], [new CountryDE]); InvoiceBuilder::useDefaultVat(new CountryDefaultVat($quittio->countries())); // lines without vat(): 19 % $result = $quittio->invoice() // with the seller and its bank account // ... as above ->render('zugferd'); file_put_contents($result->filename(), $result->pdf()); // or $result->save('/path/to/dir') $cancellation = $quittio->cancellation($result->data(), 'ST-2026-0001', reason: 'Charged twice'); ``` `$quittio->invoice()` applies the seller as `Quittio::invoice()` does: `->seller(fn ($s) => …)` changes the configured seller, another seller (`->seller(Party::make(…))`) drops its bank account and small business flag, `payment()` with an IBAN replaces the account and `creditTransfer()` adds a further one. It ends with `->render()`, `->render('xrechnung-cii')`, `->render(['zugferd', 'xrechnung-cii'])` or `->check()`. `$quittio->quote()`, `orderConfirmation()`, `deliveryNote()`, `proforma()`, `paymentReminder()`, `bonusStatement()` and `accountStatement()` start documents with the same seller and end with `->render()`. For anything special, such as several sellers in one application, `InvoiceBuilder::make()` still starts an empty invoice: set the seller with `->seller()` and render it with `$quittio->make($builder)->render()`. `Quittio::create(Config|array $config = [], iterable $countryPacks = [], ?PdfRenderer $renderer = null, ?TemplateEngine $templates = null, ?LoggerInterface $logger = null, ?FormatResolver $formatResolver = null)` takes the configuration as array or as `Quittio\Core\Config` object (`new Config(...)`, `Config::fromArray([...])`, `$config->with([...])`). The array keys are flatter than those of the Laravel `config/quittio.php`; the Laravel integration translates its configuration itself: | Key | Default | Laravel key | |---|---|---| | `seller` | `null` (a `Party::make()` builder or a `SellerParty`: the seller of `invoice()` and the document methods) | `seller.*` | | `bank_account` | `null` (`['iban' => …, 'bic' => …, 'name' => …]`, added as SEPA credit transfer; needs `seller`) | `seller.bank_accounts` (the first account with an IBAN) | | `small_business` | `false` (flags every invoice as small business invoice; needs `seller`) | `seller.small_business` | | `format` | `null` (automatic choice; also `'auto'`) | `defaults.format` | | `profile` | `en16931` | `defaults.profile` | | `locale`, `country` | `null` (country pack default, seller country) | `defaults.locale`, `defaults.country` | | `due_days` | `null` | `defaults.due_days` | | `template`, `template_paths` | `default`, `[]` (directories with `{name}.php`) | `pdf.template` (Blade view) | | `filename` | `{title}_{number}.{ext}` | `pdf.filename` | | `pdf.pdfa`, `pdf.b2c_embed_xml`, `pdf.girocode_amount` | `true`, `false`, `due` | `pdf.pdfa`, `format_resolver.b2c_embed_xml`, `pdf.payment_qr.girocode_amount` | | `auto_upgrade_profile` | `true` | `format_resolver.auto_upgrade_profile` | | `validation.mode` | `error` (`warn`, `off`) | `validation.mode` | | `validation.levels` | `['L1', 'L2', 'L3', 'L4', 'L7']` | `validation.levels` (`php`, `xsd`) | | `validation.block_on_warnings` | `false` | `validation.block_on_warnings` | | `validation.locale` | `null` (the language of the invoice; `'app'` = the language of the translator; or a locale) | `validation.locale` (default: the language of the application) | | `validation.kosit`, `validation.verapdf` | disabled; `['enabled' => true, 'mode' => …, …]` enables L5 and L6 (KoSIT scenario sets only in `configurations`) | `validation.levels` (`kosit`, `verapdf`) and `validation.drivers.*` | | `mandatory_fields` | `exception` (`log`, `off`) | `validation.mandatory_field_guard` | | `temp_dir` | system temp directory | `pdf.cache_path` | | `options` | `[]` (e.g. `paper`, `markdown`, `fold_marks`, `watermark`) | `pdf.paper`, `pdf.markdown`, `pdf.fold_marks` | | `presentation` | `null` (a `Presentation` object with the design defaults) | `pdf.*` design keys | | `reader.max_xml_bytes`, `reader.max_pdf_bytes`, `reader.max_decompressed_bytes` | 10, 25 and 50 MB | `reader.*` | | `corrections.cancellation_strategy` | `null` (country pack default) | `corrections.cancellation_strategy` | The validation keys are described in [Validation](validation.md), the output keys in [Output configuration](formats.md#output-configuration), the Laravel keys in [Configuration](configuration.md). The instance offers the methods of the facade: `invoice()` and the document methods, `make()`, `edit()` (continue existing invoice data), `cancellation()`, `document()`, `read()`, `readFile()`, `validateFile()` and `validatePath()`, plus `registerCountry()`, `setRenderer()`, `setTemplateEngine()`, `setFormatResolver()`, `setPostProcessor()` (PDF/A and XML embedding for renderers that cannot embed), `addSerializer()`, `addValidator()`, `clearValidators()`, `configureRules()` and `ruleCodes()` ([switching rules off](validation.md#switching-rules-off-and-changing-their-severity)) and `onMandatoryFieldsMissing()`. A custom `Quittio\Core\Calculation\TotalsCalculator`, passed to `Quittio::create(calculator: …)` (or the constructor), calculates render runs, documents, read invoices, edits and cancellations; `calculator()` returns it. Without one, the EN 16931 calculator applies the calculation policy of `calculation.declared_amounts` ([Declared amounts](building-invoices.md#declared-amounts)). The core uses plain PHP templates (`resources/templates/default.php`); pass your own `TemplateEngine` to `Quittio::create()` for Twig or others. ## JSON `InvoiceData::toArray()`, `toJson()`, `fromArray()` and `fromJson()` convert the model losslessly. The JSON Schema is shipped in `packages/core/resources/schema/invoice.schema.json`; with `opis/json-schema` installed, `(new JsonSchemaValidator)->validate($json)` checks input before hydration. Details in [Arrays and JSON](building-invoices.md#arrays-and-json); all fields are listed in the [field reference](field-reference.md). ## Next steps - [Examples](examples.md): complete invoices for common situations, from small businesses and XRechnung to customers abroad and reminders. - [Building invoices](building-invoices.md): every builder method. - [Templates and design](templates.md): logo, colours, texts and your own template. - [Validation](validation.md) and [Troubleshooting](troubleshooting.md): what the checks do and how to fix errors. - [Laravel integration](laravel.md): storage, queues, events and mail. # E-invoicing basics This page explains the terms you meet in Quittio and in this documentation, in about five minutes. You do not need to know them to render a first invoice ([Getting started](getting-started.md)), but they explain why Quittio asks for certain data and what the formats and error codes mean. ## What an e-invoice is An e-invoice is an invoice in a structured, machine-readable format: an XML file that accounting software can read without a person typing the values. A PDF that only shows the invoice is not an e-invoice, even when it is sent by e-mail. Many countries now require e-invoices between businesses. In Germany every domestic business must be able to receive them since 2025; sending them becomes mandatory step by step until 2028, with exceptions such as invoices up to 250 € ([German country pack](country-packs.md#germany-quittiocountry-de)). Invoices to consumers are not affected. Quittio produces both parts from one set of data: the XML for the software and, where useful, a PDF for people. ## EN 16931 and business terms **EN 16931** is the European standard that defines what an e-invoice contains: seller, buyer, lines, VAT, totals, payment and so on. Every national format in the EU is based on it. The standard gives every field a number: | Abbreviation | Meaning | Example | |---|---|---| | BT-*n* | Business term: a single field | BT-1 invoice number, BT-27 seller name, BT-10 buyer reference | | BG-*n* | Business group: a group of fields | BG-5 seller address, BG-25 invoice line | This documentation names these numbers in parentheses, e.g. "buyer reference (BT-10)", because validation messages and the formats use them. You never type them in your code: the builder methods have plain names (`buyerReference()`). The [Field reference](field-reference.md) lists every field with its number. ## Syntaxes: CII and UBL EN 16931 describes the content, not the file. Two XML **syntaxes** write it down: | Syntax | Full name | Used by | |---|---|---| | CII | UN/CEFACT Cross Industry Invoice | ZUGFeRD/Factur-X, XRechnung | | UBL | OASIS Universal Business Language 2.1 | Peppol, XRechnung | Both carry the same information. Which one you need depends on the format the recipient expects. ## Formats A **format** is what Quittio produces. The common ones: | Format | What it is | Typical recipient | |---|---|---| | ZUGFeRD / Factur-X | A PDF (PDF/A-3) with the CII XML embedded: people read the PDF, software reads the XML. ZUGFeRD (Germany) and Factur-X (France) are the same standard. | Businesses | | XRechnung | The German standard for public authorities: an XML file only, CII or UBL, with additional German rules | Public buyers in Germany | | Peppol BIS Billing | UBL XML sent over the Peppol network, an international delivery network for e-invoices | Businesses and authorities connected to Peppol | | CII, UBL | Plain XML in either syntax | Recipients that ask for it | | PDF | A PDF without XML (PDF/A-3 for archiving) | Consumers, small amount invoices, countries without an obligation | [Formats and profiles](formats.md) lists every format with its keys (`zugferd`, `xrechnung-cii` …). ## Profiles A **profile** decides how much of EN 16931 an XML file contains and which extra rules apply. ZUGFeRD/Factur-X has the levels MINIMUM, BASIC WL, BASIC, EN 16931 and EXTENDED; XRechnung and Peppol are profiles with national or network rules on top of EN 16931. | Profile | Use | |---|---| | `en16931` | The standard itself; the default for business invoices | | `extended` | More fields than EN 16931 (e.g. sub lines); Quittio switches to it automatically when you use them | | `xrechnung` | XRechnung rules (public buyers in Germany) | | `peppol` | Peppol BIS Billing 3.0 | | `minimum`, `basic-wl`, `basic` | Reduced levels without (all) lines; not valid e-invoices under EN 16931, only for recipients that ask for them | You rarely choose a profile yourself: each format has a default, and the [automatic choice](formats.md#automatic-choice) picks format and profile from the invoice. ## Rules and validation The standards come with **business rules**: conditions every invoice must meet, such as "the sum of the line amounts equals the net total" or "a seller address is required". They have codes, and Quittio's error messages show them: | Code | Source | |---|---| | `BR-…`, `BR-CO-…`, `BR-CL-…` | EN 16931 (e.g. `BR-CO-26`: the seller needs a VAT identifier or another identifier) | | `BR-DE-…` | XRechnung (Germany) | | `PEPPOL-…` | Peppol BIS Billing | | `DE-USTG-…`, `DE-…` | Quittio's German country pack: mandatory content of German invoices under the VAT Act (UStG) | | `QUITTIO-…` | Quittio itself | Quittio checks an invoice before it renders it. An error stops the rendering with a `ValidationException` that names the rule, the field and a hint; warnings are reported but do not stop it. Optional external validators (the official KoSIT validator for XRechnung and EN 16931, veraPDF for PDF/A) check the finished files. See [Validation](validation.md) and, for common errors, [Troubleshooting](troubleshooting.md). ## Which format do I need? Usually none: without `->format()`, Quittio chooses for each invoice ([Automatic choice](formats.md#automatic-choice)). For a German seller: | Your customer | Format Quittio chooses | Why | |---|---|---| | A business in Germany | ZUGFeRD (profile EN 16931) | E-invoice that is also a readable PDF | | A public authority in Germany (buyer reference is a Leitweg-ID) | XRechnung (CII) | Required by public buyers | | A consumer | PDF | No e-invoice obligation | | Any customer in Germany, invoice up to 250 € marked with `->de()->smallAmount()` | PDF | Small amount invoices are exempt | | A business in another EU country | ZUGFeRD (profile EN 16931) | Readable PDF with standard XML | | A business reachable via Peppol (with a Peppol lookup) | Peppol BIS | Delivery over the Peppol network | | A customer outside the EU | PDF | No EU e-invoice rules | Ask for a format with `->render('xrechnung-cii')` or `->format(…)` when a customer requires a specific one. ## How Quittio works ```text config/quittio.php ──► Quittio::invoice() ──► …->line(…)->buyer(…) ──► render() (your company) (invoice builder) (your invoice data) │ ▼ calculation → format and profile → validation → XML and PDF → result │ $result->pdf(), ->xml(), ->save(), ->download() ``` 1. **Configuration:** your company (the seller), bank account and defaults are set once in `config/quittio.php` ([Configuration](configuration.md)). 2. **Building:** `Quittio::invoice()` starts an invoice with that seller; you add the number, customer, lines and payment terms ([Building invoices](building-invoices.md)). 3. **Rendering:** `render()` calculates totals and VAT, chooses format and profile, validates, writes the XML and renders the PDF from a template ([Templates and design](templates.md)). You never calculate totals yourself. 4. **Result:** a `RenderedInvoice` with the PDF, the XML, a file name and the validation result, which you save, download or mail ([Laravel integration](laravel.md)). Without Laravel, `Quittio::create()` takes the place of `config/quittio.php` (your company under `seller`, its account under `bank_account`) and `$quittio->invoice()` that of `Quittio::invoice()`; the rest of the flow is the same ([Without Laravel](getting-started.md#without-laravel)). Everything country-specific, such as German VAT rates, legal texts, XRechnung and the DIN 5008 letter layout, comes from a **country pack** ([Country packs](country-packs.md)); `quittio/quittio` includes the one for Germany. The optional **Managed layer** (not released yet) adds gapless numbering, an archive, cancellations and corrections as stored records ([Managed layer](managed.md)). ## German terms Quittio prints German invoices with German wording, and some German legal terms have no exact English equivalent. This documentation keeps the German term where it is the text on the invoice or the legal name, with an English explanation: | German | English | Note | |---|---|---| | Rechnung | Invoice | | | Gutschrift | Self-billed invoice | Issued by the buyer for the seller's supply (type code 389), not a refund | | Rechnungskorrektur | Invoice correction | Title of credit notes (type code 381) and of corrections issued with the German pack (corrected invoice, type code 384) | | Korrigierte Rechnung | Corrected invoice | Title of type code 384 outside the German correction policy | | Stornorechnung | Cancellation invoice | Cancels an issued invoice | | Anzahlungsrechnung, Abschlagsrechnung, Schlussrechnung | Advance payment invoice, partial invoice, final invoice | | | Angebot, Auftragsbestätigung, Lieferschein | Quote, order confirmation, delivery note | [Documents](documents.md) | | Zahlungserinnerung, Mahnung | Payment reminder, reminder | "1. Mahnung" is the first reminder after the payment reminder | | Leistungsdatum, Leistungszeitraum | Date of supply, period of supply | Mandatory on German invoices | | Skonto | Cash discount | | | Übertrag | Carried forward | Running total at a page break | | USt-IdNr. | VAT identification number | e.g. DE123456789 | | Steuernummer (St.-Nr.) | Tax number | Issued by the local tax office | | Kleinunternehmer | Small business | Charges no VAT (section 19 UStG) | | Steuerschuldnerschaft des Leistungsempfängers | Reverse charge | The buyer owes the VAT (section 13b UStG) | | Innergemeinschaftliche Lieferung | Intra-community supply | Tax-exempt supply of goods to a business in another EU country | | Leitweg-ID | Routing ID of a German public buyer | Goes into the buyer reference (BT-10) of an XRechnung | | UStG | German VAT Act (Umsatzsteuergesetz) | | | GoBD | German rules for digital bookkeeping and retention | | | KoSIT | Agency that publishes XRechnung and its validator | | | DIN 5008 | German standard for business letters | Address field and fold marks of the PDF | # Examples This page shows complete examples for common situations, from a first service invoice to reading an e-invoice you received. Find the situation closest to yours, copy the code and adapt it. If you have not rendered an invoice yet, start with [Getting started](getting-started.md). Terms such as ZUGFeRD, XRechnung or profile are explained in [E-invoicing basics](concepts.md). Every example runs in Quittio's test suite against the current version. The XML the examples produce passed the official validator of KoSIT, the German agency that publishes XRechnung. It checks the rules of EN 16931, XRechnung and Peppol BIS Billing 3.0 ([Rules and validation](concepts.md#rules-and-validation)). Each example starts with the situation, then shows the code, then explains the important lines with links to the reference. | Example | Situation and what it shows | |---|---| | [Service invoice](#service-invoice) | Hours and hosting for a German business: service period, cash discount, ZUGFeRD | | [Different VAT rates and a discount](#different-vat-rates-and-a-discount) | Goods at 7 % and 19 %: lines as arrays, a discount split per VAT rate | | [Online shop](#online-shop) | A consumer who paid at checkout: prices including VAT, a voucher | | [Small business](#small-business) | A seller who charges no VAT (section 19 UStG, the German VAT Act) and has no VAT identification number | | [Public sector](#public-sector) | A German public authority: XRechnung with Leitweg-ID (the buyer's routing ID), PDF copy | | [Advance payment and final invoice](#advance-payment-and-final-invoice) | A project paid in two parts: advance payment invoice, final invoice with deduction | | [Cancellation](#cancellation) | An issued invoice that was wrong: full and partial cancellation with `$result->cancel()` | | [Self-billing](#self-billing) | You write the invoice for your supplier: "Gutschrift" (self-billed invoice) | | [EU business: services](#eu-business-services) | A service for a business in Belgium: reverse charge (the customer owes the VAT), Peppol BIS | | [EU business: goods](#eu-business-goods) | Goods for a business in Austria: intra-community supply, deliver-to address | | [Export](#export) | A customer outside the EU, invoiced in US dollars | | [Foreign currency with German VAT](#foreign-currency-with-german-vat) | A German customer invoiced in US dollars: VAT stated in euro | | [Invoices for orders](#invoices-for-orders) | Orders in your Laravel application: Eloquent models, storing and mailing | | [Drafts and previews](#drafts-and-previews) | Invoices prepared over time: drafts and previews without the Managed layer | | [Testing](#testing) | Feature tests for the order flow: fake and validation in Pest | | [From quote to invoice](#from-quote-to-invoice) | A quote with an optional line, then the invoice from the quote | | [Payment reminder](#payment-reminder) | An overdue invoice: reminder with statutory default interest | | [Incoming e-invoices](#incoming-e-invoices) | An e-invoice from a supplier: validate and read an upload | | [Logo, colours and texts](#logo-colours-and-texts) | The design of a single invoice | | [Without Laravel](#without-laravel) | A plain PHP script | All examples use this seller. In Laravel it is in `config/quittio.php` ([Seller](configuration.md#seller)). In plain PHP the examples use the core instance `$quittio` set up here with this seller ([Without Laravel](#without-laravel)): ```php laravel // config/quittio.php 'seller' => [ 'name' => 'Muster GmbH', 'vat_id' => 'DE123456789', 'address' => ['line1' => 'Hauptstraße 1', 'postcode' => '12345', 'city' => 'Musterstadt', 'country' => 'DE'], 'contact' => ['name' => 'Max Muster', 'phone' => '+49 30 1234567', 'email' => 'rechnung@muster.de'], 'electronic_address' => ['value' => 'rechnung@muster.de', 'scheme' => 'EM'], 'bank_accounts' => [['iban' => 'DE02120300000000202051', 'bic' => 'BYLADEM1001', 'name' => 'Muster GmbH']], ], ``` ```php plain use Quittio\Core\Builder\InvoiceBuilder; use Quittio\Core\Builder\Party; use Quittio\Core\Quittio; use Quittio\Core\Tax\CountryDefaultVat; use Quittio\Country\DE\CountryDE; $quittio = Quittio::create([ 'seller' => Party::make('Muster GmbH') ->vatId('DE123456789') ->address('Hauptstraße 1', '12345', 'Musterstadt', 'DE') ->contact('Max Muster', '+49 30 1234567', 'rechnung@muster.de') ->electronicAddress('rechnung@muster.de', 'EM'), 'bank_account' => ['iban' => 'DE02120300000000202051', 'bic' => 'BYLADEM1001', 'name' => 'Muster GmbH'], 'due_days' => 14, // payment target for invoices without one ], [new CountryDE]); InvoiceBuilder::useDefaultVat(new CountryDefaultVat($quittio->countries())); // lines without vat(): 19 % ``` How the examples are written: - `Quittio::invoice()` starts an invoice with this seller and its bank account. `->render()` at the end of the chain calculates, validates and renders it ([Starting invoices](laravel.md#starting-invoices)). `Quittio::quote()`, `Quittio::paymentReminder()` and the other document methods work the same way. - The examples follow [one way to write it](getting-started.md#one-way-to-write-it). A line is its name with named values: `->line('Hosting', netPrice: '49.00', quantity: 12, unit: UnitCode::Month)`. Without `quantity` the quantity is 1. Without `vat` the line gets 19 %, the standard rate for a German seller ([Default VAT](building-invoices.md#default-vat)), so the examples set VAT only where it differs. - `Line::make('…', netPrice: …)->…` appears only where a line needs more than these values. The example says why. - Lines from your data appear as arrays or models, the customer as `Party::make()` or as your model, payment terms as `->dueInDays()` and `->cashDiscount()`. - Amounts are strings such as `'49.00'`, never floats. - `invoices` and `documents` are filesystem disks of your application (`config/filesystems.php`). - The seller is German, so the documents are in German. A comment such as `// 2026/Rechnung_RE-2026-0101.pdf` shows the German file name ("Rechnung" means invoice). `->locale('en')` switches texts and file names to English, see [EU business: services](#eu-business-services). - In plain PHP, `$quittio->invoice()` takes the place of `Quittio::invoice()`, and `$quittio->quote()`, `$quittio->paymentReminder()` … the place of the other document methods. They start with the seller and its bank account from `Quittio::create()` and end with `->render()` as well. Files are saved to local directories instead of disks ([Without Laravel](#without-laravel)). ## Invoices in Germany These examples invoice customers in Germany. Read the first one even if your case differs: it explains what all examples have in common, and the [Cancellation](#cancellation) and [Incoming e-invoices](#incoming-e-invoices) examples reuse it. ### Service invoice You bill a German business customer for a month of work: hours of software development and a monthly hosting fee. The example shows a service period, payment terms with a cash discount and the format Quittio chooses for German businesses. ```php laravel use Quittio\Core\Builder\Party; use Quittio\Core\Enums\UnitCode; use Quittio\Laravel\Facades\Quittio; $result = Quittio::invoice() ->number('RE-2026-0101') ->issueDate('2026-10-01') ->invoicingPeriod('2026-09-01', '2026-09-30') // service period instead of a delivery date ->buyerReference('PO-4711') // the reference your customer asked for (BT-10) ->buyer(Party::make('Kunde AG') ->vatId('DE987654321') ->address('Bahnhofstraße 5', '54321', 'Beispielstadt', 'DE') ->electronicAddress('ap@kunde.de', 'EM')) ->line('Software development', netPrice: '95.00', quantity: '62.5', unit: UnitCode::Hour, description: 'Customer portal, sprints 5 and 6') ->line('Hosting', netPrice: '49.00', unit: UnitCode::Month) ->dueInDays(30)->cashDiscount(days: 10, percent: '2.00') ->render(); // ZUGFeRD, profile EN 16931 $result->save('invoices', '2026/'); // 2026/Rechnung_RE-2026-0101.pdf ``` ```php plain use Quittio\Core\Builder\Party; use Quittio\Core\Enums\UnitCode; $result = $quittio->invoice() ->number('RE-2026-0101') ->issueDate('2026-10-01') ->invoicingPeriod('2026-09-01', '2026-09-30') // service period instead of a delivery date ->buyerReference('PO-4711') // the reference your customer asked for (BT-10) ->buyer(Party::make('Kunde AG') ->vatId('DE987654321') ->address('Bahnhofstraße 5', '54321', 'Beispielstadt', 'DE') ->electronicAddress('ap@kunde.de', 'EM')) ->line('Software development', netPrice: '95.00', quantity: '62.5', unit: UnitCode::Hour, description: 'Customer portal, sprints 5 and 6') ->line('Hosting', netPrice: '49.00', unit: UnitCode::Month) ->dueInDays(30)->cashDiscount(days: 10, percent: '2.00') ->render(); // ZUGFeRD, profile EN 16931 $result->save(__DIR__.'/invoices/2026/'); // invoices/2026/Rechnung_RE-2026-0101.pdf ``` - Without a format, Quittio chooses one from the invoice ([Automatic choice](formats.md#automatic-choice)). For a German business it renders ZUGFeRD: a PDF/A-3 file (a PDF for archiving) with the e-invoice XML embedded. The XML follows the profile EN 16931 ([Formats](concepts.md#formats), [Profiles](concepts.md#profiles)). - German invoices must state when the service was provided. `invoicingPeriod()` states the service period (September) instead of a single delivery date. - Both lines get 19 % VAT by default. Hosting has no quantity, so it is 1 month. - Totals: 5,986.50 net, 1,137.44 VAT, 7,123.94 due on 31 October 2026 (30 days after the issue date). - `dueInDays()` and `cashDiscount()` become the payment terms. PDF and XML state them in German: "Zahlbar innerhalb von 30 Tagen ohne Abzug." (payable within 30 days without deduction) and "2 % Skonto bei Zahlung innerhalb von 10 Tagen (bis 11.10.2026)." (2 % cash discount for payment within 10 days, until 11 October 2026). See [Payment terms](building-invoices.md#payment-terms). - `save()` stores the file on the disk `invoices` below `2026/` and returns its path. The file name starts with the German title "Rechnung" (invoice). ### Different VAT rates and a discount You sell goods with different VAT rates: books at the reduced rate of 7 % and office supplies at the standard rate of 19 %. You grant a discount of 5 % on everything. The example passes the lines as arrays, as they might come from your database, and prints the VAT breakdown: ```php laravel use Quittio\Core\Builder\Party; use Quittio\Core\Enums\UnitCode; use Quittio\Country\DE\Tax\VatPreset; use Quittio\Laravel\Facades\Quittio; $result = Quittio::invoice() ->number('RE-2026-0102') ->issueDate('2026-10-05') ->deliveryDate('2026-10-02') ->buyer(Party::make('Kanzlei Recht & Partner') ->vatId('DE987654321') ->address('Marktplatz 2', '54321', 'Beispielstadt', 'DE')) ->lines([ ['name' => 'Handbook of VAT law', 'quantity' => [3, UnitCode::Piece], 'netPrice' => '89.00', 'vat' => VatPreset::Reduced], ['name' => 'Desk organiser', 'quantity' => [3, UnitCode::Piece], 'netPrice' => '24.90'], ]) ->discountPercent('5', 'Customer discount') // one allowance per VAT rate ->render(); foreach ($result->data()->vatBreakdown as $row) { echo $row->rate.' %: '.$row->taxableAmount.' net, '.$row->taxAmount." VAT\n"; } ``` ```php plain use Quittio\Core\Builder\Party; use Quittio\Core\Enums\UnitCode; use Quittio\Country\DE\Tax\VatPreset; $result = $quittio->invoice() ->number('RE-2026-0102') ->issueDate('2026-10-05') ->deliveryDate('2026-10-02') ->buyer(Party::make('Kanzlei Recht & Partner') ->vatId('DE987654321') ->address('Marktplatz 2', '54321', 'Beispielstadt', 'DE')) ->lines([ ['name' => 'Handbook of VAT law', 'quantity' => [3, UnitCode::Piece], 'netPrice' => '89.00', 'vat' => VatPreset::Reduced], ['name' => 'Desk organiser', 'quantity' => [3, UnitCode::Piece], 'netPrice' => '24.90'], ]) ->discountPercent('5', 'Customer discount') // one allowance per VAT rate ->render(); foreach ($result->data()->vatBreakdown as $row) { echo $row->rate.' %: '.$row->taxableAmount.' net, '.$row->taxAmount." VAT\n"; } ``` ``` 7 %: EUR 253.65 net, EUR 17.76 VAT 19 %: EUR 70.96 net, EUR 13.48 VAT ``` - Each array key names a method of the line builder, and the value holds its arguments: `'quantity' => [3, UnitCode::Piece]` means 3 pieces ([Lines](building-invoices.md#lines)). - `VatPreset::Reduced` is a tax preset of the German country pack: the reduced rate of 7 % ([Tax presets](country-packs.md#tax-presets)). The desk organiser has no `vat`, so it gets 19 %. - VAT is calculated per VAT rate, never per line. So `discountPercent()` splits the discount of 17.09 into one allowance per rate, in proportion to the line sums: 13.35 at 7 % and 3.74 at 19 % ([Discount splitting](building-invoices.md#discount-splitting)). - For a discount on a single rate, use `allowance(VatCategory::StandardRate, '19', percent: '5', reason: '…')` instead ([Document level allowances and charges](building-invoices.md#document-level-allowances-and-charges)). ### Online shop You sell to consumers in an online shop. Your prices include VAT, and the customer pays at checkout, here with PayPal. The example shows prices including VAT, shipping, a voucher and an invoice that is already paid. ```php laravel use Quittio\Core\Builder\Party; use Quittio\Core\Enums\PaymentMeansCode; use Quittio\Laravel\Facades\Quittio; $result = Quittio::invoice() ->number('RE-2026-0103') ->issueDate('2026-10-06') ->deliveryDate('2026-10-06') ->buyer(Party::make('Erika Mustermann') ->address('Lindenweg 3', '10115', 'Berlin', 'DE') ->consumer()) // a consumer (B2C): PDF without XML ->line('T-shirt "Quittio"', priceInclVat: '19.99', quantity: 3) ->line('Shipping', priceInclVat: '4.90') ->line('Voucher WELCOME5', priceInclVat: '5.00', quantity: -1) ->payment(PaymentMeansCode::OnlinePaymentService, meansText: 'PayPal') ->prepaid('59.87') // paid at checkout ->render(); $result->format(); // "pdf" $result->data()->totals->grossTotal; // EUR 59.87 $result->data()->totals->amountDue; // EUR 0.00 ``` ```php plain use Quittio\Core\Builder\Party; use Quittio\Core\Enums\PaymentMeansCode; $result = $quittio->invoice() ->number('RE-2026-0103') ->issueDate('2026-10-06') ->deliveryDate('2026-10-06') ->buyer(Party::make('Erika Mustermann') ->address('Lindenweg 3', '10115', 'Berlin', 'DE') ->consumer()) // a consumer (B2C): PDF without XML ->line('T-shirt "Quittio"', priceInclVat: '19.99', quantity: 3) ->line('Shipping', priceInclVat: '4.90') ->line('Voucher WELCOME5', priceInclVat: '5.00', quantity: -1) ->payment(PaymentMeansCode::OnlinePaymentService, meansText: 'PayPal') ->prepaid('59.87') // paid at checkout ->render(); $result->format(); // "pdf" $result->data()->totals->grossTotal; // EUR 59.87 $result->data()->totals->amountDue; // EUR 0.00 ``` - `consumer()` marks the buyer as a consumer. Invoices to consumers need no e-invoice, so the automatic choice renders a PDF without XML ([Which format do I need?](concepts.md#which-format-do-i-need)). - `priceInclVat()` takes the price including VAT. The calculator derives the net prices, so that the invoice total is exactly the amount the customer paid: 3 × 19.99 + 4.90 − 5.00 = 59.87, of which 9.56 VAT. - In this gross price mode every line uses `priceInclVat()`. Shipping and vouchers are lines (the voucher with quantity −1), not charges or allowances ([Gross price mode](building-invoices.md#gross-price-mode)). - `payment()` states how the customer paid. `prepaid()` records the payment at checkout, so the amount due is 0.00 and the PDF shows no payment QR code. ### Small business You run a small business ("Kleinunternehmer") under section 19 UStG, the German VAT Act, and charge no VAT. You state this once, in the configuration (in plain PHP, in `Quittio::create()`). The seller in this example has a tax number but no VAT identification number: ```php laravel // config/quittio.php of the small business 'seller' => [ 'name' => 'Lisa Klein Grafikdesign', 'tax_number' => '21/815/08150', 'identifiers' => [['value' => '21/815/08150', 'scheme' => null]], // seller identifier (BT-29): needed without a VAT identifier 'address' => ['line1' => 'Gartenstraße 7', 'postcode' => '12345', 'city' => 'Musterstadt', 'country' => 'DE'], 'electronic_address' => ['value' => 'hallo@lisaklein.de', 'scheme' => 'EM'], 'bank_accounts' => [['iban' => 'DE89370400440532013000', 'name' => 'Lisa Klein']], 'small_business' => true, // or QUITTIO_SELLER_SMALL_BUSINESS=true ], ``` ```php plain use Quittio\Core\Builder\InvoiceBuilder; use Quittio\Core\Builder\Party; use Quittio\Core\Quittio; use Quittio\Core\Tax\CountryDefaultVat; use Quittio\Country\DE\CountryDE; // The core instance of the small business $quittio = Quittio::create([ 'seller' => Party::make('Lisa Klein Grafikdesign') ->taxNumber('21/815/08150') ->identifier('21/815/08150') // seller identifier (BT-29): needed without a VAT identifier ->address('Gartenstraße 7', '12345', 'Musterstadt', 'DE') ->electronicAddress('hallo@lisaklein.de', 'EM'), 'bank_account' => ['iban' => 'DE89370400440532013000', 'name' => 'Lisa Klein'], 'small_business' => true, ], [new CountryDE]); InvoiceBuilder::useDefaultVat(new CountryDefaultVat($quittio->countries())); // lines without vat(): no VAT ``` Then you write every invoice as usual, without VAT on the lines: ```php laravel use Quittio\Core\Builder\Party; use Quittio\Core\Enums\UnitCode; use Quittio\Laravel\Facades\Quittio; $result = Quittio::invoice() ->number('2026-017') ->issueDate('2026-10-07') ->buyer(Party::make('Café Sonnenschein GmbH')->address('Am Markt 3', '12345', 'Musterstadt', 'DE')) ->line('Logo design', netPrice: '650.00', unit: UnitCode::LumpSum) ->line('Business card layout', netPrice: '55.00', quantity: 2, unit: UnitCode::Hour) ->dueInDays(14) ->render(); $result->data()->totals->amountDue; // EUR 760.00, no VAT ``` ```php plain use Quittio\Core\Builder\Party; use Quittio\Core\Enums\UnitCode; $result = $quittio->invoice() ->number('2026-017') ->issueDate('2026-10-07') ->buyer(Party::make('Café Sonnenschein GmbH')->address('Am Markt 3', '12345', 'Musterstadt', 'DE')) ->line('Logo design', netPrice: '650.00', unit: UnitCode::LumpSum) ->line('Business card layout', netPrice: '55.00', quantity: 2, unit: UnitCode::Hour) ->dueInDays(14) ->render(); $result->data()->totals->amountDue; // EUR 760.00, no VAT ``` - `seller.small_business` (in plain PHP `'small_business' => true`) makes `Quittio::invoice()` flag the invoice as a small business invoice (`Meta::FLAG_SMALL_BUSINESS`). Lines without `vat()` get `VatPreset::SmallBusiness`, and the German country pack rejects VAT on the invoice (rule `DE-USTG-09`). - Only an invoice with another seller than the configured one needs `->flag(Meta::FLAG_SMALL_BUSINESS)`. - Every line carries the exemption text "Steuerfreie Leistung nach § 19 Abs. 1 UStG (Steuerbefreiung für Kleinunternehmer)." (tax-exempt supply under section 19 (1) UStG, exemption for small businesses) in PDF and XML. - Invoices of a small business need no service date (section 34a UStDV, the German VAT implementing ordinance). They need the tax number or the VAT identification number ([Small businesses](country-packs.md#small-businesses)). - Without a VAT identification number, EN 16931 needs a seller identifier (BT-29, `seller.identifiers`) or a trade register number (BT-30, `seller.legal_registration`). Otherwise rendering fails with the rule `BR-CO-26` ([Rules and validation](concepts.md#rules-and-validation)). Here the tax number serves as the seller identifier. ### Public sector You invoice a German public authority, here a city administration. German public buyers require XRechnung, an e-invoice that is an XML file only. With the order they give you a Leitweg-ID, the routing ID of the buyer ([German terms](concepts.md#german-terms)). The example shows where the Leitweg-ID goes and how to add a readable PDF copy. ```php laravel use Quittio\Core\Builder\Party; use Quittio\Core\Enums\UnitCode; use Quittio\Laravel\Facades\Quittio; $result = Quittio::invoice() ->number('RE-2026-0104') ->issueDate('2026-10-08') ->deliveryDate('2026-10-02') ->buyerReference('04011000-12345-03') // Leitweg-ID from the order ->buyer(Party::make('Stadt Beispielstadt, Hauptamt') ->address('Rathausplatz 1', '54321', 'Beispielstadt', 'DE') ->electronicAddress('04011000-12345-03', '0204')) // scheme 0204: Leitweg-ID ->line('Website maintenance', netPrice: '85.00', quantity: 8, unit: UnitCode::Hour) ->dueInDays(30) ->render(['xrechnung-cii', 'pdf']); // XRechnung and a PDF copy $result->save('invoices', '2026/'); // 2026/Rechnung_RE-2026-0104.xml, the e-invoice $result->as('pdf')->save('invoices', '2026/'); // 2026/Rechnung_RE-2026-0104.pdf, a readable copy ``` ```php plain use Quittio\Core\Builder\Party; use Quittio\Core\Enums\UnitCode; $result = $quittio->invoice() ->number('RE-2026-0104') ->issueDate('2026-10-08') ->deliveryDate('2026-10-02') ->buyerReference('04011000-12345-03') // Leitweg-ID from the order ->buyer(Party::make('Stadt Beispielstadt, Hauptamt') ->address('Rathausplatz 1', '54321', 'Beispielstadt', 'DE') ->electronicAddress('04011000-12345-03', '0204')) // scheme 0204: Leitweg-ID ->line('Website maintenance', netPrice: '85.00', quantity: 8, unit: UnitCode::Hour) ->dueInDays(30) ->render(['xrechnung-cii', 'pdf']); // XRechnung and a PDF copy $result->save(__DIR__.'/invoices/2026/'); // invoices/2026/Rechnung_RE-2026-0104.xml, the e-invoice $result->as('pdf')->save(__DIR__.'/invoices/2026/'); // invoices/2026/Rechnung_RE-2026-0104.pdf, a readable copy ``` - The Leitweg-ID goes into the buyer reference (BT-10). With a Leitweg-ID there, the automatic choice selects XRechnung in the CII syntax (`xrechnung-cii`) by itself ([Syntaxes](concepts.md#syntaxes-cii-and-ubl)). The buyer's electronic address is the Leitweg-ID as well, with the scheme `0204`. - `render()` without a format would render `xrechnung-cii` alone. The list `['xrechnung-cii', 'pdf']` renders both formats from the same calculation, like `->formats([...])`. The first format is the main result, and `as('pdf')` returns the PDF. The XML is the invoice, the PDF only a readable copy. The PDF says so in its legal notes: "Lesbare Darstellung der E-Rechnung (XRechnung 3.0) Nr. RE-2026-0104 – inhaltsgleiches Mehrstück. Maßgeblich ist ausschließlich die XML-Datei." (readable copy of the e-invoice, a copy with the same content; only the XML file is authoritative; label `einvoice_visualization`). The BMF letter of 15 October 2024 (marginal no. 6) allows such an additional PDF; keep it with the XML. The render option `visualization_notice` set to `false` (`->option('visualization_notice', false)`; in the core also `Quittio::create(['options' => ['visualization_notice' => false]])`) leaves the notice out. - XRechnung requires the seller contact with name, phone and email, the electronic addresses of both parties and payment instructions. The seller configuration at the top of this page provides them ([XRechnung](formats.md#xrechnung)). - Quittio creates the file but does not send it. Upload it to the portal the authority names, or send it via Peppol. ### Advance payment and final invoice You agree on a project with an advance payment: you invoice part of the price when the order is placed and the rest after completion. The example shows the advance payment invoice and the final invoice that deducts it. ```php laravel use Quittio\Core\Builder\Party; use Quittio\Core\Enums\UnitCode; use Quittio\Country\DE\Builder\GermanInvoice; use Quittio\Laravel\Facades\Quittio; $customer = Party::make('Kunde AG') ->vatId('DE987654321') ->address('Bahnhofstraße 5', '54321', 'Beispielstadt', 'DE'); // Advance payment invoice when the order is placed $advance = Quittio::invoice() ->de()->advance('2026-10') // expected month of the service ->number('RE-2026-0090') ->issueDate('2026-09-01') ->buyer($customer) ->line('Website relaunch, advance payment', netPrice: '1000.00', unit: UnitCode::LumpSum) ->dueInDays(14) ->render(); // Final invoice: the whole service with its whole VAT, minus the advance payment received $final = Quittio::invoice() ->number('RE-2026-0110') ->issueDate('2026-10-14') ->deliveryDate('2026-10-10') ->buyer($customer) ->line('Website relaunch', netPrice: '3000.00', unit: UnitCode::LumpSum) ->de()->deductAdvance($advance->data(), received: GermanInvoice::RECEIVED_IN_FULL) ->dueInDays(14) ->render(); $final->data()->totals->grossTotal; // EUR 3570.00 $final->data()->totals->prepaidAmount; // EUR 1190.00 $final->data()->totals->amountDue; // EUR 2380.00 ``` ```php plain use Quittio\Core\Builder\Party; use Quittio\Core\Enums\UnitCode; use Quittio\Country\DE\Builder\GermanInvoice; $customer = Party::make('Kunde AG') ->vatId('DE987654321') ->address('Bahnhofstraße 5', '54321', 'Beispielstadt', 'DE'); // Advance payment invoice when the order is placed $advance = $quittio->invoice() ->de()->advance('2026-10') // expected month of the service ->number('RE-2026-0090') ->issueDate('2026-09-01') ->buyer($customer) ->line('Website relaunch, advance payment', netPrice: '1000.00', unit: UnitCode::LumpSum) ->dueInDays(14) ->render(); // Final invoice: the whole service with its whole VAT, minus the advance payment received $final = $quittio->invoice() ->number('RE-2026-0110') ->issueDate('2026-10-14') ->deliveryDate('2026-10-10') ->buyer($customer) ->line('Website relaunch', netPrice: '3000.00', unit: UnitCode::LumpSum) ->de()->deductAdvance($advance->data(), received: GermanInvoice::RECEIVED_IN_FULL) ->dueInDays(14) ->render(); $final->data()->totals->grossTotal; // EUR 3570.00 $final->data()->totals->prepaidAmount; // EUR 1190.00 $final->data()->totals->amountDue; // EUR 2380.00 ``` - `->de()->advance('2026-10')` sets the invoice type code 386 (BT-3, the kind of invoice) and the note "Anzahlungsrechnung. Die Leistung wird voraussichtlich im Oktober 2026 erbracht." (advance invoice, the service is expected in October 2026). The PDF is titled "Anzahlungsrechnung" ([Prepayment invoices](country-packs.md#prepayment-invoices)). - The final invoice states the whole service with its whole VAT. `deductAdvance()` refers to the advance payment invoice and deducts the amount received, here all of it ([Final invoices](country-packs.md#final-invoices-deductadvance)). - It also adds the note "Abzüglich Anzahlung gemäß Rechnung RE-2026-0090 vom 01.09.2026: Entgelt 1.000,00 € zzgl. 19 % Umsatzsteuer 190,00 € (§ 14 Abs. 5 Satz 2 UStG)." (less the advance payment of invoice RE-2026-0090 of 1 September 2026: net amount 1,000.00 € plus 19 % VAT 190.00 €, section 14 (5) sentence 2 UStG). - Call `deductAdvance()` once per advance payment received, with the amount received: `received: '595.00'` for a part. Do not deduct an advance that was not paid. Without `received:` the German pack warns (`DE-USTG-20`). ### Cancellation An issued invoice is never changed. If it is wrong, you issue a cancellation: a new document with its own number that refers to the original. The example cancels the [service invoice](#service-invoice) from above, first completely and then in part. `$result` is that invoice; `cancel()` renders the cancellation in the formats of the invoice (in plain PHP, `$quittio->cancellation()` builds it and `formats()` keeps the formats). ```php laravel // Cancel the whole invoice $cancellation = $result->cancel('ST-2026-0007', reason: 'Ordered twice'); $cancellation->filename(); // Stornorechnung_ST-2026-0007.pdf // Or cancel only part of it: 10 of the 62.5 hours of line 1 $partial = $result->cancel('ST-2026-0008', reason: 'Hours booked twice', lines: [ ['line' => '1', 'quantity' => '10'], ]); $partial->data()->totals->grossTotal; // EUR 1130.50 ``` ```php plain // Cancel the whole invoice $cancellation = $quittio->make($quittio->cancellation($result->data(), 'ST-2026-0007', reason: 'Ordered twice')) ->formats($result->formats())->render(); $cancellation->filename(); // Stornorechnung_ST-2026-0007.pdf // Or cancel only part of it: 10 of the 62.5 hours of line 1 $partial = $quittio->make($quittio->cancellation($result->data(), 'ST-2026-0008', reason: 'Hours booked twice', lines: [ ['line' => '1', 'quantity' => '10'], ]))->formats($result->formats())->render(); $partial->data()->totals->grossTotal; // EUR 1130.50 ``` - In Germany a cancellation is a credit note (type code 381) with positive amounts. It is titled "Stornorechnung" (cancellation invoice). - It refers to RE-2026-0101 and carries the note "Stornierung der Rechnung RE-2026-0101 vom 01.10.2026. Grund: Ordered twice" (cancellation of invoice RE-2026-0101 of 1 October 2026, reason: …). - The partial cancellation reverses 10 hours: 950.00 net plus 180.50 VAT. `['line' => '1', 'amount' => '100.00']` reduces a line by an amount instead, e.g. after a complaint. - For an invoice you stored as data, `Quittio::make(Quittio::cancellation($data, 'ST-2026-0007', reason: '…'))->render()` does the same ([Cancellations](laravel.md#cancellations)). - For several partial cancellations of one invoice, pass the earlier ones as `history:`, so that the VAT adds up exactly ([Cumulative VAT rounding](building-invoices.md#cumulative-vat-rounding)). The [Managed layer](managed.md#cancellations-and-corrections), the optional package `quittio/managed`, keeps this history itself. ### Self-billing With self-billing, the buyer writes the invoice instead of the seller, e.g. the commission statement for your sales agent. In Germany this document is called "Gutschrift" (self-billed invoice); it is not a refund. The example shows who is seller and who is buyer, and where the payment goes. ```php laravel use Quittio\Core\Builder\Party; use Quittio\Core\Enums\PaymentMeansCode; use Quittio\Core\Enums\UnitCode; use Quittio\Laravel\Facades\Quittio; $result = Quittio::invoice() ->de()->selfBilled() // type code 389 and the note "Gutschrift" ->number('GS-2026-0012') ->issueDate('2026-10-05') ->invoicingPeriod('2026-09-01', '2026-09-30') ->seller(Party::make('Jonas Schreiber Handelsvertretung') // the supplier: your sales agent ->vatId('DE111111125') ->address('Lindenallee 12', '80331', 'München', 'DE')) ->buyer(Party::make('Muster GmbH') // you: you issue the document ->vatId('DE123456789') ->address('Hauptstraße 1', '12345', 'Musterstadt', 'DE')) ->line('Commission September 2026', netPrice: '840.00', unit: UnitCode::LumpSum) ->payment(PaymentMeansCode::SepaCreditTransfer, iban: 'DE89370400440532013000', accountName: 'Jonas Schreiber') ->render(); $result->filename(); // Gutschrift_GS-2026-0012.pdf ``` ```php plain use Quittio\Core\Builder\Party; use Quittio\Core\Enums\PaymentMeansCode; use Quittio\Core\Enums\UnitCode; $result = $quittio->invoice() ->de()->selfBilled() // type code 389 and the note "Gutschrift" ->number('GS-2026-0012') ->issueDate('2026-10-05') ->invoicingPeriod('2026-09-01', '2026-09-30') ->seller(Party::make('Jonas Schreiber Handelsvertretung') // the supplier: your sales agent ->vatId('DE111111125') ->address('Lindenallee 12', '80331', 'München', 'DE')) ->buyer(Party::make('Muster GmbH') // you: you issue the document ->vatId('DE123456789') ->address('Hauptstraße 1', '12345', 'Musterstadt', 'DE')) ->line('Commission September 2026', netPrice: '840.00', unit: UnitCode::LumpSum) ->payment(PaymentMeansCode::SepaCreditTransfer, iban: 'DE89370400440532013000', accountName: 'Jonas Schreiber') ->render(); $result->filename(); // Gutschrift_GS-2026-0012.pdf ``` - The supplier stays the seller (BG-4) and you are the buyer, even though you issue the document. - `->seller()` replaces the seller of the configuration, and with it the configured bank account and small business setting. `payment()` sends the payment to the supplier's account. - `selfBilled()` sets type code 389 and the note "Gutschrift". The PDF is titled "Gutschrift" ([Self-billing](country-packs.md#self-billing-gutschrift)). - "Gutschrift" is used only for self-billing. Cancellations are titled "Stornorechnung" (cancellation invoice). - Self-billing needs a prior agreement with the supplier, e.g. in the agency contract (section 14 (2) sentence 2 UStG). Without it the document is no invoice. The supplier may object to it; it then loses its effect as invoice for the future ([Self-billing](country-packs.md#self-billing-gutschrift)). ### Continuing invoices A maintenance contract runs for a year and is paid monthly. Instead of an invoice every month you may issue one e-invoice for the first month that is the invoice for the whole term (a "Dauerrechnung", continuing invoice). The example shows what it must contain. ```php laravel use Quittio\Core\Builder\Party; use Quittio\Core\Enums\UnitCode; use Quittio\Laravel\Facades\Quittio; $result = Quittio::invoice() ->number('WV-2027-001') // a number from the contract is enough ->issueDate('2026-12-15') ->invoicingPeriod('2027-01-01', '2027-01-31') // the first partial period ->contractReference('WV-2027-001') ->buyer(Party::make('Kunde AG') ->vatId('DE987654321') ->address('Bahnhofstraße 5', '54321', 'Beispielstadt', 'DE')) ->line('Server maintenance, monthly', netPrice: '250.00', unit: UnitCode::Month) ->paymentTerms('Dauerrechnung für den Wartungsvertrag WV-2027-001: Diese Rechnung gilt für jeden Monat von Januar bis Dezember 2027. Zahlen Sie monatlich 250,00 € zzgl. 19 % Umsatzsteuer 47,50 €, zusammen 297,50 €, bis zum 3. des Monats.') ->render(); ``` ```php plain use Quittio\Core\Builder\Party; use Quittio\Core\Enums\UnitCode; $result = $quittio->invoice() ->number('WV-2027-001') // a number from the contract is enough ->issueDate('2026-12-15') ->invoicingPeriod('2027-01-01', '2027-01-31') // the first partial period ->contractReference('WV-2027-001') ->buyer(Party::make('Kunde AG') ->vatId('DE987654321') ->address('Bahnhofstraße 5', '54321', 'Beispielstadt', 'DE')) ->line('Server maintenance, monthly', netPrice: '250.00', unit: UnitCode::Month) ->paymentTerms('Dauerrechnung für den Wartungsvertrag WV-2027-001: Diese Rechnung gilt für jeden Monat von Januar bis Dezember 2027. Zahlen Sie monatlich 250,00 € zzgl. 19 % Umsatzsteuer 47,50 €, zusammen 297,50 €, bis zum 3. des Monats.') ->render(); ``` - In Germany one e-invoice for the first partial period is enough if it makes clear that it is a continuing invoice: either the contract is attached (`->attachment()`, BG-24) or its content says so, as the payment terms (BT-20) above do (section 14.1 (19) UStAE). An external link to the contract is not enough. - Net amount and VAT of each partial period, and the period itself, must be in the structured part: here the line and the invoicing period (BG-14) of the first month, and the payment schedule in BT-20 (BMF letter of 15 October 2025, marginal no. 35). The invoice number may be a number from the contract (section 14.5 (12) UStAE). - When the price, the VAT rate or another mandatory detail changes, issue a new e-invoice; a letter is not enough (section 14.1 (19) sentence 3 UStAE). A continuing invoice issued lawfully as paper or PDF before the obligation needs no new e-invoice until something changes (sentence 4). - Monthly invoices are allowed as well and easier for the buyer's accounting; they avoid the change problem. Quittio has no recurring invoices of its own. ## Customers abroad For customers in other countries, the VAT treatment and the format the customer can receive decide how the invoice looks. ### EU business: services You provide a service to a business in another EU country, here IT consulting for a customer in Belgium. For such services the customer owes the VAT (reverse charge), so your invoice shows 0 % VAT. Belgian businesses receive e-invoices through Peppol, a network for delivering e-invoices, so the example writes Peppol BIS Billing 3.0 ([Formats](concepts.md#formats)). ```php laravel use Quittio\Core\Builder\Party; use Quittio\Core\Enums\UnitCode; use Quittio\Country\DE\Tax\VatPreset; use Quittio\Laravel\Facades\Quittio; $result = Quittio::invoice() ->number('RE-2026-0105') ->issueDate('2026-10-09') ->deliveryDate('2026-09-30') ->buyerReference('PO-2026-118') // Peppol requires a buyer reference (BT-10) or an order reference (BT-13) ->locale('en') // English texts, labels and file name ->seller(fn ($s) => $s->electronicAddress('DE123456789', '9930')) // Peppol participant ID ->buyer(Party::make('Klant BV') ->vatId('BE0123456749') ->address('Rue de la Loi 16', '1000', 'Brussels', 'BE') ->electronicAddress('0123456749', '0208')) ->defaultVat(VatPreset::ReverseChargeEu) // for every line of this invoice ->line('IT consulting', netPrice: '110.00', quantity: 16, unit: UnitCode::Hour) ->dueInDays(14) ->render('peppol'); $xml = $result->xml(); // hand it to your Peppol access point ``` ```php plain use Quittio\Core\Builder\Party; use Quittio\Core\Enums\UnitCode; use Quittio\Country\DE\Tax\VatPreset; $result = $quittio->invoice() ->number('RE-2026-0105') ->issueDate('2026-10-09') ->deliveryDate('2026-09-30') ->buyerReference('PO-2026-118') // Peppol requires a buyer reference (BT-10) or an order reference (BT-13) ->locale('en') // English texts, labels and file name ->seller(fn ($s) => $s->electronicAddress('DE123456789', '9930')) // Peppol participant ID ->buyer(Party::make('Klant BV') ->vatId('BE0123456749') ->address('Rue de la Loi 16', '1000', 'Brussels', 'BE') ->electronicAddress('0123456749', '0208')) ->defaultVat(VatPreset::ReverseChargeEu) // for every line of this invoice ->line('IT consulting', netPrice: '110.00', quantity: 16, unit: UnitCode::Hour) ->dueInDays(14) ->render('peppol'); $xml = $result->xml(); // hand it to your Peppol access point ``` - `defaultVat()` sets the VAT of every line of this invoice. `VatPreset::ReverseChargeEu` is VAT category AE with 0 % and the text "Reverse charge, the recipient is liable for VAT" (in German: "Steuerschuldnerschaft des Leistungsempfängers"). - The German country pack requires the VAT identification numbers of both parties (`DE-USTG-11`). It warns when the invoice is issued after the 15th of the month following the service (`DE-USTG-15`). - Peppol needs an electronic address (participant ID) for both parties and a buyer reference or purchase order reference ([Peppol BIS Billing 3.0](formats.md#peppol-bis-billing-30)). Here these are the German VAT number (scheme 9930) and the Belgian enterprise number (scheme 0208). - `->seller(fn ($s) => …)` adds the Peppol address to the configured seller. A `Party` instead of the closure would replace the seller. - `->locale('en')` makes texts, labels and the file name English: `Invoice_RE-2026-0105.xml`. - Quittio writes the XML but does not send it. Sending goes through a Peppol access point, a provider connected to the network. ### EU business: goods You deliver goods to a business in another EU country, here two pumps to a customer in Austria. This is an intra-community supply, which is exempt from German VAT. The example also shows a deliver-to address that differs from the buyer's address, and a line with an item number and a country of origin. ```php laravel use Quittio\Core\Builder\Line; use Quittio\Core\Builder\Party; use Quittio\Core\Data\Party\Address; use Quittio\Core\Enums\UnitCode; use Quittio\Country\DE\Tax\VatPreset; use Quittio\Laravel\Facades\Quittio; $result = Quittio::invoice() ->number('RE-2026-0106') ->issueDate('2026-10-09') ->deliveryDate('2026-10-08') ->buyer(Party::make('Kunde Handels GmbH') ->vatId('ATU12345675') ->address('Mariahilfer Straße 1', '1060', 'Wien', 'AT')) ->deliverTo('Kunde Handels GmbH, Lager', Address::make('Industriestraße 4', '4020', 'Linz', 'AT')) // the customer's warehouse ("Lager") // Item number and country of origin go beyond the named values: Line::make() ->line(Line::make('Industrial pump', netPrice: '1450.00', quantity: 2, unit: UnitCode::Piece, vat: VatPreset::IntraCommunitySupply) ->sellerId('P-200') ->originCountry('DE')) ->render(); ``` ```php plain use Quittio\Core\Builder\Line; use Quittio\Core\Builder\Party; use Quittio\Core\Data\Party\Address; use Quittio\Core\Enums\UnitCode; use Quittio\Country\DE\Tax\VatPreset; $result = $quittio->invoice() ->number('RE-2026-0106') ->issueDate('2026-10-09') ->deliveryDate('2026-10-08') ->buyer(Party::make('Kunde Handels GmbH') ->vatId('ATU12345675') ->address('Mariahilfer Straße 1', '1060', 'Wien', 'AT')) ->deliverTo('Kunde Handels GmbH, Lager', Address::make('Industriestraße 4', '4020', 'Linz', 'AT')) // the customer's warehouse ("Lager") // Item number and country of origin go beyond the named values: Line::make() ->line(Line::make('Industrial pump', netPrice: '1450.00', quantity: 2, unit: UnitCode::Piece, vat: VatPreset::IntraCommunitySupply) ->sellerId('P-200') ->originCountry('DE')) ->render(); ``` - The line needs an item number and a country of origin, so it uses `Line::make()`. It takes the same named values as `line()` and allows the other methods of the line builder. - `VatPreset::IntraCommunitySupply` sets VAT category K with 0 % and the text "Steuerfreie innergemeinschaftliche Lieferung (§ 4 Nr. 1b i. V. m. § 6a UStG)" (tax-exempt intra-community supply under section 4 no. 1b in conjunction with section 6a UStG). - For category K, EN 16931 requires the buyer's VAT identification number, the delivery date and the country of the deliver-to address (rules `BR-IC-02`, `BR-IC-11`, `BR-IC-12`). The German country pack warns after the 15th of the following month (`DE-USTG-15`). - The automatic choice renders ZUGFeRD ([Reverse charge, intra-community supplies and VAT identifiers](country-packs.md#reverse-charge-intra-community-supplies-and-vat-identifiers)). ### Export You sell to a customer outside the EU, here a measuring device for a customer in the United States, invoiced in US dollars. Exports are exempt from German VAT. ```php laravel use Quittio\Core\Builder\Party; use Quittio\Core\Enums\PaymentMeansCode; use Quittio\Core\Enums\UnitCode; use Quittio\Country\DE\Tax\VatPreset; use Quittio\Laravel\Facades\Quittio; $result = Quittio::invoice() ->number('RE-2026-0107') ->issueDate('2026-10-12') ->deliveryDate('2026-10-12') ->currency('USD') ->buyer(Party::make('Customer Inc.')->address('1 Main Street', '10001', 'New York', 'US')) ->line('Measuring device', netPrice: '2400.00', unit: UnitCode::Piece, vat: VatPreset::Export) ->payment(PaymentMeansCode::CreditTransfer, iban: 'DE02120300000000202051', bic: 'BYLADEM1001') ->locale('en') ->render(); ``` ```php plain use Quittio\Core\Builder\Party; use Quittio\Core\Enums\PaymentMeansCode; use Quittio\Core\Enums\UnitCode; use Quittio\Country\DE\Tax\VatPreset; $result = $quittio->invoice() ->number('RE-2026-0107') ->issueDate('2026-10-12') ->deliveryDate('2026-10-12') ->currency('USD') ->buyer(Party::make('Customer Inc.')->address('1 Main Street', '10001', 'New York', 'US')) ->line('Measuring device', netPrice: '2400.00', unit: UnitCode::Piece, vat: VatPreset::Export) ->payment(PaymentMeansCode::CreditTransfer, iban: 'DE02120300000000202051', bic: 'BYLADEM1001') ->locale('en') ->render(); ``` - `VatPreset::Export` sets VAT category G with 0 % and, in English, the text "VAT-exempt export supply (section 4 no. 1a in conjunction with section 6 UStG)". - For a buyer outside the EU the automatic choice renders a PDF. Pass `->format('zugferd')` if the customer wants an e-invoice. - The account is given as credit transfer (payment means code 30), because a SEPA credit transfer (code 58) is for payments in euro. ### Foreign currency with German VAT You invoice a German customer in a foreign currency, here US dollars, with German VAT. Such an invoice also states the VAT in euro. The example sets the exchange rate and reads both VAT totals. ```php laravel use Quittio\Core\Builder\Party; use Quittio\Core\Enums\PaymentMeansCode; use Quittio\Laravel\Facades\Quittio; $result = Quittio::invoice() ->number('RE-2026-0108') ->issueDate('2026-10-12') ->deliveryDate('2026-10-12') ->currency('USD') ->taxCurrency('EUR', exchangeRate: '0.9234', rateDate: '2026-10-12') ->buyer(Party::make('Kunde AG') ->vatId('DE987654321') ->address('Bahnhofstraße 5', '54321', 'Beispielstadt', 'DE')) ->line('Software licence', netPrice: '399.00', quantity: 5) ->payment(PaymentMeansCode::CreditTransfer, iban: 'DE02120300000000202051', bic: 'BYLADEM1001') ->render(); $result->data()->totals->vatTotal; // USD 379.05 $result->data()->totals->vatTotalInTaxCurrency; // EUR 350.01 ``` ```php plain use Quittio\Core\Builder\Party; use Quittio\Core\Enums\PaymentMeansCode; $result = $quittio->invoice() ->number('RE-2026-0108') ->issueDate('2026-10-12') ->deliveryDate('2026-10-12') ->currency('USD') ->taxCurrency('EUR', exchangeRate: '0.9234', rateDate: '2026-10-12') ->buyer(Party::make('Kunde AG') ->vatId('DE987654321') ->address('Bahnhofstraße 5', '54321', 'Beispielstadt', 'DE')) ->line('Software licence', netPrice: '399.00', quantity: 5) ->payment(PaymentMeansCode::CreditTransfer, iban: 'DE02120300000000202051', bic: 'BYLADEM1001') ->render(); $result->data()->totals->vatTotal; // USD 379.05 $result->data()->totals->vatTotalInTaxCurrency; // EUR 350.01 ``` - `taxCurrency()` sets the VAT accounting currency (BT-6) and the exchange rate. The calculator writes the VAT in euro (BT-111): 379.05 × 0.9234 = 350.01. - Without the rate the validation fails (`BR-53`). Without `taxCurrency()` the German country pack warns (`DE-USTG-10`). See [Currency and exchange rate](building-invoices.md#currency-and-exchange-rate). ## Laravel applications These examples connect Quittio to your application: models, stored drafts and tests. ### Invoices for orders Your application stores customers, orders and order items as Eloquent models. Instead of copying their fields into the builder for every invoice, the models provide the data themselves. The example shows the three models and the code that issues, stores and mails the invoice when an order ships. ```php use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\HasMany; use Quittio\Core\Builder\LineBuilder; use Quittio\Core\Builder\PartyBuilder; use Quittio\Core\Contracts\ProvidesInvoiceData; use Quittio\Core\Contracts\ProvidesInvoiceLine; use Quittio\Core\Contracts\ProvidesParty; use Quittio\Core\Data\InvoiceData; use Quittio\Core\Enums\UnitCode; use Quittio\Country\DE\Tax\VatPreset; use Quittio\Laravel\Facades\Quittio; class Customer extends Model implements ProvidesParty { public function fillParty(PartyBuilder $party): void { $party->name($this->company) ->vatId($this->vat_id) ->address($this->street, $this->postcode, $this->city, $this->country) ->electronicAddress($this->email, 'EM'); } } class OrderItem extends Model implements ProvidesInvoiceLine { protected function casts(): array { return ['unit_price' => 'decimal:2']; // a string such as "24.90", never a float } public function fillLine(LineBuilder $line): void { $line->name($this->product_name) ->sellerId($this->sku) ->quantity($this->quantity, UnitCode::Piece) ->netPrice($this->unit_price) ->vat(VatPreset::from($this->tax_preset)); // stored preset key, e.g. "de.reduced" } } class Order extends Model implements ProvidesInvoiceData { protected function casts(): array { return ['invoiced_at' => 'date', 'shipped_at' => 'date']; } public function customer(): BelongsTo { return $this->belongsTo(Customer::class); } public function items(): HasMany { return $this->hasMany(OrderItem::class); } public function toInvoiceData(): InvoiceData { return Quittio::invoice() ->number($this->invoice_number) ->issueDate($this->invoiced_at) ->deliveryDate($this->shipped_at) ->purchaseOrderReference($this->customer_reference) ->buyer($this->customer) ->lines($this->items) ->dueInDays(14) ->build(); } } ``` The three contracts of `Quittio\Core\Contracts` connect the models to the builder ([Application models](building-invoices.md#application-models)): - `Customer` implements `ProvidesParty`: `fillParty()` fills the buyer, so `->buyer($this->customer)` takes the customer. - `OrderItem` implements `ProvidesInvoiceLine`: `fillLine()` fills one line, so `->lines($this->items)` takes the order items. - `Order` implements `ProvidesInvoiceData`: `toInvoiceData()` builds the invoice, so `Quittio::make($order)` renders the invoice of an order. When the order ships, issue the invoice once and keep the file: ```php use Illuminate\Support\Facades\Mail; use Illuminate\Support\Facades\Storage; use Quittio\Laravel\Facades\Quittio; // When the order ships: issue the invoice once, store it and send it $result = Quittio::make($order)->render(); $order->invoice_path = $result->save('invoices', 'orders/'); $order->save(); Mail::to($order->customer->email)->send(new InvoiceMail($result)); // Later downloads serve the stored file, so the invoice never changes return Storage::disk('invoices')->download($order->invoice_path); ``` - `InvoiceMail` is the mailable from [Mail attachments](laravel.md#mail-attachments); the rendered invoice is its attachment. - Rendering again later would build the invoice from the current model data. Serving the stored file keeps the issued invoice unchanged when, for example, the customer's address changes. - The invoice number comes from your number range. The [Managed layer](managed.md) assigns gapless numbers, stores the issued data and archives the files. - To render in the background: `Quittio::make($order)->queue()->save('invoices', 'orders/')` ([Queueing](laravel.md#queueing)). ### Drafts and previews Your users prepare an invoice over some time and want to see it before it is sent. Keep it as a draft: invoice data without a number that you store until you issue it. The example stores a draft as JSON, renders a preview, changes the draft and issues it. This needs no Managed layer. ```php laravel use Quittio\Core\Builder\InvoiceBuilder; use Quittio\Core\Builder\Party; use Quittio\Core\Data\InvoiceData; use Quittio\Core\Enums\UnitCode; use Quittio\Laravel\Facades\Quittio; // Create a draft and keep it as JSON, e.g. in a column of your model $draft = Quittio::invoice() ->buyer(Party::make('Kunde AG')->vatId('DE987654321')->address('Bahnhofstraße 5', '54321', 'Beispielstadt', 'DE')) ->line('Consulting', netPrice: '120.00', quantity: 10, unit: UnitCode::Hour) ->build(); $json = $draft->toJson(); // Preview: a PDF with watermark, without e-invoice XML; a draft has no number yet $preview = Quittio::make(InvoiceData::fromJson($json)) ->format('pdf') ->option('watermark', 'ENTWURF') // "Entwurf" means draft ->withoutValidation() ->render(); // Change the draft as often as needed $json = InvoiceBuilder::from(InvoiceData::fromJson($json)) ->updateLine('1', netPrice: '110.00') ->build() ->toJson(); // Issue it: number and dates, then render and store the final invoice $invoice = InvoiceBuilder::from(InvoiceData::fromJson($json)) ->number('RE-2026-0115') // the next number of your number range ->issueDate(today()) ->deliveryDate('2026-10-13') ->build(); $result = Quittio::make($invoice)->render(); $result->save('invoices', '2026/'); ``` ```php plain use DateTimeImmutable; use Quittio\Core\Builder\InvoiceBuilder; use Quittio\Core\Builder\Party; use Quittio\Core\Data\InvoiceData; use Quittio\Core\Enums\UnitCode; // Create a draft and keep it as JSON, e.g. in a column of your database $draft = $quittio->invoice() ->buyer(Party::make('Kunde AG')->vatId('DE987654321')->address('Bahnhofstraße 5', '54321', 'Beispielstadt', 'DE')) ->line('Consulting', netPrice: '120.00', quantity: 10, unit: UnitCode::Hour) ->build(); $json = $draft->toJson(); // Preview: a PDF with watermark, without e-invoice XML; a draft has no number yet $preview = $quittio->make(InvoiceData::fromJson($json)) ->format('pdf') ->option('watermark', 'ENTWURF') // "Entwurf" means draft ->withoutValidation() ->render(); // Change the draft as often as needed $json = InvoiceBuilder::from(InvoiceData::fromJson($json)) ->updateLine('1', netPrice: '110.00') ->build() ->toJson(); // Issue it: number and dates, then render and store the final invoice $invoice = InvoiceBuilder::from(InvoiceData::fromJson($json)) ->number('RE-2026-0115') // the next number of your number range ->issueDate(new DateTimeImmutable('today')) ->deliveryDate('2026-10-13') ->build(); $result = $quittio->make($invoice)->render(); $result->save(__DIR__.'/invoices/2026/'); ``` - A watermark renders a plain PDF and never e-invoice XML, so a draft cannot pass as an invoice ([Drafts and watermarks](formats.md#drafts-and-watermarks)). - The preview runs without validation because a draft has no number yet. Return `$preview->stream()` to show it in the browser (in plain PHP, send `$preview->pdf()` with the header `Content-Type: application/pdf`). - Issue a draft by setting the number and the dates. After that, never change the invoice; correct it with a [cancellation](#cancellation). - The [Managed layer](managed.md) adds drafts as database records, gapless numbering, frozen issued data, an archive with hashes, the history of cancellations and an audit log. ### Testing You want feature tests for the order flow from [Invoices for orders](#invoices-for-orders). The first test checks the flow with the fake: `Quittio::fake()` records every render call and skips validation, XML and PDF, so the test is fast. The second test runs the real validation on the invoice of an order with `check()`: ```php use Illuminate\Support\Facades\Mail; use Illuminate\Support\Facades\Storage; use Quittio\Laravel\Facades\Quittio; use Quittio\Laravel\Rendering\RenderedInvoice; it('sends the invoice when an order ships', function () { Quittio::fake(); // no PDF, no XML, no validation: fast Mail::fake(); Storage::fake('invoices'); $order = Order::factory()->create(['invoice_number' => 'RE-2026-0130']); $this->post("/orders/{$order->id}/ship")->assertOk(); Quittio::assertRendered(fn (RenderedInvoice $r) => $r->data()->number === 'RE-2026-0130' && $r->format() === 'zugferd'); Mail::assertSent(InvoiceMail::class); }); it('builds a valid e-invoice for an order', function () { $order = Order::factory()->create(); $report = Quittio::make($order)->check(); // the real validation, without rendering expect($report->isValid())->toBeTrue() ->and($report->warnings())->toBe([]); }); ``` - `Order::factory()` is the model factory of your application. `InvoiceMail` and the route are from [Invoices for orders](#invoices-for-orders). - `assertRendered()` passes if at least one rendered invoice matches the callback ([Fake](testing.md#fake)). - `check()` is never faked. It validates like a render run, including the XML, without rendering a PDF ([Testing](testing.md)). ## Quotes and reminders Besides invoices, Quittio renders other business documents such as quotes and payment reminders ([Quotes and other documents](documents.md)). ### From quote to invoice You send the customer a quote first and invoice when they accept it. The example shows a quote with an optional line and an invoice that takes over the accepted quote. ```php laravel use Quittio\Core\Builder\InvoiceBuilder; use Quittio\Core\Builder\Party; use Quittio\Core\Enums\UnitCode; use Quittio\Laravel\Facades\Quittio; $quote = Quittio::quote() ->number('AN-2026-0031') ->issueDate('2026-10-01') ->validUntil('2026-10-31') ->buyer(Party::make('Kunde AG')->vatId('DE987654321')->address('Bahnhofstraße 5', '54321', 'Beispielstadt', 'DE')) ->line('Workshop "E-invoicing"', netPrice: '1200.00', unit: UnitCode::Day) ->optionalLine('Follow-up session', netPrice: '120.00', quantity: 4, unit: UnitCode::Hour); $quote->render()->save('documents', 'quotes/'); // quotes/Angebot_AN-2026-0031.pdf ("Angebot": quote) // The customer accepts: the invoice takes over parties, lines (without the optional line) and the bank account $result = Quittio::make(InvoiceBuilder::fromDocument($quote->build()) ->number('RE-2026-0140') ->issueDate('2026-11-03') ->deliveryDate('2026-10-28') ->dueInDays(14)) ->render(); ``` ```php plain use Quittio\Core\Builder\InvoiceBuilder; use Quittio\Core\Builder\Party; use Quittio\Core\Enums\UnitCode; $quote = $quittio->quote() ->number('AN-2026-0031') ->issueDate('2026-10-01') ->validUntil('2026-10-31') ->buyer(Party::make('Kunde AG')->vatId('DE987654321')->address('Bahnhofstraße 5', '54321', 'Beispielstadt', 'DE')) ->line('Workshop "E-invoicing"', netPrice: '1200.00', unit: UnitCode::Day) ->optionalLine('Follow-up session', netPrice: '120.00', quantity: 4, unit: UnitCode::Hour); $quote->render()->save(__DIR__.'/quotes/'); // quotes/Angebot_AN-2026-0031.pdf ("Angebot": quote) // The customer accepts: the invoice takes over parties, lines (without the optional line) and the bank account $result = $quittio->make(InvoiceBuilder::fromDocument($quote->build()) ->number('RE-2026-0140') ->issueDate('2026-11-03') ->deliveryDate('2026-10-28') ->dueInDays(14)) ->render(); ``` - The optional line is shown with its amounts. It is not counted in the totals and not taken over by `fromDocument()`. The invoice totals 1,428.00. - `Quittio::quote()` carries the bank account of the configuration, although quotes do not print it. The invoice takes it over ([From document to invoice](documents.md#from-document-to-invoice)). ### Payment reminder A customer has not paid an invoice by its due date. The example sends the first reminder ("1. Mahnung") and adds the statutory default interest for a business customer. ```php laravel use Brick\Money\Money; use Quittio\Core\Builder\Party; use Quittio\Core\Support\Amount; use Quittio\Core\Support\Date; use Quittio\Country\DE\Dunning\DefaultInterest; use Quittio\Laravel\Facades\Quittio; $reminder = Quittio::paymentReminder(1) // first reminder ("1. Mahnung"), with seller and bank account ->number('M-2026-0005') ->issueDate('2026-10-15') ->buyer(Party::make('Kunde AG')->address('Bahnhofstraße 5', '54321', 'Beispielstadt', 'DE')) ->openItem('RE-2026-0042', '2026-08-03', '1190.00', dueDate: '2026-08-17') ->deadline('2026-10-29'); // Statutory default interest (section 288 BGB, the German Civil Code), split at every change of the base rate foreach ((new DefaultInterest)->calculate(Money::of('1190.00', 'EUR'), Date::parse('2026-08-18'), Date::parse('2026-10-15')) as $charge) { $reminder->interest(Amount::format($charge->base), $charge->ratePercent, $charge->from, $charge->until, $charge->description, $charge->dayCount); } $reminder->render()->save('documents', 'reminders/'); // reminders/1._Mahnung_M-2026-0005.pdf $reminder->build()->dunning->total('EUR'); // EUR 1209.89 ``` ```php plain use Brick\Money\Money; use Quittio\Core\Builder\Party; use Quittio\Core\Support\Amount; use Quittio\Core\Support\Date; use Quittio\Country\DE\Dunning\DefaultInterest; $reminder = $quittio->paymentReminder(1) // first reminder ("1. Mahnung"), with seller and bank account ->number('M-2026-0005') ->issueDate('2026-10-15') ->buyer(Party::make('Kunde AG')->address('Bahnhofstraße 5', '54321', 'Beispielstadt', 'DE')) ->openItem('RE-2026-0042', '2026-08-03', '1190.00', dueDate: '2026-08-17') ->deadline('2026-10-29'); // Statutory default interest (section 288 BGB, the German Civil Code), split at every change of the base rate foreach ((new DefaultInterest)->calculate(Money::of('1190.00', 'EUR'), Date::parse('2026-08-18'), Date::parse('2026-10-15')) as $charge) { $reminder->interest(Amount::format($charge->base), $charge->ratePercent, $charge->from, $charge->until, $charge->description, $charge->dayCount); } $reminder->render()->save(__DIR__.'/reminders/'); // reminders/1._Mahnung_M-2026-0005.pdf $reminder->build()->dunning->total('EUR'); // EUR 1209.89 ``` - `paymentReminder(1)` is the first formal reminder. Level 0 is a friendly payment reminder ("Zahlungserinnerung"), level 2 the second reminder, and so on ([Payment reminders](documents.md#payment-reminders)). - `openItem()` lists the unpaid invoice with its number, date, amount and due date. `deadline()` is the date by which the customer should pay. - `calculate()` takes the first day with interest and the day after the last one. Here the rate is 10.52 % a year: the base rate of 1.52 % plus 9 points for business debtors. From 18 August to 14 October 2026 this gives 19.89, so the reminder asks for 1,209.89. For consumers pass `consumer: true` (5 points). See [Default interest](country-packs.md#default-interest). - Fees and interest carry no VAT. - The PDF is saved as `1._Mahnung_M-2026-0005.pdf`, after its German title "1. Mahnung" (first reminder). ## Incoming e-invoices Your suppliers send you e-invoices, and you want to check and book them. The example is controller code that accepts an uploaded e-invoice, validates it and extracts the values for your accounting. ```php laravel use Quittio\Laravel\Facades\Quittio; $content = $request->file('invoice')->get(); // uploaded PDF or XML $report = Quittio::validateFile($content); if (! $report->isValid()) { return back()->withErrors(array_map(fn ($m) => "[{$m->code}] {$m->message}", $report->errors())); } $read = Quittio::read($content); $invoice = $read->data; $booking = [ 'supplier' => $invoice->seller->name, 'supplier_vat_id' => $invoice->seller->vatId, 'number' => $invoice->number, 'issue_date' => $invoice->issueDate->toIsoString(), 'due_date' => $invoice->dueDate?->toIsoString(), 'amount_due' => (string) $invoice->totals?->amountDue->getAmount(), 'currency' => $invoice->currency, 'iban' => $invoice->paymentInstructions?->primaryCreditTransfer()?->accountId, 'profile' => $read->profile, // e.g. "en16931" or "xrechnung" ]; ``` ```php plain $content = file_get_contents($_FILES['invoice']['tmp_name']); // uploaded PDF or XML $report = $quittio->validateFile($content); if (! $report->isValid()) { return array_map(fn ($m) => "[{$m->code}] {$m->message}", $report->errors()); // e.g. to show them with the form } $read = $quittio->read($content); $invoice = $read->data; $booking = [ 'supplier' => $invoice->seller->name, 'supplier_vat_id' => $invoice->seller->vatId, 'number' => $invoice->number, 'issue_date' => $invoice->issueDate->toIsoString(), 'due_date' => $invoice->dueDate?->toIsoString(), 'amount_due' => (string) $invoice->totals?->amountDue->getAmount(), 'currency' => $invoice->currency, 'iban' => $invoice->paymentInstructions?->primaryCreditTransfer()?->accountId, 'profile' => $read->profile, // e.g. "en16931" or "xrechnung" ]; ``` For the ZUGFeRD invoice of the first example, `$booking` is: ```json {"supplier":"Muster GmbH","supplier_vat_id":"DE123456789","number":"RE-2026-0101","issue_date":"2026-10-01","due_date":"2026-10-31","amount_due":"7123.94","currency":"EUR","iban":"DE02120300000000202051","profile":"en16931"} ``` - `validateFile()` reads the file and runs all configured validation levels ([Validation](validation.md)). Each error has a rule code and a message, which the example passes back to the form. - `read()` returns the data as stated in the document. It reads XML in both syntaxes (CII and UBL, including XRechnung and Peppol) and PDFs with embedded XML the same way ([Syntaxes](concepts.md#syntaxes-cii-and-ubl), [Reading incoming invoices](reading.md)). - Amounts are never corrected silently: totals that differ from a recalculation are reported as `QUITTIO-DECLARED-TOTALS`. ## Logo, colours and texts You usually set your logo, colours and texts once in the configuration. The example shows how to set them for a single invoice. ```php laravel use Quittio\Core\Builder\Party; use Quittio\Core\Data\Presentation\Colors; use Quittio\Core\Data\Presentation\Presentation; use Quittio\Core\Enums\UnitCode; use Quittio\Laravel\Facades\Quittio; $result = Quittio::invoice() ->number('RE-2026-0150') ->deliveryDate('2026-10-14') ->buyer(Party::make('Kunde AG')->vatId('DE987654321')->address('Bahnhofstraße 5', '54321', 'Beispielstadt', 'DE')) ->line('Consulting', netPrice: '120.00', quantity: 4, unit: UnitCode::Hour) ->presentation(new Presentation( logo: storage_path('app/logo.png'), colors: new Colors(primary: '#0f766e'), introText: 'Thank you for your order. We invoice the following services:', closingText: 'Questions about this invoice? Call us at +49 30 1234567.', footerColumns: [ ['Muster GmbH', 'Hauptstraße 1', '12345 Musterstadt'], ['Managing director: Max Muster', 'Amtsgericht Musterstadt, HRB 12345'], // register court and register number ['Bank: Musterbank', 'IBAN DE02 1203 0000 0000 2020 51'], ], )) ->render(); ``` ```php plain use Quittio\Core\Builder\Party; use Quittio\Core\Data\Presentation\Colors; use Quittio\Core\Data\Presentation\Presentation; use Quittio\Core\Enums\UnitCode; $result = $quittio->invoice() ->number('RE-2026-0150') ->deliveryDate('2026-10-14') ->buyer(Party::make('Kunde AG')->vatId('DE987654321')->address('Bahnhofstraße 5', '54321', 'Beispielstadt', 'DE')) ->line('Consulting', netPrice: '120.00', quantity: 4, unit: UnitCode::Hour) ->presentation(new Presentation( logo: __DIR__.'/logo.png', colors: new Colors(primary: '#0f766e'), introText: 'Thank you for your order. We invoice the following services:', closingText: 'Questions about this invoice? Call us at +49 30 1234567.', footerColumns: [ ['Muster GmbH', 'Hauptstraße 1', '12345 Musterstadt'], ['Managing director: Max Muster', 'Amtsgericht Musterstadt, HRB 12345'], // register court and register number ['Bank: Musterbank', 'IBAN DE02 1203 0000 0000 2020 51'], ], )) ->render(); ``` - The same values for all invoices go into the configuration: `pdf.logo`, `pdf.colors.primary`, `pdf.texts.intro`, `pdf.texts.closing` and `pdf.footer_columns` ([Configuration](configuration.md)). - Logos are PNG, JPEG or SVG. SVG logos in PDF/A need the PHP extension `imagick` ([Logos](templates.md#logos)). - The design is never part of the XML. ## Without Laravel You use Quittio in a PHP application without Laravel. Every example above has a plain PHP variant when you switch its code to PHP. This example is a complete script with the packages `quittio/core` and `quittio/country-de` (the German country pack). It renders an invoice, saves it and reads it back. ```php Party::make('Muster GmbH')->vatId('DE123456789')->address('Hauptstraße 1', '12345', 'Musterstadt', 'DE'), 'bank_account' => ['iban' => 'DE02120300000000202051'], 'due_days' => 14, ], [new CountryDE]); InvoiceBuilder::useDefaultVat(new CountryDefaultVat($quittio->countries())); // lines without vat(): 19 % $result = $quittio->invoice() ->number('RE-2026-0120') ->issueDate('2026-10-14') ->deliveryDate('2026-10-14') ->buyer(Party::make('Kunde AG')->vatId('DE987654321')->address('Bahnhofstraße 5', '54321', 'Beispielstadt', 'DE')) ->line('Consulting', netPrice: '120.00', quantity: 4, unit: UnitCode::Hour) ->render(); $path = $result->save(__DIR__.'/invoices/'.$result->filename()); // invoices/Rechnung_RE-2026-0120.pdf // Read it back, as the recipient would $read = $quittio->readFile($path); echo $read->data->totals->amountDue; // EUR 571.20 ``` - Without Laravel there is no configuration file and no facade. Your company, its bank account and the payment target go to `Quittio::create()`; `$quittio->invoice()` starts an invoice with them, like `Quittio::invoice()` in Laravel ([Without Laravel](getting-started.md#without-laravel)). - `useDefaultVat()` gives lines without `vat()` the default VAT of the seller's country pack (19 % in Germany), as the Laravel integration does. Without a default, such lines make `build()` fail. - `Quittio::create()` takes the configuration as an array ([Without Laravel](getting-started.md#without-laravel)). The instance offers `make()`, `cancellation()`, `document()`, `read()` and the other methods of the facade. # Building invoices This page is the reference for creating invoice data with Quittio's invoice builder: every builder method, VAT, payment, the calculation of totals, cancellations and the data model. Use it when you write your first real invoice and whenever you need an option that the tutorial does not show. If you have not rendered an invoice yet, start with [Getting started](getting-started.md); terms such as EN 16931, business terms and profiles are explained in [E-invoicing basics](concepts.md). The page has three parts: - **Basics:** the [overview](#overview) with the usual way to write each part of an invoice, the [conventions](#conventions) for amounts, dates and codes, and [creating and building](#creating-and-building) the data. - **The parts of an invoice**, in the order you usually need them: [number and type](#document-type-and-identification), [dates](#dates), [parties](#parties), [lines](#lines), [VAT](#vat), [payment](#payment), [references](#references), [notes](#notes), [attachments](#supporting-documents), [design and metadata](#presentation-and-metadata) and [your own models](#application-models). - **Advanced topics:** [foreign currencies](#currency-and-exchange-rate), [allowances and charges](#allowances-and-charges), [sub lines](#sub-lines), [prices including VAT](#gross-price-mode), [changing existing data](#changing-existing-data), [cancellations](#cancellations-and-corrections), [data of profile EXTENDED](#extensions), [macros](#macros), the [calculation](#calculation) and the [data model](#data-model). ## Overview `Quittio\Core\Builder\InvoiceBuilder` creates an `InvoiceData` object: the invoice as immutable data, following the European standard EN 16931 ([EN 16931 and business terms](concepts.md#en-16931-and-business-terms)). The builder is part of `quittio/core` and works with and without Laravel. Rendering turns the data into PDF and XML ([Formats and profiles](formats.md), [Laravel integration](laravel.md)). In Laravel, start with `Quittio::invoice()`. It returns the same builder, already filled with the seller, the first bank account and the small business setting of `config/quittio.php`, and the builder can render itself with `->render()` ([Starting invoices](laravel.md#starting-invoices)): ```php laravel use Quittio\Core\Builder\Party; use Quittio\Core\Enums\PaymentMeansCode; use Quittio\Core\Enums\UnitCode; use Quittio\Country\DE\Tax\VatPreset; use Quittio\Laravel\Facades\Quittio; $invoice = Quittio::invoice() // seller and bank account from config/quittio.php ->number('RE-2026-0042') ->issueDate('2026-10-03') ->deliveryDate('2026-09-30') // date of supply, mandatory in Germany ->buyerReference('PO-4711') ->buyer(Party::make('Kunde AG') ->vatId('DE987654321') ->address('Bahnhofstraße 5', '54321', 'Beispielstadt', 'DE') ->electronicAddress('ap@kunde.de', 'EM')) ->line('Web development', netPrice: '95.00', quantity: 24, unit: UnitCode::Hour) // default VAT: 19 % ->line('Handbook of VAT law', netPrice: '39.00', vat: VatPreset::Reduced) ->payment(PaymentMeansCode::SepaCreditTransfer, remittanceInformation: 'RE-2026-0042') // keeps the configured account ->dueInDays(14)->cashDiscount(days: 7, percent: '2.00') ->build(); // or ->render() for PDF and XML ``` ```php plain use Quittio\Core\Builder\Party; use Quittio\Core\Enums\PaymentMeansCode; use Quittio\Core\Enums\UnitCode; use Quittio\Country\DE\Tax\VatPreset; $invoice = $quittio->invoice() // seller and bank account from Quittio::create() ->number('RE-2026-0042') ->issueDate('2026-10-03') ->deliveryDate('2026-09-30') // date of supply, mandatory in Germany ->buyerReference('PO-4711') ->buyer(Party::make('Kunde AG') ->vatId('DE987654321') ->address('Bahnhofstraße 5', '54321', 'Beispielstadt', 'DE') ->electronicAddress('ap@kunde.de', 'EM')) ->line('Web development', netPrice: '95.00', quantity: 24, unit: UnitCode::Hour) // default VAT: 19 % ->line('Handbook of VAT law', netPrice: '39.00', vat: VatPreset::Reduced) ->payment(PaymentMeansCode::SepaCreditTransfer, remittanceInformation: 'RE-2026-0042') // keeps the configured account ->dueInDays(14)->cashDiscount(days: 7, percent: '2.00') ->build(); // or ->render() for PDF and XML ``` Without Laravel, start with `$quittio->invoice()`. With your company as `seller` in `Quittio::create()`, it returns the same builder with the seller, the configured `bank_account` and `small_business`, and it renders itself with `->render()` ([Rendering in the core](formats.md#invoices-and-documents-with-the-configured-seller)). `InvoiceBuilder::make()` starts an empty builder for special cases, e.g. another seller per invoice; set the seller yourself ([Seller and buyer](#seller-and-buyer)) and render it with `$quittio->make($builder)`. The plain PHP examples on this page use `$quittio` as created in [Without Laravel](getting-started.md#without-laravel), with your company as `seller`. Three things to know before you continue: - `build()` returns the data. At the end of `Quittio::invoice()` or `$quittio->invoice()`, `render()` renders it right away instead. - You never pass totals, VAT amounts or the VAT breakdown. Quittio calculates them when the invoice is rendered ([Calculation](#calculation)). - The builder only checks that the essential parts are there ([Creating and building](#creating-and-building)). Everything else, such as a missing invoice number, is reported by the [validation](validation.md) when the invoice is rendered. ### The usual forms Most parts of an invoice can be written in several ways. This documentation uses one usual form for each, the same as [Getting started](getting-started.md#one-way-to-write-it). The other forms exist for special cases; the linked sections describe them. | You need | Write | Details | |---|---|---| | A line with price, quantity, unit, VAT or description | `->line('Hosting', netPrice: '49.00', quantity: 12, unit: UnitCode::Month)`. Without `quantity` it is 1, without `vat` the default VAT applies (in Laravel 19 % for a German seller). | [Lines](#lines), [Default VAT](#default-vat) | | A line with more than that: item number, line discount, list price, period, sub lines, line group | `->line(Line::make('Pump', netPrice: '1450.00', quantity: 2)->sellerId('P-200'))`. `Line::make()` takes the same named values as `line()` and returns the line builder for the other methods. | [LineBuilder](#linebuilder) | | Many lines from your data | `->lines($order->items)` with models that implement `ProvidesInvoiceLine`, or `->lines($rows)` with arrays such as `['name' => 'Hosting', 'netPrice' => '49.00']` | [Lines](#lines), [Application models](#application-models) | | The customer | `->buyer($customer)` with a model that implements `ProvidesParty`, otherwise `->buyer(Party::make('Kunde AG')->address(…))` | [Seller and buyer](#seller-and-buyer) | | A VAT rate other than the default | `->line('Book', netPrice: '39.00', vat: VatPreset::Reduced)` | [VAT](#vat) | | Payment terms | `->dueInDays(14)->cashDiscount(days: 7, percent: '2.00')` | [Payment terms](#payment-terms) | | The result | `->render()` for PDF and XML, `->build()` for the data only, e.g. to store a draft | [Creating and building](#creating-and-building) | ## Conventions These rules apply to every method on this page. **Chaining.** Every builder method returns the builder, so calls can be chained. The builders are mutable; the built `InvoiceData` is not ([Immutability](#immutability)). **Numbers are strings.** Amounts, prices, quantities, percentages and rates are strings (`'95.00'`), integers or `Brick\Math` numbers. Floats are rejected with an `InvalidArgumentException` ("Floats are not accepted …"), with or without `declare(strict_types=1)`, because most decimal values have no exact float representation. - Methods typed `BigDecimal|int|float|string` accept a float only to reject it. Without `float` in the signature, PHP would turn `19.99` into `19` in files without strict types. - Parameters typed `string`, such as the amount of `allowance()`, receive a float as its string form. **Amounts have at most two decimals.** Allowance, charge, prepaid and rounding amounts and the base amounts of cash discounts have at most two decimals, in every currency. More decimals throw an `InvalidArgumentException`. Prices, quantities, percentages and rates keep any precision. **Dates.** Date parameters accept a `Quittio\Core\Support\Date`, a `DateTimeInterface` or a string: `YYYY-MM-DD`, `YYYYMMDD` or another notation that names a calendar date. Relative expressions such as `tomorrow` or `+14 days` are rejected. A `DateTimeInterface` is converted into a date in the time zone set with `timezone()`, so call `timezone()` first. `invoicingPeriod()` and `LineBuilder::period()` accept `Date` objects and strings only. **Codes.** Code parameters take the enum case (`UnitCode::Hour`) or the code as string (`'HUR'`). A string that is not a case of the enum is kept as `Quittio\Core\Codes\RawCode`, so every code of the official code lists can be used; the validation checks raw codes against the code lists. Exception: `attachment()` accepts only the MIME types of `MimeType`. **Calculated values.** Line net amounts (BT-131), the document totals (BG-22), the VAT breakdown (BG-23) and the due date derived from the payment terms are calculated when the invoice is rendered ([Calculation](#calculation)). There is no method to set them. **Terms used on this page:** - Numbers such as "buyer reference (BT-10)" or "seller postal address (BG-5)" are the business terms (BT) and business groups (BG) of EN 16931. You never type them in code; they help you match validation messages and the [field reference](field-reference.md) ([EN 16931 and business terms](concepts.md#en-16931-and-business-terms)). - Codes such as `BR-CO-26`, `BR-DE-1` or `QUITTIO-PROFORMA` name the rules that the validation checks ([Rules and validation](concepts.md#rules-and-validation)). - ZUGFeRD/Factur-X, XRechnung and Peppol are e-invoice formats ([Formats](concepts.md#formats)). CII and UBL are the two XML syntaxes they use ([Syntaxes: CII and UBL](concepts.md#syntaxes-cii-and-ubl)). A profile, such as EN 16931, EXTENDED or XRechnung, decides which fields and rules an XML file has ([Profiles](concepts.md#profiles)). - A country pack brings the tax presets, legal rules and texts of one country; `quittio/quittio` includes the German pack ([Country packs](country-packs.md)). - A **VAT group** is everything with the same VAT category and rate. The **VAT breakdown** (BG-23) has one entry per VAT group, with its taxable amount and its VAT. - round2(x) is x rounded half up to two decimals. ## Creating and building The tables of this page group the builder methods by topic and name their business terms. The API reference lists every method with its parameters. | Method | Description | |---|---| | `InvoiceBuilder::make()` | New, empty builder. Defaults: type code 380 (commercial invoice), currency `EUR`, EN 16931:2017. | | `$quittio->invoice()`, Laravel `Quittio::invoice()` | Builder with the configured seller, bank account and small business flag. It ends with `render()` or `check()` ([Invoices and documents with the configured seller](formats.md#invoices-and-documents-with-the-configured-seller), [Starting invoices](laravel.md#starting-invoices)). | | `InvoiceBuilder::from(InvoiceData $data)` | Builder with all values of existing data, e.g. to change a draft, a stored invoice or a read invoice ([Changing existing data](#changing-existing-data)). | | `Quittio::edit(InvoiceData $data)` | Like `from()`, but declared amounts are compared with the configured calculator and its policy ([Declared amounts](#declared-amounts)). `InvoiceBuilder::fromUsing($data, $calculator)` does the same with a calculator of your own. | | `InvoiceBuilder::fromDocument(DocumentData $document)` | Invoice from a quote, order confirmation, delivery note or proforma invoice. Parties, billable lines, document allowances and charges and payment data are taken over; number, issue date and notes are not. The number of an order confirmation becomes the sales order reference (BT-14), that of a delivery note the despatch advice reference (BT-16). See [From document to invoice](documents.md#from-document-to-invoice). | | `build(): InvoiceData` | Builds the data. Requires at least one line. | | `buildDraft(): InvoiceData` | Builds without requiring lines, e.g. for drafts or as the basis of payment reminders or account statements. Data without lines can be calculated (its line sum is zero), but it is not a valid invoice (BR-16). | `build()` and `buildDraft()` throw `Quittio\Core\Exceptions\InvalidInvoiceData` (an `InvalidArgumentException`) when an essential part is missing. The message names the business term, e.g. "Missing buyer postal address (BG-8).": | Missing | Business term | |---|---| | Seller, seller name, seller postal address | BG-4, BT-27, BG-5 | | Buyer, buyer name, buyer postal address | BG-7, BT-44, BG-8 | | Lines (`build()` only) | BG-25 | | Item name of a line | BT-153 | | VAT category of a line, unless the invoice has a [default VAT](#default-vat) | BG-30 | Everything else is reported by the [validation](validation.md) when the invoice is rendered or checked, e.g. a missing invoice number or a missing buyer reference that XRechnung requires. Without `issueDate()`, the issue date is today in the builder's time zone (`timezone()`, otherwise PHP's default time zone). ## Document type and identification Every invoice needs a number. The type code tells the recipient what kind of document it is. Its default, 380, is a normal commercial invoice, so most invoices only call `number()`. | Method | BT | Description | |---|---|---| | `number(string $number)` | BT-1 | Invoice number. The builder does not check it; the validation requires it. The [Managed layer](managed.md) assigns numbers itself. | | `type(InvoiceTypeCode\|RawCode\|string $type)` | BT-3 | Type code from the code list UNTDID 1001, default `InvoiceTypeCode::CommercialInvoice` (380). See [Type codes](#type-codes). | | `businessProcess(?string $process)` | BT-23 | Business process identifier. The profiles Peppol and XRechnung write `urn:fdc:peppol.eu:2017:poacc:billing:01:1.0` when it is not set. | | `standard(StandardVersion $version)` | BT-24 | Version of EN 16931: `StandardVersion::En16931_2017` (default) or `En16931_2026`. Only the profile EN 16931 supports 2026 (`urn:cen.eu:en16931:2026`); other profiles report `QUITTIO-STANDARD-VERSION`. | The specification identifier (BT-24) itself is not part of the data. It comes from the profile chosen when rendering ([Formats and profiles](formats.md#profiles)). ### Credit notes, corrected invoices and self-billing Set another type code when the document is not a normal invoice: ```php laravel use Quittio\Core\Enums\InvoiceTypeCode; use Quittio\Laravel\Facades\Quittio; // Credit note: positive amounts, type code 381, reference to the invoice Quittio::invoice()->type(InvoiceTypeCode::CreditNote)->precedingInvoice('RE-2026-0042', '2026-10-03'); // Corrected invoice (384) based on the original, with the note "Diese Rechnung berichtigt und ersetzt …" Quittio::correction($original, 'RE-2026-0050') ->updateLine('2', netPrice: '80.00'); // Self-billing: the buyer issues the invoice, the supplier stays the seller (BG-4) Quittio::invoice()->type(InvoiceTypeCode::SelfBilledInvoice); ``` ```php plain use Quittio\Core\Enums\InvoiceTypeCode; // Credit note: positive amounts, type code 381, reference to the invoice $quittio->invoice()->type(InvoiceTypeCode::CreditNote)->precedingInvoice('RE-2026-0042', '2026-10-03'); // Corrected invoice (384) based on the original, with the note "Diese Rechnung berichtigt und ersetzt …" $quittio->correction($original, 'RE-2026-0050') ->updateLine('2', netPrice: '80.00'); // Self-billing: the buyer issues the invoice, the supplier stays the seller (BG-4) $quittio->invoice()->type(InvoiceTypeCode::SelfBilledInvoice); ``` To cancel an issued invoice, build a cancellation with `Quittio::cancellation()` instead ([Cancellations and corrections](#cancellations-and-corrections)); `Quittio::correction()` is described in [Corrected invoices](#corrected-invoices). The German pack adds `selfBilled()` for self-billing. It sets type code 389 and adds the note "Gutschrift" (self-billed invoice) with subject `REG`, which the German rules require ([Self-billing](country-packs.md#self-billing-gutschrift), [German terms](concepts.md#german-terms)). ### Type codes `InvoiceTypeCode` contains the type codes that EN 16931 allows: | Case | Code | Note | |---|---|---| | `CommercialInvoice` | 380 | Default. | | `CreditNote` | 381 | Credit note with positive amounts; UBL writes a `CreditNote` document. | | `CorrectedInvoice` | 384 | Reference the corrected invoice with `precedingInvoice()`. | | `SelfBilledInvoice` | 389 | Issued by the buyer (self-billing). | | `SelfBilledCreditNote` | 261 | Self-billed credit note. | | `SelfBilledDebitNote` | 527 | Self-billed debit note. | | `PartialInvoice` | 326 | Partial invoice. | | `PrepaymentInvoice` | 386 | Advance payment invoice. | | `PartialConstructionInvoice`, `PartialFinalConstructionInvoice`, `FinalConstructionInvoice` | 875, 876, 877 | Construction invoices. | | `DebitNote` | 383 | Debit note. | | `ProformaInvoice` | 325 | Rejected in the invoice pipeline (`QUITTIO-PROFORMA`); use `Quittio::proforma()` in Laravel, `$quittio->proforma()` or `DocumentBuilder::proforma()` ([Proforma invoices](documents.md#proforma-invoices)). | Further cases: `RequestForPayment` (71), `DebitNoteGoodsServices` (80), `CreditNoteGoodsServices` (81), `MeteredServicesInvoice` (82), `CreditNoteFinancialAdjustment` (83), `DebitNoteFinancialAdjustment` (84), `TaxNotification` (102), `InvoicingDataSheet` (130), `DirectPaymentValuation` (202), `ProvisionalPaymentValuation` (203), `PaymentValuation` (204), `InterimApplicationForPayment` (211), `FinalPaymentRequest` (218), `PaymentRequestForCompletedUnits` (219), `ConsolidatedCreditNote` (262), `PriceVariationInvoice` (295), `CreditNoteForPriceVariation` (296), `DelcredereCreditNote` (308), `CommercialInvoiceWithPackingList` (331), `CommissionNote` (382), `ConsolidatedInvoice` (385), `HireInvoice` (387), `TaxInvoice` (388), `DelcredereInvoice` (390), `FactoredInvoice` (393), `LeaseInvoice` (394), `ConsignmentInvoice` (395), `FactoredCreditNote` (396), `OcrPaymentCreditNote` (420), `DebitAdvice` (456), `ReversalOfDebit` (457), `ReversalOfCredit` (458), `ForwardersCreditNote` (532), `ForwardersInvoiceDiscrepancyReport` (553), `InsurersInvoice` (575), `ForwardersInvoice` (623), `PortChargesDocument` (633), `InvoiceInformationForAccounting` (751), `FreightInvoice` (780), `ClaimNotification` (817), `ConsularInvoice` (870), `CustomsInvoice` (935). `InvoiceTypeCode::isCreditNote()` is true for 81, 83, 261, 262, 296, 308, 381, 396, 420, 458 and 532. These are written as a `CreditNote` document in UBL. `isSelfBilled()` is true for 261, 389 and 527. The document title in PDF, HTML and file names follows the type code: - 380, 381, 384, 389, 325, 326, 386, 875, 876 and 877 have their own title. - Other credit notes use the title of 381, other self-billed documents that of 389. - Everything else is titled "Invoice" ("Rechnung" on a German invoice). `Presentation::$title` overrides the title. ## Dates An invoice has an issue date and usually the date or period of the delivery or service. German invoices must state the date of supply: a delivery date (`deliveryDate()`), an invoicing period (`invoicingPeriod()`) or a period on the lines (rule `DE-USTG-03`). | Method | BT | Description | |---|---|---| | `issueDate(Date\|DateTimeInterface\|string $date)` | BT-2 | Issue date, default today. | | `deliveryDate(Date\|DateTimeInterface\|string $date)` | BT-72 | Actual delivery or service date. Keeps the deliver-to data. | | `invoicingPeriod(Date\|string\|null $start, Date\|string\|null $end = null)` | BG-14 (BT-73, BT-74) | Invoicing or service period. One of the two dates may be `null`, not both. | | `dueDate(Date\|DateTimeInterface\|string $date)` | BT-9 | Due date. Without it, the calculator derives it from `dueInDays()`. Without payment terms, the configured default applies when rendering (`due_days`, Laravel `defaults.due_days`, default 14 there); never for credit notes. | | `taxPointDate(Date\|DateTimeInterface\|string $date)` | BT-7 | Date when VAT becomes chargeable, if it differs from the issue date. | | `taxPointDateCode(TaxPointDateCode $code)` | BT-8 | `TaxPointDateCode::IssueDate`, `DeliveryDate` or `PaymentDate` (written as 5, 29, 72 in CII and 3, 35, 432 in UBL). EN 16931 allows BT-7 or BT-8, not both (BR-CO-03). | | `timezone(string $timezone)` | – | Time zone for `DateTimeInterface` values and the default issue date. | Lines can carry their own period (`LineBuilder::period()`, BG-26). ## Parties Every invoice has a seller (your company) and a buyer (your customer). Further parties are optional: a payee, a tax representative of the seller and a deliver-to party. ### Seller and buyer With `Quittio::invoice()` in Laravel (seller from `config/quittio.php`) and `$quittio->invoice()` (seller from `Quittio::create()`), you set only the buyer. With `InvoiceBuilder::make()`, set both: ```php use Quittio\Core\Builder\InvoiceBuilder; use Quittio\Core\Builder\Party; $builder = InvoiceBuilder::make() ->seller(Party::make('Muster GmbH') ->vatId('DE123456789') ->address('Hauptstraße 1', '12345', 'Musterstadt', 'DE') ->contact('Max Muster', '+49 123 456789', 'rechnung@muster.de') ->electronicAddress('rechnung@muster.de', 'EM')) ->buyer(Party::make('Kunde AG') ->vatId('DE987654321') ->address('Bahnhofstraße 5', '54321', 'Beispielstadt', 'DE') ->electronicAddress('ap@kunde.de', 'EM')); ``` `seller()` and `buyer()` take one of four kinds of argument: | Argument | Effect | |---|---| | `Party::make('Kunde AG')->vatId(…)->address(…)` | A `PartyBuilder` (`Quittio\Core\Builder\Party` starts one). It replaces the party set before. The builder is copied, so it can serve as a template. | | An application model implementing `ProvidesParty`, e.g. `->buyer($customer)` | The model fills a new `PartyBuilder` ([Application models](#application-models)). It replaces the party set before. | | `SellerParty`, `BuyerParty` | A finished party, e.g. `Seller::fromConfig()` in Laravel. It replaces the party set before. | | A callable that receives a `PartyBuilder` | Continues the party set before, also a `SellerParty` or `BuyerParty` (e.g. from `Quittio::invoice()`, `$quittio->invoice()` or `InvoiceBuilder::from()`), so you can change single values. | A callable is the way to change the configured seller, e.g. to add a contact person: ```php use Quittio\Core\Builder\PartyBuilder; use Quittio\Laravel\Facades\Quittio; Quittio::invoice() // seller from config/quittio.php ->seller(fn (PartyBuilder $s) => $s->contact('Erika Muster', '+49 123 4567', 'erika@muster.de')) ->buyer($customer); // ProvidesParty ``` **Replacing the configured seller.** `Quittio::invoice()` and, without Laravel, `$quittio->invoice()` start the builder with the defaults of a seller: the seller of the configuration or the current issuer of the Managed layer. It does this with `applyDefaults(callable $apply)`, and the builder remembers what these defaults set. If you then replace the seller with another one, those values are removed again: the bank account, the small business flag and the other defaults of that seller. Values that you set on the builder yourself stay. A callable keeps the seller and its defaults ([Starting invoices](laravel.md#starting-invoices)). `PartyBuilder` (`Quittio\Core\Builder\PartyBuilder`) has these methods: | Method | Seller | Buyer | Description | |---|---|---|---| | `name(string $name)` | BT-27 | BT-44 | Legal name. Required. | | `tradingName(?string $tradingName)` | BT-28 | BT-45 | Trading name. | | `vatId(?string $vatId)` | BT-31 | BT-48 | VAT identifier with country prefix, e.g. `DE123456789`; uppercased, spaces removed (a Swiss UID number keeps one before its note, "CHE-123.456.789 MWST"). | | `taxNumber(?string $taxNumber)` | BT-32 | – | Tax registration number (German "Steuernummer", the number issued by the local tax office); ignored for the buyer. | | `legalRegistration(?string $value, IdentifierScheme\|RawCode\|string\|null $scheme = null)` | BT-30 | BT-47 | Legal registration identifier, e.g. the commercial register number. | | `additionalLegalInfo(?string $info)` | BT-33 | – | Additional legal information (legal form, share capital …); ignored for the buyer. | | `identifier(string $value, IdentifierScheme\|RawCode\|string\|null $scheme = null)` | BT-29 | BT-46 | Adds a party identifier, e.g. a GLN (Global Location Number) or the customer number at the buyer. The seller keeps all identifiers, the buyer and the payee only the first. CII writes identifiers without scheme as `ram:ID`, with scheme as `ram:GlobalID`. | | `address(?string $line1, ?string $postcode, ?string $city, string $countryCode, ?string $line2 = null, ?string $line3 = null, ?string $subdivision = null)` | BG-5 | BG-8 | Postal address. The country code (ISO 3166-1 alpha-2, e.g. `DE`) is uppercased. Required. | | `postalAddress(Address $address)` | BG-5 | BG-8 | Postal address as object. | | `electronicAddress(string $value, ElectronicAddressScheme\|RawCode\|string $scheme = ElectronicAddressScheme::Email)` | BT-34 | BT-49 | Electronic address, e.g. an e-mail address, with its scheme (EAS code, e.g. `EM` for e-mail). Required by XRechnung and Peppol. Peppol needs a participant identifier, e.g. `9930` (German VAT number) or `0088` (GLN); `EM` is rejected there. | | `contact(?string $name = null, ?string $phone = null, ?string $email = null)` | BG-6 | BG-9 | Contact person, phone and e-mail. XRechnung requires all three for the seller. | | `consumer(bool $consumer = true)` | – | – | Marks the buyer as consumer (B2C). The automatic format choice then renders a PDF without XML, country packs apply their consumer rules, and templates get `buyer.isConsumer`. Not part of the XML; ignored for the seller. | | `fromModel(ProvidesParty $model)` | | | Lets an application model fill the builder ([Application models](#application-models)). | | `PartyBuilder::fromSeller(SellerParty $seller)`, `PartyBuilder::fromBuyer(BuyerParty $buyer)`, `PartyBuilder::fromPayee(PayeeParty $payee)` | | | Builder with the values of an existing party. | | `countryCode(): ?string` | | | Country code of the postal address set so far. | | `buildSeller(): SellerParty`, `buildBuyer(): BuyerParty`, `buildPayee(): PayeeParty` | | | Build the party. A missing name, or a missing address of seller or buyer, throws `InvalidInvoiceData`. | Without a VAT identifier, EN 16931 requires a seller identifier (BT-29) or a legal registration identifier (BT-30); otherwise rendering fails with BR-CO-26. Identifiers and electronic addresses take a scheme code. Use the enum case or pass any other code of the lists as string: - `IdentifierScheme` (identifier schemes of ISO 6523, the ICD codes) has the cases `Siren` (0002), `SwedishOrganisationNumber` (0007), `Siret` (0009), `Duns` (0060), `Gln` (0088), `DutchKvk` (0106), `Gtin` (0160), `DanishCvr` (0184), `DutchOin` (0190), `NorwegianOrganisationNumber` (0192), `LeitwegId` (0204) and `BelgianEnterpriseNumber` (0208). - `ElectronicAddressScheme` (EAS, the electronic address schemes) has `Email` (EM), `Siren` (0002), `SwedishOrganisationNumber` (0007), `Siret` (0009), `Duns` (0060), `Gln` (0088), `DutchKvk` (0106), `DanishCvr` (0184), `DutchOin` (0190), `NorwegianOrganisationNumber` (0192), `LeitwegId` (0204), `BelgianEnterpriseNumber` (0208), `AustrianVatNumber` (9914), `AustrianOrganisationNumber` (9915), `GermanVatNumber` (9930) and `FrenchVatNumber` (9957). ### Payee, tax representative and delivery | Method | BT | Description | |---|---|---| | `payee(PayeeParty\|PartyBuilder\|string\|callable $payee, ?string $identifier = null, ?string $legalRegistration = null, IdentifierScheme\|RawCode\|string\|null $identifierScheme = null, IdentifierScheme\|RawCode\|string\|null $legalRegistrationScheme = null)` | BG-10 (BT-59, BT-60, BT-61) | Payee, if different from the seller (e.g. a factoring company). See below. | | `taxRepresentative(string $name, string $vatId, Address $address)` | BG-11 (BT-62, BT-63, BG-12) | The seller's tax representative. | | `deliverTo(?string $recipientName, ?Address $address = null, ?Identifier $locationId = null)` | BG-13 (BT-70, BG-15, BT-71) | Deliver-to party, address and location identifier. Replaces these three values (also with `null`) and keeps the delivery date. | | `delivery(Delivery $delivery)` | BG-13 | Replaces the whole delivery information, including the delivery date. | `payee()` takes one of these: - the name, optionally with the identifier, the legal registration identifier and their schemes (e.g. `'0088'` for a GLN); - a `PayeeParty`; - a `PartyBuilder`, e.g. `Party::make('Factoring AG')->identifier(…)`; - a callable that receives a `PartyBuilder` (`name()`, `identifier()`, `legalRegistration()`). Like `seller()` and `buyer()`, it continues an earlier payee. Identifiers and schemes as arguments are allowed only next to a name; otherwise `payee()` throws an `InvalidArgumentException`. ```php use Quittio\Core\Data\Identifier; use Quittio\Core\Data\Party\Address; use Quittio\Core\Enums\IdentifierScheme; ->deliverTo('Kunde AG, Lager Nord', Address::make('Industriestraße 9', '54322', 'Beispielstadt', 'DE'), Identifier::of('4000001000005', IdentifierScheme::Gln)) ->taxRepresentative('Steuer Vertretung GmbH', 'DE111111125', new Address(countryCode: 'DE', line1: 'Ring 1', city: 'Berlin', postcode: '10115')) ``` `Address::make(?string $line1, ?string $postcode, ?string $city, string $countryCode)` creates an address with the most common fields. The constructor takes `countryCode`, `line1`, `line2`, `line3`, `city`, `postcode` and `subdivision`. `Identifier::of(string $value, IdentifierScheme|RawCode|string|null $scheme = null)` creates an identifier. ## Lines Lines (BG-25) are the goods and services you invoice. Every invoice needs at least one line. | `InvoiceBuilder` method | Description | |---|---| | `line(string\|LineBuilder\|ProvidesInvoiceLine\|array\|callable\|InvoiceLine $line, netPrice, quantity, unit, vat, description, priceInclVat)` | Adds a line (BG-25), in one of the forms below. | | `lines(iterable $lines)` | Adds several lines. Each entry may be any of the forms, e.g. an array of arrays or an Eloquent collection of order items. | | `updateLine(string $id, ?callable $change = null, netPrice, quantity, priceInclVat, name, description)` | Changes an existing line ([Changing existing data](#changing-existing-data)). | | `removeLine(string $id)` | Removes an existing line by its identifier (BT-126) ([Changing existing data](#changing-existing-data)). | A line can be given in these forms. Use the first one that fits: | Form | Use it when | Example | |---|---|---| | The name with named values | the line needs only price, quantity, unit, VAT or description (the usual case) | `->line('Web development', netPrice: '95.00', quantity: 24, unit: UnitCode::Hour)` | | `Line::make()` (`Quittio\Core\Builder\Line`) | the line needs more: item number, line allowance or charge, list price, base quantity, period, sub lines, line group. It takes the same named values and returns the `LineBuilder` for the other methods. | `->line(Line::make('Web development', netPrice: '95.00')->sellerId('WD-1')->allowance(percent: '10', reason: 'Framework agreement'))` | | An application model implementing `ProvidesInvoiceLine` ([Application models](#application-models)) | the lines come from your models | `->lines($order->items)` | | An array whose keys are methods of the `LineBuilder` | the lines come as data, e.g. database rows or a JSON request | `->lines([['name' => 'Hosting', 'quantity' => [1, UnitCode::Month], 'netPrice' => '49.00']])` | | A callable that receives a new `LineBuilder` | rarely; the forms above cover the same | `->line(fn (LineBuilder $l) => $l->name('Travel expenses')->netPrice('120.00'))` | | A finished `InvoiceLine`, taken as it is | you copy a line of existing data | `->line($invoice->lines[0])` | The named arguments of `line()` and `Line::make()` are: | Argument | Meaning | |---|---| | `netPrice` | The price without VAT (BT-146). | | `priceInclVat` | The price including VAT ([Gross price mode](#gross-price-mode)). | | `quantity` | Default 1. | | `unit` | Default `UnitCode::Unit` (C62). | | `vat` | A tax preset or a category without rate. Default: the [default VAT](#default-vat) of the invoice. | | `description` | The item description. | The named arguments are allowed only together with a name; with another form, `line()` throws an `InvalidArgumentException`. A string is always the name of the line, never a callable. A `LineBuilder` is copied when it is added, so the same builder can serve as a template for further lines. ### Lines as arrays In an array, each key names a method of the `LineBuilder` and the value is its argument. The keys are `LineBuilder::ARRAY_KEYS`: `id`, `name`, `description`, `note`, `quantity`, `unit`, `netPrice`, `listPrice`, `priceInclVat`, `vat`, `period`, `allowance`, `charge`, `sellerId`, `buyerId`, `standardId`, `classification`, `originCountry`, `attribute`, `orderLineReference`, `buyerAccountingReference`, `objectId`, `group`, `highlight` and `showGrossPrice`. - A method with several arguments takes an array value, as list or by name: `'quantity' => [4, UnitCode::Hour]`, `'allowance' => ['percent' => '10', 'reason' => 'Early bird']`. - Null values are skipped, so database rows with empty columns can be passed. - An unknown key throws an `InvalidArgumentException`. - `Line::fromArray($array)` and `LineBuilder::fill($array)` do the same for a single builder. ```php use Quittio\Core\Builder\Line; use Quittio\Core\Enums\UnitCode; use Quittio\Country\DE\Tax\VatPreset; $builder->lines([ Line::make('Web development', netPrice: '95.00', quantity: 24, unit: UnitCode::Hour), // in a list: Line::make() ['name' => 'Hosting', 'quantity' => [1, UnitCode::Month], 'netPrice' => '49.00'], ['name' => 'Book', 'netPrice' => '39.00', 'vat' => VatPreset::Reduced], ]); ``` ### Line identifiers Every line has an identifier (BT-126). Partial cancellations, `updateLine()` and `removeLine()` refer to lines by it. - A line without `id()` gets its position (1, 2, 3 …). Identifiers that existing lines or other lines' `id()` already use are skipped, so identifiers stay unique after `from()` and `removeLine()`. Example: lines `A`, `B` with `id('1')` and `C` get `2`, `1` and `3`. - Sub lines get `{parent}.{n}`, e.g. `2.1`. - An identifier used twice, also by a sub line, makes `build()` throw `InvalidInvoiceData`. - Data from other sources (JSON, incoming invoices) gets the warning `QUITTIO-LINE-ID-DUPLICATE` instead, because EN 16931 does not require unique identifiers. ### LineBuilder `Quittio\Core\Builder\LineBuilder` is the builder that `Line::make()` returns: | Method | BT | Description | |---|---|---| | `id(string $id)` | BT-126 | Line identifier; default the position ([Line identifiers](#line-identifiers)). | | `name(string $name)` | BT-153 | Item name. Required. | | `description(?string $description)` | BT-154 | Item description. Printed as plain text; with the option `markdown` (Laravel `pdf.markdown`) as Markdown ([Templates](templates.md)). | | `note(?string $note)` | BT-127 | Line note. | | `quantity(BigDecimal\|int\|string $quantity, UnitCode\|RawCode\|string\|null $unit = null)` | BT-129, BT-130 | Invoiced quantity and optionally the unit; default 1. Negative quantities for returns and discounts. | | `unit(UnitCode\|RawCode\|string $unit)` | BT-130 | Unit (UN/ECE Recommendation 20/21), default `UnitCode::Unit` (C62). | | `netPrice(BigDecimal\|int\|string $price, BigDecimal\|int\|string\|null $baseQuantity = null, UnitCode\|RawCode\|string\|null $baseQuantityUnit = null)` | BT-146, BT-149, BT-150 | Net price per base quantity; the base quantity unit defaults to the line unit. Each call replaces the base quantity. | | `listPrice(BigDecimal\|int\|string $grossPrice, BigDecimal\|int\|string\|null $discount = null)` | BT-148, BT-147 | List (gross) price before price discount, and the discount per unit. Without `netPrice()` the net price is list price minus discount. | | `priceInclVat(BigDecimal\|int\|string $price)` | – | Price including VAT ([Gross price mode](#gross-price-mode)); the calculator derives the net price. | | `vat(TaxPreset\|VatCategory $presetOrCategory, BigDecimal\|int\|string\|null $rate = null, ?string $exemptionReason = null, VatExemptionReasonCode\|RawCode\|string\|null $exemptionReasonCode = null)` | BG-30 (BT-151, BT-152) | VAT treatment: a tax preset of a country pack, or category, rate and exemption reason ([VAT](#vat)). Without it, the line takes the [default VAT](#default-vat) of the invoice. | | `period(Date\|string\|null $start, Date\|string\|null $end = null)` | BG-26 (BT-134, BT-135) | Line period. | | `allowance(?string $amount = null, ?string $percent = null, ?string $reason = null, AllowanceReasonCode\|RawCode\|string\|null $reasonCode = null, ?string $baseAmount = null)` | BG-27 | Line allowance: amount or percentage; repeatable ([Line allowances and charges](#line-allowances-and-charges)). | | `charge(?string $amount = null, ?string $percent = null, ?string $reason = null, ChargeReasonCode\|RawCode\|string\|null $reasonCode = null, ?string $baseAmount = null)` | BG-28 | Line charge: amount or percentage; repeatable. | | `sellerId(?string $id)` | BT-155 | Seller's item number. | | `buyerId(?string $id)` | BT-156 | Buyer's item number. | | `standardId(string $value, IdentifierScheme\|RawCode\|string $scheme = IdentifierScheme::Gtin)` | BT-157 | Standard item identifier, default scheme GTIN (0160, the global trade item number). | | `classification(string $code, ItemClassificationScheme\|RawCode\|string $scheme, ?string $version = null)` | BT-158 | Item classification with list identifier and version; repeatable. | | `originCountry(?string $country)` | BT-159 | Country of origin (uppercased). | | `attribute(string $name, string $value)` | BG-32 (BT-160, BT-161) | Item attribute; repeatable. | | `orderLineReference(?string $reference)` | BT-132 | Line of the purchase order. | | `buyerAccountingReference(?string $reference)` | BT-133 | Buyer's accounting reference of the line. | | `objectId(string $value, string\|RawCode\|null $scheme = null)` | BT-128 | Invoiced object identifier of the line, with scheme. | | `subLine(string\|LineBuilder\|ProvidesInvoiceLine\|array\|callable $line, netPrice, quantity, unit, vat, description, priceInclVat)` | – | Adds a sub line, in the forms of `line()` except `InvoiceLine` ([Sub lines](#sub-lines)). | | `reference(DocumentReference $reference)` | – | Line reference to an order, contract, despatch or receiving advice or another document (profile EXTENDED, [Extensions](#extensions)). | | `extended(LineExtendedData $extended)` | – | Line data of profile EXTENDED ([Extensions](#extensions)). | | `group(string $groupId)` | – | Assigns the line to a line group of the PDF (`InvoiceBuilder::group()`, [Presentation and metadata](#presentation-and-metadata)). | | `highlight(bool $highlight = true)` | – | Highlights the line in the PDF (the default templates shade it and mark it in the secondary colour). | | `showGrossPrice(?bool $show = true)` | – | Prints the price including VAT below the net unit price of this line (`false`: not), whatever the presentation's `showGrossPrices` says; `null` follows the presentation. Only for lines with `priceInclVat()`. | | `fromModel(ProvidesInvoiceLine $model)` | – | Lets an application model fill the builder. | | `fill(array $values)` | – | Calls the methods named by the keys of the array ([Lines as arrays](#lines-as-arrays)). | | `build(string $currency, string $defaultId, ?string $locale = null, ?LineBuilder $vatDefault = null): InvoiceLine` | – | Builds the line; called by `InvoiceBuilder`, which passes the [default VAT](#default-vat) as `$vatDefault`. Use it to create an `InvoiceLine` on its own, e.g. `(new LineBuilder)->name('…')->…->build('EUR', '1')`. | `UnitCode` has the cases `Unit` (C62), `Piece` (H87), `Set` (SET), `Pair` (PR), `Dozen` (DZN), `LumpSum` (LS), `Second` (SEC), `Minute` (MIN), `Hour` (HUR), `Day` (DAY), `Week` (WEE), `Month` (MON), `Quarter` (QAN), `Year` (ANN), `Gram` (GRM), `Kilogram` (KGM), `Tonne` (TNE), `Millimetre` (MMT), `Centimetre` (CMT), `Metre` (MTR), `Kilometre` (KMT), `SquareMetre` (MTK), `CubicMetre` (MTQ), `Millilitre` (MLT), `Litre` (LTR), `KilowattHour` (KWH), `Kilowatt` (KWT), `Percent` (P1), `ServiceUnit` (E48), `Package` (XPK), `Box` (XBX) and `Pallet` (XPX). Every other code of the list can be passed as string. `ItemClassificationScheme` (code list UNTDID 7143) has `HarmonisedSystem` (HS), `Unspsc` (TST), `CustomsArticleNumber` (CV), `NationalProductGroup` (GN), `Isbn` (IB), `ProductServiceId` (MP) and `MutuallyDefined` (ZZZ). ### Prices Most lines need only `netPrice`. A price per base quantity (e.g. per 1000 pieces) or a list price with a discount needs `Line::make()`: ```php use Quittio\Core\Builder\Line; use Quittio\Core\Enums\UnitCode; use Quittio\Country\DE\Tax\VatPreset; ->line(Line::make('Paper A4', quantity: 5000, unit: UnitCode::Piece, vat: VatPreset::Standard) ->netPrice('12.50', baseQuantity: 1000)) // 12.50 per 1000 sheets: 62.50 ->line(Line::make('Monitor', quantity: 2, vat: VatPreset::Standard) ->listPrice('299.00', discount: '30.00')) // net price 269.00 ``` The line amount before allowances and charges is round2(quantity × net price / base quantity). Prices must not be negative (BR-27); returns and discounts use a negative quantity. ## VAT Every line has a VAT category (BT-151) and, except for category O (not subject to VAT), a rate (BT-152). Usually you do not set them on every line. Lines without `vat()` take the [default VAT](#default-vat) of the invoice; in Laravel that is 19 % for a German seller. Set the VAT of a line when it differs from the default. Use a tax preset of a country pack or the category: ```php use Quittio\Core\Enums\VatCategory; use Quittio\Core\Enums\VatExemptionReasonCode; use Quittio\Country\DE\Tax\VatPreset; ->vat(VatPreset::Standard) // preset of the German pack ->vat(VatCategory::StandardRate, '19') ->vat(VatCategory::ReverseCharge, '0', 'Reverse charge', VatExemptionReasonCode::ReverseCharge) ->vat(VatCategory::Exempt, '0', 'Exempt according to Art. 132 VAT Directive', 'VATEX-EU-132') ->vat(VatCategory::NotSubjectToVat) // no rate ``` `vat()` is a method of the `LineBuilder`; `line()` and `Line::make()` take a preset or a category without rate as named argument `vat:`. A tax preset is a ready-made VAT treatment of a country pack: category, rate and, for exemptions, the reason text and code, e.g. `VatPreset::Reduced` for the German 7 % rate ([Tax presets](#tax-presets)). Reverse charge (category AE) means that the buyer, not the seller, owes the VAT. With a preset, category, rate, exemption reason and code come from the preset, and the other parameters are ignored. The preset key is kept on the line (`LineVat::$presetKey`). The exemption text of a preset is resolved in the locale of the invoice (`locale()`) when the line is built; the German presets use German without a locale. ### Default VAT Lines and sub lines without `vat()` take the default VAT of the invoice when it is built. The default is, in this order: 1. `defaultVat()` of the builder, with the arguments of `LineBuilder::vat()`, e.g. `->defaultVat(VatPreset::Reduced)` for a bookshop; 2. otherwise the application default, set once with `InvoiceBuilder::useDefaultVat(callable|TaxPreset|null $default)`. It is a preset, or a callable that receives the seller's country code (BT-40) and whether the invoice is flagged as small business invoice (`Meta::FLAG_SMALL_BUSINESS`), and returns a preset or `null`. `Quittio\Core\Tax\CountryDefaultVat` is such a callable: `new CountryDefaultVat(CountryRegistry $countries, ?TaxPreset $preset = null)`. - For normal invoices it returns `$preset`, otherwise the standard preset of the seller's country pack (`CountryDefaults::$vatPreset`, Germany `de.standard`). - For small business invoices it returns the small business preset of the pack (`CountryDefaults::$smallBusinessVatPreset`, Germany `de.small_business`), otherwise `$preset`. A small business ("Kleinunternehmer" in Germany) charges no VAT ([German terms](concepts.md#german-terms)). The Laravel integration installs it with the preset of `quittio.defaults.vat` ([Configuration](configuration.md#defaults)). So in Laravel, lines without `vat()` get 19 % for a German seller. Without Laravel, install it yourself: ```php use Quittio\Core\Builder\InvoiceBuilder; use Quittio\Core\Enums\UnitCode; use Quittio\Core\Tax\CountryDefaultVat; use Quittio\Country\DE\Tax\VatPreset; // Without Laravel, once at start-up InvoiceBuilder::useDefaultVat(new CountryDefaultVat($quittio->countries())); // or a preset: VatPreset::Standard $invoice = $quittio->invoice() // ... ->line('Web development', netPrice: '95.00', quantity: 24, unit: UnitCode::Hour) // 19 % ->line('Book', netPrice: '39.00', vat: VatPreset::Reduced) // 7 % ->build(); ``` The default only fills in what a line leaves open: the built data and the XML carry the VAT of every line, as EN 16931 requires. Without a default, a line without VAT makes `build()` fail (`InvalidInvoiceData`, BG-30). `useDefaultVat(null)` removes the application default. Documents (`DocumentBuilder`) use the same defaults and have `defaultVat()` as well. ### Categories | `VatCategory` | Code | Rate | VAT | Exemption reason (BT-120/BT-121) | Further requirements | |---|---|---|---|---|---| | `StandardRate` | S | greater than 0 (BR-S-05) | rate × taxable amount | not allowed (BR-S-10) | Seller VAT identifier, tax number or tax representative (BR-S-02). One VAT breakdown per rate. | | `ZeroRated` | Z | 0 (BR-Z-05) | 0 | not allowed (BR-Z-10) | As S (BR-Z-02). | | `Exempt` | E | 0 (BR-E-05) | 0 | required (BR-E-10) | As S (BR-E-02). | | `ReverseCharge` | AE | 0 (BR-AE-05) | 0 | required (BR-AE-10), e.g. `VATEX-EU-AE` | As S, and the buyer VAT identifier or legal registration identifier (BR-AE-02). | | `IntraCommunitySupply` | K | 0 (BR-IC-05) | 0 | required (BR-IC-10), e.g. `VATEX-EU-IC` | Seller VAT identifier or tax representative, and buyer VAT identifier (BR-IC-02); delivery date or invoicing period (BR-IC-11); deliver-to country (BR-IC-12). | | `Export` | G | 0 (BR-G-05) | 0 | required (BR-G-10), e.g. `VATEX-EU-G` | Seller VAT identifier or tax representative (BR-G-02). | | `NotSubjectToVat` | O | none (BR-O-05) | 0 | required (BR-O-10), e.g. `VATEX-EU-O` | No VAT identifier of seller, tax representative or buyer (BR-O-02); no other category in the invoice (BR-O-11). | | `CanaryIslands` | L | 0 or greater (BR-AF-05) | rate × taxable amount (BR-AF-09) | not allowed (BR-AF-10) | IGIC (Canary Islands). As S (BR-AF-02). One VAT breakdown per rate. The official CII validation rejects the rate 0, UBL accepts it (warning `QUITTIO-IGIC-ZERO-RATE-CII`). | | `CeutaMelilla` | M | 0 or greater (BR-AG-05) | rate × taxable amount (BR-AG-09) | not allowed (BR-AG-10) | IPSI (Ceuta and Melilla). As S (BR-AG-02). One VAT breakdown per rate. | | `TransferredVatItaly` | B | as given | rate × taxable amount | – | Split payment (Italy): only in a domestic Italian invoice, every country code (seller, buyer, tax representative, deliver-to, item origin) is `IT` (BR-B-01); no category S in the same invoice (BR-B-02). | - Categories Z, E, AE, K, G and O allow exactly one VAT breakdown each (BR-Z-01 …); S, L and M one per rate. - The calculator calculates VAT 0 for Z, E, AE, K, G and O, whatever rate is given. It writes the rate 0 to the VAT breakdown of a group whose lines have no rate (category O: no rate). The validation still requires the rate 0 on the lines (BR-Z-05 …). - The rules are part of the [validation](validation.md) (level L3). `VatCategory::requiresRate()`, `isZeroTax()` and `requiresExemptionReason()` expose the same properties. `VatExemptionReasonCode` (code list VATEX) has `ReverseCharge` (VATEX-EU-AE), `IntraCommunitySupply` (VATEX-EU-IC), `Export` (VATEX-EU-G), `NotSubjectToVat` (VATEX-EU-O), `TravelAgents` (VATEX-EU-D), `SecondHandGoods` (VATEX-EU-F), `WorksOfArt` (VATEX-EU-I), `CollectorsItems` (VATEX-EU-J), `Article79c` (VATEX-EU-79-C), `Article132` (VATEX-EU-132), `Article143` (VATEX-EU-143), `Article148` (VATEX-EU-148), `Article151` (VATEX-EU-151) and `Article309` (VATEX-EU-309). Other codes of the list can be passed as strings. ### Exemption reasons in the VAT breakdown You give the exemption reason per line, but the XML carries it per VAT breakdown entry (one per category and rate). The calculator therefore collects the reasons of the lines of each group, for the categories that require one (E, AE, K, G, O): - Different texts are joined with "; " in the order of the lines, so that no legally required note is lost. - A code is kept when all lines of the group have the same code. Otherwise it is left out, and the validation reports `QUITTIO-EXEMPTION-CONFLICT`. - The exemption reason of a document level allowance or charge is used only if no line of its group provides one, e.g. for an exempt charge on an otherwise standard rated invoice. ### Tax presets A tax preset implements `Quittio\Core\Tax\TaxPreset` (`key()`, `category()`, `rate()`, `exemptionReasonCode()`, `exemptionReason(?string $locale = null)`). Country packs provide their presets as `TaxPresetCollection` (`$pack->taxPresets()`, with `get(string $key)`, `has()`, `add()`, `count()` and iteration), so a stored preset key can be resolved again: ```php $preset = $quittio->countries()->get('DE')?->taxPresets()->get('de.standard'); ``` The German presets (`VatPreset::Standard`, `Reduced`, `SmallBusiness`, `ReverseChargeEu`, `VatPreset::exempt('§ 4 Nr. 14 UStG')` …) are listed in [Tax presets](country-packs.md#tax-presets); [Presets of your pack](country-packs.md#presets-of-your-pack) shows how a pack provides its own. Create your own presets with `CustomTaxPreset::make(string $key, VatCategory $category, BigDecimal|int|string|null $rate = null, VatExemptionReasonCode|RawCode|string|null $code = null, array|string|null $reason = null)`. Give the reason as text, or as an array of texts per locale (fallback `en`): ```php use Quittio\Core\Enums\VatCategory; use Quittio\Core\Tax\CustomTaxPreset; $exempt = CustomTaxPreset::make('acme.exempt_132', VatCategory::Exempt, '0', 'VATEX-EU-132', [ 'de' => 'Steuerfrei nach Art. 132 MwStSystRL', 'en' => 'Exempt according to Art. 132 VAT Directive', ]); ->line('Course', netPrice: '300.00', vat: $exempt) ``` ## Payment Payment data tells the buyer how and when to pay. It has three parts: the payment instructions (payment means and bank account), the payment terms (due date and cash discount) and amounts already paid. In Laravel, `Quittio::invoice()` already adds a SEPA credit transfer to the first bank account with an IBAN in `config/quittio.php`, without Laravel `$quittio->invoice()` to the configured `bank_account`, so most invoices only add payment terms. ### Payment instructions | Method | BT | Description | |---|---|---| | `payment(PaymentMeansCode\|RawCode\|string $means, ?string $iban = null, ?string $bic = null, ?string $accountName = null, ?string $remittanceInformation = null, ?string $meansText = null)` | BG-16 (BT-81, BT-82, BT-83), BG-17 | Payment means, optionally with one account (IBAN uppercased, spaces removed), the remittance information (the payment reference the buyer should state) and a text for the means. | | `creditTransfer(string $accountId, ?string $bic = null, ?string $accountName = null)` | BG-17 (BT-84, BT-86, BT-85) | Adds a further account. CII writes an IBAN as `IBANID` and any other account identifier as `ProprietaryID`. Without payment instructions, it starts them with `SepaCreditTransfer` (58). | | `paymentCard(string $lastDigits, ?string $holderName = null)` | BG-18 (BT-87, BT-88) | Card data: only the last 4 to 6 digits (more throw an `InvalidArgumentException`). Without payment instructions, it starts them with `BankCard` (48). | | `directDebit(?string $mandateReference, ?string $creditorId = null, ?string $debitedIban = null)` | BG-19 (BT-89, BT-90, BT-91) | SEPA direct debit: mandate reference, creditor identifier, debited account. Without payment instructions, it starts them with `SepaDirectDebit` (59). | A second call of `payment()` replaces the payment instructions: - An account given in the call replaces all accounts. - Without an account, existing accounts are kept for the credit transfer codes 30, 42 and 58 (e.g. the seller's default account set by `Quittio::invoice()`), card data for 48, 54 and 55, and direct debit data for 49 and 59. Everything else is dropped. - The remittance information is kept unless a new one is given. `creditTransfer()`, `paymentCard()` and `directDebit()` add to existing instructions without changing the means code, so call `payment()` with the means first. ```php use Quittio\Core\Enums\PaymentMeansCode; // SEPA credit transfer with two accounts ->payment(PaymentMeansCode::SepaCreditTransfer, iban: 'DE02 1203 0000 0000 2020 51', bic: 'BYLADEM1001', accountName: 'Muster GmbH', remittanceInformation: 'RE-2026-0042') ->creditTransfer('AT61 1904 3002 3457 3201', 'BKAUATWW') // SEPA direct debit (replaces the seller's default account set by Quittio::invoice()) ->payment(PaymentMeansCode::SepaDirectDebit, remittanceInformation: 'RE-2026-0042') ->directDebit('MANDATE-2026-17', creditorId: 'DE98ZZZ09999999999', debitedIban: 'DE02120300000000202051') // Paid by credit card ->payment(PaymentMeansCode::CreditCard, meansText: 'Paid online') ->paymentCard('4242', 'Max Muster') ``` The payment means codes come from the code list UNTDID 4461: | `PaymentMeansCode` | Code | Data | |---|---|---| | `NotDefined` | 1 | – | | `Cash` | 10 | – | | `Cheque` | 20 | – | | `CreditTransfer` | 30 | account required (BR-61) | | `DebitTransfer` | 31 | – | | `PaymentToBankAccount` | 42 | account | | `BankCard` | 48 | card | | `DirectDebit` | 49 | direct debit | | `CreditCard` | 54 | card | | `DebitCard` | 55 | card | | `StandingAgreement` | 57 | – | | `SepaCreditTransfer` | 58 | account required (BR-61) | | `SepaDirectDebit` | 59 | direct debit; XRechnung requires creditor identifier and debited account (BR-DE-30, BR-DE-31) | | `OnlinePaymentService` | 68 | – | | `Clearing` | 97 | – | | `MutuallyDefined` | ZZZ | – | XRechnung requires payment instructions (BR-DE-1). Profile EXTENDED can carry further payment instructions (`ExtendedData::$additionalPaymentInstructions`, [Extensions](#extensions)). ### Payment terms Set the payment terms (BT-20) with these methods. Each continues the terms set before, also those of `InvoiceBuilder::from()` or of the seller's defaults: | Method | Description | |---|---| | `dueInDays(int $days)` | Payment target: the calculator sets the due date (BT-9) to issue date + days, unless `dueDate()` is set. | | `cashDiscount(int $days, string $percent, ?string $baseAmount = null)` | Cash discount ("Skonto") for payment within `$days` days after the issue date, optionally on a base amount. Repeatable for several tiers. The percentage is rounded to two decimals. | | `lateFee(?int $days = null, ?string $percent = null, ?string $text = null)` | Late payment terms. | | `paymentTerms(PaymentTerms\|string\|callable $terms)` | A text or a `PaymentTerms` object replaces the earlier terms, e.g. to start over. A callable receives the `PaymentTermsBuilder` (`text()` and the three methods above) and continues them. | ```php ->dueInDays(30) ->cashDiscount(days: 10, percent: '3.00') ->cashDiscount(days: 20, percent: '2.00', baseAmount: '1000.00') ``` `InvoiceBuilder::from($draft)->cashDiscount(days: 7, percent: '2.00')` adds a cash discount to the terms of the draft. A cash discount is an agreed reduction of the price, so it must be part of the XML, not only of the PDF. Quittio therefore writes the terms into the text BT-20, generated in the language of the rendering run: - Without `text()`, `dueInDays()` adds "Payable within 30 days without deduction." (German: "Zahlbar innerhalb von 30 Tagen ohne Abzug."). - Each cash discount adds a line such as "3.00 % cash discount for payment within 10 days (until 2026-10-13)." (German: "3 % Skonto bei Zahlung innerhalb von 10 Tagen (bis 13.10.2026)."). The late fee text follows. - XRechnung uses its structured notation instead (BR-DE-18): the texts first, then one line `#SKONTO#TAGE=10#PROZENT=3.00#` per cash discount (German for cash discount, days and percent), each closed by a line break. A base amount adds `BASISBETRAG=1000.00#`. - Profile EXTENDED additionally writes the cash discounts (one payment terms group per tier) and the late fee days and percentage as structured CII elements. ### Prepaid amounts and rounding | Method | BT | Description | |---|---|---| | `prepaid(BigDecimal\|int\|string $amount)` | BT-113 | Amount already paid, e.g. received advance payments; replaces an earlier value. | | `addPrepaid(BigDecimal\|int\|string $amount)` | BT-113 | Adds to the amount already paid, e.g. one of several advance payments. | | `rounding(BigDecimal\|int\|string $amount)` | BT-114 | Rounding amount, e.g. cash rounding to 0.05. Never use it to fix wrong totals. | The amount due is BT-115 = gross total − BT-113 + BT-114. For final invoices, the German pack offers `deductAdvance($advanceInvoice)`: it references the advance invoice and adds its gross amount to BT-113 ([Builder macros](country-packs.md#builder-macros)). ## References References link the invoice to other documents, e.g. the buyer's purchase order or a contract. All of them are optional in EN 16931. The one you need most often is the buyer reference (BT-10): XRechnung requires it, and for German public buyers it holds the Leitweg-ID, the routing ID of the authority ([German terms](concepts.md#german-terms)). | Method | BT | Description | |---|---|---| | `buyerReference(?string $reference)` | BT-10 | Buyer reference; required by XRechnung, for German public buyers the Leitweg-ID. | | `projectReference(string $id, ?string $name = null)` | BT-11 | Project reference. CII requires a name and writes the identifier when none is given. | | `contractReference(?string $reference)` | BT-12 | Contract reference. | | `purchaseOrderReference(?string $reference)` | BT-13 | Purchase order reference of the buyer. | | `salesOrderReference(?string $reference)` | BT-14 | Sales order reference of the seller. | | `receivingAdviceReference(?string $reference)` | BT-15 | Receiving advice reference. | | `despatchAdviceReference(?string $reference)` | BT-16 | Despatch advice (delivery note) reference. | | `tenderReference(?string $reference)` | BT-17 | Tender or lot reference. | | `invoicedObject(string $value, string\|RawCode\|null $scheme = null)` | BT-18 | Invoiced object identifier (e.g. a meter or subscription), with the scheme from the code list UNTDID 1153, written as `ReferenceTypeCode` (CII) or `schemeID` (UBL). | | `buyerAccountingReference(?string $reference)` | BT-19 | Buyer's accounting reference (cost centre). | | `precedingInvoice(string $number, Date\|DateTimeInterface\|string\|null $issueDate = null)` | BG-3 (BT-25, BT-26) | Reference to a preceding invoice; repeatable. CII carries only the first reference, UBL all of them. | Lines have their own references (`orderLineReference()`, `buyerAccountingReference()`, `objectId()`, see [LineBuilder](#linebuilder)). ## Notes `note(string $content, NoteSubjectCode|RawCode|string|null $subject = null)` adds an invoice note (BG-1): a free text (BT-22) with an optional subject code (BT-21). Call it several times for several notes. UBL writes a note with subject code as `#CODE#text`. | `NoteSubjectCode` | Code | |---|---| | `GeneralInformation` | AAI | | `PriceConditions` | AAK | | `LegalInformation` | ABL | | `Introduction` | ACY | | `PaymentDetail` | PMD | | `PaymentInformation` | PMT | | `RegulatoryInformation` | REG | | `SupplierRemarks` | SUR | | `TaxDeclaration` | TXD | Cancellations take over the notes with subject `REG` and `TXD` of the original ([Cancellations and corrections](#cancellations-and-corrections)). ## Supporting documents `attachment(string $id, ?string $content = null, MimeType|string|null $mimeType = null, ?string $filename = null, ?string $description = null, ?string $externalUri = null)` adds a supporting document (BG-24), e.g. a timesheet. It is repeatable. A supporting document is either embedded or a link: - Embedded: `$content` are the raw bytes; the XML carries them base64 encoded. An embedded document requires MIME type and file name (`InvalidArgumentException` otherwise). - Link: `$externalUri`. ```php use Quittio\Core\Enums\MimeType; ->attachment('Timesheet-09', file_get_contents($path), MimeType::Pdf, 'timesheet-2026-09.pdf', 'Timesheet September') ->attachment('Contract', externalUri: 'https://example.com/contracts/4711.pdf', description: 'Framework contract') ``` - `MimeType` has `Pdf` (application/pdf), `Png` (image/png), `Jpeg` (image/jpeg), `Csv` (text/csv), `Xlsx` (application/vnd.openxmlformats-officedocument.spreadsheetml.sheet) and `Ods` (application/vnd.oasis.opendocument.spreadsheet), the MIME codes EN 16931 allows. `Xml` (application/xml) is allowed only in the profile `xrechnung-extension` (BR-DEX-01); other profiles report it with `BR-CL-24`. Another string fails with a `ValueError`. - Supporting documents are part of the XML from profile EN 16931 upwards, not in the profiles MINIMUM, BASIC WL and BASIC. They are not separate files in the PDF ([Formats and profiles](formats.md#embedded-files)). - XRechnung requires unique file names (BR-DE-22). ## Presentation and metadata These methods set the design of the PDF and HTML, the language of the invoice and data for templates and country packs. | Method | Description | |---|---| | `presentation(Presentation\|array\|callable $presentation)` | Design of this invoice in PDF and HTML: logo, colours, font, texts, footer, line groups, gross prices, payment QR code, watermark, paper, labels, title … A `Presentation` replaces it, an array changes single properties (`['introText' => '…']`), a callable receives the current `Presentation` (or an empty one) and returns the new one. See [Templates and design](templates.md). | | `group(string $id, string $title, bool $showSubtotal = true)` | Defines a line group of the PDF; lines join it with `LineBuilder::group($id)`. | | `locale(string $locale)` | Language of the invoice: labels, generated texts, exemption texts of presets. Rendering uses the locale of the call, then this one, then the configured locale, then the country pack default. | | `timezone(string $timezone)` | Time zone for dates (see [Dates](#dates)). | | `custom(string $key, mixed $value)` | Free data for templates (view model key `meta.custom`). | | `source(string $source)` | Origin of the data, e.g. `shop` (view model key `meta.source`). | | `flag(string $flag, bool $enabled = true)` | Sets or removes a flag that country packs evaluate, e.g. `Meta::FLAG_SMALL_BUSINESS` (`small_business`) or the German `Quittio\Country\DE\Support\Flags::SMALL_AMOUNT` (`de.small_amount`, see [Meta flags](country-packs.md#meta-flags)). | ```php use Quittio\Core\Builder\Line; use Quittio\Country\DE\Tax\VatPreset; ->presentation(['introText' => 'Thank you for your order.', 'showGrossPrices' => true]) ->group('hardware', 'Hardware') ->line(Line::make('Notebook', netPrice: '1200.00', vat: VatPreset::Standard)->group('hardware')) // group(): Line::make() ``` Quittio sets some flags itself; do not set them: `declared_amounts`, `declared_amounts_recalculated`, `cancellation_vat_aligned` and those with the prefixes `amounts_fingerprint:` and `declared_vat_in_tax_currency:` ([Declared amounts](#declared-amounts)). They are the stored format of the declared amounts: Quittio reads them in any order and writes them after the other flags in a fixed order, the fingerprint last. ## Application models Your own models can fill the builder, so a customer becomes the buyer and order items become lines. Implement one of three contracts in `Quittio\Core\Contracts`: | Contract | Method | Used by | |---|---|---| | `ProvidesParty` | `fillParty(PartyBuilder $party): void` | `InvoiceBuilder::buyer($model)` and `seller($model)`, `PartyBuilder::fromModel($model)`, e.g. a customer or user as buyer | | `ProvidesInvoiceLine` | `fillLine(LineBuilder $line): void` | `InvoiceBuilder::line($model)`, `lines($models)`, `LineBuilder::fromModel($model)` | | `ProvidesInvoiceData` | `toInvoiceData(): InvoiceData` | `Quittio::make($model)` (core and Laravel), `Invoice::draftFor($model)` and `HasInvoices::draftInvoice()` in the [Managed layer](managed.md) | ```php use Quittio\Core\Builder\LineBuilder; use Quittio\Core\Contracts\ProvidesInvoiceData; use Quittio\Core\Contracts\ProvidesInvoiceLine; use Quittio\Core\Data\InvoiceData; use Quittio\Core\Enums\UnitCode; use Quittio\Country\DE\Tax\VatPreset; use Quittio\Laravel\Facades\Quittio; class OrderItem extends Model implements ProvidesInvoiceLine { public function fillLine(LineBuilder $line): void { $line->id((string) $this->position) ->name($this->product_name) ->sellerId($this->sku) ->quantity((string) $this->quantity, UnitCode::Piece) ->netPrice($this->unit_price) // decimal string from the database ->vat(VatPreset::from($this->tax_preset)); // stored preset key, e.g. "de.standard" } } class Order extends Model implements ProvidesInvoiceData { public function toInvoiceData(): InvoiceData { return Quittio::invoice() ->number($this->invoice_number) ->buyer($this->customer) // ProvidesParty ->lines($this->items) ->build(); } } ``` `fillParty()` and `fillLine()` may set any value. `buyer($model)`, `seller($model)`, `line($model)` and `lines($models)` pass them a fresh builder. `PartyBuilder::fromModel()` and `LineBuilder::fromModel()` pass the builder they are called on, e.g. the builder of the party set before inside a `buyer()` callable. The invoice keeps a copy, so changing the model later does not change invoices that were already built. Store amounts as decimal strings (database `decimal` columns), not as floats. ## Currency and exchange rate Invoices are in euros by default. Set another invoice currency with `currency()`; all amounts of the invoice are then in that currency. If the VAT must also be stated in another currency, the VAT accounting currency (BT-6), set it with `taxCurrency()` together with the exchange rate. | Method | BT | Description | |---|---|---| | `currency(string $currency)` | BT-5 | Invoice currency (ISO 4217, uppercased), default `EUR`. All amounts of the invoice are in this currency. | | `taxCurrency(string $currency, BigDecimal\|int\|string\|null $exchangeRate = null, Date\|DateTimeInterface\|string\|null $rateDate = null)` | BT-6 | VAT accounting currency; with a rate, also sets `exchangeRate()`. | | `exchangeRate(BigDecimal\|int\|string $rate, Date\|DateTimeInterface\|string\|null $date = null)` | – | Units of the VAT accounting currency per unit of the invoice currency. | ```php ->currency('USD') ->taxCurrency('EUR', exchangeRate: '0.9234', rateDate: '2026-10-02') ``` The calculator then sets the VAT total in accounting currency: BT-111 = round2(BT-110 × rate), where BT-110 is the VAT total in the invoice currency. - Without a rate, BT-111 stays empty (except for a VAT total of zero) and the validation fails with BR-53. - BT-6 is written only if it differs from BT-5. - The rate itself appears in the XML only in profile EXTENDED (CII `TaxApplicableTradeCurrencyExchange`). Data read from XML has no exchange rate; see [Declared amounts](#declared-amounts) for how `from()` handles it. ## Allowances and charges An allowance reduces an amount, a charge increases it, e.g. a discount or a shipping fee. Both exist on two levels: - **Line allowances and charges** (BG-27, BG-28) change the net amount of one line. They need `Line::make()`. - **Document level allowances and charges** (BG-20, BG-21) belong to one VAT group of the whole invoice. For a discount on the whole invoice, `discountPercent()` and `discountAmount()` split it over the VAT groups for you. Each one has an amount, or a percentage of a base amount. EN 16931 requires a reason text or a reason code ([Reason codes](#reason-codes)). Invoices with prices including VAT cannot have allowances or charges ([Gross price mode](#gross-price-mode)). ### Line allowances and charges A line allowance or charge has an amount, or a percentage of a base amount. Without a base amount, the base is the line amount before allowances and charges (quantity × price); the calculator writes it to BT-137/BT-142. ```php use Quittio\Core\Builder\Line; use Quittio\Country\DE\Tax\VatPreset; // Line allowances and charges need Line::make() ->line(Line::make('Seminar', netPrice: '400.00', quantity: 3, vat: VatPreset::Standard) ->allowance(percent: '10', reason: 'Early bird') // 120.00 of 1200.00 ->charge('25.00', reason: 'Materials', reasonCode: 'ABK')) ``` ### Document level allowances and charges | Method | Description | |---|---| | `allowance(VatCategory $category, BigDecimal\|int\|string\|null $rate, ?string $amount = null, ?string $percent = null, ?string $reason = null, AllowanceReasonCode\|RawCode\|string\|null $reasonCode = null, ?string $baseAmount = null, ?string $exemptionReason = null, VatExemptionReasonCode\|RawCode\|string\|null $exemptionReasonCode = null)` | Document level allowance (BG-20: BT-92 to BT-98) for one VAT category and rate. | | `charge(VatCategory $category, BigDecimal\|int\|string\|null $rate, ?string $amount = null, ?string $percent = null, ?string $reason = null, ChargeReasonCode\|RawCode\|string\|null $reasonCode = null, ?string $baseAmount = null, ?string $exemptionReason = null, VatExemptionReasonCode\|RawCode\|string\|null $exemptionReasonCode = null)` | Document level charge (BG-21: BT-99 to BT-105). | | `discountPercent(BigDecimal\|int\|string $percent, ?string $reason = null, AllowanceReasonCode\|RawCode\|string\|null $reasonCode = AllowanceReasonCode::Discount)` | Percentage discount on all lines, split into one allowance per VAT group. | | `discountAmount(BigDecimal\|int\|string $amount, ?string $reason = null, AllowanceReasonCode\|RawCode\|string\|null $reasonCode = AllowanceReasonCode::Discount)` | Absolute discount, distributed over the VAT groups in proportion to their line sums. | A document level allowance or charge belongs to exactly one VAT group, given by category and rate. Without a base amount, the base is the sum of the line net amounts of its VAT group; the calculator writes it to BT-93/BT-100. Its exemption reason is used for the VAT breakdown as described in [Exemption reasons in the VAT breakdown](#exemption-reasons-in-the-vat-breakdown). ```php use Quittio\Core\Enums\ChargeReasonCode; use Quittio\Core\Enums\VatCategory; ->charge(VatCategory::StandardRate, '19', amount: '9.90', reason: 'Shipping', reasonCode: ChargeReasonCode::Freight) ->allowance(VatCategory::StandardRate, '19', percent: '5', reason: 'Loyalty discount') ->discountPercent('3', 'Framework agreement') // one allowance per VAT group ``` `discountPercent()` and `discountAmount()` split the discount when the invoice is built ([Discount splitting](#discount-splitting)): - Each VAT group gets one allowance, in proportion to the signed line sum of the group. A group with a negative sum (only returns) receives a negative part. - Rounding differences are distributed with the largest remainder method, so the parts add up exactly to the discount. - A part keeps percentage and base amount only if it equals round2(base × percentage / 100). Otherwise only the amount is written, because validators check that formula (e.g. PEPPOL-EN16931-R040). - A discount of 0 adds nothing. A discount on lines that add up to zero throws a `CalculationException`. ### Reason codes Use these codes for the `reasonCode` of allowances and charges on both levels. Other codes of the lists can be passed as strings. - `AllowanceReasonCode` (code list UNTDID 5189): `BonusForWorksAheadOfSchedule` (41), `OtherBonus` (42), `ManufacturersConsumerDiscount` (60), `DueToMilitaryStatus` (62), `DueToWorkAccident` (63), `SpecialAgreement` (64), `ProductionErrorDiscount` (65), `NewOutletDiscount` (66), `SampleDiscount` (67), `EndOfRangeDiscount` (68), `IncotermDiscount` (70), `PointOfSalesThresholdAllowance` (71), `MaterialSurchargeDeduction` (88), `Discount` (95), `SpecialRebate` (100), `FixedLongTerm` (102), `Temporary` (103), `Standard` (104), `YearlyTurnover` (105). - `ChargeReasonCode` (code list UNTDID 7161): `Advertising` (AA), `Telecommunication` (AAA), `Miscellaneous` (ABK), `AdditionalPackaging` (ABL), `OtherServices` (ADR), `PickUp` (ADT), `Delivery` (DL), `Freight` (FC), `Financing` (FI), `Labelling` (LA), `Packing` (PC), `SpecialHandling` (SH). ## Sub lines Sub lines divide a line into parts, e.g. a workstation that consists of a computer and a monitor. The parent line needs `Line::make()`. `subLine()` takes the same forms as `line()`, usually the name with named values: ```php use Quittio\Core\Builder\Line; use Quittio\Country\DE\Tax\VatPreset; ->line(Line::make('Workstation', vat: VatPreset::Standard) ->subLine('Computer', netPrice: '900.00', vat: VatPreset::Standard) ->subLine('Monitor', netPrice: '250.00', quantity: 2, vat: VatPreset::Standard)) ``` - A parent line without quantity has the quantity 1. Without its own price, it takes the sum of its sub lines as price. - Sub lines exist only in two profiles: EXTENDED (CII, with parent line identifier and line status `GROUP`/`DETAIL`) and the XRechnung extension (UBL only, `->format('xrechnung-ubl')->profile('xrechnung-extension')`). - The automatic format choice upgrades ZUGFeRD and CII to EXTENDED ([Automatic choice](formats.md#automatic-choice)). Other profiles reject sub lines (`QUITTIO-PROFILE-SUBLINES`). ## Gross price mode Shops and B2C invoices often work with prices including VAT. Give every line a `priceInclVat` instead of a `netPrice`. The calculator then derives the net prices so that the customer pays exactly the gross amount ([Gross price conversion](#gross-price-conversion)): ```php laravel use Quittio\Country\DE\Tax\VatPreset; use Quittio\Laravel\Facades\Quittio; Quittio::invoice() // ... ->line('T-shirt', priceInclVat: '19.99', quantity: 3, vat: VatPreset::Standard) ->line('Shipping', priceInclVat: '4.90', vat: VatPreset::Standard) ->line('Voucher', priceInclVat: '5.00', quantity: -1, vat: VatPreset::Standard) ->build(); ``` ```php plain use Quittio\Country\DE\Tax\VatPreset; $quittio->invoice() // ... ->line('T-shirt', priceInclVat: '19.99', quantity: 3, vat: VatPreset::Standard) ->line('Shipping', priceInclVat: '4.90', vat: VatPreset::Standard) ->line('Voucher', priceInclVat: '5.00', quantity: -1, vat: VatPreset::Standard) ->build(); ``` Restrictions: - All lines of the invoice use `priceInclVat()`. - Gross price lines have no line allowances, charges or sub lines. - The invoice has no document level allowances or charges. Model shipping and discounts as lines, a discount with a negative quantity. Violations throw a `CalculationException` when the invoice is calculated. The VAT per rate is rounded commercially from the gross sums (section 14.5 (20) UStAE), and the lines add up exactly to the gross prices; a rounding amount (BT-114) is only needed when net amount and VAT cannot reproduce the gross sum. So the fallback the BMF letter of 15 October 2026 (marginal no. 19) allows for gross price e-invoices until 2027, sums per rate with the lines in an attachment, is not needed. To change a price later, `InvoiceLine::withPriceInclVat()` changes a gross price line and `withNetPrice()` a net price line. Each throws an `InvalidArgumentException` for a line of the other mode. ## Changing existing data `InvoiceBuilder::from(InvoiceData $data)` takes over every value of the data, including lines, document allowances and charges, payment data, presentation and metadata. Drafts, stored invoices and read invoices can then be changed with the normal builder methods. Existing lines are changed with `updateLine()` and removed with `removeLine()`: ```php use Quittio\Core\Builder\InvoiceBuilder; use Quittio\Core\Builder\PartyBuilder; use Quittio\Core\Data\Lines\InvoiceLine; use Quittio\Country\DE\Tax\VatPreset; $changed = InvoiceBuilder::from($draft) ->issueDate('2026-10-20') ->buyer(fn (PartyBuilder $b) => $b->contact('Lena Kunde', null, 'lena@kunde.de')) // changes the existing buyer ->updateLine('2', netPrice: '80.00', description: 'Price adjusted') ->updateLine('4', fn (InvoiceLine $line) => $line->with(['note' => 'Delivered in two parts'])) ->removeLine('3') ->line('Travel expenses', netPrice: '120.00', vat: VatPreset::Standard) ->build(); ``` `updateLine(string $id, ?callable $change = null, netPrice, quantity, priceInclVat, name, description)` changes a line in one of two ways: with the named values (`->updateLine('2', netPrice: '80.00', quantity: 3)`), or with a callable that receives the `InvoiceLine` and returns the changed one. `removeLine(string $id)` removes a line by its identifier (BT-126, [Line identifiers](#line-identifiers)). Both work only on lines that already exist as `InvoiceLine`: the lines of data passed to `InvoiceBuilder::from()` and lines added as `InvoiceLine`. Lines added in the other forms are built only in `build()`, so they cannot be changed or removed by identifier. An unknown identifier throws an `InvalidArgumentException`. What happens to the amounts: - Totals and the VAT breakdown are not taken over (except [declared amounts](#declared-amounts)); the result is calculated again when rendered. - Percentage document allowances and charges whose base is the line sum of their VAT group follow the lines when lines are added, changed or removed. So do discounts that `discountPercent()` or `discountAmount()` split over the VAT groups. They are recalculated or split again: a VAT group without lines keeps no allowance of 0.00, and a new VAT group gets its part. - `updateLine()` resets the line net amount and recalculates percentage line allowances and charges from the new line amount. A base amount that equalled the previous line amount follows the new one. - `InvoiceLine::withNetPrice()` drops list price and discount. It throws for a line with a price including VAT, and `withPriceInclVat()` throws for a line with a net price (the gross price mode applies to all lines). - `dueInDays()`, `cashDiscount()` and `lateFee()` continue the existing payment terms; a text passed to `paymentTerms()` replaces them. Seller and buyer callables continue the existing parties. ## Cancellations and corrections A cancellation ("Stornorechnung", cancellation invoice) is a new invoice with its own number. It reverses an issued invoice and refers to it (BG-3); the original is never changed. Build it with `cancellation()` of the `Quittio` instance or the Laravel facade. It returns an `InvoiceBuilder`: ```php use Quittio\Laravel\Facades\Quittio; $builder = $quittio->cancellation($original, 'ST-2026-0001', reason: 'Charged twice'); // core instance $builder = Quittio::cancellation($original, 'ST-2026-0001', reason: 'Charged twice'); // Laravel facade $result = $quittio->make($builder)->render(); ``` In Laravel, a rendered invoice can also be cancelled with `$result->cancel(…)` ([Getting started](getting-started.md#cancellation)). `cancellation(InvoiceData $original, string $number, ?string $reason = null, ?string $strategy = null, ?Date $issueDate = null, ?array $lines = null, ?CancellationHistory $history = null, ?string $title = null): InvoiceBuilder` | Parameter | Description | |---|---| | `$original` | The issued invoice, calculated (e.g. `RenderedInvoice::data()`, a stored snapshot or read data). A cancellation reverses its amounts exactly, also amounts another system rounded ([declared amounts](#declared-amounts)). | | `$number` | Number of the cancellation. | | `$reason` | Appended to the cancellation note ("Reason: …"). | | `$strategy` | `credit_note` or `negative_invoice` (`CorrectionPolicy::CANCELLATION_CREDIT_NOTE`, `CANCELLATION_NEGATIVE_INVOICE`, see [Sign strategies](#sign-strategies)). Default: the configured `corrections.cancellation_strategy`, then the country pack (Germany: `credit_note`). Another value throws an `InvalidArgumentException`. | | `$issueDate` | A `Date` (`Date::parse('2026-10-20')`), default today in the time zone of the original. | | `$lines` | Partial cancellation ([below](#partial-cancellations)); `null` cancels the whole invoice. | | `$history` | Earlier partial cancellations and price reductions of the original, for the cumulative VAT rounding ([below](#cumulative-vat-rounding)). | | `$title` | Document title in PDF, HTML and file name (`Presentation::$title`), e.g. "Stornorechnung". Default: the title `cancellation` of the country pack's correction policy (`cancellation_self_billed` for self-billed originals); without one, the label of the type code. | The leading country pack of the original ([Country packs](country-packs.md)) provides the correction policy and the locale of the texts: the locale of the original, then the configured locale, then the pack default. Without a `Quittio` instance, `Cancellation::of(InvoiceData $original, string $number, string $strategy = 'credit_note', ?string $reason = null, ?Date $issueDate = null, ?string $locale = null, ?string $title = null, ?array $lines = null, ?CorrectionPolicy $policy = null, ?CancellationHistory $history = null)` (`Quittio\Core\Corrections\Cancellation`) does the same. Note the different parameter order, and that without `$title` or `$policy` the document title comes from the type code. The cancellation is a copy of the original with these changes: | Field | Value | |---|---| | Number, issue date | `$number`, `$issueDate` | | Type code | by strategy, see [Sign strategies](#sign-strategies) | | Preceding invoice (BG-3) | the original's number and issue date (replaces earlier references) | | Notes (BG-1) | "Stornierung der Rechnung RE-2026-0042 vom 03.10.2026." ("Cancellation of invoice … of …"; for self-billed originals "Stornierung der Gutschrift …", "Cancellation of the self-billed invoice …") with subject `AAI`, plus the reason. The original's notes with subject `REG` and `TXD` are kept, others dropped. | | Payment terms, due date | "Der Betrag wird mit offenen Forderungen verrechnet oder erstattet." ("The amount will be offset against open items or refunded."); no due date | | Lines, allowances, charges | all lines with document allowances and charges, or the selected lines | | Prepaid amount BT-113, rounding amount BT-114, third party payments | taken over by a full cancellation, so that the amounts due match; not by a partial one | | Title in PDF and file name | from the correction policy (Germany: "Stornorechnung", cancellation invoice; for self-billed originals "Storno-Gutschrift", cancellation of the self-billed invoice) | Everything else stays as in the original: parties, references, payment instructions, delivery, currency, attachments and presentation. The result is an `InvoiceBuilder`, so you can change it before rendering, e.g. `->note('…')` or `->payment(PaymentMeansCode::SepaCreditTransfer, iban: '…')` for the refund account. Changing lines or allowances recalculates the amounts. A prepayment invoice (386) is cancelled like any invoice, fully or partly, e.g. when the advance payment is refunded. The cancellation carries the meta flag `prepayment_correction` (`Meta::FLAG_PREPAYMENT_CORRECTION`), and so does a corrected invoice of a prepayment invoice (`correction()`) and the cancellation of such a document. Country packs then need no date of the supply, which has not been made: in Germany the cancellation refers to the prepayment invoice instead (`DE-USTG-03`, [Prepayment invoices](country-packs.md#prepayment-invoices)). ### Sign strategies A cancellation reverses the amounts in one of two ways: as a credit note with positive amounts (`credit_note`) or as an invoice with negative amounts (`negative_invoice`). | Original | `credit_note` | `negative_invoice` | |---|---|---| | Invoice (380, 384, 326 …) | 381, positive amounts | 380, negative quantities and amounts | | Credit note (`isCreditNote()`) | 380, positive amounts | 380, positive amounts | | Self-billed invoice (389) or debit note (527) | 261, positive amounts | 389, negative quantities and amounts | | Self-billed credit note (261) | 389, positive amounts | 389, positive amounts | - A credit note is reversed by an invoice with the same positive amounts in both strategies; a second credit note would credit twice. - With `negative_invoice`, the quantities, line net amounts, line and document allowances and charges (amounts and base amounts), BT-113, BT-114 and third party payments are negated. Prices stay positive (BR-27). - Self-billed documents stay self-billed. - Both strategies are permitted in Germany. The German pack titles the document "Stornorechnung", never "Gutschrift" (in German a self-billed invoice), except for self-billing. - UBL writes a cancellation with `credit_note` as `CreditNote`. The XRechnung extension has no UBL credit note: use `negative_invoice` there. ### Partial cancellations Pass `lines:` to cancel only some lines, quantities or amounts: ```php $builder = $quittio->cancellation($original, 'ST-2026-0002', reason: 'Partial return', lines: [ ['line' => '3'], // the whole line ['line' => '1', 'quantity' => '1'], // 1 of 3 ['line' => '2', 'amount' => '50.00'], // an amount, e.g. a price reduction ]); ``` - Each entry names a line identifier (BT-126) once, with a `quantity`, an `amount` or neither (the whole line). Quantity and amount together throw an `InvalidArgumentException`, as do an unknown line or an empty list. - Quantities and amounts are magnitudes: a negative line (discount, return) keeps its sign and is reversed with it. - A quantity must be greater than 0 and at most the invoiced quantity. Line allowances and charges are scaled in proportion. Lines with sub lines can only be cancelled as a whole. - An amount becomes one unit (C62) at that net price, without allowances and charges. It must be greater than 0 and at most the line net amount, so the original must be calculated. For lines with a price including VAT, the amount includes VAT and is compared with the gross line amount. - Whole lines keep the original's declared net amounts; quantities and amounts are recalculated. - Invoices with document level allowances or charges cannot be cancelled partially, because these cannot be assigned to single lines reliably. Cancel fully and issue a new invoice. - Each part is rounded on its own: three cancellations of one unit of a line of 29.00 net for 3 units give 9.67 each. Cancel the remainder of a line as an amount (`['line' => '1', 'amount' => '9.66']`), so that the parts add up exactly to the line. The Managed layer tracks this per line ([Managed layer](managed.md#cancellations-and-corrections)). - The core checks each part against the invoiced quantity or amount of the line, and with a history the sum per VAT group against the original. It does not know what earlier parts cancelled of a line: limit the last part to the remainder yourself, or let the Managed layer do it. - A price reduction is no partial cancellation: the invoice stays correct, only the consideration changes. Use `priceReduction()` ([Price reductions](#price-reductions)). - A full cancellation suits an invoice issued twice: cancel the second, duplicate invoice. ### Cumulative VAT rounding VAT is rounded per document and VAT group. If each partial cancellation is rounded on its own, the parts together can differ from the original by a cent per part. Example: three parts of 9.67, 9.67 and 9.66 net at 19 % carry 3 × 1.84 = 5.52 VAT, the original 5.51. With a `CancellationHistory` of the earlier partial cancellations, the VAT is rounded cumulatively per VAT group (price reductions share the history, see [VAT of price reductions](#vat-of-price-reductions)): - S = taxable amount of the earlier cancellations + taxable amount of this one, - target = round2(S × rate / 100), or the original's VAT BT-117 when this cancellation closes the group (all its lines are cancelled completely afterwards), - VAT of this cancellation = target − VAT of the earlier cancellations. The three parts then carry 1.84, 1.83 and 1.84 = 5.51. Why cumulatively: section 17 (1) sentence 1 UStG requires the VAT owed to be corrected, here 5.51; rounding every part on its own would correct 5.52, a cent more than was ever owed. Union law leaves the rounding method to the member states within the principles of neutrality and proportionality (CJEU C-302/07, J D Wetherspoon), and the BMF letter of 15 October 2026 (marginal no. 21) looks at the original invoice and all corrections together. Section 14.5 (20) UStAE asks for the VAT of an invoice rounded to the cent; a single part then differs by up to one cent from that, which the note explains. No ruling or administrative instruction deals with cumulative rounding over several correction documents explicitly; the approach was confirmed by a tax adviser in the review of October 2026 (see the README). - Every part differs by at most 0.01 from round2(own taxable amount × rate) and keeps the sign of its taxable amount. - The validation reports the difference as information `QUITTIO-CANCELLATION-VAT-ALIGNED`, and the cancellation note explains the rounding: "Rounding adjustment: the VAT of this partial cancellation is set so that all partial cancellations of invoice RE-… together correct its VAT exactly." (German: "Rundungsausgleich: Die Umsatzsteuer dieses Teilstornos ist so bemessen, dass alle Teilstornos zur Rechnung RE-… zusammen deren Umsatzsteuer exakt berichtigen."). - For an original whose VAT another system rounded (BT-117 ≠ round2(BT-116 × rate)), the target uses its effective rate BT-117 / BT-116, which spreads the difference over the parts. This does not apply to groups with positive and negative lines. - In gross price mode, the taxable amounts follow the same way from the gross amounts cancelled so far, and the rounding amounts (BT-114) of all parts add up to the original's. - BT-111 in accounting currency is aligned the same way at the original's exchange rate. - Without a history, or for an original whose amounts are stale, the VAT is rounded per document. The Managed layer keeps the history itself. Without it, build the history from the cancellations as issued: ```php use Quittio\Core\Corrections\CancellationHistory; // $original: 3 × 10.00 with a line allowance of 1.00 at 19 %, 29.00 net, 5.51 VAT $history = new CancellationHistory; // no earlier partial cancellation $first = $quittio->make($quittio->cancellation($original, 'ST-1', lines: [['line' => '1', 'quantity' => '1']], history: $history))->render(); $history = $history->withCancellation($original, $first->data()); $second = $quittio->make($quittio->cancellation($original, 'ST-2', lines: [['line' => '1', 'quantity' => '1']], history: $history))->render(); $history = $history->withCancellation($original, $second->data()); // The last part cancels what is left of line 1 and closes the VAT group S|19.00 $history = new CancellationHistory($history->groups, closes: ['S|19.00']); $third = $quittio->make($quittio->cancellation($original, 'ST-3', lines: [['line' => '1', 'amount' => '9.66']], history: $history))->render(); ``` | `CancellationHistory` | Description | |---|---| | `new CancellationHistory(array $groups = [], array $closes = [])` | `$groups`: per VAT group key (`DeclaredAmounts::breakdownKey()`, e.g. `S\|19.00`, `S\|7.00`, `E\|0.00`, `O\|`) the sums of the earlier cancellations as `BigDecimal`: `taxable` (BT-116), `tax` (BT-117), `taxInTaxCurrency` (share of BT-111, null if unknown) and in gross price mode `gross` (null or missing if unknown), in the original's direction. `$closes`: keys of the VAT groups whose lines are all cancelled completely once this cancellation is issued, including groups closed earlier. | | `withCancellation(InvoiceData $original, InvoiceData $cancellation, array $closes = []): self` | The history after an issued (calculated) cancellation; `$closes` for the next one. The cancellation of a price reduction counts negatively. | | `withPriceReduction(InvoiceData $original, InvoiceData $reduction): self` | The history after an issued (calculated) price reduction; the closed groups stay. | | `CancellationHistory::fromDocuments(InvoiceData $original, iterable $documents, array $closes = []): self` | The history of all issued (calculated) documents that credited the original: partial cancellations, price reductions and the cancellations of those. | | `CancellationHistory::entries(InvoiceData $original, InvoiceData $cancellation)` | The VAT groups of an issued cancellation in the original's direction. | | `taxable(string $key)`, `tax(string $key)`, `gross(string $key)`, `closes(string $key)`, `taxInTaxCurrency()` | Values of the history. | | `align(InvoiceData $original, InvoiceData $cancellation)` | The aligned VAT breakdown and BT-111 of a calculated partial cancellation or price reduction (used by `cancellation()` and `priceReduction()`). | | `assertFits(InvoiceData $original, InvoiceData $cancellation, array $aligned)` | Throws an `InvalidArgumentException` for a history that does not fit the original: unknown VAT groups, more taxable amount than the original's lines, or a VAT more than 0.01 off or of the wrong sign. A history built with `withCancellation()` from the issued cancellations always fits. | | `matches(InvoiceData $original, InvoiceData $cancellation): bool` | Whether an issued cancellation carries the VAT this history gives it; false e.g. after another partial cancellation was issued meanwhile. | Amounts in the history are signed in the original's direction: a credit note that cancels an invoice and an invoice that cancels a credit note count with their amounts, a negative invoice with its amounts negated. ### Correction policy A country pack defines its defaults for cancellations and corrections in `Quittio\Core\Countries\CorrectionPolicy`: - `new CorrectionPolicy(string $cancellationStrategy = 'credit_note', string $correctionStrategy = 'cancel_and_reissue', array $titles = [])`, with the constants `CANCELLATION_CREDIT_NOTE`, `CANCELLATION_NEGATIVE_INVOICE`, `CORRECTION_CANCEL_AND_REISSUE` and `CORRECTION_CORRECTED_INVOICE`. - `$titles` maps a document kind to titles per locale (`['cancellation' => ['de' => 'Stornorechnung', 'en' => 'Cancellation invoice']]`). `title(string $kind, string $locale = 'en')` and `cancellationTitle(bool $selfBilled, string $locale = 'en')` read them; self-billed originals use `cancellation_self_billed` if defined. - `new CorrectionPolicy(…, ?Closure $strategyResolver = null)`: a closure `fn (InvoiceData $original): ?string` that chooses the cancellation strategy for a particular original; `null` keeps `$cancellationStrategy`. `cancellationStrategyFor(InvoiceData $original)` applies it; `Quittio::cancellation()` uses it when neither the argument nor `corrections.cancellation_strategy` sets a strategy. The German pack cancels self-billed invoices sent as XRechnung this way by a negative self-billed invoice ([Country packs](country-packs.md#cancellations-and-corrections)). - The correction strategy is used by the Managed layer. In the core, correct an invoice by cancelling it and issuing a new one (`InvoiceBuilder::from($original)->number(…)`), or with a corrected invoice (`correction()`, below). - The titles `correction` and `price_reduction` title the documents of `correction()` and `priceReduction()`. ### Corrected invoices `correction(InvoiceData $original, string $number, ?string $reason = null, ?Date $issueDate = null, ?string $title = null): InvoiceBuilder` (core instance and Laravel facade) starts a corrected invoice (type code 384) that replaces the original: ```php $builder = $quittio->correction($original, 'RE-2026-0050', reason: 'Wrong hourly rate') ->removeLine('1') ->line('Web development', netPrice: '90.00', quantity: 24, unit: UnitCode::Hour); $result = $quittio->make($builder)->render(); ``` - It is a copy of the original with the new number and issue date, type code 384, the reference to the original (BG-3) and the note "Diese Rechnung berichtigt und ersetzt die Rechnung RE-2026-0042 vom 03.10.2026." ("This invoice corrects and replaces invoice … of …", subject `AAI`, label `correction_note`) plus the reason. With this note the corrected invoice refers to the original specifically and unambiguously (section 31 (5) UStDV, section 15.2a (7) UStAE). Correcting a corrected invoice replaces its earlier note. - Change what was wrong on the builder. The title comes from the policy (`correction`, Germany: "Rechnungskorrektur"). - Credit notes and self-billed documents cannot be corrected this way (`InvalidArgumentException`): cancel them and issue a new document. - `Correction::of(InvoiceData $original, string $number, ?string $reason = null, ?Date $issueDate = null, ?string $locale = null, ?string $title = null, ?CorrectionPolicy $policy = null)` (`Quittio\Core\Corrections\Correction`) does the same without a `Quittio` instance. Cancelling the original and issuing a new invoice stays the safer default: a receiving system that does not read type code 384 as replacement books both invoices, and the buyer deducts the VAT twice. ### Price reductions A price reduction (German "Entgeltminderung") reduces the consideration of a correct invoice afterwards: a cash discount (Skonto) taken, a reduction after a complaint about defects, a bonus (section 17 UStG). The invoice is not corrected; in Germany such a document is not even required, except for section 17 (4) UStG, and it need not be an e-invoice (section 14.11 (4), 17.1 (3a) UStAE). A cash discount taken may simply be booked with the payment. `priceReduction(InvoiceData $original, string $number, PriceReductionReason $reason, $percent = null, $amount = null, ?array $amounts = null, ?Date $issueDate = null, ?string $title = null, ?CancellationHistory $history = null): InvoiceBuilder` builds such a document: ```php use Quittio\Core\Corrections\PriceReductionReason; // 2 % cash discount taken, on every VAT group of the invoice $builder = $quittio->priceReduction($original, 'EM-2026-0001', PriceReductionReason::CashDiscount, percent: '2'); // 100.00 net after a complaint, on an invoice with one VAT group $builder = $quittio->priceReduction($original, 'EM-2026-0002', PriceReductionReason::Defect, amount: '100.00'); // per VAT group, keyed "category:rate" $builder = $quittio->priceReduction($original, 'EM-2026-0003', PriceReductionReason::Bonus, amounts: ['S:19' => '50.00', 'S:7' => '5.00']); ``` - Give exactly one of `percent`, `amount` (only for an original with one VAT group) and `amounts`. A reduction must be greater than zero and at most the taxable amount of its group; an unknown group throws. - The document is a credit note (381, positive amounts) with one line "Minderung des Entgelts" per reduced VAT group, with the VAT of that group's first line (preset, exemption reason), the reference to the original (BG-3) and the meta flag `price_reduction` (`Meta::FLAG_PRICE_REDUCTION`). - The note names reason, net amount and VAT per rate: "Minderung des Entgelts zur Rechnung RE-2026-0042 vom 03.10.2026 wegen in Anspruch genommenen Skontos (2 %). Minderung Entgelt 50,00 €, Umsatzsteuer 19 %: 9,50 €." The reasons (`PriceReductionReason`): `CashDiscount`, `Defect`, `Bonus`, `Other`. - Payment terms: for a cash discount "Die Minderung wurde bei der Zahlung bereits einbehalten.", otherwise the text of a cancellation. - The title comes from the policy (`price_reduction`, Germany: "Entgeltminderung"); without one, the label `price_reduction_title`. It is deliberately neither "Rechnungskorrektur" nor "Gutschrift". - Credit notes, self-billed documents and uncalculated invoices cannot be reduced (`InvalidArgumentException`). - Prepayment invoices (386, also a document with the flag `prepayment_correction`) cannot be reduced either (`InvalidArgumentException`): an advance payment is no supply. A lower price is settled in the final invoice, which deducts only the advance payment received; an advance payment refunded is a (partial) [cancellation](#cancellations-and-corrections) of the prepayment invoice. - `PriceReduction::of(InvoiceData $original, string $number, PriceReductionReason $reason, $percent = null, $amount = null, ?array $amounts = null, ?Date $issueDate = null, ?string $locale = null, ?string $title = null, ?CorrectionPolicy $policy = null, TotalsCalculator $calculator = new En16931Calculator, ?CancellationHistory $history = null)` (`Quittio\Core\Corrections\PriceReduction`) does the same without a `Quittio` instance. #### VAT of price reductions Without a history, the VAT of a price reduction is round2(its net amount × rate) per VAT group. Several reductions (and partial cancellations) of one invoice can then credit a cent more VAT than the invoice has: an invoice of 1.50 net at 19 % carries 0.29 VAT, three price reductions of 0.50 each 3 × 0.10 = 0.30. Pass `history:` with what the earlier partial cancellations and price reductions of the original credited, as for [partial cancellations](#cumulative-vat-rounding). One history per invoice holds both kinds, so a price reduction after a partial cancellation is aligned with it, and a partial cancellation after a price reduction with that: - Per VAT group, the VAT credited so far is round2(net amount credited so far × rate); the reduction carries that minus the VAT already credited. The three reductions above carry 0.10, 0.09 and 0.10. - Once the reductions and cancellations credit the whole net amount of a group, the reduction that gets there carries the rest of the invoice's VAT (BT-117): it closes the group by itself. - A VAT amount that differs from the reduction's own rounding is declared (meta flag `cancellation_vat_aligned`, the validation information `QUITTIO-CANCELLATION-VAT-ALIGNED`, at most 0.01 and with the sign of the net amount, within BR-CO-17). The note names that VAT ("Minderung Entgelt 0,50 €, Umsatzsteuer 19 %: 0,09 €.") and adds "Rundungsausgleich: Die Umsatzsteuer dieser Entgeltminderung ist so bemessen, dass alle Entgeltminderungen und Stornos zur Rechnung RE-… zusammen die Umsatzsteuer des geminderten und stornierten Entgelts exakt berichtigen." ("Rounding adjustment: the VAT of this price reduction is set so that all price reductions and cancellations of invoice RE-… together correct exactly the VAT of the reduced and cancelled consideration.", label `price_reduction_vat_aligned`). - BT-111 in accounting currency is aligned the same way. - With a history, the reductions and cancellations together cannot credit more than the taxable amount of a group, and a history that does not fit the original throws an `InvalidArgumentException` (`CancellationHistory::assertFits()`). After price reductions were cancelled, the VAT credited so far can be a cent off; a reduction that would then have to differ by more than a cent from its own rounding is rejected. - Without a history, nothing changes: the VAT is rounded per document. The Managed layer keeps the history itself ([Managed layer](managed.md#price-reductions)). Without it, add every issued document to the history: ```php laravel use Quittio\Core\Corrections\CancellationHistory; use Quittio\Core\Corrections\PriceReductionReason; use Quittio\Laravel\Facades\Quittio; // $original: 3 × 0.50 at 19 %, 1.50 net, 0.29 VAT $history = new CancellationHistory; $first = Quittio::make(Quittio::priceReduction($original, 'EM-1', PriceReductionReason::Defect, amount: '0.50', history: $history))->render(); $history = $history->withPriceReduction($original, $first->data()); // VAT 0.10 $cancellation = Quittio::make(Quittio::cancellation($original, 'ST-1', lines: [['line' => '1', 'quantity' => '1']], history: $history))->render(); $history = $history->withCancellation($original, $cancellation->data()); // VAT 0.09 $second = Quittio::make(Quittio::priceReduction($original, 'EM-2', PriceReductionReason::Defect, amount: '0.50', history: $history))->render(); // VAT 0.10: together exactly 0.29 // Or from all documents issued so far, cancelled price reductions included: $history = CancellationHistory::fromDocuments($original, [$first->data(), $cancellation->data(), $second->data()]); ``` ```php plain use Quittio\Core\Corrections\CancellationHistory; use Quittio\Core\Corrections\PriceReductionReason; // $original: 3 × 0.50 at 19 %, 1.50 net, 0.29 VAT $history = new CancellationHistory; $first = $quittio->make($quittio->priceReduction($original, 'EM-1', PriceReductionReason::Defect, amount: '0.50', history: $history))->render(); $history = $history->withPriceReduction($original, $first->data()); // VAT 0.10 $cancellation = $quittio->make($quittio->cancellation($original, 'ST-1', lines: [['line' => '1', 'quantity' => '1']], history: $history))->render(); $history = $history->withCancellation($original, $cancellation->data()); // VAT 0.09 $second = $quittio->make($quittio->priceReduction($original, 'EM-2', PriceReductionReason::Defect, amount: '0.50', history: $history))->render(); // VAT 0.10: together exactly 0.29 // Or from all documents issued so far, cancelled price reductions included: $history = CancellationHistory::fromDocuments($original, [$first->data(), $cancellation->data(), $second->data()]); ``` An annual bonus over several invoices (section 17 (4) UStG) is documented by a bonus statement ([Documents: Bonus statements](documents.md#bonus-statements)). ## Extensions Profile EXTENDED of ZUGFeRD/Factur-X carries more data than EN 16931, e.g. further parties, delivery terms or instalments ([Profiles](concepts.md#profiles)). Add it with `extended(ExtendedData $extended)` and, for lines, `LineBuilder::extended(LineExtendedData $extended)`. - The data is written to CII in profile EXTENDED only. - When you use it, the automatic choice switches ZUGFeRD and CII to EXTENDED. Other profiles report `QUITTIO-PROFILE-EXTENDED-ONLY`. | `ExtendedData` (`Quittio\Core\Data\Extensions`) | Written as | |---|---| | `invoicer`, `invoicee` (`ExtendedParty`) | `InvoicerTradeParty`, `InvoiceeTradeParty` | | `ultimateCustomer` (`ExtendedParty`) | `ProductEndUserTradeParty` | | `shipFrom` (`ExtendedParty`) | `ShipFromTradeParty` | | `deliveryTermsCode` (string, e.g. an Incoterms code of the international delivery terms such as `FCA`) | `ApplicableTradeDeliveryTerms/DeliveryTypeCode` | | `additionalReferences` (list of `DocumentReference`) | `AdditionalReferencedDocument` with type code (default 916), name and date | | `installments` (list of `Installment(Date $dueDate, ?Money $amount = null, ?string $description = null)`) | one payment terms group per instalment with due date and partial amount | | `additionalPaymentInstructions` (list of `PaymentInstructions`) | further payment means | | `LineExtendedData` | Written as | |---|---| | `lineStatusReasonCode` (`LineExtendedData::STATUS_DETAIL`, `STATUS_GROUP`, `STATUS_INFORMATION`) | Line status; default `GROUP` for lines with sub lines and `DETAIL` for sub lines | | `shipTo` (`ExtendedParty`) | Ship-to party of the line | | `deliveryDate` (`Date`) | Delivery date of the line | | `includedProducts` (list of `IncludedProduct(string $name, ?BigDecimal $quantity = null, UnitCode\|RawCode\|null $unit = null, ?string $description = null, ?string $sellerId = null)`) | Included products | `ExtendedParty(string $name, ?Address $address = null, array $identifiers = [], ?string $vatId = null, ?Contact $contact = null)` describes a further party. A line `DocumentReference(string $id, string $kind = DocumentReference::TYPE_OTHER, ?string $lineId = null, ?Date $issueDate = null, ?RawCode $typeCode = null, ?string $description = null)` is added with `LineBuilder::reference()`. It is written by its kind: `TYPE_ORDER`, `TYPE_CONTRACT`, `TYPE_DESPATCH_ADVICE`, `TYPE_RECEIVING_ADVICE` or `TYPE_OTHER`. ```php use Quittio\Core\Data\Extensions\ExtendedData; use Quittio\Core\Data\Extensions\ExtendedParty; use Quittio\Core\Data\Extensions\Installment; use Quittio\Core\Data\Party\Address; use Quittio\Core\Support\Amount; use Quittio\Core\Support\Date; ->extended(new ExtendedData( ultimateCustomer: new ExtendedParty('Endkunde GmbH', Address::make('Weg 2', '12345', 'Musterstadt', 'DE')), deliveryTermsCode: 'FCA', installments: [ new Installment(Date::parse('2026-11-01'), Amount::of('500.00', 'EUR')), new Installment(Date::parse('2026-12-01'), Amount::of('690.00', 'EUR')), ], )) ``` ### XRechnung extension The XRechnung extension is a profile of XRechnung with additional fields, such as sub lines and third party payments. `xrechnungExtension(XRechnungExtensionData $extension)` adds third party payments (BG-DEX-09): `new XRechnungExtensionData([new ThirdPartyPayment(string $type, Money $amount, string $description)])`. - Third party payments are added to the amount due (BR-DEX-09). - They can only be transmitted in an XRechnung UBL invoice with profile `xrechnung-extension` (UBL `cac:PrepaidPayment`). CII, credit notes and other profiles fail with `QUITTIO-THIRD-PARTY-PAYMENTS`. ## Macros `InvoiceBuilder` and `LineBuilder` are macroable, so you can add your own methods: - `InvoiceBuilder::macro(string $name, callable $macro)` adds a method; `hasMacro(string $name)` and `flushMacros()` inspect and remove them. - The closure is bound to the builder, so `$this` and the builder's private properties are available. - `InvoiceBuilder` can also be extended: `make()`, `from()` and `fromDocument()` return `static`. Country packs add their helpers this way, e.g. `smallAmount()`, `selfBilled()` and `deductAdvance()` of the German pack ([Builder macros](country-packs.md#builder-macros)). ```php use Quittio\Core\Builder\InvoiceBuilder; InvoiceBuilder::macro('forProject', function (string $id, string $name): InvoiceBuilder { return $this->projectReference($id, $name)->note('Project: '.$name); }); $builder->forProject('P-17', 'Customer portal'); ``` ## Calculation `Quittio\Core\Calculation\En16931Calculator` calculates line net amounts, document allowances and charges, the VAT breakdown and the totals. Every render, check and prepare run calls it, so data from the builder never needs to be calculated by hand. To calculate without rendering, call it directly or use `prepare()` ([Formats and profiles](formats.md#rendering-in-the-core)): ```php use Quittio\Core\Calculation\En16931Calculator; $calculated = (new En16931Calculator)->calculate($invoice); $calculated->isCalculated(); // true $calculated->totals->amountDue; // Brick\Money\Money $calculated->vatBreakdown[0]->taxAmount; ``` Amounts are rounded half up to two decimals, only at the points listed below. VAT is calculated per VAT group (category and rate), never per line (BR-CO-17). Calculating calculated data again gives the same result. ### Line amounts | Step | Formula | |---|---| | Net price BT-146 | as given; otherwise list price BT-148 − price discount BT-147 | | Line amount before allowances and charges B | round2(quantity BT-129 × net price BT-146 / base quantity BT-149), the base quantity only if it is set and not 0 or 1 | | Line allowance BT-136 | as given; otherwise round2((base BT-137, default B) × percentage BT-138 / 100) | | Line charge BT-141 | as given; otherwise round2((base BT-142, default B) × percentage BT-143 / 100) | | Line net amount BT-131 | B − Σ line allowances + Σ line charges | A line with sub lines and without its own price takes the sum of the net amounts of its sub lines as line amount. The price is derived from it with up to ten decimals. `LineCalculator` (`calculate(InvoiceLine $line, string $currency)`) does this per line. Its static helpers are: - `baseAmount($quantity, $netPrice, $baseQuantity)`: B; - `exactAmount(InvoiceLine $line)`: the unrounded line amount that PEPPOL-EN16931-R120 checks; - `priceFor($amount, $quantity, $baseQuantity)`: the shortest net price, 2 to 10 decimals, for which the line formula yields an amount. ### Document totals and VAT breakdown | Step | Formula | |---|---| | Document allowance BT-92 / charge BT-99 | as given; otherwise round2((base BT-93/BT-100, default the line net sum of its VAT group) × percentage / 100) | | Taxable amount BT-116 per VAT group | Σ line net amounts − Σ allowances + Σ charges of the group | | VAT amount BT-117 per VAT group | round2(BT-116 × rate / 100); 0 for categories Z, E, AE, K, G and O | | Sum of line net amounts BT-106 | Σ BT-131 | | Sum of allowances BT-107, charges BT-108 | Σ document allowances, Σ document charges (empty if there are none) | | Total without VAT BT-109 | BT-106 − BT-107 + BT-108 | | VAT total BT-110 | Σ BT-117 | | VAT total in accounting currency BT-111 | round2(BT-110 × exchange rate), only if BT-6 differs from BT-5 | | Total with VAT BT-112 | BT-109 + BT-110 | | Amount due BT-115 | BT-112 − BT-113 + BT-114, plus third party payments of the XRechnung extension | | Due date BT-9 | issue date + `dueInDays()` if no due date is set | The VAT groups appear in the breakdown in the order of their first line. A document allowance or charge for a group without lines adds its own group. A rounding amount of 0 is left out. ### Gross price conversion `GrossPriceConverter` applies when a line has a price including VAT (`priceInclVat()`, [Gross price mode](#gross-price-mode)). Per VAT group: 1. G = Σ g_i with g_i = round2(quantity × price including VAT). 2. N = round2(G / (1 + rate / 100)), the taxable amount. 3. T = round2(N × rate / 100), the VAT (BR-CO-17). 4. Every line gets n_i = round2(g_i / (1 + rate / 100)); the cents N − Σ n_i go to the lines with the largest rounding remainders. A line keeps the sign of its gross amount (returns and vouchers stay negative). A cent never moves a line to zero or across zero while another line can take it. Net prices are derived with the precision needed for the line formula to yield n_i. 5. G − (N + T) of all groups becomes the rounding amount BT-114, so that the amount due equals the gross amount the customer saw. Example: 3 × 9.99 including 19 % gives G = 29.97, N = 25.18, T = 4.78, net price 8.393, BT-114 = 0.01 and an amount due of 29.97. `GrossPriceConverter::netOf(BigDecimal $gross, BigDecimal $rate)` is step 2. ### Discount splitting `AllowanceSplitter::splitAllowance(array $lines, string $currency, ?BigDecimal $percent, ?Money $amount, ?string $reason = null, AllowanceReasonCode|RawCode|null $reasonCode = null): list` implements `discountPercent()` and `discountAmount()`. The discount (the amount, or round2(line sum × percentage / 100)) is distributed over the VAT groups in proportion to their signed line sums with `LargestRemainder::distribute(BigDecimal $total, array $weights, int $scale = 2)`. `LargestRemainder::distribute()` floors every part and gives the remaining cents to the parts with the largest remainders (ties in the order of the weights). It returns parts that add up exactly to the total. Weights that are all zero share equally; weights that add up to zero throw a `CalculationException`. Example: a discount of 10.00 on 100.00 at 19 % and 50.00 at 7 % becomes 6.67 and 3.33. ### Declared amounts Data that Quittio did not calculate itself can carry amounts that another system rounded differently, e.g. line net amounts rounded per line or a VAT amount within the tolerance of BR-CO-17. Recalculating such data would change amounts that were already issued, and a cancellation would no longer reverse the original exactly. Quittio therefore keeps these declared amounts in two cases: - `InvoiceBuilder::from($data)` with data whose line net amounts or VAT breakdown the recalculation does not reproduce exactly (e.g. an invoice read from XML), as long as no amount-relevant input changes: lines, document allowances and charges, discounts and the currency. Changing a line, adding one or calling `allowance()` recalculates everything. - Cancellations of such data ([Cancellations and corrections](#cancellations-and-corrections)). The builder then sets `Meta::FLAG_DECLARED_AMOUNTS` with a fingerprint of the amount inputs (`DeclaredAmounts::fingerprint()`, an xxh128 hash over identifiers, quantities, prices, VAT groups, allowances, charges, net amounts, VAT breakdown and currency). The calculator keeps a declared amount within these tolerances: | Declared amount | Kept if | |---|---| | Line net amount BT-131 | within 0.02 of the unrounded line formula (`DeclaredAmounts::LINE_TOLERANCE`, as PEPPOL-EN16931-R120 tolerates it); a parent line may also state the sum of its sub lines | | VAT amount BT-117 | less than one currency unit from the recalculation (BR-CO-17); 0 for categories without VAT | | VAT total in accounting currency BT-111 | within 0.01 (`DeclaredAmounts::TAX_CURRENCY_TOLERANCE`) | - Amounts beyond these tolerances are recalculated, and the data gets `Meta::FLAG_DECLARED_AMOUNTS_RECALCULATED`. The validation reports it as `QUITTIO-DECLARED-AMOUNTS` (the document may not reverse the original exactly). - Data whose amount inputs no longer match the fingerprint, e.g. changed with `with()` or edited in stored JSON, is recalculated completely. - Data calculated by Quittio never needs declared amounts. The calculator also writes a fingerprint to every result, so `from()`, cancellations and the calculator never keep amounts that were changed afterwards. The calculation policy decides what happens with declared amounts (`calculation.declared_amounts` in Laravel, `calculation.declared_amounts` in `Quittio::create()`, or `new En16931Calculator(policy: new CalculationPolicy(DeclaredAmountsMode::Recalculate))`): | Mode | Declared amounts | |---|---| | `keep` (default) | kept within the tolerances above | | `recalculate` | always recalculated, reported as `QUITTIO-DECLARED-AMOUNTS`; the aligned VAT of partial cancellations is kept | | `reject` | kept within the tolerances, otherwise a `CalculationException` | The policy belongs to the run, not to the data: the same stored invoice gives other amounts under another policy. `InvoiceBuilder::from()` compares the declared amounts with the default calculator; `Quittio::edit()` and cancellations use the calculator of the instance. The helpers are public: `DeclaredAmounts::needed(InvoiceData $data)` (the recalculation does not reproduce the declared amounts), `isStale()` (changed after the amounts were calculated or declared), `isTrusted()` (flagged and fingerprint matches), `hasAmounts()` and `breakdownKey(VatCategory $category, ?BigDecimal $rate)` (VAT group key, e.g. `S|19.00`). Data read from XML has no exchange rate. `InvoiceData::withImpliedExchangeRate()` returns a copy with the rate BT-111 / BT-110 (ten decimals). `from()` takes it over, so that the recalculation reproduces BT-111. It drops the rate once amounts or the VAT accounting currency change, because the rate is only as precise as the declared amounts. Set the rate with `exchangeRate()` then, otherwise the validation fails with BR-53. ## Data model `Quittio\Core\Data\InvoiceData` is the root of the model. It is a superset of EN 16931 (versions 2017 and 2026) with the extensions of profile EXTENDED and the XRechnung extension. All data classes are `final readonly` with promoted constructor properties. The [field reference](field-reference.md) lists every field with business term, cardinality, profile level and XML paths. | Property | Type | BT | Set with | |---|---|---|---| | `number` | `string` | BT-1 | `number()` | | `issueDate` | `Date` | BT-2 | `issueDate()` | | `typeCode` | `InvoiceTypeCode\|RawCode` | BT-3 | `type()` | | `currency` | `string` | BT-5 | `currency()` | | `seller` | `SellerParty` | BG-4 | `seller()` | | `buyer` | `BuyerParty` | BG-7 | `buyer()` | | `lines` | `list` | BG-25 | `line()`, `lines()` | | `taxCurrency` | `?string` | BT-6 | `taxCurrency()` | | `taxPointDate`, `taxPointDateCode` | `?Date`, `TaxPointDateCode\|RawCode\|null` | BT-7, BT-8 | `taxPointDate()`, `taxPointDateCode()` | | `dueDate` | `?Date` | BT-9 | `dueDate()`, calculator | | `buyerReference`, `projectReference`, `contractReference`, `purchaseOrderReference`, `salesOrderReference`, `receivingAdviceReference`, `despatchAdviceReference`, `tenderReference`, `invoicedObject`, `buyerAccountingReference` | `?string`, `?ProjectReference`, `?Identifier` | BT-10 to BT-19 | [References](#references) | | `paymentTerms` | `?PaymentTerms` | BT-20 | `paymentTerms()` | | `notes` | `list` | BG-1 | `note()` | | `businessProcess` | `?string` | BT-23 | `businessProcess()` | | `precedingInvoices` | `list` | BG-3 | `precedingInvoice()` | | `payee` | `?PayeeParty` | BG-10 | `payee()` | | `sellerTaxRepresentative` | `?TaxRepresentativeParty` | BG-11 | `taxRepresentative()` | | `delivery` | `?Delivery` | BG-13 | `deliveryDate()`, `deliverTo()`, `delivery()` | | `invoicingPeriod` | `?Period` | BG-14 | `invoicingPeriod()` | | `paymentInstructions` | `?PaymentInstructions` | BG-16 | `payment()`, `creditTransfer()`, `paymentCard()`, `directDebit()` | | `allowances`, `charges` | `list`, `list` | BG-20, BG-21 | `allowance()`, `charge()`, `discountPercent()`, `discountAmount()` | | `totals` | `?Totals` | BG-22 | calculator | | `vatBreakdown` | `list` | BG-23 | calculator | | `attachments` | `list` | BG-24 | `attachment()` | | `prepaidAmount`, `roundingAmount` | `?Money` | input for BT-113, BT-114 | `prepaid()`, `addPrepaid()`, `rounding()` | | `extended` | `?ExtendedData` | profile EXTENDED | `extended()` | | `xrechnungExtension` | `?XRechnungExtensionData` | XRechnung extension | `xrechnungExtension()` | | `presentation` | `?Presentation` | PDF and HTML only | `presentation()`, `group()` | | `meta` | `Meta` | internal | `locale()`, `timezone()`, `custom()`, `source()`, `flag()`, `exchangeRate()` | | `standardVersion` | `StandardVersion` | internal | `standard()` | The parts live in sub namespaces of `Quittio\Core\Data`: | Namespace | Classes | |---|---| | `Party` | `SellerParty`, `BuyerParty`, `PayeeParty`, `TaxRepresentativeParty`, `Address`, `Contact`, `ElectronicAddress` | | `Lines` | `InvoiceLine`, `Item`, `Price`, `LineVat`, `Classification`, `ItemAttribute` | | `AllowanceCharge` | `DocumentAllowance`, `DocumentCharge` (base `DocumentAllowanceCharge`), `LineAllowance`, `LineCharge` (base `LineAllowanceCharge`) | | `Payment` | `PaymentInstructions`, `CreditTransfer`, `PaymentCard`, `DirectDebit`, `PaymentTerms`, `CashDiscount`, `PenaltyTerms` | | `Delivery` | `Delivery`, `Period` | | `References` | `PrecedingInvoiceReference`, `ProjectReference`, `DocumentReference` | | `Totals` | `Totals`, `VatBreakdown` | | `Attachments` | `Attachment` | | `Extensions` | `ExtendedData`, `ExtendedParty`, `Installment`, `IncludedProduct`, `LineExtendedData`, `XRechnungExtensionData`, `ThirdPartyPayment` | | `Presentation` | `Presentation`, `Colors`, `LineGroup`, `LinePresentation` | | (root) | `InvoiceData`, `Identifier`, `Note`, `Meta` | `Totals` has `lineNetSum` (BT-106), `allowanceSum` (BT-107), `chargeSum` (BT-108), `netTotal` (BT-109), `vatTotal` (BT-110), `vatTotalInTaxCurrency` (BT-111), `grossTotal` (BT-112), `prepaidAmount` (BT-113), `roundingAmount` (BT-114) and `amountDue` (BT-115), all `Brick\Money\Money`. A `VatBreakdown` has `taxableAmount` (BT-116), `taxAmount` (BT-117), `category` (BT-118), `rate` (BT-119), `exemptionReason` (BT-120) and `exemptionReasonCode` (BT-121). Types: amounts are `Money` with two decimals; prices, quantities and rates are `Brick\Math\BigDecimal`; dates are `Quittio\Core\Support\Date` (`toIsoString()`, `format()`, `addDays()`, `toCarbon()`, `isBefore()` …). ### Immutability Data objects never change. `with(array $changes)` returns a copy with the named properties replaced; an unknown property throws an `InvalidArgumentException`: ```php $copy = $invoice->with(['buyerReference' => '04011000-12345-03']); $copy = $invoice->withNumber('RE-2026-0043')->withIssueDate(Date::parse('2026-10-05')); $line = $invoice->lines[0]->with(['note' => 'Delivered in two parts']); ``` `with()` does not recalculate anything and checks nothing. For changes of amounts, prefer `InvoiceBuilder::from()`, so that allowances and discounts follow the lines ([Changing existing data](#changing-existing-data)). Changing amount inputs of calculated data with `with()` makes its amounts stale: the next calculation recalculates them ([Declared amounts](#declared-amounts)). Helpers of `InvoiceData`: `isCalculated()` (totals present), `typeCodeValue()` (BT-3 as string), `isCreditNote()`, `allLines()` (all lines including sub lines, depth first), `withImpliedExchangeRate()` and `InvoiceData::factory()` for test data ([Testing](testing.md)). Helpers of the parts: `InvoiceLine::withNetPrice()`, `withPriceInclVat()`, `hasSubLines()`, `Price::isGrossMode()`, `LineVat::groupKey()`, `DocumentAllowanceCharge::isCharge()` and `reasonCodeValue()`, `PaymentInstructions::primaryCreditTransfer()`, `CreditTransfer::isIban()`, `PaymentTerms::isEmpty()`, `Period::isValid()`, `Attachment::size()`, `Identifier::schemeValue()`, `Meta::hasFlag()`, `Presentation::isExplicit()`. ### Arrays and JSON `InvoiceData::toArray()`, `toJson(int $flags = 0)`, `InvoiceData::fromArray(array $data)` and `InvoiceData::fromJson(string $json)` convert the model losslessly, including totals, presentation and metadata: ```php $json = $invoice->toJson(JSON_PRETTY_PRINT); $same = InvoiceData::fromJson($json); ``` ```json { "number": "RE-1", "issueDate": "2026-10-03", "typeCode": "380", "currency": "EUR", "seller": { "name": "Muster GmbH", "address": { "countryCode": "DE", "line1": "Hauptstraße 1", "city": "Musterstadt", "postcode": "12345" }, "vatId": "DE123456789" }, "buyer": { "name": "Kunde AG", "address": { "countryCode": "DE", "line1": "Bahnhofstraße 5", "city": "Beispielstadt", "postcode": "54321" } }, "lines": [ { "id": "1", "quantity": "2", "unit": "HUR", "price": { "netPrice": "95.00" }, "vat": { "category": "S", "rate": "19" }, "item": { "name": "Beratung" } } ] } ``` - Keys are the property names. Values equal to the constructor default are left out and restored on the way back. - Amounts are strings with two decimals and without currency: `fromArray()` uses the invoice currency (BT-5), for BT-111 the VAT accounting currency (BT-6). Decimals are strings, dates `YYYY-MM-DD`, codes their value. The content of attachments is base64 encoded. - `fromArray()` rejects unknown fields, missing required values, floats and values of the wrong type with a `Quittio\Core\Exceptions\HydrationException` that names the path, e.g. `lines[0].price.netPrice: Floats are not accepted. Pass monetary values and quantities as strings.` A code that is not a case of its enum becomes a `RawCode` where the property allows one. - `toJson()` always uses `JSON_THROW_ON_ERROR`, `JSON_UNESCAPED_SLASHES` and `JSON_UNESCAPED_UNICODE`; pass further flags such as `JSON_PRETTY_PRINT`. The JSON Schema (draft 2020-12, `$id` `https://quittio.dev/schema/invoice.schema.json`) is shipped in `packages/core/resources/schema/invoice.schema.json` (`JsonSchemaGenerator::defaultPath()`). With the optional package `opis/json-schema`, `Quittio\Core\Serialization\JsonSchemaValidator` checks input before hydration: - `JsonSchemaValidator::available()` tells whether the package is installed. - `(new JsonSchemaValidator)->validate(string $json)` returns up to 20 errors as `path: message`, or an empty list if the input is valid. Without the package it throws a `RuntimeException`. ### Snapshots Stored invoices (the Managed layer, queued render jobs) use snapshots. A snapshot is `toSnapshot()`: `toArray()` plus the schema version `_version` (`InvoiceData::SNAPSHOT_VERSION`, currently 1). `InvoiceData::fromSnapshot(array $snapshot, ?SnapshotUpcasterChain $chain = null)` brings a snapshot of an older version to the current model before hydrating it; a snapshot without `_version` counts as version 1. Snapshots of issued invoices are never rewritten: upcasters run in memory when a snapshot is read. ```php use Quittio\Core\Serialization\Snapshots\SnapshotUpcaster; use Quittio\Core\Serialization\Snapshots\SnapshotUpcasterChain; final class SnapshotV1ToV2 implements SnapshotUpcaster { public function from(): int { return 1; // reads version 1, produces version 2 } public function upcast(array $snapshot): array { // rename or convert the fields that changed between the versions return $snapshot; } } SnapshotUpcasterChain::useDefault(new SnapshotUpcasterChain([new SnapshotV1ToV2])); ``` - `SnapshotUpcasterChain` (`register(SnapshotUpcaster $upcaster)`, `upcast(array $snapshot, int $from, int $to = InvoiceData::SNAPSHOT_VERSION)`) applies one upcaster per version step. - `SnapshotUpcasterChain::default()` is the shared chain of `fromSnapshot()`; `useDefault(?SnapshotUpcasterChain $chain)` replaces it. - A snapshot of a newer version than the installed package, an invalid version or a missing upcaster throw a `SnapshotVersionException`. - The current model is version 1, so no upcaster is needed yet; upcasters matter once a release changes the model. In Laravel, list the upcaster classes in `snapshots.upcasters` ([Configuration](configuration.md)). # Formats and profiles This page explains what Quittio produces from an invoice: a PDF with embedded XML, XML only, a plain PDF, HTML or JSON. It shows how Quittio chooses the output by itself, how you request a specific one, and lists every format and profile with its details. If the words format, profile, CII or UBL are new to you, read [Formats](concepts.md#formats) and [Profiles](concepts.md#profiles) in the E-invoicing basics first. Field numbers such as BT-10 are explained in [EN 16931 and business terms](concepts.md#en-16931-and-business-terms). Two settings decide the output of a render run: - The **format** decides what is produced: PDF, XML, HTML or JSON. For XML it also decides the syntax, CII or UBL ([Syntaxes](concepts.md#syntaxes-cii-and-ubl)). - The **profile** decides which fields and rules the XML follows, for example EN 16931, XRechnung, Peppol or a Factur-X level. Storage, downloads, queues and events are described in [Laravel integration](laravel.md), all configuration keys in [Configuration](configuration.md). ## You usually do not choose a format Without `format()`, Quittio chooses format and profile for each invoice. It uses data you provide anyway: the countries of seller and buyer, whether the buyer is a consumer, and the buyer reference. For a German seller: - A business customer gets ZUGFeRD: a PDF that people can read, with the XML for accounting software embedded (profile EN 16931). - A German public authority gets XRechnung as CII XML. Quittio recognises it by the Leitweg-ID (the routing ID of a German public buyer) in the buyer reference (BT-10). - A consumer gets a PDF without XML. So do a customer outside the EU and a small amount invoice up to 250 € that you mark with `->de()->smallAmount()`. [Which format do I need?](concepts.md#which-format-do-i-need) shows all cases in a table, [Automatic choice](#automatic-choice) the exact rules. The result tells you what Quittio chose: ```php laravel use Quittio\Laravel\Facades\Quittio; $result = Quittio::make($invoice)->render(); // no format: automatic choice $result->format(); // e.g. "zugferd" $result->profile()?->key(); // e.g. "en16931" $prepared = Quittio::make($invoice)->prepare(); // the same decision, without rendering $prepared->format(); // e.g. "zugferd" $prepared->profile()?->key(); // e.g. "en16931" ``` ```php plain $result = $quittio->make($invoice)->render(); // no format: automatic choice $result->format(); // e.g. "zugferd" $result->profile()?->key(); // e.g. "en16931" $prepared = $quittio->make($invoice)->prepare(); // the same decision, without rendering $prepared->format(); // e.g. "zugferd" $prepared->profile()?->key(); // e.g. "en16931" ``` ## Requesting a format When a customer requires a specific format, name it. Every format has a default profile, so you rarely need `profile()` as well. ```php laravel use Quittio\Laravel\Facades\Quittio; // At the end of the builder chain $result = Quittio::invoice() ->number('RE-2026-0043') ->deliveryDate('2026-09-30') ->buyer($customer) // with an electronic address, required by XRechnung ->buyerReference('04011000-12345-03') // Leitweg-ID, required by XRechnung ->line('Consulting', netPrice: '120.00') ->render('xrechnung-cii'); // For invoice data you built before $result = Quittio::make($invoice)->format('xrechnung-cii')->render(); $result = Quittio::make($invoice)->format('zugferd')->profile('extended')->render(); // Several formats from one calculation; the first one is the main result $result = Quittio::make($invoice)->formats(['zugferd', 'xrechnung-cii'])->render(); $result->as('xrechnung-cii')->xml(); ``` ```php plain // At the end of the builder chain $result = $quittio->invoice() ->number('RE-2026-0043') ->deliveryDate('2026-09-30') ->buyer($customer) // with an electronic address, required by XRechnung ->buyerReference('04011000-12345-03') // Leitweg-ID, required by XRechnung ->line('Consulting', netPrice: '120.00') ->render('xrechnung-cii'); // For invoice data you built before $result = $quittio->make($invoice)->format('xrechnung-cii')->render(); $result = $quittio->make($invoice)->format('zugferd')->profile('extended')->render(); // Several formats from one calculation; the first one is the main result $result = $quittio->make($invoice)->formats(['zugferd', 'xrechnung-cii'])->render(); $result->as('xrechnung-cii')->xml(); ``` - The format keys are listed in [Output formats](#output-formats). - Use `profile()` when a recipient asks for a Factur-X level such as `basic`, or for the XRechnung extension. Which profile applies without it is described in [Which profile is used](#which-profile-is-used). - To use one format for every invoice, set `defaults.format` in `config/quittio.php` (without Laravel: `format`). The default `null` means automatic choice ([Output configuration](#output-configuration)). - Without Laravel, the same methods exist on `$quittio->invoice()` and `$quittio->make($invoice)` ([Rendering in the core](#rendering-in-the-core)). The plain PHP example uses `$quittio` as created in [Without Laravel](getting-started.md#without-laravel), with your company as `seller`. ## Output formats These are the keys for `render()`, `format()` and `formats()`: | Format | Aliases | Syntax | Output | Profiles | Default profile | |---|---|---|---|---|---| | `zugferd` | `factur-x`, `facturx` | CII | PDF/A-3b with embedded XML (and the XML) | every CII profile that can be embedded: `minimum`, `basic-wl`, `basic`, `en16931`, `extended`, `xrechnung`, `xrechnung-extension`, `xrechnung-cvd` | `en16931` | | `xrechnung-cii` | `xrechnung` | CII | XML | `xrechnung`, `xrechnung-extension`, `xrechnung-cvd` | `xrechnung` | | `xrechnung-ubl` | – | UBL | XML | `xrechnung`, `xrechnung-extension`, `xrechnung-cvd` | `xrechnung` | | `cii` | – | CII | XML | every CII profile | `en16931` | | `ubl` | – | UBL | XML | every UBL profile: `en16931`, `peppol`, `xrechnung`, `xrechnung-extension`, `xrechnung-cvd` | `en16931` | | `peppol` | – | UBL | XML according to Peppol BIS Billing 3.0 | `peppol` | `peppol` | | `pdf` | – | – | PDF without XML (PDF/A-3b by default; optionally with embedded XML, see [PDF, HTML and JSON](#pdf-html-and-json)) | – | – | | `html` | – | – | the rendered template | – | – | | `json` | – | – | the calculated data model | – | – | PDF/A-3b is the archiving standard for PDF (PDF/A) in version 3, which allows embedded files, at conformance level b. Format and profile keys are case-insensitive. The profiles `xrechnung`, `xrechnung-extension` and `xrechnung-cvd` and the formats `xrechnung-cii` and `xrechnung-ubl` come with the German country pack (`Quittio\Country\DE\Formats\XRechnungFormats`); without it they are unknown. Other country packs register their own formats the same way ([Writing your own country pack](country-packs.md#writing-your-own-country-pack)). MINIMUM and BASIC WL carry no invoice lines and do not comply with EN 16931. The validation warns about them with `QUITTIO-PROFILE-NOT-EINVOICE`; use them only when a recipient asks for them. ## Automatic choice Without a format, and without a configured `defaults.format`, the class `Quittio\Core\Formats\DefaultFormatResolver` decides. It first checks whether the invoice is **domestic**: seller and buyer lie in the same VAT territory, or the buyer has no country code. The VAT territory follows VAT law, not the map (`VatTerritory::sameVatTerritory()`). Monaco counts as France, and excluded territories such as Büsingen or Heligoland do not count as domestic. Then the first step that applies decides: 1. **Domestic invoice with a country rule.** The format rules of the leading country pack decide only what the country prescribes ([German format choice](country-packs.md#format-choice)). In Germany: - A valid Leitweg-ID in the buyer reference (BT-10), or a buyer electronic address with scheme `0204` → `xrechnung-cii` with profile `xrechnung`. - A small amount invoice (`smallAmount()`) between parties in Germany's domestic territory under VAT law (the "Inland" of the VAT Act, without Büsingen and Heligoland) → `pdf`. - Everything else goes on to the next steps. 2. **Buyer reachable via Peppol.** A buyer that is not a consumer and is reachable via Peppol → `peppol`. This step needs a [Peppol lookup](#peppol-lookup); without one it is skipped. 3. **Consumer** → `pdf`. 4. **Other domestic invoices** → `zugferd` with the configured profile (default `en16931`). 5. **Cross-border invoice.** The format rules of the buyer's country pack decide first. In Germany a Leitweg-ID leads to XRechnung, whatever the seller's country. A buyer in an excluded territory of the seller's country uses the seller's pack. Without a choice, an invoice within the EU VAT territory → `zugferd` with the configured profile. 6. **Seller or buyer outside the EU VAT territory** → `pdf`, e.g. a US seller invoicing a German business. `prepare()` shows the choice without rendering (see the [example above](#you-usually-do-not-choose-a-format)). ### Upgrade to profile EXTENDED Some data exists only in the profile EXTENDED: sub lines, `extended()` data and line references. When an invoice uses such data, the profile is upgraded: - The automatic choice `zugferd` or `cii` with another profile gets the profile `extended`. - The same applies to a CII format you request without `->profile()`, e.g. `->format('zugferd')`, and to a configured profile. It applies only to formats that allow `extended`. - A profile you request with `->profile()` is never changed. The validation reports the data it cannot carry. - With `auto_upgrade_profile = false` (Laravel `format_resolver.auto_upgrade_profile`), such an invoice fails with a `ConfigurationException` instead. XRechnung has no EXTENDED profile. `->format('xrechnung-cii')` keeps the profile `xrechnung`, and the validation reports the sub lines. To render XRechnung with sub lines, use `->format('xrechnung-ubl')->profile('xrechnung-extension')`. ### Peppol lookup Peppol is an international network for delivering e-invoices ([Formats](concepts.md#formats)). The default resolver chooses `peppol` only when a lookup says that the buyer is reachable there. The lookup is a closure that receives the `BuyerParty` and returns `true` or `false`. Quittio ships no lookup; pass your own resolver: ```php use Quittio\Core\Data\Party\BuyerParty; use Quittio\Core\Formats\DefaultFormatResolver; use Quittio\Core\Quittio; use Quittio\Country\DE\CountryDE; $quittio = Quittio::create($config, [new CountryDE], formatResolver: new DefaultFormatResolver( defaultProfile: 'en16931', autoUpgradeProfile: true, peppolLookup: fn (BuyerParty $buyer): bool => $directory->isRegistered($buyer->electronicAddress), )); ``` In Laravel, name an invokable class in `format_resolver.peppol_lookup`. It is resolved from the container, receives the `BuyerParty` and returns a bool. You can also set a callable at runtime; see [Peppol lookup](laravel.md#peppol-lookup) in the Laravel integration. Country rules come first, but they decide only what the country prescribes (in Germany: public buyers and small amount invoices). Domestic business invoices and cross-border invoices reach the lookup. ### Own resolver and country rules To replace the whole choice, write a resolver. It implements `Quittio\Core\Formats\FormatResolver` (`resolve(InvoiceData $invoice, ResolvedCountries $countries): FormatChoice`) and returns a `FormatChoice(string $format, ?string $profile = null, ?string $reason = null)`. A `null` profile uses the default profile of the format. Register it: - without Laravel with `Quittio::create(formatResolver: …)` or `$quittio->setFormatResolver(…)`, - in Laravel with `Quittio::extend('format_resolver', 'mine', fn ($app, array $config) => new MyResolver)` and `format_resolver.driver = 'mine'`. A country pack contributes its domestic and buyer rules through `formatRules()`. This is a list of `Quittio\Core\Formats\FormatRule` (`resolve(InvoiceData $invoice): ?FormatChoice`, `null` if the rule does not apply). The first rule that returns a choice wins ([Country packs](country-packs.md)). ## Profiles A profile is a set of fields and rules based on EN 16931 ([Profiles](concepts.md#profiles)). Every profile writes its specification identifier (BT-24) into the XML, so that the recipient knows which rules the invoice follows. Some profiles also set a default business process (BT-23), an identifier of the business context in which the invoice is exchanged. | Key | Name | Level | Syntax | Specification identifier (BT-24) | Business process (BT-23) default | Additionally required | |---|---|---|---|---|---|---| | `minimum` | Factur-X/ZUGFeRD MINIMUM | MINIMUM | CII | `urn:factur-x.eu:1p0:minimum` | – | – | | `basic-wl` | Factur-X/ZUGFeRD BASIC WL | BASIC WL | CII | `urn:factur-x.eu:1p0:basicwl` | – | – | | `basic` | Factur-X/ZUGFeRD BASIC | BASIC | CII | `urn:cen.eu:en16931:2017#compliant#urn:factur-x.eu:1p0:basic` | – | – | | `en16931` | EN 16931 | EN 16931 | CII, UBL | `urn:cen.eu:en16931:2017` (`…:2026` with `standard(StandardVersion::En16931_2026)`) | – | – | | `extended` | Factur-X/ZUGFeRD EXTENDED | EXTENDED | CII | `urn:cen.eu:en16931:2017#conformant#urn:factur-x.eu:1p0:extended` | – | – | | `peppol` | Peppol BIS Billing 3.0 | EN 16931 | UBL | `urn:cen.eu:en16931:2017#compliant#urn:fdc:peppol.eu:2017:poacc:billing:3.0` | `urn:fdc:peppol.eu:2017:poacc:billing:01:1.0` | Electronic addresses of seller and buyer (BT-34, BT-49); Peppol rules | | `xrechnung` | XRechnung 3.0 | EN 16931 | CII, UBL | `urn:cen.eu:en16931:2017#compliant#urn:xeinkauf.de:kosit:xrechnung_3.0` | `urn:fdc:peppol.eu:2017:poacc:billing:01:1.0` | Buyer reference (BT-10), electronic addresses of seller and buyer (BT-34, BT-49), seller contact (BG-6), payment instructions (BG-16); BR-DE rules | | `xrechnung-extension` | XRechnung 3.0 Extension | EN 16931 | CII, UBL | `urn:cen.eu:en16931:2017#compliant#urn:xeinkauf.de:kosit:xrechnung_3.0#conformant#urn:xeinkauf.de:kosit:extension:xrechnung_3.0` | as XRechnung | as XRechnung | | `xrechnung-cvd` | XRechnung 3.0 CVD | EN 16931 | CII, UBL | `urn:cen.eu:en16931:2017#compliant#urn:xeinkauf.de:kosit:xrechnung_3.0#compliant#urn:xeinkauf.de:kosit:xrechnung:cvd_0.9` | as XRechnung | as XRechnung, plus contract reference (BT-12), tender or lot reference (BT-17) and a vehicle line; BR-DE-CVD rules | Aliases: `basicwl` (basic-wl), `en-16931` and `comfort` (en16931), `peppol-bis-3` (peppol). The default business process is written only when the invoice sets none (`businessProcess()`). The registry is available as `$quittio->profiles()` (`get()`, `has()`, `all()`, `register()`, `alias()`, `bySpecificationId()`). ### Which profile is used The profile of a format is the first of these that applies: 1. The profile you request with `profile()`. 2. The configured profile (`profile`, Laravel `defaults.profile`), if it fits the format: the format allows it, it exists in the syntax of the format, and it can be embedded into the PDF where the format embeds XML. 3. The profile of the automatic choice. 4. The default profile of the format. 5. `en16931` (`Quittio::DEFAULT_PROFILE`). A configured profile therefore applies to `->format('zugferd')` and to formats chosen by a country rule as well. It is skipped where it does not fit, e.g. `basic` for `xrechnung-cii` or `peppol`. Without a configured profile (`null`, the default) the format or the automatic choice decides. The [upgrade to EXTENDED](#upgrade-to-profile-extended) comes on top. A run fails with a `ConfigurationException` for: - an unknown format, - a profile the format does not allow, - a profile that is not available in the syntax of the format (e.g. `peppol` in `zugferd`), - a profile that cannot be embedded into a PDF. An unknown profile throws an `InvalidArgumentException`. ### What each profile carries The writers leave out every field that the profile does not contain. The validation (level L2, see [Validation](validation.md)) reports such fields as warning `QUITTIO-PROFILE-NOT-ALLOWED`. A missing mandatory field of a profile is an error (`QUITTIO-PROFILE-REQUIRED`), and so is data of profile EXTENDED or of the XRechnung extension in another profile. The "Level" column of the [field reference](field-reference.md) names the lowest level of every field. | Level | Contains | Drops | |---|---|---| | MINIMUM | Number, issue date, type code, currency, buyer reference, purchase order reference, business process, seller name, legal registration, VAT identifier, tax number and country, buyer name and legal registration, total without VAT, VAT total, total with VAT, amount due | lines, addresses, VAT breakdown, payment data and everything else | | BASIC WL | MINIMUM plus postal addresses, identifiers and electronic addresses of seller and buyer, seller trading name, buyer VAT identifier, tax currency, tax point date, due date, contract, despatch advice and accounting references, payment terms text, notes, preceding invoice, payee, tax representative, delivery, invoicing period, payment means with IBAN and direct debit, document allowances and charges, VAT breakdown, all totals | invoice lines | | BASIC | BASIC WL plus lines: identifier, note, quantity and unit, prices (net, list price, discount, base quantity), VAT, item name and standard identifier, line period, line allowances and charges, line amount | item description, seller and buyer item numbers, classification, origin country, attributes, line object identifier, order line and accounting references, contacts, seller additional legal information, buyer trading name, supporting documents, project, sales order, receiving advice, tender and invoiced object references, payment means text, card, account name and BIC | | EN 16931 | everything of EN 16931 | data of profile EXTENDED | | EXTENDED | EN 16931 plus sub lines (with parent line identifier and line status), `ExtendedData` and `LineExtendedData`, the exchange rate, cash discounts and late fees as structured elements, several cash discount tiers, instalments, further payment instructions, line references, exemption reasons repeated on line and allowance level | – | The UBL profiles (`en16931`, `peppol`, `xrechnung`, `xrechnung-extension`, `xrechnung-cvd`) are on level EN 16931. UBL ignores `extended()` data and writes sub lines only for the XRechnung extension. ### Capabilities Profiles can implement marker interfaces in `Quittio\Core\Profiles\Capabilities` that change how the writers work: | Interface | Effect | Implemented by | |---|---|---| | `RequiresVatBreakdownRate` | The VAT breakdown always carries a rate, 0 for category O, outside the scope of VAT (BR-DE-14). | `xrechnung`, `xrechnung-extension`, `xrechnung-cvd` | | `StructuredCashDiscountText` | Cash discounts are written to the payment terms (BT-20) in the XRechnung notation `#SKONTO#TAGE=…#PROZENT=…#` ([Payment terms](building-invoices.md#payment-terms)). | `xrechnung`, `xrechnung-extension`, `xrechnung-cvd` | | `DescribesEmbeddedXml` | `xmpDescription()` and `xmpVersion()` replace the XMP metadata of the embedded XML (`Factur-X/ZUGFeRD Invoice`, `fx:Version` `1.0`), e.g. `XRechnung Invoice` and `3.0`. | `xrechnung`, `xrechnung-extension`, `xrechnung-cvd` | | `ExtendsCodeLists` | `additionalCodes(string $codeList)` adds codes to an official code list for the validation. | `xrechnung-extension` (identifier schemes `XR01` to `XR03` for the code lists ICD and EAS, checked by `BR-DEX-04` to `BR-DEX-08`), `xrechnung-cvd` (item classification scheme `CVD` for UNTDID 7143) | | `ReplacesRules` | `replacedRules(?Syntax $syntax)` names built-in rules that the PHP rules driver does not run for the profile, because own rules with other codes replace them. | `xrechnung-extension` (`BR-CL-10`, `-11`, `-21`, `-25`, `-26`; in UBL also `BR-CO-16` and `QUITTIO-SUBLINES`, see [XRechnung rules](country-packs.md#xrechnung-rules)) | ### Own profiles and formats A profile implements `Quittio\Core\Profiles\Profile`. `AbstractProfile` provides the defaults: syntax CII, EN 16931:2017 only, embedded as `factur-x.xml` with AFRelationship `Alternative`, EN 16931 compliant, no additional rules. Register a profile in a country pack (`profiles()`) or with `$quittio->profiles()->register(new MyProfile)`. Register a format with `$quittio->formats()->register(new OutputFormat(string $key, ?Syntax $syntax = null, bool $pdf = false, bool $embedsXml = false, ?string $defaultProfile = null, array $profiles = [], bool $html = false, bool $json = false))` and an alias with `alias(string $alias, string $key)`. An empty `$profiles` allows every profile of the syntax. XML is written by one `XmlSerializer` per syntax (`syntax(): Syntax`, `serialize(InvoiceData $invoice, Profile $profile, SerializationOptions $options = new SerializationOptions): string`). `$quittio->addSerializer(…)` replaces the CII or UBL writer, in Laravel `Quittio::extend('serializer', …)`. ## ZUGFeRD and Factur-X ZUGFeRD (Germany) and Factur-X (France) are the same standard: a PDF for people with the CII XML embedded for software ([Formats](concepts.md#formats)). The format `zugferd` produces a PDF/A-3b with the CII XML as associated file, an embedded file that PDF/A-3 links to the document. mPDF, the PHP library that renders the PDF, writes it as PDF/A-3b (`PDFAversion` 3-B). The embedded XML is the same as `xml()` of the run, byte for byte. The PDF metadata carry: - the title "{title} {number}", e.g. "Rechnung RE-2026-0042" ("Rechnung" is the German document title "invoice"), - the seller as author, - "Quittio" as creator. The paper size comes from the presentation, then the option `paper` (Laravel `pdf.paper`), then the country pack (Germany: A4). ### Embedded files The name of the embedded file and its AFRelationship depend on the profile. The AFRelationship is a PDF/A-3 entry that says how the file relates to the document. The XMP metadata, the metadata block of the PDF, declare conformance level and version, so that software finds the invoice: | Profile | File name in the PDF | AFRelationship | XMP `fx:ConformanceLevel` | XMP `fx:Version` | |---|---|---|---|---| | BASIC, EN 16931, EXTENDED | `factur-x.xml` | `Alternative` | `BASIC`, `EN 16931`, `EXTENDED` | `1.0` | | MINIMUM, BASIC WL | `factur-x.xml` | `Data` | `MINIMUM`, `BASIC WL` | `1.0` | | XRechnung, XRechnung extension | `xrechnung.xml` | `Alternative` | `XRECHNUNG` | the XRechnung version, `3.0` | The embedded file has the MIME type `text/xml` and the description "Factur-X/ZUGFeRD Invoice" or "XRechnung Invoice". The XMP metadata contain the Factur-X extension schema (namespace `urn:factur-x:pdfa:CrossIndustryDocument:invoice:1p0#`, prefix `fx`) and its PDF/A extension schema description. The schema carries: - `DocumentType` `INVOICE`, also for credit notes, - `DocumentFileName`, `Version` and `ConformanceLevel`. Peppol cannot be embedded. XRechnung can: `->format('zugferd')->profile('xrechnung')` gives a PDF with `xrechnung.xml` (ZUGFeRD profile XRECHNUNG). Supporting documents (`attachment()`, BG-24) are part of the XML, base64 encoded. They are not separate files in the PDF: the PDF carries exactly one associated file. ### Drafts and watermarks Drafts and previews carry a watermark (`Presentation::$watermark`, or the option `watermark`). They never produce e-invoice XML, so that a draft cannot look like an issued e-invoice. A run with a watermark and any format with XML throws a `ConfigurationException`. This covers ZUGFeRD/Factur-X, XRechnung, CII, UBL and Peppol, also next to `pdf` in `formats([...])`. Watermarked PDFs are plain PDF without embedded XML. They are not PDF/A, because PDF/A forbids the transparency of the watermark ([Watermark](templates.md#watermark)). ```php laravel Quittio::make($draft)->format('pdf')->option('watermark', 'ENTWURF')->render(); // "Entwurf" = draft ``` ```php plain $quittio->make($draft)->format('pdf')->option('watermark', 'ENTWURF')->render(); // "Entwurf" = draft ``` ### PDF/A and logos PDF/A is produced for every PDF with embedded XML, and for `pdf` output when `pdf.pdfa` is `true`. PDF/A forbids the alpha channel (transparency) that mPDF writes. Logos in PDF/A documents are therefore re-encoded as RGB PNG on white. SVG logos are rasterised with the PHP extension `imagick` and must be self-contained. Without `imagick`, rendering an SVG logo fails with a `ConfigurationException` ([Logos](templates.md#logos)). ### PDF renderers The PDF comes from a `Quittio\Core\Pdf\PdfRenderer` (`render(RenderRequest $request): string`). Quittio ships three: - `MpdfRenderer`, the default, - `CallbackRenderer` for another HTML-to-PDF engine (Browsershot, Gotenberg …), - `PassthroughRenderer` for a finished PDF. How to configure and register them is described in [PDF renderers](templates.md#pdf-renderers). For the e-invoice, two fields of the request matter. `RenderRequest::$pdfa` asks for PDF/A-3b. `RenderRequest::$embedded` carries the XML as `EmbeddedXml` (`content`, `filename`, `relationship`, `conformanceLevel`, `description`, `documentType`, `version`). - A renderer whose `supportsEmbedding()` returns `true` handles both itself. - For a renderer that returns `false`, the core passes the result to `MpdfPostProcessor` whenever PDF/A or an embedded XML is requested. - `CallbackRenderer` and `PassthroughRenderer` return `true` and use their own post processor (default `MpdfPostProcessor`). It imports every page into a new PDF/A-3b and adds the output intent, the metadata, the XML as associated file and the Factur-X XMP metadata. So PDFs from other engines become ZUGFeRD. A result that does not start with `%PDF` throws a `PdfException`. ## XRechnung XRechnung 3.0 is the German standard for invoices to public authorities. It is a CIUS of EN 16931: a national specialisation with additional rules. The German country pack provides it ([XRechnung profiles](country-packs.md#xrechnung-profiles)) in both syntaxes: - as plain XML: `xrechnung-cii` (alias `xrechnung`) and `xrechnung-ubl`, - embedded in ZUGFeRD, as shown in [Embedded files](#embedded-files). The automatic choice uses `xrechnung-cii` for domestic German invoices whose buyer reference (BT-10) is a Leitweg-ID with valid check digits, or whose buyer electronic address has the scheme `0204`. XRechnung adds to EN 16931: - Required fields: the buyer reference (BT-10; for public buyers the Leitweg-ID), the electronic addresses of seller and buyer (BT-34, BT-49), a seller contact with name, phone and email (BG-6), payment instructions (BG-16), and city and postcode of seller and buyer. - Further XRechnung rules with the codes `BR-DE-…` ([XRechnung rules](country-packs.md#xrechnung-rules)). - The business process (BT-23) defaults to `urn:fdc:peppol.eu:2017:poacc:billing:01:1.0`. - Cash discounts in the payment terms (BT-20) use the notation `#SKONTO#TAGE=7#PROZENT=2.00#` (Skonto = cash discount, Tage = days, Prozent = percent; see [Payment terms](building-invoices.md#payment-terms)). - The VAT breakdown always carries a rate. The **XRechnung extension** (`->profile('xrechnung-extension')`, specification identifier `…#conformant#urn:xeinkauf.de:kosit:extension:xrechnung_3.0`) adds: - sub lines, in UBL only (`xrechnung-ubl`; CII fails with BR-DEX-15), - third party payments (`xrechnungExtension()`, BG-DEX-09), written as `cac:PrepaidPayment` and added to the amount due; only in UBL invoices, - the identifier schemes `XR01` to `XR03`. The extension is never chosen automatically; request it explicitly. It has no credit note in UBL (`DE-XRECHNUNG-EXT-01`): cancel such invoices with the strategy `negative_invoice`. **XRechnung CVD** (`->profile('xrechnung-cvd')`, specification identifier `…#compliant#urn:xeinkauf.de:kosit:xrechnung:cvd_0.9`) is XRechnung 3.0 for vehicles procured under the Clean Vehicles Directive, in CII and UBL. It requires the contract reference (BT-12), the tender or lot reference (BT-17) and at least one line with the vehicle category as item classification of scheme `CVD` (BT-158) and the item attribute `cva` (BT-160, BT-161), see [XRechnung CVD](country-packs.md#xrechnung-cvd). It is never chosen automatically either. ## Peppol BIS Billing 3.0 Peppol BIS Billing 3.0 is the invoice specification of the Peppol network. The format `peppol` writes UBL 2.1 according to it, with the profile `peppol`: - CustomizationID (the specification identifier, BT-24): `urn:cen.eu:en16931:2017#compliant#urn:fdc:peppol.eu:2017:poacc:billing:3.0`, - ProfileID (the business process, BT-23): `urn:fdc:peppol.eu:2017:poacc:billing:01:1.0`, unless the invoice sets BT-23. Seller and buyer need an electronic address (BT-34, BT-49), and the Peppol rules apply ([Validation](validation.md)). The electronic address is the Peppol participant identifier, so its scheme must be one Peppol accepts (`PEPPOL-EN16931-CL008`): e.g. `9930` (German VAT number) or `0088` (GLN), not `EM` (e-mail), which EN 16931 allows. Credit note type codes produce a `CreditNote` document. Quittio produces the document. Sending it through an access point, the service provider that connects you to the Peppol network, is not part of the core. ## CII and UBL The formats `cii` and `ubl` write plain XML in any profile of the syntax. Both writers require calculated data; the render run calculates. They write the elements in the order of the XSD, the XML schema of the syntax. **CII** (UN/CEFACT Cross Industry Invoice D16B, CEN/TS 16931-3-3, root `rsm:CrossIndustryInvoice`) is the syntax of ZUGFeRD/Factur-X and supports all Factur-X levels: - It carries only one preceding invoice reference (BG-3) on header level, so further references are dropped. - Party identifiers without scheme are written as `ram:ID`, with scheme as `ram:GlobalID`. - An account identifier that is no IBAN is written as `ProprietaryID`. - The tax point date is written with the first VAT breakdown. **UBL** (OASIS UBL 2.1, CEN/TS 16931-3-2) writes an `Invoice` document. For credit note type codes (`InvoiceTypeCode::isCreditNote()`) it writes a `CreditNote` document, whose element order differs from `Invoice`: - quantities as `CreditedQuantity`, - the due date (BT-9) in the first payment means; without payment instructions it is not written, - the project reference (BT-11) as additional document reference with type code 50, followed by the tender or lot reference (BT-17) as `OriginatorDocumentReference`. In both UBL documents: - A note with subject code is written as `#CODE#text`. - The creditor identifier of a direct debit (BT-90) is written as seller party identifier with scheme `SEPA`. - A sales order reference without purchase order reference is written with the order ID `NA`. - The payment card network is written as `NA`. Rules of both writers: - Amounts have exactly two decimals, prices and percentages at least two decimals, quantities no trailing zeros. The decimal separator is a dot. - The VAT accounting currency (BT-6) is written only when it differs from the invoice currency (BT-5). - Texts generated for the payment terms (BT-20) are in the run locale. `SerializationOptions(string $locale = 'en', bool $indent = true)` controls locale and indentation when you use a writer (`CiiWriter`, `UblWriter`) directly. ## PDF, HTML and JSON These formats are not e-invoices. The validation skips the profile field matrix (level L2) for them; the other levels run as usual. - `pdf` renders the template as PDF without e-invoice XML. It is PDF/A-3b unless `pdf.pdfa` is `false` or the run has a watermark. - With `pdf.b2c_embed_xml = true` (Laravel `format_resolver.b2c_embed_xml`), `pdf` embeds the CII XML as in ZUGFeRD, also for consumers. The XML uses the profile of the call or the configured profile (default EN 16931). The result then has `xml()` and `profile()`. Watermarked runs never embed XML. - `html` returns the rendered template as HTML (`html()`), e.g. for previews or mails. - `json` returns the calculated data model (`json()`). It is the same as `InvoiceData::toJson(JSON_PRETTY_PRINT)` of the calculated data ([Arrays and JSON](building-invoices.md#arrays-and-json)). ## Rendering in the core This section is the reference of a render call. The examples use the core class `Quittio\Core\Quittio` without Laravel. In Laravel, `Quittio::make()` returns the Laravel variant with the same methods plus `queue()`; its result can also be saved to a disk, downloaded and mailed ([Rendering invoices](laravel.md#rendering-invoices)). With your company as `seller` in the configuration, `$quittio->invoice()` and `$quittio->quote()` … start invoices and documents that render themselves ([Invoices and documents with the configured seller](#invoices-and-documents-with-the-configured-seller)). ```php use Quittio\Core\Quittio; use Quittio\Country\DE\CountryDE; $quittio = Quittio::create([], [new CountryDE]); $result = $quittio->make($invoice)->render(); // automatic choice $result = $quittio->make($invoice)->format('zugferd')->profile('extended')->render(); $result = $quittio->make($invoice)->formats(['zugferd', 'xrechnung-cii', 'json'])->render(); $result->as('xrechnung-cii')->xml(); ``` `make(InvoiceData|ProvidesInvoiceData|InvoiceBuilder $data)` returns a `Quittio\Core\Rendering\PendingInvoice`. A builder is built, and a `ProvidesInvoiceData` model is converted. | `PendingInvoice` method | Description | |---|---| | `format(string $format)` | One output format. Without it: the configured format (`format`, Laravel `defaults.format`), or the [automatic choice](#automatic-choice) if none is configured. | | `formats(array $formats)` | Several formats from one calculation and validation run, e.g. `['zugferd', 'xrechnung-cii']`; duplicates are removed. The first is the main result. | | `profile(Profile\|string $profile)` | Profile for all formats of the run (by key, alias or as object). | | `locale(string $locale)` | Language of PDF, HTML and generated XML texts. | | `country(string $country)` | Country pack that leads the run, instead of the seller's country (BT-40). | | `template(string $template)` | Template of PDF and HTML ([Templates and design](templates.md)). | | `presentation(Presentation $presentation)` | Design defaults for this run; the invoice's own values win. | | `option(string $key, mixed $value)` | Option for templates and validation rules, e.g. `watermark`, `paper`, `markdown`. | | `validate(bool $throwOnError = true)` | Validation mode of this run: errors throw, or (`false`) warnings only. | | `withoutValidation()` | Switches the validation off for this render run (not for `check()` and `prepare()`). | | `render(): RenderedInvoice` | Calculates, chooses format and profile, validates, writes the XML, renders template and PDF. | | `check(): ValidationResult` | Validates like a render run, without template and PDF, whatever the validation mode. This includes the XML levels, also for the XML that `pdf` embeds with `pdf.b2c_embed_xml`. Returns the result and does not throw for invalid data. | | `prepare(): PreparedInvoice` | Calculates and validates like `check()` without rendering. Returns the calculated data, the chosen formats with their profiles (`formats`, `format()`, `profile()`; `null` for formats that write or embed no XML), the leading and buyer country packs, the locale and the validation result. | | `data(): InvoiceData`, `options(): RenderOptions` | The data and the collected options. | ### Invoices and documents with the configured seller With your company as `seller` in the configuration, `$quittio->invoice()` starts an invoice like `Quittio::invoice()` in Laravel and renders it at the end of the chain: ```php use Quittio\Core\Builder\InvoiceBuilder; use Quittio\Core\Builder\Party; use Quittio\Core\Quittio; use Quittio\Core\Tax\CountryDefaultVat; use Quittio\Country\DE\CountryDE; $quittio = Quittio::create([ 'seller' => Party::make('Muster GmbH')->vatId('DE123456789')->address('Hauptstraße 1', '12345', 'Musterstadt', 'DE'), 'bank_account' => ['iban' => 'DE02120300000000202051', 'bic' => 'BYLADEM1001', 'name' => 'Muster GmbH'], 'due_days' => 14, ], [new CountryDE]); InvoiceBuilder::useDefaultVat(new CountryDefaultVat($quittio->countries())); // VAT of lines without vat $invoice = $quittio->invoice() // seller and bank account from the configuration ->number('RE-2026-0044') ->deliveryDate('2026-10-14') ->buyer($customer) ->line('Consulting', netPrice: '120.00'); $result = $invoice->render(); // automatic choice $result = $invoice->render(['zugferd', 'json']); // several formats; the first is the main result $report = $invoice->check('zugferd'); // ValidationResult, nothing rendered $quote = $quittio->quote()->number('AN-2026-0008')->buyer($customer)->line('Consulting', netPrice: '120.00')->render(); ``` | Key of `Quittio::create()` | Value | |---|---| | `seller` | Your company: a `PartyBuilder` (`Party::make()`) or a `SellerParty`. It needs a name and a postal address, otherwise `create()` throws a `ConfigurationException`. | | `bank_account` | `['iban' => …, 'bic' => …, 'name' => …]`, BIC and name optional. Added as SEPA credit transfer (BG-17). | | `small_business` | `true` flags the invoices as small business invoices (`Meta::FLAG_SMALL_BUSINESS`, [Default VAT](building-invoices.md#default-vat)). Default `false`. | `bank_account` or `small_business` without `seller` throws a `ConfigurationException`. - `$quittio->invoice()` returns a `BoundInvoiceBuilder`, an `InvoiceBuilder` that ends with `render()`, `render('xrechnung-cii')`, `render(['zugferd', 'xrechnung-cii'])` (the first format is the main result) or `check()` with the same arguments. - `$quittio->quote()`, `orderConfirmation()`, `deliveryNote()`, `proforma()`, `paymentReminder(int $level = 0)`, `bonusStatement()` and `accountStatement()` return a `BoundDocumentBuilder` that ends with `render()` ([Documents](documents.md)). - The defaults behave as in Laravel: `->seller($otherParty)` replaces the seller and removes the bank account and the small business flag; `->seller(fn (PartyBuilder $s) => …)` changes the configured seller and keeps them ([Seller and buyer](building-invoices.md#seller-and-buyer)). `->payment(PaymentMeansCode::SepaCreditTransfer, iban: …)` replaces the account, `->creditTransfer(…)` adds a further one. - Without `seller`, these methods start empty builders. - For further options, pass the builder to `$quittio->make($builder)` (invoices) or `$quittio->document($builder)` (documents: locale, template, HTML only). `InvoiceBuilder::make()` and `DocumentBuilder::quote()` … with `$quittio->make()` and `$quittio->document()` remain for special cases, e.g. another seller per invoice. ### Result `render()` returns a `Quittio\Core\Rendering\RenderedInvoice`: | Method | Description | |---|---| | `data(): InvoiceData` | The calculated data (totals, VAT breakdown, line amounts, due date). | | `format(): string`, `profile(): ?Profile` | Format key (aliases resolved, e.g. `zugferd` for `factur-x`) and profile; `null` for outputs without XML. | | `validation(): ValidationResult` | Validation result including warnings ([Validation](validation.md)). | | `as(string $format): RenderedInvoice` | The result of another format of the same run, by format key (not alias); `LogicException` for a format that was not rendered. | | `formats(): array` | Keys of all formats of the run. | | `pdf()`, `xml()`, `html()` | The outputs; `LogicException` if the format produced none. `hasPdf()`, `hasXml()` check first. | | `json(): string` | The calculated data as pretty-printed JSON (for every format). | | `contents(): string`, `extension(): string`, `mimeType(): string` | The main output (PDF, otherwise XML, HTML, JSON), its extension and MIME type. | | `filename(?string $extension = null): string` | File name of the main output, or with another extension. | | `hashes(): array` | SHA-256 hashes of PDF, XML and HTML (`['pdf' => …, 'xml' => …]`), e.g. for archiving. | | `save(string $path): string` | Writes the main output to a file, or into a directory (an existing one or a path ending in `/`) with `filename()`; creates missing directories and returns the path. Throws a `RuntimeException` when the file cannot be written. | ### File names File names follow the pattern `filename` (Laravel `pdf.filename`), default `{title}_{number}.{ext}`: | Placeholder | Value | |---|---| | `{title}` | Document title in the run locale, e.g. "Rechnung" (invoice), "Stornorechnung" (cancellation invoice), "Credit note" (`Presentation::$title` overrides it) | | `{number}` | Invoice number | | `{date}` | Issue date, `YYYY-MM-DD` | | `{format}` | Format key, e.g. `zugferd` | | `{ext}` | Extension of the output: `pdf`, `xml`, `html` or `json` | In title and number, characters other than letters, digits, `.`, `_` and `-` become `_`. A run of such characters becomes one `_`, and `_` at the start or end is removed. Example: `Rechnung_RE-2026-0042.pdf`; the XRechnung of the same run is `Rechnung_RE-2026-0042.xml`. ## Output configuration | `Quittio::create()` key | Laravel key | Default | Effect | |---|---|---|---| | `format` | `defaults.format` | `null` | Format of runs without `format()`; `null` = automatic choice (`Quittio::create()` also accepts `auto`). | | `profile` | `defaults.profile` | `null` | Default profile for every format that allows it; `null` = the profile of the format or of the automatic choice. | | `auto_upgrade_profile` | `format_resolver.auto_upgrade_profile` | `true` | Upgrade to EXTENDED when EXTENDED features are used. | | `pdf.b2c_embed_xml` | `format_resolver.b2c_embed_xml` | `false` | Embed the CII XML into `pdf` output. | | `pdf.pdfa` | `pdf.pdfa` | `true` | `pdf` output as PDF/A-3b (ZUGFeRD is always PDF/A). | | `filename` | `pdf.filename` | `{title}_{number}.{ext}` | [File names](#file-names). | | `locale`, `country` | `defaults.locale`, `defaults.country` | `null` | Locale of the run; country pack used when the seller has no country code. | | `options.paper` | `pdf.paper` | `null` | Paper size that wins over the country pack default. | | `temp_dir` | `pdf.cache_path` | system temp directory | Temporary files of mPDF and the logo cache. | | – | `format_resolver.driver` | `default` | Resolver registered with `Quittio::extend('format_resolver', …)`. | | `peppolLookup` of `DefaultFormatResolver` | `format_resolver.peppol_lookup` | `null` | [Peppol lookup](#peppol-lookup): invokable class (Laravel: resolved from the container) or callable that receives the `BuyerParty` and returns whether the buyer is reachable via Peppol. | | – | `pdf.renderer` | `mpdf` | Renderer registered with `Quittio::extend('renderer', …)`. | All keys of `config/quittio.php` are described in [Configuration](configuration.md). # Validation Quittio checks every invoice before it issues it: against the rules of EN 16931, of the profile (for example XRechnung or Peppol, see [Formats](concepts.md#formats)) and of the country (for example the German VAT Act). This page explains what happens when an invoice is invalid, how to read and handle the messages and how to configure the checks. It then describes the validation levels, the installation of the official external validators, all built-in rules and how to add your own. Rule codes such as `BR-CO-25` are explained in [Rules and validation](concepts.md#rules-and-validation), field numbers such as BT-10 in [EN 16931 and business terms](concepts.md#en-16931-and-business-terms). Common errors and their fixes are listed in [Troubleshooting](troubleshooting.md). ## Errors while rendering By default (validation mode `error`), an invoice with errors is not rendered: `render()` throws a `Quittio\Core\Validation\ValidationException`. Its message lists the first five errors, each with rule code, field and message, and the hint on the next line. For example, an XRechnung without buyer reference: ```text The invoice is not valid (2 errors): [QUITTIO-PROFILE-REQUIRED] BT-10: The field buyerReference (BT-10) is mandatory in profile XRechnung 3.0. Provide the field or choose a profile that does not require it. [BR-DE-15] BT-10: The buyer reference (BT-10) must be provided. Set the Leitweg-ID with ->buyerReference('04011000-12345-03'). ``` More than five errors end with "… and N more."; the full result is in `$e->result`. When only warnings block (with `block_on_warnings`), the message lists the blocking warnings instead. ### Reading a message Each finding starts with its rule code in brackets: - `[BR-DE-15]` is the rule code. Its prefix tells where the rule comes from: `BR-` EN 16931, `BR-DE-` XRechnung, `PEPPOL-` Peppol, `DE-USTG-` the German VAT Act (UStG), `QUITTIO-` Quittio itself. All built-in rules are listed in [Rule sets](#rule-sets). - `BT-10` is the field, here the buyer reference. The [Field reference](field-reference.md) shows where each field is in the data model. - The text is the message. The indented line below is the hint, usually the builder method that fixes the error. The hint of `BR-DE-15` sets the Leitweg-ID, the routing ID of a German public buyer ([German terms](concepts.md#german-terms)). One missing value can be reported by more than one rule. In the example, the field check of the profile (level L2, `QUITTIO-PROFILE-REQUIRED`) and the XRechnung rule `BR-DE-15` (level L3) both report the buyer reference. Setting it fixes both. ### Handling the exception ```php laravel use Quittio\Core\Validation\ValidationException; use Quittio\Laravel\Facades\Quittio; try { $rendered = Quittio::make($invoice)->format('xrechnung-cii')->render(); } catch (ValidationException $e) { foreach ($e->result->errors() as $message) { report($message->code.' '.$message->message); } } ``` ```php plain use Quittio\Core\Validation\ValidationException; try { $rendered = $quittio->make($invoice)->format('xrechnung-cii')->render(); } catch (ValidationException $e) { foreach ($e->result->errors() as $message) { error_log($message->code.' '.$message->message); } } ``` `$e->result` is a [`ValidationResult`](#the-result) with all findings. The plain PHP examples on this page use `$quittio` as created in [Without Laravel](getting-started.md#without-laravel), with your company as `seller`. The Laravel integration dispatches two events ([Events](laravel.md#events)): - `InvoiceValidationFailed($invoice, $result)` before the exception is thrown, - `InvoiceValidated($invoice, $result)` after a successful run. This includes mode `warn`, with warnings or errors, but not mode `off`, where nothing is validated. Other exceptions of a render run: - `ConfigurationException`: unknown format, profile not supported by the format, watermark with e-invoice XML, invalid design values, - `Quittio\Core\View\MandatoryFieldMissing` from the [mandatory field guard](#mandatory-field-guard). All exceptions of the package implement `Quittio\Core\Exceptions\QuittioException`, so `catch (QuittioException $e)` catches every error of Quittio. Invalid arguments and runtime errors without a class of their own are `InvalidArgumentException`, `RuntimeException` or `LogicException` from `Quittio\Core\Exceptions`; they extend the PHP classes of the same name. ### Warnings Every finding has a severity: error, warning or info. Only errors stop the rendering. Warnings, for example a BIC with an invalid format (`QUITTIO-BIC`), are attached to the result: `$rendered->validation()->warnings()`. With `block_on_warnings` set to `true`, warnings block like errors ([Configuration](#configuration)). ### Checking without rendering While you build an invoice, `check()` instead of `render()` shows all findings at once. It validates like `render()`, renders no PDF, returns the `ValidationResult` and never throws for invalid data: ```php laravel use Quittio\Laravel\Facades\Quittio; $report = Quittio::invoice()->buyer($customer)->line('Consulting', netPrice: '120.00')->check('xrechnung-cii'); $report = Quittio::make($invoice)->format('xrechnung-cii')->check(); $report->isValid(); $report->errors(); ``` ```php plain $report = $quittio->invoice()->buyer($customer)->line('Consulting', netPrice: '120.00')->check('xrechnung-cii'); $report = $quittio->make($invoice)->format('xrechnung-cii')->check(); $report->isValid(); $report->errors(); ``` Details are in [When validation runs](#when-validation-runs). ## Configuration The validation mode decides what happens with errors: | Mode | Behaviour | |---|---| | `error` (default) | Errors throw a `ValidationException`; nothing is rendered. | | `warn` | The run continues. `$rendered->validation()` holds all findings, errors included. | | `off` | Nothing is validated while rendering; the result is empty. `check()` and `prepare()` still validate. | Set it for the application with `validation.mode` (environment variable `QUITTIO_VALIDATION_MODE`), or for one call. ### Per call ```php laravel Quittio::make($invoice)->validate()->render(); // mode error Quittio::make($invoice)->validate(false)->render(); // mode warn: errors are attached, nothing is thrown Quittio::make($invoice)->withoutValidation()->render(); // mode off: empty result (check() and prepare() still validate) Quittio::make($invoice)->option('max_decimals', 6)->render(); // option for the rules ``` ```php plain $quittio->make($invoice)->validate()->render(); // mode error $quittio->make($invoice)->validate(false)->render(); // mode warn: errors are attached, nothing is thrown $quittio->make($invoice)->withoutValidation()->render(); // mode off: empty result (check() and prepare() still validate) $quittio->make($invoice)->option('max_decimals', 6)->render(); // option for the rules ``` ### Settings In Laravel (keys of `config/quittio.php`, see [Configuration](configuration.md#validation)). The levels L1 to L7 are described in [Validation levels](#validation-levels) below. | Key | Values | Default | |---|---|---| | `validation.mode` | `error` (throw), `warn` (attach the result only), `off` | `error` (`QUITTIO_VALIDATION_MODE`) | | `validation.levels` | `php` (L1, L2, L3, L7), `xsd` (L4), `kosit` (L5), `verapdf` (L6), or the name of a driver registered with `Quittio::extend('validator', …)` | `['php', 'xsd']` | | `validation.block_on_warnings` | `true`: warnings block like errors | `false` | | `validation.locale` | language of the messages: `null` = the language of the application, `'invoice'` = the language of the invoice, or a locale | `null` (`QUITTIO_VALIDATION_LOCALE`) | | `validation.mandatory_field_guard` | `exception`, `log`, `off`; `null` = `exception` outside production, `log` in production | `null` (`QUITTIO_MANDATORY_FIELD_GUARD`) | | `validation.rules` | single PHP rules switched off or re-rated by code, see [Switching rules off](#switching-rules-off-and-changing-their-severity) | nothing changed | | `validation.drivers.kosit` | see [KoSIT validator](#kosit-validator-l5) | | | `validation.drivers.verapdf` | see [veraPDF](#verapdf-l6) | | | `validation.drivers.vies` | see [VIES](#vat-identifiers-and-vies) | | Without Laravel, `Quittio::create()` takes the same settings. It uses the level names of the enum and separate switches for the external validators: ```php use Quittio\Core\Quittio; use Quittio\Country\DE\CountryDE; $quittio = Quittio::create([ 'validation' => [ 'mode' => 'error', // error, warn, off 'levels' => ['L1', 'L2', 'L3', 'L4', 'L7'], // default; L5 and L6 are switched on below 'block_on_warnings' => false, 'kosit' => ['enabled' => true, 'mode' => 'daemon', 'url' => 'http://127.0.0.1:8081'], 'verapdf' => ['enabled' => true, 'mode' => 'docker'], ], 'mandatory_fields' => 'exception', // exception, log, off 'options' => ['max_decimals' => 4], // options for rules, see below ], [new CountryDE]); ``` In `Quittio::create()`: - The PHP driver runs only the listed levels of L1, L2, L3 and L7, so L7 can be left out. - `L4` adds the XSD driver. - The KoSIT and veraPDF drivers are added only with `enabled => true`. Listing `L5` or `L6` alone has no effect. - An unknown mode throws a `ConfigurationException`. ### Options for rules Some rules read options. Set them per call with `->option()`, without Laravel also in `options`: | Option | Used by | Default | |---|---|---| | `max_decimals` | `QUITTIO-PRECISION`: more decimals in quantity or net price are a warning | `4` | | `attachment_max_bytes` | `QUITTIO-ATTACHMENT-SIZE`: limit per attached document | 10 MB | | `attachments_max_total_bytes` | `QUITTIO-ATTACHMENT-SIZE`: limit of all attachments | 15 MB | | `syntax` | Syntax of the XML that will be written (`Quittio\Core\Profiles\Syntax`); set by the run for every format with XML, used by `QUITTIO-THIRD-PARTY-PAYMENTS`, `QUITTIO-CREDIT-NOTE-DUE-DATE`, the `BR-DEX-…` rules, `DE-XRECHNUNG-EXT-01` and the rules a profile replaces (`ReplacesRules`) | from the format | ## Validation levels The checks are split into seven levels. Each level is checked by a driver. The default configuration runs L1 to L4 and L7 in PHP. L5 and L6 use the official external validators, which you install separately. | Level | What is checked | Driver | Stage | |---|---|---|---| | L1 | Structure and data formats of the data model (calculated, country and currency codes, decimals) | `php` | data | | L2 | Mandatory and allowed fields of the profile (field matrix) | `php` | data | | L3 | Business rules: EN 16931 (`BR-…`, `BR-CO-…`, `BR-CL-…`, VAT categories), package rules (`QUITTIO-…`), profile rules (Peppol, XRechnung) and country pack rules (`DE-USTG-…`) | `php` | data | | L4 | XML against the XSD (CII D16B, UBL 2.1) | `xsd` | xml | | L5 | XML against the official Schematron (KoSIT validator: EN 16931, XRechnung, Peppol) | `kosit` | xml | | L6 | PDF/A-3b conformance | `verapdf` | pdf | | L7 | Plausibility: IBAN, BIC, VAT identifier formats, e-mail addresses, dates, VAT category against the destination, Leitweg-ID, optional VIES check | `php` | data | Some terms of the table: - The XSD (XML Schema Definition) describes which elements an XML file of a syntax may contain. - The Schematron files are the official rules of EN 16931, XRechnung and Peppol, published as executable checks. The [KoSIT validator](#kosit-validator-l5) runs them. - PDF/A-3b is the archiving variant of PDF that may carry embedded files. [veraPDF](#verapdf-l6) checks it. - VIES is the EU service that confirms VAT identification numbers online ([VAT identifiers and VIES](#vat-identifiers-and-vies)). L1 to L3 and L7 run in PHP. L4 needs only `ext-dom`. L5 needs Java (or Docker), L6 needs veraPDF (or Docker). No other external validator (for example Mustang) is integrated; add one as [own driver](#own-rules-and-drivers). ## When validation runs A render run validates in three stages, per requested format: 1. **data** (L1, L2, L3, L7) on the calculated invoice, before any XML is written; 2. **xml** (L4, L5) on the generated XML, for formats with XML (and for `pdf` with embedded XML for consumers, `b2c_embed_xml`); 3. **pdf** (L6) on the rendered PDF. In mode `error`, the run stops after the first stage that has errors (or warnings with `block_on_warnings`). Data errors throw before XML is written, XML errors before the PDF is rendered. A driver runs only if it supports the subject: XML drivers need XML, veraPDF needs a PDF. The validation context holds: - the profile of the format, - the country packs: the seller's pack first, the buyer's pack for cross-border invoices, - the locale of the run: the language of the invoice, which rules use for its texts, - the language of the messages ([Messages and translations](#messages-and-translations)), - the options. Formats without XML (`pdf`, `html`, `json`) are no e-invoices: L2 (profile field matrix) is skipped for them. With several formats (`->formats([...])`), every format is validated with its own profile and syntax. `check()` and `prepare()` validate like a render run without template and PDF: ```php laravel $result = Quittio::make($invoice)->format('xrechnung-cii')->check(); // ValidationResult $prepared = Quittio::make($invoice)->formats(['zugferd'])->prepare(); // PreparedInvoice: data, formats, country, buyerCountry, locale, validation ``` ```php plain $result = $quittio->make($invoice)->format('xrechnung-cii')->check(); // ValidationResult $prepared = $quittio->make($invoice)->formats(['zugferd'])->prepare(); // PreparedInvoice: data, formats, country, buyerCountry, locale, validation ``` They are explicit validation requests: - They run the data and xml stages of every requested format with all configured drivers, whatever the validation mode (also `off` and `withoutValidation()`). The [Managed layer](managed.md) freezes invoices with `prepare()`. - They never throw a `ValidationException`. Configuration errors, such as an unsupported profile or an XML format for watermarked data, still throw. - They take the same decisions as `render()`. For `pdf` with `b2c_embed_xml` (and no watermark), the embedded CII XML is generated and validated in the same profile, so what is checked is what is rendered. - L6 does not run, because it needs the rendered PDF. ## The result `Quittio\Core\Validation\ValidationResult` (immutable, `JsonSerializable`): | Member | Returns | |---|---| | `messages` | `list` – all findings | | `levels` | `list` – the levels that were checked | | `isValid()` | `true` if there is no finding with severity `error`; warnings never make a result invalid | | `hasWarnings()` | whether there are warnings | | `errors()`, `warnings()`, `infos()` | findings of one severity | | `byLevel(ValidationLevel $level)` | findings of one level | | `has(string $code)` | whether a finding with this code exists | | `merge(ValidationResult $other)` | new result with the messages of both and the union of the levels | | `toArray()`, `jsonSerialize()` | `['valid' => bool, 'levels' => ['L1', …], 'messages' => [ … ]]` | | `toHtml()` | self-contained HTML fragment: status ("Valid", "Valid with warnings", "Invalid") and a table with severity, level, code, BT and message (with the hint); CSS classes `quittio-report`, `quittio-report-status`, `quittio-valid`, `quittio-invalid`, `quittio-{severity}` | `Quittio\Core\Validation\ValidationMessage` (readonly): | Property | Content | |---|---| | `severity` | `Severity::Error`, `Severity::Warning` or `Severity::Info` (`error`, `warning`, `info`) | | `code` | rule identifier, e.g. `BR-CO-25`, `BR-DE-15`, `DE-USTG-03`, `PEPPOL-EN16931-R010`, `QUITTIO-IBAN`, `XSD`, `PDFA-6.2.2-1` | | `message` | text in the language of the messages (`validation.locale`, see [Messages and translations](#messages-and-translations)), where a translation exists | | `level` | `ValidationLevel::L1` … `L7` | | `bt` | business term or group, e.g. `BT-10`, `BG-23` (nullable) | | `path` | path in the data model, e.g. `buyer.vatId`, `line 2.price.netPrice`, `vatBreakdown[0].taxAmount`; for XSD `line 12` (nullable) | | `hint` | solution hint from the message catalog (nullable) | | `xpath` | location in the XML (KoSIT findings, nullable) | `isError()` and `toArray()` are available on every message. Results of several drivers are merged by concatenation. A rule that is checked both in PHP (L3) and by the official Schematron (L5) can therefore appear twice, with the two levels. Within the PHP driver, identical findings (same code, path and message) are reported once. ## Messages and translations In Laravel, messages and hints are written in the language of the application (`app()->getLocale()`). A developer of an English application therefore reads English messages, also for German invoices. `validation.locale` sets `'invoice'` (the language of the invoice, as in the PDF) or a fixed locale. Without Laravel, the default is the language of the invoice. `Quittio::create(['validation' => ['locale' => 'en']])` sets a fixed locale, `'app'` the locale of the translator. Rules that check texts of the invoice, e.g. the reverse charge statement of `DE-USTG-06` (the note that the buyer owes the VAT), still use the language of the invoice. Messages come from the catalog `quittio::rules.{CODE}` with the entries `message` and `hint`; placeholders such as `:value` are replaced. The core ships the catalog in German and English (`packages/core/resources/lang/{de,en}/rules.php`). Other locales fall back to English, and rules without an entry use their English fallback text. Country packs bring their own namespace (`quittio-de::rules.DE-USTG-01`). To override messages in Laravel, publish the language files with `php artisan vendor:publish --tag=quittio-lang` and edit `lang/vendor/quittio/{locale}/rules.php`. Without Laravel, register a directory with `{locale}/rules.php` files; later paths override earlier ones: ```php use Quittio\Core\I18n\Translations; Translations::translator()->addPath(__DIR__.'/lang', 'quittio'); ``` Findings of the XSD validation, the KoSIT validator, veraPDF and the invoice reader are not translated: they carry the text of the tool or an English text. ## XML schema (L4) `Quittio\Core\Validation\Drivers\XsdValidator` validates against the bundled schemas (`packages/core/resources/xsd`): CII D16B for `CrossIndustryInvoice`, UBL 2.1 for `Invoice` and `CreditNote`. It needs no installation. All its findings are errors: | Code | Meaning | |---|---| | `XSD` | The XML does not match the schema; the path is `line N` | | `XSD-NOT-WELL-FORMED` | Unsafe or broken XML, see [reading](reading.md#limits-and-security) | | `XSD-UNKNOWN-ROOT` | No schema for the root element | Use it on its own with `(new XsdValidator)->validateXml($xml)` (returns `list`). ## KoSIT validator (L5) KoSIT, the German agency that publishes XRechnung, provides the official validator. The official Schematron rules are XSLT 2.0, which PHP cannot execute, so L5 uses the KoSIT validator (Java). It checks EN 16931 and XRechnung (CII and UBL) with the XRechnung validator configuration, and Peppol BIS Billing 3.0 with a second configuration. To use it: 1. Download the validator and its configurations ([Installation](#installation)). 2. Start it as a daemon, or let Quittio call it per document ([Modes](#modes)). 3. Add `kosit` to `validation.levels`. ### Installation ```bash php artisan quittio:schemas:download # into storage/quittio/validators php artisan quittio:schemas:download --path=/opt/validators --force --java=/usr/bin/java php artisan quittio:schemas:download --without-peppol ``` The command downloads into the target directory: - the validator `1.6.3` (standalone JAR from Maven Central) as `validator.jar`, - the XRechnung validator configuration `v2026-08-31` (XRechnung 3.0.2) into `xrechnung/`. It then compiles the Peppol BIS Billing 3.0 Schematron (`v3.0.20`, with SchXslt 1.10.1 and the Saxon bundled in the validator) into `peppol/PEPPOL-EN16931-UBL.xsl`. Compiling needs Java; skip it with `--without-peppol`. Existing files are kept unless `--force` is given. The PHP extension `zip` is required. Java 11 or newer is required to run the validator. At the end, the command prints the configuration to add and the command that starts the daemon on the port of `validation.drivers.kosit.url` (`-P `). Without Laravel use `Quittio\Core\Validation\Drivers\KositArtifacts`: - `download(string $target, bool $force = false)` returns `['jar' => …, 'scenarios' => …, 'repository' => …]`, - `compilePeppol(string $target, string $java = 'java', bool $force = false)` returns `['scenarios' => …, 'repository' => …]`. The scenario file `peppol-scenarios.xml` ships with the core (`KositArtifacts::peppolScenarios()`). ### Modes | Mode | How | Configuration | |---|---|---| | `daemon` (default, recommended) | HTTP POST of the XML (`Content-Type: application/xml`) to `url`; a running validator answers with its report | `url` | | `cli` | One JVM per document: `java -jar {jar} -s {scenarios} -r {repository} … -o {tmp} document.xml` | `jar`, `scenarios` and `repository` and/or `configurations`, `java` | Start a daemon with both configurations (paths as printed by the download command) on the port of the default URL `http://127.0.0.1:8081`. The validator itself listens on port 8080 unless it is started with `-P`: ```bash cd storage/quittio/validators java -jar validator.jar \ -s xrechnung/scenarios.xml -r xrechnung \ -s ../../../vendor/quittio/core/resources/kosit/peppol-scenarios.xml -r . \ -D -P 8081 ``` The repository of Quittio contains a Docker image with the same setup (`tools/docker/kosit/Dockerfile`). It listens on 8080 inside the container: ```bash docker build -t quittio/kosit -f tools/docker/kosit/Dockerfile . docker run --rm -p 8081:8080 quittio/kosit # maps it to the default port 8081 ``` With another port, set `QUITTIO_KOSIT_URL` (without Laravel `validation.kosit.url`) accordingly. Any endpoint that accepts the POST and returns a KoSIT report works. `validation.drivers.kosit`: | Key | Meaning | Default | |---|---|---| | `mode` | `daemon` or `cli` (other values throw `InvalidArgumentException`) | `daemon` | | `url` | daemon endpoint | `http://127.0.0.1:8081` (`QUITTIO_KOSIT_URL`) | | `jar` | path of `validator.jar` (cli) | `null` | | `scenarios`, `repository` | main configuration (cli) | `null` | | `configurations` | further configurations (cli), `[['scenarios' => …, 'repository' => …]]`, e.g. Peppol | `[]` | | `java` | Java binary (cli) | `java` | | `timeout` | seconds per document (HTTP timeout or process limit) | `30` | | `fail_on_unavailable` | an unreachable validator is an error (`true`) or a warning (`false`) | `true` | Add `kosit` to `validation.levels`. Without Laravel, the same keys go to `validation.kosit` with `enabled => true`; use `configurations` for all scenario sets there. ### Findings Every message of the report becomes a finding with: - the rule code of the report (`BR-DE-15`, `PEPPOL-EN16931-R010` …), - the severity of the report (`error`, `warning`, otherwise `info`); a level the scenario sets for the rule (`customLevel`, e.g. `BR-CL-13` as information in XRechnung) takes precedence, as in the validator's own assessment, - the business term found in the text, - the XPath location. Findings of the schema step of the validator have the level L4, all others L5. A message of the schema step without a code of its own gets the code `KOSIT-XSD`. Additional codes: | Code | Severity | Meaning | |---|---|---| | `KOSIT-UNAVAILABLE` | error or warning (`fail_on_unavailable`) | No report: daemon unreachable or HTTP status other than 200, 406 or 422, JAR, configuration or Java missing, timeout | | `KOSIT-NO-SCENARIO` | warning | The configuration has no scenario for the document (e.g. Factur-X EXTENDED); only the XML schema was checked | | `KOSIT-REJECT` | error | The validator recommends rejection although no message is an error | | `KOSIT` | from the report | Message without code | The raw report of the last call is available from the driver instance with `lastReport()`, e.g. for archiving the test report. `KositReportParser::parse($report)` returns `['accepted' => bool, 'scenario' => ?string, 'messages' => list]`. ## veraPDF (L6) veraPDF is an open-source validator for PDF/A. `Quittio\Core\Validation\Drivers\VeraPdfValidator` checks the rendered PDF against PDF/A-3b (`--flavour 3b`, machine readable report, at most 5 failures per rule). It runs for formats that produce a PDF. ### Installing veraPDF veraPDF runs in one of two modes: | Mode | How | |---|---| | `cli` | local veraPDF installation (Java); the PDF is written to a temporary file and passed to `binary` | | `docker` | `docker run --rm -i {image}`; the PDF is passed via stdin | For mode `docker`, Docker is enough; fetch the image once with `docker pull verapdf/cli`. For mode `cli`, install veraPDF locally and make its `verapdf` command available (or set `binary`). Then add `verapdf` to `validation.levels`; without Laravel use `validation.verapdf` with `enabled => true`. `validation.drivers.verapdf` (all keys are in the published configuration): | Key | Meaning | Default | |---|---|---| | `mode` | `cli` or `docker` | `cli` in the Laravel configuration, `docker` without Laravel | | `binary` | veraPDF binary (cli) | `verapdf` | | `image` | Docker image (docker) | `verapdf/cli` | | `docker` | Docker binary (docker) | `docker` | | `timeout` | seconds | `120` | | `fail_on_unavailable` | an unavailable veraPDF is an error (`true`) or a warning (`false`) | `true` | Findings of veraPDF: | Code | Meaning | |---|---| | `PDFA-{clause}-{test}` | Failed rule, e.g. `PDFA-6.2.2-1`; the hint names specification, clause and description, the path the PDF object | | `VERAPDF-NOT-COMPLIANT` | Not compliant without a failed rule in the report | | `VERAPDF-NOT-PARSED` | veraPDF could not validate the file | | `VERAPDF-UNAVAILABLE` | veraPDF could not be run, e.g. `verapdf` or `docker` not installed. It is reported as a finding, not thrown: an error with `fail_on_unavailable` (in mode `error` the run then stops with a `ValidationException`), otherwise a warning | All findings of the external validators are merged into the result of the run like the PHP findings. ## Rule sets The PHP driver (`Quittio\Core\Validation\Drivers\PhpRulesDriver`, name `php`) runs these rule sets, filtered by the configured levels: | Rule set | Level | Codes | |---|---|---| | `StructureRules` | L1 | `QUITTIO-NOT-CALCULATED` (no totals), `QUITTIO-FORMAT-COUNTRY` (BT-40, BT-55 not two upper case letters), `QUITTIO-FORMAT-CURRENCY` (BT-5, BT-6 not three upper case letters), `QUITTIO-PRECISION` (warning, more decimals than `max_decimals`) | | `FieldMatrixRule` | L2 | `QUITTIO-PROFILE-REQUIRED` (error: mandatory field of the profile missing), `QUITTIO-PROFILE-NOT-ALLOWED` (warning: field is not part of the profile and is not written), `QUITTIO-PROFILE-EXTENDED-ONLY`, `QUITTIO-PROFILE-XRECHNUNG-EXTENSION-ONLY`, `QUITTIO-PROFILE-SUBLINES` (errors). The matrix comes from the mapping attributes of the data model ([field reference](field-reference.md)) plus the business terms the profile requires (XRechnung: BT-10, BT-34, BT-49, BG-6, BG-16); BT-23 is not required when the profile sets a default business process | | `En16931Rules` | L3 | `BR-02`, `BR-04` to `BR-07`, `BR-09`, `BR-11`, `BR-16` to `BR-18`, `BR-20`, `BR-21`, `BR-25`, `BR-27` to `BR-30`, `BR-33`, `BR-38`, `BR-42`, `BR-44`, `BR-48` to `BR-50`, `BR-52` to `BR-57`, `BR-61`, `BR-CO-03`, `BR-CO-09` to `BR-CO-18`, `BR-CO-25`, `BR-CO-26` | | `VatCategoryRules` | L3 | per category (`BR-S`, `BR-Z`, `BR-E`, `BR-AE`, `BR-IC`, `BR-G`, `BR-O`, `BR-AF` for L, `BR-AG` for M): `-01` breakdown present, `-02` party identifiers, `-05` rate, `-08` taxable amount, `-09` tax amount, `-10` exemption reason; `-02` and `-05` also cover document level allowances and charges (the Schematron rules `-03`, `-04`, `-06`, `-07`). Plus `BR-IC-11`, `BR-IC-12`, `BR-O-11`, `BR-B-01` (split payment only in a domestic Italian invoice: every country code is `IT`), `BR-B-02` (no category S next to B) and `QUITTIO-IGIC-ZERO-RATE-CII` (warning, see below) | | `CodeListRules` | L3 | `BR-CL-01`, `-04` to `-08`, `-10`, `-11`, `-13`, `-14`, `-16`, `-19` to `-26` (official code lists; `-24` reports `MimeType::Xml` outside the XRechnung extension) | | `QuittioRules` | L3 | package rules, see below | | `PlausibilityRules` | L7 | see [plausibility](#plausibility-l7) | | profile rules | L3 | Peppol BIS profile: `PEPPOL-EN16931-R001`, `-R002`, `-R003`, `-R005` (warning), `-R007`, `-R008`, `-R010`, `-R020`, `-R040`, `-R041`, `-R042`, `-R046`, `-R055`, `-R061`, `-R110`, `-R111`, `-R120`, `-R121`, `-R130`, `-CL007`, `-CL008`, `-F001`, `-P0100`, `-P0101`, `-P0104` to `-P0112`, `PEPPOL-COMMON-R040` to `-R047`, `-R049`, `-R050`, `-R052`, `-R053` (`-R044` to `-R047`, `-R052`, `-R053` warnings), see [Peppol rules](#peppol-rules); XRechnung profiles (country pack DE): `BR-DE-…`, `DE-XRECHNUNG-EXT-01`; XRechnung extension: `BR-DEX-02` (warning), `BR-DEX-04` to `-10`, `-12` to `-15`; XRechnung CVD: `BR-DE-CVD-01` to `BR-DE-CVD-06-b` | | country pack rules | L3, L7 | `rules()` of the seller's pack and `buyerCountryRules()` of the buyer's pack; Germany: `DE-USTG-01` … `DE-USTG-15` (L3), `DE-LEITWEG-ID`, `DE-LEITWEG-ID-SUSPECT`, `DE-TAX-NUMBER` (L7), see [Country packs](country-packs.md) | All EN 16931, code list, VAT category and Peppol rules report errors unless noted. The PHP rules check the invoice data before any XML is written, with readable messages: the EN 16931 rules, the XRechnung rules (`BR-DE-…`, `BR-DEX-…`, `BR-DE-CVD-…`) and the Peppol rules that invoice data can violate. Rules that the builder or the writers always fulfil are not checked again; they are listed with the reason ([XRechnung rules](country-packs.md#xrechnung-rules), [Peppol rules](#peppol-rules)). The PHP rules do not replace the official Schematron (L5), which checks the written XML. A profile can replace rules with its own (`Profiles\Capabilities\ReplacesRules`); the driver then does not run them for that profile. The XRechnung extension replaces `BR-CL-10`, `-11`, `-21`, `-25`, `-26` with `BR-DEX-04` to `-08`, accepts the MIME code `application/xml` in `BR-CL-24` (`BR-DEX-01`) and, in UBL, `BR-CO-16` with `BR-DEX-09` and `QUITTIO-SUBLINES` with `BR-DEX-02`, as its official validator configuration does ([XRechnung rules](country-packs.md#xrechnung-rules)). ### Package rules (`QUITTIO-…`) | Code | Severity | Meaning | |---|---|---| | `QUITTIO-NEGATIVE-TOTAL` | warning | Commercial invoice (380) with a negative amount due; consider a credit note | | `QUITTIO-SUBLINES` | error | Net amount of a line differs from the sum of its sub lines (XRechnung extension in UBL: `BR-DEX-02`, warning) | | `QUITTIO-LINE-ID-DUPLICATE` | warning | A line identifier (BT-126) is used more than once (data not built with `InvoiceBuilder`, which rejects duplicates) | | `QUITTIO-SUBLINE-VAT` | error | Sub line with another VAT category or rate than its parent line | | `QUITTIO-PRECEDING-INVOICES-CII` | warning | More than one preceding invoice (BG-3): CII transmits only the first | | `QUITTIO-IGIC-ZERO-RATE-CII` | warning | Category L (IGIC) with the rate 0 in a profile that renders CII: EN 16931 and the UBL Schematron accept it, the CII Schematron requires a rate greater than zero (BR-AF-05 to BR-AF-07); use UBL | | `QUITTIO-EXEMPTION-CONFLICT` | warning | Lines of one VAT group with different exemption reason codes: the code (BT-121) is omitted, the texts are joined | | `QUITTIO-DECLARED-AMOUNTS` | warning | Declared amounts of an existing document were outside the tolerance and recalculated | | `QUITTIO-THIRD-PARTY-PAYMENTS` | error | Third party payments (BG-DEX-09) outside an XRechnung UBL invoice of the extension | | `QUITTIO-CREDIT-NOTE-DUE-DATE` | warning | UBL credit note with a due date (BT-9) but without payment instructions (BG-16): the UBL binding has no place for the date there, it is left out | | `QUITTIO-VAT-ROUNDING` | warning | VAT amount differs from taxable amount × rate within the tolerance of BR-CO-17 | | `QUITTIO-CANCELLATION-VAT-ALIGNED` | info | VAT of a partial cancellation or price reduction aligned with the earlier partial cancellations and price reductions of the original (cumulative rounding) | | `QUITTIO-LINE-ROUNDING` | warning | Declared line net amount differs from quantity × price ± allowances and charges | | `QUITTIO-ATTACHMENT-FILENAME` | error | File name of an attached document used twice | | `QUITTIO-ATTACHMENT-SIZE` | error | Attachments larger than `attachment_max_bytes` or `attachments_max_total_bytes` | | `QUITTIO-INVALID-CHARACTERS` | error | A text contains control characters (e.g. a vertical tab from a spreadsheet cell) or invalid UTF-8, which XML cannot represent; XML writers refuse such data | | `QUITTIO-GENERIC-COUNTRY` | warning | No country pack for the seller's country: only EN 16931 is checked | | `QUITTIO-PROFILE-NOT-EINVOICE` | warning | Profile that is no EN 16931 e-invoice (MINIMUM, BASIC WL) | | `QUITTIO-STANDARD-VERSION` | error | The profile does not support the EN 16931 version of the invoice | | `QUITTIO-PROFORMA` | error | Type code 325 in the invoice pipeline; use `Quittio::proforma()`, `$quittio->proforma()` or `DocumentBuilder::proforma()` ([documents](documents.md#proforma-invoices)) | ### Peppol rules The Peppol BIS Billing 3.0 Schematron (3.0.20) has 59 rule ids of its own (`PEPPOL-EN16931-…`, `PEPPOL-COMMON-…`); the national rules it contains (`NO-R-…`, `DK-R-…`, `SE-R-…` …) are not ported. In the Peppol profile the PHP rules check every rule that the data of an invoice can break. The others need no PHP rule: | Rules | Why there is no PHP rule | |---|---| | `PEPPOL-EN16931-R004` | The writer takes the specification identifier (BT-24) from the profile. | | `PEPPOL-EN16931-R043`, `-R044` | The writer writes the charge indicator itself, `false` for the price discount (BT-147). | | `PEPPOL-EN16931-R051` | The writer gives every amount the invoice currency (BT-5), BT-111 the VAT accounting currency (BT-6). | | `PEPPOL-EN16931-R053`, `-R054` | The writer writes one `cac:TaxTotal` with the VAT breakdown and a second one with BT-111 only together with BT-6. A missing breakdown or BT-111 is reported by `BR-CO-18` and `BR-53`. | | `PEPPOL-EN16931-R080`, `-R100`, `-R101` | The data holds one project reference (BT-11) and one invoiced object per line (BT-128); the writer gives the line reference the type code 130. | | `PEPPOL-EN16931-CL001`, `-CL002`, `-CL003`, `-CL006` | The lists equal those of `BR-CL-24`, `BR-CL-19`, `BR-CL-20` and `BR-CL-06`, which report the code once (`BR-CL-24` reports `MimeType::Xml`, the only case outside the list). | | `PEPPOL-COMMON-R048` | Commented out in the Schematron. | Where a Peppol rule overlaps an EN 16931 rule, the Peppol code is reported only for what the Peppol rule adds: `-CL007` for currencies of the EN 16931 list that the Peppol copy of ISO 4217 lacks (e.g. `XCG`), `-P0100` and `-P0101` for type codes of the EN 16931 list that business process 01 does not allow, `-R008` for optional values of only whitespace (the writer leaves out empty values; mandatory ones are reported as missing by `BR-02` …), `-R007` for a business process in another format (a missing one is `-R001`). The narrower code lists `CodeList::PEPPOL_CURRENCIES`, `PEPPOL_INVOICE_TYPES` and `PEPPOL_CREDIT_NOTE_TYPES` are generated from the Schematron like `PEPPOL_EAS` (`tools/codelists/update.php`). `PEPPOL-COMMON-R040` to `-R053` check the format and check digits of identifiers with the schemes 0088 (GLN), 0192, 0184, 0208, 0201, 0210, 9907 (electronic address only), 0211, 0007, 0151, 0096 and 0198 in electronic addresses (BT-34, BT-49), party identifiers (BT-29, BT-46, BT-60) and legal registration identifiers (BT-30, BT-47, BT-61). ### Plausibility (L7) | Code | Severity | Check | |---|---|---| | `QUITTIO-IBAN` | error | Check digits (ISO 13616, mod 97) of BT-84 and BT-91, for values that start like an IBAN | | `QUITTIO-BIC` | warning | Format of BT-86 | | `QUITTIO-VATID-FORMAT` | warning | Format of BT-31, BT-48 and BT-63 by country prefix (no check digits); unknown prefixes and small business identification numbers (suffix `EX`) are not judged | | `QUITTIO-SME-ID` | info | BT-31, BT-48 or BT-63 holds a small business identification number of the cross-border small business scheme (suffix `EX`, Article 284 (3) VAT Directive). It is no VAT identifier: a seller states it as tax registration (BT-32) | | `QUITTIO-EMAIL` | error / warning | Electronic addresses with scheme `EM` (BT-34, BT-49: error) and contact e-mails (BT-43, BT-58: warning) | | `QUITTIO-DUE-DATE` | warning | Due date (BT-9) before the issue date | | `QUITTIO-VAT-K-DOMESTIC` | warning | Category K (intra-community supply) with a destination in the seller's member state | | `QUITTIO-VAT-K-OUTSIDE-EU` | warning | Category K with a destination outside the EU VAT territory | | `QUITTIO-VAT-G-INSIDE-EU` | warning | Category G (export) with a destination inside the EU VAT territory | | `QUITTIO-VIES` | error | VIES reports the VAT identifier as invalid (only with a VAT identifier verifier) | | `QUITTIO-VIES-UNAVAILABLE` | info | VIES could not answer | The destination is the deliver-to country (BT-80), otherwise the buyer's country (BT-55). The seller's member state comes from the prefix of BT-31 or BT-63, otherwise from BT-40. Territories outside the EU VAT area (e.g. Heligoland, the Canary Islands) are recognised by postcode. The helpers are public: `Quittio\Core\Validation\Plausibility\Iban::isValid($iban)`, `Iban::normalize($iban)` and `VatIdFormat::isValid($vatId)` (`null` for an unknown prefix). ### VAT identifiers and VIES VIES is the EU service that confirms VAT identification numbers online. The online check is off by default. In Laravel, switch it on with `validation.drivers.vies.enabled = true` (`timeout` in seconds, default 5; `cache_ttl` in seconds, default 86400). A `Quittio\Core\Validation\Plausibility\VatIdVerifier` bound in the container replaces the VIES client, e.g. in tests. Without Laravel, give the PHP driver a verifier: ```php use Quittio\Core\Validation\Drivers\PhpRulesDriver; use Quittio\Core\Validation\Plausibility\ViesVerifier; $drivers = $quittio->validators(); $quittio->clearValidators(); foreach ($drivers as $driver) { $quittio->addValidator($driver instanceof PhpRulesDriver ? $driver->withVatIdVerifier(new ViesVerifier(timeout: 5, cacheTtl: 86400)) : $driver); } ``` `ViesVerifier` uses the VIES REST interface: - It checks only identifiers of EU member states (Greece `EL`) and Northern Ireland (`XI`) whose format is valid. Others are reported as not supported and skipped. - Only the answers "valid" and "invalid" are results. They are cached per verifier instance. - Errors and unreachable services give `valid = null`, are not cached and never block (`QUITTIO-VIES-UNAVAILABLE`). `verify($vatId)` returns a `VatIdVerification` with `vatId`, `valid`, `name`, `address`, `error`, `supported` and `toArray()`. Own verifiers implement `VatIdVerifier::verify(string $vatId): VatIdVerification` and must not throw when a service is unavailable. ## Own rules and drivers A driver implements `Quittio\Core\Validation\ValidationDriver` (`name()`, `levels()`, `supports(ValidationSubject $subject)`, `validate(ValidationSubject $subject): ValidationResult`). Its levels decide the stage: L6 runs on the PDF, L4 or L5 on the XML, everything else on the data. The subject holds: - `invoice`: the calculated `InvoiceData`, - `context`: the `ValidationContext` with `profile`, `countryPacks`, `locale`, `options`, `option()`, `intOption()`, `leadingCountry()`, `hasCountry()`, `profileIs()`, `translator()`, - `xml`, `syntax` and `pdf`. Rules are easiest written as `CallbackRule`: `CallbackRule::l3()`, `CallbackRule::l7()` or `new CallbackRule($code, $level, $fallback, $check, $namespace)`. The closure receives the invoice and a `RuleReporter` with `error()`, `warning()` and `info()` (arguments `$bt`, `$path`, `$replace`) and `context()`: ```php use Quittio\Core\Data\InvoiceData; use Quittio\Core\Validation\Rules\CallbackRule; use Quittio\Core\Validation\Rules\RuleReporter; use Quittio\Core\Validation\{ValidationDriver, ValidationLevel, ValidationResult, ValidationSubject}; final class AcmeRules implements ValidationDriver { public function name(): string { return 'acme'; } public function levels(): array { return [ValidationLevel::L3]; } public function supports(ValidationSubject $subject): bool { return true; } public function validate(ValidationSubject $subject): ValidationResult { $rule = CallbackRule::l3('ACME-PO', 'Invoices to :value need a purchase order number (BT-13).', function (InvoiceData $i, RuleReporter $report): void { if ($i->purchaseOrderReference === null) { $report->error('BT-13', 'purchaseOrderReference', ['value' => $i->buyer->name]); } }, namespace: 'acme'); return new ValidationResult([...$rule->check($subject->invoice, $subject->context)], $this->levels()); } } ``` Register it in Laravel and add its name to the levels. The factory receives the container and `validation.drivers.acme`: ```php laravel Quittio::extend('validator', 'acme', fn ($app, array $config) => new AcmeRules); // config/quittio.php: 'levels' => ['php', 'xsd', 'acme'] ``` ```php plain $quittio->addValidator(new AcmeRules); ``` Without Laravel: `$quittio->addValidator(new AcmeRules)`. The message of `ACME-PO` is looked up as `acme::rules.ACME-PO.message`, otherwise the fallback text is used. Register the catalog in Laravel with `loadTranslationsFrom(…, 'acme')`, in the core with `Translations::translator()->addPath($dir, 'acme')`. Other ways to add rules: - Implement `Quittio\Core\Validation\Rule` (`code()`, `level()`, `check(InvoiceData, ValidationContext): iterable`) and build the messages with `Messages::make()`. - Give such rules to `new PhpRulesDriver(additionalRules: [...])`. - Return them from a country pack (`rules()`, `buyerCountryRules()`) or a profile (`rules()`). Country packs may only add or tighten rules. `Quittio\Core\Validation\InvoiceValidator` runs a list of drivers on a `ValidationSubject` outside a render run. ## Switching rules off and changing their severity Every PHP rule is addressed by the code of its messages, e.g. `DE-USTG-15` or `QUITTIO-PRECISION`. `validation.rules` switches rules off, changes the severity of their findings or, with an own implementation, replaces them. A trailing `*` matches by prefix: ```php laravel // config/quittio.php 'validation' => [ 'rules' => [ 'disabled' => ['QUITTIO-GENERIC-COUNTRY', 'DE-USTG-1*'], 'severity' => ['DE-USTG-08' => 'warning', 'QUITTIO-*' => 'info'], 'allow_official' => false, ], ], ``` ```php plain use Quittio\Core\Quittio; use Quittio\Country\DE\CountryDE; $quittio = Quittio::create([ 'validation' => [ 'rules' => [ 'disabled' => ['QUITTIO-GENERIC-COUNTRY', 'DE-USTG-1*'], 'severity' => ['DE-USTG-08' => 'warning', 'QUITTIO-*' => 'info'], 'allow_official' => false, ], ], ], [new CountryDE]); ``` - `disabled` drops the rules and every finding with a matching code. Rules that report several codes are covered too, e.g. `QUITTIO-PROFILE-NOT-ALLOWED` of the field matrix. - `severity` sets `error`, `warning` or `info`. An exact code wins over a prefix, a longer prefix over a shorter one. - A code that no rule has throws a `ConfigurationException` when the core is built, so typing errors do not switch nothing off silently. `$quittio->ruleCodes()` lists the known codes. - The rules of EN 16931 (`BR-…`) and Peppol (`PEPPOL-…`) are official: receivers and the KoSIT validator reject invoices that break them. Changing them needs `'allow_official' => true`. - The overrides change the PHP rules only (L1, L2, L3, L7). The findings of the XML schema, KoSIT and veraPDF are never changed. A rule of your own replaces a rule with the same code: ```php laravel use Quittio\Core\Validation\Rules\CallbackRule; use Quittio\Core\Validation\Rules\RuleReporter; use Quittio\Laravel\Facades\Quittio; Quittio::extend('rule', 'DE-USTG-15', fn ($app) => CallbackRule::l7('DE-USTG-15', 'Own check of the service date.', function ($invoice, RuleReporter $report): void { // … }, namespace: 'quittio-de')); ``` ```php plain use Quittio\Core\Validation\RuleOverrides; use Quittio\Core\Validation\Rules\CallbackRule; use Quittio\Core\Validation\Rules\RuleReporter; $quittio->configureRules(new RuleOverrides(replacements: ['DE-USTG-15' => CallbackRule::l7('DE-USTG-15', 'Own check of the service date.', function ($invoice, RuleReporter $report): void { // … }, namespace: 'quittio-de')])); ``` Without Laravel, `Quittio::create()` reads the same keys under `validation.rules`, and `configureRules()` sets them on an instance: ```php use Quittio\Core\Validation\RuleOverrides; use Quittio\Core\Validation\Severity; $quittio->configureRules(new RuleOverrides( disabled: ['QUITTIO-GENERIC-COUNTRY'], severities: ['DE-USTG-08' => Severity::Warning], replacements: ['DE-USTG-15' => $ownRule], )); ``` ## Incoming files To check e-invoices you receive, validate the file itself: ```php laravel $report = Quittio::validateFile($content); // content (bytes) of an XML or PDF e-invoice, never a path $report = Quittio::validatePath($path); // the same from a local file ``` ```php plain $report = $quittio->validateFile($content); // content (bytes) of an XML or PDF e-invoice, never a path $report = $quittio->validatePath($path); // the same from a local file ``` Both read the file ([Reading incoming invoices](reading.md)) and run every configured driver that supports it, independent of the stage and of `validation.mode`. - They never throw a `ValidationException`. The reader exceptions (`UnsafeXmlException`, `PdfException`, `UnreadableInvoiceException`) are thrown. - The result starts with the reader's findings (level L1, `QUITTIO-DECLARED-TOTALS` L3). - The rules use the profile detected from the specification identifier (BT-24), otherwise the configured default profile. They also use the country packs of the parties and the syntax of the file. - XSD and KoSIT check the XML; for a PDF, the embedded XML. veraPDF runs only when the input was a PDF. - The read data is checked as declared, without recalculation. On the command line: ```bash php artisan quittio:validate invoice.pdf --profile=en16931 --kosit --verapdf --json ``` `--profile` fails the command when the detected profile differs. `--kosit` and `--verapdf` add the drivers for this call with the configured `validation.drivers.*` settings (see [Artisan commands](commands.md)). ## Mandatory field guard The template decides what the PDF shows. After rendering a PDF or HTML invoice, the guard checks that the template printed every mandatory value: invoice number and date, names and addresses, quantities and units, VAT rows, amount due, legal notes and the values the country pack requires. It does not run for [documents](documents.md). | Mode | Behaviour | |---|---| | `exception` | throws `Quittio\Core\View\MandatoryFieldMissing` (`$e->fields`: list of `MandatoryField` with `accessKey`, `description`, `legalBasis`) | | `log` | logs a warning (PSR-3 logger) and continues | | `off` | no check | Set the mode with `validation.mandatory_field_guard` (Laravel; default `exception` outside production, `log` in production) or `mandatory_fields` (`Quittio::create()`, default `exception`). In every mode except `off`, a missing value calls the listener of `$quittio->onMandatoryFieldsMissing(fn (InvoiceData $invoice, array $fields) => …)`. Laravel dispatches the event `Quittio\Laravel\Events\MandatoryFieldMissing($invoice, $fields)`. Which values count as printed is described in [Templates](templates.md#mandatory-field-guard). ## Germany: BMF error classes The German Federal Ministry of Finance (BMF) groups e-invoice errors into classes in its letter of 15 October 2025. The German country pack sorts findings into these classes: ```php use Quittio\Country\DE\CountryDE; use Quittio\Country\DE\Rules\BmfErrorClass; $classes = (new CountryDE)->errorClassification($result); // ['format' => [...], 'business_rule' => [...], 'content' => [...]] BmfErrorClass::of($message)->label('de'); // "Formatfehler (Rz. 6a)", the German label of "format error (marginal no. 6a)" ``` Errors and warnings (no infos) are grouped by class: | Class | Value | Findings | `voidsEInvoice()` | |---|---|---|---| | Format error (marginal no. 6a) | `format` | L1, L2, L4, L6 | `true` | | Business rule error (marginal no. 6b) | `business_rule` | L3, L5 | `false` | | Content error (marginal no. 35a) | `content` | every `DE-USTG-…` rule, L7 | `false` | `label(string $locale = 'de')` returns the German name, any other locale the English name. Classes without findings are not in the array. ## JSON input Invoice data can also arrive as JSON, e.g. from an API. Check it against the shipped schema (`packages/core/resources/schema/invoice.schema.json`, `JsonSchemaGenerator::defaultPath()`) before hydrating it. This needs the optional package `opis/json-schema`: ```php use Quittio\Core\Serialization\JsonSchemaValidator; use Quittio\Core\Data\InvoiceData; if (JsonSchemaValidator::available()) { $errors = (new JsonSchemaValidator)->validate($json); // list "path: message", at most 20; [] = valid } $invoice = InvoiceData::fromJson($json); ``` Without the package, `validate()` throws a `RuntimeException`; invalid JSON throws a `JsonException`. The schema checks the structure only. The business rules run when the invoice is rendered or checked. # Templates and design This page explains how Quittio prints an invoice or a [document](documents.md) (quote, reminder …) as PDF or HTML, and how you change its look. Read it when you want your own logo, colours, texts or layout. The first sections need no template knowledge; the [view model](#view-model) reference at the end is for writing own templates. The design only affects the PDF and HTML, never the e-invoice XML ([What an e-invoice is](concepts.md#what-an-e-invoice-is)). ## Design levels You can change the design on four levels. Start with level 1 and go further only when it is not enough. | Level | Use it when you want to | What you do | |---|---|---| | 1 – Configuration | Set logo, colours, font, texts, footer, sender line, letter layout, paper or QR code | Set `pdf.*` in `config/quittio.php`, or pass a [`Presentation`](#presentation) per invoice or per call ([Logo, colours and texts](#logo-colours-and-texts-level-1)) | | 2 – Partials | Change one part of the default template, e.g. the payment block | `php artisan vendor:publish --tag=quittio-views` and change single partials ([Changing single partials](#changing-single-partials-level-2)) | | 3 – Own template | Use a layout of your own | `php artisan make:quittio-template my-design`, then `->template('invoices.my-design.layout')` or `pdf.template` ([Own templates](#own-templates-level-3)) | | 4 – Own renderer | Create the PDF with another engine, e.g. Browsershot or Gotenberg | `Quittio::extend('renderer', …)` ([PDF renderers](#pdf-renderers)); PDF/A and the embedded XML stay with the package | PDF/A is the PDF variant for long-term archiving. A ZUGFeRD/Factur-X invoice is a PDF/A-3 file with the XML embedded ([Formats](concepts.md#formats)). Templates only display data. Quittio prepares totals, VAT, the texts of the payment terms, QR codes and labels in the [view model](#view-model) before the template runs. The same data also produces the XML. After rendering, the [mandatory field guard](#mandatory-field-guard) checks that the template printed every value an invoice must show. ## Default templates Quittio ships one default design in two template engines. Both print the same document. | Engine | Template | Used by | |---|---|---| | Blade | `quittio::templates.default.layout` with partials in `quittio::templates.default.partials` | Laravel (`pdf.template`) | | Plain PHP | `packages/core/resources/templates/default.php` | `Quittio::create()` without Laravel (template `default`); Laravel falls back to it for names that are no Blade view | The PDF is created by mPDF, a PHP library that converts the HTML of the template into a PDF ([PDF renderers](#pdf-renderers)). Optionally, Fagus renders the same templates ([Fagus](#fagus)). To see the result with your configuration, render the sample invoices with `php artisan quittio:preview` or open the preview route ([HTML output and preview](#html-output-and-preview)). ### Page layout The default templates print A4 pages ([Paper size](#paper-size)) with a left margin of 20 mm and a right margin of 19 mm, in the font Geist ([Fonts](#fonts)). The issuer is the party that sends the document: the seller, or the buyer on a self-billed invoice (German "Gutschrift", see [German terms](concepts.md#german-terms)). - **First page:** the logo (at most 14 mm high) or the issuer's name in the primary colour at the top left, 15 mm from the top edge. Below it is the address field at the position of the [letter layout](#letter-layouts): the sender line at its top and the recipient directly below. The invoice details (number, dates, references …) are on the right at the same height. Then follow the title, the line table, the totals with the gross total (or the amount due) in the primary colour, and the payment block. - **Following pages:** a header with the logo or name on the left, and the title with number, the recipient with customer number and the invoice date on the right. The line table continues below the header with its column heads. - **Every page:** the footer with up to four columns (address; phone and e-mail; register and legal information; VAT identifier and tax number) and the page number. Which elements use which colour is listed in [Design](#design). ### Carry-over across pages When the line table continues on the next page, the default templates print a running total at the break: - The last row of the page reads "Continued on page 2", "Carried forward" and the sum of the line amounts so far. The German output is "Fortsetzung auf Seite 2" (continued on page 2) and "Übertrag" (carried forward). - The first row of the next page reads "Brought forward from page 1" (German "Übertrag von Seite 1") with the same amount. The mPDF renderer does this. It lays the document out once. Only if the line rows land on more than one page, it lays the document out again with space reserved for the carry rows, finds the page breaks, splits the table there and inserts the rows. Single-page documents are rendered once. Documents without prices (delivery notes) get no carry-over. The [Fagus renderer](#fagus) puts the carry rows into the head and the foot of the line table, where Fagus shows them only at page breaks; the document is laid out once. Own templates can use the same mechanism ([Carry-over in own templates](#carry-over-in-own-templates)). ## Logo, colours and texts (level 1) Most designs need only configuration. Set the defaults for all invoices in `config/quittio.php` ([Configuration](configuration.md)); without Laravel, pass them as `presentation` to `Quittio::create()` ([Without Laravel](getting-started.md#without-laravel)): ```php laravel // config/quittio.php 'pdf' => [ 'logo' => storage_path('app/logo.png'), // PNG, JPEG or SVG 'colors' => ['primary' => '#0f766e', 'text' => '#15171c', 'muted' => '#5f6470', 'secondary' => null], 'font' => 'geist', // or 'inter', or a registered font 'texts' => ['salutation' => null, 'intro' => 'Thank you for your order.', 'closing' => 'Kind regards'], 'sender_line' => null, // null: generated from the seller 'footer_columns' => [], // []: generated from the seller ], ``` ```php plain use Quittio\Core\Data\Presentation\Colors; use Quittio\Core\Data\Presentation\Presentation; use Quittio\Core\Quittio; use Quittio\Country\DE\CountryDE; $quittio = Quittio::create([ 'presentation' => new Presentation( logo: __DIR__.'/logo.png', // PNG, JPEG or SVG colors: new Colors(primary: '#0f766e', text: '#15171c', muted: '#5f6470'), font: 'geist', // or 'inter', or a registered font introText: 'Thank you for your order.', closingText: 'Kind regards', ), ], [new CountryDE]); ``` To change the design of one invoice, call `->presentation()` on the builder. The design is stored with the invoice data, so the invoice looks the same when it is rendered again. To change it for one render call only, e.g. for a second brand, call `->presentation()` on `Quittio::make()`: ```php laravel use Quittio\Core\Data\Presentation\Colors; use Quittio\Core\Data\Presentation\Presentation; use Quittio\Laravel\Facades\Quittio; $invoice = Quittio::invoice() // ... ->presentation(['introText' => 'Thank you for your order.', 'letterLayout' => 'din5008a']) // this invoice ->build(); $result = Quittio::make($invoice) ->presentation(new Presentation(logo: storage_path('app/brand-b.png'), colors: new Colors(primary: '#7c3aed'))) // this call ->render(); ``` ```php plain use Quittio\Core\Data\Presentation\Colors; use Quittio\Core\Data\Presentation\Presentation; $invoice = $quittio->invoice() // ... ->presentation(['introText' => 'Thank you for your order.', 'letterLayout' => 'din5008a']) // this invoice ->build(); $result = $quittio->make($invoice) ->presentation(new Presentation(logo: __DIR__.'/brand-b.png', colors: new Colors(primary: '#7c3aed'))) // this call ->render(); ``` The invoice's own presentation wins over the presentation of the call, which wins over the configuration. The rules are in [Presentation](#presentation). In the plain PHP examples, `$quittio` is created as in [Without Laravel](getting-started.md#without-laravel), with your company as `seller`. | You want to change | Setting | Details | |---|---|---| | Logo | `pdf.logo`, `Presentation::$logo` | [Logos](#logos) | | Colours | `pdf.colors`, `Presentation::$colors` | [Presentation](#presentation), [Design](#design) | | Font | `pdf.font`, `pdf.fonts` | [Fonts](#fonts) | | Salutation, intro and closing text | `pdf.texts.*` | [Texts and Markdown](#texts-and-markdown) | | Footer columns and sender line | `pdf.footer_columns`, `pdf.sender_line` | [Presentation](#presentation), [Design](#design) | | Position of the address field, fold marks | `pdf.layout`, `pdf.fold_marks` | [Letter layouts](#letter-layouts) | | Paper size | `pdf.paper` | [Paper size](#paper-size) | | Payment QR code | `pdf.payment_qr.*` | [Payment QR codes](#payment-qr-codes) | | Single printed texts, e.g. "Amount due" | `Presentation::$labels`, language files | [Translations and locales](#translations-and-locales) | | Title of the document | `Presentation::$title` | [Presentation](#presentation) | | Draft marker | option `watermark` | [Watermark](#watermark) | ### Presentation `Quittio\Core\Data\Presentation\Presentation` holds everything that only affects the PDF and HTML. It is never written to the XML. | Property | Default | Effect | Laravel configuration | |---|---|---|---| | `template` | `null` | Template of this invoice ([Selecting a template](#selecting-a-template)) | `pdf.template` | | `logo` | `null` | Logo ([Logos](#logos)) | `pdf.logo` | | `colors` | `null` | `Colors(primary: '#2741d9', text: '#15171c', muted: '#5f6470', secondary: null)` | `pdf.colors.primary`, `text`, `muted`, `secondary` | | `font` | `null` (`geist`) | Font family ([Fonts](#fonts)) | `pdf.font` | | `senderLine` | `null` (generated) | Sender line above the address | `pdf.sender_line` | | `letterLayout` | `null` (country default) | [Letter layout](#letter-layouts) | `pdf.layout` | | `salutation` | `null` | Plain text before the intro | `pdf.texts.salutation` | | `introText`, `closingText` | `null` | Markdown texts before the lines and at the end | `pdf.texts.intro`, `pdf.texts.closing` | | `footerColumns` | `[]` (generated) | `list>`, one list of lines per column | `pdf.footer_columns` | | `lineGroups` | `[]` | `list` (`id`, `title`, `showSubtotal = true`) | – (`InvoiceBuilder::group()`) | | `showGrossPrices` | `false` | Print the price including VAT below the net unit price | – | | `showItemNumbers` | `false` | Print the seller's item number (BT-155) after the item name | `pdf.show_item_numbers` | | `paymentQr` | `auto` | [Payment QR code](#payment-qr-codes): `auto`, `girocode`, `swiss-qr-bill`, `none` | `pdf.payment_qr.type` | | `watermark` | `null` | [Watermark](#watermark) text | – (option `watermark`) | | `paper` | `A4` | [Paper size](#paper-size) | `pdf.paper` | | `labels` | `[]` | Label overrides, e.g. `['amount_due' => 'Total to pay']` | – | | `title` | `null` | Title instead of the type code label; also used in the file name and the PDF title | – | | `explicit` | `[]` | Properties whose value wins even when it equals the default | – | BT-155 and the other BT numbers name the fields of the European standard EN 16931 ([Business terms](concepts.md#en-16931-and-business-terms)). Hints for single lines are `LinePresentation` objects (`groupId`, `highlight`, `showGrossPrice`). The line builder sets them: - `LineBuilder::group($groupId)` puts the line into a line group. - `highlight()` shades the line. - `showGrossPrice(?bool $show = true)` prints the price including VAT of this line, or with `false` not, whatever `showGrossPrices` says. `null` follows the presentation. ```php laravel use Quittio\Core\Builder\Line; use Quittio\Core\Data\Presentation\Colors; use Quittio\Core\Data\Presentation\Presentation; use Quittio\Laravel\Facades\Quittio; $invoice = Quittio::invoice() // ... ->presentation(['logo' => storage_path('app/logo.png'), 'introText' => 'Thank you for your order.']) ->group('hardware', 'Hardware') // line group with subtotal ->line(Line::make('Router', netPrice: '89.00', quantity: 2)->group('hardware')) // group(): Line::make() ->build(); Quittio::make($invoice) ->presentation(new Presentation(colors: new Colors(primary: '#0f766e'), labels: ['amount_due' => 'Total to pay'])) ->render(); ``` ```php plain use Quittio\Core\Builder\Line; use Quittio\Core\Data\Presentation\Colors; use Quittio\Core\Data\Presentation\Presentation; $invoice = $quittio->invoice() // ... ->presentation(['logo' => __DIR__.'/logo.png', 'introText' => 'Thank you for your order.']) ->group('hardware', 'Hardware') // line group with subtotal ->line(Line::make('Router', netPrice: '89.00', quantity: 2)->group('hardware')) // group(): Line::make() ->build(); $quittio->make($invoice) ->presentation(new Presentation(colors: new Colors(primary: '#0f766e'), labels: ['amount_due' => 'Total to pay'])) ->render(); ``` **How presentations are merged.** The design of a run is built property by property from three layers: the invoice presentation over the presentation of the call (`->presentation(...)`) over the configured design. - A value that equals the default of an empty `Presentation` (`false`, `[]`, `'auto'`, `'A4'`, `null`) counts as not set and keeps the value of the layer below. - Objects such as `colors` replace the value below as a whole. - Labels are merged key by key. - To reset a configured value for one invoice, name the property in `explicit`. Example: `new Presentation(showGrossPrices: false, paper: 'A4', footerColumns: [], explicit: ['showGrossPrices', 'paper', 'footerColumns'])` switches gross prices off, prints on A4 although `pdf.paper` is Letter, and prints no footer columns. **Checks.** Values are checked when rendering; invalid values throw a `ConfigurationException`: - colours must be hex values (`#2741d9` or `#fff`); - fonts must be plain family names (letters, digits, space, `_` and `-`, at most 64 characters); - letter layouts and payment QR code types must be known. An unknown `pdf.payment_qr.type` already fails when the Laravel configuration is mapped (first use of the facade). **Render options.** Some design settings are render options: per call with `->option()`, without Laravel also in the `options` key of `Quittio::create()`. They are `fold_marks` (bool, default `true`), `markdown` (bool), `paper` (string), `watermark` (string), `girocode_amount` (`due`, `discounted`) and `logo_cache` (directory). ### Logos Set the logo with `pdf.logo` or `Presentation::$logo`. The default templates print it at the top left of the first page and in the header of the following pages. - Logos are local files, data URIs or `http`/`https` URLs of PNG, JPEG or SVG images, at most 10 MB and 25 megapixels. Other stream wrappers (`ftp://`, `php://`, `phar://` …), a leading `//`, backslashes and surrounding whitespace fail with a `ConfigurationException`, as does a local file that does not exist. - A data URI is decoded strictly, checked and re-encoded, so only validated bytes reach the renderer. - Remote logos are downloaded by Quittio on every render (no cache), with a 10 s timeout and at most 3 redirects, each checked again. Quittio downloads only from hosts whose every IPv4 and IPv6 address is public: no loopback, private, link-local, shared, reserved, documentation or multicast range, also not inside NAT64 addresses. The connection is pinned to the checked address, and TLS is verified for the host name. A refused address fails with a `ConfigurationException`; an unreachable logo is left out. The downloaded copy is embedded as data URI (also in HTML output). - Raster logos larger than 600 × 200 px are scaled down with GD (transparency is kept). Scaled copies of local files are cached in the logo cache: `pdf.cache_path`/`logos`, without Laravel `temp_dir`/`logos`, default `sys_get_temp_dir()/quittio-mpdf/logos`. - For PDF/A (ZUGFeRD/Factur-X, XRechnung in PDF, or `pdf.pdfa = true`), every logo is re-encoded as RGB PNG on white, because PDF/A forbids the alpha channel mPDF writes. SVG is rasterised with the PHP extension `imagick` (SVG coder only, 300 dpi but at most twice the logo size). Without `imagick`, an SVG logo fails with a `ConfigurationException` in PDF/A documents. - SVG logos must be self-contained: no `href` or `url()` to files, URLs or nested SVG (embedded PNG, JPEG, GIF or WebP data URIs are allowed) and no entity declarations. - mPDF never fetches anything itself ([PDF renderers](#pdf-renderers)). - In HTML output, a local logo is referenced by its file path, which browsers cannot load. Use a URL or data URI for logos in HTML that is shown in a browser. - Local logo paths and URLs are trusted configuration. Do not take `Presentation::$logo` or issuer branding from end users unless your application validates them (e.g. an uploaded file stored by the application). ### Fonts Three fonts are bundled (SIL Open Font License): | Family | Files | Script | |---|---|---| | `geist` (default, `pdf.font = 'geist'`) | Regular, Bold, Italic, Bold Italic; `geistmedium` with Medium and SemiBold | Latin and Cyrillic | | `inter` | Regular, Bold, Italic, Bold Italic | Latin, Cyrillic and Greek | | `liberationsans` | Regular, Bold; used for the [payment slip](#payment-slips) | Latin, Cyrillic and Greek | Set `pdf.font = 'inter'` for Greek names or texts: mPDF prints no characters the font does not have. The font name is used as CSS `font-family` in the templates and as default font of mPDF. Register more fonts in the `pdf` section of `config/quittio.php`, without Laravel on the renderer: ```php laravel 'font' => 'corporate', 'fonts' => ['corporate' => ['R' => 'Corporate-Regular.ttf', 'B' => 'Corporate-Bold.ttf', 'I' => 'Corporate-Italic.ttf', 'BI' => 'Corporate-BoldItalic.ttf']], 'font_directories' => [resource_path('fonts')], ``` ```php plain use Quittio\Core\Data\Presentation\Presentation; use Quittio\Core\Pdf\Renderers\MpdfRenderer; use Quittio\Core\Quittio; use Quittio\Country\DE\CountryDE; $quittio = Quittio::create(['presentation' => new Presentation(font: 'corporate')], [new CountryDE], renderer: new MpdfRenderer( fonts: ['corporate' => ['R' => 'Corporate-Regular.ttf', 'B' => 'Corporate-Bold.ttf', 'I' => 'Corporate-Italic.ttf', 'BI' => 'Corporate-BoldItalic.ttf']], fontDirectories: [__DIR__.'/fonts'], defaultFont: 'corporate', )); ``` - Use lower case family names, as mPDF looks fonts up in lower case. - Fonts must be embeddable TrueType fonts (PDF/A embeds all fonts). - `php artisan vendor:publish --tag=quittio-fonts` copies Geist, Inter and Liberation Sans to `resources/fonts/quittio/geist`, `…/inter` and `…/liberation`. - The Laravel renderer searches `pdf.font_directories`, then `resources/fonts/quittio` and its subdirectories automatically. Fonts placed there only need an entry in `pdf.fonts`. - Font files are taken from the first directory that has them. The configured directories come before the bundled fonts and those of mPDF, so a published and edited font replaces the bundled one. - Without Laravel, pass the fonts to the renderer: `new MpdfRenderer(tempDir: …, fonts: [...], fontDirectories: [...], defaultFont: 'corporate')`. - The [Fagus renderer](#fagus) takes the same settings and prints the same families with the same files. ### Letter layouts A letter layout fixes the address field on the first page, so that the recipient appears in the window of a window envelope. It is a `Quittio\Core\View\LetterLayout` with these values in mm (defaults in parentheses): `name`, `addressTop` (45), `addressLeft` (20), `addressWidth` (85), `addressHeight` (45), `senderLineHeight` (5), `foldMarks` (`[]`), `punchMark` (`null`) and `addressZoneTop` (17.7). `LetterLayout::free()` is the layout without norm. The layout is `Presentation::$letterLayout` (`pdf.layout`), otherwise the country pack default, otherwise `free`. Country packs provide layouts with `letterLayouts()`; an unknown name fails with a `ConfigurationException` listing the known layouts. The German pack provides layouts after DIN 5008, the German standard for business letters: | Layout | Address field from the top | Fold marks | Punch mark | |---|---|---|---| | `din5008a` (form A) | 27 mm | 87 and 192 mm | 148.5 mm | | `din5008b` (form B, default) | 45 mm | 105 and 210 mm | 148.5 mm | | `free` | 45 mm (layout default) | none | none | The default templates print the sender line at the top of the address field and the recipient directly below it, both inside the window of a window envelope. DIN 5008 divides the address field into zones; own templates can use them (`design.addressZoneTop`, `design.noticeZoneHeight`, see [Design](#design)). Fold and punch marks are printed at the left edge unless `pdf.fold_marks` (option `fold_marks`) is `false`. See [Country packs](country-packs.md#din-5008-letter-layouts). ### Paper size The paper is the first of: 1. the invoice presentation's `paper`, the presentation of the call and the configured presentation, each only when it is not `A4` or names `paper` in `explicit`; 2. the option `paper` (`pdf.paper`); 3. the country pack default (Germany: A4). `pdf.paper = null` uses the country default; a configured size wins, also `A4`. The value is a page format of mPDF such as `A4`, `A5` or `Letter`. ### Watermark A watermark marks drafts and previews: `->option('watermark', 'DRAFT')` or `Presentation::$watermark`. - Watermarked PDFs are rendered without PDF/A, because PDF/A does not allow the transparency of watermarks. - They never contain e-invoice XML. A watermark together with any format that produces XML (also next to `pdf` in `formats([...])`) throws a `ConfigurationException`, so a draft can never pass as an e-invoice. - The default templates print it with mPDF's `` (alpha 0.08) and, for browsers, as rotated CSS overlay (`design.watermarkCss`). The [Fagus renderer](#fagus) prints the `` and leaves the overlay out. - The labels `draft` and `preview` can be used as text: "DRAFT" and "PREVIEW", in German "ENTWURF" (draft) and "VORSCHAU" (preview). ### Payment QR codes The default templates print a QR code next to the bank details that banking apps can scan to fill in the transfer. The type is set with `Presentation::$paymentQr` (`pdf.payment_qr.type`): | `paymentQr` | Generator | |---|---| | `auto` (default) | A registered generator (`setPaymentQrGenerator()`, Laravel `pdf.payment_qr.generator`). Otherwise what the country pack names in `CountryDefaults::$paymentQr`: `none` prints no code; for other values the country pack's generator (`paymentQr()`), otherwise the EPC GiroCode for `girocode` (the default, also without country pack) and no code for other types | | `girocode` | EPC GiroCode, the European QR code for SEPA credit transfers | | `swiss-qr-bill` | The generator registered with `setPaymentQrGenerator()` (Laravel: `pdf.payment_qr.generator`), otherwise the QR bill of the country pack Switzerland ([`quittio/country-ch`](country-ch.md#qr-bill)) for its sellers. Without either, the render run fails with a `ConfigurationException` | | `none` | No code | No code is printed on refunds (credit notes, negative invoices) and on self-billed invoices. The EPC GiroCode (`EpcGiroCodeGenerator`, standard EPC069-12 version 002) is created when: - the currency is EUR, - the payment means is a (SEPA) credit transfer (code 30 or 58) with a valid IBAN, - and the amount due is between 0.01 and 999,999,999.99. Its payload contains the BIC (optional), the IBAN, the amount, the beneficiary (payee name, otherwise account name, otherwise seller name, at most 70 characters) and the remittance information (BT-83, otherwise the invoice number, at most 140 characters); in total at most 331 bytes. `pdf.payment_qr.girocode_amount` (option `girocode_amount`) is `due` (the amount due) or `discounted` (the amount after the first cash discount). With `discounted`, `qrCode.note` says until when the code is valid ("QR code with the amount after cash discount (…), valid until …"). Payment reminders get a code over the total of the reminder ([Payment reminders](documents.md#payment-reminders)). `payment.qrCode` in the view model holds `type` (e.g. `girocode`), `payload`, `dataUri` (PNG data URI rendered with GD, SVG without GD; PNG because mPDF's SVG output violates PDF/A), `amount` and `note`. `Quittio\Core\Pdf\Qr\QrImage::svg()`, `png()` and `dataUri()` render any payload; `border: false` leaves out the quiet zone of four modules (the code alone, as on the payment slip). Own generators implement `PaymentQrGenerator` (`key()`, `supports(InvoiceData)`, `payload(InvoiceData, array $options)`) and are returned by a country pack's `paymentQr()`. The default templates caption a GiroCode with the label `girocode` ("GiroCode") and other codes printed next to the bank details with the label `payment_qr` ("QR-Code zum Bezahlen", "Scan to pay"). #### Payment slips A generator that also implements `Quittio\Core\Pdf\Qr\ProvidesPaymentSlip` (`slip(InvoiceData $invoice, string $payload, string $locale): ?PaymentSlip`; also called for the code of a payment reminder, whose payload carries the reminder total) prints its code on a payment slip instead of next to the bank details, laid out after the payment part of the Swiss QR bill: a receipt of 62 mm and a payment part of 148 mm, 105 mm high, at the bottom of a page of its own without footer, the code at 46 × 46 mm without quiet zone, separated by dashed lines with a note. `PaymentSlip` holds the titles, the headed sections of payment part and receipt (a section without lines and a missing amount are printed as empty fields to fill in by hand), the currency and amount with their headings, the acceptance point, the separation note and an optional image in the middle of the code (`mark`, e.g. the Swiss cross). The texts are printed in Liberation Sans, which Quittio bundles for it. `payment.qrCode.slip` in the view model holds these values (`title`, `receiptTitle`, `sections[].heading`, `sections[].lines`, `receiptSections`, `currencyHeading`, `amountHeading`, `currency`, `amount`, `acceptancePoint`, `separationNote`, `mark`) and `dataUri`, the code without quiet zone; codes without slip have no `slip`. Own templates print the slip with the partial `payment-slip` (Blade) or the end of `default.php`. ### Texts and Markdown Line descriptions and notes are also part of the e-invoice XML. The templates therefore print them as plain text (`lines[].description.html`, `notes[].html`: escaped, line breaks kept). With `pdf.markdown = true` (option `markdown`) they are rendered as Markdown: paragraphs, lists, bold and italic. HTML is shown as text, and links keep only their text. Formatting changes the displayed text compared with the XML. For example, `20*30*40 cm` is shown as "20*30*40 cm" with "30" in italics and without the asterisks. Keep the option off for texts that must match the XML. Intro and closing texts (`texts.intro`, `texts.closing`) are PDF-only and always Markdown. The salutation is plain text. ### Translations and locales The locale (language) of a run is the first of: 1. `->locale()` of the call, 2. the invoice's locale (`InvoiceBuilder::locale()`), 3. `defaults.locale` (`locale` in `Quittio::create()`), 4. the country pack default (Germany: `de`). A regional locale such as `de_CH` or `de-AT` takes the texts of its language (`de`) where it has none of its own, and English after that; numbers and dates follow the regional locale (with `intl`). Labels and code names (units, VAT categories, payment means, type codes …) exist in German, English, French and Dutch; other locales fall back to English. The XML texts generated for the run (e.g. payment terms) use the same locale. | Source | Where | |---|---| | Shipped labels | `packages/core/resources/lang/{de,en,fr}/labels.php` (namespace `quittio`) | | Code names | `codes.php`, payment terms texts `terms.php` | | Laravel overrides | `lang/vendor/quittio/{locale}/labels.php` (`php artisan vendor:publish --tag=quittio-lang`) | | Country pack overrides | `quittio-{code}::labels.{key}` in the pack's `translationPath()` | | Per invoice or call | `Presentation::$labels` | Without Laravel, the translator is `Quittio\Core\I18n\ArrayTranslator` (files `{path}/{locale}/{group}.php`, later paths override earlier ones, fallback `en`). Add a directory with `Translations::translator()->addPath($path, 'quittio')`, or replace the translator with `Translations::use(new MyTranslator)` (`Quittio\Core\I18n\Translator`: `get()`, `has()`, `locale()`, `addPath()`). The Laravel integration bridges to Laravel's translator. Values are formatted by `IntlFormatter` from their exact decimal value: - amounts with two decimals and the currency symbol (`€`, `$`, `£`, `CHF`, otherwise the code; English puts `$` and `£` in front); - prices with at least two decimals; - quantities and rates without trailing zeros; - separators from `ext-intl` (fallback: German and English conventions); - dates as `dd.MM.yyyy` (de), `dd/MM/yyyy` (fr, it, es, pt, nl, en), `MM/dd/yyyy` (`en_US`) and the medium date format of `ext-intl` for other locales. Country names come from `ext-intl`. ## HTML output and preview `->format('html')` returns the rendered template without PDF (`$result->html()`); documents use `->htmlOnly()`. The HTML is the same markup mPDF receives; the watermark is shown with CSS. The preview route `/_quittio/preview` lists the sample scenarios (`simple`, `many-lines`, `long-texts`, `mixed-vat`, `reverse-charge`, `intra-eu`, `export`, `cancellation`, `sub-lines`, `foreign-currency`, `b2c-gross`, `allowances`, `attachments`, `peppol`). It shows them as HTML or, with `?format=pdf`, as PDF, with a "PREVIEW" watermark, the configured design and validation in mode `warn` (errors are reported, not thrown). - The route exists in the local environment, or with `quittio.preview.enabled = true`; outside `local` the gate `viewQuittioPreview` must allow the request ([Preview route](laravel.md#preview-route)). Its path is `quittio.preview.path`, its middleware `quittio.preview.middleware`. It is not registered while routes are cached. - `?template=` accepts the views that rendering accepts ([Selecting a template](#selecting-a-template)): `default`, the configured `pdf.template`, the views under `quittio::templates.` and the views of `pdf.templates`, never partials; the view must exist. - `?locale=` accepts a locale code. - Other values return 404. More in [Preview route](laravel.md#preview-route). On the command line: ```bash php artisan quittio:preview --scenario=many-lines --format=pdf --locale=en --output=/tmp/preview.pdf ``` The command writes to `storage/app/quittio/preview/{scenario}.{format}` by default; `--template` accepts the same templates as the route. ## Changing single partials (level 2) The Blade layout is split into partials, one per part of the page. To change one part, publish the views and edit the copy of that partial: ```bash php artisan vendor:publish --tag=quittio-views # copies the views to resources/views/vendor/quittio/templates ``` Laravel then uses your copy of a partial instead of the shipped one. You can delete the copies you did not change; for those, Laravel uses the shipped partials, which follow package updates. The layout takes the partial prefix from the variable `$partials` (default `quittio::templates.default.partials`). | Partial | Content | |---|---| | `styles` | CSS: page margins (first and following pages), font, colours, address field position, watermark for browsers | | `header` | `` of the following pages: logo or issuer name, title with number, recipient with customer number, invoice date; and an empty header for the first page | | `footer` | `` with the footer columns and "Page {PAGENO} of {nbpg}" | | `marks` | Fold and punch marks at the left edge of the first page (option `fold_marks`, on by default) | | `sender-line` | Sender line at the top of the address field | | `recipient` | Address lines of the recipient | | `letterhead` | Logo or name of the issuer at the top left; the issuer's address when the footer does not start with it | | `meta` | Number, date, valid until, reference document, delivery date, service period, customer number, references, VAT identifier and tax number of the issuer (only when the footer does not show them), VAT identifier of the recipient ("Your VAT ID"; on a self-billed invoice also the seller's tax number, "Your tax number"), tax representative, deliver-to address | | `title` | Title (`

`) | | `references` | Preceding invoices ("Reference: invoice … of …") | | `intro` | Salutation and intro text | | `lines` | Line table: groups with subtotals, optional and alternative markers, item numbers, descriptions, line periods, attributes, line allowances and charges, line notes, serial numbers, sub lines, price base quantity, gross unit price; a VAT column only with several VAT rates; the rows for the [carry-over](#carry-over-across-pages) | | `allowances` | Sum of lines, document allowances and charges (inside `totals`) | | `totals` | Net total, VAT rows, gross total, paid amount, rounding, third party payments, amount due, VAT in accounting currency. When the amount due is the gross total, it is printed once, as gross total | | `documents` | Packages, open items, fees, interest, totals and balance of [documents](documents.md) | | `tax-notes` | Exemption reasons and regulatory notes (`legalNotes`) | | `payment` | Payment terms and direct debit notice; next to them the bank details (payee, IBAN; BIC and reference; the account holder only when it is not the issuer) or the payout account, and the payment QR code | | `notes` | Other notes | | `attachments` | Attached documents (identifier and description) | | `closing` | Closing text, acceptance field of quotes | Partials read the [view model](#view-model). Keep printing every value a partial prints today unless you print it elsewhere: the [mandatory field guard](#mandatory-field-guard) reports missing mandatory values. ## Own templates (level 3) For a layout of your own, create a copy of the default template under your own name: ```bash php artisan make:quittio-template my-design # resources/views/invoices/my-design (--force overwrites) ``` The name may contain lower case letters, digits, `-` and `_`. The command copies the default layout and partials and points the layout at `invoices.my-design.partials`. Use the template per call with `->template('invoices.my-design.layout')` (allowed by the default `pdf.templates` entry `invoices.*`) or for every invoice with `pdf.template`. A template must follow some rules of mPDF ([mPDF rules for templates](#mpdf-rules-for-templates)) and must print every mandatory value ([Mandatory field guard](#mandatory-field-guard)). ### Selecting a template The template of a run is the first of: 1. `->template('…')` of the call; 2. `Presentation::$template` of the invoice's own presentation; 3. the `template` of the presentation passed to `->presentation()` of the call; 4. the `template` of the configured presentation; 5. the configured template. In Laravel this is the name `default`, which the Blade engine maps to `pdf.template` (default `quittio::templates.default.layout`). Without Laravel it is the `template` key of `Quittio::create()` (default `default`). The same order applies to documents (quotes, reminders …). Template names may come from invoice data (`Presentation::$template`, issuer branding of the [Managed layer](managed.md)), so they are restricted: - **Blade engine:** it renders `default`, the configured `pdf.template`, the shipped views under `quittio::templates.` (not their partials) and the views listed in `pdf.templates` (default `['invoices.*']`; an entry ending in `*` allows every view below that prefix, e.g. `mytheme::*`). A view whose name contains `.partials.` is never rendered as a template. Another existing view fails with an `InvalidArgumentException`. Names that are no Blade view are passed to the plain PHP engine. - **Plain PHP engine:** it accepts names only, no paths: segments of letters, digits, `_` and `-` separated by `/` (segments after the first may also contain `.`), no `..`, no absolute paths or stream wrappers. It resolves `{name}.php` inside its template directories (`template_paths` of `Quittio::create()`, then the shipped templates). An unknown or invalid name fails with an `InvalidArgumentException`. ### What a template receives A Blade template receives `$invoice`, the [view model](#view-model). A plain PHP template receives `$invoice` and `$e`, an escape function that returns HTML-safe text. Its nodes are [typed](#typed-nodes); object and array syntax read the same values. Print values escaped: with `{{ }}` in Blade, with `$e(…)` in plain PHP. Only these prepared HTML values may be printed unescaped (`{!! !!}`): `lines[].description.html`, `notes[].html`, `texts.intro`, `texts.closing` and `design.watermarkCss`. ### Carry-over in own templates Own templates get the [carry-over](#carry-over-across-pages) with these markers (other renderers and browsers ignore them): ```html …… {{-- every line row; sub lines and group rows without --}}
``` - `` and `` enclose the rows of the line table. - Every line row carries its running total in `data-carry-over` (`lines[].carryOver` of `lineGroups`). - The `carry-out` comment holds the row printed at the end of a page, the `carry-in` comment the row at the start of the next page. - `{page}` is the next page in the carry-out row and the previous page in the carry-in row. `{amount}` is the `carryOver` of the last line row before the break. - The table needs a `` and fixed column widths, because each page gets a table of its own. ### Page numbers, headers and footers The default templates put the footer columns and "Page {PAGENO} of {nbpg}" into an `` that every page uses (`@page { footer: html_quittioFooter; }`). mPDF replaces `{PAGENO}` and `{nbpg}` with the page number and the number of pages. Headers work the same way with ``: the first page uses an empty header (`@page :first { header: html_quittioFirstHeader; }`), the following pages the header with logo, title and recipient. Up to four footer columns get a fixed width (43.8 mm each, the last 39.6 mm); more columns share the width. The page margins come from the view model: `design.pageMarginTop` for the first page and `design.continuationMarginTop` for the following pages ([Design](#design)). ### mPDF rules for templates mPDF supports only part of CSS. Follow these rules: - Layout with tables, not flexbox or grid. - Inside table cells, mPDF ignores `margin` and `padding` of blocks (`div`, `p`). Create spacing there with the padding of a table cell, e.g. a nested table with one row per block. - Position elements on the page with `position: absolute` (measured from the page edge); `position: fixed` is measured from the page margins. The address field must be a direct child of ``. - Repeat table headers on every page via ``. - Headers and footers via `` / ``, page numbers with `{PAGENO}` and `{nbpg}`. - Use `page-break-inside: avoid` for the totals block. - Images as PNG or JPEG; fonts must be embeddable. Templates that follow these rules also render with [Fagus](#fagus), which translates the mPDF constructs into standard CSS. ### Other template engines Other engines (Twig …) implement `Quittio\Core\Templates\TemplateEngine::render(string $template, InvoiceViewModel $invoice, array $data = []): string`. Pass them to `Quittio::create(templates: …)` or `$quittio->setTemplateEngine(…)`. ## PDF renderers A renderer turns the HTML of the template into the PDF (design level 4). | Renderer | Use | |---|---| | `MpdfRenderer` (default) | HTML to PDF/A-3b with mPDF in pure PHP; embeds the XML and writes the XMP metadata (the document description PDF/A requires) in one pass | | `FagusRenderer` | HTML to PDF/A-3b with Fagus, a binary next to PHP; the same templates, embedding and metadata by Fagus ([Fagus](#fagus)). Needs `composer require nforst/fagus` | | `CallbackRenderer(Closure $callback)` | Own rendering (Browsershot, Gotenberg …): `fn (string $html, RenderRequest $request): string` returns the PDF; PDF/A, metadata and the XML are added by `MpdfPostProcessor` | | `PassthroughRenderer(string $pdf)` | A finished PDF of the application; only PDF/A and the XML are added | ```php laravel use Quittio\Core\Pdf\Renderers\CallbackRenderer; use Quittio\Core\Pdf\RenderRequest; use Quittio\Laravel\Facades\Quittio; use Spatie\Browsershot\Browsershot; Quittio::extend('renderer', 'browsershot', fn ($app, array $config) => new CallbackRenderer( fn (string $html, RenderRequest $request) => Browsershot::html($html)->format($request->paper)->pdf(), )); // config/quittio.php: 'pdf' => ['renderer' => 'browsershot', 'renderers' => ['browsershot' => [...]]] ``` ```php plain use Quittio\Core\Pdf\Renderers\CallbackRenderer; use Quittio\Core\Pdf\RenderRequest; use Spatie\Browsershot\Browsershot; $quittio->setRenderer(new CallbackRenderer( fn (string $html, RenderRequest $request) => Browsershot::html($html)->format($request->paper)->pdf(), )); ``` The factory receives the container and `pdf.renderers.{name}`. Without Laravel, pass the renderer to `Quittio::create(renderer: …)` or `$quittio->setRenderer(…)`. A renderer implements `PdfRenderer` with `render(RenderRequest $request): string` and `supportsEmbedding(): bool`: - `supportsEmbedding()` returns `true` when the renderer creates the PDF/A and embeds the XML itself (`MpdfRenderer`, `FagusRenderer`, and `CallbackRenderer`/`PassthroughRenderer` through their post processor). - For `false`, Quittio passes the PDF to `MpdfPostProcessor` whenever the request asks for PDF/A or an embedded XML, so a plain HTML-to-PDF renderer is enough. - `RenderRequest` holds `html`, `title`, `author`, `subject`, `paper`, `pdfa`, `embedded` (`EmbeddedXml`: `content`, `filename`, `relationship`, `conformanceLevel`, `description`, `documentType`, `version`) and `font`. - The post processor imports the pages with FPDI (a PHP library that reads existing PDFs). The result is PDF/A only if the source PDF allows it (embedded fonts, no encryption, no JavaScript), so check it with [veraPDF](validation.md#verapdf-l6), a validator for PDF/A. A PDF is PDF/A-3b when it embeds XML, otherwise when `pdf.pdfa` is `true` (default) and it has no watermark. Its metadata: title "{title} {number}", author the seller, creator "Quittio". mPDF settings of `MpdfRenderer`: - margins 20 (left), 15 (right), 20 (top), 25 (bottom), header and footer 8 mm; the default templates set their own page margins; - `pdf.renderers.mpdf.simple_tables` (default `false`; `true` drops the borders of table cells and is not faster); - `pdf.renderers.mpdf.pdfa_auto` (default `false`; lets mPDF fix PDF/A issues itself); - `pdf.cache_path` as temporary directory (without Laravel `temp_dir`, default `sys_get_temp_dir()/quittio-mpdf`). mPDF cannot load anything over HTTP (a denying HTTP client is installed), has no remote base path and does not follow redirects. Remote resources of a template are rendered as missing. ### Fagus [Fagus](https://fagus.niklasforst.de) is an engine for HTML and CSS to PDF that implements CSS Paged Media and prints like Chrome, without a browser. It runs as a binary next to PHP and writes PDF/A-3b and ZUGFeRD/Factur-X itself. `FagusRenderer` renders the same templates as mPDF with it. mPDF stays the default: Fagus is opt-in, because it adds a binary to the installation and is still a 0.x release. Install the package. Its Composer plugin downloads the binary for the platform (see the [Fagus documentation](https://fagus.niklasforst.de/docs) for servers without download): ```bash composer require nforst/fagus ``` Then select the renderer: ```php laravel // config/quittio.php 'pdf' => [ 'renderer' => 'fagus', 'renderers' => ['fagus' => ['binary' => env('FAGUS_BINARY'), 'timeout' => 60]], ], ``` ```php plain use Quittio\Core\Pdf\Renderers\FagusRenderer; use Quittio\Core\Quittio; use Quittio\Country\DE\CountryDE; $quittio = Quittio::create([], [new CountryDE], renderer: new FagusRenderer( fonts: ['corporate' => ['R' => 'Corporate-Regular.ttf', 'B' => 'Corporate-Bold.ttf']], fontDirectories: [__DIR__.'/fonts'], defaultFont: 'geist', binary: null, timeout: 60.0, )); ``` - `fonts`, `fontDirectories` and `defaultFont` are those of `MpdfRenderer` ([Fonts](#fonts)); in Laravel `pdf.fonts`, `pdf.font_directories` and `pdf.font`. Font directories that do not exist are skipped. - `binary` is the path of the `fagus` binary (`pdf.renderers.fagus.binary`). `null` takes `FAGUS_BINARY`, the binary the package installed, or `fagus` on the `PATH`. - `timeout` is the number of seconds the renderer waits for each answer of the Fagus worker (`pdf.renderers.fagus.timeout`, default 60). - The renderer starts the Fagus worker process with the first document and keeps it running for the next ones, e.g. in a queue worker. - Without `nforst/fagus`, creating the renderer (or the Laravel core with `pdf.renderer = 'fagus'`) fails with a `ConfigurationException` that asks for `composer require nforst/fagus`. A failed render throws a `PdfException`. #### What the renderer translates Templates keep the mPDF markup. Before rendering, `FagusRenderer` translates it into standard CSS, so the default templates and own templates written for mPDF work unchanged: | mPDF | With Fagus | |---|---| | ``, `` | Running elements (`position: running()`) | | `@page { header: html_x; footer: html_y; }` (also `odd-header-name`, `odd-footer-name`) | The margin boxes `@top-center` and `@bottom-center` with `content: element()`; other values print no header or footer | | `margin-header`, `margin-footer` in `@page` | The distance of the header from the top edge and of the footer from the bottom edge | | `sheet-size` in `@page` | `size` | | `{PAGENO}`, `{nbpg}`, `{nb}` | `counter(page)`, `counter(pages)` | | ``, ``, `` | A page break | | `` | A block on the named page `slip` up to the next page selector. Its first page has the header and footer of `@page :first`, as in mPDF. | | `position: absolute` or `fixed` on a child of `` | Placed from the edges of the sheet on the page where it is, as by mPDF | | `` | The text at 45 degrees on every page, not in PDF/A (as with mPDF); a `body::before` overlay of the template is left out | | [Carry-over](#carry-over-in-own-templates) markers | Rows of the table head and foot that Fagus shows only at page breaks, with the running total from `data-carry-over` | | The paper size, mPDF's page margins (20, 15, 20 and 25 mm, header and footer 8 mm) and mPDF's default stylesheet | Applied before the template's own styles | | The font families of mPDF (`geist`, `geistmedium`, `inter`, `liberationsans`, `pdf.fonts`) | `@font-face` rules with the same files | | Title, author and subject of the `RenderRequest` | ``, `<meta name="author">` and `<meta name="description">` | Not translated: `<tocpagebreak>`, `<columns>`, `<barcode>`, `<bookmark>`, `<annotation>`, `<watermarkimage>`, `<sethtmlpageheader>`, the attributes of `<pagebreak>` other than `page-selector`, the margins of `@page :first` on the first page of a named page, `even-header-name` and `even-footer-name` (`MpdfRenderer` prints the odd ones on every page as well), and the fonts that come with mPDF (DejaVu, FreeSans …) unless their directory is a font directory. #### Differences from mPDF The pages break at the same places as with mPDF for the default templates, and the documents look alike. Remaining differences: - Fagus applies all of CSS, mPDF only part of it. Rules mPDF ignores take effect: the receipt of the Swiss QR bill prints its headings and values at 6 and 8 pt (`.receipt .slip-heading`, `.receipt .slip-value`), mPDF at the 8 and 10 pt of the payment part. A template may also use flexbox and grid, but then prints differently with mPDF. - A table row that does not fit on the page breaks across the page, as in browsers. mPDF moves the whole row to the next page, so an invoice line with a long description can start a page later there. The carry-over at such a break shows the running total including the broken line. - Text is kerned and the widths of table columns without a fixed width are computed as in browsers, so text can wrap at other places (e.g. a long label in the totals). - Positioned elements of `<body>` are drawn over the page content. - The watermark is centred on the page area, not on the sheet. - The XMP version and the description of the embedded XML are those of the `EmbeddedXml`, as with mPDF (for XRechnung `3.0` and "XRechnung Invoice"). File name and relationship come from Fagus' profile and are the same as with mPDF; the profile comes from `conformanceLevel` (or from the XML when it is unknown). - The metadata have no creator "Quittio"; the producer is "Fagus". - A multi-page invoice is laid out once instead of up to three times, so rendering is faster. #### Files and network Like mPDF, Fagus loads nothing over the network, and it reads no files of its own accord. `FagusRenderer` hands over only images that the HTML names by a local path (as the logo prepared by the [logo cache](#logos)), at most 10 MB and only if they are PNG, JPEG, GIF, WebP or SVG images. `data:` URIs work as in mPDF. Other files and `http(s)` URLs of a template are rendered as missing. ## View model Templates receive `$invoice` (`Quittio\Core\View\InvoiceViewModel`) and nothing else. It holds every value of the invoice, already calculated and formatted for printing. - Nodes are read-only `ViewNode` objects. Use object syntax (`$invoice->seller->name`) or array syntax (`$invoice['seller']['name']`), loop over lists, and use `count()`, `isEmpty()` and `toArray()` (plain values, formatted). - Writing throws a `LogicException`; a missing key reads as `null`. - Values that need formatting are `FormattedValue` objects. `{{ $invoice->totals->amountDue }}` prints the formatted text (`->formatted`). `->raw` holds the original value: `Brick\Money\Money` for amounts, `Quittio\Core\Support\Date` for dates, `Period` for periods, `Brick\Math\BigDecimal` for quantities, prices and rates. - Nodes are typed ([Typed nodes](#typed-nodes)): `$invoice->seller` is a `PartyView`, `$invoice->lines` a list of `LineView`. - Templates contain no calculations. `$invoice->label($key, $replace)` returns a label with `:placeholders` replaced (unknown keys return the key); `$invoice->title()` returns the title. ### Typed nodes Every node of the view model has a class of its own in `Quittio\Core\View\Model`, with its keys documented as typed properties. IDEs complete `$invoice->totals->` and know that `amountDue` is a `?FormattedValue`; PHPStan checks templates and own template engines against the same types. The typed nodes are `ViewNode` objects with the same data as before. Templates you published keep working unchanged: object syntax, array syntax, loops, `count()`, `toArray()`, `json_encode()` and the [mandatory field guard](#mandatory-field-guard) behave exactly as they did, and both syntaxes read the same value. Nothing is copied; the classes only describe the structure. | Node | Class | |---|---| | `$invoice` | `InvoiceViewModel` (`Quittio\Core\View`) | | `document`, `documentInfo` | `DocumentView`, `DocumentInfoView` | | `seller`, `buyer`, `issuer`, `recipient` | `PartyView` (keys of the seller only are `null` for the buyer and the other way round) | | `…address`, `…contact` | `AddressView`, `ContactView` | | `payee`, `taxRepresentative`, `delivery` | `PayeeView`, `TaxRepresentativeView`, `DeliveryView` | | `references[]`, `precedingInvoices[]` | `ReferenceView`, `PrecedingInvoiceView` | | `lineGroups[]`, `lines[]`, `…subLines[]` | `LineGroupView`, `LineView` | | `lines[].description`, `.unit`, `.attributes[]`, `.allowances[]`, `.charges[]` | `DescriptionView`, `UnitView`, `AttributeView`, `LineAllowanceChargeView` | | `allowances[]`, `charges[]` | `AllowanceChargeView` | | `vatRows[]` | `VatRowView` | | `totals`, `totals.thirdPartyPayments[]` | `TotalsView`, `DescribedAmountView` | | `payment`, `.accounts[]`, `.card`, `.directDebit`, `.qrCode` | `PaymentView`, `AccountView`, `CardView`, `DirectDebitView`, `QrCodeView` | | `paymentTerms`, `.discounts[]` | `PaymentTermsView`, `DiscountView` | | `notes[]`, `attachments[]`, `texts`, `design`, `meta` | `NoteView`, `AttachmentView`, `TextsView`, `DesignView`, `MetaView` | | `documentInfo.packages[]`, `.lines[]`, `.dunning`, `.statement` | `PackageView`, `LineOptionsView`, `DunningView`, `StatementView` | | `dunning.openItems[]`, `statement.items[]`, `dunning.fees[]`, `dunning.interest[]` | `OpenItemView`, `DescribedAmountView`, `InterestView` | Lists are `ViewList<T>` objects (`[]` in the table): `lines` is a `ViewList<LineView>`, `legalNotes`, `address.lines` and `labels` are `ViewList<string>`, `design.footerColumns` is a `ViewList<ViewList<string>>`. `meta.custom` is a plain `ViewNode`. To use the types in a plain PHP template, declare `$invoice` and type your helpers: ```php <?php /** * @var \Quittio\Core\View\InvoiceViewModel $invoice * @var callable(mixed): string $e */ use Quittio\Core\View\Model\LineView; $name = static fn (LineView $line): string => $e($line->name).($line->sellerId ? ' · '.$e($line->sellerId) : ''); foreach ($invoice->lines as $line) { echo '<tr><td>'.$name($line).'</td><td>'.$e($line->quantity).' '.$e($line->unit->label).'</td><td>'.$e($line->total).'</td></tr>'; } ``` In Blade, declare the variable in a `@php` block at the top of the view: `@php /** @var \Quittio\Core\View\InvoiceViewModel $invoice */ @endphp`. Labels are a map: read them with `$invoice->labels['amount_due']` or `$invoice->label('amount_due')` for a typed result; `$labels->amount_due`, as in the default partials, works as before but is untyped. The property types are part of the public API ([Versioning and compatibility](compatibility.md)). A release may add keys and node classes; it does not remove or retype a key without listing it in the changelog. The node objects are created by the view model only; their constructors are not meant to be called. The tables name the EN 16931 field of a value in parentheses, e.g. invoice number (BT-1) or seller address (BG-5); see [Business terms](concepts.md#en-16931-and-business-terms). ### Top level | Key | Content | |---|---| | `number` | Invoice number (BT-1) | | `numberLabel`, `dateLabel` | Labels for number and date ("Invoice number", "Invoice date"; documents: "Number", "Date") | | `title` | Document title (see below) | | `issueDate`, `dueDate` | Dates (BT-2, BT-9) | | `servicePeriod` | Invoicing period (BG-14), otherwise the delivery date (BT-72), otherwise the period from the earliest start to the latest end of the line periods when every line has one; `null` otherwise | | `servicePeriodLabel` | "Delivery date" for a single date or a one-day period, otherwise "Service period". German output: "Leistungsdatum" (date of supply) and "Leistungszeitraum" (period of supply) | | `deliveryDate` | BT-72 when an invoicing period is also set (otherwise `servicePeriod` shows it) | | `currency` | Invoice currency (BT-5) | | `document` | [document](#document) | | `documentInfo` | `null` for invoices, [documentInfo](#documentinfo) for documents | | `seller`, `buyer` | [Parties](#parties) | | `issuer`, `recipient` | The party in letterhead, sender line and footer, and the party in the address field: seller and buyer; on a self-billed invoice buyer and seller | | `payee` | Payee (BG-10): `name`, `identifier`, `legalRegistration`; `null` without | | `taxRepresentative` | Seller tax representative (BG-11): `name`, `vatId`, `address`; `null` without | | `delivery` | `recipientName`, `date` (BT-72), `address` (with the recipient name as first line); `null` without delivery data | | `references` | List of `key`, `label`, `value` for the filled references: `buyer_reference`, `purchase_order`, `sales_order`, `contract`, `project` (identifier and name), `despatch_advice`, `tender`, `invoiced_object`, `accounting_reference` | | `precedingInvoices` | List of `number`, `issueDate` (BG-3) | | `lineGroups` | [Line groups](#lines) | | `lines` | All top-level [lines](#lines) | | `allowances`, `charges` | [Document allowances and charges](#allowances-and-charges) | | `vatRows` | [VAT breakdown](#vat-rows) | | `totals` | [Totals](#totals); `null` when not calculated | | `payment` | [Payment](#payment); `null` without payment instructions | | `paymentTerms` | [Payment terms](#payment-terms) | | `legalNotes` | List of texts: exemption reasons (BT-120, except category S) and notes with subject `REG`, `ABL` or `TXD` (BT-22), without duplicates | | `notes` | Other notes: `subject` (BT-21), `content`, `html` | | `attachments` | List of `id`, `description`, `filename`, `uri` (BG-24) | | `texts` | `salutation` (plain text), `intro`, `closing` (HTML from Markdown) | | `labels` | All labels of the locale, with the overrides of `Presentation::$labels` | | `design` | [Design values](#design) | | `meta` | `locale`, `custom` (values of `->custom()`), `source` | The `title` is the first of: 1. `Presentation::$title`; 2. for self-billed type codes: the title `self_billed` of the country pack's correction policy, which also holds the titles of cancellations and corrections. Germany: "Gutschrift"; in English "Self-billed invoice (Gutschrift)"; 3. the label of the type code (BT-3). | Label | English text | Used for | |---|---|---| | `title_380` | Invoice | Type code 380 | | `title_381` | Credit note | Type code 381 and other credit note codes | | `title_384` | Corrected invoice | Type code 384 | | `title_389` | Self-billed invoice | Type code 389 and other self-billed codes | | `title_325` | Proforma invoice | Type code 325 | | `title_326` | Partial invoice | Type code 326 | | `title_386` | Prepayment invoice | Type code 386 | | `title_875`, `title_876`, `title_877` | Partial construction invoice, Partial final construction invoice, Final construction invoice | Type codes 875, 876, 877 | | `title_default` | Invoice | Every other type code | ### document | Key | Content | |---|---| | `typeCode` | Type code (BT-3) as string, e.g. `380`; `null` for documents | | `type` | Name of the type code in the locale; for documents the name of the document type, e.g. "Quote" | | `isCreditNote` | Credit note type code | | `isSelfBilled` | Self-billed invoice ("Gutschrift") | | `profile`, `profileKey` | Name and key of the [profile](concepts.md#profiles) of the run, e.g. `EN 16931`, `en16931` | | `kind` | `invoice`, or the document type (`quote`, `order_confirmation`, `delivery_note`, `proforma`, `payment_reminder`, `account_statement`) | | `isInvoice` | `true` for invoices, `false` for documents | | `showPrices` | `false` for delivery notes | | `showTotals` | `false` for delivery notes, reminders and statements | ### Parties `seller` and `buyer`: | Key | Seller | Buyer | |---|---|---| | `name` | BT-27 | BT-44 | | `tradingName` | BT-28 | BT-45 | | `displayName` | trading name, otherwise name | trading name, otherwise name | | `address` | see below | see below | | `vatId` | BT-31 | BT-48 | | `taxNumber` | BT-32 | – | | `legalRegistration` | BT-30 value | BT-47 value | | `additionalLegalInfo` | BT-33 | – | | `customerNumber` | – | buyer identifier (BT-46) | | `contact` | `name`, `phone`, `email` or `null` | `name`, `phone`, `email` or `null` | | `electronicAddress` | BT-34 value | – | | `identifiers` | list of BT-29 values | – | | `isConsumer` | – | consumer flag | `issuer` and `recipient` are the same nodes. Every `address` has `lines`, `street`, `additional`, `line3`, `postcode`, `city`, `subdivision`, `countryCode` and `country` (name in the locale). `lines` is formatted by the country pack's address formatter and starts with the name. The country is added in upper case when it differs from the issuer's country. The fallback formatter writes "postcode city", for GB, IE, US, CA, AU, LV and UA "city subdivision postcode". ### Lines `lines` and `lineGroups[].lines` contain: | Key | Content | |---|---| | `position`, `id` | Line identifier (BT-126) | | `name` | Item name (BT-153) | | `description` | `text` (BT-154) and `html` (escaped plain text with line breaks, or Markdown with the option `markdown`) | | `note` | Line note (BT-127) | | `sellerId`, `buyerId` | Item identifiers (BT-155, BT-156) | | `quantity` | Quantity (BT-129), formatted without trailing zeros | | `unit` | `code` (BT-130) and `label` in the locale | | `unitPrice` | Net price (BT-146), at least two decimals | | `grossUnitPrice` | Price including VAT (gross price mode) | | `listPrice` | Gross price before the price discount (BT-148) | | `baseQuantity` | Price base quantity (BT-149) | | `unitPriceBase` | Base quantity with unit, e.g. "100 pcs", for printing with the unit price; `null` for 1 | | `showGrossPrice` | Print `grossUnitPrice`: the line's `showGrossPrice` (`LineBuilder::showGrossPrice()`), otherwise the presentation's `showGrossPrices`, and only if a price including VAT exists | | `total` | Line net amount (BT-131) | | `carryOver` | Sum of the line net amounts up to this line in display order, only in `lineGroups[].lines`: the [carry-over](#carry-over-across-pages) when a page ends after the line | | `vatRate` | Rate (BT-152); `null` without rate and for margin schemes and travel agents (special VAT schemes without separate VAT) | | `vatCategory` | Category code (BT-151) | | `period` | Line period (BG-26) | | `attributes` | List of `name`, `value` (BG-32) | | `allowances`, `charges` | Line allowances and charges: `reason`, `amount`, `percent`, `label` ("Allowance reason 10 %") | | `subLines` | Sub lines with the same keys | | `highlight` | `LineBuilder::highlight()`; the default templates shade the line and mark it in the secondary colour | | `groupId` | Line group | | `optional`, `alternativeTo`, `serialNumbers` | Document line options (quotes, delivery notes) | `lineGroups` lists the groups defined with `InvoiceBuilder::group()` in their order, then one group with `id` and `title` `null` for the lines without a group (or with an unknown group). Empty groups are left out. Each group has `id`, `title`, `lines` and `subtotal` (sum of the line net amounts when `showSubtotal` is set, otherwise `null`). Print either `lineGroups` or `lines`, not both. ### Allowances and charges `allowances` and `charges` (BG-20, BG-21) are discounts and surcharges on the whole document. They contain `reason` (text or code), `amount`, `percent`, `base`, `vatRate`, `vatCategory` and `label` ("Allowance reason 3 %"; with several VAT groups followed by the VAT rate or category, e.g. "(19 % VAT)"). ### VAT rows | Key | Content | |---|---| | `label` | Ready text: "VAT 19%" when it is the only VAT row (its base is the net total printed above), otherwise "19% VAT on 1,000.00 €"; "VAT exempt (…) on …", "No VAT (reverse charge) on …", "0% VAT (zero rate) on …", "Not subject to VAT: …", "Special scheme, no separate VAT statement: …" | | `category`, `categoryLabel` | Category code and name | | `rate` | Rate (BT-119) | | `base` | Taxable amount (BT-116) | | `amount` | VAT amount (BT-117); `null` for margin schemes and travel agents (exemption reason codes `VATEX-EU-D`, `-F`, `-I`, `-J` on the group or on all its lines) | | `isSpecialScheme` | Margin scheme or travel agents | | `exemptionReason`, `exemptionReasonCode` | BT-120, BT-121 | Reverse charge means that the buyer owes the VAT ([German terms](concepts.md#german-terms)). Margin schemes and travel agents are special VAT schemes (sections 25 and 25a of the German VAT Act, UStG) that state no separate VAT. Usually there is one row per VAT breakdown row (BG-23). An exempt group (category `E`) that mixes a special scheme with other exemptions takes two rows, the special scheme part (`isSpecialScheme`, `base` its share) and the exempt part, or one row "Exempt or special scheme, no separate VAT statement: …" without `amount` when the parts cannot be told apart. `ViewModelFactory::vatRowIndexes($invoice)` maps the index of a breakdown row to its first row in `vatRows`. ### Totals | Key | Content | |---|---| | `lineNetSum`, `allowanceSum`, `chargeSum`, `netTotal`, `vatTotal`, `grossTotal`, `prepaid`, `rounding` | Document totals | | `vatTotalInTaxCurrency` | VAT in accounting currency (BT-111) | | `taxCurrencyNote` | "VAT in USD: … (rate … of …)" when an exchange rate is set | | `thirdPartyPayments` | List of `description`, `amount` (XRechnung extension) | | `amountDue` | Amount due | | `amountDueLabel` | "Amount due"; "Amount to be refunded" on credit notes and negative invoices; "Amount paid out" on self-billed invoices | | `dueEqualsGross` | The amount due is the gross total: nothing prepaid, rounded or paid by third parties, no refund and no payout | When `dueEqualsGross` is `true`, the default templates print the amount once, with the label `gross_total` ("Total incl. VAT"; German "Gesamtbetrag", total amount). On a negative invoice (e.g. a cancellation with the strategy `negative_invoice`), `amountDue` is printed as a positive refund amount; `amountDue->raw` and the XML keep the negative amount due (BT-115). ### Payment | Key | Content | |---|---| | `meansCode`, `means`, `meansText` | Payment means code (BT-81), its name, BT-82 | | `remittance` | Remittance information (BT-83), otherwise the invoice number | | `accounts` | List of `iban` (grouped in blocks of four), `bic`, `name` | | `card` | `number` ("•••• 1234"), `holder`; or `null` | | `directDebit` | `mandate`, `creditorId`, `account`; or `null` | | `qrCode` | [Payment QR code](#payment-qr-codes) or `null` | | `isRefund` | Credit note or negative amount due: show no bank details for a transfer by the buyer and no direct debit notice | | `isPayout` | Self-billed invoice: the accounts receive the payout | ### Payment terms `paymentTerms` is `null` without payment terms (BT-20) and due date. Otherwise it has: - `lines`: ready texts. These are the terms text; "Please transfer the amount by …" when the buyer pays by credit transfer, otherwise "Please pay the amount by …", on self-billed invoices "We will transfer the amount to your account by …"; one text per cash discount, such as "2% discount until 10/10/2026: 2,692.76 €"; and the late fee terms. - `discounts`: list of `days`, `percent`, `until`, `amount`, `text`. - `dueDate`. On credit notes, quotes, order confirmations and invoices without a positive amount due, discounts are shown as agreement ("For payment within 7 days …") without date or amount, and no due date text is added. ### Design | Key | Content | |---|---| | `primaryColor`, `secondaryColor`, `textColor`, `mutedColor` | Hex colours (`secondaryColor` falls back to the primary colour). The default templates print the issuer's name, the title, the header of the following pages and the gross total or amount due in the primary colour; section titles and the mark of highlighted lines in the secondary colour; the lines below the column heads and above the gross total or amount due in the text colour; secondary texts and labels in the muted colour | | `font` | Font family | | `fontMedium` | Family for the medium and semibold weights (item names, column heads, title, headings): `geistmedium` for Geist (normal = medium, bold = semibold); `null` for other fonts, then the templates use bold | | `logo` | Prepared logo ([Logos](#logos)) or `null` | | `letterLayout` | Name of the [letter layout](#letter-layouts) | | `addressTop`, `addressLeft`, `addressWidth`, `addressHeight` | Address field in mm from the top left page corner | | `pageMarginTop` | Top page margin of the first page in the default templates (15 mm): the letterhead starts here | | `continuationMarginTop` | Top page margin of the following pages (40 mm), below their header | | `letterheadHeight` | Space above the address field: `addressTop` − `pageMarginTop` | | `logoMaxHeight` | Height of the logo: 14 mm, less when the letterhead is lower (the logo ends 2 mm above the address field), at least 6 mm | | `addressZoneTop` | Start of the recipient zone (DIN 5008 "Anschriftzone") within the address field (17.7 mm), for own templates; the default templates print the recipient directly below the sender line | | `senderLineHeight` | Height of the sender line (5 mm) | | `noticeZoneHeight` | `addressZoneTop` − `senderLineHeight`: the DIN 5008 zone for additions and postal notes ("Zusatz- und Vermerkzone") above the sender line, for own templates | | `foldMarks`, `punchMark` | Mark positions in mm from the top; empty when the option `fold_marks` is `false` (default `true`) | | `paper` | Paper of the presentation | | `watermark`, `watermarkCss` | Watermark text, and the same as escaped CSS string for the HTML overlay | | `senderLine` | Configured sender line, otherwise "Name · Street · Postcode City" of the issuer | | `footerColumns` | Configured columns, otherwise generated: the issuer's address lines; phone and e-mail; legal registration and the parts of the additional legal information (split at " · " and line breaks); "VAT ID …" and "Tax no. …" of the issuer. The bank details are in the payment block | | `footerHasAddress` | The generated footer starts with the issuer's address | | `footerHasTaxIds` | The generated footer shows the issuer's VAT identifier or tax number (they count as printed for the [mandatory field guard](#mandatory-field-guard)); otherwise the default templates print them with the invoice details | | `showItemNumbers`, `showGrossPrices` | Presentation switches | ### documentInfo Only for [documents](documents.md): | Key | Content | |---|---| | `type` | Document type value | | `validUntil` | Quote validity | | `reference`, `referenceDate` | Preceding document (`reference()`) | | `deliveryDate` | Delivery date | | `packages` | List of `id`, `type`, `weight` ("2.5 kg"), `dimensions`, `trackingNumber` | | `lines` | Line options keyed by line identifier: `optional`, `alternativeTo`, `serialNumbers` | | `dunning` | `level`, `deadline`, `deadlineText` ("Please pay the total amount by …"), `openItems`, `fees` (`description`, `amount`), `interest` (`description`, `days`, `amount`), `openTotal`, `feeTotal`, `interestTotal`, `total`; `null` for other types | | `statement` | `period`, `items`, `openingBalance`, `balance`; `null` for other types | | `showAcceptance` | Print the acceptance field (quotes) | Open items (`dunning.openItems[]`, `statement.items[]`) have `invoiceNumber`, `invoiceDate`, `dueDate`, `description`, `amount`, `paid` and `open`. ## Mandatory field guard Some values must appear on every invoice by law. After rendering a PDF or HTML invoice, the guard checks that the template printed them all: - number and issue date; - the full name of seller and buyer (`seller.name` or the address lines, which start with it; the trading name `displayName` alone is not enough) and their address (all address lines, or street, postcode and city); - name, quantity and unit (`unit.label`) of every line (in `lineGroups` or `lines`). Section 14 (4) no. 5 UStG requires "Menge und Art" (quantity and kind) of the goods; - label, or base and rate, and the VAT amount of every VAT row; - the cash discount terms (`paymentTerms.discounts[].text` or `paymentTerms.lines`) and the amount due; - every legal note (exemption reasons and regulatory notes, e.g. "Gutschrift" or the retention notice of section 14b UStG) and every preceding invoice number; - the tax representative (name, address, VAT identifier); - what the country pack requires. Germany: tax number or VAT identifier (also of the tax representative); the service date (`servicePeriod`, `deliveryDate` or `delivery.date`, or the period of every line); on self-billed invoices the title and the note "Gutschrift"; the retention notice of property related services; the [reverse charge](concepts.md#german-terms) or exemption note per VAT row; the VAT identifiers of buyer and seller for reverse charge and intra-community supplies (tax-exempt supplies of goods to a business in another EU country; see [Country packs](country-packs.md#mandatory-pdf-output)). How the guard decides whether a value was printed: - Lists are checked per entry: printing only the first VAT row or note is not enough. - Values that are null are not required. - A value counts as printed when the template reads it as a leaf (a single value, not a node), also in a condition such as `@if ($invoice->buyer->vatId)`, while a loop reads the entries of a list, or with `toArray()`. - `count()`, `isEmpty()`, `isset()` and reading null values do not count. - Values printed through `issuer` and `recipient` count for the seller and the buyer, and the generated footer counts as the issuer's address. A custom `senderLine` or custom `footerColumns` do not replace the seller's address. Mandatory fields are `Quittio\Core\Countries\MandatoryField` objects (`accessKey`, `description`, `legalBasis`). The access key is a view model path where `[*]` stands for every index, `&` joins paths that must all be printed and `|` separates alternatives. Country packs return them from `mandatoryOutput(InvoiceData $invoice)`. A template that omits a mandatory value fails with `MandatoryFieldMissing` (`validation.mandatory_field_guard = exception`, default outside production) or logs it (`log`, default in production); `off` disables the check. The event `MandatoryFieldMissing` is dispatched in both modes. Details in [Validation](validation.md#mandatory-field-guard). <!-- Source: https://quittio.dev/docs/documents --> # Quotes, delivery notes and other documents Besides invoices, a business sends other documents: quotes, order confirmations, delivery notes, proforma invoices, payment reminders, account statements and bonus statements. This page shows how to create them with Quittio. It assumes you know the invoice builder from [Getting started](getting-started.md). Documents share parties, lines, calculation, design and templates with invoices, but they are no invoices. They never produce e-invoice XML ([What an e-invoice is](concepts.md#what-an-e-invoice-is)), are not validated and are rendered as PDF or HTML only. | Type | `DocumentType` | Builder | Lines | Prices and totals | Payment block | |---|---|---|---|---|---| | Quote | `Quote` (`quote`) | `DocumentBuilder::quote()` | required | yes | none (no bank details, QR code or amount due) | | Order confirmation | `OrderConfirmation` (`order_confirmation`) | `orderConfirmation()` | required | yes | none | | Delivery note | `DeliveryNote` (`delivery_note`) | `deliveryNote()` | required | no | none | | Proforma invoice | `Proforma` (`proforma`) | `proforma()` | required | yes | payment terms, bank details, QR code | | Payment reminder | `PaymentReminder` (`payment_reminder`) | `paymentReminder(int $level = 0)` | not allowed | open items, fees, interest | bank details, QR code over the total | | Account statement | `AccountStatement` (`account_statement`) | `accountStatement()` | not allowed | open items, balance | bank details | | Bonus statement | `BonusStatement` (`bonus_statement`) | `bonusStatement()` | required (one per VAT rate) | yes | none (the seller pays) | The printed title depends on the locale. In English it is the name in the first column; reminders from level 1 on are titled "Reminder no. 1", "Reminder no. 2" … ([Payment reminders](#payment-reminders)). German documents are titled "Angebot" (quote), "Auftragsbestätigung" (order confirmation), "Lieferschein" (delivery note), "Proforma-Rechnung" (proforma invoice), "Zahlungserinnerung" (payment reminder), "1. Mahnung" (first reminder), "Kontoauszug" (account statement) and "Bonusabrechnung" (bonus statement). ## Creating a document In Laravel, start with the facade: `Quittio::quote()`, `Quittio::orderConfirmation()`, `Quittio::deliveryNote()`, `Quittio::proforma()`, `Quittio::paymentReminder(int $level = 0)`, `Quittio::accountStatement()` or `Quittio::bonusStatement()`. Like `Quittio::invoice()`, these methods start the builder with the seller, the first bank account and the small business setting of `config/quittio.php` ([Starting invoices](laravel.md#starting-invoices)). `->render()` at the end of the chain renders the PDF. ```php laravel use Quittio\Core\Builder\Party; use Quittio\Core\Enums\UnitCode; use Quittio\Laravel\Facades\Quittio; $quote = Quittio::quote() ->number('AN-2026-0007') ->issueDate('2026-10-06') ->buyer(Party::make('Kunde AG')->address('Weg 1', '54321', 'Beispielstadt', 'DE')) ->validUntil('2026-10-31') ->line('Consulting', netPrice: '120.00', quantity: 10, unit: UnitCode::Hour) ->optionalLine('Training', netPrice: '800.00', unit: UnitCode::Day) // shown, not in the totals ->alternativeLine('1', 'Senior consulting', netPrice: '150.00', quantity: 10, unit: UnitCode::Hour) // alternative to line 1 ->build(); Quittio::document($quote)->locale('de')->render()->download(); ``` ```php plain use Quittio\Core\Builder\Party; use Quittio\Core\Enums\UnitCode; $quote = $quittio->quote() ->number('AN-2026-0007') ->issueDate('2026-10-06') ->buyer(Party::make('Kunde AG')->address('Weg 1', '54321', 'Beispielstadt', 'DE')) ->validUntil('2026-10-31') ->line('Consulting', netPrice: '120.00', quantity: 10, unit: UnitCode::Hour) ->optionalLine('Training', netPrice: '800.00', unit: UnitCode::Day) // shown, not in the totals ->alternativeLine('1', 'Senior consulting', netPrice: '150.00', quantity: 10, unit: UnitCode::Hour) // alternative to line 1 ->build(); $result = $quittio->document($quote)->locale('de')->render(); file_put_contents($result->filename(), $result->pdf()); ``` This downloads (without Laravel: saves) a German quote as `Angebot_AN-2026-0007.pdf` ([File names](#file-names)). Use `->build()` to get the document data, e.g. to store it, and `Quittio::document()` to render it with more options ([Rendering](#rendering)). Without Laravel, the same methods exist on `$quittio`: `$quittio->quote()`, `orderConfirmation()`, `deliveryNote()`, `proforma()`, `paymentReminder(int $level = 0)`, `accountStatement()` and `bonusStatement()`. They start the builder with the `seller`, `bank_account` and `small_business` of `Quittio::create()`, and `->render()` renders the PDF ([Invoices and documents with the configured seller](formats.md#invoices-and-documents-with-the-configured-seller)). The static methods of `DocumentBuilder` (`DocumentBuilder::quote()` …) start an empty builder for special cases, e.g. another seller; set the seller with `->seller()` and render with `$quittio->document($builder)`. The plain PHP examples on this page use `$quittio` as created in [Without Laravel](getting-started.md#without-laravel), with your company as `seller`. `DocumentBuilder::make(DocumentType $type)` creates a builder for any type; reminders created this way have level 0. `DocumentType` has three methods: - `showsPrices()`: `false` for delivery notes; - `hasLineTotals()`: `true` for quotes, order confirmations and proformas; - `labelKey()`: the label key of the title, `document_{value}`. ## Quotes and order confirmations A quote offers goods or services at a price; an order confirmation confirms an order. Quotes print the validity date (`validUntil()`). They mark optional lines with "[Optional]" and alternative lines with "[Alternative to pos. 1]", and they end with an acceptance field ("Order placed:" with a signature line), where the customer can sign the quote. Optional and alternative lines get their line amounts, but they are excluded from the totals, the VAT breakdown and `InvoiceBuilder::fromDocument()`. Document discounts apply to the remaining lines. Quotes and order confirmations are no request to pay: the [view model](templates.md#view-model) has no payment block, no amount due and no due date text. Order confirmations reference the quote with `reference('AN-2026-0007', '2026-10-06')` and state the delivery date with `deliveryDate()`. ## Delivery notes A delivery note accompanies a shipment. It prints quantities without prices or totals. Lines get the net price 0 and the VAT category O (not subject to VAT) unless they set a price or VAT themselves, so they need only name, quantity and unit. This applies to lines given by name, as builder, array, model (`ProvidesInvoiceLine`) or callable. Finished `InvoiceLine` objects are taken as they are. ```php laravel use Brick\Math\BigDecimal; use Quittio\Core\Documents\Package; use Quittio\Core\Enums\UnitCode; use Quittio\Laravel\Facades\Quittio; $note = Quittio::deliveryNote() ->number('LS-2026-0012') ->buyer($buyer) ->reference('AB-2026-0003') // the order confirmation ->deliveryDate('2026-10-02') ->serialisedLine('Router', ['SN-1001', 'SN-1002'], quantity: 2, unit: UnitCode::Unit) ->line('Cable', quantity: 5, unit: UnitCode::Metre) ->package(new Package('P1', type: 'Box', weightKg: BigDecimal::of('2.5'), dimensions: '30 × 20 × 10 cm', trackingNumber: '00340434161094042557')) ->build(); ``` ```php plain use Brick\Math\BigDecimal; use Quittio\Core\Documents\Package; use Quittio\Core\Enums\UnitCode; $note = $quittio->deliveryNote() ->number('LS-2026-0012') ->buyer($buyer) ->reference('AB-2026-0003') // the order confirmation ->deliveryDate('2026-10-02') ->serialisedLine('Router', ['SN-1001', 'SN-1002'], quantity: 2, unit: UnitCode::Unit) ->line('Cable', quantity: 5, unit: UnitCode::Metre) ->package(new Package('P1', type: 'Box', weightKg: BigDecimal::of('2.5'), dimensions: '30 × 20 × 10 cm', trackingNumber: '00340434161094042557')) ->build(); ``` `Package` has `id`, `type`, `weightKg` (`BigDecimal`), `dimensions` and `trackingNumber`. The template lists the packages, and the serial numbers below each line. ## Proforma invoices A proforma invoice announces the amount of a future invoice, e.g. for advance payment or customs. It is not an invoice for tax purposes. Build it with `Quittio::proforma()` (Laravel), `$quittio->proforma()` or `DocumentBuilder::proforma()`. It is rendered like an invoice, with prices, totals, payment terms, bank details and QR code. Its title is "Proforma invoice", and the legal notes contain "This proforma invoice is not an invoice for tax purposes." It never carries e-invoice XML. Do not render a proforma as an invoice. An invoice with the type code (BT-3) 325 (`InvoiceTypeCode::ProformaInvoice`) fails validation with the rule `QUITTIO-PROFORMA` ([Rules and validation](concepts.md#rules-and-validation)), because e-invoice XML with VAT amounts would be booked as an invoice. ## Payment reminders A payment reminder asks the buyer to pay invoices that are overdue. The level counts the reminders: - Level 0 (default) is a friendly payment reminder, titled "Payment reminder" (German "Zahlungserinnerung"). - Level 1 and higher are formal reminders, titled "Reminder no. :level": "Reminder no. 1", "Reminder no. 2" … The German titles are "1. Mahnung" (first reminder), "2. Mahnung" (second reminder) … A negative level throws an `InvalidArgumentException`. ```php laravel use Quittio\Laravel\Facades\Quittio; $reminder = Quittio::paymentReminder(1) // level 1: first reminder ->number('M-2026-0003') ->buyer($buyer) ->openItem('RE-2026-0042', '2026-08-01', '1190.00', dueDate: '2026-08-15', paid: '190.00') ->fee('Reminder costs', '2.50') ->interest('1000.00', '10.27', from: '2026-08-16', until: '2026-10-04') // until is exclusive: the last day with interest is 3 October ->deadline('2026-10-18') ->build(); $reminder->dunning->total('EUR'); // open items + fees + interest, no VAT $reminder->dunning->remittanceText(); // "RE-2026-0042" – open invoice numbers for the transfer ``` ```php plain $reminder = $quittio->paymentReminder(1) // level 1: first reminder ->number('M-2026-0003') ->buyer($buyer) ->openItem('RE-2026-0042', '2026-08-01', '1190.00', dueDate: '2026-08-15', paid: '190.00') ->fee('Reminder costs', '2.50') ->interest('1000.00', '10.27', from: '2026-08-16', until: '2026-10-04') // until is exclusive: the last day with interest is 3 October ->deadline('2026-10-18') ->build(); $reminder->dunning->total('EUR'); // open items + fees + interest, no VAT $reminder->dunning->remittanceText(); // "RE-2026-0042" – open invoice numbers for the transfer ``` The template lists the open items (invoice number, date, due date, amount, paid, open), the fees, the interest lines and "Total to pay", then the deadline text ("Please pay the total amount by …"). The payment block uses the open invoice numbers as remittance information (the document number if none is open). The GiroCode, the QR code for the bank transfer ([Payment QR codes](templates.md#payment-qr-codes)), carries the total of the reminder. Rules: - Reminders have no lines, allowances or charges; the builder rejects them. The amount to pay is `Dunning::total()`: open items plus fees plus interest. - Fees and default interest carry no VAT. They are damages, not payment for a supply (section 1.3 (6) of the German VAT application decree, UStAE). The same applies to the flat rate for late payment of section 288 (5) of the German Civil Code (BGB). - Only actual costs may be claimed as reminder fees; Quittio has no default fee. - A reminder to a business that claims the flat rate and reminder fees of your own gets the notice `QUITTIO-DUNNING-FLAT-RATE-FEES` (warning): reminder fees count towards the flat rate (Article 6 (3) Directive 2011/7/EU, section 288 (5) sentence 3 BGB) and may be claimed only in so far as they exceed it. Documents are not validated, so the notice does not stop rendering: `$document->notices($locale)` and `RenderedDocument::notices()` return it (as `ValidationMessage`), and the render run logs it as warning. - `flatRate(string $claim, $amount = '40.00', ?string $description = null)` adds the flat rate for recovery costs of a late payment between businesses (Article 6 Directive 2011/7/EU; in Germany section 288 (5) BGB) for one claim, as a `DunningFee` of kind `DunningFeeKind::FlatRate` with the claim. The default description is the label `dunning_flat_rate` ("Flat rate for recovery costs, claim RE-…"). Building throws an `InvalidArgumentException` for a second flat rate of the same claim and for a consumer as buyer. Across reminders, track which claims already carried it yourself; the German rules are in [Country packs: Dunning law](country-packs.md#default-interest). - `interest()` takes the first day with interest (`from`, e.g. the day after the due date) and the day after the last day with interest (`until`, exclusive). `InterestCharge::lastDay()` is the last day with interest. The default description uses it: "Default interest 10.27% p.a. on 1,000.00 € from … to …". - Interest is simple interest, counted actual/actual: the days of each calendar year are divided by 365 or 366, so that a full year yields exactly the annual rate. Pass `dayCount: 365` or `dayCount: 360` for a fixed basis. Other values, and a period that ends before it starts, throw an `InvalidArgumentException`. The amount is rounded half up once. Classes of a reminder: - `Dunning` (`$document->dunning`): `level`, `openItems`, `deadline`, `fees` (`DunningFee`: `description`, `amount`, `kind` (`DunningFeeKind::Fee` or `FlatRate`), `claim`), `interest`, `openTotal($currency)`, `feeTotal($currency)`, `interestTotal($currency)`, `total($currency)`, `openInvoiceNumbers()` (unsettled items, without duplicates) and `remittanceText(int $maxLength = 140)` (as many complete numbers as fit, comma separated). - `InterestCharge`: `base`, `ratePercent`, `from`, `until`, `description`, `amount` (a stated amount replaces the calculation), `dayCount`, `days()`, `lastDay()`, `total()`. - `OpenItem`: `invoiceNumber`, `invoiceDate`, `amount`, `dueDate`, `paid`, `description`, `open()` (amount minus paid; negative for overpaid items and credits) and `isSettled()` (nothing open). ### German default interest In Germany, a debtor in default owes interest at the statutory rate of section 288 BGB: the base rate of the Bundesbank plus 9 percentage points (businesses) or 5 points (consumers). The German country pack calculates it, with periods split at every change of the base rate. Add its charges to the reminder: ```php laravel use Brick\Money\Money; use Quittio\Core\Support\Date; use Quittio\Country\DE\Dunning\DefaultInterest; use Quittio\Laravel\Facades\Quittio; $reminder = Quittio::paymentReminder(1) ->number('M-2026-0003') ->buyer($buyer) ->openItem('RE-2026-0042', '2026-06-01', '1000.00', dueDate: '2026-06-15'); // one charge per period with the same base rate; the end date is exclusive $reminder->interestCharge(...(new DefaultInterest)->calculate(Money::of('1000.00', 'EUR'), Date::parse('2026-06-16'), Date::parse('2026-10-05'), consumer: false)); ``` ```php plain use Brick\Money\Money; use Quittio\Core\Support\Date; use Quittio\Country\DE\Dunning\DefaultInterest; $reminder = $quittio->paymentReminder(1) ->number('M-2026-0003') ->buyer($buyer) ->openItem('RE-2026-0042', '2026-06-01', '1000.00', dueDate: '2026-06-15'); // one charge per period with the same base rate; the end date is exclusive $reminder->interestCharge(...(new DefaultInterest)->calculate(Money::of('1000.00', 'EUR'), Date::parse('2026-06-16'), Date::parse('2026-10-05'), consumer: false)); ``` `interestCharge()` takes the charges with their day count (actual/actual in Germany) and texts. For any country pack with a reference rate, or with fixed rates for businesses and consumers (`DunningLaw::hasFixedRates()`), `Quittio\Core\Dunning\DefaultInterest::forCountry($pack)` calculates the same with the pack's `referenceRates()` and `dunningLaw()`; the German class adds the German texts. The descriptions are German by default; any other locale, e.g. `calculate(…, locale: 'en')`, returns English ones. The base rate table, the flat rate and the conditions of default are described in [Country packs](country-packs.md#dunning-law). The country-neutral contract is `CountryPack::dunningLaw()` (`DunningLaw`: `b2bInterestPoints`, `b2cInterestPoints`, `b2bFlatRate`, `dayCount`, `consumerDefaultAfterDays`, `referenceRateName`, `b2cFixedRate`, `b2bFixedRate`). ## Account statements An account statement lists the invoices of a customer and the resulting balance. ```php laravel use Quittio\Laravel\Facades\Quittio; $statement = Quittio::accountStatement() ->number('KA-2026-09') ->buyer($buyer) ->statementPeriod('2026-09-01', '2026-09-30') ->openingBalance('100.00') ->openItem('RE-2026-0050', '2026-09-10', '595.00', dueDate: '2026-09-24', paid: '595.00') ->openItem('RE-2026-0061', '2026-09-28', '238.00', dueDate: '2026-10-12') ->build(); $statement->statement->balance('EUR'); // 338.00 ``` ```php plain $statement = $quittio->accountStatement() ->number('KA-2026-09') ->buyer($buyer) ->statementPeriod('2026-09-01', '2026-09-30') ->openingBalance('100.00') ->openItem('RE-2026-0050', '2026-09-10', '595.00', dueDate: '2026-09-24', paid: '595.00') ->openItem('RE-2026-0061', '2026-09-28', '238.00', dueDate: '2026-10-12') ->build(); $statement->statement->balance('EUR'); // 338.00 ``` The balance is the opening balance plus the open amounts (amount minus paid) of the listed items. The opening balance is the balance at the start of the period and already contains every invoice dated before it. Therefore: - with `openingBalance()`, only items dated within `statementPeriod()` are accepted; - without an opening balance, the statement is an open item list and may list older items; - items dated after the end of the period are always rejected; - without `statementPeriod()`, the period ends on the document date. Violations throw an `InvalidArgumentException`, as does a period that ends before it starts. `AccountStatement` (`$document->statement`) has `period`, `items`, `openingBalance`, `openItems()` (unsettled items) and `balance($currency)`. The template lists all items, the period, the opening balance and the balance; the payment block shows the bank details without QR code. ## Bonus statements A bonus agreed for a period, e.g. 3 % on the annual revenue, reduces the consideration of all invoices of that period afterwards. Instead of one document per invoice, a bonus statement documents the reduction once, per VAT rate. In Germany section 17 (4) UStG requires such a document when the reduction concerns supplies taxed at different rates; it need not be an e-invoice (section 17.1 (3a) UStAE). ```php laravel use Quittio\Core\Enums\VatCategory; use Quittio\Laravel\Facades\Quittio; $statement = Quittio::bonusStatement() ->number('BO-2027-0001') ->buyer($buyer) ->bonusPeriod('2026-01-01', '2026-12-31') ->bonusAgreement('der Bonusvereinbarung vom 15.01.2026') ->bonusOnRevenue('100000.00', '3', VatCategory::StandardRate, '19') // 3,000.00 plus VAT 570.00 ->bonusOnRevenue('20000.00', '3', VatCategory::StandardRate, '7') // 600.00 plus VAT 42.00 ->bonusInvoices('RE-2026-0001', 'RE-2026-0002') // optional ->render(); ``` ```php plain use Quittio\Core\Enums\VatCategory; $statement = $quittio->bonusStatement() ->number('BO-2027-0001') ->buyer($buyer) ->bonusPeriod('2026-01-01', '2026-12-31') ->bonusAgreement('der Bonusvereinbarung vom 15.01.2026') ->bonusOnRevenue('100000.00', '3', VatCategory::StandardRate, '19') // 3,000.00 plus VAT 570.00 ->bonusOnRevenue('20000.00', '3', VatCategory::StandardRate, '7') // 600.00 plus VAT 42.00 ->bonusInvoices('RE-2026-0001', 'RE-2026-0002') // optional ->render(); ``` - `bonusPeriod($start, $end)` is the period of the supplies, `bonusAgreement(string $agreement)` the agreement the bonus is based on. Both are required; `build()` throws an `InvalidArgumentException` without them. - Each reduction is a line "Bonus" with the VAT of its rate: `bonusOnRevenue($revenue, $percent, $vat, $rate = null, ?string $exemptionReason = null, $exemptionReasonCode = null)` calculates it from the net revenue of that rate (description "3 % auf den Nettoumsatz (Entgelt) von 100.000,00 €"); for a bonus on the gross revenue, take the net amount out yourself and pass it to `bonus()`, `bonus($net, $vat, …, ?string $description = null)` takes the net amount. Exempt revenue gets a line of its own with category `E` and the exemption reason. Intra-community supplies (`K`) and exports (`G`) get "Minderung des Entgelts für steuerfreie innergemeinschaftliche Lieferungen" or "… Ausfuhrlieferungen" instead of the exemption text of a supply, unless you pass a reason. The VAT breakdown then shows the reduction of net amount and VAT per rate. - So that it does not read like an invoice with VAT shown, the statement names reductions: the columns "Minderung" and "Summe" instead of "Einzelpreis" and "Betrag", the VAT rows "Minderung USt. 19 %" or "Minderung ohne USt. (…)", the totals "Minderung Entgelt gesamt" and "Bonus gesamt (brutto)" (labels `bonus_label_*`, `bonus_vat_row`, `bonus_vat_row_untaxed`). - The statement names the period and the agreement: "Nachträgliche Minderung der Entgelte für die Lieferungen und sonstigen Leistungen vom 01.01.2026 bis 31.12.2026 gemäß der Bonusvereinbarung vom 15.01.2026 (§ 17 Abs. 4 UStG)." (label `bonus_statement_note`; the German pack adds the reference), the invoices of `bonusInvoices()` if given, and, without payment terms of your own, "Der Bonus wird mit offenen Forderungen verrechnet oder ausgezahlt." (label `bonus_statement_payout`). - The seller pays the bonus: the statement shows no bank details, QR code or amount due. - `BonusStatement` (`$document->bonus`) has `period`, `agreement` and `invoices`. The revenue per rate comes from your accounting; Quittio does not know it. For a reduction of a single invoice, e.g. a cash discount taken, use `priceReduction()` instead ([Price reductions](building-invoices.md#price-reductions)). ## From document to invoice When the customer accepts a quote or the goods are delivered, turn the document into an invoice: ```php use Quittio\Core\Builder\InvoiceBuilder; $invoice = InvoiceBuilder::fromDocument($quote) ->number('RE-2026-0100') ->issueDate('2026-11-16') ->deliveryDate('2026-11-15') ->build(); ``` `fromDocument()` starts an invoice from a quote, order confirmation, delivery note or proforma. - It takes over the parties, the billable lines (amounts are recalculated), document allowances and charges, payment terms and instructions, delivery, buyer reference, purchase order reference, presentation and locale. - Number and notes are not taken over. Set the number, and the issue date (otherwise today). - The number of an order confirmation becomes the sales order reference (BT-14), the number of a delivery note the despatch advice reference (BT-16). Quotes and proformas are not referenced. - Lines of a delivery note have no prices (net price 0, category O) and need prices and VAT before invoicing. The result is a normal `InvoiceBuilder`; validation and e-invoice formats apply when it is rendered. ## Rendering `Quittio::document()` renders a document with more options than `->render()` at the end of the builder chain: ```php laravel use Quittio\Core\Data\Presentation\Presentation; use Quittio\Laravel\Facades\Quittio; $result = Quittio::document($quote) // DocumentData or DocumentBuilder ->locale('en') ->country('DE') ->template('invoices.my-design.layout') ->presentation(new Presentation(title: 'Offer')) ->render(); $html = Quittio::document($quote)->htmlOnly()->render()->html(); ``` ```php plain use Quittio\Core\Data\Presentation\Presentation; $result = $quittio->document($quote) // DocumentData or DocumentBuilder ->locale('en') ->country('DE') ->template('my-design') // my-design.php in template_paths ->presentation(new Presentation(title: 'Offer')) ->render(); $html = $quittio->document($quote)->htmlOnly()->render()->html(); ``` | `PendingDocument` method | Effect | |---|---| | `template(string $template)` | Template ([selection rules](templates.md#selecting-a-template)) | | `locale(string $locale)` | Locale; otherwise the document's locale, the configured locale, the country default | | `country(string $country)` | Country pack | | `presentation(Presentation $presentation)` | Design defaults of this call; the document's own presentation wins | | `htmlOnly()` | HTML instead of PDF | | `option(string $key, mixed $value)` | Output option of this call, e.g. `option('fold_marks', false)` ([output configuration](formats.md#output-configuration)) | | `render()` | `RenderedDocument` | | `queue(?string $connection = null, ?string $queue = null)` | Laravel: renders in a queued job, see below | Documents use the invoice templates and the same view model. The node `documentInfo` holds the document specific values ([view model](templates.md#documentinfo)), `document.kind` the type. The PDF is PDF/A-3b (the archivable PDF variant) when `pdf.pdfa` is set and no watermark is used, and it never contains embedded XML. Documents run no validation and no [mandatory field guard](templates.md#mandatory-field-guard). In Laravel they dispatch `DocumentRendering` and `DocumentRendered` ([Events](laravel.md#events)). `RenderedDocument` (core) has: - `data()`, `html()`, `hasPdf()`, `pdf()` (`LogicException` after `htmlOnly()`), `contents()` (PDF, otherwise HTML) and `mimeType()`; - `filename(?string $extension = null)`; - `save(string $path)`: a file, or a directory (an existing one or a path ending in `/`) for the generated file name; missing directories are created. The Laravel class adds `core()`, `download(?string $filename = null)`, `stream(?string $filename = null)` and `save(?string $disk = null, ?string $path = null)` (default disk `quittio.storage.disk`; a path ending in `/` gets the file name appended). It is `Responsable`, so a controller can return it as a download, and `Attachable` for mails ([Laravel integration](laravel.md)). ### Queueing In Laravel, `queue()->save()` renders the document in a queued job (`Quittio\Laravel\Jobs\RenderDocument`) and stores it on a disk: ```php use Quittio\Laravel\Facades\Quittio; Quittio::document($quote)->locale('de')->queue()->save('documents', 'quotes/'); ``` - The job carries the document as versioned JSON snapshot (`DocumentData::toSnapshot()`, `SNAPSHOT_VERSION`) and the render options as versioned JSON, never as serialised PHP objects. Jobs queued before an update are brought up to date by the classes in `quittio.snapshots.document_upcasters`. - Connection, queue and the dispatch after a database commit follow `quittio.queue.*`, as for invoices. - After storing, the job dispatches `QueuedDocumentStored` (result, disk and path); a job that failed for good dispatches `QueuedDocumentFailed`. Errors that another attempt cannot fix (invalid data, configuration) fail the job at once. `DocumentData::toArray()`, `fromArray()`, `toJson()`, `fromJson()`, `toSnapshot()` and `fromSnapshot()` store and restore documents outside the queue as well. ### File names The file name follows `pdf.filename` (default `{title}_{number}.{ext}`; `{format}` is the document type, `{date}` the document date). Characters other than letters, digits, `.`, `_` and `-` become `_`. Examples: | Document | English file name | German file name | |---|---|---| | Quote `AN-2026-0007` | `Quote_AN-2026-0007.pdf` | `Angebot_AN-2026-0007.pdf` ("Angebot": quote) | | Reminder level 1 `M-2026-0003` | `Reminder_no._1_M-2026-0003.pdf` | `1._Mahnung_M-2026-0003.pdf` ("1. Mahnung": first reminder) | ## Builder methods Parties, lines, notes, discounts and payment data work exactly like in the [invoice builder](building-invoices.md): - lines by name with named values (`->line('Consulting', netPrice: '120.00', quantity: 10, unit: UnitCode::Hour)`), as `Line::make()`, arrays, models or callables; - parties as `Party::make()`, models or callables; - lines without `vat()` get the [default VAT](building-invoices.md#default-vat). Dates accept `Date`, `DateTimeInterface` or a string; amounts are strings. | Method | Effect | |---|---| | `number(string $number)` | Document number | | `issueDate($date)` | Document date; default today (in PHP's default time zone, or the one set with `timezone()` through `tap()`) | | `currency(string $currency)` | Currency; default `EUR` | | `seller(SellerParty\|PartyBuilder\|ProvidesParty\|callable $seller)`, `buyer(BuyerParty\|PartyBuilder\|ProvidesParty\|callable $buyer)` | Parties ([Seller and buyer](building-invoices.md#seller-and-buyer)) | | `line(string\|InvoiceLine\|LineBuilder\|ProvidesInvoiceLine\|array\|callable $line, $netPrice = null, $quantity = null, $unit = null, $vat = null, ?string $description = null, $priceInclVat = null, ?DocumentLineOptions $options = null)` | Line ([Lines](building-invoices.md#lines)); the values are only allowed with a name | | `defaultVat(TaxPreset\|VatCategory $presetOrCategory, …)` | VAT of lines without `vat()` ([Default VAT](building-invoices.md#default-vat)) | | `lines(iterable $lines)` | Several lines | | `optionalLine(string\|InvoiceLine\|LineBuilder\|array\|callable $line, …)` | Optional quote line: shown with its amounts, not in the totals. Takes the same named values as `line()` | | `alternativeLine(string $alternativeTo, string\|InvoiceLine\|LineBuilder\|array\|callable $line, …)` | Alternative to the line with the identifier `$alternativeTo` (BT-126; lines are numbered `1`, `2`, … unless set with `LineBuilder::id()`); shown, not in the totals | | `serialisedLine(string\|InvoiceLine\|LineBuilder\|array\|callable $line, array $serialNumbers, …)` | Delivery note line with serial numbers | | `note(string $content, NoteSubjectCode\|RawCode\|string\|null $subject = null)` | Note (BT-22) with its subject code (BT-21) | | `discountPercent(BigDecimal\|int\|string $percent, ?string $reason = null, $reasonCode = AllowanceReasonCode::Discount)`, `discountAmount(BigDecimal\|int\|string $amount, ?string $reason = null, $reasonCode = AllowanceReasonCode::Discount)` | Document discount, on the lines that count towards the totals | | `dueInDays(int $days)`, `cashDiscount(int $days, string $percent, ?string $baseAmount = null)` | Payment target and cash discount ([Payment terms](building-invoices.md#payment-terms)) | | `paymentTerms(PaymentTerms\|string\|callable $terms)` | Payment terms as text or object | | `creditTransfer(string $iban, ?string $bic = null, ?string $accountName = null)` | Adds a bank account; a configured account stays ([Payment instructions](building-invoices.md#payment-instructions)) | | `buyerReference(?string $reference)`, `purchaseOrderReference(?string $reference)` | Buyer's references | | `reference(string $number, $date = null)` | Preceding document, e.g. the quote of an order confirmation or the order of a delivery note | | `validUntil($date)` | Validity of a quote | | `deliveryDate($date)` | Delivery date | | `deliverTo(?string $recipientName, ?Address $address = null)` | Deliver-to party | | `package(Package $package)` | Package of a delivery note | | `openItem(string $invoiceNumber, $invoiceDate, string $amount, $dueDate = null, ?string $paid = null, ?string $description = null)` | Invoice of a reminder or statement | | `fee(string $description, BigDecimal\|int\|string $amount)` | Reminder fee | | `interest(string $base, BigDecimal\|string $ratePercent, $from, $until, ?string $description = null, ?int $dayCount = InterestCharge::ACTUAL_ACTUAL)` | Default interest of a reminder | | `interestCharge(InterestCharge ...$charges)` | Calculated interest charges, e.g. of `DefaultInterest::calculate()`, with their day count and texts | | `deadline($date)` | Payment deadline of a reminder | | `statementPeriod($start, $end)` | Period of an account statement | | `bonusPeriod($start, $end)`, `bonusAgreement(string $agreement)`, `bonusInvoices(string ...$numbers)` | Period, agreement and invoices of a bonus statement | | `bonus($net, TaxPreset\|VatCategory $vat, $rate = null, ?string $exemptionReason = null, $exemptionReasonCode = null, ?string $description = null)`, `bonusOnRevenue($revenue, $percent, TaxPreset\|VatCategory $vat, …)` | Reduction of one VAT rate of a bonus statement, as a line | | `openingBalance(BigDecimal\|int\|string $amount)` | Opening balance of an account statement | | `presentation(Presentation\|array\|callable $presentation)` | Design of this document ([Templates](templates.md#presentation)) | | `locale(string $locale)` | Locale | | `custom(string $key, mixed $value)` | Custom value (`meta.custom` in the view model) | | `tap(callable $callback)` | Access to the underlying `InvoiceBuilder` | | `build(): DocumentData` | Builds the immutable document | | `render()` | Builds and renders the PDF; only on builders started with `Quittio::quote()` … or `$quittio->quote()` … ([Rendering](#rendering)) | `DocumentBuilder` is `Macroable`: add own methods with `DocumentBuilder::macro('name', fn () => …)`. `tap()` reaches every invoice builder method, but the document keeps only number, date, currency, parties, lines, allowances, charges, notes, buyer reference, purchase order reference, delivery, payment terms, payment instructions, presentation and meta. Other values set through `tap()` are dropped. `build()` throws an `InvalidArgumentException` when a quote, order confirmation, proforma, delivery note or bonus statement has no line, when a bonus statement has no period or agreement, or when a reminder or account statement has lines, allowances or charges. ## DocumentData `build()` returns `Quittio\Core\Documents\DocumentData` (immutable; change values with `with()`). Its properties: `type`, `number`, `issueDate`, `currency`, `seller`, `buyer`, `lines`, `lineOptions` (`DocumentLineOptions` keyed by line identifier), `allowances`, `charges`, `notes`, `validUntil`, `reference`, `referenceDate`, `buyerReference`, `purchaseOrderReference`, `delivery`, `packages`, `dunning`, `statement`, `bonus`, `paymentTerms`, `paymentInstructions`, `totals`, `vatBreakdown`, `presentation` and `meta`. | Method | Returns | |---|---| | `options(string $lineId)` | `DocumentLineOptions` of a line (`optional`, `alternativeTo`, `serialNumbers`, `isBillable()`) | | `billableLines()` | Lines that count towards the totals (without optional and alternative lines) | | `isCalculated()` | Totals are set (or there is nothing to calculate) | | `toInvoiceDraft(bool $billableOnly = true)` | The document as `InvoiceData` for calculation and rendering; never use it as an invoice | Documents are calculated by `DocumentCalculator` with the invoice calculator when they are rendered. Every line gets its amounts; the totals and the VAT breakdown come from the billable lines. <!-- Source: https://quittio.dev/docs/reading --> # Reading incoming invoices This page is about e-invoices you receive, for example from suppliers. Quittio reads XML files (CII and UBL, including XRechnung and Peppol) and PDFs with embedded XML (ZUGFeRD, Factur-X). It returns their content in the same data model that you use to build invoices, so you can take the values into your accounting. If these formats are new to you, see [Formats](concepts.md#formats), [Syntaxes](concepts.md#syntaxes-cii-and-ubl) and [Profiles](concepts.md#profiles) in the E-invoicing basics; field numbers such as BT-24 are explained in [EN 16931 and business terms](concepts.md#en-16931-and-business-terms). ## Reading a file ```php laravel use Quittio\Laravel\Facades\Quittio; $read = Quittio::read($request->file('invoice')->get()); // content of an uploaded XML or PDF $read = Quittio::readFile('/path/to/invoice.pdf'); // or a local file $invoice = $read->data; // InvoiceData as stated in the document $invoice->number; // e.g. "RE-2026-0101" $invoice->seller->name; // the supplier $invoice->totals?->amountDue; // amount due as stated in the document $read->profile; // detected profile key, e.g. "en16931" or "xrechnung" $read->findings; // problems found while reading, e.g. QUITTIO-DECLARED-TOTALS $read->declaredTotals; // totals as stated in the document $read->embeddedFilename; // for PDFs: factur-x.xml, xrechnung.xml, zugferd-invoice.xml … ``` ```php plain $read = $quittio->read(file_get_contents($_FILES['invoice']['tmp_name'])); // content of an uploaded XML or PDF $read = $quittio->readFile('/path/to/invoice.pdf'); // or a local file $invoice = $read->data; // InvoiceData as stated in the document $invoice->number; // e.g. "RE-2026-0101" $invoice->seller->name; // the supplier $invoice->totals?->amountDue; // amount due as stated in the document $read->profile; // detected profile key, e.g. "en16931" or "xrechnung" $read->findings; // problems found while reading, e.g. QUITTIO-DECLARED-TOTALS $read->declaredTotals; // totals as stated in the document $read->embeddedFilename; // for PDFs: factur-x.xml, xrechnung.xml, zugferd-invoice.xml … ``` You get back a `ReadResult` ([The result](#the-result)): - `data` is an `InvoiceData` with the values as stated in the document. Amounts are never corrected. Totals that do not match the lines are reported as finding `QUITTIO-DECLARED-TOTALS` ([Declared amounts](#declared-amounts)). - `findings` lists problems found while reading, e.g. a missing issue date ([Findings](#findings)). - `profile` is the profile detected from the document, e.g. `xrechnung`. `read()` always treats its argument as the content of the document, never as a file name. You can pass request bodies (`$request->getContent()`) and uploads directly. `readFile()` reads a local file. It rejects paths with null bytes, missing or unreadable files, and files larger than the larger of the XML and PDF limits (`UnreadableInvoiceException`). Without Laravel, both methods exist on `Quittio\Core\Quittio` and use the limits of its configuration ([Limits and security](#limits-and-security)). A file that is no supported e-invoice throws an exception ([Errors](#errors)). ## Checking an incoming invoice Reading never validates the whole document. Before you book an invoice, check `$read->findings`, or validate the file: ```php laravel use Quittio\Laravel\Facades\Quittio; $report = Quittio::validateFile($content); // content of an XML or PDF $report = Quittio::validatePath($path); // or a local file if (! $report->isValid()) { // reject the invoice, e.g. show $report->errors() } ``` ```php plain $report = $quittio->validateFile($content); // content of an XML or PDF $report = $quittio->validatePath($path); // or a local file if (! $report->isValid()) { // reject the invoice, e.g. show $report->errors() } ``` `validateFile()` and `validatePath()` read the file and run all configured validation levels on it ([Incoming files](validation.md#incoming-files)). A complete controller that validates an upload and extracts the values for accounting is in [Incoming e-invoices](examples.md#incoming-e-invoices). ## On the command line ```bash php artisan quittio:read invoice.pdf # number, date, type, syntax and profile, parties, lines, totals, findings php artisan quittio:read invoice.xml --json # InvoiceData as JSON php artisan quittio:validate invoice.pdf # validation report ``` See [quittio:read](commands.md#quittioread) and [quittio:validate](commands.md#quittiovalidate). ## Supported documents | Input | Recognised by | Syntax | Content | |---|---|---|---| | CII XML | root `CrossIndustryInvoice` in `urn:un:unece:uncefact:data:standard:CrossIndustryInvoice:100` | `cii` | ZUGFeRD 2.x / Factur-X MINIMUM, BASIC WL, BASIC, EN 16931, EXTENDED; XRechnung CII including the extension | | UBL XML | root `Invoice` or `CreditNote` in the UBL 2.1 namespaces | `ubl` | EN 16931, XRechnung UBL including the extension, Peppol BIS Billing 3.0 | | PDF | content starts with `%PDF` (leading whitespace allowed) | of the embedded XML | ZUGFeRD 2.x / Factur-X, XRechnung embedded in a PDF | Everything else fails: - ZUGFeRD 1.0 (`urn:ferd:CrossIndustryDocument:invoice:1p0`) does not conform to EN 16931 and is rejected with a clear message. - Other root elements fail with "Unknown invoice format". - PDFs without embedded invoice fail with "The PDF does not contain an embedded e-invoice". The profile is detected from the specification identifier (BT-24). In CII it is `GuidelineSpecifiedDocumentContextParameter`, in UBL `cbc:CustomizationID`. Quittio compares it exactly with the identifiers of the installed profiles, for EN 16931:2017 and EN 16931:2026. Country pack profiles such as XRechnung count once the pack is registered. - An unknown identifier leaves `profile` `null` and is reported as information (`QUITTIO-READER-UNKNOWN-PROFILE`). - An identifier starting with `urn:cen.eu:en16931:2026` sets the standard version of the data to EN 16931:2026. ## Errors The reader throws an exception only when it cannot read the document at all: | Exception | When | |---|---| | `Quittio\Core\Xml\UnsafeXmlException` | The XML is too large, not well-formed, has a DOCTYPE, an unsupported encoding or exceeds a tag limit | | `Quittio\Core\Pdf\PdfException` | The PDF is too large, encrypted, malformed, exceeds a structure or decompression limit or uses an unsupported stream filter | | `Quittio\Core\Reading\UnreadableInvoiceException` | Unknown format, ZUGFeRD 1.0, a PDF without embedded invoice, a file that does not exist, is not readable or is too large | All three implement `Quittio\Core\Exceptions\QuittioException`. `validateFile()` and `validatePath()` throw the same exceptions. Everything the reader can read becomes a finding instead. ## The result `Quittio\Core\Reading\ReadResult` (readonly): | Property | Content | |---|---| | `data` | `InvoiceData` as stated: lines with their declared net amounts, the declared totals and VAT breakdown, all other business terms | | `syntax` | `cii` or `ubl` | | `specificationId` | BT-24 as written, or `null` | | `profile` | key of the detected profile (`en16931`, `extended`, `xrechnung`, `peppol` …) or `null` | | `declaredTotals` | `Totals` as stated (BT-106 to BT-115), `null` if the document has no monetary summation | | `declaredVatBreakdown` | `list<VatBreakdown>` as stated (BG-23) | | `findings` | `list<ValidationMessage>` (see [Findings](#findings)) | | `xml` | the XML that was read (for a PDF: the embedded XML) | | `raw` | the input: the PDF bytes, or the XML | | `embeddedFilename` | name of the embedded file for PDFs, otherwise `null` | `hasFindings()` tells whether there are findings. Extended data is read into the same data model as when building invoices ([field reference](field-reference.md)): Factur-X EXTENDED, sub lines from `ParentLineID` or `cac:SubInvoiceLine`, and XRechnung third party payments. ### Declared amounts Totals are never corrected silently. The reader keeps the amounts as stated and recalculates a copy from the lines. Every difference is reported as `QUITTIO-DECLARED-TOTALS` (warning, level L3). It compares: - the net amount of every line (BT-131), - the sum of line net amounts (BT-106), the total without VAT (BT-109), the VAT total (BT-110), the total with VAT (BT-112) and the amount due (BT-115). Documents without lines (Factur-X MINIMUM, BASIC WL) are not recalculated. MINIMUM does not transmit BT-106; it is derived from BT-109, BT-107 and BT-108 (`QUITTIO-READER-DERIVED`). EN 16931 carries the VAT exemption reason (BT-120, BT-121) only on the VAT breakdown. The reader copies it back to the lines, allowances and charges of the VAT group, so a recalculation keeps it. A read invoice can be the start of a builder (`InvoiceBuilder::from($read->data)`) or be cancelled ([Building invoices](building-invoices.md)). To keep its declared amounts there, the reader stamps a fingerprint of the amount inputs into the meta data (`$read->data->meta->amountsFingerprint()`). As long as lines, prices, allowances, charges, VAT breakdown and currency are unchanged, `InvoiceBuilder::from($read->data)` and cancellations of the read invoice keep: - declared line net amounts within 0.02 of quantity × price ± allowances and charges, - declared VAT amounts less than one currency unit from the recalculation, e.g. when another system rounded per line. Data changed before (e.g. with `with()`) no longer matches the fingerprint and is recalculated completely. `Quittio::make($read->data)` recalculates everything. The price base quantity (BT-149, BT-150) is read from the net price, or from the gross price if only the gross price states it. If both state different base quantities (CII), the gross price and discount are converted to the base quantity of the net price. With different units they are kept as stated, and a warning is reported. ## Findings The reader is tolerant: it reads as much of the document as possible and reports problems as findings instead of failing. Codes starting with `BR-` are the EN 16931 rules that the problem breaks ([Rules and validation](concepts.md#rules-and-validation)). Findings have level L1 unless noted. Errors mean that values are missing or could not be read as stated: | Code | Severity | Meaning | |---|---|---| | `BR-03` | error | The issue date (BT-2) is missing or unreadable. The placeholder `1970-01-01` is used, never the current date. | | `BR-05`, `BR-CL-04` | error | The invoice currency (BT-5) is missing or not an ISO 4217 code. The amounts are read in the currency of the amounts, otherwise in `XXX` (no currency). | | `QUITTIO-READER-CURRENCY` | error / warning | Amounts use another currency than BT-5 and are read as BT-5 (error); only the VAT total in accounting currency (BT-111) may differ. In CII a BT-110 without `currencyID` is read in the invoice currency (warning). | | `QUITTIO-READER-EXCHANGE-RATE` | warning | The exchange rate (CII) converts other currencies than BT-5 and BT-6. | | `QUITTIO-READER-DATE` | error | A date is not in the format of the syntax: CII format 102 (`YYYYMMDD`), UBL `YYYY-MM-DD` with an optional time zone. The date is not read. | | `QUITTIO-READER-NUMBER` | error | A number is not a decimal number (exponents like `1e3`, separators, more than 40 characters) or a payment term period is no whole number. The value is not read. | | `BR-DEC-…` | error | An amount whose business term has a BR-DEC rule has more than two decimals. It is rounded to two decimals. | | `QUITTIO-READER-DECIMALS` | warning | Another amount has more than two decimals and is rounded. | | `BR-12` … `BR-15`, `BR-45`, `BR-46` | error | A mandatory amount (BT-106, BT-109, BT-112, BT-115, BT-116, BT-117) is missing; 0.00 is used. Without the document totals (BG-22: CII `SpecifiedTradeSettlementHeaderMonetarySummation`, UBL `LegalMonetaryTotal`) `BR-12` (only with lines) to `BR-15` are reported and `data->totals` and `declaredTotals` stay `null`; `validateFile()` then reports these instead of `QUITTIO-NOT-CALCULATED`. | | `QUITTIO-READER-DERIVED` | info | BT-106 was derived for a document without lines. | | `BR-22`, `BR-23` | error | A line has no quantity (0 is used) or no unit. | | `QUITTIO-READER-SUBLINE-QUANTITY`, `QUITTIO-READER-SUBLINE-UNIT` | info | A sub line of the extension omits quantity or unit. | | `QUITTIO-READER-DUPLICATE-LINE` | warning | A line identifier is used more than once (CII). | | `QUITTIO-READER-PARENT-LINE` | warning / error | A sub line refers to a parent line that does not exist (warning), to itself, to a cycle or to a hierarchy deeper than 32 levels (error); it is read as a top-level line (CII). | | `QUITTIO-READER-BASE-QUANTITY` | info / warning | Net and gross price state different base quantities (CII): converted (info) or not convertible (warning). | | `QUITTIO-READER-VAT-CATEGORY` | error | Unknown VAT category; `S` is assumed. | | `QUITTIO-READER-UNKNOWN-CODE` | info / warning | A code that this package version does not know (unit, scheme, reason codes …) is kept as raw value (info); a VAT point date code outside the code list (warning). Codes of the official code lists without an enum case are read without finding. | | `QUITTIO-READER-UNIT` | warning | A payment terms period is not given in days or weeks (CII); weeks are converted to days. | | `QUITTIO-READER-INSTALLMENT` | warning | A partial payment (EXTENDED) without due date is skipped. | | `QUITTIO-READER-ATTACHMENT` | warning | An attached document has invalid Base64, an unsupported MIME code or no usable file name and is skipped. | | `QUITTIO-READER-UNKNOWN-PROFILE` | info | The specification identifier (BT-24) is not known to this installation. | | `QUITTIO-READER-PDF-CANDIDATES` | warning | The PDF embeds several invoice files with different content, or several XML files without a known name; the chosen file is named. | | `QUITTIO-READER-PDF-AF` | warning | The embedded file is not an associated file (`/AF`), as PDF/A-3 requires. | | `QUITTIO-READER-PDF-RELATIONSHIP` | warning | The `/AFRelationship` of the embedded file does not match the profile (`Alternative`, or `Data` for MINIMUM and BASIC WL). | | `QUITTIO-DECLARED-TOTALS` | warning (L3) | The declared amounts differ from a recalculation from the lines. | | `QUITTIO-READER-RECALCULATION` | warning (L3) | The invoice could not be recalculated for the comparison. | Unknown codes are errors in `validateFile()`, where the code list rules (`BR-CL-…`) run. ## PDF A ZUGFeRD or Factur-X PDF carries the invoice XML as embedded file ([Embedded files](formats.md#embedded-files)). The reader finds embedded files in the associated files (`/AF`) of the document catalog and in the name tree (`/Names /EmbeddedFiles`). This works also in PDFs with cross-reference streams, object streams, hybrid files and incremental updates. Damaged cross-reference data is rebuilt by scanning the file. The file is chosen in this order: 1. A known file name (`factur-x.xml`, `xrechnung.xml`, `zugferd-invoice.xml`, `ZUGFeRD-invoice.xml`, case-insensitive) before any other `.xml` file. 2. Among those, files referenced from `/AF` before files only in the name tree. 3. Then the order of the known names and of the document. Up to three further candidates with a known name are compared with the chosen file; different content is reported (`QUITTIO-READER-PDF-CANDIDATES`). Encrypted PDFs cannot be read. Streams must use `FlateDecode` (with PNG or TIFF predictors) or no filter. ## Limits and security Incoming files come from outside, so the reader limits what it accepts: | Protection | Limit | |---|---| | XML size | `quittio.reader.max_xml_bytes` (10 MB); without Laravel `reader.max_xml_bytes` | | PDF size | `quittio.reader.max_pdf_bytes` (25 MB) | | Decompressed size of every PDF stream | `quittio.reader.max_decompressed_bytes` (50 MB) | | DOCTYPE | Rejected (also an internal subset), so there are no external entities, no DTDs and no entity expansion; libxml runs without network access and without entity substitution | | Encoding | UTF-8, UTF-16, US-ASCII, ISO-8859-*, Windows-125*; UTF-32, UTF-7, EBCDIC and other encodings are rejected | | Start tags | at most 64 KB and 256 attributes per element, at most 256 namespace declarations in scope (checked before parsing) | | Numbers | decimal literals of at most 40 characters, no exponents | | PDF structure | at most 1,000,000 objects, 100 cross-reference sections, reference chains of 32, 100,000 objects per object stream, 100,000 objects when rebuilding, nesting depth 64; name tree depth 10 and 1,000 nodes, 1,000 file specifications, every node visited once | | Sub lines | hierarchies deeper than 32 levels are flattened (CII) | | File names | embedded file names and attachment file names are never used as paths: directory parts and control and format characters (e.g. a right-to-left override) are removed, `.`, `..` and empty names are rejected | Untrusted values are shortened in messages, and the currency of amounts is compared in PHP, never inside an XPath expression. The configuration keys are described in [Reader](configuration.md#reader). ## Own readers `Quittio\Core\Reading\InvoiceReader` can be used directly: ```php use Quittio\Core\Pdf\PdfEmbeddedFileExtractor; use Quittio\Core\Reading\InvoiceReader; $reader = new InvoiceReader( readers: null, // null = InvoiceReader::defaultReaders(): CII and UBL profiles: null, // null = ProfileRegistry::withDefaults() (no country pack profiles) pdfExtractor: new PdfEmbeddedFileExtractor(maxPdfBytes: 25 * 1024 * 1024, maxDecompressedBytes: 50 * 1024 * 1024), maxXmlBytes: 10 * 1024 * 1024, ); $read = $reader->withReader(new MyFormatReader)->readFile('/path/to/invoice.xml'); ``` A reader for another XML format implements `FormatReader` (`canRead(DOMDocument $document): bool`, `read(DOMDocument $document, string $xml): ReadResult`). `withReader()` returns a copy with the reader added after the default ones. Country packs provide readers for national formats with `CountryPack::readers()`. It returns new instances on every call, because readers keep the state of one document. `Quittio::read()`, `readFile()`, `validateFile()` and `validatePath()` try them after the CII and UBL readers, for every registered pack. The XSD driver (L4) knows only CII and UBL and reports other root elements (`XSD-UNKNOWN-ROOT`); add a validator for a national format with `addValidator()`. A PDF extractor implements one of two interfaces: - `EmbeddedXmlExtractor::extract(string $pdf): ?array` returns file name and XML, - `DiagnosingXmlExtractor::extractFile(string $pdf): ?ExtractedXml` returns `filename`, `xml`, `relationship` and `findings`. `PdfEmbeddedFileExtractor::names($pdf)` lists the names of all embedded files. <!-- Source: https://quittio.dev/docs/laravel --> # Laravel integration This page explains how Quittio works in a Laravel application: you start an invoice, render it, save, download or mail the result, render in the queue, react to events and adapt templates, translations and drivers. Read [Getting started](getting-started.md) first for a first invoice. The terms used here (format, profile, ZUGFeRD, XRechnung) are explained in [E-invoicing basics](concepts.md). `quittio/laravel` connects the country-neutral core with Laravel. It needs PHP 8.3 and Laravel 13. ```bash composer require quittio/quittio # core, Laravel integration and country pack Germany php artisan quittio:install # publishes config/quittio.php (and config/quittio/countries/de.php for Germany) ``` Then set your company in `config/quittio.php` ([The keys you set first](configuration.md#the-keys-you-set-first)). ## Overview A typical invoice goes through these steps: ```php use Quittio\Core\Enums\UnitCode; use Quittio\Laravel\Facades\Quittio; $result = Quittio::invoice() // 1. start: seller from config/quittio.php ->number('RE-2026-0042') ->deliveryDate('2026-09-30') // date of supply, mandatory in Germany ->buyer($customer) // a model that implements ProvidesParty ->line('Web development', netPrice: '95.00', quantity: 24, unit: UnitCode::Hour) ->dueInDays(14) ->render(); // 2. render: format chosen automatically $result->save('invoices', '2026/'); // 3. save on a filesystem disk … return $result->download(); // … or download, or attach to a mail ``` | Step | What you use | Section | |---|---|---| | Start an invoice | `Quittio::invoice()` | [Starting invoices](#starting-invoices) | | Render it | `->render()`, or `Quittio::make($invoice)` for more options | [Rendering invoices](#rendering-invoices) | | Hand it out | `->save()`, `->download()`, `->stream()`, mail attachment | [Saving, downloading and mailing](#saving-downloading-and-mailing) | | Render later | `->queue()->save()` | [Queueing](#queueing) | | React to rendering | `InvoiceRendered` and other events | [Events](#events) | | Cancel an invoice | `$result->cancel()` | [Cancellations](#cancellations) | | Quotes, reminders and other documents | `Quittio::quote()` … | [Documents](#documents) | | Adapt the output | Blade templates, translations, drivers | [Blade templates](#blade-templates) and the sections after it | All calls go through the facade `Quittio\Laravel\Facades\Quittio`. Instead of the facade you can inject `Quittio\Laravel\QuittioManager`; both are the same singleton. Every method is listed in [Facade](#facade). ## Starting invoices `Quittio::invoice()` starts an invoice. It returns an `InvoiceBuilder` ([Building invoices](building-invoices.md)) that already has your company as seller, its first bank account and the small business setting of `config/quittio.php` ([Seller](configuration.md#seller)). You add the number, the customer, the lines and the payment terms. Then you end the chain: - `->render()` renders the invoice: PDF and XML, in a [`RenderedInvoice`](#renderedinvoice). - `->build()` returns the data only (an `InvoiceData`), e.g. to store a draft or to render it later with `Quittio::make()`. ```php use Quittio\Core\Enums\UnitCode; use Quittio\Laravel\Facades\Quittio; $builder = Quittio::invoice() ->number('RE-2026-0042') ->deliveryDate('2026-09-30') // date of supply, mandatory in Germany ->buyer($customer) // a model that implements ProvidesParty ->line('Web development', netPrice: '95.00', quantity: 24, unit: UnitCode::Hour) ->dueInDays(14); $result = $builder->render(); // format chosen automatically $result = $builder->render('xrechnung-cii'); // one format $result = $builder->render(['zugferd', 'xrechnung-cii']); // several formats; the first is the main result $report = $builder->check(); // validate only, no PDF $invoice = $builder->build(); // the data, not rendered ``` `render(string|array|null $format = null)` is the same as `Quittio::make($builder)->format($format)->render()`. For profile, locale, template or the queue, pass the builder to `Quittio::make()` ([Rendering invoices](#rendering-invoices)). `check(string|array|null $format = null)` validates in the same way, including the XML, but renders no PDF. It returns the `ValidationResult` and does not throw for invalid data ([Validation](validation.md)). The builder is a `Quittio\Laravel\Builder\RenderableInvoiceBuilder`, a subclass of `InvoiceBuilder`, so all builder methods and macros work. Documents start the same way, with the seller and bank account of the configuration. They end with `->build()` or `->render()` (PDF); see [Documents](#documents): | Method | Document | |---|---| | `Quittio::quote()` | Quote | | `Quittio::orderConfirmation()` | Order confirmation | | `Quittio::deliveryNote()` | Delivery note | | `Quittio::proforma()` | Proforma invoice | | `Quittio::paymentReminder(int $level = 0)` | Payment reminder (level 0) or reminder (level 1, 2 …) | | `Quittio::accountStatement()` | Account statement | | `Quittio::bonusStatement()` | Bonus statement (reduction of the consideration of a period, section 17 (4) UStG) | ### Another seller The bank account and the small business setting belong to the seller of the configuration. So `->seller(...)` with another seller (`Party::make()`, a `SellerParty` or a model) removes everything the configuration set for its seller: the bank account and the small business flag. With the [Managed layer](#managed-layer) (the optional package that stores invoices in the database) it also removes the issuer's payment terms, design, locale, time zone and currency. What you set on the builder yourself stays, also when you set it before `->seller()`. A callable changes the configured seller instead and keeps its values: ```php use Quittio\Core\Builder\Party; use Quittio\Core\Data\Meta; use Quittio\Core\Enums\PaymentMeansCode; use Quittio\Laravel\Facades\Quittio; Quittio::invoice() ->seller(Party::make('Lisa Klein')->taxNumber('21/815/08150')->identifier('21/815/08150')->address('Gartenstraße 7', '12345', 'Musterstadt', 'DE')) ->payment(PaymentMeansCode::SepaCreditTransfer, iban: 'DE89370400440532013000') // Lisa's account ->flag(Meta::FLAG_SMALL_BUSINESS); // if she is a small business Quittio::invoice()->seller(fn ($s) => $s->contact('Max Muster')); // same seller, same defaults ``` ### Seller from the configuration `Quittio\Laravel\Seller` turns the `seller` section of `config/quittio.php` ([Configuration](configuration.md#seller)) into invoice data: | Method | Effect | |---|---| | `Seller::fromConfig(): SellerParty` | Builds the seller: name, VAT identifier, tax number, address, legal registration, identifiers, additional legal information, contact (when one of its values is set) and electronic address (when set) | | `Seller::apply(InvoiceBuilder $builder): InvoiceBuilder` | Sets the seller on the builder and adds a credit transfer with the first bank account that has an IBAN. With `seller.small_business`, it flags the invoice as small business invoice (`Meta::FLAG_SMALL_BUSINESS`). Returns the same builder. | `Quittio::invoice()` and the document methods use them through `ConfigInvoiceDefaults` (see below). Use them directly for builders you create yourself: ```php use Quittio\Core\Builder\InvoiceBuilder; use Quittio\Core\Documents\DocumentBuilder; use Quittio\Laravel\Seller; $invoice = Seller::apply(InvoiceBuilder::make())->number('RE-2026-0042')/* ... */->build(); $quote = DocumentBuilder::quote()->seller(Seller::fromConfig()); ``` With the Managed layer, issuer profiles hold the seller instead (`$issuer->builder()`). **Taking the seller from somewhere else.** `Quittio::invoice()` gets its seller from the binding of `Quittio\Laravel\Contracts\InvoiceDefaults` (`apply(InvoiceBuilder $builder): void`; for documents it is applied to their invoice builder). The default binding, `ConfigInvoiceDefaults`, calls `Seller::apply()`. The Managed layer binds the current issuer. Bind your own class to take the seller from elsewhere, e.g. from the current tenant: ```php use Quittio\Core\Builder\InvoiceBuilder; use Quittio\Laravel\Contracts\InvoiceDefaults; $this->app->bind(InvoiceDefaults::class, fn () => new class implements InvoiceDefaults { public function apply(InvoiceBuilder $builder): void { $builder->seller(tenant()->billingParty()); // a SellerParty, PartyBuilder or ProvidesParty } }); ``` ## Rendering invoices Rendering turns invoice data into the output files. `Quittio::make()` starts a render call for data you built before: an `InvoiceData`, an `InvoiceBuilder`, or a model that implements `ProvidesInvoiceData`. It offers the options that `->render()` on the builder does not have: ```php $result = Quittio::make($invoice)->render(); // format chosen automatically $result = Quittio::make($order)->format('zugferd')->profile('en16931')->locale('de')->render(); $result = Quittio::make($invoice)->formats(['zugferd', 'xrechnung-cii'])->render(); ``` A run does everything in one go: 1. It calculates the invoice: totals, VAT breakdown, and the due date from `defaults.due_days`. You never calculate totals yourself. 2. It chooses the format (the output, e.g. a ZUGFeRD PDF or an XRechnung XML, see [Formats](concepts.md#formats)) and the profile (how much of EN 16931 the XML contains, see [Profiles](concepts.md#profiles)). 3. It validates the invoice ([Validation per call](#validation-per-call)). 4. It writes the XML, renders the Blade template and produces the PDF/A (the archivable PDF standard) with the embedded XML. All formats of one call share the same calculation. ### PendingInvoice `Quittio::make()` returns a `Quittio\Laravel\Rendering\PendingInvoice`. It collects the options of one call; every setter returns the same object. | Method | Effect | |---|---| | `format(string $format)` | One output format: `zugferd` (`factur-x`, `facturx`), `xrechnung-cii` (`xrechnung`), `xrechnung-ubl`, `cii`, `ubl`, `peppol`, `pdf`, `html`, `json`. Replaces earlier formats. | | `formats(array $formats)` | Several formats from one calculation; duplicates are removed. The first is the main result. | | `profile(Profile\|string $profile)` | Profile key (`minimum`, `basic-wl`, `basic`, `en16931`, `extended`, `peppol`; `xrechnung`, `xrechnung-extension` and `xrechnung-cvd` with the German country pack; aliases such as `comfort`) or a `Profile` object. Every requested format must allow it, otherwise the run throws a `ConfigurationException`. | | `locale(string $locale)` | Locale of labels and formatting | | `country(string $country)` | Leading country pack (upper-cased), instead of the seller's country | | `template(string $template)` | Blade view or plain PHP template name; only allowed views (see [Blade templates](#blade-templates)) | | `presentation(Presentation $presentation)` | Design for this call, merged over the configured design property by property; the invoice's own presentation wins (see [Templates and design](templates.md)) | | `validate(bool $throwOnError = true)` | Validation mode `error` (`true`) or `warn` (`false`) for this call | | `withoutValidation()` | Validation mode `off` for this call | | `option(string $key, mixed $value)` | Option for the view model and the validation rules (see [Render options](#render-options)) | | `render()` | Renders: `RenderedInvoice` | | `check()` | Validates like `render()` without template and PDF: `ValidationResult` | | `prepare()` | Calculates and validates without rendering: `PreparedInvoice` | | `queue(?string $connection = null, ?string $queue = null)` | Renders in a queued job: `QueuedInvoice` (see [Queueing](#queueing)) | | `data()` | The invoice data passed to `make()` (not yet calculated) | | `options()` | The collected `Quittio\Core\Rendering\RenderOptions` | ### Fallback order Without an explicit value, each choice falls back in this order: | Choice | Order | |---|---| | Format | `format()`/`formats()` → `defaults.format` → automatic choice (when `defaults.format` is `null` or `'auto'`; see [Automatic choice](formats.md#automatic-choice)) | | Profile | `profile()` → `defaults.profile`, where the format allows it → profile of the automatic choice → default profile of the format. CII formats switch to EXTENDED (the profile with more fields than EN 16931) when the invoice uses EXTENDED features and `profile()` was not called (`format_resolver.auto_upgrade_profile`). | | Locale | `locale()` → invoice locale (`InvoiceBuilder::locale()`) → `defaults.locale` → country pack | | Country pack | `country()` → seller country (BT-40, see [business terms](concepts.md#en-16931-and-business-terms)) → `defaults.country` → generic EN 16931 pack | | Template | `template()` → `Presentation::$template` of the invoice → `template` of the presentation passed with `presentation()` → `pdf.template` | | Validation | `validate()`/`withoutValidation()` → `validation.mode` | ### Render options `option()` passes values to the view model and the validation rules. They override configured values of the same name: | Key | Value | Effect | |---|---|---| | `watermark` | string | Watermark text, e.g. `'DRAFT'`. Only for the formats `pdf` and `html`: with any format that produces e-invoice XML, the run throws a `ConfigurationException`. Watermarked PDFs are not PDF/A. | | `paper` | string | Paper size (like `pdf.paper`) | | `markdown` | bool | Line descriptions and notes as Markdown (like `pdf.markdown`) | | `fold_marks` | bool | Fold and punch marks (like `pdf.fold_marks`) | | `girocode_amount` | `'due'`\|`'discounted'` | Amount in the GiroCode, the payment QR code (like `pdf.payment_qr.girocode_amount`) | ### Validation per call Validation checks the invoice against the rules of EN 16931, the format and the country ([Rules and validation](concepts.md#rules-and-validation)). The validation mode decides what happens with errors: - In mode `error`, a run with errors throws `Quittio\Core\Validation\ValidationException`. With `validation.block_on_warnings`, warnings throw as well. The exception's `result` property holds the `ValidationResult`. - In mode `warn`, the result is attached and rendering continues. - In mode `off`, nothing is validated. ```php use Quittio\Core\Validation\ValidationException; use Quittio\Laravel\Facades\Quittio; try { $result = Quittio::make($invoice)->format('xrechnung-cii')->render(); } catch (ValidationException $e) { return back()->withErrors(array_map(fn ($m) => $m->message, $e->result->errors())); } $result = Quittio::make($invoice)->validate(false)->render(); // never throws on findings $result->validation()->warnings(); ``` `check()` always validates with the configured levels, whatever the mode, and never throws on findings. It does not render the template or the PDF, so the PDF/A check (level L6, veraPDF) does not run: ```php $report = Quittio::make($invoice)->format('xrechnung-cii')->check(); $report->isValid(); ``` `prepare()` returns a `Quittio\Core\Rendering\PreparedInvoice` with the decisions of a run: | Member | Content | |---|---| | `data` | Calculated `InvoiceData` | | `formats` | Format key => `Profile` (null for formats without XML) | | `country`, `buyerCountry` | Leading country pack and the buyer's pack (or null) | | `locale` | Chosen locale | | `validation` | `ValidationResult` of the data and XML levels | | `format()`, `profile()` | First format and its profile | Validation levels and messages: [Validation](validation.md). Common errors and their fixes: [Troubleshooting](troubleshooting.md). ### RenderedInvoice `render()` returns a `Quittio\Laravel\Rendering\RenderedInvoice` for the first format. It holds the files in memory. It implements `Illuminate\Contracts\Mail\Attachable` and `Illuminate\Contracts\Support\Responsable`, so you can attach it to a mail or return it from a controller. | Method | Returns | |---|---| | `data()` | Calculated `InvoiceData` (totals, VAT breakdown, due date) | | `format()` | Format key of this result | | `formats()` | All format keys of the run | | `as(string $format)` | The result of another format of the same run; a format that was not rendered throws a `LogicException` | | `profile()` | `Profile` of the XML, `null` for formats without XML | | `validation()` | `ValidationResult` of this format (warnings; in mode `warn` also errors) | | `hasPdf()`, `hasXml()` | Whether the format produced a PDF or XML | | `pdf()` | PDF bytes (`zugferd`, `pdf`); other formats throw a `LogicException` | | `xml()` | XML (`zugferd`, `xrechnung-cii`, `xrechnung-ubl`, `cii`, `ubl`, `peppol`, `pdf` with `b2c_embed_xml`); other formats throw | | `html()` | HTML (format `html` only); other formats throw | | `json()` | The calculated invoice as JSON (`InvoiceData::toJson()`), for every format | | `contents()` | Main output: PDF, otherwise XML, HTML or JSON | | `mimeType()` | `application/pdf`, `application/xml`, `text/html` or `application/json` | | `filename(?string $extension = null)` | File name from `pdf.filename`, e.g. `Rechnung_RE-2026-0042.pdf` ("Rechnung" is the German title, invoice); with `$extension` for another output, e.g. `filename('xml')` | | `hashes()` | SHA-256 of the outputs: `['pdf' => …, 'xml' => …, 'html' => …]` (only those produced) | | `download(?string $filename = null)` | HTTP response as attachment | | `stream(?string $filename = null)` | HTTP response for inline display in the browser | | `toResponse($request)` | Same as `download()`: return the result from a controller | | `toMailAttachment()` | `Illuminate\Mail\Attachment` with file name and MIME type | | `save(?string $disk = null, ?string $path = null)` | Stores the main output on a filesystem disk, returns the path; throws a `RuntimeException` when the disk does not store it | | `cancel(string $number, ?string $reason = null, ?array $lines = null, Date\|DateTimeInterface\|string\|null $issueDate = null, ?string $strategy = null, ?CancellationHistory $history = null)` | Builds the cancellation of this invoice with `Quittio::cancellation()` and renders it in the formats of this run; returns its `RenderedInvoice` ([Cancellations](#cancellations)) | | `core()` | The core result `Quittio\Core\Rendering\RenderedInvoice` (adds `extension()` and `save(string $localPath)` for local files) | ## Saving, downloading and mailing A rendered result is not stored anywhere yet. Save it on a disk, return it as an HTTP response or attach it to a mail. The same methods work for documents (`RenderedDocument`, see [Documents](#documents)). ### File names Results are named by the pattern `pdf.filename` (default `{title}_{number}.{ext}`). The placeholders are: - `{title}`: the document title in the render locale, e.g. "Rechnung" (invoice), "Stornorechnung" (cancellation invoice) or, in English, "Invoice", - `{number}`: the invoice number, - `{date}`: the issue date as `Y-m-d`, - `{format}`: the format key (for quotes and other documents: the document type), - `{ext}`: the extension (`pdf`, `xml`, `html`, `json`). Title and number are reduced to letters, digits, `.`, `_` and `-`. ```php // 'filename' => '{date}_{number}.{ext}' $result->filename(); // 2026-10-03_RE-2026-0042.pdf $result->as('xrechnung-cii')->filename(); // 2026-10-03_RE-2026-0042.xml ``` ### Responses Return the result from a controller to send it to the browser: ```php public function show(Invoice $invoice) { $result = Quittio::make($invoice)->format('zugferd')->render(); return $result; // download (Content-Disposition: attachment) // return $result->download('invoice.pdf'); // own file name // return $result->stream(); // inline, e.g. in a browser tab or iframe } ``` The response carries: - the content as body, - `Content-Type` from `mimeType()`, - `Content-Disposition` with an ASCII fallback name and the UTF-8 name (`filename*=`), - `Cache-Control: private, no-store`. The ASCII fallback transliterates: `Rechnung Über.pdf` becomes `Rechnung_Uber.pdf`, and `ß` becomes `ss`. Every other character outside letters, digits, `.`, `_` and `-` becomes one `_`. `stream()` sends the complete file inline; it is not a chunked `StreamedResponse`. ### Storage ```php $path = $result->save(); // quittio.storage.disk, file name of the result $path = $result->save('invoices', '2026/'); // directory (ends with "/"): 2026/Rechnung_RE-2026-0042.pdf $path = $result->as('xrechnung-cii')->save('invoices', '2026/RE-2026-0042.xml'); ``` `save()` stores `contents()` (the main output) with `Storage::disk($disk)->put()` and returns the path: - The disk defaults to `quittio.storage.disk`, and to the default disk when that is empty. - The path defaults to `filename()`. A path that ends with `/` is a directory; the file name is added. - Existing files are overwritten (unlike the archive of the Managed layer). For a local path without a disk, use `$result->core()->save('/var/invoices')`. ### Mail attachments `RenderedInvoice` and `RenderedDocument` are attachable. Return them from `attachments()` of a mailable; file name and MIME type come from the result: ```php use Illuminate\Mail\Mailable; use Illuminate\Mail\Mailables\Content; use Illuminate\Mail\Mailables\Envelope; use Quittio\Laravel\Facades\Quittio; use Quittio\Laravel\Rendering\RenderedInvoice; final class InvoiceMail extends Mailable { public function __construct(private RenderedInvoice $invoice) {} public function envelope(): Envelope { return new Envelope(subject: 'Invoice '.$this->invoice->data()->number); } public function content(): Content { return new Content(view: 'mail.invoice'); } public function attachments(): array { return [$this->invoice]; // file name and MIME type of the result } } Mail::to($customer)->send(new InvoiceMail(Quittio::make($invoice)->format('zugferd')->render())); ``` `->attach($result)` works in `build()` and in notification mail messages as well. - For an XRechnung, attach the XML result (`$result->as('xrechnung-cii')`). If the recipient wants a readable PDF too, render a second format `pdf` in the same run and attach it as well. - For queued mailables, consider storing the file first (`save()`) and attaching it with `Attachment::fromStorageDisk()`, so that the file does not travel through the queue. The Managed layer ships its own mailable and delivery tracking (see [Managed layer](managed.md#delivery)). ## Queueing Render in a queued job when a request should not wait for the PDF, e.g. for many invoices at once. The job renders and saves the result on a disk: ```php $job = Quittio::make($invoice)->format('zugferd')->queue()->save('invoices', '2026/'); $job = Quittio::make($invoice)->queue('redis', 'invoices')->save(); ``` `queue()` returns a `Quittio\Laravel\Rendering\QueuedInvoice`. Its only method, `save(?string $disk = null, ?string $path = null)`, dispatches a `Quittio\Laravel\Jobs\RenderInvoice` job and returns it. | Detail | Behaviour | |---|---| | Connection, queue | Arguments of `queue()`, else `quittio.queue.connection` and `quittio.queue.queue`. The default queue is `quittio`: start a worker with `--queue=quittio,…`. | | Payload | The invoice as versioned JSON snapshot (`invoice`), the `RenderOptions` of the call as versioned JSON (`options`, see `RenderOptions::toArray()`; `renderOptions()` restores them), `disk` and `path` (public properties). A profile object travels by its key; options must be scalars, `null` or arrays of them. | | Dispatch | Inside a database transaction after the commit, and not at all after a rollback (`quittio.queue.after_commit`, default `true`) | | Execution | `handle()` renders with the stored options (events included), calls `save($disk, $path)` and dispatches `QueuedInvoiceStored`. A `null` disk is resolved when the job runs. | | Retries | `$tries = 3` with 10 and 60 seconds between the attempts, for errors that may pass (a disk that is not reachable, a KoSIT daemon that restarts). Errors that another attempt cannot fix fail the job at once: validation errors, invalid or unreadable data, configuration errors (`RenderInvoice::PERMANENT_ERRORS`). | | Failure | `failed()` dispatches `QueuedInvoiceFailed` with the job and the exception | Documents are queued the same way: `Quittio::document($quote)->queue()->save('documents', 'quotes/')` dispatches a `RenderDocument` job, which carries the document as versioned snapshot and dispatches `QueuedDocumentStored` or `QueuedDocumentFailed` ([Documents: queueing](documents.md#queueing)). | Upgrades | Snapshots of older data model versions are migrated by `quittio.snapshots.upcasters` ([Snapshots](configuration.md#snapshots)); `data()` returns the restored invoice. Jobs queued by Quittio 0.1.0 (options as PHP object) still run. | With the `sync` connection the job runs immediately. ## Events Events let you react to rendering, e.g. to log every invoice or to store its hashes. All events are in the namespace `Quittio\Laravel\Events`. They are dispatched by `QuittioManager::renderInvoice()`, i.e. by `PendingInvoice::render()`, by queued `RenderInvoice` jobs and by the rendering of the Managed layer. | Event | Dispatched | Payload | |---|---|---| | `InvoiceRendering` | Before the invoice is calculated, validated and rendered | `invoice` (`InvoiceData` as passed, not calculated), `options` (`RenderOptions`) | | `InvoiceValidated` | After all formats were rendered, before `InvoiceRendered`, when the run validated and validation did not block it: in mode `error` and in mode `warn`; not in mode `off` (nothing was validated) | `invoice` (calculated `InvoiceData`), `result` (`ValidationResult` of the main format; in mode `warn` it may contain errors, so check `isValid()`) | | `InvoiceValidationFailed` | When validation blocked the run (mode `error`); the `ValidationException` is thrown afterwards | `invoice` (`InvoiceData` as passed), `result` (`ValidationResult`) | | `InvoiceRendered` | After all requested formats were produced | `result` (`Quittio\Laravel\Rendering\RenderedInvoice`) | | `QueuedInvoiceStored` | After a queued `RenderInvoice` job stored the main output, after `InvoiceRendered` | `result` (`RenderedInvoice`), `disk` (of the job, `null` = configured disk), `path` (the stored path) | | `DocumentRendering` | Before a document (quote, reminder, …) is calculated and rendered | `document` (`DocumentData` as passed), `options` (`RenderOptions`) | | `DocumentRendered` | After a document was rendered | `result` (`Quittio\Laravel\Rendering\RenderedDocument`) | | `QueuedInvoiceFailed` | When a queued `RenderInvoice` job failed for good (last attempt, or at once for errors another attempt cannot fix) | `job` (`RenderInvoice`; `$job->data()` returns the invoice), `exception` | | `QueuedDocumentStored` | After a queued `RenderDocument` job stored the document | `result` (`RenderedDocument`), `disk`, `path` | | `QueuedDocumentFailed` | When a queued `RenderDocument` job failed for good | `job` (`RenderDocument`; `$job->data()` returns the document), `exception` | | `MandatoryFieldMissing` | When the template omitted mandatory values ([Mandatory field guard](validation.md#mandatory-field-guard)), in the guard modes `exception` (before the exception is thrown) and `log` | `invoice` (calculated `InvoiceData`), `fields` (list of `Quittio\Core\Countries\MandatoryField` with `accessKey`, `description`, `legalBasis`) | No events are dispatched for `check()`, `prepare()`, reading or validating files. `Quittio::fake()` dispatches the events of a real run ([Testing](testing.md#how-the-fake-works)). Queued listeners receive the event serialised: `InvoiceRendered`, `QueuedInvoiceStored` and `DocumentRendered` carry the rendered files, PDF bytes included, into the queue payload. For many or large invoices, listen synchronously and queue a job with the stored path instead. ```php use Illuminate\Support\Facades\Event; use Quittio\Laravel\Events\InvoiceRendered; Event::listen(function (InvoiceRendered $event) { Log::info('Invoice rendered', [ 'number' => $event->result->data()->number, 'format' => $event->result->format(), 'hashes' => $event->result->hashes(), ]); }); ``` The Managed layer dispatches further events for the lifecycle of stored invoices (see [Managed layer](managed.md#events)). ## Cancellations A cancellation reverses an issued invoice. It is a new invoice with its own number and a reference to the original ("Stornorechnung", cancellation invoice, on German invoices). ```php $result = Quittio::make($invoice)->render(); $cancellation = $result->cancel('ST-2026-0001', reason: 'Charged twice'); // rendered in the formats of $result // stored data: build the cancellation and render it $builder = Quittio::cancellation($original, 'ST-2026-0001', reason: 'Charged twice'); Quittio::make($builder)->render(); // partial cancellation of line 2 (one unit), with the earlier partial cancellations Quittio::cancellation($original, 'ST-2026-0002', lines: [['line' => '2', 'quantity' => 1]], history: $history); ``` `$result->cancel()` takes the arguments of `Quittio::cancellation()` (`reason`, `lines`, `issueDate`, `strategy`, `history`). It renders the cancellation in the formats of the invoice, so a cancellation of an XRechnung is an XRechnung again. The sign strategy decides how the amounts are written: `credit_note` is a credit note (type code 381) with positive amounts, `negative_invoice` an invoice (type code 380) with negative amounts. Both are permitted in Germany. - The sign strategy comes from the argument, then `corrections.cancellation_strategy`, then the country pack. - The locale comes from the original, then `defaults.locale`, then the country pack. Details: [Cancellation](getting-started.md#cancellation), [Cancellations and corrections](building-invoices.md#cancellations-and-corrections) and, for stored invoices, [Managed layer](managed.md#cancellations-and-corrections). ## Documents Quotes, order confirmations, delivery notes, proforma invoices, payment reminders and account statements are documents: PDFs without e-invoice XML. Start them with the methods of [Starting invoices](#starting-invoices). End the chain with `->render()`, or pass the builder to `Quittio::document()` for more options: ```php use Quittio\Core\Builder\Party; use Quittio\Core\Enums\UnitCode; use Quittio\Laravel\Facades\Quittio; $quote = Quittio::quote()->number('AN-2026-0007')->issueDate('2026-10-01') ->buyer(Party::make('Kunde AG')->address('Weg 1', '54321', 'Beispielstadt', 'DE')) ->line('Consulting', netPrice: '100.00', quantity: 2, unit: UnitCode::Hour); return Quittio::document($quote)->locale('de')->render()->download(); ``` `Quittio::document()` returns a `Quittio\Laravel\Rendering\PendingDocument`: | Method | Effect | |---|---| | `template(string $template)` | Template (same allowlist as invoices) | | `locale(string $locale)` | Locale | | `country(string $country)` | Leading country pack | | `presentation(Presentation $presentation)` | Design for this call | | `htmlOnly()` | Render HTML only, no PDF | | `option(string $key, mixed $value)` | Output option of this call, e.g. `option('fold_marks', false)` | | `render()` | `RenderedDocument` | `PendingDocument` is `Macroable` like `PendingInvoice`. Documents never contain XML and are not validated. `RenderedDocument` offers: - `data()` (`DocumentData`), `hasPdf()` (`false` after `htmlOnly()`), `pdf()` (throws after `htmlOnly()`), `html()`, `contents()`, `mimeType()`, `filename(?string $extension = null)` and `core()`, - like invoices: `download()`, `stream()`, `toResponse()`, `toMailAttachment()` and `save()`. Document types and their data: [Quotes and other documents](documents.md). ## Blade templates The sections from here on describe how to adapt the output. The PDF is rendered from a Blade template. The core prepares the invoice for display (the view model: formatted amounts, labels, design values) and renders it with `Quittio\Laravel\Templates\BladeTemplateEngine`. A view receives one variable, `$invoice` (`Quittio\Core\View\InvoiceViewModel`, see [View model](templates.md#view-model)). | View | Use | |---|---| | `quittio::templates.default.layout` | Default template (`pdf.template`) | | `quittio::templates.default.partials.*` | Its partials (`letterhead`, `recipient`, `lines`, `totals`, `payment`, …) | | `invoices.{name}.layout` | Templates created by `make:quittio-template {name}` | Customise the design in levels (see [Templates and design](templates.md)): 1. the configuration (`pdf.*`, see [PDF and design](configuration.md#pdf-and-design)), 2. published partials: `php artisan vendor:publish --tag=quittio-views` copies them to `resources/views/vendor/quittio/templates`, which Laravel prefers over the package views, 3. an own template (`make:quittio-template`), 4. an own renderer ([Extensions](#extensions)). Template names may come from invoice data (`Presentation::$template`) or issuer branding. So only these views can be rendered: - `default`, which means the view of `pdf.template`, - the view configured in `pdf.template`, - the shipped views under `quittio::templates.` (not their partials), - the views of `pdf.templates` (default `['invoices.*']`). An entry ending in `*` allows every view below that prefix, e.g. `mytheme::*`. Views containing `.partials.` never qualify. Any other existing view fails with an `InvalidArgumentException`. A name that is no Blade view falls back to the plain PHP templates of the core. They resolve names inside their template directories only, never file paths. ```php // config/quittio.php 'pdf' => [ 'template' => 'invoices.acme.layout', // every invoice 'templates' => ['invoices.*', 'mytheme::*'], // selectable per call or per invoice ], Quittio::make($invoice)->template('mytheme::invoice')->render(); ``` ## Translations Invoices are printed in the language of the invoice, with Quittio's labels ("Rechnung", "Invoice" …). Labels, rule messages, code names and terms come from the core's language files `labels.php`, `rules.php`, `codes.php` and `terms.php`. They exist in German, English, French and Dutch; French and Dutch have no rule messages. They are in the translation namespace `quittio`. The core translates through Laravel's translator, so the usual overrides work: ```bash php artisan vendor:publish --tag=quittio-lang # lang/vendor/quittio/{locale}/*.php ``` A published file only needs the keys you change; Laravel merges it over the package file. ```php // lang/vendor/quittio/de/labels.php: "Bitte überweisen" (please transfer) instead of "Zahlbetrag" (amount due) return ['amount_due' => 'Bitte überweisen']; // or at runtime app('translator')->addLines(['labels.amount_due' => 'Bitte überweisen'], 'de', 'quittio'); ``` - Country packs add their own namespace `quittio-{code}`, e.g. `quittio-de` (`rules.php`, `tax.php`). Override it in `lang/vendor/quittio-de/{locale}/`. - The Managed layer uses `quittio-managed` (`--tag=quittio-managed-lang`). - Labels of a single invoice can be changed with `Presentation::$labels`. - Invoices are translated in the render locale, not in the application locale. ## Preview route The preview shows the sample invoices in the browser with your design, so you can check logo, colours and texts without creating an invoice. With `quittio.preview.enabled` (default: only in the `local` environment), the provider registers two routes under `quittio.preview.path`, with the middleware `quittio.preview.middleware`: | Route | Name | Response | |---|---|---| | `GET /_quittio/preview` | `quittio.preview.index` | List of the sample scenarios with HTML and PDF links | | `GET /_quittio/preview/{scenario}` | `quittio.preview.show` | The scenario as HTML, with `?format=pdf` as inline PDF | Query parameters of `show`: - `format`: `pdf`; anything else means HTML. - `template`: one of the views that rendering accepts (see [Blade templates](#blade-templates)): `default`, `pdf.template`, the shipped views under `quittio::templates.` and the views of `pdf.templates`, never partials. The view must exist. - `locale`: a locale code such as `en` or `de_CH`. Unknown scenarios, other or missing templates and invalid locales return 404, so no request can name a file or an arbitrary view. The preview renders the [sample scenarios](testing.md#scenarios) with the configured design, validation mode `warn` and a watermark ("PREVIEW", in German "VORSCHAU"). The locale defaults to the scenario's locale. The routes are not registered while routes are cached (`php artisan route:cache`). Requests are limited to `quittio.preview.throttle` (default 30 per minute; `null` = no limit). Outside the `local` environment every request is refused with 403 unless the gate `viewQuittioPreview` allows it. Define it, like Telescope's gate, in a service provider of your application: ```php use Illuminate\Support\Facades\Gate; Gate::define('viewQuittioPreview', fn (User $user) => $user->is_admin); ``` Add `auth` to `quittio.preview.middleware` (`['web', 'auth']`), so that guests are sent to the login instead of getting 403. On the command line, use `php artisan quittio:preview` (see [Artisan commands](commands.md#quittiopreview)). `Quittio\Laravel\Support\Preview` is the service behind route and command: | Method | Description | |---|---| | `scenarios(): array` | Names of the sample scenarios | | `allowsTemplate(string $template): bool` | Whether the preview may render this template: an existing view that rendering accepts (`BladeTemplateEngine::fromSettings()`), or `default` | | `allowsLocale(string $locale): bool` | Whether the locale code is well-formed | | `render(string $scenario, string $format = 'pdf', ?string $template = null, ?string $locale = null): RenderedInvoice` | Renders a scenario (`pdf` or `html`) with the watermark; invalid arguments throw an `InvalidArgumentException` | ## Extensions `Quittio::extend(string $type, string $name, Closure $factory)` registers a driver: your own PDF renderer, validator, XML writer or format resolver. - The factory receives the container and the driver's configuration array. - It must return an instance of the expected interface, otherwise building the core fails with a `ConfigurationException`. - Unknown types throw an `InvalidArgumentException`. - `extend()` forgets the built core, so call it in the `boot()` method of a service provider. - A renderer registered as `mpdf` or `fagus` replaces the built-in renderer of that name. | Type | Interface | Used when | Configuration passed | |---|---|---|---| | `renderer` | `Quittio\Core\Pdf\PdfRenderer` | `pdf.renderer` is `{name}` | `pdf.renderers.{name}` | | `validator` | `Quittio\Core\Validation\ValidationDriver` | `{name}` is listed in `validation.levels` | `validation.drivers.{name}` | | `serializer` | `Quittio\Core\Xml\XmlSerializer` | always; replaces the writer of its syntax | `serializers.{name}` | | `format_resolver` | `Quittio\Core\Formats\FormatResolver` | `format_resolver.driver` is `{name}` | `format_resolver` (including `peppol_lookup`) | ```php use Illuminate\Contracts\Container\Container; use Quittio\Core\Pdf\Renderers\CallbackRenderer; use Quittio\Laravel\Facades\Quittio; public function boot(): void { Quittio::extend('renderer', 'gotenberg', fn (Container $app, array $config) => new CallbackRenderer( fn (string $html) => $app->make(GotenbergClient::class)->pdf($html, $config), )); } // config/quittio.php: 'pdf' => ['renderer' => 'gotenberg', 'renderers' => ['gotenberg' => ['url' => '…']]] ``` - The callback of `Quittio\Core\Pdf\Renderers\CallbackRenderer` receives the HTML and the `RenderRequest` and returns any PDF. `CallbackRenderer` then turns it into PDF/A-3 and embeds the XML itself (design level 4 in [Templates and design](templates.md)). - A class implementing `PdfRenderer` directly receives the `RenderRequest` (`html`, `title`, `author`, `paper`, `pdfa`, `embedded`, `font`) and must produce the PDF/A and embed the file itself. - A validator driver returns its levels, decides with `supports()` which subjects it checks and returns a `ValidationResult` (see [Validation](validation.md)). ### Macros `QuittioManager` and `PendingInvoice` are macroable (`macro()`, `mixin()`, `hasMacro()`, `flushMacros()`). Use a macro for a combination of options you need often: ```php use Quittio\Laravel\Facades\Quittio; use Quittio\Laravel\Rendering\PendingInvoice; PendingInvoice::macro('forPublicBuyer', function () { /** @var PendingInvoice $this */ return $this->format('xrechnung-cii')->locale('de'); }); Quittio::make($invoice)->forPublicBuyer()->render(); ``` Builder macros are described in [Macros](building-invoices.md#macros). ## Peppol lookup Peppol is an international network for delivering e-invoices ([Formats](concepts.md#formats)). The default format resolver chooses the format `peppol` only with a lookup that tells whether a buyer is reachable via Peppol (see [Formats and profiles](formats.md#peppol-lookup)). Quittio ships no Peppol directory client, so you provide the lookup. Name an invokable class in `format_resolver.peppol_lookup`. It is resolved from the container, receives the `BuyerParty` and returns whether the buyer is reachable via Peppol: ```php use Illuminate\Support\Facades\Cache; use Quittio\Core\Data\Party\BuyerParty; final class PeppolDirectoryLookup { public function __construct(private PeppolDirectory $directory) {} public function __invoke(BuyerParty $buyer): bool { $address = $buyer->electronicAddress; // BT-49 if ($address === null) { return false; } $participant = $address->scheme->value.':'.$address->value; // e.g. 0208:0123456749 return Cache::remember('peppol:'.$participant, now()->addDay(), fn (): bool => $this->directory->isRegistered($participant)); } } // config/quittio.php: 'format_resolver' => ['peppol_lookup' => PeppolDirectoryLookup::class, …] ``` The lookup runs for every automatic choice with a business buyer that no domestic country rule decided (for German sellers: cross-border invoices), so cache its answers. A resolver registered with `Quittio::extend('format_resolver', …)` receives the value in its configuration and decides itself whether to use it. ## Logging The manager passes Laravel's logger (`Psr\Log\LoggerInterface`, the default log channel) to the core. The logger receives the warnings of the mandatory field guard in mode `log` (`validation.mandatory_field_guard`; the default in production). To route them elsewhere, listen for the `MandatoryFieldMissing` event, which is dispatched in the modes `log` and `exception`. ## Country packs Country packs bring the rules, tax presets and texts of a country. They are discovered from Composer metadata, listed in `quittio.countries` or registered with `Quittio::registerCountry()` (see [Configuration](configuration.md#country-packs)). Their translations, profiles, formats and rules are registered with them. Available packs and writing your own: [Country packs](country-packs.md). ## Managed layer `quittio/managed` stores invoices in the database and builds on this package: - It renders through the same `QuittioManager`, so configuration, templates, events and `Quittio::fake()` apply. - It reads `pdf.template` and `pdf.templates` to check issuer branding. - It uses `corrections.cancellation_strategy`. - It adds commands and implements two contracts of this package: | Contract | Used by | |---|---| | `Quittio\Laravel\Contracts\ManagedInstaller` | `php artisan quittio:install --managed` (migrations, first issuer profile) | | `Quittio\Laravel\Contracts\ManagedInvoiceRenderer` | `php artisan quittio:render {invoice}` (render a stored invoice again) | Issuer profiles replace the `seller` section, and the Managed archive uses its own disk and queue settings (`config/quittio-managed.php`). See [Managed layer](managed.md). ## Reference The tables below list the methods by purpose. The <a href="api/classes/Quittio-Laravel-QuittioManager.html">API reference</a> has every public class and method with its parameters, generated from the code of this version. ### Facade ```php use Quittio\Laravel\Facades\Quittio; ``` Instead of the facade you can inject `Quittio\Laravel\QuittioManager`; both are the same singleton. | Method | Returns | Description | |---|---|---| | `make(InvoiceData\|ProvidesInvoiceData\|InvoiceBuilder $data)` | `PendingInvoice` | Starts a render call. A builder is built, a `ProvidesInvoiceData` model converted with `toInvoiceData()`. See [Rendering invoices](#rendering-invoices). | | `invoice()` | `RenderableInvoiceBuilder` | A new invoice with the seller of the configuration (or of the current issuer of the Managed layer); ends with `build()` or `render()` (see [Starting invoices](#starting-invoices)). | | `quote()`, `orderConfirmation()`, `deliveryNote()`, `proforma()`, `paymentReminder(int $level = 0)`, `accountStatement()`, `bonusStatement()` | `RenderableDocumentBuilder` | A new document with the seller of the configuration; ends with `build()` or `render()`. | | `document(DocumentData\|DocumentBuilder $document)` | `PendingDocument` | Starts a render call for a quote, order confirmation, delivery note, proforma invoice, payment reminder or account statement (see [Documents](#documents)). | | `cancellation(InvoiceData $original, string $number, ?string $reason = null, ?string $strategy = null, ?Date $issueDate = null, ?array $lines = null, ?CancellationHistory $history = null, ?string $title = null)` | `InvoiceBuilder` | Builder for the cancellation of an issued invoice; render it with `make()`. `$title` is the document title in the PDF, e.g. "Stornorechnung" (cancellation invoice); `null` = the title of the country pack's correction policy. See [Cancellations](#cancellations). | | `check(InvoiceData $invoice, RenderOptions $options)` | `ValidationResult` | Validates like a render run; the fluent form is `Quittio::make($invoice)->check()`. | | `prepare(InvoiceData $invoice, RenderOptions $options)` | `PreparedInvoice` | Calculates and validates without rendering; fluent form `->prepare()`. | | `read(string $content)` | `ReadResult` | Reads an incoming XML or PDF e-invoice from its content (bytes, never a path). See [Reading incoming invoices](reading.md). | | `readFile(string $path)` | `ReadResult` | The same from a file | | `validateFile(string $content)` | `ValidationResult` | Reads and validates an incoming XML or PDF (content) with all configured levels. See [Validation](validation.md#incoming-files). | | `validatePath(string $path)` | `ValidationResult` | The same from a file | | `renderInvoice(InvoiceData $invoice, RenderOptions $options)` | `RenderedInvoice` | The render run behind `PendingInvoice::render()`, with events | | `renderDocument(DocumentData $document, RenderOptions $options)` | `RenderedDocument` | The render run behind `PendingDocument::render()` | | `extend(string $type, string $name, Closure $factory)` | `QuittioManager` | Registers a renderer, validator, serializer or format resolver (see [Extensions](#extensions)) | | `registerCountry(CountryPack $pack)` | `QuittioManager` | Registers a country pack; it wins over configured and discovered packs with the same code | | `defaultVat(?string $sellerCountry, bool $smallBusiness)` | `?TaxPreset` | Default VAT of lines without `->vat()`: `defaults.vat`, otherwise the standard preset of the seller's country pack, for small businesses its small business preset ([Default VAT](building-invoices.md#default-vat)). The service provider installs it with `InvoiceBuilder::useDefaultVat()`. | | `countries()` | `CountryRegistry` | Active country packs: `all()`, `has($code)`, `get($code)`, `getOrGeneric($code)` | | `profiles()` | `ProfileRegistry` | Profiles of the core and the country packs: `all()`, `has($key)`, `get($key)`, `bySpecificationId($id)` | | `formats()` | `FormatRegistry` | Output formats: `all()`, `has($key)`, `get($key)` | | `settings()` | `Settings` | Typed access to `config('quittio')` (see [Settings](#settings)) | | `flush()` | `QuittioManager` | Forgets the built core; the next call builds it again. Configuration changes do not need it | | `core()` | `Quittio\Core\Quittio` | The core instance, e.g. `Quittio::core()->config()` or `->validators()` | | `coreWithLevels(array $levels)` | `Quittio\Core\Quittio` | A new core (the cached one stays unchanged) that validates with `validation.levels` plus `$levels`, e.g. `['kosit', 'verapdf']`, every driver with its settings of `validation.drivers.*`; used by `quittio:validate --kosit --verapdf` | | `macro()`, `mixin()`, `hasMacro()`, `flushMacros()` | – | Macros of the manager (see [Macros](#macros)) | | `fake()` | `QuittioFake` | Replaces rendering in tests (see [Testing](testing.md#fake)) | | `assertRendered()`, `assertRenderedCount()`, `assertNothingRendered()`, `assertDocumentRendered()`, `rendered()`, `documents()` | – | Assertions and recordings of the fake, only after `fake()` | The manager builds the core lazily, on the first call that needs it. It uses the configuration, the country packs, the Blade template engine, the PDF renderer, the logger and your extensions. ### Settings `Quittio::settings()` returns `Quittio\Laravel\Support\Settings`: typed read access to `config('quittio')` with dot notation. Wrong types throw a `ConfigurationException` naming the key. | Method | Returns | |---|---| | `get(string $key, mixed $default = null)` | Raw value | | `string(string $key, string $default)` | String; `null` and `''` give the default | | `nullableString(string $key)` | String or `null` | | `bool(string $key, bool $default)` | Boolean | | `int(string $key, int $default)` | Integer | | `array(string $key)` | Array (missing = `[]`) | | `strings(string $key)` | The string values of a list | | `section(string $key)` | `Settings` for a sub-array, e.g. `section('validation.drivers.kosit')` | ### Service provider The package registers itself through Laravel's package discovery (`composer.json`: `extra.laravel`): the provider `Quittio\Laravel\QuittioServiceProvider` and the alias `Quittio` for `Quittio\Laravel\Facades\Quittio`. With `"dont-discover": ["quittio/laravel"]` in your `composer.json`, register both yourself in `bootstrap/providers.php` and `config/app.php`. | Registered | Details | |---|---| | Configuration | `config/quittio.php` merged with the package defaults (see [Configuration](configuration.md)) | | `Quittio\Laravel\QuittioManager` | Singleton behind the facade, also available as `app('quittio')` | | `Quittio\Laravel\Contracts\InvoiceDefaults` | Bound to `ConfigInvoiceDefaults` unless already bound (see [Seller from the configuration](#seller-from-the-configuration)) | | `Quittio\Laravel\Support\Preview` | Singleton that renders the sample scenarios (see [Preview route](#preview-route)) | | `Quittio\Core\Serialization\Snapshots\SnapshotUpcasterChain` | Singleton with the upcasters of `quittio.snapshots.upcasters`; also the default chain of `InvoiceData::fromSnapshot()` | | Default VAT | `InvoiceBuilder::useDefaultVat()` with `Quittio::defaultVat()` (see [Default VAT](building-invoices.md#default-vat)) | | Views | Namespace `quittio` (`quittio::templates.default.layout`, its partials, `quittio::preview.index`) | | Translations | Namespace `quittio` with the labels and messages of the core; the core uses Laravel's translator (see [Translations](#translations)) | | Routes | The preview routes, when enabled | | Commands | `quittio:*` and `make:quittio-template` (console only, see [Artisan commands](commands.md)) | | Publish tags | `quittio-config`, `quittio-views`, `quittio-lang`, `quittio-fonts` (see [Artisan commands](commands.md#publish-tags)) | | `php artisan about` | Section "Quittio" with the active country packs and profiles | Country packs bring their own provider. The German pack registers `Quittio\Country\DE\Laravel\GermanyServiceProvider` (discovered as well): it merges the defaults of its settings into `quittio.countries.de`, registers the configured base rates, the command `quittio:base-rate:update` and the publish tag `quittio-de-config` (`config/quittio/countries/de.php`, see [Country pack Germany](configuration.md#country-pack-germany-quittiocountriesde)). <!-- Source: https://quittio.dev/docs/configuration --> # Configuration This page describes `config/quittio.php`, the configuration file of the Laravel integration. When you install Quittio, read [The keys you set first](#the-keys-you-set-first): your company, your bank account and the defaults most applications change. The rest of the page is the reference of every key, in the order of the file. Without Laravel there is no configuration file: the core takes its settings, including your company (`seller`), its bank account (`bank_account`) and the small business setting (`small_business`), as an array for `Quittio::create()`. See [Without Laravel](#without-laravel) at the end of this page. The terms used here (format, profile, BT numbers, rule codes) are explained in [E-invoicing basics](concepts.md). ## The keys you set first Publish the file once: ```bash php artisan quittio:install # config/quittio.php and the files of the country packs, with hints for the next steps php artisan vendor:publish --tag=quittio-config # only config/quittio.php, without the hints ``` The options of the installer are described in [Artisan commands](commands.md#quittioinstall). ### Your company Every invoice names the company that issues it: the **seller**. `Quittio::invoice()` takes the seller from the `seller` section, so you set it once: ```php // config/quittio.php 'seller' => [ 'name' => env('QUITTIO_SELLER_NAME'), // legal name of the company 'vat_id' => env('QUITTIO_SELLER_VAT_ID'), // VAT identification number, e.g. DE123456789 'tax_number' => env('QUITTIO_SELLER_TAX_NUMBER'), // tax number from the tax office, e.g. 21/815/08150 'legal_registration' => 'HRB 12345', // commercial register number 'address' => [ 'line1' => 'Hauptstraße 1', // street and number 'line2' => null, 'postcode' => '12345', 'city' => 'Musterstadt', 'country' => 'DE', ], 'contact' => ['name' => 'Max Muster', 'phone' => '+49 30 1234567', 'email' => 'billing@muster.de'], 'electronic_address' => ['value' => 'billing@muster.de', 'scheme' => 'EM'], 'bank_accounts' => [ ['iban' => 'DE89370400440532013000', 'bic' => 'COBADEFFXXX', 'name' => 'Muster GmbH'], ], 'small_business' => (bool) env('QUITTIO_SELLER_SMALL_BUSINESS', false), // identifiers and additional_legal_info: see the reference below ], ``` Name, VAT identification number, tax number and the small business setting can also come from the environment: ```bash # .env QUITTIO_SELLER_NAME="Muster GmbH" QUITTIO_SELLER_VAT_ID=DE123456789 QUITTIO_SELLER_TAX_NUMBER=21/815/08150 QUITTIO_SELLER_SMALL_BUSINESS=false ``` The rules of the formats require some of these values: - Every invoice needs the name. German invoices also need street, postcode and city. - German invoices need the VAT identification number or the tax number. - Without a VAT identification number, EN 16931 (the European standard for e-invoices) needs another identifier of the seller: `identifiers` (BT-29) or `legal_registration` (BT-30). Otherwise rendering fails with the rule BR-CO-26. This concerns, for example, a small business with a tax number only. - XRechnung (the format for German public authorities) also needs the contact with name, phone and e-mail, and the electronic address. Peppol (an international network for delivering e-invoices) needs the electronic address as well. BT numbers are explained in [EN 16931 and business terms](concepts.md#en-16931-and-business-terms), rule codes such as BR-CO-26 in [Rules and validation](concepts.md#rules-and-validation). Every key of the section is listed in [Seller](#seller). Without Laravel, the seller is a `Party::make()` under the key `seller` of `Quittio::create()`, and `$quittio->invoice()` takes it from there ([Without Laravel](#without-laravel)). ### Your bank account `Quittio::invoice()` puts the first entry of `seller.bank_accounts` that has an IBAN on every invoice, as payment by SEPA credit transfer. The PDF shows the IBAN and a payment QR code that banking apps can read (GiroCode in Germany). `bic` and `name` are optional. Further entries are ignored. Without Laravel, `bank_account` of `Quittio::create()` holds the one account: `['iban' => …, 'bic' => …, 'name' => …]`. ### Small businesses Set `seller.small_business` to `true` if you are a small business that charges no VAT (Kleinunternehmer, section 19 of the German VAT Act UStG). Invoices then carry no VAT. Lines without `->vat()` get the small business exemption with its legal note, and VAT on a line is rejected. See [Small businesses](country-packs.md#small-businesses). Without Laravel, set `'small_business' => true` in `Quittio::create()`. ### Defaults you may change The `defaults` section sets what an invoice uses when it does not set a value itself. These are the ones applications change most often: | Key | Default | Change it when | |---|---|---| | `defaults.due_days` | `14` | Your invoices are due after another number of days. `null` = no due date unless the invoice sets one. | | `defaults.vat` | `null` (19 % for a German seller) | Most of your lines have another VAT rate, e.g. `'de.reduced'` (7 %) for a bookshop | | `defaults.format` | `null` (automatic choice) | All your invoices need the same format, e.g. `'xrechnung-cii'` | | `defaults.locale` | `null` (German for a German seller) | Your invoices should be in another language, e.g. `'en'` | All keys of the section are described in [Defaults](#defaults). ### Design The `pdf` section sets the look of the PDF: logo, colours, font and texts. For example `'logo' => resource_path('images/logo.png')` and `'colors' => ['primary' => '#0f766e', …]`. See [PDF and design](#pdf-and-design) and [Templates and design](templates.md). Check the design with the sample invoices. They use sample data, not your seller: ```bash php artisan quittio:preview --scenario=simple ``` Then render a first invoice with your own data ([Getting started](getting-started.md#building-an-invoice)). ## How the configuration is read Without a published file, the package defaults apply. Laravel merges the package file with yours by top-level key. A section you leave out (for example `preview`) keeps the package defaults. Inside a section you keep, a missing key gets the value Quittio uses when nothing is set. For most keys that is the default listed on this page. These keys differ: | Key left out | Value | |---|---| | `defaults.country` | none: the seller's country decides; without it the only installed country pack, else the generic EN 16931 rules | | `defaults.due_days` | none: no due date unless the invoice sets one | | `pdf.cache_path` | `sys_get_temp_dir().'/quittio-mpdf'` | | `storage.disk` | the default disk of `config/filesystems.php` | | `queue.queue` | the default queue of the connection | The manager (a singleton) builds the core from the configuration when it is used for the first time and keeps it as long as the `quittio` configuration stays the same. A value changed at runtime (in tests, or per tenant) makes the next call build the core again, without further steps: ```php config()->set('quittio.pdf.colors.primary', '#0f766e'); Quittio::make($invoice)->render(); // uses the new colour ``` Under Octane the manager reads the configuration of the current request, not that of the worker's first request. `Quittio::flush()` still forgets the built core, e.g. after a bound class changed. Some values are process-wide rather than per application: the translator bridge, the default VAT for lines without VAT, the snapshot upcasters and the registered base rates of the German pack. `Quittio\Core\Quittio::resetState()` forgets them; the service providers set them again when the application boots. The test trait `InteractsWithQuittio` calls it after each test ([Testing](testing.md#assertions)). Some keys are read at other times: - `seller`, `defaults.vat`, `storage.disk` and `queue` are read on every call. - `preview` and `snapshots.upcasters` are read when the application boots. A value of the wrong type fails with a `ConfigurationException` that names the key, e.g. `quittio.pdf.pdfa must be a boolean.` The Managed layer has its own file, `config/quittio-managed.php`, with the database, issuers, archive, queue, numbering, corrections, delivery, audit log, retention and policies. Its keys are described in the [Managed layer](managed.md). Issuer profiles of the Managed layer replace the `seller` section below. ## Environment variables | Variable | Key | Default | |---|---|---| | `QUITTIO_DEFAULT_COUNTRY` | `defaults.country` | – (the only installed country pack) | | `QUITTIO_SELLER_NAME` | `seller.name` | – | | `QUITTIO_SELLER_VAT_ID` | `seller.vat_id` | – | | `QUITTIO_SELLER_TAX_NUMBER` | `seller.tax_number` | – | | `QUITTIO_SELLER_SMALL_BUSINESS` | `seller.small_business` | `false` | | `QUITTIO_DEFAULT_VAT` | `defaults.vat` | – (standard rate of the seller's country) | | `QUITTIO_VALIDATION_MODE` | `validation.mode` | `error` | | `QUITTIO_VALIDATION_LOCALE` | `validation.locale` | – (the language of the application) | | `QUITTIO_MANDATORY_FIELD_GUARD` | `validation.mandatory_field_guard` | – (`exception`, in production `log`) | | `QUITTIO_KOSIT_URL` | `validation.drivers.kosit.url` | `http://127.0.0.1:8081` (start the validator with `-P 8081`; its own default port is 8080) | | `QUITTIO_CANCELLATION_STRATEGY` | `corrections.cancellation_strategy` | – (country pack) | | `QUITTIO_DECLARED_AMOUNTS` | `calculation.declared_amounts` | `keep` | | `QUITTIO_STORAGE_DISK` | `storage.disk` | `local` | | `QUITTIO_PREVIEW_ENABLED` | `preview.enabled` | – (local environment only) | `QUITTIO_PREVIEW_ENABLED` must be `true` or `false`. Other values count as not set. Quittio 0.1.0 used shorter names for some variables: `QUITTIO_COUNTRY`, `QUITTIO_VALIDATION`, `QUITTIO_GUARD`, `QUITTIO_DISK` and `QUITTIO_PREVIEW`. Since 1.0 they are no longer read; rename them in your `.env` ([Upgrade guide](upgrading.md)). ## Defaults Values used when an invoice or a render call does not set them itself. | Key | Type | Default | Effect | |---|---|---|---| | `defaults.country` | string\|null | `env('QUITTIO_DEFAULT_COUNTRY')` | Country pack used when the seller has no country code (BT-40), e.g. `'DE'`. Normally the seller's country decides; `->country()` on a render call wins as well. `null` = the only installed country pack if there is exactly one (`quittio/quittio` installs Germany). Without an installed pack for the code, only the generic EN 16931 rules apply. | | `defaults.profile` | string\|null | `null` | Profile of the e-invoice XML, i.e. how much of EN 16931 it contains ([Profiles](concepts.md#profiles)), e.g. `'en16931'`, `'extended'`, `'xrechnung'`. It applies to every format that allows it, also to `->format('zugferd')` and to formats chosen by a country rule. Formats that do not allow it ignore it (e.g. `basic` for XRechnung or Peppol). `null` = the profile of the automatic choice or the format's default (`zugferd`, `cii`, `ubl`: `en16931`; `xrechnung-cii`, `xrechnung-ubl`: `xrechnung`; `peppol`: `peppol`). `->profile()` on a render call always wins. See [Formats and profiles](formats.md). | | `defaults.format` | string\|null | `null` | Format of a render call without `->format()`. `null` or `'auto'` = automatic choice by the format resolver: XRechnung for public buyers with a Leitweg-ID (the routing ID of a German public buyer, see [German terms](concepts.md#german-terms)), PDF for consumers, ZUGFeRD for businesses ([Automatic choice](formats.md#automatic-choice)). Keys: `zugferd` (PDF with embedded XML; aliases `factur-x`, `facturx`), `xrechnung-cii` (alias `xrechnung`), `xrechnung-ubl`, `cii`, `ubl`, `peppol`, `pdf`, `html`, `json`. | | `defaults.locale` | string\|null | `null` | Language of the invoice (labels, generated texts, number and date formats), e.g. `'de'` or `'en'`, when neither `->locale()` on the render call nor the invoice (`InvoiceBuilder::locale()`) sets one. `null` = the default of the seller's country pack (Germany: `de`). | | `defaults.due_days` | int\|numeric string\|null | `14` | Due date (BT-9) = issue date + this number of days. It applies to invoices that set neither a due date nor payment terms (`->dueInDays()`), never to credit notes. `null` or `''` switches it off. Other values fail with a `ConfigurationException`. | | `snapshots.document_upcasters` | list | `[]` | The same for stored documents: `DocumentData::fromSnapshot()` and queued `RenderDocument` jobs. Documents have their own versions (`DocumentData::SNAPSHOT_VERSION`). | | `defaults.vat` | string\|null | `env('QUITTIO_DEFAULT_VAT')` | Tax preset of invoice lines without `->vat()`, by key, e.g. `'de.reduced'` for a bookshop. `null` = the standard rate of the seller's country pack (Germany: `de.standard`). Invoices of small businesses (`seller.small_business`) use the small business preset of the pack (`de.small_business`). An unknown key fails with a `ConfigurationException` when a line needs the default. See [Default VAT](building-invoices.md#default-vat). | ## Country packs A country pack brings the tax presets, legal rules and texts of one country ([How Quittio works](concepts.md#how-quittio-works)). `quittio/quittio` includes the pack for Germany. ```php laravel 'countries' => [ // 'AT' => \App\Quittio\CountryAT::class, // 'de' => ['base_rates' => ['2027-01-01' => '1.77']], ], ``` ```php plain use Quittio\Core\Quittio; use Quittio\Country\DE\CountryDE; use Quittio\Country\DE\Dunning\BaseRates; $quittio = Quittio::create([], [new CountryDE]); // $quittio->registerCountry(new \App\Quittio\CountryAT); // BaseRates::register(['2027-01-01' => '1.77']); ``` Without Laravel, the packs are passed to `Quittio::create()` or registered later with `$quittio->registerCountry()` ([Registering packs](country-packs.md#without-laravel)). The rest of this section describes the Laravel configuration. `countries` holds two kinds of entries: pack classes (strings) and the settings of a pack (arrays under the lower-case country code, see [Settings of a pack](#settings-of-a-pack-quittiocountriescode)). Country packs are found in three ways, and all of them are combined: 1. **Package discovery**: a Composer package (or your root `composer.json`) lists its packs under `extra.quittio.country-packs`. `quittio/country-de` does this, so `composer require quittio/country-de` is enough. ```json "extra": { "quittio": { "country-packs": ["App\\Quittio\\CountryAT"] } } ``` The result is kept in `bootstrap/cache/quittio-countries.php` until Composer rewrites `vendor/composer/installed.json` or your `composer.json` changes, so requests do not read the package list. After editing `extra.quittio.country-packs` of the root `composer.json` by hand, the next request picks it up as well. 2. **Configuration**: `countries` lists further pack classes. The array keys are ignored; the pack's `code()` counts. Classes are resolved through the container. Arrays are not pack classes but settings and are skipped here. 3. **At runtime**: `Quittio::registerCountry(new CountryAT)`, e.g. in a service provider. It wins over the other two for the same country code and survives `Quittio::flush()`. Every pack must implement `Quittio\Core\Countries\CountryPack`, otherwise building the core fails with a `ConfigurationException`. For the same country code the last one wins, in this order: discovered packs, then `countries`, then `Quittio::registerCountry()`. So a subclass of `CountryDE` listed in `countries` replaces the discovered `CountryDE`. `php artisan quittio:countries` and `php artisan about` list the active packs. To write your own pack, see [Country packs](country-packs.md). ### Settings of a pack (`quittio.countries.{code}`) A pack with settings of its own keeps them under `quittio.countries.{code}`, with the lower-case country code: `quittio.countries.de` for Germany. Its service provider merges the defaults, so `config('quittio.countries.de.base_rate_file')` works without a published file. You set the keys in one of two places: - **The file of the pack**, `config/quittio/countries/{code}.php`. `php artisan quittio:install` publishes it for every installed pack, `php artisan vendor:publish --tag=quittio-{code}-config` (e.g. `quittio-de-config`) publishes it alone. Laravel loads files in subdirectories of `config/` under the dotted path, so `config/quittio/countries/de.php` becomes `quittio.countries.de`. - **A section in `config/quittio.php`**: `'countries' => ['de' => ['base_rates' => […]]]`. When the file of the pack exists as well, the file wins as a whole. Without Laravel, pass the settings to `Quittio::create()` under the same key, e.g. `Quittio::create(['countries' => ['de' => ['consumer_default_notice' => false]]], [new CountryDE])`. The German base rates are the exception: register them with `BaseRates::register()` ([Base rate table](country-packs.md#base-rate-table)). Keys you leave out keep the defaults of the pack. A pack class must not be listed under a lower-case code that holds settings (`'de' => CountryDE::class`): use the upper-case code or no key. A class listed under `'de'` by an older configuration is moved to a numeric key when the German pack registers. ### Country pack Germany (`quittio.countries.de`) The German pack's settings are the base rate (Basiszinssatz) under section 247 of the German Civil Code (BGB). `DefaultInterest` needs it to calculate the statutory interest on late payments, e.g. for payment reminders ([German default interest](documents.md#german-default-interest)). Publish the file with `php artisan vendor:publish --tag=quittio-de-config` (`config/quittio/countries/de.php`) or let `php artisan quittio:install` do it. | Key | Type | Default | Effect | |---|---|---|---| | `countries.de.base_rates` | array | `[]` | Base rates in addition to the table shipped with Quittio: ISO date (1 January or 1 July) => percent, e.g. `['2027-01-01' => '1.77']`. They win over the file below. | | `countries.de.base_rate_file` | string\|null | `storage_path('app/quittio/base-rates.json')` | JSON file written by `php artisan quittio:base-rate:update` with the rates of the Deutsche Bundesbank. `null` = not used. | | `countries.de.prior_year_turnover_above_800k` | bool | `false` | Your total turnover of the previous year was above 800,000 EUR: other invoices for domestic business supplies of 2027 are no longer allowed (section 27 (38) UStG, `DE-EINVOICE-01`, [E-invoice obligation](country-packs.md#e-invoice-obligation)). | | `countries.de.omit_vat_ids_for_category_o` | bool | `true` | Invoices of category `O` only (not subject to VAT) leave out the VAT identifiers of seller and buyer when the seller's tax number is given (BR-O-02, [Category O](country-packs.md#vat-identifiers-on-invoices-of-category-o)). | | `countries.de.consumer_default_notice` | bool | `true` | Invoices for consumers get the notice on default after 30 days (section 286 (3) BGB, [Default notice for consumers](country-packs.md#default-notice-for-consumers)). `false` = add it yourself with `->de()->consumerDefaultNotice()`. | See [Country packs: base rate table](country-packs.md#base-rate-table) and [quittio:base-rate:update](commands.md#quittiobase-rateupdate). #### The old file `config/quittio-de.php` Up to 0.3 the German settings were a configuration of their own, `quittio-de` (`config/quittio-de.php`). Since 1.0 it is no longer read. So that settings such as `prior_year_turnover_above_800k` are not lost unnoticed, the application refuses to start while `quittio-de` is still set, with a `RuntimeException` that names the new key. To migrate, publish the new file, move the values of `config/quittio-de.php` into it and delete the old file (and `bootstrap/cache/config.php` if the configuration is cached): ```bash php artisan vendor:publish --tag=quittio-de-config # config/quittio/countries/de.php ``` ## Seller Your company as it appears on every invoice. The section is used by `Quittio::invoice()`, the document methods (`Quittio::quote()` …), `Seller::fromConfig()` and `Seller::apply()` (see [Laravel integration](laravel.md#seller-from-the-configuration)). With `quittio/managed`, issuer profiles replace it. Without Laravel, the core keys `seller`, `bank_account` and `small_business` of `Quittio::create()` take its place ([Without Laravel](#without-laravel)). | Key | Type | Default | Effect | |---|---|---|---| | `seller.name` | string | `env('QUITTIO_SELLER_NAME')` | Legal name of the company (BT-27). Required. | | `seller.vat_id` | string\|null | `env('QUITTIO_SELLER_VAT_ID')` | VAT identification number with country prefix, e.g. `'DE123456789'` (BT-31) | | `seller.tax_number` | string\|null | `env('QUITTIO_SELLER_TAX_NUMBER')` | Tax number from the tax office, e.g. `'21/815/08150'` (BT-32). German invoices need the VAT identification number or the tax number. | | `seller.legal_registration` | string\|null | `null` | Commercial register number, e.g. `'HRB 12345'` (legal registration identifier, BT-30) | | `seller.identifiers` | list | `[]` | Further identifiers of the company (BT-29): `['value' => '…', 'scheme' => null]` (the scheme is optional) or plain strings, e.g. `[['value' => '4000001000005', 'scheme' => '0088']]` for a GLN (Global Location Number; `0088` is its code in the ISO 6523 list). Empty values are skipped. Without a VAT identification number, EN 16931 needs an identifier here or `legal_registration`, otherwise rendering fails with BR-CO-26. | | `seller.additional_legal_info` | string\|null | `null` | Further legal information printed on the invoice (BT-33), e.g. the court of registration and the managing directors | | `seller.address.line1` | string\|null | `null` | Street and number (BT-35). Required on German invoices. | | `seller.address.line2` | string\|null | `null` | Additional address line (BT-36) | | `seller.address.postcode` | string\|null | `null` | Postcode (BT-38). Required on German invoices. | | `seller.address.city` | string\|null | `null` | City (BT-37). Required on German invoices. | | `seller.address.country` | string\|null | `null` | Country code, ISO 3166-1 alpha-2 (BT-40), e.g. `'DE'`. It also selects the leading country pack. `null` = `defaults.country`, without it the code of the only installed country pack. | | `seller.contact.name` / `.phone` / `.email` | string\|null | `null` | Contact person (BG-6), added only when at least one value is set. XRechnung requires name, phone and e-mail. | | `seller.electronic_address.value` | string\|null | `null` | Electronic address of the seller (BT-34), added only when set. Required by XRechnung and Peppol. | | `seller.electronic_address.scheme` | string | `'EM'` | Scheme of the electronic address, a code of the EAS list (electronic address schemes): `EM` = e-mail address, `9930` = German VAT number (as Peppol participant ID). Peppol does not accept `EM` (`PEPPOL-EN16931-CL008`); set a participant ID such as `9930` when you send via Peppol | | `seller.bank_accounts` | list | `[['iban' => null, 'bic' => null, 'name' => null]]` | Bank accounts. `Quittio::invoice()` (`Seller::apply()`) adds a SEPA credit transfer with the first entry whose `iban` is not empty: the PDF shows the IBAN and a payment QR code. `bic` and `name` are optional. The other entries are ignored. | | `seller.small_business` | bool | `(bool) env('QUITTIO_SELLER_SMALL_BUSINESS', false)` | `Quittio::invoice()` (`Seller::apply()`) marks the invoice as an invoice of a small business (Germany: section 19 UStG, `Meta::FLAG_SMALL_BUSINESS`). Lines without `->vat()` get the small business preset of the country pack (Germany: `VatPreset::SmallBusiness`) with its legal note. Country packs reject VAT on the invoice; Germany also rejects the intra-community supply exemption, except for new vehicles. | ## PDF and design The look of the PDF and HTML output. The design of a single invoice and `->presentation()` on a render call override these values property by property. | Key | Type | Default | Effect | |---|---|---|---| | `pdf.renderer` | string | `'mpdf'` | PDF engine: `mpdf` (bundled), `fagus` (needs `composer require nforst/fagus`, see [Fagus](templates.md#fagus)) or a name registered with `Quittio::extend('renderer', …)`. An unknown name fails with a `ConfigurationException`, as does `fagus` without the package. | | `pdf.template` | string | `'quittio::templates.default.layout'` | Blade view of the invoice layout. It is used for the template name `default`, i.e. for every render without `->template()` or `Presentation::$template`. Create your own copy of the default template with `php artisan make:quittio-template`, or name your own view. | | `pdf.templates` | list | `['invoices.*']` | Further views that `->template()`, `Presentation::$template` or issuer branding may select, besides `pdf.template` and the shipped `quittio::templates.*` views. `prefix*` allows every view below a prefix (`invoices.*`, `mytheme::*`). Partials (`.partials.`) are never selectable. Views not listed are refused. A missing key means `['invoices.*']`, `[]` allows no further views. See [Blade templates](laravel.md#blade-templates). | | `pdf.layout` | string\|null | `null` | Letter layout, i.e. the position of the address field: `free` (no norm), with the German pack also `din5008a` and `din5008b` (DIN 5008, the German standard for business letters). `null` = the default of the country pack (Germany: `din5008b`). An unknown layout fails with a `ConfigurationException`. See [Letter layouts](templates.md#letter-layouts). | | `pdf.paper` | string\|null | `null` | Paper size, e.g. `A4`, `Letter`. `null` = the default of the country pack (Germany: A4). A size set here wins over the country default, also `A4`. The invoice presentation and `->presentation()` win over it. | | `pdf.pdfa` | bool | `true` | Create plain PDFs (format `pdf`, quotes, reminders and other documents) as PDF/A-3b, the PDF standard for archiving. PDFs with embedded XML (ZUGFeRD/Factur-X) are always PDF/A-3b. PDFs with a watermark (drafts, previews) never are. | | `pdf.font` | string | `'geist'` | Default font family (plain family name). Geist (Latin, Cyrillic) and Inter (also Greek) are bundled, see [Fonts](templates.md#fonts). | | `pdf.fonts` | array | `[]` | Additional TrueType fonts for mPDF and Fagus: lower-case family => `['R' => 'Regular.ttf', 'B' => 'Bold.ttf', 'I' => 'Italic.ttf', 'BI' => 'BoldItalic.ttf']`, files relative to `pdf.font_directories` | | `pdf.font_directories` | list | `[]` | Directories mPDF searches for the font files of `pdf.fonts`. `resources/fonts/quittio` and its subdirectories are added after the configured directories when they exist, so fonts placed there need no entry here. (`--tag=quittio-fonts` publishes Geist, Inter and Liberation Sans there, to `resources/fonts/quittio/geist`, `…/inter` and `…/liberation`.) mPDF takes a file from the first directory that has it: these directories come before the bundled fonts and those of mPDF. | | `pdf.logo` | string\|null | `null` | Logo: absolute path, `http(s)` URL or data URI of a PNG, JPEG or SVG. At most 10 MB and 25 megapixels; URLs only from public hosts. For PDF/A, logos are flattened to an RGB PNG; SVG logos then need the PHP extension `imagick`. Details in [Templates and design](templates.md#logos). | | `pdf.colors.primary` | string | `'#2741d9'` | Primary colour (hex): issuer name, title, gross total or amount due | | `pdf.colors.text` | string | `'#15171c'` | Text colour (hex) | | `pdf.colors.muted` | string | `'#5f6470'` | Colour of secondary text (hex): labels, descriptions, sender line, footer | | `pdf.colors.secondary` | string\|null | `null` | Accent colour (hex), e.g. section titles and the mark of highlighted lines (`design.secondaryColor` in templates). `null` = the primary colour. | | `pdf.sender_line` | string\|null | `null` | Small sender line above the address field. `null` = generated from the seller. | | `pdf.footer_columns` | list | `[]` | Footer columns, each a list of lines: `[['Muster GmbH', 'Hauptstraße 1'], ['IBAN DE02 …']]`. `[]` = footer generated from the seller data. | | `pdf.texts.salutation` | string\|null | `null` | Salutation above the intro text. `null` = none. | | `pdf.texts.intro` | string\|null | `null` | Text above the lines (Markdown, PDF only). `null` = none. | | `pdf.texts.closing` | string\|null | `null` | Text below the totals (Markdown, PDF only). `null` = none. | | `pdf.show_item_numbers` | bool | `false` | Print the seller's item number (BT-155) next to the item name | | `pdf.markdown` | bool | `false` | Render line descriptions and notes as Markdown instead of plain text. It is off by default: the same texts are in the e-invoice XML, where formatting characters such as `*` or `_` stay visible and can change the displayed text. | | `pdf.fold_marks` | bool | `true` | Print fold and punch marks for window envelopes, at the left edge of the first page | | `pdf.payment_qr.type` | string | `'auto'` | Payment QR code in the PDF. `auto`: the generator below, otherwise the code of the country pack (Germany: GiroCode, the EPC QR code for banking apps). `girocode`: the EPC QR code. `swiss-qr-bill`: the generator below, otherwise the QR bill of the country pack Switzerland ([`quittio/country-ch`](country-ch.md#qr-bill)); without either, rendering fails with a `ConfigurationException`. `none`: no code. Unknown values fail with a `ConfigurationException`. Refunds and self-billed invoices never get a code. | | `pdf.payment_qr.generator` | class-string\|null | `null` | Class implementing `Quittio\Core\Pdf\Qr\PaymentQrGenerator`, resolved from the container. It is used for `auto` and `swiss-qr-bill` before the country pack's generator. Another class fails with a `ConfigurationException`. | | `pdf.payment_qr.girocode_amount` | string | `'due'` | Amount in the GiroCode: `due` (amount due) or `discounted` (amount after the first cash discount; the PDF then notes until when it is valid) | | `pdf.filename` | string | `'{title}_{number}.{ext}'` | File name pattern of the results. Placeholders: `{title}` (document title in the language of the invoice, e.g. "Rechnung", German for invoice), `{number}`, `{date}` (issue date, `Y-m-d`), `{format}` (format key; the document type for quotes and other documents), `{ext}` (`pdf`, `xml`, `html`, `json`). Title and number are reduced to letters, digits, `.`, `_` and `-`. | | `pdf.cache_path` | string\|null | `storage_path('framework/cache/quittio')` | Temporary directory of mPDF. Prepared logos are cached in its `logos` subdirectory. `null` = `sys_get_temp_dir().'/quittio-mpdf'`. | | `pdf.renderers.mpdf.simple_tables` | bool | `false` | mPDF `simpleTables`: drops the borders of table cells and is not faster. Keep it off. | | `pdf.renderers.mpdf.pdfa_auto` | bool | `false` | mPDF `PDFAauto`: let mPDF correct PDF/A errors itself instead of failing | | `pdf.renderers.fagus.binary` | string\|null | `env('FAGUS_BINARY')` | Path of the `fagus` binary. `null` = the environment variable `FAGUS_BINARY`, the binary installed with `nforst/fagus`, or `fagus` on the `PATH`. | | `pdf.renderers.fagus.timeout` | int\|float | `60` | Seconds the Fagus renderer waits for each answer of its worker process. Another type fails with a `ConfigurationException`. | | `pdf.renderers.{name}` | array | – | Options passed to the factory of a renderer registered with `Quittio::extend('renderer', '{name}', …)` | The design keys (`logo`, `colors`, `font`, `sender_line`, `layout`, `texts`, `footer_columns`, `show_item_numbers`, `payment_qr.type`, `paper`) are design level 1 of [Templates and design](templates.md). The invoice presentation and `->presentation()` override them property by property. ## Validation Every invoice is checked before it is created: against EN 16931, the rules of the format (XRechnung, Peppol) and those of the country (Germany: UStG). See [Rules and validation](concepts.md#rules-and-validation) for the basics and [Validation](validation.md) for the details. | Key | Type | Default | Effect | |---|---|---|---| | `validation.mode` | string | `env('QUITTIO_VALIDATION_MODE', 'error')` | What happens with errors. `error`: throw a `ValidationException`. `warn`: create the invoice anyway and attach the result (`$result->validation()`). `off`: no validation while rendering. Per call: `->validate()`, `->validate(false)`, `->withoutValidation()`. | | `validation.levels` | list | `['php', 'xsd']` | Checks that run while rendering and in `validateFile()`: `php` (rules of EN 16931, format and country; levels L1–L3 and L7), `xsd` (XML schema, L4), `kosit` (the official KoSIT validator for XRechnung and Peppol, needs Java; L5), `verapdf` (PDF/A check, needs veraPDF; L6), or the name of a driver registered with `Quittio::extend('validator', …)`. Without `php`, the PHP rules do not run. | | `validation.block_on_warnings` | bool | `false` | In mode `error`, warnings block like errors | | `validation.locale` | string\|null | `env('QUITTIO_VALIDATION_LOCALE')` | Language of the validation messages and hints. `null` = the language of the application (`app()->getLocale()`), `'invoice'` = the language of the invoice, or a locale such as `'de'`. The invoice itself keeps its language. | | `validation.mandatory_field_guard` | string\|null | `env('QUITTIO_MANDATORY_FIELD_GUARD')` | Check that the PDF shows every legally required value (the template could leave one out): `exception`, `log` or `off`. `null` = `exception` outside production, `log` in production. See [Mandatory field guard](validation.md#mandatory-field-guard). | | `validation.rules.disabled` | list | `[]` | Codes of PHP rules to switch off, e.g. `['DE-USTG-15']`; a trailing `*` matches by prefix. See [Switching rules off](validation.md#switching-rules-off-and-changing-their-severity). | | `validation.rules.severity` | array | `[]` | Severity of the findings per code or prefix: `error`, `warning` or `info`, e.g. `['DE-USTG-08' => 'warning']` | | `validation.rules.allow_official` | bool | `false` | `true` allows changing the official EN 16931 and Peppol rules (`BR-…`, `PEPPOL-…`) | | `validation.drivers.kosit.mode` | string | `'daemon'` | `daemon` (a running validator via HTTP, fast) or `cli` (one Java call per file) | | `validation.drivers.kosit.url` | string | `env('QUITTIO_KOSIT_URL', 'http://127.0.0.1:8081')` | Address of the validator daemon. The validator listens on port 8080 unless started with `-P 8081` (or mapped, `docker run -p 8081:8080`). `quittio:schemas:download` prints a start command for the port of this URL. | | `validation.drivers.kosit.jar` | string\|null | `null` | Validator JAR (mode `cli`) | | `validation.drivers.kosit.scenarios` | string\|null | `null` | Scenario file of the main configuration (mode `cli`, e.g. XRechnung) | | `validation.drivers.kosit.repository` | string\|null | `null` | Repository directory of the main configuration (mode `cli`) | | `validation.drivers.kosit.configurations` | list | `[]` | Further scenario sets `[['scenarios' => …, 'repository' => …]]` (mode `cli`), e.g. Peppol BIS. `quittio:schemas:download` prints the values. | | `validation.drivers.kosit.java` | string | `'java'` | Java binary (mode `cli`) | | `validation.drivers.kosit.timeout` | int | `30` | Timeout in seconds | | `validation.drivers.kosit.fail_on_unavailable` | bool | `true` | `true` = an unreachable validator is an error (`KOSIT-UNAVAILABLE`), `false` = a warning | | `validation.drivers.verapdf.mode` | string | `'cli'` | `cli` (local `verapdf` binary) or `docker` (Docker image; the PDF is passed via stdin) | | `validation.drivers.verapdf.binary` | string | `'verapdf'` | veraPDF binary (mode `cli`) | | `validation.drivers.verapdf.image` | string | `'verapdf/cli'` | Docker image (mode `docker`) | | `validation.drivers.verapdf.docker` | string | `'docker'` | Docker binary (mode `docker`) | | `validation.drivers.verapdf.timeout` | int | `120` | Timeout in seconds | | `validation.drivers.verapdf.fail_on_unavailable` | bool | `true` | `true` = an unavailable veraPDF is an error, `false` = a warning | | `validation.drivers.vies.enabled` | bool | `false` | Check VAT identification numbers online with VIES, the VAT number service of the EU (`QUITTIO-VIES`, `QUITTIO-VIES-UNAVAILABLE`). A `Quittio\Core\Validation\Plausibility\VatIdVerifier` bound in the container replaces the VIES client (e.g. in tests). | | `validation.drivers.vies.cache_ttl` | int | `86400` | Seconds a VALID or INVALID answer is cached (in memory, per process) | | `validation.drivers.vies.timeout` | int | `5` | Timeout in seconds | | `validation.drivers.{name}` | array | – | Options passed to the factory of a validator registered with `Quittio::extend('validator', '{name}', …)` | The KoSIT and veraPDF drivers run only when `kosit` and `verapdf` are listed in `validation.levels`. `quittio:validate --kosit --verapdf` adds them for one file, with the same settings. Levels, messages and the official validators: see [Validation](validation.md). ## Corrections | Key | Type | Default | Effect | |---|---|---|---| | `corrections.cancellation_strategy` | string\|null | `env('QUITTIO_CANCELLATION_STRATEGY')` | How cancellations (`$result->cancel()`, `Quittio::cancellation()` and Managed cancellations) are written. `credit_note`: type code 381 with positive amounts. `negative_invoice`: type code 380 with negative amounts. `null` = the default of the country pack (Germany: `credit_note`; both are permitted). The `strategy:` argument wins. An unknown value fails with a `ConfigurationException`. See [Cancellations and corrections](building-invoices.md#cancellations-and-corrections). | ## Calculation | Key | Type | Default | Effect | |---|---|---|---| | `calculation.declared_amounts` | string | `env('QUITTIO_DECLARED_AMOUNTS', 'keep')` | What happens with amounts another system declared and rounded differently, in invoices continued with `Quittio::edit()` or `InvoiceBuilder::from()` and in their cancellations. `keep`: keep them within the tolerances of EN 16931. `recalculate`: always recalculate. `reject`: throw a `CalculationException` when they are outside the tolerances. Replaced amounts are reported as `QUITTIO-DECLARED-AMOUNTS`. See [Declared amounts](building-invoices.md#declared-amounts). | | `calculation.calculator` | string\|null | `null` | Class of an own calculator (`Quittio\Core\Calculation\TotalsCalculator`), resolved from the container. It calculates renders, cancellations, documents, read invoices and `Quittio::edit()`. `null` = the EN 16931 calculator with `declared_amounts`. | ## Snapshots A snapshot is an invoice stored as JSON together with the version of Quittio's data model. Queued render jobs and the Managed layer store invoices this way. | Key | Type | Default | Effect | |---|---|---|---| | `snapshots.upcasters` | list | `[]` | Classes (resolved through the container) or instances implementing `Quittio\Core\Serialization\Snapshots\SnapshotUpcaster`. They bring stored snapshots of older data model versions up to date when they are read: `InvoiceData::fromSnapshot()`, queued `RenderInvoice` jobs and the invoices of the Managed layer. Only needed after an update that changes the data model. Other values fail with a `ConfigurationException`. | An upcaster reads one version and returns the next one: ```php use Quittio\Core\Serialization\Snapshots\SnapshotUpcaster; final class RenameReferenceField implements SnapshotUpcaster { public function from(): int { return 1; // produces version 2 } public function upcast(array $snapshot): array // without the "_version" key { $snapshot['buyerReference'] ??= $snapshot['reference'] ?? null; unset($snapshot['reference']); return $snapshot; } } ``` ## Reader Limits for reading incoming e-invoices, as protection against oversized files. They apply to `Quittio::read()`, `readFile()`, `validateFile()`, `validatePath()`, `quittio:read` and `quittio:validate`. See [Reading incoming invoices](reading.md#limits-and-security). | Key | Type | Default | Effect | |---|---|---|---| | `reader.max_xml_bytes` | int | `10 * 1024 * 1024` | Largest XML file (bytes) | | `reader.max_pdf_bytes` | int | `25 * 1024 * 1024` | Largest PDF file (bytes) | | `reader.max_decompressed_bytes` | int | `50 * 1024 * 1024` | Largest decompressed content of the PDF streams (bytes) | ## Format resolver The format resolver makes the automatic choice of the format when a render call names none ([Automatic choice](formats.md#automatic-choice)). | Key | Type | Default | Effect | |---|---|---|---| | `format_resolver.driver` | string | `'default'` | `default` (the built-in choice) or the name of a resolver registered with `Quittio::extend('format_resolver', …)`. The factory receives the whole `format_resolver` array. An unknown name fails with a `ConfigurationException`. | | `format_resolver.peppol_lookup` | class-string\|null | `null` | Peppol lookup of the `default` resolver: an invokable class, resolved from the container, that receives the `Quittio\Core\Data\Party\BuyerParty` and returns `true` when the buyer receives invoices via Peppol (an international delivery network for e-invoices). The automatic choice then picks `peppol` for business buyers that no domestic country rule decided. See [Peppol lookup](laravel.md#peppol-lookup). At runtime a callable works as well. Anything else fails with a `ConfigurationException`. `null` = no lookup, the resolver never picks `peppol`. | | `format_resolver.b2c_embed_xml` | bool | `false` | `true` = embed the e-invoice XML in CII syntax (`factur-x.xml`, profile from `defaults.profile`) also into plain PDFs (format `pdf`, e.g. the automatic choice for consumers). These PDFs are then PDF/A-3b. | | `format_resolver.auto_upgrade_profile` | bool | `true` | When an invoice uses EXTENDED features (e.g. sub lines) and no profile was requested, CII formats switch to the profile EXTENDED, which has more fields than EN 16931. `false` = fail with a `ConfigurationException` instead. | Published files of earlier versions may contain a `networks` section (mail, Peppol, French platform). Nothing reads it, so remove it. The Peppol lookup above replaces `networks.peppol`. ## Storage, queue and preview | Key | Type | Default | Effect | |---|---|---|---| | `storage.disk` | string\|null | `env('QUITTIO_STORAGE_DISK', 'local')` | Filesystem disk (`config/filesystems.php`, e.g. `local` or `s3`) of `->save()` on rendered results and of queued renders without a disk. `null` or `''` = the default disk of `config/filesystems.php`. The archive of the Managed layer uses `quittio-managed.disk`. | | `queue.connection` | string\|null | `null` | Queue connection of `->queue()`. `null` = the default connection. | | `queue.queue` | string\|null | `'quittio'` | Queue name of `->queue()`. Workers must listen on it: `php artisan queue:work --queue=quittio,default`. | | `queue.after_commit` | bool | `true` | Inside a database transaction the job is dispatched after the commit, and not at all after a rollback. `false` = at once. | | `preview.enabled` | bool\|null | `env('QUITTIO_PREVIEW_ENABLED')` | `true` = register the browser preview of the sample invoices, `false` = never. `null` = only in the `local` environment. Never registered while routes are cached (`route:cache`). | | `preview.path` | string | `'_quittio/preview'` | URL prefix of the preview | | `preview.middleware` | list | `['web']` | Middleware of the preview routes, e.g. `['web', 'auth']` when you enable it outside `local`. Outside `local` the gate `viewQuittioPreview` must also allow the request ([Preview route](laravel.md#preview-route)). | | `preview.throttle` | string\|null | `'30,1'` | Rate limit of the preview as `attempts,minutes` (Laravel's `throttle` middleware); `null` = none | See [Saving, downloading and mailing](laravel.md#saving-downloading-and-mailing), [Queueing](laravel.md#queueing) and [Preview route](laravel.md#preview-route). ## Serializer extensions `serializers.{name}` (not in the published file) holds the options passed to the factory of a serializer registered with `Quittio::extend('serializer', '{name}', …)`. Registered serializers are always used. They replace the built-in XML writer of their syntax (CII or UBL, see [Syntaxes](concepts.md#syntaxes-cii-and-ubl)). ## Without Laravel The core takes the same settings as a `Quittio\Core\Config` object or as an array for `Quittio::create()` (`Config::fromArray()`). Some keys are shaped differently there, e.g. `validation.levels` as `L1` … `L7`, `pdf.b2c_embed_xml`, and `format` instead of `defaults.format`. See [Getting started](getting-started.md#without-laravel), which maps every core key to its Laravel key. The `seller` section becomes three keys. `$quittio->invoice()` and the document methods (`$quittio->quote()` …) start with them, as `Quittio::invoice()` does with the section: ```php use Quittio\Core\Builder\Party; use Quittio\Core\Quittio; use Quittio\Country\DE\CountryDE; $quittio = Quittio::create([ 'seller' => Party::make('Muster GmbH') // seller.name … electronic_address ->vatId('DE123456789') ->taxNumber('21/815/08150') ->legalRegistration('HRB 12345') ->address('Hauptstraße 1', '12345', 'Musterstadt', 'DE') ->contact('Max Muster', '+49 30 1234567', 'billing@muster.de') ->electronicAddress('billing@muster.de', 'EM'), 'bank_account' => ['iban' => 'DE89370400440532013000', 'bic' => 'COBADEFFXXX', 'name' => 'Muster GmbH'], // the first entry of seller.bank_accounts 'small_business' => false, // seller.small_business ], [new CountryDE]); ``` - `seller` takes a `Party::make()` builder or a `SellerParty`. A seller without name or postal address fails with a `ConfigurationException` when the instance is created. - `bank_account` holds one account; `iban` is required, `bic` and `name` are optional. It is added as SEPA credit transfer. - `bank_account` and `small_business` without `seller` fail with a `ConfigurationException`. - On an invoice, `->seller()` with another `Party` drops the configured account and the small business flag, `->seller(fn ($s) => …)` changes the configured seller and keeps them, `->payment(…)` replaces the account and `->creditTransfer(…)` adds a second one. <!-- Source: https://quittio.dev/docs/commands --> # Artisan commands This page lists every Artisan command of Quittio and every publish tag for `vendor:publish`. You need it when you install Quittio, check the invoice design, validate e-invoice files (locally or in CI) and schedule recurring tasks. The commands are grouped by purpose: [Setup](#setup), [Preview and testing](#preview-and-testing), [Maintenance](#maintenance) and [Package development](#package-development). Terms such as XRechnung, Peppol, profile or KoSIT are explained in [E-invoicing basics](concepts.md). Three packages register commands: - `quittio/laravel` registers the general commands (console only). - `quittio/managed` adds the commands for stored invoices and extends `quittio:install` and `quittio:render`. - `quittio/country-de` adds `quittio:base-rate:update`. Every command returns exit code `0` on success and `1` on failure. The failure cases are listed per command, so CI jobs and the scheduler can react to them. ## Overview | Group | Command | Package | Purpose | |---|---|---|---| | Setup | [`quittio:install`](#quittioinstall) | laravel | Publish the configuration (with that of the country packs), optionally templates and fonts; `--managed` installs the Managed layer | | Setup | [`quittio:countries`](#quittiocountries) | laravel | Show the installed country packs | | Setup | [`make:quittio-template`](#makequittio-template) | laravel | Create a template from the default template | | Setup | [`quittio:schemas:download`](#quittioschemasdownload) | laravel | Download the KoSIT validator and the XRechnung configuration, compile the Peppol rules | | Preview and testing | [`quittio:preview`](#quittiopreview) | laravel | Render a sample invoice with the configured design | | Preview and testing | [`quittio:render`](#quittiorender) | laravel, managed | Render an invoice from a JSON file, or render a stored invoice again | | Preview and testing | [`quittio:validate`](#quittiovalidate) | laravel | Validate an XML or PDF e-invoice and print a report | | Preview and testing | [`quittio:read`](#quittioread) | laravel | Read an e-invoice and show its content | | Preview and testing | [`quittio:benchmark`](#quittiobenchmark) | laravel | Measure rendering performance | | Maintenance | [`quittio:verify`](#quittioverify) | managed | Check the hashes of the archived documents | | Maintenance | [`quittio:drafts:prune`](#quittiodraftsprune) | managed | Delete left-behind cancellation and correction drafts | | Maintenance | [`quittio:retention:check`](#quittioretentioncheck) | managed | List (and delete) invoices past their retention period | | Maintenance | [`quittio:sequence:show`](#quittiosequenceshow) | managed | Show the number sequences | | Maintenance | [`quittio:sequence:set`](#quittiosequenceset) | managed | Increase a number sequence | | Maintenance | [`quittio:base-rate:update`](#quittiobase-rateupdate) | country-de | Fetch the German base rate (Basiszinssatz, section 247 of the German Civil Code BGB) from the Deutsche Bundesbank | | Package development | [`quittio:codelists:update`](#quittiocodelistsupdate) | laravel | Regenerate the code lists | `php artisan about` shows a section "Quittio" with the active country packs and profiles. Commands that ask for confirmation (`quittio:sequence:set`, `quittio:retention:check --delete`, `quittio:drafts:prune`) treat a run without interaction as "no" and exit with `1`. Runs without interaction are `--no-interaction`, the scheduler and CI; pass `--force` there. ## Setup Run these commands when you install Quittio or change its setup. ### quittio:install ```bash php artisan quittio:install {--views} {--fonts} {--managed} {--force} ``` | Option | Effect | |---|---| | `--views` | Also publish the Blade templates (`quittio-views`) | | `--fonts` | Also publish the fonts (`quittio-fonts`, to `resources/fonts/quittio/geist` and `resources/fonts/quittio/inter`). The renderer searches `resources/fonts/quittio` and its subdirectories automatically. | | `--managed` | Also install the Managed layer (needs `quittio/managed`) | | `--force` | Overwrite existing files | The command publishes `config/quittio.php` (tag `quittio-config`), the settings of every installed country pack that has some (tags `quittio-{code}-config`, e.g. `quittio-de-config`: `config/quittio/countries/de.php`) and the selected tags. Then it prints the next steps: set the seller, install a country pack, run the preview. It exits with `1` when `--managed` is given without `quittio/managed`. With `--managed`, the Managed installer then: 1. publishes `config/quittio-managed.php` (`quittio-managed-config`; overwritten with `--force`), 2. publishes the migrations (`quittio-managed-migrations`) unless they were published before. It detects them by file name, because `vendor:publish` gives migrations new timestamps. 3. asks "Run the migrations now?" (default yes) and runs `migrate --force`. When you decline, it prints the next steps and ends with exit code `0`. 4. asks for the first issuer profile, if none exists: key (`default`), company name (required), street and number, postcode, city, country (`DE`), VAT identifier, tax number (only without VAT identifier), e-mail address for invoices (contact and electronic address), IBAN, BIC (only with IBAN) and time zone. The time zone defaults to `app.timezone`, or to `Europe/Berlin` for Germany when that is UTC. The profile becomes the default issuer. Without interaction (`-n`), it runs the migrations without asking and skips the issuer profile. The immutability triggers are not published; publish them separately (see [Managed layer](managed.md#immutability)). It exits with `1` when the migrations or the database fail. ### quittio:countries ```bash php artisan quittio:countries ``` Lists the active country packs: code, class, profiles, number of rules and format rules, and the defaults (currency, locale, profile). Without a country pack, it warns that only EN 16931 rules are checked (exit code `0`). See [Country packs](country-packs.md). ### make:quittio-template ```bash php artisan make:quittio-template {name} {--force} ``` | Argument / option | Effect | |---|---| | `name` | Template name: lower-case letters, digits, `-` and `_`, starting with a letter or digit | | `--force` | Overwrite an existing template | Copies the default template (`layout.blade.php` and `partials/`) to `resources/views/invoices/{name}` and points the layout to its own partials. Use the new template per call with `->template('invoices.{name}.layout')` (allowed by the default `pdf.templates`), or for every invoice with `pdf.template`. An invalid name, or an existing template without `--force`, exits with `1`. See [Templates and design](templates.md). ### quittio:schemas:download ```bash php artisan quittio:schemas:download {--path=} {--force} {--without-peppol} {--java=java} ``` Installs the official validators for local checks and CI: the KoSIT validator (the validator for XRechnung and EN 16931, published by KoSIT, the agency behind XRechnung) and the rules of Peppol BIS Billing. Quittio uses them for the validation level L5 ([KoSIT validator](validation.md#kosit-validator-l5)). | Option | Default | Effect | |---|---|---| | `--path` | `storage/quittio/validators` | Target directory | | `--force` | – | Download and compile again, also when the files exist | | `--without-peppol` | – | Skip compiling the Peppol BIS Billing 3.0 rules | | `--java` | `java` | Java binary for compiling the Peppol rules | It downloads into the target directory: | File | Content | |---|---| | `validator.jar` | KoSIT validator 1.6.3 (standalone) | | `xrechnung/` | XRechnung validator configuration (release `v2026-08-31`, XRechnung 3.0.2), with `scenarios.xml` | | `peppol/PEPPOL-EN16931-UBL.xsl` | Peppol BIS Billing 3.0 rules (Schematron, a rule language for XML, `v3.0.20`), compiled with SchXslt 1.10.1 and the Saxon of the validator JAR | Every download is checked against the SHA-256 checksum pinned in `KositArtifacts::SHA256`; a file that does not match is discarded and the command fails. Existing files are kept unless `--force` is given. The command needs the PHP `zip` extension. Compiling the Peppol rules and running the validator need Java 11 or newer. Afterwards it prints: - the configuration for `validation.drivers.kosit` in mode `cli` (`jar`, `scenarios`, `repository` and, with Peppol, `configurations`), - a reminder to add `kosit` to `validation.levels`, - the command that starts the validator as a daemon for the default mode `daemon`, on the port of `validation.drivers.kosit.url`. The default URL is `http://127.0.0.1:8081`, so the command contains `-P 8081`; the validator's own default port is 8080. ```bash java -jar '…/validators/validator.jar' -s '…/validators/xrechnung/scenarios.xml' -r '…/validators/xrechnung' \ -s '…/peppol-scenarios.xml' -r '…/validators' -D -P 8081 ``` Download and compile errors exit with `1`. See [Validation](validation.md#kosit-validator-l5) and [Official validators in CI](testing.md#official-validators-in-ci). ## Preview and testing Use these commands to check the design, to render invoices from files and to check e-invoice files, e.g. in CI or when a customer sends you an invoice. ### quittio:preview ```bash php artisan quittio:preview {--scenario=simple} {--template=} {--format=pdf} {--locale=} {--output=} ``` Renders a sample invoice with your design (logo, colours, texts, template) into a file. The sample invoices use sample data, not your seller. | Option | Default | Effect | |---|---|---| | `--scenario` | `simple` | Sample scenario (see [Scenarios](testing.md#scenarios)) | | `--template` | configured | A view that rendering accepts: `default`, the configured `pdf.template`, a view under `quittio::templates.` or one of `pdf.templates`, e.g. `invoices.acme.layout` from `make:quittio-template`. No partials; the view must exist. | | `--format` | `pdf` | `pdf` or `html` | | `--locale` | scenario locale (`de`) | Locale of the labels | | `--output` | `storage/app/quittio/preview/{scenario}.{format}` | Target file; missing directories are created | The command renders the scenario with the configured design, validation mode `warn` and the watermark "PREVIEW" ("VORSCHAU" in German), like the [preview route](laravel.md#preview-route). Unknown scenarios, formats, templates or invalid locales exit with `1`. ### quittio:render ```bash php artisan quittio:render {invoice?} {--json=} {--format=} {--profile=} {--output=} ``` | Argument / option | Effect | |---|---| | `invoice` | Number, UUID or id of a stored invoice of the Managed layer (see below). Takes precedence over `--json`. | | `--json` | JSON file with invoice data in the format of `InvoiceData::toJson()` (see [Getting started](getting-started.md#json)) | | `--format` | Output format; default: `defaults.format`, else the automatic choice | | `--profile` | Profile | | `--output` | Directory (an existing one or a path ending in `/`; the file gets `filename()`) or target file; missing directories are created; default: the current directory. A file that cannot be written fails the command | **From a JSON file.** With `--json`, the command renders like `Quittio::make($data)->format(…)->profile(…)->render()`, with the configured validation mode. It writes the main output (`contents()`): the PDF of `zugferd` and `pdf`, the XML of the XML formats. It prints the number, format, profile and path, and the findings when there are warnings. Validation errors are printed as a table and exit with `1`. A missing `--json`, an unreadable file and any other error exit with `1` as well. **A stored invoice (Managed layer).** With `invoice` (and `quittio/managed` installed), the command renders an issued invoice whose documents are missing or failed: - It looks up a UUID first, then the number (a number used by several issuers must be given as UUID), then the numeric id. - When the current document version is complete, it reports that and exits with `0`. - Missing files are rendered as a new document version; existing files are never overwritten. The command lists the missing files and the new version. - Damaged files (hash mismatch) dispatch `ArchiveIntegrityViolation` and exit with `1`. Drafts and unknown invoices exit with `1` as well. Without `quittio/managed`, `invoice` exits with `1`. See [Rendering and archive](managed.md#rendering-and-archive). ### quittio:validate ```bash php artisan quittio:validate {file} {--profile=} {--kosit} {--verapdf} {--json} ``` Checks an e-invoice file against the rules, e.g. one you received or one your application produced. See [Validation](validation.md) for the levels L1 to L7. | Argument / option | Effect | |---|---| | `file` | XML or PDF file | | `--profile` | Expected profile (aliases allowed); a different profile fails | | `--kosit` | Also run the KoSIT validator (L5) with all settings of `quittio.validation.drivers.kosit` (`mode`, `url`, `jar`, `scenarios`, `repository`, `configurations`, `java`, `timeout`, `fail_on_unavailable`) | | `--verapdf` | Also run veraPDF, the PDF/A checker (L6), with all settings of `quittio.validation.drivers.verapdf` (`mode`, `binary`, `image`, `docker`, `timeout`, `fail_on_unavailable`) | | `--json` | Print the result as JSON instead of the report | The command reads the file and validates it with the configured levels plus `kosit` and `verapdf` (`Quittio::coreWithLevels()`): - The drivers are built exactly as in a render run. - A level already in `validation.levels` is not added twice. - The cached core of the application is not changed. - With `fail_on_unavailable` set to `false`, a validator that cannot be reached or started is reported as a warning (`KOSIT-UNAVAILABLE`, `VERAPDF-UNAVAILABLE`) and does not fail the command. The report shows invoice number, syntax, profile, the checked levels and a table of findings (severity, level, code, business term, message and hint). `--json` prints `{"valid": …, "levels": […], "messages": [{severity, code, message, level, bt, path, hint, xpath}], "profile": …, "expectedProfile": …, "profileMismatch": …}`; when the file cannot be checked, it prints `{"valid": false, "error": "…"}`. | Exit code | Meaning | |---|---| | `0` | The file has no errors and, with `--profile`, has the expected profile; warnings do not fail | | `1` | The file has errors or another profile than `--profile` | | `2` | The file could not be checked: missing or unreadable, not readable as e-invoice, or an unknown `--profile` | ### quittio:read ```bash php artisan quittio:read {file} {--json} ``` | Argument / option | Effect | |---|---| | `file` | XML or PDF file | | `--json` | Print the invoice data as JSON (`InvoiceData::toJson()`) | Shows the content of an e-invoice file: - number, issue date, type code, syntax and profile, - seller and buyer (with country), - the embedded file name of a PDF, - a table of the lines (position, item, quantity and unit, net amount, VAT category and rate), - net total, VAT and amount due (the totals declared in the file), - the findings of the reader. A missing or unreadable file exits with `1`. See [Reading incoming invoices](reading.md). ### quittio:benchmark ```bash php artisan quittio:benchmark {--count=20} {--scenario=simple} {--format=*} ``` | Option | Default | Effect | |---|---|---| | `--count` | `20` | Measured runs per format (at least 1) | | `--scenario` | `simple` | Sample scenario | | `--format` | `cii`, `zugferd` | Formats; repeat the option for several (`--format=cii --format=zugferd`) | Renders the scenario once per format to warm up fonts and caches. Then it renders `--count` times with validation mode `warn` and prints average, minimum, 95th percentile and maximum in milliseconds, plus the peak memory. An unknown scenario exits with `1`. ## Maintenance Recurring tasks. Most of them belong to the Managed layer, which stores invoices in the database ([Managed layer](managed.md)). Schedule them as shown in [Scheduling](#scheduling). ### quittio:verify Managed layer. ```bash php artisan quittio:verify {--from=} {--to=} {--issuer=} ``` | Option | Effect | |---|---| | `--from` | Issue date from (`Y-m-d`, inclusive) | | `--to` | Issue date to (`Y-m-d`, inclusive) | | `--issuer` | Only invoices of this issuer key | Checks every issued invoice of all issuers; the tenancy scope does not apply. The archived XML and PDF of the current document version must exist and match their SHA-256 hashes. Issued invoices whose documents were never archived (render status `pending`, `rendering` or `failed`) count as problems too. Every problem dispatches `ArchiveIntegrityViolation` (invoice, path, problem). The run writes the audit entry `verified` with the number of checked invoices and violations. Problems are printed as a table and exit with `1`. See [Rendering and archive](managed.md#rendering-and-archive). ### quittio:drafts:prune Managed layer. ```bash php artisan quittio:drafts:prune {--older-than=60} {--force} ``` | Option | Default | Effect | |---|---|---| | `--older-than` | `60` | Minimum age of cancellation drafts in minutes | | `--force` | – | Do not ask for confirmation | Deletes drafts that can never be issued: - cancellation drafts older than `--older-than` minutes. They were left behind (e.g. by a crash) while `cancel()` or `cancelPartially()` issued them. - correction drafts whose original is no longer in status `issued` or no longer exists. The command lists them (draft, kind, original, created), asks, and deletes each through the model (audit entry `deleted_draft`). A draft issued meanwhile is not touched. A non-numeric `--older-than` or a declined confirmation exits with `1`. See [Cancellations and corrections](managed.md#cancellations-and-corrections). ### quittio:retention:check Managed layer. ```bash php artisan quittio:retention:check {--delete} {--force} ``` | Option | Effect | |---|---| | `--delete` | Delete the expired invoices and their archived documents (asks for confirmation) | | `--force` | Do not ask for confirmation | Invoices must be kept for a legal retention period ([Retention and deletion](managed.md#retention-and-deletion)). The command lists the issued invoices past their retention period that are not on legal hold. An invoice counts as expired two days after `retention_until`. It dispatches `RetentionExpired` for each of them. It also reports archived files of deleted invoices that could not be deleted yet. Without `--delete` nothing changes. With `--delete`, it first retries the leftover files. Then it deletes by group: - A group is an invoice together with all invoices connected to it through cancellations, partial cancellations, corrections and replacements. - A group is deleted only when every member is expired and none is on legal hold. Otherwise the command names the invoice that keeps the group. - The rows of a group (relations, deliveries, referring drafts, invoices) are deleted in one transaction with audit entries, then all archived files of all document versions. Files that cannot be deleted are tried again by the next run. Failures of single groups are reported and the run continues (exit code `0`). A declined confirmation exits with `1`. See [Rendering and archive](managed.md#rendering-and-archive). ### quittio:sequence:show Managed layer. ```bash php artisan quittio:sequence:show {--issuer=} ``` | Option | Effect | |---|---| | `--issuer` | Only the sequences of this issuer key | Lists every number sequence with its next value and pattern, ordered by key. The key has the form `{issuer}:{sequence}:{period}`, e.g. `default:invoice:2026`. Sequences are created when the first invoice of a period is issued. See [Numbering](managed.md#numbering). ### quittio:sequence:set Managed layer. ```bash php artisan quittio:sequence:set {key} {value} {--force} ``` | Argument / option | Effect | |---|---| | `key` | Sequence key `{issuer}:{sequence}:{period}`, e.g. `default:invoice:2026` | | `value` | New next value, a positive integer greater than the current one | | `--force` | Do not ask for confirmation | Raises the next value of a sequence, e.g. when you migrate from another system. Lowering it is refused. A sequence that does not exist yet is created ahead of time, but only when the numbering would use it: - the issuer must exist, - the sequence must be `invoice`, or a kind with its own sequence for that issuer (`cancellation`, `correction`), - the period must match the reset mode (`2026` yearly, `2026-10` monthly, `all` never). The pattern comes from the configuration. The change runs in a transaction with a row lock and is written to the audit log. Invalid values or keys, a lower value and a declined confirmation exit with `1`. See [Numbering](managed.md#numbering). ### quittio:base-rate:update German country pack. ```bash php artisan quittio:base-rate:update [--dry-run] ``` | Option | Effect | |---|---| | `--dry-run` | Show the rates, write nothing | German default interest on late payments is the base rate (Basiszinssatz) under section 247 of the German Civil Code (BGB) plus a surcharge. The base rate changes on 1 January and 1 July. Quittio ships the rates up to its release; this command fetches the later ones, so that default interest (`DefaultInterest`) covers periods after the shipped table without a new release. The command fetches the base rate from the statistics API of the Deutsche Bundesbank (series `BBIN1.M.DE.BBK.BBKBAS2.EUR.ME`). It stores the rates that the shipped table does not contain, and values that differ from it, in `quittio.countries.de.base_rate_file` (default `storage/app/quittio/base-rates.json`). The German country pack registers it (`GermanyServiceProvider`). It prints the latest rate and the rates after the shipped table. It warns when a value differs from the shipped table; the Bundesbank value is then used. It writes the file only when something changed. Exit code `1` when: - the API cannot be reached or returns no rates, - `quittio.countries.de.base_rate_file` is empty (not with `--dry-run`), - the directory of the file cannot be created. See [Country packs: base rate table](country-packs.md#base-rate-table) and [Country pack Germany](configuration.md#country-pack-germany-quittiocountriesde). ## Package development ### quittio:codelists:update ```bash php artisan quittio:codelists:update {xsl?} {--target=} ``` | Argument / option | Default | Effect | |---|---|---| | `xsl` | `storage/quittio/validators/xrechnung/resources/cii/16b/xsl/EN16931-CII-validation.xsl` | EN 16931 CII Schematron XSL of the validator configuration | | `--target` | the code lists of `quittio/core` (`resources/codelists`) | Output directory | For the development of Quittio itself: it regenerates the JSON code lists (units, currencies, countries, VAT categories, VATEX, EAS and ICD schemes, payment means, …) from the official rules and prints the number of codes per list. In an application, pass `--target`; the default writes into the installed package. A missing XSL exits with `1` (run `quittio:schemas:download` first). ## Scheduling Schedule the maintenance commands in `routes/console.php`: ```php // routes/console.php use Illuminate\Support\Facades\Schedule; Schedule::command('quittio:verify')->weekly()->onOneServer(); // exit code 1 on problems Schedule::command('quittio:drafts:prune --force')->daily()->onOneServer(); Schedule::command('quittio:retention:check')->monthly()->onOneServer(); // report and RetentionExpired events Schedule::command('quittio:base-rate:update')->weekly()->onOneServer(); // new base rate on 1 January and 1 July ``` | Command | Recommendation | |---|---| | `quittio:verify` | Daily or weekly. React to failures with `->onFailure(…)` or `->emailOutputOnFailure(…)` and listen for `ArchiveIntegrityViolation`. On large archives limit the range, e.g. `['--from' => now()->subDays(8)->toDateString()]`, and run a full check less often. | | `quittio:drafts:prune` | Daily with `--force` | | `quittio:retention:check` | Monthly without `--delete` for a report. Add `--delete --force` only when expired invoices should be deleted without review. | | `quittio:schemas:download` | Not scheduled: run it in deployment or CI when you use the KoSIT validator | | `quittio:base-rate:update` | Weekly (or daily in January and July): the new rate is stored as soon as the Bundesbank has published it | ## Publish tags Publish tags copy files of the packages into your application, so that you can change them: ```bash php artisan vendor:publish --tag=quittio-config ``` | Tag | Package | Publishes to | |---|---|---| | `quittio-config` | laravel | `config/quittio.php` ([Configuration](configuration.md)) | | `quittio-views` | laravel | `resources/views/vendor/quittio/templates` (default template and partials; they override the package views) | | `quittio-lang` | laravel | `lang/vendor/quittio` (labels, rule messages, codes, terms) | | `quittio-fonts` | laravel | `resources/fonts/quittio/geist` (Geist) and `resources/fonts/quittio/inter` (Inter). `resources/fonts/quittio` and its subdirectories are added to the font directories automatically, so further font files placed there only need an entry in `pdf.fonts`. | | `quittio-managed-config` | managed | `config/quittio-managed.php` | | `quittio-managed-migrations` | managed | `database/migrations` (tables of the Managed layer, with new timestamps) | | `quittio-managed-triggers` | managed | `database/migrations` (immutability triggers, recommended for production) | | `quittio-managed-views` | managed | `resources/views/vendor/quittio-managed` (mail view) | | `quittio-managed-lang` | managed | `lang/vendor/quittio-managed` (mail and invoice texts) | | `quittio-de-config` | country-de | `config/quittio/countries/de.php` (`quittio.countries.de`: base rates; published by `quittio:install` as well) | Publishing is only registered in the console. <!-- Source: https://quittio.dev/docs/testing --> # Testing This page shows how to test code that creates invoices: fast feature tests with a fake, checks that your e-invoices are valid, test data and the official validators in CI. The examples use Pest; the same methods work in PHPUnit. | You want to test | Use | |---|---| | That your code renders an invoice, without the cost of a real run | [`Quittio::fake()`](#fake) | | That the invoice data is a valid e-invoice, without rendering | [`check()`](#validating-the-invoice-data) | | Storage, events, the queue or mail with real rendering | [Laravel fakes](#laravel-fakes) | | That a rendered PDF or XML is a valid e-invoice, or that the XML has not changed | [Assertions](#assertions) | | An invoice to test with, without writing a builder chain | [Factory](#factory) | | Realistic sample invoices: many lines, reverse charge, foreign currency … | [Scenarios](#scenarios) | | Your files with the official validators (KoSIT, veraPDF) | [Official validators in CI](#official-validators-in-ci) | | Models of the Managed layer | [Managed layer factories](#managed-layer-factories) | The factory and the scenarios are part of `quittio/core` and work without Laravel. The fake and the assertions need `quittio/laravel`. Terms such as ZUGFeRD, profile or reverse charge are explained in [E-invoicing basics](concepts.md). ## Fake The most common test checks that your code renders an invoice, e.g. when an order ships. `Quittio::fake()` replaces the rendering with a fast fake that records every render call. Afterwards you assert what was rendered: ```php use Quittio\Laravel\Facades\Quittio; use Quittio\Laravel\Rendering\RenderedInvoice; it('renders the invoice of an order', function () { $fake = Quittio::fake(); $this->post('/orders/42/invoice')->assertOk(); Quittio::assertRenderedCount(1); Quittio::assertRendered(fn (RenderedInvoice $r) => $r->format() === 'zugferd' && $r->data()->totals->amountDue->isEqualTo('1234.56')); expect($fake->rendered()[0]->data()->number)->toBe('RE-2026-0042'); }); ``` - `assertRenderedCount(1)` checks that exactly one invoice was rendered. - `assertRendered()` with a callback checks that at least one rendered invoice matches: here one in the format ZUGFeRD (`zugferd`, a PDF with embedded XML) with the expected amount due. The callback receives a `RenderedInvoice`; its `data()` holds the calculated invoice with totals. - `Quittio::fake()` returns the fake. `$fake->rendered()` lists the recorded results, in order. - The fake skips validation. To test that the invoice is a valid e-invoice, add a test with [`check()`](#validating-the-invoice-data). A complete example with an order, a mail and both kinds of test is [Testing](examples.md#testing) on the Examples page. ### How the fake works `Quittio::fake()` replaces the manager with a `Quittio\Laravel\Testing\QuittioFake` and returns it. It is swapped into the facade and into the container. So code that injects `QuittioManager`, queued `RenderInvoice` jobs and the Managed layer use the fake as well. The fake takes the decisions of a real run: it calls `prepare()` of the core without validators. Then it returns placeholder results instead of rendering. It skips validation, XML, template and PDF: | | Behaviour of the fake | |---|---| | Calculation | Real: totals, VAT breakdown and the due date of `defaults.due_days`, so `data()` holds the amounts | | Format | As in a real run: `format()`/`formats()`, then `defaults.format`, then the automatic choice (country rules, `format_resolver`, Peppol lookup). Every format of the call is recorded under the main result, so `formats()` and `as()` work. | | Profile | As in a real run: `profile()` with a key, alias or `Profile` object, `defaults.profile`, the profile of the automatic choice or of the format, the EXTENDED upgrade; `null` for formats without XML | | Errors | An unknown format or profile, or a profile the format does not allow, throws a `ConfigurationException` like a real run | | Validation | None: `validation()` is an empty `ValidationResult`, no `ValidationException` | | Outputs | Placeholders according to the format: XML `<fake number="…"/>`, PDF `%PDF-1.7` with a comment, HTML `<p>{number}</p>`, JSON of the data | | File name | `Invoice_{number}.{ext}` | | Documents | Calculated; fake HTML and, unless `htmlOnly()`, a fake PDF; file name `{number}.{ext}` | | Events | As in a real run: `InvoiceRendering`, `InvoiceValidated` (with the empty result, not in mode `off`) and `InvoiceRendered`, so `Event::fake()` with `Event::assertDispatched(InvoiceRendered::class)` works | | Queue | `queue()->save()` records the job (`queued()`, `assertQueued()`) and dispatches it like a real run: `Queue::fake()` sees it, a `sync` queue renders it with the fake | Not faked: `check()`, `prepare()`, `read()`, `readFile()`, `validateFile()`, `validatePath()` and `cancellation()` run the real core. Responses, `save()` and mail attachments work on the fake results. The fake stays active until the application is rebuilt for the next test. ### Assertions of the fake These methods belong to the fake and are also callable through the facade (`Quittio::assertRendered()`): | Method | Asserts / returns | |---|---| | `assertRendered(?callable $callback = null)` | At least one invoice was rendered; with a callback, at least one `RenderedInvoice` for which it returns `true` | | `assertRenderedCount(int $count)` | Exactly `$count` invoices were rendered | | `assertNothingRendered()` | No invoice was rendered | | `assertDocumentRendered(?callable $callback = null)` | At least one document (quote, reminder, …) was rendered; with a callback, one `RenderedDocument` matches | | `rendered(): array` | The recorded `RenderedInvoice` results (the main format of each call), in order | | `documents(): array` | The recorded `RenderedDocument` results, in order | | `assertQueued(?callable $callback = null)` | At least one invoice was queued with `queue()->save()`; with a callback, one `RenderInvoice` job matches (`$job->data()` is the invoice, `$job->disk`, `$job->path`) | | `assertNothingQueued()` | No invoice and no document was queued | | `assertDocumentQueued(?callable $callback = null)` | At least one document was queued with `Quittio::document(…)->queue()->save()`; with a callback, one `RenderDocument` job matches (`$job->data()` is the document) | | `queued(): array` | The recorded `RenderInvoice` jobs, in order | Documents such as quotes and reminders ([Quotes and other documents](documents.md)) are recorded separately from invoices: ```php $fake = Quittio::fake(); Quittio::document($quote)->htmlOnly()->render(); expect($fake->documents())->toHaveCount(1) ->and($fake->documents()[0]->hasPdf())->toBeFalse(); ``` ## Validating the invoice data A test with the fake does not show whether the invoice is a valid e-invoice. `check()` runs the real validation, including the XML, without rendering a PDF. It is never faked, so it also works while the fake is active: ```php laravel use Quittio\Laravel\Facades\Quittio; it('builds a valid e-invoice for an order', function () { $order = Order::factory()->create(); $report = Quittio::make($order)->check(); // the real validation, without rendering expect($report->isValid())->toBeTrue() ->and($report->warnings())->toBe([]); }); ``` ```php plain use Quittio\Core\Quittio; use Quittio\Country\DE\CountryDE; it('builds a valid e-invoice for an order', function () { $order = new Order(/* … */); $report = Quittio::create([], [new CountryDE])->make($order)->check(); // the real validation, without rendering expect($report->isValid())->toBeTrue() ->and($report->warnings())->toBe([]); }); ``` - `Order` is a model or class of your application that implements `ProvidesInvoiceData` ([Invoices for orders](examples.md#invoices-for-orders)). Any invoice data works the same way: `Quittio::make($invoice)->check()`. - `check()` returns a `ValidationResult` and never throws a `ValidationException` for invalid data. `isValid()` is `true` without errors; `warnings()` lists the warnings ([The result](validation.md#the-result)). - It validates in the same formats and profiles as `render()` would. The PDF/A check (level L6) does not run, because it needs the rendered PDF ([When validation runs](validation.md#when-validation-runs)). - To validate a rendered PDF or XML file, use [`assertValidEInvoice()`](#assertions). ## Laravel fakes Without `Quittio::fake()` the real core renders. Then the usual Laravel fakes test the integration end to end: files on a disk, events and queued jobs. `InvoiceData::factory()` builds the test invoice ([Factory](#factory)): ```php use Illuminate\Support\Facades\Event; use Illuminate\Support\Facades\Queue; use Illuminate\Support\Facades\Storage; use Quittio\Core\Data\InvoiceData; use Quittio\Laravel\Events\InvoiceRendered; use Quittio\Laravel\Events\InvoiceValidationFailed; use Quittio\Laravel\Facades\Quittio; use Quittio\Laravel\Jobs\RenderInvoice; it('stores the PDF', function () { Storage::fake('invoices'); Quittio::make(InvoiceData::factory()->make())->format('zugferd')->render()->save('invoices', '2026/'); Storage::disk('invoices')->assertExists('2026/Rechnung_RE-2026-0042.pdf'); }); it('dispatches the events', function () { Event::fake([InvoiceRendered::class, InvoiceValidationFailed::class]); Quittio::make(InvoiceData::factory()->make())->format('cii')->render(); Event::assertDispatched(InvoiceRendered::class, fn ($e) => $e->result->format() === 'cii'); Event::assertNotDispatched(InvoiceValidationFailed::class); }); it('queues the rendering', function () { Queue::fake(); Quittio::make(InvoiceData::factory()->make())->queue()->save('invoices', 'queued/'); Queue::assertPushedOn('quittio', RenderInvoice::class, fn (RenderInvoice $job) => $job->path === 'queued/'); }); ``` - The factory's invoice is German (locale `de`), so the file name starts with the German title "Rechnung" (invoice). - The events are described in [Events](laravel.md#events), the queue in [Queueing](laravel.md#queueing). `quittio` is the default queue name. - Rendered results are `Attachable`. So `Mail::fake()` with `Mail::assertSent(YourMail::class, fn ($mail) => $mail->hasAttachment($result))` checks mail attachments. - After changing `config('quittio.…')` inside a test, the next call uses the new configuration ([Configuration](configuration.md)). ## Assertions The trait `Quittio\Laravel\Testing\InteractsWithQuittio` adds two assertions for rendered files to a test case. `assertValidEInvoice()` checks that a PDF or XML is a valid e-invoice. `assertXmlMatchesSnapshot()` checks that the XML has not changed since you last accepted it. Add the trait to your tests: ```php // PHPUnit use Quittio\Laravel\Testing\InteractsWithQuittio; class InvoiceTest extends TestCase { use InteractsWithQuittio; } // Pest, in a single test file uses(InteractsWithQuittio::class); // Pest, for all tests of a directory (in tests/Pest.php) pest()->use(InteractsWithQuittio::class)->in('Feature'); ``` After each test the trait also resets the process-wide state of Quittio (`Quittio\Core\Quittio::resetState()`), e.g. base rates that a test registered. Then use the assertions on the outputs of a rendered invoice: ```php $result = Quittio::make(InvoiceData::factory()->make())->formats(['zugferd', 'xrechnung-ubl'])->render(); $this->assertValidEInvoice($result->pdf(), 'en16931'); $this->assertValidEInvoice($result->as('xrechnung-ubl')->xml(), 'xrechnung'); $this->assertXmlMatchesSnapshot($result->xml(), 'zugferd-default'); ``` | Method | Asserts | |---|---| | `assertValidEInvoice(string $pdfOrXml, ?string $profile = null)` | Reads the PDF or XML content and validates it with all configured levels (`quittio.validation.levels`, see [below](#official-validators-in-ci)). Fails with the code and message of every error; warnings do not fail. With `$profile`, the profile read from the file must be that profile (aliases are resolved, e.g. `comfort`). | | `assertXmlMatchesSnapshot(string $xml, ?string $name = null)` | Compares the canonicalised XML (whitespace between elements removed, re-indented) with a stored snapshot. The first run writes the snapshot and passes. Not well-formed XML fails. | The profile is the set of rules the file follows, e.g. `en16931` or `xrechnung` ([Profiles](concepts.md#profiles)). ### Snapshots A snapshot is a stored copy of the XML. Later runs compare the XML with it, so that an unintended change of the output fails the test. - Snapshots are stored in `__snapshots__/quittio/{name}.xml` next to the test file. - The name is reduced to letters, digits, `.`, `_` and `-`. Without a name it is `{TestClass}__{test name}`. Pest generates class and test names, so pass a name there. - To accept a changed XML, delete the snapshot file and run the test again. - Override the protected methods `quittioSnapshotDirectory()` and `quittioSnapshotName()` to change the location and the default name. ### Outside test case classes Outside test case classes, e.g. in Pest helper functions, `Quittio\Laravel\Testing\EInvoiceAssertions` provides the same assertions: ```php use Quittio\Laravel\Testing\EInvoiceAssertions; (new EInvoiceAssertions)->assertValidEInvoice($pdf, 'xrechnung'); (new EInvoiceAssertions(base_path('tests/__snapshots__')))->assertXmlMatchesSnapshot($xml, 'order-42'); ``` Its constructor takes the snapshot directory (default `tests/__snapshots__/quittio` below the working directory). Its default snapshot name is `xml`, so pass a name per snapshot. ## Factory Most tests need an invoice. `InvoiceData::factory()` (or `Quittio\Core\Testing\InvoiceFactory::new()`) builds one in a single line. The test invoices are deterministic: they contain no random values, so XML snapshots stay stable. Every method returns a new factory. ```php use Quittio\Core\Data\InvoiceData; InvoiceData::factory()->make(); // one line, 19 % InvoiceData::factory()->reverseCharge()->withLines(5)->make(); InvoiceData::factory()->intraCommunity()->calculated(); InvoiceData::factory()->b2c()->currency('USD')->number('X-1')->make(); InvoiceData::factory()->creditNote()->state(fn ($builder) => $builder->buyerReference('04011000-12345-03'))->make(); ``` The base invoice is the one of the scenarios (`Scenarios::base()`): - number `RE-2026-0042`, issue date 2026-10-03, delivery date 2026-09-30, locale `de`; - seller Muster GmbH (`DE123456789`, Musterstadt), buyer Kunde AG (`DE987654321`), buyer reference `PO-4711`; - payment terms 14 days and a SEPA credit transfer. With the German country pack the automatic choice renders these invoices as ZUGFeRD, and with `b2c()` as plain PDF. `withLines(3)` gives net 140.00, VAT 26.60 and an amount due of 166.60. | Method | Effect | |---|---| | `withLines(int $count)` | Number of lines (at least 1). Line *i*: "Item *i*", quantity *i* pieces, net price 10 × *i*, VAT 19 % (or the category of the VAT mode) | | `reverseCharge()` | Buyer Client SARL (Paris, `FR12345678901`), lines in category `AE` (reverse charge) with `VATEX-EU-AE` | | `intraCommunity()` | Buyer Cliente S.r.l. (Rome, `IT12345678901`), lines in category `K` (intra-community supply) with `VATEX-EU-IC` | | `export()` | Buyer Customer Inc. (New York, no VAT identifier), lines in category `G` (export) with `VATEX-EU-G` | | `b2c()` | Consumer buyer Erika Mustermann (Berlin), no buyer reference | | `currency(string $currency)` | Invoice currency; other than EUR adds the VAT accounting currency EUR (rate 0.9 of 2026-10-02) and a credit transfer | | `number(string $number)` | Invoice number (default `RE-2026-0042`) | | `creditNote()` | Type code 381 with the preceding invoice RE-2026-0001 of 2026-09-01 | | `state(callable $state)` | Calls `$state(InvoiceBuilder $builder)` for free changes; several states run in order | | `builder(): InvoiceBuilder` | The prepared builder | | `make(): InvoiceData` | Invoice data, not calculated (as passed to `Quittio::make()`) | | `calculated(?TotalsCalculator $calculator = null): InvoiceData` | Invoice data with totals and VAT breakdown, calculated with `$calculator` (default `En16931Calculator`) | `VATEX-EU-…` are the codes of the VAT exemption reasons ([Exemption reasons in the VAT breakdown](building-invoices.md#exemption-reasons-in-the-vat-breakdown)). ## Scenarios `Quittio\Core\Testing\Scenarios` holds realistic sample invoices: the ones of the preview, the visual tests and the official validation runs. Use them when a test needs special content, e.g. 60 lines for page breaks or sub lines. They are country neutral: they use VAT categories directly, not the tax presets of a country pack. ```php laravel use Quittio\Core\Testing\Scenarios; use Quittio\Laravel\Facades\Quittio; $invoice = Scenarios::make('sub-lines')->number('T-1')->build(); $result = Quittio::make($invoice)->profile(Scenarios::profile('sub-lines'))->format('zugferd')->render(); ``` ```php plain use Quittio\Core\Testing\Scenarios; $invoice = Scenarios::make('sub-lines')->number('T-1')->build(); $result = $quittio->make($invoice)->profile(Scenarios::profile('sub-lines'))->format('zugferd')->render(); ``` Without Laravel, `$quittio` is the instance created in [Without Laravel](getting-started.md#without-laravel). `php artisan quittio:preview --scenario=simple` renders a scenario with your template ([quittio:preview](commands.md#quittiopreview)). | Method | Returns | |---|---| | `Scenarios::names(): array` | All scenario names | | `Scenarios::make(string $name): InvoiceBuilder` | The builder of a scenario; an unknown name throws an `InvalidArgumentException` | | `Scenarios::profile(string $name): string` | Best profile: `extended` for `sub-lines`, `peppol` for `peppol`, otherwise `en16931` | | `Scenarios::base(): InvoiceBuilder` | Seller, buyer, dates and payment of all scenarios, without lines | Each scenario also has a static method (`Scenarios::simple()`, `manyLines()`, `longTexts()`, `mixedVat()`, `reverseCharge()`, `intraEu()`, `export()`, `cancellation()`, `subLines()`, `foreignCurrency()`, `b2cGross()`, `allowances()`, `attachments()`, `peppol()`). | Name | Content | |---|---| | `simple` | Two lines (24 h web development, monthly hosting with a period), 19 %, 2 % cash discount within 7 days | | `many-lines` | 60 lines with item numbers, 7 % and 19 % (page breaks) | | `long-texts` | Long note and description, item attributes | | `mixed-vat` | 7 %, 19 % and zero rated lines, 10 % document discount | | `reverse-charge` | French buyer, reverse charge (`AE`) | | `intra-eu` | Italian buyer, intra-community supply (`K`), delivery address, country of origin, HS code | | `export` | US buyer, export (`G`) | | `cancellation` | Credit note ST-2026-0007 cancelling RE-2026-0042 | | `sub-lines` | Line with three sub lines, invoicee and delivery terms (profile EXTENDED) | | `foreign-currency` | USD invoice with the VAT accounting currency EUR | | `b2c-gross` | Consumer buyer, gross prices, 7 % and 19 % | | `allowances` | Line allowance and charge, document charge and allowance, price base quantity, list price with discount | | `attachments` | Embedded CSV time sheet and an external document reference | | `peppol` | Belgian buyer, Peppol endpoints (`0208`, `9930`), reverse charge | ## Official validators in CI By default, rendering and `assertValidEInvoice()` use Quittio's PHP rules and the XSD schemas (levels `php` and `xsd`). Two official validators check more ([Rules and validation](concepts.md#rules-and-validation)): - the KoSIT validator (level L5) with the official Schematron rules of EN 16931, XRechnung and Peppol; KoSIT is the German agency that publishes XRechnung; - veraPDF (level L6), which checks that a PDF is a valid PDF/A file. They need Java and veraPDF. Run them in a separate test group, so that your fast tests do not need them: ```php use Quittio\Core\Data\InvoiceData; use Quittio\Core\Validation\Drivers\KositArtifacts; use Quittio\Laravel\Facades\Quittio; function useOfficialValidators(): void { $root = storage_path('quittio/validators'); // php artisan quittio:schemas:download config()->set('quittio.validation.levels', ['php', 'xsd', 'kosit', 'verapdf']); config()->set('quittio.validation.drivers.kosit', [ 'mode' => 'cli', 'jar' => $root.'/validator.jar', 'scenarios' => $root.'/xrechnung/scenarios.xml', 'repository' => $root.'/xrechnung', 'configurations' => [['scenarios' => KositArtifacts::peppolScenarios(), 'repository' => $root]], 'timeout' => 120, ]); config()->set('quittio.validation.drivers.verapdf', ['mode' => 'docker', 'image' => 'verapdf/cli']); } it('produces valid ZUGFeRD and XRechnung', function () { useOfficialValidators(); $invoice = InvoiceData::factory()->state(fn ($b) => $b->buyerReference('04011000-12345-03'))->make(); $result = Quittio::make($invoice)->formats(['zugferd', 'xrechnung-cii'])->render(); $this->assertValidEInvoice($result->pdf(), 'en16931'); $this->assertValidEInvoice($result->as('xrechnung-cii')->xml(), 'xrechnung'); })->group('official'); ``` - `php artisan quittio:schemas:download` downloads the validator and prints the values for `jar`, `scenarios`, `repository` and `configurations`. - In mode `cli` every validation starts a JVM (Java virtual machine). For many documents, run the validator as a daemon instead: `mode` `daemon` with `QUITTIO_KOSIT_URL` ([KoSIT validator](validation.md#kosit-validator-l5)). - The download command also prints the start command of the daemon, with `-P 8081` for the default URL `http://127.0.0.1:8081`. The validator's own default port is 8080. - An unreachable validator fails the validation with `KOSIT-UNAVAILABLE`, unless `fail_on_unavailable` is `false`. A GitHub Actions job for this group: ```yaml official-validation: runs-on: ubuntu-latest steps: - uses: actions/checkout@v7 - uses: shivammathur/setup-php@v2 with: php: '8.4' extensions: dom, libxml, mbstring, xmlwriter, zlib, intl, gd, bcmath, zip - uses: actions/setup-java@v6 with: distribution: temurin java-version: '21' - uses: actions/cache@v6 with: path: storage/quittio/validators key: quittio-validators-${{ hashFiles('composer.lock') }} - run: composer install --no-interaction --no-progress - run: php artisan quittio:schemas:download # keeps existing files - run: docker pull verapdf/cli - run: vendor/bin/pest --group=official ``` Exclude the group from the fast test job with `--exclude-group=official`. To check a single file by hand: `php artisan quittio:validate invoice.pdf --profile=en16931 --kosit --verapdf` ([Artisan commands](commands.md#quittiovalidate)). ## Managed layer factories The [Managed layer](managed.md) is the optional package `quittio/managed`: it stores invoices in your database, numbers and archives them. It ships Eloquent factories for its models (namespace `Quittio\Managed\Database\Factories`). Tests need the published Managed migrations (`quittio:install --managed`, see [Installation](managed.md#installation)) and a refreshed database. ```php use Quittio\Core\Data\InvoiceData; use Quittio\Managed\Models\Invoice; use Quittio\Managed\Models\Issuer; $issuer = Issuer::factory()->default()->create(); $invoice = Invoice::factory()->for($issuer)->create()->issue('2026-10-05'); $other = Issuer::factory()->company('Andere AG', 'DE111111111')->create(['key' => 'tenant-b']); $draft = Invoice::factory()->for($issuer)->data(InvoiceData::factory()->reverseCharge()->make())->create(); ``` `Issuer::factory()` (`IssuerFactory`) creates issuer profiles, the companies that issue invoices: | State | Attributes | |---|---| | (definition) | Key `issuer-{10 random characters}`; seller Muster GmbH with a random German VAT identifier (`DE` + 9 digits), Hauptstraße 1, 12345 Musterstadt, contact Max Muster, e-mail and electronic address `rechnung@muster.de`; country `DE`, time zone `Europe/Berlin`, bank account `DE02120300000000202051` / `BYLADEM1001`, defaults `locale` `de` and `due_days` 14; not the default issuer. Every issuer is a company of its own and gets its own number space. | | `default()` | Key `default`, default issuer, seller VAT identifier `DE123456789` | | `company(string $name, string $vatId)` | Another company: own name and VAT identifier, Marktplatz 2, 54321 Anderstadt, electronic address `rechnung@{slug of the name}.de` | `Invoice::factory()` (`InvoiceFactory`) creates drafts: | State | Attributes | |---|---| | (definition) | Draft (`status` draft, `kind` invoice) with the data of `InvoiceData::factory()->withLines(2)->make()` (number empty, totals not yet calculated), for a new issuer (`Issuer::factory()`) | | `data(InvoiceData $data)` | The columns of your invoice data instead | Issuing takes the number from the issuer's sequence. The documents are rendered in a queued job after the transaction. In tests, use `Queue::fake()`, or set `quittio-managed.queue.render_sync` to render in the same request. See [Managed layer](managed.md) for the lifecycle and [Testing against MySQL and PostgreSQL](managed.md#testing-against-mysql-and-postgresql). <!-- Source: https://quittio.dev/docs/country-packs --> # Country packs A country pack holds everything in Quittio that differs between countries: VAT rates and exemption texts, national invoice rules and profiles, the formats a country prescribes, legal notices, letter layouts, numbering and retention periods, and the law on late payment. The core of Quittio stays country-neutral. Quittio ships a pack for Germany, and `quittio/quittio` installs it. Packs for [Austria](country-at.md), [Belgium](country-be.md), [Switzerland](country-ch.md) and [France](country-fr.md) are published as separate packages; their legal wording is not reviewed by a tax adviser yet ([Other countries](#other-countries)). Read this page when you invoice from Germany and need more than a standard invoice: an exemption or reverse charge, a small business invoice, XRechnung for a public buyer, a reminder with default interest or a letter layout after DIN 5008 (the German standard for business letters). Read it also when you want to support another country. If terms such as EN 16931, XRechnung, profile or `BR-DE` codes are new to you, read [E-invoicing basics](concepts.md) first. The page has two parts: | Part | For | Start with | |---|---|---| | **Using the German pack** | Everyone who invoices as a seller in Germany (most readers) | [Germany (`quittio/country-de`)](#germany-quittiocountry-de) | | **Writing a country pack** | Developers who add another country or change how a pack behaves | [How a pack is selected](#how-a-pack-is-selected), [Writing your own country pack](#writing-your-own-country-pack), [The `CountryPack` contract](#the-countrypack-contract) | The legal wording, references, rules and defaults of the German pack were reviewed in October 2026 and confirmed by a tax adviser; they reflect the law of that time. Quittio is no tax advice, and the issuer of an invoice remains responsible for it (see the legal review and the disclaimer in the README). ## Germany (`quittio/country-de`) The German pack implements German VAT law (the VAT Act UStG and its implementing ordinance UStDV), XRechnung and German business letter conventions. Its class is `Quittio\Country\DE\CountryDE` (code `DE`, translation namespace `quittio-de`). - **Installation.** Laravel discovers the pack automatically, so there is nothing to register. Without Laravel, pass `new CountryDE` to `Quittio::create()` (see [Registering packs](#registering-packs)). The builder macro `de()` leads to the German special cases (`Quittio\Country\DE\Builder\GermanInvoice`), e.g. `->de()->smallAmount()`; it is available as soon as Composer loads the package. Each method returns the builder, so the chain continues there. The macros of version 0.2 directly on the builder (`->smallAmount()`, `->selfBilled()` …) were removed in 1.0. `stubs/InvoiceBuilder.stub.php` describes `de()` for IDEs and PHPStan. - **When it applies.** The pack leads every invoice whose seller is in Germany (seller country code `DE`). It then checks the German rules, chooses the format and provides the defaults: the German locale (unless the invoice or the configuration sets one), A4 paper and the DIN 5008 form B layout. For an invoice from another country to a business in Germany, only its format rules apply, so that German public buyers receive XRechnung. Details are in [How a pack is selected](#how-a-pack-is-selected). - **Legal references.** This page writes German legal references in English form: "section 14 (4) no. 1 UStG" stands for "§ 14 Abs. 4 Nr. 1 UStG". Other laws cited are the Civil Code (BGB), the Fiscal Code (AO) and the VAT application decree (UStAE). Values that the pack stores or prints in German keep their German form. German terms such as Gutschrift, Kleinunternehmer or Leitweg-ID are explained on first use and in the [glossary](concepts.md#german-terms). Common tasks: | You want to | Read | |---|---| | Set the VAT rate or an exemption on a line | [Tax presets](#tax-presets) | | Invoice as a small business without VAT (Kleinunternehmer) | [Small businesses](#small-businesses) | | Invoice a business in another EU country | [Reverse charge, intra-community supplies and VAT identifiers](#reverse-charge-intra-community-supplies-and-vat-identifiers) | | Know which format Quittio picks (ZUGFeRD, XRechnung, PDF) | [Format choice](#format-choice) | | Invoice a German public authority | [Format choice](#format-choice), [XRechnung profiles](#xrechnung-profiles), [XRechnung rules](#xrechnung-rules) | | Issue an invoice of up to 250 € with fewer details | [Small amount invoices](#small-amount-invoices) | | Deduct advance payments in a final invoice | [Final invoices](#final-invoices-deductadvance) | | Issue a self-billed invoice (Gutschrift) | [Self-billing](#self-billing-gutschrift) | | Cancel or correct an invoice | [Cancellations and corrections](#cancellations-and-corrections) | | Send a reminder with default interest | [Dunning law](#dunning-law), [Default interest](#default-interest) | | Choose the letter layout | [DIN 5008 letter layouts](#din-5008-letter-layouts) | | Look up a validation code such as `DE-USTG-03` or `BR-DE-15` | [UStG rules](#ustg-rules), [XRechnung rules](#xrechnung-rules) | Complete invoices for these cases are on [Examples](examples.md#invoices-in-germany). ### Tax presets A tax preset is a ready-made VAT treatment for an invoice line. It sets the VAT category (BT-151) and the rate, and for exempt supplies also the exemption reason code (BT-121) and text (BT-120). Use a preset instead of a bare category and rate: the line then carries the wording German law requires, and the German rules recognise the case. Lines without `vat:` take the [default VAT](building-invoices.md#default-vat); in Laravel that is 19 % for a German seller and `VatPreset::SmallBusiness` for a small business. The categories are the codes of EN 16931: `S` standard rate, `Z` zero rated, `E` exempt, `AE` reverse charge, `K` intra-community supply, `G` export outside the EU, `O` not subject to VAT (see [Categories](building-invoices.md#categories)). `Quittio\Country\DE\Tax\VatPreset` is a string-backed enum that implements `TaxPreset`. Apply it per line: ```php laravel use Quittio\Core\Enums\UnitCode; use Quittio\Country\DE\Tax\VatPreset; use Quittio\Laravel\Facades\Quittio; $builder = Quittio::invoice() ->line('Web development', netPrice: '95.00', quantity: 24, unit: UnitCode::Hour, vat: VatPreset::Standard) // an exemption without its own case: legal reference and VATEX code; // the invoice prints "Steuerfrei nach § 4 Nr. 14 UStG" (exempt under section 4 no. 14 UStG) ->line('Medical treatment', netPrice: '90.00', unit: UnitCode::Piece, vat: VatPreset::exempt('§ 4 Nr. 14 UStG', 'VATEX-EU-132-1C')); ``` ```php plain use Quittio\Core\Enums\UnitCode; use Quittio\Country\DE\Tax\VatPreset; $builder = $quittio->invoice() ->line('Web development', netPrice: '95.00', quantity: 24, unit: UnitCode::Hour, vat: VatPreset::Standard) // an exemption without its own case: legal reference and VATEX code; // the invoice prints "Steuerfrei nach § 4 Nr. 14 UStG" (exempt under section 4 no. 14 UStG) ->line('Medical treatment', netPrice: '90.00', unit: UnitCode::Piece, vat: VatPreset::exempt('§ 4 Nr. 14 UStG', 'VATEX-EU-132-1C')); ``` In the plain PHP examples on this page, `$quittio` is the instance created in [Without Laravel](getting-started.md#without-laravel), with your company under `seller` in `Quittio::create()`: `$quittio->invoice()` adds it and its bank account, as `Quittio::invoice()` does from `config/quittio.php`. | Case | Key | Category | Rate | Code (BT-121) | Use | |---|---|---|---|---|---| | `Standard` | `de.standard` | `S` | 19 (of the supply date) | – | Standard rate | | `Reduced` | `de.reduced` | `S` | 7 (of the supply date) | – | Reduced rate | | `ZeroRatedPv` | `de.zero_rated_pv` | `Z` | 0 | – | 0 % rate for photovoltaic systems (section 12 (3) UStG). Category `Z` allows no exemption reason (BR-Z-10), so the preset adds the note "Steuersatz 0 % nach § 12 Abs. 3 UStG." (BT-22). Quittio does not check the conditions of the zero rate (operator, place of the system). | | `SmallBusiness` | `de.small_business` | `E` | 0 | – | Small business exemption (Kleinunternehmer, section 19 (1) UStG); see [Small businesses](#small-businesses) | | `ReverseChargeDomestic` | `de.reverse_charge_domestic` | `AE` | 0 | `VATEX-EU-AE` | Domestic reverse charge (section 13b UStG): the buyer in Germany owes the VAT | | `ReverseChargeEu` | `de.reverse_charge_eu` | `AE` | 0 | `VATEX-EU-AE` | Service to a business in another member state, which owes the VAT there. Both VAT identifiers are required (`DE-USTG-11`). Issue the invoice by the 15th of the following month (`DE-USTG-15`). | | `IntraCommunitySupply` | `de.intra_community_supply` | `K` | 0 | `VATEX-EU-IC` | VAT-exempt intra-community supply (section 4 no. 1b with section 6a UStG), also of new vehicles (`newVehicle()`). Not for small businesses, except new vehicles (`DE-USTG-14`). Issue the invoice by the 15th of the following month (`DE-USTG-15`). | | `TriangularTransaction` | `de.triangular_transaction` | `AE` | 0 | `VATEX-EU-AE` | Intra-community triangular transaction (section 25b UStG), in which the last customer owes the VAT; wording of section 14a (7) UStG, also as note (BT-22). Both VAT identifiers are required. | | `Export` | `de.export` | `G` | 0 | `VATEX-EU-G` | VAT-exempt export supply (section 4 no. 1a with section 6 UStG) | | `NotTaxableInGermany` | `de.not_taxable` | `O` | none | `VATEX-EU-O` | Supply not taxable in Germany (place of supply abroad). EN 16931 allows no VAT identifiers with category `O` (BR-O-02); the pack leaves them out when the seller's tax number is given ([Category O](#vat-identifiers-on-invoices-of-category-o)). | | `BusinessTransfer` | `de.business_transfer` | `O` | none | `VATEX-EU-O` | Transfer of a business as a whole (Geschäftsveräußerung im Ganzen, section 1 (1a) UStG), not subject to VAT. VAT identifiers as with `NotTaxableInGermany`. VAT shown on such an invoice would be owed under section 14c (1) UStG; category `O` cannot carry any. | | `MarginSecondHand` | `de.margin_second_hand` | `E` | 0 | `VATEX-EU-F` | Margin scheme, second-hand goods; wording of section 14a (6) UStG, also as note (BT-22) | | `MarginArt` | `de.margin_art` | `E` | 0 | `VATEX-EU-I` | Margin scheme, works of art; also as note (BT-22) | | `MarginAntiques` | `de.margin_antiques` | `E` | 0 | `VATEX-EU-J` | Margin scheme, collectors' items and antiques; also as note (BT-22) | | `TravelAgency` | `de.travel_agency` | `E` | 0 | `VATEX-EU-D` | Special scheme for travel agents; also as note (BT-22) | | `VatPreset::exempt(string $paragraph, $code = null)` | `de.exempt` | `E` | 0 | `$code` (enum, raw code or string) | Any other exemption, e.g. `§ 4 Nr. 14 UStG` | The codes in column BT-121 are VATEX codes: the standard codes for the reason of an exemption. `Standard` and `Reduced` take the rate that applied on the supply date of the line (`TaxTables::STANDARD_RATE`, `TaxTables::REDUCED_RATE`). The supply date is the end of the line period (BT-135), its start, the VAT point date (BT-7), the delivery date (BT-72), the end of the invoicing period (BT-74) or the issue date, in this order (`Quittio\Core\Tax\SupplyDate`). A delivery in August 2020 gets 16 % and 5 %, a correction of it issued in 2021 as well: ```php use Quittio\Core\Builder\InvoiceBuilder; use Quittio\Country\DE\Tax\VatPreset; InvoiceBuilder::make() ->issueDate('2021-01-20') ->deliveryDate('2020-08-15') ->line('Desk', netPrice: '400.00', vat: VatPreset::Standard); // 16 % ``` `VatPreset::Standard->rate()` returns the rate of today. The plausibility rule `DE-VAT-RATE` warns when a line of category `S` within the German VAT territory has a rate that applied neither as standard nor as reduced rate on its supply date. It cannot tell whether the right one of the two was chosen: 19 % on restaurant meals, which are reduced again since 1 January 2026 (section 12 (2) no. 15 UStG, not for drinks), passes unnoticed. Average rates of agriculture and forestry (section 24 UStG) are a legitimate exception; switch the rule off for them with `validation.rules.disabled` ([Switching rules off](validation.md#switching-rules-off-and-changing-their-severity)). Up to version 0.2 the presets were called `Standard19` (`de.standard_19`) and `Reduced7` (`de.reduced_7`). The cases were removed in 1.0, their keys stay readable: `taxPresets()->get('de.standard_19')`, `quittio.defaults.vat` and `VatPreset::fromKey('de.standard_19')` find `Standard`, and lines of stored invoices keep their key (`VatPreset::LEGACY_STANDARD_KEY`, `LEGACY_REDUCED_KEY`). `Standard`, `Reduced` and `ZeroRatedPv` carry no text, because EN 16931 forbids an exemption reason for these categories (BR-S-10, BR-Z-10). The other presets print an exemption reason (BT-120) in German or English, from `resources/lang/{de,en}/tax.php`: | Key | German | English | |---|---|---| | `de.small_business` | Steuerfreie Leistung nach § 19 Abs. 1 UStG (Steuerbefreiung für Kleinunternehmer). | VAT-exempt supply under section 19 (1) UStG (small business exemption). | | `de.reverse_charge_domestic` | Steuerschuldnerschaft des Leistungsempfängers (§ 13b UStG) | Reverse charge, the recipient is liable for VAT (section 13b UStG) | | `de.reverse_charge_eu` | Steuerschuldnerschaft des Leistungsempfängers | Reverse charge, the recipient is liable for VAT | | `de.intra_community_supply` | Steuerfreie innergemeinschaftliche Lieferung (§ 4 Nr. 1b i. V. m. § 6a UStG) | VAT-exempt intra-Community supply (section 4 no. 1b in conjunction with section 6a UStG) | | `de.triangular_transaction` | Innergemeinschaftliches Dreiecksgeschäft nach § 25b UStG; Steuerschuldnerschaft des letzten Abnehmers | Intra-Community triangular transaction (section 25b UStG); the last customer is liable for the VAT | | `de.export` | Steuerfreie Ausfuhrlieferung (§ 4 Nr. 1a i. V. m. § 6 UStG) | VAT-exempt export supply (section 4 no. 1a in conjunction with section 6 UStG) | | `de.not_taxable` | Nicht im Inland steuerbare Leistung (Leistungsort im Ausland) | Service not taxable in Germany (place of supply abroad) | | `de.business_transfer` | Nicht steuerbare Geschäftsveräußerung im Ganzen (§ 1 Abs. 1a UStG). | Transfer of a business as a whole, not subject to VAT (section 1 (1a) UStG). | | `de.margin_second_hand` | Gebrauchtgegenstände/Sonderregelung | Second-hand goods/special arrangements | | `de.margin_art` | Kunstgegenstände/Sonderregelung | Works of art/special arrangements | | `de.margin_antiques` | Sammlungsstücke und Antiquitäten/Sonderregelung | Collectors’ items and antiques/special arrangements | | `de.travel_agency` | Sonderregelung für Reisebüros | Special arrangements for travel agents | | `de.exempt` | Steuerfrei nach :paragraph | Exempt from VAT according to :paragraph | The English texts follow the terms of Directive 2006/112/EC ("exempt", "intra-Community supply", "Reverse charge"). The [legal texts](#legal-texts) of the same notices use the same wording. How presets behave: - **Language.** The text is taken in the invoice locale (`->locale()` on the builder) when the line is built. The enum presets and `VatPreset::exempt()` (a `Quittio\Country\DE\Tax\CustomVatPreset`) use German when the invoice has no locale. Other locales without a text fall back to English. - **Preset key.** The key stays on the line (`$line->vat->presetKey`). `DE-USTG-09`, `DE-USTG-11`, `DE-USTG-14`, `DE-USTG-15` and the small business detection rely on it. - **VAT breakdown.** Category, rate, code and text flow into the VAT breakdown (BG-23). When lines of one category and rate have different texts, the texts are joined in BT-120. The code (BT-121) is kept only when all codes agree; otherwise Quittio warns with `QUITTIO-EXEMPTION-CONFLICT`. - **Invoice notes.** The mapping table of KoSIT and FeRD (recommended by the BMF letter of 15 October 2026) puts the statements of section 14a (6) and (7) UStG into the invoice note (BG-1). The margin scheme, travel agency and triangular presets therefore add their text once as note (BT-22, subject `REG`) as well, and `ZeroRatedPv` its reference to section 12 (3) UStG. A note with the same text is not added twice. Presets of other packs can do the same by implementing `Quittio\Core\Tax\StatesInvoiceNote`. - **PDF.** The PDF lists the BT-120 texts of all categories other than the standard rate in its legal notes (`legalNotes`), together with the regulatory notes and without duplicates. Margin scheme and travel agency rows show no VAT amount and their lines no rate (section 14a (6) UStG), recognised by the code of the line. - **Margin scheme next to an exemption.** EN 16931 allows one VAT group of category `E` only (BR-E-01). A margin scheme line and a line exempt under section 4 UStG therefore share it in the XML, with both texts in BT-120 and no code in BT-121 (`QUITTIO-EXEMPTION-CONFLICT`). The PDF shows the two parts in rows of their own, "Sonderregelung, kein gesonderter Steuerausweis: 500,00 €" and "Umsatzsteuerfrei (Steuerbefreit) auf 90,00 €", which add up to the group in the XML. With a document level allowance or charge of category `E` the parts cannot be told apart; then one row reads "Steuerfrei bzw. Sonderregelung, kein gesonderter Steuerausweis: 590,00 €" (label `vat_row_exempt_special_scheme`). Either way no "0 %" appears next to the margin scheme. - **Allowances and charges.** Document level allowances and charges take a category and a rate, not a preset: `->charge(VatCategory::StandardRate, '19', amount: '10.00', reason: 'Shipping')`. - **Lookup by key**, e.g. from a database column: `VatPreset::fromKey('de.standard')` (null for keys of other packs; it also knows the keys of 0.2, which `VatPreset::from()` does not), `(new CountryDE)->taxPresets()->get('de.standard')` or, across all installed packs, `$quittio->countries()->taxPreset('de.standard')`. `de.exempt` is not part of the collection. ### Small businesses A small business (Kleinunternehmer, section 19 UStG) charges no VAT. Its invoices state the exemption instead. Three steps make an invoice a correct small business invoice: 1. **Mark the seller as a small business.** Set `quittio.seller.small_business = true` (applied by `Quittio::invoice()`), without Laravel `'small_business' => true` in `Quittio::create()` (applied by `$quittio->invoice()`), the Managed issuer setting `tax_settings.small_business`, or `->flag(Meta::FLAG_SMALL_BUSINESS)`. `Flags::SMALL_BUSINESS` is the same flag (`small_business`). With the flag, a standard rated line, allowance or charge is an error (`DE-USTG-09`). The flag does not set presets or texts. 2. **Use `VatPreset::SmallBusiness` on every line.** Lines without `->vat()` get it automatically when the invoice has the small business flag and the default VAT comes from the country pack (`CountryDefaultVat`; in Laravel always, see [Default VAT](building-invoices.md#default-vat)). The preset's text (BT-120) appears in the PDF. 3. **Give a seller identifier if you have no VAT identifier.** Without a VAT identifier, EN 16931 needs a seller identifier (BT-29) or a legal registration (BT-30) (rule BR-CO-26). In Laravel set `quittio.seller.identifiers` or `legal_registration` (see [Configuration](configuration.md)), without Laravel `->identifier()` or `->legalRegistration()` on the seller's `Party::make()` in `Quittio::create()`. ```php laravel use Quittio\Core\Enums\UnitCode; use Quittio\Laravel\Facades\Quittio; $builder = Quittio::invoice() // quittio.seller.small_business = true ->line('Consulting', netPrice: '80.00', unit: UnitCode::Hour); // VatPreset::SmallBusiness by default ``` ```php plain use Quittio\Core\Enums\UnitCode; $builder = $quittio->invoice() // 'small_business' => true in Quittio::create() ->line('Consulting', netPrice: '80.00', unit: UnitCode::Hour); // VatPreset::SmallBusiness by default ``` What the pack checks: - An invoice with the small business flag, or with a line that uses the preset, is a small business invoice under section 34a UStDV. It needs no service date (`DE-USTG-03`), and the PDF is not checked for one. The tax number or VAT identifier is still required (`DE-USTG-02`). - A small business needs no VAT identifier of its own for reverse charge services in another member state (`DE-USTG-11`; section 19 (1) sentence 2 UStG). The buyer's VAT identifier is still required. - A small business that takes part in the cross-border small business scheme may state its small business identification number (Kleinunternehmer-Identifikationsnummer, suffix `EX`) instead of the tax number (section 34a sentence 1 no. 2 UStDV). It is no VAT identifier and belongs to the tax number (BT-32): `->de()->smallBusinessId('DE123456789EX')` sets it there and sets the small business flag. `DE-TAX-NUMBER` accepts it. In a VAT identifier field (BT-31) it gets the info `QUITTIO-SME-ID` instead of a format warning. - A small business cannot use the exemption for intra-community supplies (category `K`; `DE-USTG-14`, section 19 (1) sentence 2 UStG). The only exception is the intra-community supply of a new vehicle (`->de()->newVehicle()`, section 19 (6) sentence 1 UStG). A complete invoice is in [Examples: Small business](examples.md#small-business). ### Reverse charge, intra-community supplies and VAT identifiers With reverse charge (German: Steuerschuldnerschaft des Leistungsempfängers), the buyer owes the VAT instead of the seller. The invoice shows no VAT and must say why. An intra-community supply (innergemeinschaftliche Lieferung) is a VAT-exempt delivery of goods to a business in another EU member state. Use the presets `ReverseChargeDomestic`, `ReverseChargeEu`, `TriangularTransaction` and `IntraCommunitySupply` for these cases ([Tax presets](#tax-presets)). The pack then checks: - **Wording.** Reverse charge rows (category `AE`) must name "Steuerschuldnerschaft des Leistungsempfängers" (`DE-USTG-06`, error; the buyer owes the VAT all the same). The texts of the reverse charge presets are accepted in every locale the pack ships, so English invoices with the presets pass as well. Your own texts must contain "Steuerschuldnerschaft". - **VAT identifiers.** Reverse charge in another member state and triangular transactions need the VAT identifiers of seller and buyer (`DE-USTG-11`). The rule does not apply to `ReverseChargeDomestic` (section 13b UStG), and a small business needs none of its own (section 19 (1) sentence 2 UStG). - **Deadline.** Invoices for intra-community supplies and for services in another member state (`ReverseChargeEu`) must be issued by the 15th of the month following the supply (`DE-USTG-15`, warning; section 14a (1) sentence 2 and (3) sentence 1 UStG). This includes final invoices: advance payments trigger no VAT on intra-community supplies, so the invoice for the supply is the one with the deadline. - **PDF.** The PDF must show the reverse charge or exemption note and the VAT identifiers (see [Mandatory PDF output](#mandatory-pdf-output)). - **Tax representative.** A tax representative of the seller (BG-11, `->taxRepresentative($name, $vatId, $address)`) satisfies `DE-USTG-02` and `BR-DE-16`. Its VAT identifier satisfies `DE-USTG-11` and the mandatory output. - **Number formats.** The tax number (Steuernummer, BT-32) of a seller in Germany is checked for format and check digit (`DE-TAX-NUMBER`, see [Tax number](#tax-number)). VAT identifiers are checked by the core plausibility rules: `QUITTIO-VATID-FORMAT` (for `DE` nine digits) and optionally `QUITTIO-VIES`, an online check against the EU's VIES service. The same rules warn about category `K` with a domestic or non-EU destination, and about `G` within the EU (see [Validation](validation.md#plausibility-l7)). Complete invoices are in [Examples: EU business: services](examples.md#eu-business-services), [EU business: goods](examples.md#eu-business-goods) and [Export](examples.md#export). ### Format choice Without `->format()`, Quittio chooses the format for each invoice ([Automatic choice](formats.md#automatic-choice)). The German pack adds only the cases in which German law prescribes a format. `Quittio\Country\DE\Formats\GermanFormatRule` returns a choice for these cases and null (no opinion) otherwise: | Condition | Format | Profile | |---|---|---| | The buyer reference (BT-10) is a Leitweg-ID with valid check digits, or the buyer's electronic address (BT-49) uses scheme `0204` (`GermanFormatRule::LEITWEG_SCHEME`) | `xrechnung-cii` | `xrechnung` | | A small amount invoice whose simplifications apply (`UstgRules::isSmallAmountInvoice()`), with seller and buyer in the German Inland (domestic territory under section 1 (2) UStG, i.e. without Büsingen and Heligoland; an address without country code counts as domestic) | `pdf` | – | | otherwise | – (null) | – | A Leitweg-ID is the routing ID of a German public buyer, such as an authority or a municipality. The buyer names it in the order, and it goes into the buyer reference (BT-10). Its last two digits are check digits. ```php laravel use Quittio\Core\Builder\Party; use Quittio\Laravel\Facades\Quittio; $builder = Quittio::invoice() ->buyerReference('04011000-12345-03') // a Leitweg-ID: XRechnung ->buyer(Party::make('Stadt Beispielstadt') ->electronicAddress('04011000-12345-03', '0204')); // or the same ID as electronic address (scheme 0204) ``` ```php plain use Quittio\Core\Builder\Party; $builder = $quittio->invoice() ->buyerReference('04011000-12345-03') // a Leitweg-ID: XRechnung ->buyer(Party::make('Stadt Beispielstadt') ->electronicAddress('04011000-12345-03', '0204')); // or the same ID as electronic address (scheme 0204) ``` - Order numbers shaped like a Leitweg-ID (e.g. `4711-01`) do not switch to XRechnung. A Leitweg-ID with a typo does not either; validation reports it as `DE-LEITWEG-ID-SUSPECT` (info, see [Leitweg-ID](#leitweg-id)). Correct it, set the `0204` endpoint as well, or choose the format explicitly (`->format('xrechnung-ubl')`). - An explicit `->format()` or a configured `quittio.defaults.format` always wins. Everything else follows the [general order of the resolver](formats.md#automatic-choice): - **Domestic business invoices:** the Peppol lookup of the resolver, if one is configured, then `zugferd` with the configured profile (`en16931` by default; EXTENDED when EXTENDED features are used). - **Consumers:** `pdf`. - **Cross-border invoices:** the e-invoicing obligation of section 14 (2) UStG covers only supplies between businesses established in Germany. Sellers outside the EU invoicing a German business get `pdf` from the resolver, sellers in other member states `zugferd`. Buyers in Büsingen or Heligoland are outside the EU VAT territory and get `pdf`. - **German public buyers** receive XRechnung whatever the seller's country: for cross-border invoices to a buyer in Germany, the rule runs as the rule of the buyer's pack. A complete invoice to a public buyer is in [Examples: Public sector](examples.md#public-sector). #### E-invoice obligation When an explicit format or profile produces no e-invoice, the German rules check whether one was required (section 14 (1) and (2), section 27 (38) UStG). A run produces an e-invoice when one of its formats writes XML of an EN 16931 profile; MINIMUM, BASIC WL and a plain `pdf` do not. `xrechnung-cii` with `pdf` in one run is an e-invoice with a readable copy. Drafts and previews (watermark) are not checked. The obligation applies when seller and buyer are in the German Inland and the buyer is a business. It does not apply to: - consumers (`->consumer()`); - supplies exempt only under section 4 no. 8 to 29 UStG, told by the legal reference ("§ 4 Nr. 14 UStG") or a VATEX code of Article 132 or 135; - small amount invoices up to 250 EUR gross (section 33 sentence 4 UStDV), with or without `->de()->smallAmount()`; - small businesses (section 34a sentence 4 UStDV); - tickets (section 34 UStDV, `->de()->ticket()`, flag `de.ticket`); - cancellations and corrections of earlier invoices (section 14.11 (1) sentence 9 UStAE). The supply date decides (`UstgRules::supplyDate()`, otherwise the issue date); for a prepayment invoice the issue date (BMF letter of 15 October 2026, marginal no. 2): | Supply | Other invoice (PDF, MINIMUM, BASIC WL) | |---|---| | before 2025 | no finding | | 2025 and 2026 | allowed if issued by 31 December 2026: warning `DE-EINVOICE-02` (a PDF needs the buyer's consent); issued later: error `DE-EINVOICE-01` | | 2027 | prior-year turnover above 800,000 EUR: error `DE-EINVOICE-01`. Otherwise allowed if issued by 31 December 2027: warning `DE-EINVOICE-02`; later: error | | from 2028 | error `DE-EINVOICE-01` | Set the turnover with `quittio.countries.de.prior_year_turnover_above_800k` (core: `Quittio::create(['countries' => ['de' => ['prior_year_turnover_above_800k' => true]]], …)`); the default is `false`. Both findings belong to the BMF error class "Formatfehler" (format error, marginal no. 6a). An other invoice instead of a required e-invoice is no administrative offence (marginal no. 28), but it is no proper invoice, and the buyer may lose the input tax deduction. #### Mapping table of KoSIT and FeRD Which mandatory detail of the UStG goes into which field of an e-invoice is set out in the mapping table of KoSIT and FeRD (Empfehlungen zu Pflichtangaben in einer E-Rechnung, as of 25 July 2025), which the BMF letter of 15 October 2026 recommends (marginal no. 8 f.). The pack follows it: exemption and reverse charge texts in BT-120 with the code in BT-121, the statements of section 14a (6) and (7) UStG also as note, the retention notice and "Gutschrift" as note, vehicle details as item attributes (BG-32), the date of receipt of an advance payment in BT-7, a service month as invoicing period (BG-14). Details such as time sheets may go into an embedded attachment, the type, quantity and kind of the service must be in the structured part (marginal no. 10 to 12). ### XRechnung profiles XRechnung is the German e-invoice standard for public buyers: EN 16931 with additional German rules, as an XML file in the CII or UBL syntax (see [Formats](concepts.md#formats)). The pack registers three profiles for it. XRechnung 3.0 is the one you normally use. The extension allows data that XRechnung 3.0 does not, such as sub lines. XRechnung CVD is XRechnung 3.0 for the procurement of road vehicles under the Clean Vehicles Directive (CVD, Directive (EU) 2019/1161). How Quittio writes XRechnung files is described in [Formats: XRechnung](formats.md#xrechnung). | | `XRechnung30` | `XRechnung30Extension` | `XRechnung30Cvd` | |---|---|---|---| | Key, name | `xrechnung`, XRechnung 3.0 | `xrechnung-extension`, XRechnung 3.0 Extension | `xrechnung-cvd`, XRechnung 3.0 CVD | | Specification identifier (BT-24), which names the profile in the XML | `urn:cen.eu:en16931:2017#compliant#urn:xeinkauf.de:kosit:xrechnung_3.0` | `urn:cen.eu:en16931:2017#compliant#urn:xeinkauf.de:kosit:xrechnung_3.0#conformant#urn:xeinkauf.de:kosit:extension:xrechnung_3.0` | `urn:cen.eu:en16931:2017#compliant#urn:xeinkauf.de:kosit:xrechnung_3.0#compliant#urn:xeinkauf.de:kosit:xrechnung:cvd_0.9` | | Level, syntaxes | EN 16931; CII and UBL | as XRechnung 3.0; sub lines only in UBL | as XRechnung 3.0 | | Default business process (BT-23) | `urn:fdc:peppol.eu:2017:poacc:billing:01:1.0` | same | same | | Additionally required | buyer reference (BT-10), seller electronic address (BT-34), buyer electronic address (BT-49), seller contact (BG-6), payment instructions (BG-16) | same | as XRechnung 3.0, plus contract reference (BT-12), tender or lot reference (BT-17) and at least one vehicle line (`BR-DE-CVD-…`) | | Embedded in a PDF | `xrechnung.xml`, XMP conformance level `XRECHNUNG`, `fx:Version` `3.0` | same | same | | Extras | VAT rate written in every breakdown, 0 for category `O` (BR-DE-14); cash discounts as `#SKONTO#` lines in the payment terms (BT-20); the [XRechnung rules](#xrechnung-rules) | sub lines, third party payments (BG-DEX-09, UBL invoices only), identifier schemes `XR01` to `XR03` in the ICD and EAS code lists | the item classification scheme `CVD` (BT-158-1) in the UNTDID 7143 code list; the [CVD rules](#xrechnung-cvd) | The profiles exist only when the pack is registered. Without it, the formats `xrechnung-cii` and `xrechnung-ubl` cannot be rendered, and incoming XRechnung files are reported as an unknown profile (`QUITTIO-READER-UNKNOWN-PROFILE`). ```php laravel use Quittio\Laravel\Facades\Quittio; Quittio::make($invoice)->format('xrechnung-ubl')->render(); // XRechnung 3.0, UBL Quittio::make($invoice)->format('xrechnung-ubl')->profile('xrechnung-extension')->render(); // extension Quittio::make($invoice)->format('xrechnung-cii')->profile('xrechnung-cvd')->render(); // Clean Vehicles Directive Quittio::make($invoice)->format('zugferd')->profile('xrechnung')->render(); // PDF/A-3 with xrechnung.xml ``` ```php plain $quittio->make($invoice)->format('xrechnung-ubl')->render(); // XRechnung 3.0, UBL $quittio->make($invoice)->format('xrechnung-ubl')->profile('xrechnung-extension')->render(); // extension $quittio->make($invoice)->format('xrechnung-cii')->profile('xrechnung-cvd')->render(); // Clean Vehicles Directive $quittio->make($invoice)->format('zugferd')->profile('xrechnung')->render(); // PDF/A-3 with xrechnung.xml ``` The automatic choice always uses `xrechnung`, also when the invoice carries extension data: the specification identifier never switches by itself. Choose `xrechnung-extension` explicitly for extension data. With `xrechnung`, third party payments fail with `QUITTIO-PROFILE-XRECHNUNG-EXTENSION-ONLY`. The same holds for `xrechnung-cvd`: request it when the buyer asks for an XRechnung CVD. #### XRechnung CVD A public buyer that procures road vehicles reports them under the Clean Vehicles Directive. The invoice then names the contract and the tender or lot, and every vehicle line carries the vehicle category as item classification with the scheme `CVD` (BT-158, `M1`, `M2`, `M3`, `N1`, `N2` or `N3`) and the vehicle type as item attribute `cva` (BT-160, BT-161: `clean`, `zero-emission` or `other`): ```php laravel use Quittio\Core\Enums\UnitCode; use Quittio\Country\DE\Tax\VatPreset; use Quittio\Laravel\Facades\Quittio; $invoice = Quittio::invoice() ->buyerReference('04011000-12345-03') ->contractReference('V-2026-0017') // BT-12 ->tenderReference('LOS-3') // BT-17 ->line(fn ($line) => $line->name('Elektro-Kleinbus')->quantity(1)->netPrice('68000.00')->vat(VatPreset::Standard) ->classification('M2', 'CVD') // vehicle category (BT-158) ->attribute('cva', 'zero-emission')) // vehicle type (BT-160, BT-161) ->line(fn ($line) => $line->name('Einweisung')->quantity(2, UnitCode::Hour)->netPrice('95.00')->vat(VatPreset::Standard)); // … seller, buyer, payment as for every XRechnung Quittio::make($invoice)->format('xrechnung-cii')->profile('xrechnung-cvd')->render(); ``` ```php plain use Quittio\Core\Enums\UnitCode; use Quittio\Country\DE\Tax\VatPreset; $invoice = $quittio->invoice() ->buyerReference('04011000-12345-03') ->contractReference('V-2026-0017') // BT-12 ->tenderReference('LOS-3') // BT-17 ->line(fn ($line) => $line->name('Elektro-Kleinbus')->quantity(1)->netPrice('68000.00')->vat(VatPreset::Standard) ->classification('M2', 'CVD') // vehicle category (BT-158) ->attribute('cva', 'zero-emission')) // vehicle type (BT-160, BT-161) ->line(fn ($line) => $line->name('Einweisung')->quantity(2, UnitCode::Hour)->netPrice('95.00')->vat(VatPreset::Standard)); // … seller, buyer, payment as for every XRechnung $quittio->make($invoice)->format('xrechnung-cii')->profile('xrechnung-cvd')->render(); ``` The constants of `XRechnung30Cvd` hold the values (`CLASSIFICATION_SCHEME`, `VEHICLE_CATEGORIES`, `ATTRIBUTE`, `ATTRIBUTE_VALUES`). Lines without a vehicle, such as services, need neither. Credit notes are possible in both syntaxes. ### XRechnung rules `Quittio\Country\DE\Rules\XRechnungRules` (level L3) are the business rules of the XRechnung profiles, with codes `BR-DE-…`. They apply whenever the profile is `xrechnung`, `xrechnung-extension` or `xrechnung-cvd`, whatever the seller's country; the rules `BR-DE-CVD-…` only with the specification identifier of XRechnung CVD. The severity follows the flags of the official Schematron, the rule file of the official validator. Rules flagged `fatal` ("muss", must) are errors, rules flagged `warning` ("soll", should) are warnings, and `BR-DE-TMP-32` (flagged `information`) is an info. The KoSIT validator (the official XRechnung validator) remains authoritative (see [Validation](validation.md)). | Rule | Severity | Reported when | |---|---|---| | `BR-DE-1` | error | no payment instructions (BG-16) | | `BR-DE-2` | error | no seller contact (BG-6) | | `BR-DE-3`, `BR-DE-4` | error | seller city (BT-37) or postcode (BT-38) missing | | `BR-DE-5`, `BR-DE-6`, `BR-DE-7` | error | seller contact without name (BT-41), phone (BT-42) or e-mail (BT-43) | | `BR-DE-8`, `BR-DE-9` | error | buyer city (BT-52) or postcode (BT-53) missing | | `BR-DE-10`, `BR-DE-11` | error | a deliver-to address (BG-15) without city (BT-77) or postcode (BT-78) | | `BR-DE-15` | error | no buyer reference (BT-10); for public buyers this is the Leitweg-ID | | `BR-DE-16` | error | a category other than `O` is used and the seller has no VAT identifier (BT-31), tax number (BT-32) or tax representative (BG-11) | | `BR-DE-17` | warning | type code (BT-3) not one of 326, 380, 384, 389, 381, 875, 876, 877 | | `BR-DE-18` | error | a line of the payment terms text (BT-20) starts with `#` but does not match `#SKONTO#TAGE=n#PROZENT=n.nn#` (optionally `BASISBETRAG=n.nn#`) | | `BR-DE-19` | warning | SEPA credit transfer (58) with an invalid IBAN (BT-84) | | `BR-DE-20` | warning | SEPA direct debit (59) with an invalid debited IBAN (BT-91) | | `BR-DE-22` | error | attachment file names (BT-125-2) not unique | | `BR-DE-23-a`, `BR-DE-23-b` | error | credit transfer (30, 58) without credit transfer data (BG-17), or with card (BG-18) or direct debit (BG-19) data | | `BR-DE-24-a`, `BR-DE-24-b` | error | card payment (48, 54, 55) without card data (BG-18), or with BG-17 or BG-19 data | | `BR-DE-25-a`, `BR-DE-25-b` | error | direct debit (59) without direct debit data (BG-19), or with BG-17 or BG-18 data | | `BR-DE-26` | warning | corrected invoice (384) without preceding invoice reference (BG-3) | | `BR-DE-27` | warning | seller phone (BT-42) with fewer than three digits | | `BR-DE-28` | warning | seller e-mail (BT-43) without exactly one `@` surrounded by at least two characters | | `BR-DE-30`, `BR-DE-31` | error | direct debit (BG-19) without creditor identifier (BT-90) or debited account (BT-91) | | `BR-DE-TMP-32` | info (flag `information` in the Schematron) | no delivery date (BT-72), invoicing period (BG-14) or period on every line (BG-26) | | `BR-DEX-01` | not checked | guaranteed by `MimeType`: its codes are exactly those the extension allows; `BR-CL-24` accepts `MimeType::Xml` (application/xml) only in the extension | | `BR-DEX-02` | warning | extension, UBL: the net amount of a line (BT-131) with sub lines is not the sum of the net amounts of its direct sub lines; replaces `QUITTIO-SUBLINES` | | `BR-DEX-03` | not checked | guaranteed by the data model: every sub line has exactly one `LineVat`, which the UBL writer writes as one VAT information (BG-DEX-06) | | `BR-DEX-04` | error | extension: scheme of a seller (BT-29-1), buyer (BT-46-1) or payee (BT-60-1) identifier neither in ISO/IEC 6523 nor `XR01` to `XR03`; `SEPA` is accepted for seller and payee, except in CII; replaces `BR-CL-10` | | `BR-DEX-05` | error | extension: scheme of a legal registration identifier (BT-30-1, BT-47-1, BT-61-1) neither in ISO/IEC 6523 nor `XR01` to `XR03`; replaces `BR-CL-11` | | `BR-DEX-06` | error | extension: scheme of an item standard identifier (BT-157-1) neither in ISO/IEC 6523 nor `XR01` to `XR03`; replaces `BR-CL-21` | | `BR-DEX-07` | error | extension: scheme of an electronic address (BT-34-1, BT-49-1) neither in the EAS code list nor `XR01` to `XR03`; replaces `BR-CL-25` | | `BR-DEX-08` | error | extension: scheme of the delivery location identifier (BT-71-1) neither in ISO/IEC 6523 nor `XR01` to `XR03`; replaces `BR-CL-26` | | `BR-DEX-09` | error | extension, UBL: amount due (BT-115) is not BT-112 − BT-113 + BT-114 + the third party payment amounts (BT-DEX-002); replaces `BR-CO-16` | | `BR-DEX-10` | error | extension, UBL: a third party payment (BG-DEX-09) without type (BT-DEX-001) | | `BR-DEX-11` | not checked | guaranteed by the data model: `ThirdPartyPayment` requires an amount (BT-DEX-002), and the reader skips payments without one | | `BR-DEX-12` | error | extension, UBL: a third party payment (BG-DEX-09) without description (BT-DEX-003) | | `BR-DEX-13` | error | extension, UBL: a third party payment amount (BT-DEX-002) with more than two decimals; amounts created with `Amount::of()` always have two, and a `Money` with more cannot be written | | `BR-DEX-14` | error | extension, UBL: a third party payment amount (BT-DEX-002) in another currency than the invoice currency (BT-5) | | `BR-DEX-15` | error | sub lines in XRechnung CII (sub lines need the extension in UBL) | | `DE-XRECHNUNG-EXT-01` | error | a credit note in profile `xrechnung-extension` with syntax UBL; the official validator configuration has no scenario for it. Cancel with the strategy `negative_invoice` (type code 380, negative amounts). | | `BR-DE-CVD-01`, `BR-DE-CVD-02` | error | XRechnung CVD without contract reference (BT-12) or tender or lot reference (BT-17) | | `BR-DE-CVD-03` | error | XRechnung CVD without a line that has an item classification (BT-158) with scheme `CVD` and an item attribute `cva` (BT-160) | | `BR-DE-CVD-04` | error | an item classification with scheme `CVD` that is not `M1`, `M2`, `M3`, `N1`, `N2` or `N3` | | `BR-DE-CVD-05` | error | an item attribute `cva` whose value (BT-161) is not `clean`, `zero-emission` or `other` | | `BR-DE-CVD-06-a`, `BR-DE-CVD-06-b` | error | a line with a `CVD` classification that has not exactly one `cva` attribute, or a line with a `cva` attribute that has not exactly one `CVD` classification | The `BR-DEX-…` rules apply only to the profile `xrechnung-extension`; those marked UBL are skipped when the XML is written in CII, where the official Schematron does not have them. As in the official validator configuration, where the replaced rules are only an information, the extension replaces `BR-CL-10`, `-11`, `-21`, `-25` and `-26` with `BR-DEX-04` to `BR-DEX-08` and, in UBL, `BR-CO-16` with `BR-DEX-09` and `QUITTIO-SUBLINES` with `BR-DEX-02` (`XRechnung30Extension::replacedRules()`), so a violation is reported once, with the official code. `#SKONTO#` lines state a cash discount (Skonto) in a form software can read: `TAGE` is the number of days, `PROZENT` the percentage and `BASISBETRAG` the base amount. Quittio writes structured cash discounts itself (`#SKONTO#TAGE=7#PROZENT=2.00#`), so `BR-DE-18` only concerns lines you put into the payment terms text yourself. ### Small amount invoices German law allows a simplified invoice for small amounts (section 33 UStDV). `->de()->smallAmount()` marks an invoice of at most 250.00 EUR gross as such a small amount invoice. The gross total counts, including exempt or non-taxable parts (section 14.6 (4) UStAE). The limit of the supply date applies (`TaxTables::SMALL_AMOUNT_LIMIT`: 150.00 EUR from 2007, 250.00 EUR from 2017; the raise applies to supplies from 1 January 2017), or of the issue date if the invoice states no supply date. As long as no reverse charge (`AE`) or intra-community supply (`K`) is involved, it relaxes: - `DE-USTG-01`: the buyer's address is not required (the seller's still is); - `DE-USTG-02`: no tax number or VAT identifier is required; - `DE-USTG-03`: no service date is required; - the mandatory PDF output for the tax number and the service date; - the format: `pdf` instead of `zugferd` when seller and buyer are in the German Inland. A Leitweg-ID still leads to XRechnung (see [Format choice](#format-choice)). `DE-USTG-08` enforces the limit. `DE-USTG-12` excludes reverse charge and intra-community supplies (section 33 sentence 3 UStDV): such invoices need all mandatory information and are not rendered as plain PDF. Possible distance sales (goods sent to a consumer in another member state, section 3c UStG) keep the simplifications, with a warning. ### Builder macros `Quittio\Country\DE\Builder\GermanInvoiceMacros` adds methods for German special cases to `InvoiceBuilder`, and so to `Quittio::invoice()`: | Macro | Use it for | Writes into the invoice | |---|---|---| | `smallAmount()` | an invoice of up to 250 € gross ([Small amount invoices](#small-amount-invoices)) | flag `de.small_amount` | | `propertyRelatedService(string $locale = 'de')` | a service in connection with a property for a non-business buyer, who must keep the invoice for two years | flag `de.property_related_service` and the note `LegalTexts::PROPERTY_RETENTION` (subject `REG`) | | `newVehicle(string $locale = 'de')` | the intra-community supply of a new vehicle | flag `de.new_vehicle` and the note `LegalTexts::NEW_VEHICLE` (subject `REG`). The vehicle details are your line attributes (`DE-USTG-07`). The vehicle lines use `VatPreset::IntraCommunitySupply` (`DE-USTG-13`), also for small businesses (`DE-USTG-14`). | | `selfBilled(string $locale = 'de')` | a self-billed invoice ([Self-billing](#self-billing-gutschrift)) | type code 389 and the note `LegalTexts::SELF_BILLING` (subject `REG`) | | `deductAdvance(InvoiceData $advance, string $locale = 'de', $received = null, string $style = 'prepaid')` | a final invoice that deducts an advance invoice ([Final invoices](#final-invoices-deductadvance)) | preceding invoice (BG-3), prepaid amount (BT-113) and the note `LegalTexts::ADVANCE_DEDUCTION` (subject `REG`); with `style: 'remainder'` negative lines and `LegalTexts::ADVANCE_DEDUCTION_REMAINDER` instead of BT-113 | | `advance($expectedService, $receivedOn = null, string $locale = 'de')` (only as `->de()->advance()`) | a prepayment invoice ([Prepayment invoices](#prepayment-invoices)) | type code 386, the note `LegalTexts::PREPAYMENT` or `PREPAYMENT_MONTH` (or `SERVICE_DATE_OPEN` without a date), with `$receivedOn` the VAT point date BT-7 and the note `PREPAYMENT_RECEIVED` | | `consumerDefaultNotice(string $locale = 'de')` | the notice that a consumer is in default 30 days after the due date (section 286 (3) BGB) | the note `LegalTexts::CONSUMER_DEFAULT` (subject `PMT`) | | `discountAgreement(string $agreement, string $locale = 'de')` (only as `->de()->discountAgreement()`) | an agreed bonus, rebate or other reduction whose amount is not known yet (section 14 (4) no. 7 UStG); naming the agreement is enough (section 14.5 (19) UStAE) | the note `LegalTexts::DISCOUNT_AGREEMENT` (subject `REG`) | | `smallBusinessId(string $id)` (only as `->de()->smallBusinessId()`) | a small business that states its small business identification number (suffix `EX`) instead of the tax number ([Small businesses](#small-businesses)) | the number as the seller's tax number (BT-32) and the flag `small_business` | | `serviceDateOpen(string $locale = 'de')` (only as `->de()->serviceDateOpen()`) | a prepayment invoice (386) whose date of the service is not agreed yet (section 14.8 (4) sentence 5 UStAE) | flag `de.service_date_open` and the note `LegalTexts::SERVICE_DATE_OPEN` (subject `REG`); no `DE-USTG-03` warning | The notes and their texts are listed in [Legal texts](#legal-texts). Macros are invisible to IDEs and static analysis. The pack ships a stub with their signatures, `stubs/InvoiceBuilder.stub.php`; it is never loaded at runtime. Add it to PHPStan (`vendor/quittio/quittio/packages/country-de/stubs/…` with the complete package): ```yaml parameters: stubFiles: - vendor/quittio/country-de/stubs/InvoiceBuilder.stub.php ``` - The `$locale` parameter selects the language of the note. It is independent of the invoice locale. - A locale with a region uses the text of its language (`en_GB` → English). Locales without a text of the pack get the German text (`LegalTexts::text()`). - Notes with subject `REG` (regulatory information) are listed in the PDF's legal notes (`legalNotes`). Notes with subject `PMT` (payment information) appear with the other notes. #### Prepayment invoices A prepayment invoice (Anzahlungsrechnung, type code 386) must show that it invoices an advance payment, e.g. by the expected date or month of the service (section 14.8 (1) and (4) UStAE). `->de()->advance()` sets the type code and the note: ```php laravel use Quittio\Core\Enums\UnitCode; use Quittio\Laravel\Facades\Quittio; $advance = Quittio::invoice() ->de()->advance('2027-03') // "Anzahlungsrechnung. Die Leistung wird voraussichtlich im März 2027 erbracht." ->line('Website relaunch, advance payment', netPrice: '1000.00', unit: UnitCode::LumpSum); $paid = Quittio::invoice() ->de()->advance('2027-03-15', receivedOn: '2026-10-01') // "… am 15.03.2027 erbracht. Die Anzahlung wurde am 01.10.2026 vereinnahmt." ->line('Website relaunch, advance payment', netPrice: '1000.00', unit: UnitCode::LumpSum) ->prepaid('1190.00'); ``` ```php plain use Quittio\Core\Enums\UnitCode; $advance = $quittio->invoice() ->de()->advance('2027-03') // "Anzahlungsrechnung. Die Leistung wird voraussichtlich im März 2027 erbracht." ->line('Website relaunch, advance payment', netPrice: '1000.00', unit: UnitCode::LumpSum); $paid = $quittio->invoice() ->de()->advance('2027-03-15', receivedOn: '2026-10-01') // "… am 15.03.2027 erbracht. Die Anzahlung wurde am 01.10.2026 vereinnahmt." ->line('Website relaunch, advance payment', netPrice: '1000.00', unit: UnitCode::LumpSum) ->prepaid('1190.00'); ``` - `$expectedService` is a date or a month (`"2027-03"`). `null` states that the date is not agreed yet (`serviceDateOpen()`, section 14.8 (4) sentence 5 UStAE). Either way `DE-USTG-03` does not warn. - `$receivedOn` is the date a payment was already received. It is stated as VAT point date (BT-7), to which the mapping table of KoSIT and FeRD assigns the date of receipt, and in a note (section 14 (4) sentence 1 no. 6 UStG). A prepayment invoice with a prepaid amount but no BT-7 gets `DE-USTG-17`. - XRechnung warns about type code 386 (`BR-DE-17`): its list names 326 and 380 but not 386. The mapping table of KoSIT and FeRD prescribes 386 for prepayment invoices all the same, so the warning is to be accepted. - **Cancellation.** A prepayment invoice is cancelled, fully or partly, with `Quittio::cancellation()` like any invoice, e.g. for an advance payment refunded because the supply is not made (section 17 (2) no. 2 UStG). The cancellation (381, or 380 with `negative_invoice`) carries the flag `prepayment_correction` (`Meta::FLAG_PREPAYMENT_CORRECTION`) and refers to the prepayment invoice (BG-3): `DE-USTG-03` asks it for no date of the supply. A corrected invoice of a prepayment invoice (`Quittio::correction()`) carries the flag as well and is checked like the prepayment invoice. A price reduction (`Quittio::priceReduction()`) of a prepayment invoice is refused: a lower price is settled in the final invoice. #### Final invoices (`deductAdvance`) A final invoice (Schlussrechnung, section 14 (5) sentence 2 UStG) states the full service with its full VAT and deducts the advance payments received. `->de()->deductAdvance(InvoiceData $advance, string $locale = 'de', $received = null, string $style = GermanInvoice::PREPAID)` does this for one advance invoice: ```php laravel use Quittio\Core\Enums\UnitCode; use Quittio\Country\DE\Builder\GermanInvoice; use Quittio\Country\DE\Tax\VatPreset; use Quittio\Laravel\Facades\Quittio; $advance = $advanceResult->data(); // the rendered advance invoice, already calculated $final = Quittio::invoice() // number, dates, buyer, payment … ->line('Website', netPrice: '3000.00', unit: UnitCode::Piece, vat: VatPreset::Standard) ->de()->deductAdvance($advance, received: GermanInvoice::RECEIVED_IN_FULL); ``` ```php plain use Quittio\Core\Enums\UnitCode; use Quittio\Country\DE\Builder\GermanInvoice; use Quittio\Country\DE\Tax\VatPreset; $advance = $advanceResult->data(); // the rendered advance invoice, already calculated $final = $quittio->invoice() // number, dates, buyer, payment … ->line('Website', netPrice: '3000.00', unit: UnitCode::Piece, vat: VatPreset::Standard) ->de()->deductAdvance($advance, received: GermanInvoice::RECEIVED_IN_FULL); ``` The advance invoice must be calculated. The data of a rendered invoice (`$result->data()`) already is; calculate data you built yourself with `(new En16931Calculator)->calculate($advanceInvoice)` (`Quittio\Core\Calculation\En16931Calculator`). With an advance invoice RE-2026-0040 of 1,000.00 EUR net plus 19 % VAT, the final invoice shows a gross total of 3,570.00 EUR, VAT 570.00 EUR, prepaid 1,190.00 EUR and an amount due of 2,380.00 EUR, with the note: > Abzüglich Anzahlung gemäß Rechnung RE-2026-0040 vom 01.09.2026: Entgelt 1.000,00 € zzgl. 19 % Umsatzsteuer 190,00 € (§ 14 Abs. 5 Satz 2 UStG). With `->de()->deductAdvance($advance, 'en')` the note is in English: "Less advance payment according to invoice RE-2026-0040 of 01/09/2026: net 1,000.00 € plus 19% VAT 190.00 € (section 14 (5) sentence 2 UStG)." - **Checks.** The advance invoice must be calculated (`totals` set), have a positive gross total and be in the currency of the final invoice. Otherwise an `InvalidArgumentException` is thrown. Set `->currency()` before calling the macro. - **Accepted documents.** Only documents that can be advance invoices are accepted (`GermanInvoice::ADVANCE_TYPES`): type codes 380 (commercial invoice), 386 (prepayment invoice), 326 (partial invoice), 875 (partial construction invoice) and 389 (self-billed invoice). Credit notes, debit notes, corrected invoices (384), final invoices (876, 877) and cancellations by negative invoice are rejected. - **Amount received.** Only advance payments actually received are deducted (section 14 (5) sentence 2 UStG). Pass what you received as `received:`: `GermanInvoice::RECEIVED_IN_FULL` (or the full amount) deducts the advance invoice's gross total plus its cash rounding (BT-114). A smaller amount, e.g. `received: '595.00'` for half of the example, deducts that amount: it is distributed over the VAT rows of the advance invoice in proportion to their gross amounts, and the VAT is taken out of each part at its rate (section 14.8 (5) UStAE). The note then names these amounts. Zero or more than the advance invoice throws an `InvalidArgumentException`. - **Unconfirmed amount.** Without `received:` the advance invoice is deducted in full as before, but the flag `de.advance_receipt_unconfirmed` is set and `DE-USTG-20` warns. Deducting an advance that was not paid states too little VAT; not deducting one that was paid makes you owe its VAT twice (section 14.8 (10) UStAE). - **Unpaid advance invoices.** Do not deduct them. The advance invoice need not be cancelled (section 14.8 (2) UStAE); you may cancel it for clarity in your accounts. - **Remainder invoice.** `style: GermanInvoice::REMAINDER` adds instead a line "Abzüglich Anzahlung gemäß Rechnung … vom …" per VAT row with quantity −1 and the net amount received, and the note `LegalTexts::ADVANCE_DEDUCTION_REMAINDER` ("Restrechnung: Abgezogen ist die vereinnahmte Anzahlung gemäß Rechnung …"). The invoice then shows only the VAT of the remainder (section 14.8 (11) UStAE), which the buyer's system cannot deduct twice. The default `PREPAID` (BT-113 with the itemisation in BT-22) is the variant the BMF letter of 15 October 2026 (marginal no. 3) explicitly accepts until 30 June 2030. - **Itemisation.** Every VAT row of the advance invoice is itemised. Standard rated rows read "Entgelt … zzgl. … Umsatzsteuer …" ("net … plus … VAT …", `LegalTexts::ADVANCE_DEDUCTION_TAXED`), other rows "Entgelt … ohne Umsatzsteuer" ("net … without VAT", `LegalTexts::ADVANCE_DEDUCTION_UNTAXED`). Rows are separated by semicolons. - **Language.** The whole note is in one language: the language of `$locale` if the pack has it (`de`, `en`), otherwise German. Amounts and dates are formatted in `$locale` when the note is in its language (e.g. `de_AT`). Otherwise they are formatted in the language of the note: `fr` gives the German note with German formatting. - **Several advance invoices.** Call the macro once per advance invoice; the prepaid amounts add up. - **Self-billed advances.** An advance settled by self-billing (389) must be deducted as well. If the final invoice is no self-billed invoice, `DE-USTG-19` notes the change of the way of invoicing. - **Review in 2030.** The acceptance of BT-113 with the itemisation in BT-22 ends on 30 June 2030 (BMF letter of 15 October 2026, marginal no. 3); the default will be reviewed then. A complete example with the advance invoice is in [Examples: Advance payment and final invoice](examples.md#advance-payment-and-final-invoice). ### Self-billing (Gutschrift) In self-billing, the buyer issues the invoice for the seller's supply. German law requires the word "Gutschrift" on such an invoice (section 14 (4) no. 10 UStG). Quittio uses "Gutschrift" only for self-billing; commercial credit notes and cancellations carry other titles. - `->de()->selfBilled()` sets type code 389 and adds the note "Gutschrift" (English variant: "Gutschrift (self-billed invoice)"). - The PDF is titled "Gutschrift" in German and "Self-billed invoice (Gutschrift)" in English, and shows the buyer as issuer. - `DE-USTG-04` requires the label on every self-billed type code (389, 261, 527); in an e-invoice the type code is label enough, so there it is a warning. - The mandatory output requires the title and the "Gutschrift" note in the PDF. What Quittio cannot check, and you must make sure of: - **Prior agreement.** Self-billing must be agreed before the first self-billed invoice (section 14 (2) sentence 2 UStG), best in writing, e.g. in the framework contract with the supplier. Without the agreement the document is no invoice, and the issuer loses the input tax deduction. The agreement is not stated on the document, so Quittio does not ask for it. - **Objection.** The supplier may object to a self-billed invoice (section 14 (2) sentence 6 UStG). It then loses its effect as invoice, for the future only (BFH XI R 41/20), and the supplier issues an invoice of its own. An objection is no cancellation; do not issue a cancellation for it. - **Corrections and cancellations** of a self-billed invoice come from its issuer, the buyer (section 14.11 (2) sentence 2 UStAE). `Quittio::cancellation()` keeps the document self-billed (261, or 389 negative for XRechnung). A complete example is in [Examples: Self-billing](examples.md#self-billing). ### Cancellations and corrections `CountryDE::correctionPolicy()` sets how invoices of a German seller are cancelled and corrected (see [Building invoices: cancellations and corrections](building-invoices.md#cancellations-and-corrections)): - **Cancellation strategy `credit_note`:** a cancellation is a credit note (type code 381) with positive amounts. - **Correction strategy `cancel_and_reissue`:** the Managed layer corrects an invoice by cancelling it and issuing a new one. Both cancellation strategies are permitted in Germany. Change them with `quittio.corrections.cancellation_strategy` and `quittio-managed.correction.strategy`. For the XRechnung extension in UBL use `negative_invoice` (`DE-XRECHNUNG-EXT-01`). A self-billed invoice (389) with a Leitweg-ID (BT-10), i.e. sent as XRechnung, is cancelled by a negative self-billed invoice (389) instead of a self-billed credit note (261): XRechnung lists 261 not among its type codes and warns (`BR-DE-17`). Receiving portals of public buyers may treat that warning strictly. An explicit `$strategy` or `corrections.cancellation_strategy` still wins. ZUGFeRD keeps 261. A corrected invoice (384) should state that it corrects and replaces the original (`DE-USTG-18`); `Quittio::correction()` adds the note. A price reduction (`Quittio::priceReduction()`) is titled "Entgeltminderung". What a correction does for the parties (for your users' information, not checked by Quittio): - **Seller.** VAT shown too high (section 14c (1) UStG) is corrected in the period of the correction (section 17 (1) sentence 7 UStG), whichever way you correct. - **Buyer.** A correction, also by cancellation and new invoice, takes effect back to the original invoice if it had the minimum details of seller, buyer, supply, consideration and VAT and the correction refers to it specifically (BFH V R 26/15, XI R 10/17; BMF letter of 18 September 2020). Quittio refers by number and date (BG-3) and the note. - **Procedure.** A correction is no retroactive event under section 175 (1) sentence 1 no. 2 and section 233a (2a) AO (section 14 (4) sentence 4 UStG). - **Double invoices.** If an invoice was issued twice, cancel the second one: its VAT is owed under section 14c (1) UStG until it is corrected. The policy also sets the document titles: | Kind | German | English | |---|---|---| | `cancellation` | Stornorechnung | Cancellation invoice | | `cancellation_self_billed` | Storno-Gutschrift | Cancellation of the self-billed invoice (Storno-Gutschrift) | | `correction` | Rechnungskorrektur | Corrected invoice | | `price_reduction` | Entgeltminderung | Price reduction | | `self_billed` | Gutschrift | Self-billed invoice (Gutschrift) | - `cancellation` and `cancellation_self_billed` title the documents of `Quittio::cancellation()`. - `correction` titles a corrected invoice (384) of `Quittio::correction()` and of the Managed layer. - `price_reduction` titles the documents of `Quittio::priceReduction()`. - `self_billed` titles self-billed invoices (389, 261, 527) unless the presentation sets a title. Locales without a title of their own fall back to English ("Self-billed invoice (Gutschrift)"), which keeps the word "Gutschrift" required by section 14 (4) no. 10 UStG. ### Dunning law When a customer pays late, German law (section 288 BGB) gives the seller default interest (Verzugszinsen) and, from business debtors, a flat rate of 40 EUR. The pack provides these values and a calculator for the interest. Quittio's documents do not apply them by themselves: calculate the interest with [`DefaultInterest`](#default-interest) and pass the results to a payment reminder (see [Documents: payment reminders](documents.md#payment-reminders)). `CountryDE::dunningLaw()` returns these values: | Value | Germany | |---|---| | Interest for business debtors | base rate plus 9 percentage points | | Interest for consumers | base rate plus 5 percentage points | | Flat rate for business debtors | 40.00 EUR | | Day count | actual/actual (`null`): 365 days, 366 in a leap year | | Consumer default | 30 days after due date and receipt of the invoice, if the invoice points this out (added to invoices for consumers automatically, see below) | | Reference rate | "Basiszinssatz (§ 247 BGB)", the base rate of section 247 BGB | #### Default interest `Quittio\Country\DE\Dunning\DefaultInterest` calculates the default interest on an open amount: | Method | Result | |---|---| | `__construct(?BaseRateTable $rates = null, ?DunningLaw $law = null)` | Without a table, `BaseRates::table()` is used (shipped and registered rates). Without a law, `CountryDE::dunningLaw()` (points, flat rate and day count). | | `calculate(Money $amount, Date $from, Date $until, bool $consumer = false, string $locale = 'de'): list<InterestCharge>` | One charge per base rate period, from `$from` (first day with interest) to `$until` (exclusive). Rate = base rate + 9 points, or + 5 points with `$consumer`. Empty for a non-positive amount or when `$until` is not after `$from`. `InvalidArgumentException` for days the [base rate table](#base-rate-table) does not cover. | | `flatRate(string $currency = 'EUR'): ?Money` | The flat rate of 40.00 for business debtors (section 288 (5) BGB), once per claim | ```php laravel use Brick\Money\Money; use Quittio\Core\Support\Amount; use Quittio\Core\Support\Date; use Quittio\Country\DE\Dunning\DefaultInterest; use Quittio\Laravel\Facades\Quittio; $interest = new DefaultInterest; $reminder = Quittio::paymentReminder(1) // first reminder ("1. Mahnung"); seller and bank account from the config ->number('M-2026-0003') ->buyer($buyer) ->openItem('RE-2026-0042', '2026-06-01', '1190.00', dueDate: '2026-06-15'); // first day with interest: the day after the due date; 2026-10-04 is the first day without interest foreach ($interest->calculate(Money::of('1190.00', 'EUR'), Date::parse('2026-06-16'), Date::parse('2026-10-04')) as $charge) { $reminder->interest(Amount::format($charge->base), $charge->ratePercent, $charge->from, $charge->until, $charge->description, dayCount: $charge->dayCount); } $reminder->flatRate('RE-2026-0042'); // 40.00 EUR for this claim, "Pauschale für Beitreibungskosten (§ 288 Abs. 5 BGB), Forderung RE-2026-0042" ``` ```php plain use Brick\Money\Money; use Quittio\Core\Support\Amount; use Quittio\Core\Support\Date; use Quittio\Country\DE\Dunning\DefaultInterest; $interest = new DefaultInterest; $reminder = $quittio->paymentReminder(1) // first reminder ("1. Mahnung"); seller and bank account from Quittio::create() ->number('M-2026-0003') ->buyer($buyer) ->openItem('RE-2026-0042', '2026-06-01', '1190.00', dueDate: '2026-06-15'); // first day with interest: the day after the due date; 2026-10-04 is the first day without interest foreach ($interest->calculate(Money::of('1190.00', 'EUR'), Date::parse('2026-06-16'), Date::parse('2026-10-04')) as $charge) { $reminder->interest(Amount::format($charge->base), $charge->ratePercent, $charge->from, $charge->until, $charge->description, dayCount: $charge->dayCount); } $reminder->flatRate('RE-2026-0042'); // 40.00 EUR for this claim, "Pauschale für Beitreibungskosten (§ 288 Abs. 5 BGB), Forderung RE-2026-0042" ``` - **Descriptions.** They name the rate, the base rate, the points and the last day with interest. With the locale `de` (the default) a description reads "Verzugszinsen 10,27 % p. a. (Basiszinssatz 1,27 % + 9,00 Prozentpunkte) vom 16.06.2026 bis 30.06.2026". Any other locale gives "Default interest 10.27 % p.a. (base rate 1.27 % + 9.00 points) from 2026-06-16 to 2026-06-30". - **Day count.** The charges use the day count of the dunning law (`InterestCharge::$dayCount`). `CountryDE::dunningLaw()` counts actual/actual: the days of each calendar year are divided by its length, 366 in a leap year, as the statutory day count conventions do (annex to section 16 PAngV). No federal court has decided the question for section 288 BGB; the fixed basis of 365 days would overstate the interest of a leap year slightly. Pass the day count to `interest()` as above (`dayCount: $charge->dayCount`), or use `interestCharge()`. - **Periods.** A charge covers a whole period with the same base rate. Interest from 1 December 2025 to 28 February 2026 is one charge, although the table has an entry for 1 January 2026. - **Flat rate.** `DocumentBuilder::flatRate($claim)` adds it as a fee of kind `DunningFeeKind::FlatRate` for one claim (invoice or instalment). It is due for every late payment, also of instalments and of recurring payments under one contract (section 288 (5) sentence 2 BGB; CJEU C-370/21), only from businesses, and counts towards the costs of legal pursuit (sentence 3): reminder fees of your own are recovery costs and may be claimed beside it only in so far as they exceed 40 EUR (CJEU C-287/17, C-131/18). The builder rejects a second flat rate for the same claim in one reminder and a flat rate for a consumer; a flat rate together with reminder fees gets the notice `QUITTIO-DUNNING-FLAT-RATE-FEES` ([Documents: payment reminders](documents.md#payment-reminders)). Which claims already carried it in earlier reminders is up to your application (the Managed layer does not track it). A creditor who brings about the conditions of the flat rate abusively loses it (CJEU C-209/25). - **Reminder fees.** The reminder that puts the debtor in default is part of the creditor's own receivables management; its costs are not damages (BGH VIII ZR 138/23, marginal no. 77). Quittio has no default fee. Fee clauses towards consumers are subject to section 309 no. 5 BGB. - **No VAT.** Default interest, reminder costs and the flat rate are damages, not consideration (section 1.3 (6) UStAE). Interest agreed for a deferral of payment (e.g. in an instalment agreement) is consideration for a service of its own, possibly exempt under section 4 no. 8 (a) UStG; Quittio does not cover it. - **Consumers.** Without an agreed date, a debtor is in default only after a reminder, or 30 days after due date and receipt of the invoice; a consumer only if the invoice points this out (section 286 (3) BGB). A due date the seller sets on the invoice alone does not put the buyer in default (BGH VIII ZR 215/15). The pack therefore adds the notice to every invoice for a consumer (`CountryDE::complete()`, see below); `->de()->consumerDefaultNotice()` adds it explicitly. A complete reminder is in [Examples: Payment reminder](examples.md#payment-reminder). #### VAT identifiers on invoices of category O EN 16931 allows no VAT identifiers of seller (BT-31), buyer (BT-48) or tax representative (BT-63) on an invoice of supplies not subject to VAT (category `O`, rule BR-O-02), and such an invoice has no other VAT category (BR-O-11). In Laravel the seller's VAT identifier comes from the configuration, so every such invoice would fail. `CountryDE::complete()` therefore leaves out the VAT identifiers of seller and buyer when: - every line is of category `O` (`VatPreset::NotTaxableInGermany`, `BusinessTransfer` or your own), - the seller has a tax number (BT-32), which satisfies section 14 (4) sentence 1 no. 2 UStG instead, - and there is no tax representative: EN 16931 requires its VAT identifier (BR-56) and forbids it here, so such an invoice cannot be issued at all. The invoice gets the flag `de.vat_ids_omitted` and the info `DE-CATEGORY-O-01`. The rendered data (`$result->data()`), XML and PDF are without the VAT identifiers; the builder keeps them. Without a tax number or with a tax representative nothing changes: `BR-O-02` stays an error, and the info `DE-CATEGORY-O-02` names what is missing. Switch the completion off with `quittio.countries.de.omit_vat_ids_for_category_o = false`. #### Default notice for consumers `CountryDE` completes invoices before they are calculated and rendered (`Quittio\Core\Countries\Capabilities\CompletesInvoices`): an invoice for a consumer (`->consumer()` on the buyer) gets the note `LegalTexts::CONSUMER_DEFAULT` with subject `PMT`, "Sie kommen spätestens in Verzug, wenn Sie nicht innerhalb von 30 Tagen nach Fälligkeit und Zugang dieser Rechnung zahlen (§ 286 Abs. 3 BGB)." in the language of the invoice. Credit notes and invoices that already have such a note (a note containing "286") are left alone. The note is part of the rendered data (`$result->data()`), not of the builder. Switch it off with the setting `consumer_default_notice` of the pack: `quittio.countries.de.consumer_default_notice = false` in Laravel, `Quittio::create(['countries' => ['de' => ['consumer_default_notice' => false]]], …)` in the core. #### Base rate table The base rate (Basiszinssatz, section 247 BGB) changes on 1 January and 1 July. `Quittio\Country\DE\Dunning\BaseRateTable` holds the rates. Quittio ships these (`BaseRateTable::PUBLISHED`): | Valid from | Rate in % | |---|---| | 2023-01-01 | 1.62 | | 2023-07-01 | 3.12 | | 2024-01-01 | 3.62 | | 2024-07-01 | 3.37 | | 2025-01-01 | 2.27 | | 2025-07-01 | 1.27 | | 2026-01-01 | 1.27 | | 2026-07-01 | 1.52 | Rates after the last entry are unknown until they are published. Interest for days from 1 January 2027 is therefore rejected instead of silently using the old rate. There are three ways to add new rates without a new Quittio release: 1. **Laravel configuration.** Add the rate to `quittio.countries.de.base_rates` in `config/quittio/countries/de.php` (publish it with `php artisan vendor:publish --tag=quittio-de-config`; see [Configuration](configuration.md#country-pack-germany-quittiocountriesde)). Up to 0.3 this was `config/quittio-de.php`, which is no longer read since 1.0. ```php 'base_rates' => ['2027-01-01' => '1.77'], ``` 2. **Automatic update from the Deutsche Bundesbank (Laravel).** `php artisan quittio:base-rate:update` fetches the series `BBIN1.M.DE.BBK.BBKBAS2.EUR.ME` ("Basiszinssatz gemäß BGB", the base rate under the BGB) from the Bundesbank's statistics API ([command](commands.md#quittiobase-rateupdate)). - It stores the rates the shipped table does not contain in `quittio.countries.de.base_rate_file` (default `storage/app/quittio/base-rates.json`), also those before 2023 for older claims. - It writes the file only when something changed; `--dry-run` shows the rates without writing. - A value that differs from the shipped table is reported, and the Bundesbank value is used. - Without a file (`base_rate_file` set to null) the command fails, except with `--dry-run`. Schedule it, e.g. weekly, so that the rate of 1 January and 1 July is there as soon as the Bundesbank has published it: ```php // routes/console.php Schedule::command('quittio:base-rate:update')->weekly(); ``` 3. **Without Laravel.** Call `BaseRates::register(['2027-01-01' => '1.77'])` once at start-up, fetch the rates yourself with `(new BundesbankBaseRates)->fetch()`, or use a table for one calculation: ```php $rates = (new BaseRateTable)->withRate('2027-01-01', '1.77'); $interest = new DefaultInterest($rates); ``` `DefaultInterest` without a table uses `BaseRates::table()`: the shipped table, then the rates of the file, then those of `quittio.countries.de.base_rates`. The configuration wins for the same date. The service provider `Quittio\Country\DE\Laravel\GermanyServiceProvider` registers file and configuration at boot; Laravel discovers it automatically. `BaseRateTable`: | Method | Result | |---|---| | `__construct(array $rates = self::PUBLISHED)` | ISO date => rate in percent, sorted by date | | `withRate(Date\|string $from, string $rate): self` | new table with an additional or replaced rate | | `rateOn(Date $date): BigDecimal` | rate on a day; `InvalidArgumentException` before the first entry and from `validUntil()` on | | `periods(Date $from, Date $until): list<array{from: Date, until: Date, rate: BigDecimal}>` | periods with a constant rate (start inclusive, end exclusive), split where the rate changes. A table entry that keeps the rate (e.g. 2026-01-01) starts no new period. `InvalidArgumentException` if `$until` is after `validUntil()`. | | `lastChange(): Date` | date of the last entry, e.g. to warn when the table is outdated | | `validUntil(): Date` | first day without a known rate: the next 1 January or 1 July after the last entry (with the published table: 2027-01-01) | `Quittio\Country\DE\Dunning\BaseRates`: | Method | Result | |---|---| | `register(array $rates): void` | adds or replaces rates (ISO date => percent). Only 1 January and 1 July, and values such as `'1.77'` or `'-0.88'`; otherwise `InvalidArgumentException`. | | `table(): BaseRateTable` | the shipped table with the registered rates | | `registered(): array` / `reset(): void` | the registered rates; removes them (tests) | `Quittio\Country\DE\Dunning\BundesbankBaseRates`: | Method | Result | |---|---| | `__construct(?Closure $http = null, int $timeout = 15)` | `$http` receives URL and timeout and returns the response body (for tests or your own HTTP client); default `file_get_contents()` | | `fetch(string $since = '2002-01'): array` | the January and July values from the given month on, ISO date => percent; `RuntimeException` when the API cannot be reached or returns no rates | | `parse(string $csv): array` | reads the CSV download (`2026-07;1,52;…`) | ### DIN 5008 letter layouts DIN 5008 is the German standard for business letters. It fixes where the address field sits, so that the address shows in the window of a window envelope, and where the fold and punch marks are. `Quittio\Country\DE\Layouts\Din5008` provides two forms: form A (`din5008a`) with a low letterhead and form B (`din5008b`) with a higher one. Form B is the German default. `Din5008` has the methods `formA()`, `formB()` and `all()` (form A, form B and `free`). Values are in millimetres, as in DIN 5008:2020. They are unchanged since the 2011 edition, which enlarged the address field of both forms from 40 to 45 mm and moved the return address line (Rücksendeangabe) into the zone for additional information and notes (Zusatz- und Vermerkzone). | | `din5008a` (`Din5008::FORM_A`) | `din5008b` (`Din5008::FORM_B`) | |---|---|---| | Address field from top / left | 27 / 20 | 45 / 20 | | Address field width × height | 85 × 45 | 85 × 45 | | Zone for additional information and notes (Zusatz- und Vermerkzone), above the recipient | 17.7 (five lines, filled from the bottom); its last 5 mm hold the sender line (Rücksendeangabe) | same | | Recipient zone (Anschriftzone, six lines) | 27.3, from 44.7 | 27.3, from 62.7 | | Fold marks | 87 and 192 | 105 and 210 | | Punch mark | 148.5 | 148.5 | | Letterhead height in the default templates (top margin 15) | 12 | 30 | - The address field keeps its position when the invoice has a logo. - The default templates print the sender line at the top of the address field and the recipient directly below it, inside the envelope window. The zones above are for your own templates. - Select a layout per invoice with `->presentation(['letterLayout' => 'din5008a'])`, or for all invoices with `quittio.pdf.layout`. - Fold and punch marks are printed unless `quittio.pdf.fold_marks` (core option `fold_marks`) is `false`. See [Templates: letter layouts](templates.md#letter-layouts). ### UStG rules `Quittio\Country\DE\Rules\UstgRules::all()` (level L3) checks the mandatory content of an invoice under the German VAT Act (sections 14 (4) and 14a UStG) and the simplifications of sections 33 and 34a UStDV. The rules apply to every invoice of a German seller, in every format including a plain PDF. Messages and hints are in German and English. You rarely need this table up front: a failing rule names its code, the field and a hint. Look the code up here when the hint is not enough. | Rule | Severity (BT, path) | Reported when | Legal basis | Fix | |---|---|---|---|---| | `DE-USTG-01` | error (BG-5 `seller.address`, BG-8 `buyer.address`) | One message per party that names the missing fields. The seller lacks street (address line 1), postcode or city. Or the buyer lacks street or city, or a buyer in `DE` lacks the postcode. The buyer part is skipped for small amount invoices. | section 14 (4) no. 1 UStG | Add street, postcode and city for seller and buyer. | | `DE-USTG-02` | error (BT-31 `seller.vatId`) | The seller has neither a VAT identifier (BT-31) nor a tax number (BT-32), and there is no tax representative (BG-11). Skipped for small amount invoices. | section 14 (4) no. 2 UStG | `->vatId()` or `->taxNumber()` on the seller. | | `DE-USTG-03` | error (BT-72 `delivery.actualDeliveryDate`); warning for prepayment invoices (386) and their corrected invoices (384), none with `->de()->serviceDateOpen()` | No delivery date (BT-72), no invoicing period (BG-14), and not every line has a period (BG-26). Skipped for small amount invoices (section 33 UStDV), small business invoices (section 34a UStDV: the small business flag, or a line with `VatPreset::SmallBusiness`) and full or partial cancellations of a prepayment invoice that refer to it (flag `prepayment_correction` and BG-3, section 17 (2) no. 2 UStG). | section 14 (4) no. 6 UStG | `->deliveryDate()` (also when it equals the invoice date), `->invoicingPeriod()` or a `->period()` on every line. | | `DE-USTG-04` | error (BT-22 `notes`); warning when the XML is written (option `syntax`), as the type code labels an e-invoice (section 14.5 (24) sentence 1 UStAE) | A self-billed type code (389, 261, 527), and no note contains "Gutschrift" or one of: self-billing, self billing, self-billed invoice, autofacturation, autofactura, autofatturazione, autofacturação, zelffacturering, samofakturowanie (case-insensitive). | section 14 (4) no. 10 UStG; other EU languages: section 14.5 (24) UStAE | `->de()->selfBilled()` adds the note. | | `DE-USTG-05` | error (BT-22 `notes`) | The flag `de.property_related_service` is set and no note contains "14b". | section 14 (4) no. 9 UStG | `->de()->propertyRelatedService()` adds the note. | | `DE-USTG-06` | error per VAT row (BT-120 `vatBreakdown[i].exemptionReason`) | A VAT breakdown row of category `AE` whose exemption reason contains neither "Steuerschuldnerschaft" nor the text of one of the presets `ReverseChargeDomestic`, `ReverseChargeEu` and `TriangularTransaction`. The preset texts count in every locale the pack ships (`de`, `en`), the invoice locale and the validation locale (case-insensitive). | section 14a (1) and (5) UStG | Use `ReverseChargeDomestic`, `ReverseChargeEu` or `TriangularTransaction`. | | `DE-USTG-07` | error per line (BG-32 `lines[i].item.attributes`) | The flag `de.new_vehicle` is set and a line has no item attributes. | section 14a (4) UStG | `->attribute('Erstzulassung', …)` (first registration), `->attribute('Kilometerstand', …)` (mileage) on every line. | | `DE-USTG-08` | error (BT-112 `totals.grossTotal`) | The flag `de.small_amount` is set and the gross total exceeds the limit of the supply date (`UstgRules::supplyDate()`, otherwise the issue date): 250.00 EUR from 2017, 150.00 EUR before. Other currencies count with their EUR equivalent: gross total × exchange rate of `->taxCurrency('EUR', $rate)`. Without that rate the rule always fails. | section 33 UStDV | Remove `->de()->smallAmount()` and issue a full invoice. | | `DE-USTG-09` | error (BT-151 `lines`, or BT-102 `charges` for document level entries) | A line uses `VatPreset::SmallBusiness` or the invoice has the small business flag, and a line (sub lines included) or a document level allowance or charge has category `S`. | section 19 UStG; VAT shown on charges counts too (section 14c (2) UStG) | `VatPreset::SmallBusiness` on every line, no standard rated charges. | | `DE-USTG-10` | warning (BT-6 `taxCurrency`) | The invoice currency is not EUR, the VAT total is not zero, and the VAT accounting currency (BT-6) is not EUR. | Article 230 VAT Directive, section 16 (6) UStG | `->taxCurrency('EUR', $rate, $date)`. | | `DE-USTG-11` | error (BT-31 `seller.vatId`, BT-48 `buyer.vatId`) | A line uses `ReverseChargeEu` or `TriangularTransaction`, or a line of category `AE` without preset has a buyer in the VAT territory of another member state (for services Monaco counts as France, and Northern Ireland does not count). Then the VAT identifiers of the seller (or of the tax representative) and of the buyer are required; each missing one is reported. A tax number is not sufficient. A small business (flag or `VatPreset::SmallBusiness`) needs no VAT identifier of its own (section 19 (1) sentence 2 UStG). | section 14a (1) and (7) UStG | `->vatId()` for seller and buyer. | | `DE-USTG-12` | error (BT-151 `lines`); warning for possible distance sales | The flag `de.small_amount` is set and category `AE` or `K` is used (error). Or the buyer is a consumer and the destination lies in another member state (warning: a distance sale only if goods are transported there). The destination is the deliver-to address if it has a country, otherwise the buyer's address. | section 33 sentence 3 UStDV; section 3c UStG | Remove `->de()->smallAmount()` and issue a full invoice. | | `DE-USTG-13` | warning (BT-151 `lines`) | The flag `de.new_vehicle` is set and no line, allowance or charge uses category `K`. A warning, as the exemption may not apply in the individual case. | section 14a (4) UStG | `VatPreset::IntraCommunitySupply` on the vehicle lines, or remove `->de()->newVehicle()`. | | `DE-USTG-14` | error (BT-151 `lines`) | A line uses `VatPreset::SmallBusiness` or the invoice has the small business flag, a line, allowance or charge uses category `K`, and the flag `de.new_vehicle` is not set. | section 19 (1) sentence 2, (6) sentence 1 UStG | `VatPreset::SmallBusiness` on the lines; `->de()->newVehicle()` for the intra-community supply of a new vehicle. | | `DE-USTG-15` | warning (BT-2 `issueDate`) | A line, allowance or charge uses category `K`, or a line uses `ReverseChargeEu` (or category `AE` without preset for a buyer in another member state), and the invoice date is after the 15th of the month following the supply. The supply date is the latest of the delivery date (BT-72), the end of the invoicing period (BG-14) and the ends of the line periods (BG-26). Skipped without a supply date, for the type codes 381, 261, 384 and 386, and for re-issued invoices (BG-3 without a prepaid amount). Final invoices (BG-3 with a prepaid amount BT-113) are checked. A warning, as a late invoice stays valid. | section 14a (1) sentence 2 and (3) sentence 1 UStG | Issue these invoices by the 15th of the following month. | | `DE-USTG-16` | warning (BT-2 `issueDate`) | The invoice date is more than six months after the supply (`UstgRules::supplyDate()`). Only for business buyers and for services in connection with a property (flag `de.property_related_service`), where an invoice is obligatory. Skipped without a supply date and for the same documents as `DE-USTG-15`. A warning, as a late invoice stays valid. | section 14 (2) sentences 1 and 2 UStG | Issue invoices within six months of the supply. | | `DE-USTG-17` | warning (BT-7 `taxPointDate`) | A prepayment invoice (386) states an amount already paid (BT-113 above zero) but no VAT point date (BT-7). A warning, as a payment received on the issue date needs no date of its own. | section 14 (4) sentence 1 no. 6 UStG | `->taxPointDate($received)`. | | `DE-USTG-18` | warning (BT-22 `notes`) | A corrected invoice (384) has no note that contains "berichtigt", "ersetzt", "korrigiert", "corrects", "replaces", "rectifie" or "remplace". | section 31 (5) UStDV, section 15.2a (7) UStAE | `Quittio::correction()` adds "Diese Rechnung berichtigt und ersetzt die Rechnung … vom …". | | `DE-USTG-19` | info (BT-3 `typeCode`) | A final invoice deducted an advance settled by self-billing (389, flag `de.self_billed_advance` set by `deductAdvance()`), but is no self-billed invoice. The deduction is required; changing the way of invoicing is allowed but unusual. | section 14 (2) sentence 5, (5) sentence 2 UStG | Check with the buyer who settles the final payment. | | `DE-USTG-20` | warning (BT-113 `prepaidAmount`) | `deductAdvance()` deducted an advance invoice without `received:` (flag `de.advance_receipt_unconfirmed`). Only advance payments actually received are deducted. | section 14 (5) sentence 2 UStG, section 14.8 (2), (5) and (10) UStAE | `received: GermanInvoice::RECEIVED_IN_FULL` or the amount received. | | `DE-EINVOICE-01` | error (no field) | The run produces no e-invoice although section 14 (1) and section 27 (38) UStG require one ([E-invoice obligation](#e-invoice-obligation)). Only checked while rendering (option `e_invoice`). | section 14 (1), (2), section 27 (38) UStG | Render `zugferd` (EN 16931) or `xrechnung`. | | `DE-EINVOICE-02` | warning (no field) | The run produces no e-invoice, and the transition of section 27 (38) UStG still allows an other invoice; a PDF needs the buyer's consent. | section 27 (38) UStG, section 14 (1) sentence 5 UStG | Get the buyer's consent or render an e-invoice. | | `DE-CATEGORY-O-01` | info (BT-31 `seller.vatId`) | The VAT identifiers of seller and buyer were left out of an invoice of category `O` only (flag `de.vat_ids_omitted`). | BR-O-02; section 14 (4) sentence 1 no. 2 UStG | Nothing to do. | | `DE-CATEGORY-O-02` | info (BT-32 `seller.taxNumber`) | An invoice of category `O` only states a VAT identifier, and Quittio could not leave it out: no tax number of the seller, or a tax representative. | BR-O-02, BR-56 | Set the seller's tax number. | Helpers used by the rules and available to you: - `UstgRules::isSmallAmountInvoice($invoice)`: the invoice has the small amount flag and its simplifications apply (no category `AE` or `K`); - `UstgRules::isSmallBusinessInvoice($invoice)`: the small business flag is set or a line uses `VatPreset::SmallBusiness`; - `UstgRules::hasServiceDate($invoice)`: delivery date, invoicing period or a period on every line; - `UstgRules::supplyDate($invoice)`: the latest of the delivery date, the end of the invoicing period and the ends of the line periods, or `null` without any of them; - `UstgRules::issuingDeadline($invoice)`: the 15th of the month after the supply, or `null` without a supply date. #### Leitweg-ID `UstgRules::plausibility()` (level L7) checks buyer references (BT-10 `buyerReference`) that are shaped like a Leitweg-ID but have wrong check digits: | Rule | Severity | Reported when | |---|---|---| | `DE-LEITWEG-ID` | warning | The buyer is a public buyer: the profile is `xrechnung`, `xrechnung-extension` or `xrechnung-cvd`, or the buyer's electronic address (BT-49) uses scheme `0204`. Message: "The check digits of the Leitweg-ID ":value" (BT-10) are wrong." | | `DE-LEITWEG-ID-SUSPECT` | info | Any other buyer in Germany (country `DE` or none) that is not a consumer. Message: "The buyer reference ":value" (BT-10) is shaped like a Leitweg-ID, but its check digits are wrong. It is not treated as a Leitweg-ID, so the invoice is not issued as XRechnung automatically." | So a mistyped Leitweg-ID does not lead to ZUGFeRD unnoticed. An order number of the same shape (e.g. `4711-01`) gets the same info, which you may ignore. Neither finding changes the format. `Quittio\Country\DE\Support\LeitwegId`: | Method | Result | |---|---| | `looksLike(?string $value): bool` | the shape: a coarse address of 2 to 12 digits, an optional fine address of up to 30 letters or digits and two check digits, separated by hyphens | | `isValid(?string $value): bool` | shape and check digits (ISO 7064 Mod 97-10) are correct | | `checkDigits(string $address): string` | the two check digits for coarse and fine address without hyphens, e.g. `checkDigits('0401100012345')` → `03` | #### Tax number `UstgRules::plausibility()` also checks the tax number (Steuernummer, BT-32) of a seller in Germany. The local tax office issues this number; it is not the VAT identifier. | Rule | Severity | Reported when | |---|---|---| | `DE-TAX-NUMBER` | warning (BT-32 `seller.taxNumber`) | The seller's country is `DE`, and the tax number is not a valid 13-digit ELSTER number, a 12-digit federal number or the notation of a federal state, or its check digit is wrong. Also reported when a VAT identifier (`DE…`) was given as tax number. A Bavarian notation without the tax office number (`815/08152`) cannot be checked and is accepted. So is the small business identification number of a small business (suffix `EX`, section 34a UStDV). | The checks follow the document "Prüfung der Steuer- und Steueridentifikationsnummer" (checking tax numbers and tax identification numbers) of ELSTER, the online service of the German tax authorities, published by the Bavarian State Office for Taxes (Bayerisches Landesamt für Steuern): - **Format.** The 13-digit ELSTER format is `FFFF0BBBUUUUP` (NRW: `FFFF0BBBBUUUP`), with the 0 at the 5th position. - **Excluded districts.** 000, 998 and 999; below 100 in the Bavarian group; in NRW 0000, 0998 and 0999, and `UUUP` must be above 0009. - **Check digit.** Each state has its procedure: the modified 11 procedure (Rhineland-Palatinate), the 2 procedure (Baden-Württemberg, Hesse, Schleswig-Holstein), or the 11 procedure with the factors of the state (all others; Berlin with the variants A and B by tax office and district). - **Not checked:** whether the tax office exists. - **Notation without state.** A notation without the state (e.g. `93/815/08150`) is valid when it is valid for any state that uses this notation. `Quittio\Country\DE\Support\TaxNumber`: | Method | Result | |---|---| | `TaxNumber::parse(string $value, ?string $state = null): ?TaxNumber` | the valid number in any notation (`198/815/08152`, `9198081508152`, `919881508152`, `053 815 08158` …), or null. `$state` (ISO 3166-2:DE, e.g. `BY`) restricts a state notation to that state. | | `TaxNumber::validate(string $value, ?string $state = null): ?bool` | `true` valid, `false` invalid, `null` plausible but not checkable | | `TaxNumber::looksLikeVatId(string $value): bool` | a VAT identifier (`DE` + 9 digits) | | `->elster`, `->state`, `->formatted()` | 13-digit ELSTER format, state, notation on tax notices (e.g. `198/815/08152`, `400/8150/8159`) | ### Mandatory PDF output After rendering, the mandatory field guard checks that the PDF shows certain values (see [Templates: mandatory field guard](templates.md#mandatory-field-guard)). `CountryDE::mandatoryOutput()` adds these German values to the base fields. Paths without a value are skipped. The legal basis is the value Quittio reports, in German citation form. | Condition | Access key | Description | Legal basis | |---|---|---|---| | not a small amount invoice, and the seller has a VAT identifier or tax number, or a tax representative with VAT identifier | `seller.vatId\|seller.taxNumber\|taxRepresentative.vatId` | tax number or VAT identifier of the seller | § 14 Abs. 4 Nr. 2 UStG | | not a small amount or small business invoice, with BT-72 or BG-14 | `servicePeriod\|deliveryDate\|delivery.date` | date of the supply or service | § 14 Abs. 4 Nr. 6 UStG | | the same, without BT-72 and BG-14 | `servicePeriod\|lineGroups[*].lines[*].period\|lines[*].period` | date of the supply or service | § 14 Abs. 4 Nr. 6 UStG | | self-billed type code | `title`, and the path of the first note containing "Gutschrift" | label and note "Gutschrift" | § 14 Abs. 4 Nr. 10 UStG | | flag `de.property_related_service` | path of the retention note (its text or a note containing "14b") | retention notice for property related services | § 14 Abs. 4 Nr. 9 UStG | | each VAT row of category `AE` or `K` | `vatRows[i].label` or the legal note with its BT-120 text | reverse charge or exemption note | § 14a UStG | | category `AE` or `K` used | `buyer.vatId` | VAT identifier of the buyer | § 14a Abs. 1 und 3 UStG | | category `K` used, or `AE` with a buyer country different from the seller's | `seller.vatId\|taxRepresentative.vatId` | VAT identifier of the seller | § 14a Abs. 1 und 3 UStG | The default templates print all of them. ### Legal texts `Quittio\Country\DE\Texts\LegalTexts::catalog()` (also `CountryDE::legalTexts()`) holds the German notices in German and English. The texts live in the pack's language files `resources/lang/{de,en}/legal.php` (the exemption reasons in `tax.php`) and are read through the translator, so in Laravel `lang/vendor/quittio-de/{locale}/legal.php` overrides single texts. Its fallback locale is `de` (`LegalTexts::FALLBACK_LOCALE`). Builder macros add some of them; texts marked "–" are for your own notes. | Constant (key) | German | English | Added by | |---|---|---|---| | `SELF_BILLING` (`self_billing`) | Gutschrift | Gutschrift (self-billed invoice) | `selfBilled()` | | `PROPERTY_RETENTION` (`property_retention`) | Sie sind gesetzlich verpflichtet, diese Rechnung, einen Zahlungsbeleg oder eine andere beweiskräftige Unterlage zwei Jahre lang aufzubewahren (§ 14b Abs. 1 Satz 5 UStG). | You are required by law to keep this invoice, a payment receipt or other conclusive document for two years (section 14b (1) sentence 5 UStG). | `propertyRelatedService()` | | `REVERSE_CHARGE` (`reverse_charge`) | Steuerschuldnerschaft des Leistungsempfängers | Reverse charge, the recipient is liable for VAT | – (text of `VatPreset::ReverseChargeEu`) | | `INTRA_COMMUNITY_SUPPLY` (`intra_community_supply`) | Steuerfreie innergemeinschaftliche Lieferung (§ 4 Nr. 1b i. V. m. § 6a UStG) | VAT-exempt intra-Community supply (section 4 no. 1b in conjunction with section 6a UStG) | – (text of `VatPreset::IntraCommunitySupply`) | | `EXPORT` (`export`) | Steuerfreie Ausfuhrlieferung (§ 4 Nr. 1a i. V. m. § 6 UStG) | VAT-exempt export supply (section 4 no. 1a in conjunction with section 6 UStG) | – (text of `VatPreset::Export`) | | `SMALL_BUSINESS` (`small_business`) | Steuerfreie Leistung nach § 19 Abs. 1 UStG (Steuerbefreiung für Kleinunternehmer). | VAT-exempt supply under section 19 (1) UStG (small business exemption). | – (text of `VatPreset::SmallBusiness`) | | `SERVICE_DATE_OPEN` (`service_date_open`) | Der Zeitpunkt der Leistung ist noch nicht vereinbart. | The date of the service has not been agreed yet. | `serviceDateOpen()` | | `PREPAYMENT` (`prepayment`) | Anzahlungsrechnung. Die Leistung wird voraussichtlich am :date erbracht. | Advance invoice. The service is expected to be performed on :date. | `advance()` with a date | | `PREPAYMENT_MONTH` (`prepayment_month`) | Anzahlungsrechnung. Die Leistung wird voraussichtlich im :month erbracht. | Advance invoice. The service is expected to be performed in :month. | `advance()` with a month | | `PREPAYMENT_RECEIVED` (`prepayment_received`) | Die Anzahlung wurde am :date vereinnahmt. | The advance payment was received on :date. | `advance()` with `$receivedOn` | | `ADVANCE_DEDUCTION` (`advance_deduction`) | Abzüglich Anzahlung gemäß Rechnung :number vom :date: :amounts (§ 14 Abs. 5 Satz 2 UStG). | Less advance payment according to invoice :number of :date: :amounts (section 14 (5) sentence 2 UStG). | `deductAdvance()` | | `ADVANCE_DEDUCTION_REMAINDER` (`advance_deduction_remainder`) | Restrechnung: Abgezogen ist die vereinnahmte Anzahlung gemäß Rechnung :number vom :date: :amounts (§ 14 Abs. 5 Satz 2 UStG). | Remainder invoice: less the advance payment received according to invoice :number of :date: :amounts (section 14 (5) sentence 2 UStG). | `deductAdvance()` with `style: 'remainder'` | | `ADVANCE_DEDUCTION_LINE` (`advance_deduction_line`) | Abzüglich Anzahlung gemäß Rechnung :number vom :date | Less advance payment according to invoice :number of :date | item name of the negative lines of a remainder invoice | | `ADVANCE_DEDUCTION_TAXED` (`advance_deduction_taxed`) | Entgelt :net zzgl. :rate Umsatzsteuer :vat | net :net plus :rate VAT :vat | `deductAdvance()`, part of `:amounts` | | `ADVANCE_DEDUCTION_UNTAXED` (`advance_deduction_untaxed`) | Entgelt :net ohne Umsatzsteuer | net :net without VAT | `deductAdvance()`, part of `:amounts` | | `CONSUMER_DEFAULT` (`consumer_default`) | Sie kommen spätestens in Verzug, wenn Sie nicht innerhalb von 30 Tagen nach Fälligkeit und Zugang dieser Rechnung zahlen (§ 286 Abs. 3 BGB). | You will be in default at the latest if you do not pay within 30 days of the due date and receipt of this invoice (section 286 (3) BGB). | `consumerDefaultNotice()` | | `DEFAULT_INTEREST` (`default_interest`) | Verzugszinsen :rate % p. a. (Basiszinssatz :base_rate % + :points Prozentpunkte) vom :from bis :until | Default interest :rate % p.a. (base rate :base_rate % + :points points) from :from to :until | `DefaultInterest` (interest lines of payment reminders; German numbers and dates for every German locale) | | `DISCOUNT_AGREEMENT` (`discount_agreement`) | Etwaige Minderungen des Entgelts (Boni, Rabatte) ergeben sich aus :agreement. | Any reductions of the consideration (bonuses, rebates) follow from :agreement. | `discountAgreement()` | | `ZERO_RATED_PV` (`zero_rated_pv`) | Steuersatz 0 % nach § 12 Abs. 3 UStG. | VAT rate 0 % under section 12 (3) UStG. | `VatPreset::ZeroRatedPv` | | `NEW_VEHICLE` (`new_vehicle`) | Innergemeinschaftliche Lieferung eines neuen Fahrzeugs (§ 14a Abs. 4 UStG); die Fahrzeugmerkmale nach § 1b Abs. 2 und 3 UStG sind bei der Position angegeben. | Intra-Community supply of a new means of transport (section 14a (4) UStG); the vehicle details under section 1b (2) and (3) UStG are stated with the line. | `newVehicle()` | - `REVERSE_CHARGE`, `INTRA_COMMUNITY_SUPPLY`, `EXPORT` and `SMALL_BUSINESS` are the exemption reasons of the named [tax presets](#tax-presets), in every locale the pack ships (`CountryDE::locales()`). So a notice has one wording in BT-120 and in your notes, including overrides of `tax.php`. - Validation and rendering add no text. The builder adds the notes of the presets that require one (`StatesInvoiceNote`, see [Tax presets](#tax-presets)). - `LegalTexts::text($key, $locale, $replace)` returns a text in the language of `$locale` (`en_GB` → English) or in German. `LegalTexts::localeOf($key, $locale)` names the catalog locale it uses. A text for your own note, here on a prepayment invoice (386), which names the expected date of the service: ```php use Quittio\Core\Enums\NoteSubjectCode; use Quittio\Country\DE\Texts\LegalTexts; $builder->type('386')->note( LegalTexts::catalog()->get(LegalTexts::PREPAYMENT, 'de', ['date' => '01.11.2026']), NoteSubjectCode::RegulatoryInformation, ); ``` `->de()->advance()` adds this note itself ([Prepayment invoices](#prepayment-invoices)). Prepayment invoices (386) without a service date get a `DE-USTG-03` warning instead of an error, unless `advance()` named the expected date or `->de()->serviceDateOpen()` states that it is not agreed yet. A prepayment invoice for a payment already received (BT-113) states the date of receipt as VAT point date (`->taxPointDate()`, BT-7) if it differs from the issue date (`DE-USTG-17`). ### Meta flags The pack marks German special cases with meta flags on the invoice (`InvoiceData::$meta->flags`). The builder macros set them, and the rules read them. `Quittio\Country\DE\Support\Flags`: | Constant | Value | Set by | Effect | |---|---|---|---| | `SMALL_AMOUNT` | `de.small_amount` | `smallAmount()` | small amount invoice: relaxed rules, PDF format, `DE-USTG-08`, `DE-USTG-12` | | `PROPERTY_RELATED_SERVICE` | `de.property_related_service` | `propertyRelatedService()` | `DE-USTG-05`, mandatory output | | `NEW_VEHICLE` | `de.new_vehicle` | `newVehicle()` | `DE-USTG-07`, `DE-USTG-13`, `DE-USTG-14` (exception) | | `SERVICE_DATE_OPEN` | `de.service_date_open` | `serviceDateOpen()` | no `DE-USTG-03` warning for a prepayment invoice without service date | | `SELF_BILLED_ADVANCE` | `de.self_billed_advance` | `deductAdvance()` of a self-billed advance (389) | `DE-USTG-19` | | `EXPECTED_SERVICE_DATE` | `de.expected_service_date` | `advance()` with a date or month | no `DE-USTG-03` warning for a prepayment invoice without service date | | `TICKET` | `de.ticket` | `ticket()` | ticket for the carriage of passengers (section 34 UStDV): no `DE-EINVOICE-*` | | `VAT_IDS_OMITTED` | `de.vat_ids_omitted` | `CountryDE::complete()` | `DE-CATEGORY-O-01` | | `ADVANCE_RECEIPT_UNCONFIRMED` | `de.advance_receipt_unconfirmed` | `deductAdvance()` without `received:` | `DE-USTG-20` | | `SMALL_BUSINESS` | `small_business` (`Meta::FLAG_SMALL_BUSINESS`) | seller configuration, Managed issuer, `->flag()`, `smallBusinessId()` | small business invoice (section 34a UStDV): `DE-USTG-03`, `DE-USTG-09`, `DE-USTG-11`, `DE-USTG-14`, `DE-TAX-NUMBER`, mandatory output | ### Retention `CountryDE::retention()` returns `new RetentionRule(8, fromEndOfCalendarYear: true)`: invoices are kept for 8 years from the end of the calendar year of issue (section 14b UStG, section 147 AO as amended in 2025). An invoice issued on 3 October 2026 is kept until 31 December 2034. The Managed layer stores this date (`retention_until`); `quittio-managed.retention.years` may only lengthen it. - **Suspension.** Section 147 (3) AO stays unaffected: documents that matter for taxes not yet time-barred, e.g. during a tax audit or an objection, must not be deleted after the 8 years. The Managed layer keeps them with a legal hold (`legal_hold`). - **Files.** Keep every invoice in the format it was issued in: ZUGFeRD as the PDF with its embedded XML, XRechnung as the XML. At least the structured part must stay unchanged (section 14b.1 (1) UStAE). Keep a PDF sent with an XRechnung as well, and the validation report as evidence (BMF letter of 15 October 2025, marginal no. 35a). `RenderedInvoice::save()` stores the main output only; save the siblings with `->as('pdf')->save()`. - **Supervised institutions.** For credit and financial services institutions, insurers and investment firms the 8 years apply only to invoices whose 10-year period had not expired on 1 January 2026 (section 27 (40) sentence 2 UStG); for everybody else, to invoices whose period was still running on 31 December 2024. ### BMF error classes In its letter of 15 October 2025, the German Federal Ministry of Finance (BMF) sorts errors in e-invoices into three classes. `Quittio\Country\DE\Rules\BmfErrorClass` maps Quittio's findings to these classes ("Rz." is the marginal number in the letter): | Case | Value | Findings | `label('de')` | `label('en')` | |---|---|---|---|---| | `Format` | `format` | levels L1, L2, L4, L6 | Formatfehler (Rz. 6a) | Format error (marginal no. 6a) | | `BusinessRule` | `business_rule` | levels L3, L5 | Geschäftsregelfehler (Rz. 6b) | Business rule error (marginal no. 6b) | | `Content` | `content` | every `DE-USTG-*` finding and level L7 | Inhaltsfehler (Rz. 35a) | Content error (marginal no. 35a) | - `BmfErrorClass::of(ValidationMessage $message)` classifies one finding. - `label()` returns German for `de` and English otherwise. - `voidsEInvoice()` is true for `Format` only: the document is then not an e-invoice but an "other invoice" (sonstige Rechnung). - `(new CountryDE)->errorClassification($result)` groups the errors and warnings of a `ValidationResult` by class value: ```php use Quittio\Country\DE\CountryDE; $classes = (new CountryDE)->errorClassification($result); // ['format' => [...], 'business_rule' => [...], 'content' => [...]] ``` The validation levels are described in [Validation](validation.md); see also [Validation: Germany: BMF error classes](validation.md#germany-bmf-error-classes). ### Translations The pack ships German and English catalogs in `resources/lang/{de,en}/`: - `rules.php`: message and hint of every rule (`BR-DE-*`, `BR-DEX-*`, `DE-XRECHNUNG-EXT-01`, `DE-USTG-*`, `DE-LEITWEG-ID`, `DE-LEITWEG-ID-SUSPECT`, `DE-TAX-NUMBER`); - `tax.php`: the exemption reason texts of the presets, including `de.exempt` for `VatPreset::exempt()` (placeholder `:paragraph`). They are registered as the namespace `quittio-de` (e.g. `quittio-de::rules.DE-USTG-03.message`). `CountryDE::registerTranslations()` registers them lazily, so presets work without a `Quittio` instance. Other locales fall back to English. With Laravel, Laravel's translator is used, so the usual override files apply: `lang/vendor/quittio-de/{locale}/rules.php` and `tax.php`, also for additional locales. `CountryDE::locales()` lists the locales the pack ships (the directories of `resources/lang`). Texts defined in PHP cannot be translated through files: - the legal texts (German and English, fallback German; the four notices taken from the presets follow `tax.php`); - the correction policy titles (fallback English); - the BMF labels and the default interest descriptions (German for `de`, English otherwise). ### The German pack's hooks For pack authors, this is how `CountryDE` fills the [`CountryPack` contract](#the-countrypack-contract): | Hook | Germany | |---|---| | `defaults()` | currency `EUR`, time zone `Europe/Berlin`, locale `de`, paper `A4`, letter layout `din5008b`, profile `en16931`, payment QR `girocode`, default VAT presets `de.standard` and `de.small_business` | | `profiles()` | [`XRechnung30`, `XRechnung30Extension`, `XRechnung30Cvd`](#xrechnung-profiles) | | `taxPresets()` | every case of [`VatPreset`](#tax-presets) | | `rules()` | the [UStG rules](#ustg-rules) `DE-USTG-01` to `DE-USTG-15`, the [Leitweg-ID checks](#leitweg-id) `DE-LEITWEG-ID` and `DE-LEITWEG-ID-SUSPECT`, and the [tax number check](#tax-number) `DE-TAX-NUMBER` | | `buyerCountryRules()` | none | | `formatRules()` | [`GermanFormatRule`](#format-choice) | | `mandatoryOutput()` | [mandatory PDF output](#mandatory-pdf-output) | | `legalTexts()` | [`LegalTexts::catalog()`](#legal-texts) | | `numberingRules()` | pattern `RE-{Y}-{seq:4}`, reset `yearly`, resets `never`, `yearly`, `monthly`, gapless | | `retention()` | [8 years from the end of the calendar year](#retention) | | `dunningLaw()` | [section 288 BGB values](#dunning-law) | | `correctionPolicy()` | [credit note, cancel and reissue, German titles](#cancellations-and-corrections) | | `letterLayouts()` | [`din5008a`, `din5008b`, `free`](#din-5008-letter-layouts) | | `paymentQr()`, `addressFormatter()` | defaults: EPC GiroCode, international address format | | `translationPath()` | `resources/lang` of the package | | `errorClassification()` | [BMF error classes](#bmf-error-classes) (additional method) | ### Known limitations - The legal wording, references and defaults reflect the law and administrative practice of October 2026, when a tax adviser confirmed them (see the legal review and the disclaimer in the README). Later changes of the law need a new release. - Final invoices: the EN 16931 variants of `deductAdvance()` (prepaid amount or remainder invoice) exist; the EXTENDED variant does not. The tax review found it unnecessary. - The shipped base rate table ends with 1 July 2026. Later rates come from `quittio.countries.de.base_rates` or `php artisan quittio:base-rate:update` (see [Base rate table](#base-rate-table)). - The documents layer checks the section 288 (5) BGB flat rate within one reminder (once per claim, not for consumers); across reminders the application must track it (the Managed layer does not). - Distance sales (section 3c UStG) cannot be told from the data; `DE-USTG-12` only warns about possible ones. - Tax numbers are checked for format and check digit, not against the list of tax offices. Territories without a distinct postcode cannot be detected. - The pack defines no buyer country rules, exporters (e.g. DATEV) or readers yet. ## Other countries These packs are released with the same version as the rest of Quittio, but are not part of `quittio/quittio`. Their legal wording, rules and defaults have **not been reviewed by a tax adviser** of the country yet: check the mentions and rates of your invoices before you rely on them. Each page describes the presets, rules, formats, defaults and what is not included yet. | Package | Country | Covers | Page | |---|---|---|---| | `quittio/country-at` | Austria (`AT`) | mandatory fields of the UStG 1994, tax presets, CIUS-AT profiles, ebInterface, default interest (UGB, ABGB) | [Austria](country-at.md) | | `quittio/country-be` | Belgium (`BE`) | mandatory fields of Royal Decree No. 1, tax presets, Peppol BIS, language regions, default interest (law of 2 August 2002) | [Belgium](country-be.md) | | `quittio/country-ch` | Switzerland (`CH`) | mandatory fields of the MWSTG, tax presets, QR bill, rounding to 5 Rappen, default interest (Art. 104 OR) | [Switzerland](country-ch.md) | | `quittio/country-fr` | France (`FR`) | mentions of the CGI (CIBS from 2027) and the Code de commerce, the e-invoicing reform, SIREN, late payment penalties | [France](country-fr.md) | ```bash composer require quittio/country-fr ``` The packs declare themselves in their `composer.json`, so Laravel finds them after the installation; without Laravel, pass them to `Quittio::create()`, e.g. `Quittio::create(['country' => 'FR'], [new CountryFR])` ([Registering packs](#registering-packs)). ## How a pack is selected This and the following sections are for authors of country packs, and for readers who want to know how Quittio picks a pack. A country pack implements `Quittio\Core\Countries\CountryPack`, usually by extending `Quittio\Core\Countries\AbstractCountryPack`, which supplies neutral defaults for every hook (every method of the contract). A pack may only add or tighten rules; it never relaxes EN 16931. `DefaultCountryResolver` picks the packs for every run: render, check, prepare, documents, cancellations and the validation of incoming files. 1. **Leading pack (seller side).** Quittio takes the first of these values that is set: - the country passed to the run (`->country('AT')` on the pending invoice, `RenderOptions::$country`); - the seller's country code (BT-40); - the configured default country (`quittio.defaults.country`, core config key `country`); - otherwise `XX`. The registry returns the installed pack for that code. A country without a pack of its own takes the pack of the country whose VAT territory it belongs to ([`VatTerritory::vatCountry()`](#vatterritory)): a seller in Monaco the French pack, a seller in Liechtenstein the Swiss pack. Otherwise Quittio uses a generic pack (`CountryGeneric`). 2. **Buyer pack.** If the buyer's country code (BT-55) is set and differs from the leading pack's code, the installed pack of the buyer's country (or of the country whose VAT territory it belongs to) is added, unless it is the leading pack. No generic pack is created for the buyer. ```php laravel use Quittio\Laravel\Facades\Quittio; Quittio::make($invoice)->country('DE')->render(); // force the leading pack ``` ```php plain $quittio->make($invoice)->country('DE')->render(); // force the leading pack ``` What each side contributes: | Hook | Leading pack | Buyer pack (cross-border only) | |---|---|---| | `rules()` | applied | – | | `buyerCountryRules()` | – | applied | | `formatRules()` | domestic invoices | cross-border business invoices (see [automatic format choice](formats.md#automatic-choice)) | | `mandatoryOutput()` | merged with the base fields of the mandatory field guard | – | | `defaults()` (locale, paper, letter layout), `letterLayouts()`, `addressFormatter()`, `paymentQr()` | locale fallback and PDF | – | | `correctionPolicy()` | used for cancellations (`Quittio::cancellation()`) | – | | `translationPath()` | registered | registered | "Domestic" means that seller and buyer lie in the same VAT territory (see [`VatTerritory`](#vatterritory)), or that the buyer has no country code. A buyer in a territory excluded from the seller's VAT territory (e.g. Büsingen for Germany) is cross-border. Without a buyer pack of its own, the format rules of the leading pack still apply to it. Without a pack for the seller's country, `CountryGeneric` applies: EN 16931 rules only, international formatting and neutral defaults. Validation then reports the warning `QUITTIO-GENERIC-COUNTRY` (L3, BT-40): "No country pack is installed for the seller country :value. Only EN 16931 rules are checked; national mandatory information is not validated." `ResolvedCountries::isGeneric()` and `CountryGeneric::isGeneric()` tell this case apart. With the Managed layer, the issuer's country selects the pack for numbering and retention. The leading pack of an issued invoice is stored with it (`country_pack`) and used again for re-rendering and corrections (see [Managed layer](managed.md)). ## Registering packs A pack must be registered before Quittio can use it. The German pack registers itself in Laravel. ### Laravel Laravel finds packs in three places. All of them are instantiated through the container, so constructors may use dependency injection: 1. **Composer metadata.** Every installed package and the root `composer.json` of your application may declare packs. `quittio/country-de` declares itself this way, so `composer require quittio/country-de` (or `quittio/quittio`, which contains it) is all you need. Classes that do not exist are skipped. ```json "extra": { "quittio": { "country-packs": ["Acme\\CountryAT\\CountryAT"] } } ``` 2. **Configuration.** `quittio.countries` lists further pack classes; keys are ignored (see [Configuration](configuration.md#country-packs)). Arrays under lower-case codes are the settings of a pack, not classes ([Settings of your pack](#settings-of-your-pack)). ```php 'countries' => [ 'AT' => \Acme\CountryAT\CountryAT::class, ], ``` 3. **At runtime.** Call `Quittio::registerCountry(new CountryAT)` (facade `Quittio\Laravel\Facades\Quittio`), e.g. in a service provider. Packs registered this way win over packs with the same code from the other two sources. A class from the first two sources that is not a country pack throws a `ConfigurationException`. Packs are keyed by `code()`. Of two packs with the same code, the one registered last wins. Discovered packs come first, then the configured classes, then packs registered at runtime. So a subclass of `CountryDE` in `quittio.countries` replaces the discovered `CountryDE`. `php artisan quittio:countries` lists the installed packs with code, class, profiles, number of rules and format rules, and the defaults (currency, locale, profile). Without any pack it prints a warning (see [Artisan commands](commands.md#quittiocountries)). ### Without Laravel ```php use Quittio\Core\Quittio; use Quittio\Country\DE\CountryDE; $quittio = Quittio::create(['country' => 'DE'], [new CountryDE]); $quittio->registerCountry(new CountryAT); // further packs at any time ``` Registering a pack does three things: - it adds the pack to the `CountryRegistry` under its upper-case code; - it registers the pack's `profiles()` in the profile registry, so that formats, `->profile('xrechnung')` and the reader know them; - it registers `translationPath()` as the translation namespace `quittio-{code}` (lower case, e.g. `quittio-de`). `$quittio->countries()` returns the registry: `has($code)`, `get($code)` (installed pack or null), `getOrGeneric($code)`, `all()` (array keyed by code) and `taxPreset($key)` (the preset with this key from any installed pack, or null). Codes are case-insensitive. ## Writing your own country pack 1. Create a Composer package that requires `quittio/core`. 2. Extend `AbstractCountryPack` and override only what differs. `code()` is the one required method. 3. Add tax presets, rules, format rules, mandatory output, layouts and texts as needed, and national output formats with `formats()` ([Formats of your pack](#formats-of-your-pack)). 4. Ship translations in `resources/lang/{locale}/rules.php` and return the directory from `translationPath()`. 5. Declare the pack in `composer.json` (`extra.quittio.country-packs`), so that the Laravel integration finds it. If the pack has Laravel settings, keep them under `quittio.countries.{code}` ([Settings of your pack](#settings-of-your-pack)). 6. Test it with example invoices and, where they exist, the official validation artefacts of the country. Have the legal content reviewed by a local tax adviser. A minimal pack (values for illustration only): ```php namespace Acme\CountryAT; use Quittio\Core\Countries\AbstractCountryPack; use Quittio\Core\Countries\CountryDefaults; use Quittio\Core\Countries\MandatoryField; use Quittio\Core\Countries\MandatoryFieldList; use Quittio\Core\Countries\RetentionRule; use Quittio\Core\Data\InvoiceData; use Quittio\Core\Enums\VatCategory; use Quittio\Core\Tax\CustomTaxPreset; use Quittio\Core\Tax\TaxPresetCollection; use Quittio\Core\Validation\Rules\CallbackRule; use Quittio\Core\Validation\Rules\Inspect; use Quittio\Core\Validation\Rules\RuleReporter; final class CountryAT extends AbstractCountryPack { public function code(): string { return 'AT'; } public function defaults(): CountryDefaults { return new CountryDefaults(currency: 'EUR', timezone: 'Europe/Vienna', locale: 'de'); } public function taxPresets(): TaxPresetCollection { return new TaxPresetCollection([ CustomTaxPreset::make('at.standard_20', VatCategory::StandardRate, '20'), ]); } public function rules(): array { return [ CallbackRule::l3('ACME-AT-01', 'The seller VAT identifier (BT-31) must be stated.', function (InvoiceData $i, RuleReporter $report): void { if (! Inspect::filled($i->seller->vatId)) { $report->error('BT-31', 'seller.vatId'); } }, 'quittio-at'), ]; } public function formatRules(): array { return [new ConsumerPdfRule]; } public function mandatoryOutput(InvoiceData $invoice): MandatoryFieldList { return new MandatoryFieldList([new MandatoryField('seller.vatId', 'VAT identifier of the seller')]); } public function retention(): RetentionRule { return new RetentionRule(7); } public function translationPath(): string { return dirname(__DIR__).'/resources/lang'; } } ``` The format rule of the example sends invoices to consumers as PDF: ```php use Quittio\Core\Data\InvoiceData; use Quittio\Core\Formats\FormatChoice; use Quittio\Core\Formats\FormatRegistry; use Quittio\Core\Formats\FormatRule; final class ConsumerPdfRule implements FormatRule { public function resolve(InvoiceData $invoice): ?FormatChoice { return $invoice->buyer->isConsumer ? new FormatChoice(FormatRegistry::PDF, null, 'Invoice to a consumer.') : null; // null: the next rule or the default choice decides } } ``` The German translation of the rule, in `resources/lang/de/rules.php`: ```php // "The seller's VAT identifier (UID, BT-31) must be stated." / "Set ->vatId() on the seller." return [ 'ACME-AT-01' => [ 'message' => 'Die UID des Verkäufers (BT-31) muss angegeben sein.', 'hint' => 'Setzen Sie ->vatId() beim Verkäufer.', ], ]; ``` ### Presets of your pack A preset implements `Quittio\Core\Tax\TaxPreset`: | Method | Returns | |---|---| | `key(): string` | stable key prefixed with the country code, e.g. `at.standard_20` | | `category(): VatCategory` | VAT category (BT-151) | | `rate(): ?BigDecimal` | rate in percent, null for category O | | `exemptionReasonCode(): VatExemptionReasonCode\|RawCode\|null` | VATEX code (BT-121) | | `exemptionReason(?string $locale = null): ?string` | exemption reason text (BT-120), shown in XML and PDF | - `CustomTaxPreset::make(string $key, VatCategory $category, BigDecimal|int|string|null $rate = null, VatExemptionReasonCode|RawCode|string|null $code = null, array|string|null $reason = null)` builds a preset ad hoc. `$reason` is a text or locale => text. A plain string counts as English; without a locale the English text is used. - For many presets a backed enum is convenient, as `Quittio\Country\DE\Tax\VatPreset` shows. - `TaxPresetCollection` offers `add()`, `has($key)`, `get($key)` (throws `InvalidArgumentException` for unknown keys), `count()` and iteration. A preset is applied per line with `->vat($preset)`. The line stores category, rate, reason, code and the preset key (`LineVat::$presetKey`), so that rules can recognise it (see [Building invoices: tax presets](building-invoices.md#tax-presets)). ### Rules of your pack A rule implements `Quittio\Core\Validation\Rule` (`code()`, `level()`, `check(InvoiceData, ValidationContext): iterable<ValidationMessage>`). `CallbackRule::l3($code, $fallback, $check, $namespace)` (business rules) and `CallbackRule::l7(...)` (plausibility) cover most cases. The closure receives the invoice and a `RuleReporter`: - `error(?string $bt = null, ?string $path = null, array $replace = [])`, `warning(...)` and `info(...)` add a finding with business term and data path; - `context()` returns the `ValidationContext`: `profile`, `countryPacks` (leading pack first), `locale`, `option($key)` (e.g. `option('syntax')` with the `Syntax` that will be written), `profileIs(...$keys)`, `leadingCountry()`, `hasCountry($code)`. Messages: - They come from the catalog key `{namespace}::rules.{code}` with the entries `message` and `hint`, in the validation locale or English. Without an entry, the English `$fallback` is used. - `:name` placeholders are replaced from `$replace`. - Use the namespace `quittio-{code}` that registration gives your `translationPath()`. The rules of a pack run in every format, also for a plain PDF. Profile specific rules belong to a profile class (see [Formats and profiles](formats.md)). See [Validation](validation.md) for levels and results. ### Format rules of your pack `Quittio\Core\Formats\FormatRule::resolve(InvoiceData $invoice): ?FormatChoice` returns a `FormatChoice(string $format, ?string $profile = null, ?string $reason = null)` or null. - Rules run in order; the first non-null choice wins. - The resolver consults the leading pack for domestic invoices and the buyer's pack for cross-border invoices to businesses. - An explicit format always wins. - A choice of `zugferd` or `cii` is upgraded to EXTENDED when EXTENDED features are used. ### Formats of your pack `AbstractCountryPack` implements `Quittio\Core\Countries\Capabilities\ProvidesFormats` with empty defaults. `Quittio::registerCountry()` registers what a pack returns: - `formats()`: `list<OutputFormat>`, e.g. a national format with its syntax and allowed profiles; a format with the key of a registered one replaces it. - `formatAliases()`: further names, e.g. `['xrechnung' => 'xrechnung-cii']`. - `serializers()`: `list<XmlSerializer>` for syntaxes the core does not write; a serializer replaces the one of its syntax. Germany brings XRechnung this way (`Quittio\Country\DE\Formats\XRechnungFormats`). ### Capabilities of your profiles Profiles declare what they can transmit with interfaces in `Quittio\Core\Profiles\Capabilities`, instead of the core checking profile keys: | Capability | Effect | |---|---| | `SupportsSubLines` | sub lines are allowed (no `QUITTIO-PROFILE-SUBLINES`) and the invoice is not upgraded to EXTENDED | | `SupportsExtensionFields` | `extensions()` names the extensions whose fields the profile carries, e.g. `['xrechnung']` for the fields of `XRechnungExtensionData` | | `SupportsThirdPartyPayments` | UBL invoices of the profile may carry third party payments (BG-DEX-09) | | `DescribesEmbeddedXml` | XMP description and version of the embedded XML | | `ReplacesRules` | `replacedRules(?Syntax $syntax)` names built-in rules the profile replaces with its own; the PHP rules driver does not run them for the profile | | `RequiresVatBreakdownRate`, `StructuredCashDiscountText`, `ExtendsCodeLists` | rate in every VAT breakdown, structured cash discount texts, additional codes | ### Builder macros of your pack A pack that offers builder helpers registers one macro named after its code, which returns an object with the helpers: `InvoiceBuilder::macro('at', fn () => new AustrianInvoice($this))`, used as `->at()->…`. Germany uses `->de()` ([`GermanInvoice`](#germany-quittiocountry-de)). Ship an IDE stub for the macro, as `packages/country-de/stubs/InvoiceBuilder.stub.php` does. ### Other hooks of your pack - `paymentQr()`: a `Quittio\Core\Pdf\Qr\PaymentQrGenerator` (`key()`, `supports(InvoiceData)`, `payload(InvoiceData, array $options = []): ?string`) for the QR mode `auto`. - `addressFormatter()`: a `Quittio\Core\View\AddressFormatter` (`format(Address $address, array $nameLines = [], ?string $senderCountry = null, ?string $locale = null): list<string>`). - `profiles()`: national profiles, usually extending `Quittio\Core\Profiles\AbstractProfile`. They are registered with the pack. - `referenceRates()` (capability `ProvidesReferenceRates`): the reference interest rate of the late payment law, so that `Quittio\Core\Dunning\DefaultInterest::forCountry($pack)` calculates default interest ([DunningLaw](#dunninglaw)). - `complete()` (capability `CompletesInvoices`): adds what the law of the country expects to an invoice before it is rendered, e.g. a notice for consumers. It receives the settings of the pack (`quittio.countries.{code}`, core: `Quittio::create(['countries' => ['{code}' => [...]]])`). Germany adds the default notice for consumers ([Default notice for consumers](#default-notice-for-consumers)). ### Settings of your pack A pack that needs settings in Laravel (rates, credentials of a national portal, …) keeps them under `quittio.countries.{code}` with its lower-case code, as the German pack does with `quittio.countries.de` ([Configuration](configuration.md#settings-of-a-pack-quittiocountriescode)). Do not add a top-level configuration such as `quittio-at`. In the pack's service provider: ```php namespace Acme\CountryAT\Laravel; use Illuminate\Support\ServiceProvider; final class AustriaServiceProvider extends ServiceProvider { public function register(): void { // Defaults; the keys of config/quittio/countries/at.php or of 'countries' => ['at' => […]] win. $this->mergeConfigFrom(__DIR__.'/../../config/countries/at.php', 'quittio.countries.at'); } public function boot(): void { if ($this->app->runningInConsole()) { // quittio:install publishes every tag quittio-{code}-config. $this->publishes([__DIR__.'/../../config/countries/at.php' => $this->app->configPath('quittio/countries/at.php')], 'quittio-at-config'); } } } ``` - Ship the defaults as `config/countries/{code}.php` and publish them to `config/quittio/countries/{code}.php`; Laravel loads that file as `quittio.countries.{code}`. - Name the publish tag `quittio-{code}-config`, so that `php artisan quittio:install` publishes it with `config/quittio.php`. - Read the settings with `config('quittio.countries.at.…')`, and only in Laravel code (the service provider, commands); the pack class itself takes its values as constructor arguments or through `Quittio\Core` contracts, so it works without Laravel. - Declare the provider in `composer.json` (`extra.laravel.providers`), as `quittio/country-de` does with `GermanyServiceProvider`. ## The `CountryPack` contract Every method of `Quittio\Core\Countries\CountryPack`, its default in `AbstractCountryPack` and where Quittio uses it: | Method | Returns | Default in `AbstractCountryPack` | Used by | |---|---|---|---| | `code()` | ISO 3166-1 alpha-2 code, e.g. `DE` | – (abstract) | registry key, translation namespace `quittio-{code}` | | `defaults()` | [`CountryDefaults`](#countrydefaults) | `new CountryDefaults` | locale fallback, paper size, default letter layout | | `taxPresets()` | `TaxPresetCollection` | empty | lookup of presets by key; presets are never applied automatically | | `rules()` | `list<Rule>` | `[]` | validation, when the pack leads | | `buyerCountryRules()` | `list<Rule>` | `[]` | validation, when the pack is the buyer's pack of a cross-border invoice | | `profiles()` | `list<Profile>` | `[]` | profile registry (national CIUS, i.e. national rule sets on top of EN 16931 such as XRechnung) | | `formatRules()` | `list<FormatRule>` | `[]` | automatic format choice | | `mandatoryOutput(InvoiceData $invoice)` | [`MandatoryFieldList`](#mandatory-output) | empty | mandatory field guard (leading pack only) | | `legalTexts()` | [`LegalTextCatalog`](#legaltextcatalog) | empty | the pack's own helpers and your code; Quittio itself does not read it | | `numberingRules()` | [`NumberingRules`](#numberingrules) | `new NumberingRules` | Managed numbering | | `retention()` | [`RetentionRule`](#retentionrule) | `new RetentionRule(10)` | Managed retention | | `dunningLaw()` | [`DunningLaw`](#dunninglaw) | `new DunningLaw` | `Dunning\DefaultInterest::forCountry()`; reminders take fees and interest explicitly | | `correctionPolicy()` | [`CorrectionPolicy`](#correctionpolicy) | `new CorrectionPolicy` | `Quittio::cancellation()`, Managed corrections | | `paymentQr()` | `?PaymentQrGenerator` | `null` | payment QR code of the QR mode `auto`, after a generator registered with `setPaymentQrGenerator()` and unless `CountryDefaults::$paymentQr` is `none`; null falls back to the EPC GiroCode for `girocode` (see [`CountryDefaults`](#countrydefaults)) | | `addressFormatter()` | `AddressFormatter` | `InternationalAddressFormatter` | address lines of the view model | | `letterLayouts()` | `array<string, LetterLayout>` | `['free' => LetterLayout::free()]` | position of the address field and marks | | `exporters()` | `list<Exporter>` | `[]` | declared for accounting exports of the Managed layer (`Exporter::key()`); not read in this release | | `readers()` | `list<FormatReader>` | `[]` | readers for national formats. `read()`, `readFile()` and `validateFile()` try them after the built-in CII and UBL readers, for every registered pack. | Optional capabilities (the interface gets new methods only in a major release, new abilities come as capabilities): | Capability | Methods | Default in `AbstractCountryPack` | Used by | |---|---|---|---| | `Capabilities\ProvidesFormats` | `formats()`, `formatAliases()`, `serializers()` | implemented, empty | `Quittio::registerCountry()` ([Formats of your pack](#formats-of-your-pack)) | | `Capabilities\ProvidesReferenceRates` | `referenceRates(): Dunning\ReferenceRates` | not implemented | `Dunning\DefaultInterest::forCountry()` | | `Capabilities\CompletesInvoices` | `complete(InvoiceData $invoice, array $settings): InvoiceData` | not implemented | the render pipeline, for the leading pack, before calculation and validation; `$settings` are `Config::$countrySettings[code]` (`quittio.countries.{code}`) | | `translationPath()` | `?string` | `null` | directory with `{locale}/{group}.php` files, registered as namespace `quittio-{code}` | ### CountryDefaults `new CountryDefaults(currency: 'EUR', timezone: 'UTC', locale: 'en', paper: 'A4', letterLayout: 'free', profile: 'en16931', requiredLocales: [], paymentQr: 'girocode', vatPreset: null, smallBusinessVatPreset: null)` | Property | Default | Effect | |---|---|---| | `locale` | `en` | Last fallback for the render and validation locale: run option, invoice locale (`->locale()`), `quittio.defaults.locale`, then this value. | | `paper` | `A4` | Paper size unless the presentation or `pdf.paper` sets one. | | `letterLayout` | `free` | Key of `letterLayouts()` used when the presentation sets none (`pdf.layout`). | | `currency`, `profile` | `EUR`, `en16931` | Shown by `quittio:countries`; not applied to invoices. | | `timezone`, `requiredLocales` | `UTC`, `[]` | Informational metadata for applications; not applied by the core. Set the time zone of dates with `->timezone()` on the builder. | | `paymentQr` | `girocode` | What the QR mode `auto` prints when no generator is registered with `setPaymentQrGenerator()`: `girocode` = the pack's `paymentQr()` generator, otherwise the EPC GiroCode; `none` = no code; another type (e.g. `swiss-qr-bill`) = the pack's generator, otherwise no code. See [Templates: payment QR codes](templates.md#payment-qr-codes). | | `vatPreset`, `smallBusinessVatPreset` | `null`, `null` | Keys of presets of `taxPresets()` for invoice lines without VAT treatment: the usual rate, and the rate of small business invoices (`Meta::FLAG_SMALL_BUSINESS`). Used by `CountryDefaultVat` for the seller's country ([Default VAT](building-invoices.md#default-vat)). Germany: `de.standard` and `de.small_business`. | ### CorrectionPolicy The default handling of cancellations and corrections (see [Managed: cancellations and corrections](managed.md#cancellations-and-corrections)). | Member | Meaning | |---|---| | `CANCELLATION_CREDIT_NOTE` = `credit_note` | cancel with type code 381 and positive amounts | | `CANCELLATION_NEGATIVE_INVOICE` = `negative_invoice` | cancel with type code 380 and negative amounts | | `CORRECTION_CANCEL_AND_REISSUE` = `cancel_and_reissue` | correct by cancelling and issuing a new invoice | | `CORRECTION_CORRECTED_INVOICE` = `corrected_invoice` | correct with a corrected invoice (type code 384) | | `__construct(string $cancellationStrategy = 'credit_note', string $correctionStrategy = 'cancel_and_reissue', array $titles = [])` | `$titles`: document kind => [locale => title] | | `title(string $kind, string $locale = 'en'): ?string` | title in the locale, else English, else null | | `cancellationTitle(bool $selfBilled, string $locale = 'en'): ?string` | `cancellation_self_billed` for self-billed originals if defined, otherwise `cancellation` | The kinds Quittio reads: - `cancellation` and `cancellation_self_billed`: the title of `Quittio::cancellation()`; - `correction`: the title of a Managed corrected invoice; - `self_billed`: the PDF/HTML title and file name of self-billed invoices, after a title set in the presentation. The sign strategy of a cancellation comes from the call, then `quittio.corrections.cancellation_strategy`, then the pack. The correction strategy comes from `quittio-managed.correction.strategy`, then the pack. ### DunningLaw Statutory late payment values; amounts and percentage points are decimal strings. | Property | Default | Meaning | |---|---|---| | `b2bInterestPoints` | `8.00` | points above the reference rate for business debtors | | `b2cInterestPoints` | `0.00` | points above the reference rate for consumers | | `b2bFlatRate` | `40.00` | flat rate for business debtors (null = none) | | `dayCount` | `365` | day count basis: 365, 360 or `null` for actual/actual (Germany) | | `consumerDefaultAfterDays` | `null` | days after which a consumer is in default | | `referenceRateName` | `null` | name of the reference rate | | `b2cFixedRate` | `null` | fixed rate in percent for consumers instead of the reference rate plus `b2cInterestPoints`, e.g. `4.00` in Austria (section 1000 (1) ABGB); `DefaultInterest` then charges it for the whole time | | `b2bFixedRate` | `null` | fixed rate in percent for business debtors instead of the reference rate plus `b2bInterestPoints`, e.g. `5.00` in Switzerland (Art. 104 OR) | Quittio's documents do not read these values. `Quittio\Core\Dunning\DefaultInterest` calculates default interest from them and the reference rates of a pack that implements `Countries\Capabilities\ProvidesReferenceRates` (`referenceRates(): Dunning\ReferenceRates` with `rateOn()` and `periods()`): `DefaultInterest::forCountry($pack)->calculate($amount, $from, $until)`. A pack without reference rates works only when its law fixes both rates (`DunningLaw::hasFixedRates()`, e.g. Switzerland); otherwise `forCountry()` throws a `ConfigurationException`. Germany provides the Basiszinssatz this way ([`DefaultInterest`](#default-interest)); a pack of another country implements `ReferenceRates`, e.g. for the ECB main refinancing rate, on top of `Quittio\Core\Support\DatedValues`. ### NumberingRules Used by Managed numbering (see [Managed: numbering](managed.md#numbering)). | Property | Default | Meaning | |---|---|---| | `defaultPattern` | `INV-{Y}-{seq:4}` | pattern when neither the issuer nor the configuration sets one | | `defaultReset` | `yearly` | reset when none is configured | | `allowedResets` | `['never', 'yearly', 'monthly']` | other resets are rejected with a `ConfigurationException` | | `gapless` | `true` | declared; not read in this release (see [gapless numbers](managed.md#gapless-numbers)) | | `numberConsumedOnRejection` | `true` | declared; not read in this release | ### RetentionRule `new RetentionRule(int $years, bool $fromEndOfCalendarYear = true)`. `until(Date $issueDate): Date` returns the last day of the retention period: 31 December of the issue year plus `$years`, or, with `fromEndOfCalendarYear: false`, the issue date plus `$years`. The Managed layer stores this date with every issued invoice; `quittio-managed.retention.years` may only lengthen it. ### LegalTextCatalog `new LegalTextCatalog(array $texts = [], string $fallbackLocale = 'en')` with `$texts` as key => [locale => text]. - `has(string $key): bool` - `get(string $key, ?string $locale = null, array $replace = []): ?string`: the text in `$locale`, else in the fallback locale, else the first variant; null for unknown keys. `:name` placeholders are replaced from `$replace`. ### Mandatory output `mandatoryOutput()` names values the rendered PDF must show for one invoice, in addition to the base fields every PDF needs. After rendering, the mandatory field guard checks that the template printed them (see [Templates: mandatory field guard](templates.md#mandatory-field-guard)). `new MandatoryField(string $accessKey, string $description, ?string $legalBasis = null)`. The access key is a view model path: - `|` separates alternatives, `&` combines paths that must all be printed; - `[*]` stands for every index, e.g. `vatRows[*].amount`; - a path counts only where the view model has a value: null values and empty lists are not required, and a field whose alternatives all have no value is skipped. `MandatoryFieldList::merge()` combines two lists; for equal access keys the later field wins. `MandatoryFieldGuard::notePath($invoice, $matches)` returns the view model path of the first note that matches a callback (`legalNotes[i]` for regulatory, legal and tax notes, `notes[i].content|notes[i].html` otherwise), so that a pack can require a specific note. ### Letter layouts `letterLayouts()` returns `Quittio\Core\View\LetterLayout` objects by name. `CountryDefaults::$letterLayout` names the default; the presentation property `letterLayout` (Laravel: `pdf.layout`) selects another one. `free` is always available; an unknown name throws a `ConfigurationException`. Values are millimetres from the top left corner of the first page: | Property | Default | Meaning | |---|---|---| | `name` | – | layout key | | `addressTop`, `addressLeft` | 45.0, 20.0 | position of the address field | | `addressWidth`, `addressHeight` | 85.0, 45.0 | size of the address field | | `senderLineHeight` | 5.0 | height of the sender line above the recipient | | `addressZoneTop` | 17.7 | distance of the recipient address from the top of the field | | `foldMarks` | `[]` | distances of the fold marks from the top edge | | `punchMark` | null | distance of the punch mark | `letterheadHeight(float $pageMarginTop)` returns the space above the address field: `addressTop` minus the top page margin (15 mm on the first page in the default templates). See [Templates: letter layouts](templates.md#letter-layouts) for how the default templates use them; the German layouts are in [DIN 5008 letter layouts](#din-5008-letter-layouts). ### VatTerritory `Quittio\Core\Countries\VatTerritory` tells the EU VAT territory (Art. 5 to 7 of Directive 2006/112/EC) from a country code and a postcode. The format resolver, the German rules and the core plausibility checks use it; packs can use it in their own rules. | Method / constant | Result | |---|---| | `EU_MEMBER_STATES` | the 27 member states (Greece is `GR`) | | `NORTHERN_IRELAND` | `XI` | | `vatCountry(string $country): string` | the country whose VAT territory a country belongs to: `MC` → `FR`, `IM` → `GB`, `EL` → `GR`; outside the EU `LI` → `CH` (one area of application of the Swiss and Liechtenstein VAT) | | `isEuMemberState(string $country): bool` | member state after `vatCountry()` | | `excludedTerritory(string $country, ?string $postcode): ?string` | name of an excluded territory the address lies in, or null | | `isEuVatTerritory(string $country, ?string $postcode = null, bool $goods = true): bool` | address inside the EU VAT territory | | `memberState(string $country, ?string $postcode = null, bool $goods = true): ?string` | member state of the address (`XI` for Northern Ireland and goods), null outside | | `sameVatTerritory(string $country, ?string $postcode, string $otherCountry, ?string $otherPostcode): bool` | same VAT territory, e.g. `FR` and `MC`, but not `DE` and Büsingen | | `isNorthernIreland(string $country, ?string $postcode = null): bool` | `XI`, or `GB` with a `BT` postcode | | `memberStateOfVatId(string $vatId): ?string` | member state of a VAT identifier prefix (`EL` → `GR`, `XI` stays `XI`), null otherwise (also for the prefix `GR`) | Northern Ireland belongs to the territory for goods only (`$goods = false` excludes it). Territories that are excluded and recognised by postcode: - Germany: Büsingen am Hochrhein (78266) and Heligoland (27498); - Spain: the Canary Islands (35xxx, 38xxx), Ceuta (51xxx) and Melilla (52xxx); - Italy: Livigno (23041) and Campione d'Italia (22061); - Finland: the Åland Islands (22xxx); - Greece: Mount Athos (63086); - France: the overseas territories (97xxx, 981xx to 989xx; Monaco 980xx stays France). Territories without a distinct postcode (e.g. the part of Cyprus not controlled by the government) cannot be detected. <!-- Source: https://quittio.dev/docs/country-at --> # Austria (`quittio/country-at`) > **Not reviewed by a tax adviser yet.** The legal wording, rules and defaults of this pack follow the law and the official sources as of October 2026, but have not been reviewed by an Austrian tax adviser. Check the mentions and rates of your invoices before you rely on them. Quittio is no tax or legal advice; the business that issues an invoice remains responsible for it. Until the review the pack is not covered by the [compatibility promise](compatibility.md#country-packs-without-tax-review): a minor release may change it. The Austrian pack implements the mandatory invoice information of the Austrian VAT act (UStG 1994, Umsatzsteuergesetz), the Austrian national CIUS of EN 16931 (CIUS-AT-NAT, and CIUS-AT-GOV for the federal government), the Austrian XML invoice format ebInterface and the Austrian law on late payment. Its class is `Quittio\Country\AT\CountryAT` (code `AT`, translation namespace `quittio-at`). - **Legal references.** This page writes Austrian legal references in English form: "section 11 (1) no. 3 lit. a UStG" stands for "§ 11 Abs. 1 Z 3 lit. a UStG", and "Art. 6 UStG" for an article of the annex to the UStG (the Binnenmarktregelung, the rules for the EU single market). Other laws cited are the Commercial Code (UGB, Unternehmensgesetzbuch), the Civil Code (ABGB, Allgemeines bürgerliches Gesetzbuch) and the Federal Fiscal Code (BAO, Bundesabgabenordnung). Values that the pack stores or prints in German keep their German form. - **Terms.** The UID (Umsatzsteuer-Identifikationsnummer) is the Austrian VAT identifier, e.g. `ATU12345678`. A Gutschrift is a self-billed invoice, a Kleinunternehmer a small business that charges no VAT. e-Rechnung.gv.at is the portal of the federal government for incoming e-invoices, run by the Bundesrechenzentrum (BRZ) for the Federal Ministry of Finance (BMF). - **Not part of `quittio/quittio`.** The pack is a package of its own, released with the same version as the rest of Quittio. If EN 16931, profile or CIUS are new to you, read [E-invoicing basics](concepts.md) first. ## Installation ```bash composer require quittio/country-at ``` The pack needs PHP 8.3 and `quittio/core` of the same version. It is not part of `quittio/quittio`; install it next to `quittio/quittio` (Laravel) or next to `quittio/core` (without Laravel). It is developed in the monorepo [Quittio/quittio](https://github.com/Quittio/quittio/tree/master/packages/country-at) and published as the read-only repository [Quittio/country-at](https://github.com/Quittio/country-at); please open issues and pull requests in the monorepo. **Laravel.** The pack declares itself in its `composer.json` under `extra.quittio.country-packs` (`Quittio\Country\AT\CountryAT`), so Laravel registers it after `composer require` without further steps ([Registering packs: Laravel](country-packs.md#laravel)). `php artisan quittio:countries` lists it. The pack has no service provider, no configuration file and no settings under `quittio.countries.at`. To invoice as an Austrian company, set your seller in `config/quittio.php` ([Your company](configuration.md#your-company)) with the country `AT`: ```php // config/quittio.php 'seller' => [ 'name' => 'Donau Werkstatt GmbH', 'vat_id' => 'ATU12345678', // UID 'address' => [ 'line1' => 'Mariahilfer Straße 1', 'postcode' => '1060', 'city' => 'Wien', 'country' => 'AT', ], 'bank_accounts' => [ ['iban' => 'AT611904300234573201', 'bic' => 'BKAUATWW', 'name' => 'Donau Werkstatt GmbH'], ], ], ``` `Quittio::invoice()` then starts every invoice with this seller, and lines without `vat:` get the standard rate of 20 % ([Default VAT](building-invoices.md#default-vat)). **Without Laravel.** Pass the pack to `Quittio::create()` ([Registering packs: without Laravel](country-packs.md#without-laravel)): ```php use Quittio\Core\Builder\InvoiceBuilder; use Quittio\Core\Quittio; use Quittio\Core\Tax\CountryDefaultVat; use Quittio\Country\AT\CountryAT; $quittio = Quittio::create(['country' => 'AT'], [new CountryAT]); InvoiceBuilder::useDefaultVat(new CountryDefaultVat($quittio->countries())); // lines without vat(): 20 % ``` Registering the pack adds it to the country registry, registers its profiles `cius-at-nat` and `cius-at-gov`, makes its ebInterface reader available to `read()` and `validateFile()`, and registers `resources/lang` as the translation namespace `quittio-at`. The option `country` is only the default for invoices whose seller has no country code. ## When it applies The pack leads every invoice whose seller is in Austria (seller country code BT-40 `AT`), or whose run names it (`->country('AT')`). It then checks the [UStG rules](#ustg-rules), chooses the format for Austrian public buyers ([Format choice](#format-choice)) and provides the [defaults](#defaults): German as language (unless the invoice or the configuration sets one), A4 paper, the free letter layout and the EPC GiroCode. For an invoice from another country to a buyer in Austria, only the format rule of the pack applies: a buyer with an Austrian organisation number receives UBL after CIUS-AT-GOV, whatever the seller's country. The UStG rules are not applied to such invoices. Details are in [How a pack is selected](country-packs.md#how-a-pack-is-selected). Without the pack, an Austrian seller gets the generic pack: EN 16931 rules only, and the warning `QUITTIO-GENERIC-COUNTRY`. ## Common tasks | You want to | Read | |---|---| | Build, render and validate a typical Austrian invoice | [Complete example](#complete-example) | | Set the VAT rate or an exemption on a line | [Tax presets](#tax-presets) | | Invoice as a small business without VAT (Kleinunternehmer) | [Small businesses](#small-businesses) | | Invoice a business in another EU country | [Reverse charge and intra-community supplies](#reverse-charge-and-intra-community-supplies) | | Issue an invoice of up to 400 EUR with fewer details | [Simplified invoices](#simplified-invoices) | | Look up a validation code such as `AT-USTG-05` or `AT-GOV-01` | [UStG rules](#ustg-rules), [Profiles](#profiles) | | Invoice the federal government (e-Rechnung.gv.at) | [Format choice](#format-choice), [Profiles](#profiles) | | Write or read ebInterface | [ebInterface](#ebinterface) | | Issue a self-billed invoice (Gutschrift) | [Self-billing](#self-billing-gutschrift) | | Cancel or correct an invoice | [Cancellations and corrections](#cancellations-and-corrections) | | Send a reminder with default interest | [Late payment](#late-payment) | | Change a text of the pack | [Translations](#translations) | ## Complete example An invoice of an Austrian company to an Austrian business, without Laravel. It is rendered as ZUGFeRD with the profile EN 16931 (the [automatic format choice](formats.md#automatic-choice) for a domestic business invoice), in German, and validated with the EN 16931 and UStG rules: ```php use Quittio\Core\Builder\InvoiceBuilder; use Quittio\Core\Builder\Party; use Quittio\Core\Enums\PaymentMeansCode; use Quittio\Core\Enums\UnitCode; use Quittio\Core\Quittio; use Quittio\Core\Tax\CountryDefaultVat; use Quittio\Country\AT\CountryAT; use Quittio\Country\AT\Tax\VatPreset; $quittio = Quittio::create(['country' => 'AT'], [new CountryAT]); InvoiceBuilder::useDefaultVat(new CountryDefaultVat($quittio->countries())); // lines without vat(): 20 % $invoice = InvoiceBuilder::make() ->number('RE-2026-0042') ->issueDate('2026-10-05') ->deliveryDate('2026-09-30') // date of the supply (AT-USTG-04) ->seller(Party::make('Donau Werkstatt GmbH') ->vatId('ATU12345678') // UID of the seller (AT-USTG-03) ->address('Mariahilfer Straße 1', '1060', 'Wien', 'AT') ->contact('Anna Huber', '+43 1 234567', 'rechnung@donau-werkstatt.example')) ->buyer(Party::make('Tiroler Handel KG') ->vatId('ATU87654321') // required above 10,000 EUR gross (AT-USTG-05) ->address('Maria-Theresien-Straße 10', '6020', 'Innsbruck', 'AT')) ->line('Softwareentwicklung', netPrice: '100.00', quantity: 12, unit: UnitCode::Hour) // 20 % ->line('Fachbuch', netPrice: '45.00', vat: VatPreset::Reduced) // 10 % ->paymentTerms(fn ($terms) => $terms->dueInDays(14)) ->payment(PaymentMeansCode::SepaCreditTransfer, iban: 'AT611904300234573201', bic: 'BKAUATWW') ->build(); $result = $quittio->make($invoice)->render(); $result->format(); // "zugferd" $result->profile()?->key(); // "en16931" $result->validation()->isValid(); // true: no errors (and here no warnings either) $result->data()->totals?->grossTotal; // EUR 1489.50 $result->save(__DIR__.'/invoices/'); // invoices/Rechnung_RE-2026-0042.pdf ``` `render()` throws a `ValidationException` when a rule reports an error, e.g. `AT-USTG-04` without a delivery date ([Validation](validation.md)). The PDF carries a GiroCode for the transfer ([Payment QR code](#payment-qr-code)). In Laravel, start with `Quittio::invoice()` instead of `InvoiceBuilder::make()->seller(…)`; the rest of the chain is the same. ## Tax presets A tax preset is a ready-made VAT treatment for an invoice line. It sets the VAT category (BT-151) and the rate, and for exempt supplies also the exemption reason code (BT-121) and text (BT-120). Use a preset instead of a bare category and rate: the line then carries the wording the UStG requires, and the Austrian rules recognise the case. Lines without `vat:` take the [default VAT](building-invoices.md#default-vat): `VatPreset::Standard` for an Austrian seller, `VatPreset::SmallBusiness` for a small business. The categories are the codes of EN 16931: `S` standard rate, `E` exempt, `AE` reverse charge, `K` intra-community supply, `G` export outside the EU, `O` not subject to VAT (see [Categories](building-invoices.md#categories)). `Quittio\Country\AT\Tax\VatPreset` is a string-backed enum that implements `DatedTaxPreset`. Apply it per line: ```php use Quittio\Core\Builder\InvoiceBuilder; use Quittio\Core\Enums\UnitCode; use Quittio\Country\AT\Tax\VatPreset; $builder = InvoiceBuilder::make() // ... number, dates, seller and buyer as in the complete example ->line('Softwareentwicklung', netPrice: '100.00', quantity: 12, unit: UnitCode::Hour, vat: VatPreset::Standard) // 20 % ->line('Fachbuch', netPrice: '45.00', vat: VatPreset::Reduced) // 10 % ->line('Milch', netPrice: '1.50', quantity: 10, unit: UnitCode::Litre, vat: VatPreset::BasicFood) // 4.9 % for a supply from 1 July 2026 // an exemption without its own case: the legal reference; // the invoice prints "Steuerfrei gemäß § 6 Abs. 1 Z 19 UStG" ->line('Ärztliche Leistung', netPrice: '300.00', vat: VatPreset::exempt('§ 6 Abs. 1 Z 19 UStG')); ``` | Case | Key | Category | Rate | Code (BT-121) | Use | |---|---|---|---|---|---| | `Standard` | `at.standard` | `S` | 20 | – | Standard rate (section 10 (1) UStG) | | `Reduced` | `at.reduced` | `S` | 10 | – | Reduced rate (section 10 (2) UStG) | | `Reduced13` | `at.reduced_13` | `S` | 13 | – | Second reduced rate (section 10 (3) UStG) | | `BasicFood` | `at.basic_food` | `S` | 4.9 from 1 July 2026, 10 before (by supply date) | – | Basic foods (section 10 (1a) UStG, BGBl. I Nr. 37/2026) | | `SmallBusiness` | `at.small_business` | `E` | 0 | – | Small business exemption (Kleinunternehmer, section 6 (1) no. 27 UStG); see [Small businesses](#small-businesses) | | `ReverseChargeDomestic` | `at.reverse_charge_domestic` | `AE` | 0 | `VATEX-EU-AE` | Domestic reverse charge (section 19 (1a) to (1e) UStG): the buyer in Austria owes the VAT | | `ReverseChargeEu` | `at.reverse_charge_eu` | `AE` | 0 | `VATEX-EU-AE` | Service to a business in another member state, which owes the VAT there (section 19 (1) sentence 2 UStG). Issue the invoice by the 15th of the following month (`AT-USTG-12`). | | `IntraCommunitySupply` | `at.intra_community_supply` | `K` | 0 | `VATEX-EU-IC` | VAT-exempt intra-community supply (Art. 6 (1) with Art. 7 UStG) | | `TriangularTransaction` | `at.triangular_transaction` | `AE` | 0 | `VATEX-EU-AE` | Intra-community triangular transaction (Art. 25 UStG), in which the last customer owes the VAT | | `Export` | `at.export` | `G` | 0 | `VATEX-EU-G` | VAT-exempt export supply (section 6 (1) no. 1 with section 7 UStG) | | `NotTaxableInAustria` | `at.not_taxable` | `O` | none | `VATEX-EU-O` | Supply not taxable in Austria (place of supply abroad) | | `MarginSecondHand` | `at.margin_second_hand` | `E` | 0 | `VATEX-EU-F` | Margin scheme, second-hand goods (section 24 UStG) | | `MarginArt` | `at.margin_art` | `E` | 0 | `VATEX-EU-I` | Margin scheme, works of art (section 24 UStG) | | `MarginAntiques` | `at.margin_antiques` | `E` | 0 | `VATEX-EU-J` | Margin scheme, collectors' items and antiques (section 24 UStG) | | `TravelAgency` | `at.travel_agency` | `E` | 0 | `VATEX-EU-D` | Margin scheme of travel agencies (section 23 UStG) | | `VatPreset::exempt(string $paragraph, $code = null)` | `at.exempt` | `E` | 0 | `$code` (enum, raw code or string) | Any other exemption, e.g. `§ 6 Abs. 1 Z 19 UStG` | The codes in column BT-121 are VATEX codes: the standard codes for the reason of an exemption. `SmallBusiness` has none. `BasicFood` takes the rate that applied on the supply date of the line (`TaxTables::BASIC_FOOD_RATE`): a delivery on 30 June 2026 gets 10 %, one on 1 July 2026 gets 4.9 %. The supply date is found as for the German presets ([Germany: tax presets](country-packs.md#tax-presets)): the end of the line period, its start, the VAT point date, the delivery date, the end of the invoicing period or the issue date. `VatPreset::BasicFood->rate()` returns the rate of today in Vienna. The other rates are fixed (`TaxTables::STANDARD_RATE`, `REDUCED_RATE`, `REDUCED_RATE_13`). ### Exemption texts `Standard`, `Reduced`, `Reduced13` and `BasicFood` carry no text, because EN 16931 forbids an exemption reason for taxed supplies (BR-S-10). The other presets print an exemption reason (BT-120) in German or English, from `resources/lang/{de,en}/tax.php`: | Key | German | English | |---|---|---| | `at.small_business` | Umsatzsteuerfrei aufgrund der Kleinunternehmerregelung (§ 6 Abs. 1 Z 27 UStG). | VAT exempt under the small business scheme (section 6 (1) no. 27 UStG). | | `at.reverse_charge_domestic` | Übergang der Steuerschuld auf den Leistungsempfänger (§ 19 UStG) | Reverse charge: the recipient owes the VAT (section 19 UStG) | | `at.reverse_charge_eu` | Übergang der Steuerschuld auf den Leistungsempfänger (Reverse Charge) | Reverse charge: the recipient owes the VAT | | `at.intra_community_supply` | Steuerfreie innergemeinschaftliche Lieferung (Art. 6 Abs. 1 i. V. m. Art. 7 UStG) | VAT exempt intra-community supply (Art. 6 (1) with Art. 7 UStG) | | `at.triangular_transaction` | Innergemeinschaftliches Dreiecksgeschäft gemäß Art. 25 UStG; Übergang der Steuerschuld auf den letzten Abnehmer | Intra-community triangular transaction under Art. 25 UStG; the VAT is owed by the last customer | | `at.export` | Steuerfreie Ausfuhrlieferung (§ 6 Abs. 1 Z 1 i. V. m. § 7 UStG) | VAT exempt export supply (section 6 (1) no. 1 with section 7 UStG) | | `at.not_taxable` | Nicht im Inland steuerbare Leistung (Leistungsort im Ausland) | Not taxable in Austria (place of supply abroad) | | `at.margin_second_hand` | Differenzbesteuerung – Gebrauchtgegenstände/Sonderregelung | Margin scheme – Second-hand goods | | `at.margin_art` | Differenzbesteuerung – Kunstgegenstände/Sonderregelung | Margin scheme – Works of art | | `at.margin_antiques` | Differenzbesteuerung – Sammlungsstücke und Antiquitäten/Sonderregelung | Margin scheme – Collector's items and antiques | | `at.travel_agency` | Sonderregelung für Reisebüros (§ 23 UStG) | Margin scheme – Travel agents (section 23 UStG) | | `at.exempt` | Steuerfrei gemäß :paragraph | VAT exempt under :paragraph | ### How presets behave - **Language.** The text is taken in the invoice locale (`->locale()` on the builder) when the line is built. Without a locale it is German. The enum cases take German for regional locales such as `de_AT` and English for locales the pack does not ship (e.g. `fr`). `VatPreset::exempt()` (a `Quittio\Country\AT\Tax\CustomVatPreset`) behaves the same: German without a locale and for `de_AT`. - **Preset key.** The key stays on the line (`$line->vat->presetKey`). The small business detection (`AT-USTG-08`) and the deadline of `AT-USTG-12` rely on it. - **VAT breakdown.** Category, rate, code and text flow into the VAT breakdown (BG-23). The PDF lists the exemption texts in its legal notes. - **No invoice notes.** Unlike some German presets, the Austrian presets add no invoice note (BT-22); the exemption text is in BT-120 only. - **Allowances and charges.** Document level allowances and charges take a category and a rate, not a preset: `->charge(VatCategory::StandardRate, '20', amount: '10.00', reason: 'Versand')`. - **Lookup by key**, e.g. from a database column: `VatPreset::from('at.standard')`, `VatPreset::fromKey($key)` (null for keys of other packs), `(new CountryAT)->taxPresets()->get('at.standard')` or, across all installed packs, `$quittio->countries()->taxPreset('at.standard')`. `at.exempt` is not part of the collection. In Laravel, `quittio.defaults.vat` takes a key, e.g. `'at.reduced'` ([Defaults](configuration.md#defaults)). ## Small businesses A small business (Kleinunternehmer) applies the exemption of section 6 (1) no. 27 UStG and must not show VAT on its invoices (section 11 (12) UStG). Three steps make an invoice a small business invoice in Quittio: 1. **Mark the seller as a small business.** Set `quittio.seller.small_business = true` in Laravel ([Small businesses](configuration.md#small-businesses)), `'small_business' => true` in `Quittio::create()` without Laravel (applied by `Quittio::invoice()` and `$quittio->invoice()`), or `->flag(Meta::FLAG_SMALL_BUSINESS)` on the builder. 2. **Use `VatPreset::SmallBusiness` on every line.** Lines without `vat:` get it automatically when the invoice has the flag and the default VAT comes from the country pack (`CountryDefaultVat`; in Laravel always). A line with this preset also marks the invoice as small business invoice, without the flag. 3. **Identify the seller without a UID.** EN 16931 requires the seller's VAT identifier or tax number (BT-32) for category `E` (BR-E-02), and a VAT identifier, seller identifier (BT-29) or legal registration (BT-30) so that the buyer can identify the seller (BR-CO-26). ```php use Quittio\Core\Builder\InvoiceBuilder; use Quittio\Core\Builder\Party; use Quittio\Core\Data\Meta; use Quittio\Core\Enums\PaymentMeansCode; use Quittio\Core\Quittio; use Quittio\Core\Tax\CountryDefaultVat; use Quittio\Country\AT\CountryAT; $quittio = Quittio::create([], [new CountryAT]); InvoiceBuilder::useDefaultVat(new CountryDefaultVat($quittio->countries())); $invoice = InvoiceBuilder::make() ->number('RE-2026-0007') ->issueDate('2026-10-05') ->deliveryDate('2026-10-01') ->flag(Meta::FLAG_SMALL_BUSINESS) ->seller(Party::make('Grafikstudio Maria Berger') ->taxNumber('12 345/6789') // BT-32 (BR-E-02) ->identifier('L-4711') // BT-29, e.g. your supplier number at the buyer (BR-CO-26) ->address('Hauptplatz 3', '8010', 'Graz', 'AT')) ->buyer(Party::make('Steirische Bäckerei OG')->address('Herrengasse 5', '8010', 'Graz', 'AT')) ->line('Logo-Entwurf', netPrice: '650.00') // VatPreset::SmallBusiness through the default VAT ->paymentTerms(fn ($terms) => $terms->dueInDays(14)) ->payment(PaymentMeansCode::SepaCreditTransfer, iban: 'AT611904300234573201') ->build(); $result = $quittio->make($invoice)->render(); // "Umsatzsteuerfrei aufgrund der Kleinunternehmerregelung (§ 6 Abs. 1 Z 27 UStG)." ``` A small business invoice is a [simplified invoice](#simplified-invoices): it needs neither the buyer's address nor the UIDs. VAT on it is an error (`AT-USTG-08`). ## Reverse charge and intra-community supplies - **Services to a business in another member state.** Use `VatPreset::ReverseChargeEu`. The text names the transfer of the tax liability ("Übergang der Steuerschuld auf den Leistungsempfänger"), which `AT-USTG-06` requires. Issue the invoice by the 15th of the month after the service (`AT-USTG-12`). - **Domestic reverse charge.** Use `VatPreset::ReverseChargeDomestic` (section 19 (1a) to (1e) UStG). - **Intra-community supply of goods.** Use `VatPreset::IntraCommunitySupply`. EN 16931 also needs the country of the delivery address (BR-IC-12): `->deliverTo('Isar Consulting GmbH', Address::make('Leopoldstraße 20', '80802', 'München', 'DE'))`. - **VAT identifiers.** Reverse charge and intra-community supplies are never simplified invoices: the UIDs of seller and buyer are checked (`AT-USTG-03`, `AT-USTG-05`), and the [mandatory PDF output](#mandatory-pdf-output) requires the buyer's VAT identifier. ```php use Quittio\Core\Builder\InvoiceBuilder; use Quittio\Core\Builder\Party; use Quittio\Core\Enums\UnitCode; use Quittio\Country\AT\Tax\VatPreset; $builder = InvoiceBuilder::make() // ... number, dates and payment as in the complete example ->seller(Party::make('Donau Werkstatt GmbH')->vatId('ATU12345678')->address('Mariahilfer Straße 1', '1060', 'Wien', 'AT')) ->buyer(Party::make('Isar Consulting GmbH')->vatId('DE987654321')->address('Leopoldstraße 20', '80802', 'München', 'DE')) ->line('Beratung', netPrice: '120.00', quantity: 10, unit: UnitCode::Hour, vat: VatPreset::ReverseChargeEu); ``` Without a preset, `AT-USTG-06` accepts a BT-120 text of category `AE` that contains "Steuerschuld", "reverse charge", "reverse-charge", "autoliquidation", "inversione contabile" or the text of one of the reverse charge presets in any locale (case-insensitive). ## Simplified invoices `UstgRules::isSimplifiedInvoice($invoice)` decides whether the simplifications of section 11 (6) UStG apply. An invoice is simplified when it - is in euro and its gross total (BT-112) is at most 400 EUR (150 EUR for invoices issued before 1 March 2014, `TaxTables::SIMPLIFIED_INVOICE_LIMIT`), or - is a small business invoice ([Small businesses](#small-businesses)). Invoices with reverse charge (category `AE`) or an intra-community supply (`K`) are never simplified. A simplified invoice needs neither the buyer's name and address (`AT-USTG-02`) nor the UID of the seller (`AT-USTG-03`) or the buyer (`AT-USTG-05`), and `AT-USTG-10` does not apply. There is no builder macro: the rules recognise the case from the amounts and presets. ## UStG rules `UstgRules::all()` checks the mandatory information of section 11 UStG on every invoice whose leading pack is the Austrian one, in every format. The rules run at validation level L3 ([Validation levels](validation.md#validation-levels)). Switch single rules off or change their severity with `validation.rules` ([Switching rules off](validation.md#switching-rules-off-and-changing-their-severity)). | Code | Severity | Business term | Check | |---|---|---|---| | `AT-USTG-01` | error | BT-35, BT-38, BT-37 | Name and address of the seller: street, post code and city (section 11 (1) no. 3 lit. a UStG). | | `AT-USTG-02` | error | BT-50, BT-53, BT-52 | Name and address of the buyer: street and city, and the post code for a buyer in Austria (section 11 (1) no. 3 lit. b UStG). Not on [simplified invoices](#simplified-invoices). | | `AT-USTG-03` | error | BT-31 | UID of the seller, or of its tax representative (section 11 (1) no. 3 lit. i UStG). Not on simplified invoices, and not when all lines are of category `E` or `O` (supplies without input tax deduction). | | `AT-USTG-04` | error; warning for prepayment invoices (386) and their corrected invoices (384) | BT-72 | Date of the supply: delivery date (BT-72), invoicing period (BG-14) or a period on every line (BG-26) (section 11 (1) no. 3 lit. d UStG). Not for full or partial cancellations of a prepayment invoice that refer to it (flag `prepayment_correction` and BG-3, section 16 (3) no. 2 UStG). | | `AT-USTG-05` | error | BT-48 | UID of the buyer on an invoice in euro above 10,000 EUR gross (`TaxTables::BUYER_VAT_ID_LIMIT`) from a seller in Austria to a business (section 11 (1) no. 3 lit. b UStG). Not for consumers (`->consumer()`) and not on simplified invoices. | | `AT-USTG-06` | error | BT-120 | Every VAT row of category `AE` states that the recipient owes the VAT (section 11 (1a) UStG); see [Reverse charge](#reverse-charge-and-intra-community-supplies). | | `AT-USTG-07` | error | BT-120 | Every VAT row of category `E`, `K` or `G` has an exemption note as text; a code (BT-121) alone is not enough (section 11 (1) no. 3 lit. e UStG). | | `AT-USTG-08` | error | BT-117 | A small business invoice shows no VAT: every VAT row has a VAT amount of 0, and no row of category `S` a rate other than 0 (section 11 (12) UStG). | | `AT-USTG-09` | error; warning when the invoice is written as XML | BT-22 | A self-billed invoice (type codes 389, 261 and 527) has a note containing "Gutschrift" or an equivalent ("self-billing", "self-billed invoice", "autofacturation", "autofactura", "autofatturazione", "autofacturação", "zelffacturering", "samofakturowanie") (section 11 (8) no. 3 UStG). In an e-invoice the type code labels it, so there it is a warning. See [Self-billing](#self-billing-gutschrift). | | `AT-USTG-10` | warning | BT-6 | An invoice in another currency than euro states the VAT in euro: VAT accounting currency (BT-6) `EUR` and the VAT total in it (BT-111), set with `->taxCurrency('EUR', $rate)` (section 11 (1) no. 3 lit. f UStG). Only a warning, because the conversion method may be stated in a note, which the rule cannot read. Not on simplified invoices or without VAT. | | `AT-USTG-11` | warning | BT-2 | The invoice is issued more than six months after the supply (section 11 (1) no. 1 UStG). Not for consumers, credit notes (381, 261), corrected invoices (384), prepayment invoices (386) and invoices that refer to an earlier invoice without deducting a prepayment. The supply date is the latest of delivery date, end of the invoicing period and end of the line periods. | | `AT-USTG-12` | warning | BT-2 | An invoice for services in another member state with reverse charge is issued after the 15th of the month following the service (section 11 (1) no. 2 UStG). It applies to lines with `VatPreset::ReverseChargeEu`, and to lines of category `AE` without preset when the buyer is in another member state; the same exceptions as `AT-USTG-11`. | Late invoices stay valid, so `AT-USTG-11` and `AT-USTG-12` are warnings. Messages and hints exist in German and English ([Translations](#translations)). The rules also offer helpers for your own code: `UstgRules::isSimplifiedInvoice()`, `isSmallBusinessInvoice()`, `needsBuyerVatId()`, `hasServiceDate()` and `supplyDate()`. ## Profiles The pack registers two profiles of the Austrian CIUS of EN 16931, as published by the BRZ for the BMF ([CIUS-AT-NAT](https://www.erechnung.gv.at/go/cius_at_nat), [CIUS-AT-GOV](https://www.erechnung.gv.at/go/cius_at_gov)). Both have the level EN 16931 and the syntaxes CII and UBL. Embedded in a ZUGFeRD PDF, they have the conformance level "EN 16931" with their own specification identifier ([Profiles](formats.md#profiles)). | Key | Class | Name | Specification identifier (BT-24) | Rules | |---|---|---|---|---| | `cius-at-nat` | `Profiles\CiusAtNat` | CIUS-AT-NAT 1.0.0 | `urn:cen.eu:en16931:2017#compliant#urn:erechnung.gv.at:CIUS-AT-NAT:1.0.0` | `AT-NAT-01` to `AT-NAT-08` | | `cius-at-gov` | `Profiles\CiusAtGov` | CIUS-AT-GOV 1.1.0 | `urn:cen.eu:en16931:2017#compliant#urn:erechnung.gv.at:CIUS-AT-NAT:1.0.0#compliant#urn:erechnung.gv.at:CIUS-AT-GOV:1.1.0` | the rules of `cius-at-nat` and `AT-GOV-01` to `AT-GOV-09` | `cius-at-gov` is chosen automatically for public buyers ([Format choice](#format-choice)). `cius-at-nat` is used only when you request it, in any format with CII or UBL: ```php $result = $quittio->make($invoice)->profile('cius-at-nat')->render(); // ZUGFeRD with CIUS-AT-NAT $result = $quittio->make($invoice)->format('ubl')->profile('cius-at-nat')->render(); ``` The reader recognises both profiles by their specification identifier once the pack is registered ([Reading incoming invoices](reading.md#supported-documents)). The CIUS documents state no severity; every rule is an error at level L3. Where EN 16931 forbids a value that the CIUS makes mandatory (the VAT rate of category `O`, BR-O-05 to BR-O-07), EN 16931 wins. CIUS-AT-NAT (`CiusAtRules::national()`): | Code | Business term | Check | |---|---|---| | `AT-NAT-01` | BT-35, BT-50, BT-64, BT-75 | Address line 1 of every postal address: seller, buyer, tax representative and delivery address. | | `AT-NAT-02` | BT-37, BT-52, BT-66, BT-77 | City of every postal address. | | `AT-NAT-03` | BT-38, BT-53, BT-67, BT-78 | Post code of every postal address, also of a buyer abroad. | | `AT-NAT-04` | BT-72 | Delivery date (BT-72) or invoicing period (BG-14) at document level; periods on the lines are not enough. | | `AT-NAT-05` | BT-96 | VAT rate of every document level allowance, except category `O`. | | `AT-NAT-06` | BT-103 | VAT rate of every document level charge, except category `O`. | | `AT-NAT-07` | BT-124 | No external document location; embed the attachment instead. | | `AT-NAT-08` | BT-152 | VAT rate of every invoice line, except category `O`. | CIUS-AT-GOV adds the rules of e-Rechnung.gv.at (`CiusAtRules::government()`): | Code | Business term | Check | |---|---|---| | `AT-GOV-01` | BT-10 | Buyer reference: for the federal government the order reference (Auftragsreferenz) of the ordering office (`->buyerReference(…)`). | | `AT-GOV-02` | BG-6, BT-43 | Seller contact with an email address (`->contact(name, phone, email)` on the seller). | | `AT-GOV-03` | BT-81 | A payment means code, if given, is one of 30, 31, 42, 49, 58 or 59 (`CiusAtRules::GOV_PAYMENT_MEANS`). | | `AT-GOV-04` | BT-115 | Amount due at most 999,999,999.99. | | `AT-GOV-05` | BG-24 | At most 200 attachments of together at most 15 MB. | | `AT-GOV-06` | BT-125 | Embedded attachments are PDF, PNG, XML or Excel files: mime code and file name extension `.pdf`, `.png`, `.xml`, `.xls` or `.xlsx`. | | `AT-GOV-07` | BG-25 | At most 999 invoice lines. | | `AT-GOV-08` | BT-131 | Line net amounts between -999,999,999,999.99 and 999,999,999,999.99. | | `AT-GOV-09` | BT-132 | With a ten digit order number (BT-13, `->purchaseOrderReference(…)`) every line references its order line (`->orderLineReference(…)` on the line). | ## Format choice `Formats\AustrianFormatRule` is the format rule of the pack. A buyer whose electronic address (BT-49) has the scheme `9915` (Austrian organisation number, e.g. `b` for the federal government) receives UBL after `cius-at-gov`. This applies to domestic invoices and, as buyer pack, to invoices from other countries. Everything else follows the [automatic format choice](formats.md#automatic-choice) of the core: a domestic invoice to a business becomes ZUGFeRD with the configured profile (default `en16931`), an invoice to a consumer a PDF. Austria has no e-invoicing obligation between businesses, so the pack prescribes nothing else. `prepare()` shows the choice without rendering, and `->format()` overrides it. ### Invoices to the federal government ```php use Quittio\Core\Builder\InvoiceBuilder; use Quittio\Core\Builder\Party; use Quittio\Core\Enums\PaymentMeansCode; use Quittio\Core\Enums\UnitCode; use Quittio\Core\Quittio; use Quittio\Core\Tax\CountryDefaultVat; use Quittio\Country\AT\CountryAT; $quittio = Quittio::create([], [new CountryAT]); InvoiceBuilder::useDefaultVat(new CountryDefaultVat($quittio->countries())); $invoice = InvoiceBuilder::make() ->number('RE-2026-0046') ->issueDate('2026-10-05') ->deliveryDate('2026-09-30') ->buyerReference('4700000001') // order reference (Auftragsreferenz) of the ordering office (AT-GOV-01) ->seller(Party::make('Donau Werkstatt GmbH') ->vatId('ATU12345678') ->address('Mariahilfer Straße 1', '1060', 'Wien', 'AT') ->contact('Anna Huber', '+43 1 234567', 'rechnung@donau-werkstatt.example')) // AT-GOV-02 ->buyer(Party::make('Bundesministerium für Beispiele') ->address('Musterplatz 1', '1010', 'Wien', 'AT') ->electronicAddress('b', '9915')) // scheme 9915: UBL after CIUS-AT-GOV ->line('Softwareentwicklung', netPrice: '100.00', quantity: 12, unit: UnitCode::Hour) ->paymentTerms(fn ($terms) => $terms->dueInDays(30)) ->payment(PaymentMeansCode::SepaCreditTransfer, iban: 'AT611904300234573201', bic: 'BKAUATWW') // code 58 (AT-GOV-03) ->build(); $result = $quittio->make($invoice)->render(); $result->format(); // "ubl" $result->profile()?->key(); // "cius-at-gov" $result->xml(); // the UBL to upload to e-Rechnung.gv.at ``` If you have a ten digit order number, set it as purchase order reference (BT-13) and give every line its order line reference: `->line(fn ($line) => $line->name('…')->…->orderLineReference('10'))` (`AT-GOV-09`). ## ebInterface ebInterface 6.1 is the Austrian XML invoice format of AUSTRIAPRO; e-Rechnung.gv.at accepts it besides UBL. The pack writes and reads it. ```php use Quittio\Core\Builder\InvoiceBuilder; use Quittio\Core\Builder\Party; use Quittio\Core\Calculation\En16931Calculator; use Quittio\Core\Enums\PaymentMeansCode; use Quittio\Core\Enums\UnitCode; use Quittio\Core\Quittio; use Quittio\Country\AT\CountryAT; use Quittio\Country\AT\EbInterface\EbInterfaceWriter; use Quittio\Country\AT\Tax\VatPreset; $quittio = Quittio::create([], [new CountryAT]); $invoice = InvoiceBuilder::make() ->number('RE-2026-0046') ->issueDate('2026-10-05') ->deliveryDate('2026-09-30') ->purchaseOrderReference('4700000001') // OrderID of the invoice recipient ->seller(Party::make('Donau Werkstatt GmbH')->vatId('ATU12345678')->address('Mariahilfer Straße 1', '1060', 'Wien', 'AT')) ->buyer(Party::make('Tiroler Handel KG')->vatId('ATU87654321')->address('Maria-Theresien-Straße 10', '6020', 'Innsbruck', 'AT')) ->line(fn ($line) => $line->name('Softwareentwicklung')->quantity(12, UnitCode::Hour)->netPrice('100.00')->vat(VatPreset::Standard)->orderLineReference('10')) ->paymentTerms(fn ($terms) => $terms->dueInDays(14)) ->payment(PaymentMeansCode::SepaCreditTransfer, iban: 'AT611904300234573201', bic: 'BKAUATWW') ->build(); $xml = (new EbInterfaceWriter)->write((new En16931Calculator)->calculate($invoice)); file_put_contents('RE-2026-0046.xml', $xml); $read = $quittio->read($xml); // the reader of the pack $read->syntax; // "ebinterface" $read->profile; // null $read->data->number; // "RE-2026-0046" ``` **Writer** (`EbInterface\EbInterfaceWriter`): - `write(InvoiceData $invoice): string` takes a calculated invoice (with totals); an invoice without totals throws an `InvalidArgumentException`. Calculate it with `En16931Calculator`, or take `$result->data()` of a render run. - It follows the official mapping of AUSTRIAPRO between UBL and ebInterface. The purchase order reference (BT-13), else the buyer reference (BT-10), is the order reference of the invoice recipient (`OrderID`, the Auftragsreferenz of the federal government) and of every line with its order line reference (BT-132, `OrderPositionNumber`). The first seller identifier (BT-29) is the supplier number (`InvoiceRecipientsBillerID`). - A missing VAT identifier of seller or buyer is written as `ATU00000000` (`EbInterfaceWriter::UNDEFINED_VAT_ID`). - The type code sets the document type (`EbInterfaceWriter::documentType()`): credit notes (381, 261) are a `CreditMemo` with positive amounts, prepayment invoices (386) `InvoiceForAdvancePayment`, partial invoices (326) `InvoiceForPartialDelivery`, self-billed invoices (389) `SelfBilling`, final payment requests (218) `FinalSettlement`, debit notes (383) `SubsequentDebit`, everything else `Invoice`. - The root element carries `GeneratingSystem="Quittio"`, the currency, the title of the presentation as `DocumentTitle` and the two-letter language of the invoice locale. - Fields without a place in ebInterface are not written, e.g. the payee (BG-10), the buyer reference next to a purchase order reference, attachments and the VAT in accounting currency (BT-111). **Reader** (`EbInterface\EbInterfaceReader`): - It reads ebInterface 6.0 and 6.1 (`EbInterfaceReader::NAMESPACES`). `CountryAT::readers()` registers it, so `read()`, `readFile()`, `validateFile()` and `validatePath()` accept such files once the pack is registered ([Reading incoming invoices](reading.md#reading-a-file)). - The mapping is that of the writer in reverse. The result has the syntax `ebinterface` and no profile; the rules use the configured default profile. - The language attribute sets the locale of the data, and the declared amounts are compared with a recalculation as for other formats. - The XSD level (L4) of the core has schemas for CII and UBL only and skips ebInterface files; the reader checks their structure, the other levels their content ([Incoming files](validation.md#incoming-files)). ebInterface is not an output format of `render()` yet; the XML formats of the core are CII and UBL ([CII and UBL](formats.md#cii-and-ubl)). Use the writer directly. The pack's tests check its output against the schema of ebInterface 6.1. ## Self-billing (Gutschrift) A self-billed invoice is issued by the buyer in the name of the seller. Set its type code (`->type(InvoiceTypeCode::SelfBilledInvoice)`, 389; see [Credit notes, corrected invoices and self-billing](building-invoices.md#credit-notes-corrected-invoices-and-self-billing)) and label it "Gutschrift" (section 11 (8) no. 3 UStG). The pack has no builder macro for it; add the note yourself: ```php use Quittio\Core\Enums\InvoiceTypeCode; use Quittio\Core\Enums\NoteSubjectCode; use Quittio\Country\AT\Texts\LegalTexts; $builder->type(InvoiceTypeCode::SelfBilledInvoice) ->note(LegalTexts::text(LegalTexts::SELF_BILLING), NoteSubjectCode::RegulatoryInformation); // "Gutschrift" ``` Without the note, `AT-USTG-09` is an error for a PDF without XML and a warning for an e-invoice. The PDF and HTML title of a self-billed invoice is "Gutschrift" (English "Self-billed invoice (Gutschrift)") from the [correction policy](#cancellations-and-corrections), and the [mandatory PDF output](#mandatory-pdf-output) requires it to be printed. ebInterface writes such an invoice as `SelfBilling`. ## Cancellations and corrections `CountryAT::correctionPolicy()` sets how invoices of an Austrian seller are cancelled and corrected (see [Building invoices: cancellations and corrections](building-invoices.md#cancellations-and-corrections) and [`CorrectionPolicy`](country-packs.md#correctionpolicy)): - **Cancellation strategy `credit_note`:** a cancellation is a credit note (type code 381) with positive amounts. - **Correction strategy `cancel_and_reissue`:** the Managed layer corrects an invoice by cancelling it and issuing a new one. Change them with `quittio.corrections.cancellation_strategy` and `quittio-managed.correction.strategy`. The policy sets these titles: | Kind | German | English | |---|---|---| | `cancellation` | Stornorechnung | Cancellation invoice | | `cancellation_self_billed` | Storno-Gutschrift | Cancellation of the self-billed invoice (Storno-Gutschrift) | | `correction` | Rechnungsberichtigung | Corrected invoice | | `self_billed` | Gutschrift | Self-billed invoice (Gutschrift) | A price reduction (`Quittio::priceReduction()`) has no Austrian title and takes the label of the core. Locales other than German and English take the English title. ```php $cancellation = $quittio->cancellation($result->data(), 'ST-2026-0001', reason: 'Doppelt verrechnet'); $quittio->make($cancellation)->render()->filename(); // "Stornorechnung_ST-2026-0001.pdf" ``` ## Late payment When a customer pays late, the Austrian Commercial Code (UGB) gives a business creditor default interest from a business debtor and a flat rate for recovery costs; a consumer owes the statutory interest of the Civil Code (ABGB). The pack provides these values and a calculator. Quittio's documents do not apply them by themselves: calculate the interest with [`DefaultInterest`](#default-interest) and pass the results to a payment reminder ([Documents: payment reminders](documents.md#payment-reminders)). `CountryAT::dunningLaw()` (also `CountryAT::austrianDunningLaw()` without an instance) returns these values ([`DunningLaw`](country-packs.md#dunninglaw)): | Value | Austria | |---|---| | Interest for business debtors | base rate plus 9.2 percentage points (section 456 UGB) | | Interest for consumers | a fixed 4 % (section 1000 (1) ABGB), not tied to the base rate | | Flat rate for business debtors | 40.00 EUR (section 458 UGB) | | Day count | 365 days | | Consumer default | not modelled (`null`) | | Reference rate | "Basiszinssatz (OeNB, § 456 UGB)", the base rate of the Oesterreichische Nationalbank | ### Default interest `Quittio\Country\AT\Dunning\DefaultInterest` calculates the default interest on an open amount: | Method | Result | |---|---| | `__construct(?BaseRateTable $rates = null, ?DunningLaw $law = null)` | Without a table, the published rates (`new BaseRateTable`). Without a law, `CountryAT::austrianDunningLaw()`. | | `calculate(Money $amount, Date $from, Date $until, bool $consumer = false, string $locale = 'de'): list<InterestCharge>` | From `$from` (first day with interest) to `$until` (exclusive). For businesses one charge per base rate period, rate = base rate + 9.2 points; for consumers (`$consumer`) one charge at 4 % for the whole time. Empty for a non-positive amount or when `$until` is not after `$from`. `InvalidArgumentException` for days the [base rate table](#base-rate-table) does not cover. | | `flatRate(string $currency = 'EUR'): ?Money` | The flat rate of 40.00 for business debtors (section 458 UGB), once per claim | ```php use Brick\Money\Money; use Quittio\Core\Builder\Party; use Quittio\Core\Documents\DocumentBuilder; use Quittio\Core\Quittio; use Quittio\Core\Support\Date; use Quittio\Country\AT\CountryAT; use Quittio\Country\AT\Dunning\DefaultInterest; $quittio = Quittio::create([], [new CountryAT]); $interest = new DefaultInterest; $reminder = DocumentBuilder::paymentReminder(1) // first reminder ("1. Mahnung") ->number('M-2026-0003') ->issueDate('2026-10-05') ->seller(Party::make('Donau Werkstatt GmbH')->vatId('ATU12345678')->address('Mariahilfer Straße 1', '1060', 'Wien', 'AT')) ->buyer(Party::make('Tiroler Handel KG')->vatId('ATU87654321')->address('Maria-Theresien-Straße 10', '6020', 'Innsbruck', 'AT')) ->creditTransfer('AT611904300234573201', 'BKAUATWW') ->openItem('RE-2026-0042', '2026-06-01', '1440.00', dueDate: '2026-06-15') // first day with interest: the day after the due date; 2026-10-05 is the first day without interest ->interestCharge(...$interest->calculate(Money::of('1440.00', 'EUR'), Date::parse('2026-06-16'), Date::parse('2026-10-05'))) ->flatRate('RE-2026-0042') // 40.00 EUR, once per claim, only from businesses ->deadline('2026-10-19') ->build(); $reminder->dunning->total('EUR'); // EUR 1526.99: 1,440.00 + 46.99 interest + 40.00 $quittio->document($reminder)->render()->save(__DIR__.'/reminders/'); ``` - **Descriptions.** With a German locale (the default, also `de_AT`) a description reads "Verzugszinsen 10,73 % p. a. (Basiszinssatz 1,53 % + 9,20 Prozentpunkte, § 456 UGB) vom 16.06.2026 bis 04.10.2026", for a consumer "Verzugszinsen 4,00 % p. a. (§ 1000 Abs. 1 ABGB) vom 16.06.2026 bis 04.10.2026". With `locale: 'en'` they are English: "Default interest 10.73 % p. a. (base rate 1.53 % + 9.20 percentage points, section 456 UGB) from 2026-06-16 to 2026-10-04". Other locales take German. The texts are `LegalTexts::DEFAULT_INTEREST` and `DEFAULT_INTEREST_CONSUMER` ([Legal texts](#legal-texts)). - **Day count.** The charges count 365 days per year (`InterestCharge::$dayCount`); `interestCharge()` takes it over. - **Periods.** A charge covers a whole period with the same base rate. A table entry that keeps the rate (e.g. 1 July 2026) starts no new period. - **Flat rate.** `DocumentBuilder::flatRate($claim)` adds 40.00 EUR as fee of kind `DunningFeeKind::FlatRate` for one claim. The builder rejects a second flat rate for the same claim in one reminder and a flat rate for a consumer; a flat rate together with reminder fees gets the notice `QUITTIO-DUNNING-FLAT-RATE-FEES` ([Documents: payment reminders](documents.md#payment-reminders)). Which claims already carried it in earlier reminders is up to your application (the Managed layer does not track it). - **Core calculator.** `Quittio\Core\Dunning\DefaultInterest::forCountry(new CountryAT)` calculates the same rates from `referenceRates()` and `dunningLaw()`, with the descriptions of the core instead of the Austrian texts. ### Base rate table `Quittio\Country\AT\Dunning\BaseRateTable` holds the base rate (Basiszinssatz) of the OeNB for contracts concluded from 16 March 2013. The rate on the first day of a half-year applies to the whole half-year. `CountryAT::referenceRates()` returns the table. Quittio ships these rates (`BaseRateTable::PUBLISHED`): | Valid from | Rate in % | |---|---| | 2013-01-01 | 0.38 | | 2013-07-01 | -0.12 | | 2016-07-01 | -0.62 | | 2023-01-01 | 1.88 | | 2023-07-01 | 3.38 | | 2024-01-01 | 3.88 | | 2025-01-01 | 2.53 | | 2025-07-01 | 1.53 | | 2026-01-01 | 1.53 | | 2026-07-01 | 1.53 | Rates after the last entry are unknown until they are published. Interest for days from 1 January 2027 is therefore rejected instead of silently using the old rate. The pack has no configuration or automatic update for new rates: add a published rate to a table and pass it to `DefaultInterest` (the value below is an example, not the published rate): ```php use Quittio\Country\AT\Dunning\BaseRateTable; use Quittio\Country\AT\Dunning\DefaultInterest; $rates = (new BaseRateTable)->withRate('2027-01-01', '1.78'); $interest = new DefaultInterest($rates); ``` | Method | Result | |---|---| | `__construct(array $rates = self::PUBLISHED)` | ISO date => rate in percent, sorted by date | | `withRate(Date\|string $from, string $rate): self` | new table with an additional or replaced rate | | `rateOn(Date $date): BigDecimal` | rate on a day; `InvalidArgumentException` before the first entry and from `validUntil()` on | | `periods(Date $from, Date $until): list<array{from: Date, until: Date, rate: BigDecimal}>` | periods with a constant rate (start inclusive, end exclusive), split where the rate changes; `InvalidArgumentException` if `$until` is after `validUntil()` | | `lastChange(): Date` | date of the last entry, e.g. to warn when the table is outdated | | `validUntil(): Date` | first day without a known rate: the next 1 January or 1 July after the last entry (with the published table: 2027-01-01) | ## Payment QR code The pack's default payment QR code is `girocode`, and it brings no generator of its own. With the default `paymentQr` setting `auto`, the PDF therefore prints the EPC GiroCode of the core next to the bank details: for invoices in euro with a SEPA credit transfer (payment means 30 or 58) and a valid IBAN. Conditions, payload and options are described in [Templates: payment QR codes](templates.md#payment-qr-codes); `none` switches the code off. ## Mandatory PDF output After rendering, the mandatory field guard checks that the PDF shows certain values ([Templates: mandatory field guard](templates.md#mandatory-field-guard)). `CountryAT::mandatoryOutput()` adds these Austrian values to the base fields. Paths without a value are skipped. The legal basis is the value Quittio reports, in German citation form. | Condition | Access key | Description | Legal basis | |---|---|---|---| | not a simplified invoice, and the seller or its tax representative has a VAT identifier | `seller.vatId\|taxRepresentative.vatId` | VAT identifier (UID) of the seller | § 11 Abs. 1 Z 3 lit. i UStG | | every invoice with BT-72 or BG-14 | `servicePeriod\|deliveryDate\|delivery.date` | date of the supply or service | § 11 Abs. 1 Z 3 lit. d UStG | | the same, without BT-72 and BG-14 | `servicePeriod\|lineGroups[*].lines[*].period\|lines[*].period` | date of the supply or service | § 11 Abs. 1 Z 3 lit. d UStG | | not simplified, the buyer has a VAT identifier and [`AT-USTG-05`](#ustg-rules) requires it | `buyer.vatId` | VAT identifier (UID) of the buyer | § 11 Abs. 1 Z 3 lit. b UStG | | self-billed type code | `title` | label "Gutschrift" | § 11 Abs. 8 Z 3 UStG | | each VAT row of category `AE`, `K`, `G` or `E` | `vatRows[i].label` or the legal note with its BT-120 text | reverse charge or exemption note | § 11 Abs. 1 Z 3 lit. e und Abs. 1a UStG | | category `AE` or `K` used | `buyer.vatId` | VAT identifier (UID) of the buyer | § 11 Abs. 1a UStG, Art. 11 UStG | The default templates print all of them. ## Legal texts `Quittio\Country\AT\Texts\LegalTexts::catalog()` (also `CountryAT::legalTexts()`) holds the Austrian notices in German and English. Its fallback locale is German (`LegalTexts::FALLBACK_LOCALE`). | Constant (key) | German | English | Used by | |---|---|---|---| | `SELF_BILLING` (`self_billing`) | Gutschrift | Self-billed invoice (Gutschrift) | – (your note on self-billed invoices) | | `REVERSE_CHARGE` (`reverse_charge`) | Übergang der Steuerschuld auf den Leistungsempfänger (Reverse Charge) | Reverse charge: the recipient owes the VAT | – (text of `VatPreset::ReverseChargeEu`) | | `INTRA_COMMUNITY_SUPPLY` (`intra_community_supply`) | Steuerfreie innergemeinschaftliche Lieferung (Art. 6 Abs. 1 i. V. m. Art. 7 UStG) | VAT exempt intra-community supply (Art. 6 (1) with Art. 7 UStG) | – (text of `VatPreset::IntraCommunitySupply`) | | `EXPORT` (`export`) | Steuerfreie Ausfuhrlieferung (§ 6 Abs. 1 Z 1 i. V. m. § 7 UStG) | VAT exempt export supply (section 6 (1) no. 1 with section 7 UStG) | – (text of `VatPreset::Export`) | | `SMALL_BUSINESS` (`small_business`) | Umsatzsteuerfrei aufgrund der Kleinunternehmerregelung (§ 6 Abs. 1 Z 27 UStG). | VAT exempt under the small business scheme (section 6 (1) no. 27 UStG). | – (text of `VatPreset::SmallBusiness`) | | `DEFAULT_INTEREST` (`default_interest`) | Verzugszinsen :rate % p. a. (Basiszinssatz :base_rate % + :points Prozentpunkte, § 456 UGB) vom :from bis :until | Default interest :rate % p. a. (base rate :base_rate % + :points percentage points, section 456 UGB) from :from to :until | `DefaultInterest`, business debtors | | `DEFAULT_INTEREST_CONSUMER` (`default_interest_consumer`) | Verzugszinsen :rate % p. a. (§ 1000 Abs. 1 ABGB) vom :from bis :until | Default interest :rate % p. a. (section 1000 (1) ABGB) from :from to :until | `DefaultInterest`, consumers | - `REVERSE_CHARGE`, `INTRA_COMMUNITY_SUPPLY`, `EXPORT` and `SMALL_BUSINESS` are the exemption reasons of the named [tax presets](#tax-presets), in every locale the pack ships, so a notice has one wording in BT-120 and in your notes. The other three come from `resources/lang/{de,en}/legal.php`. - All texts are read through the translator, so overrides of `tax.php` and `legal.php` change them ([Translations](#translations)). - `LegalTexts::text($key, $locale, $replace)` returns a text in `$locale`, else in its language (`de_AT` → German, `en_GB` → English), else in German. `LegalTexts::localeOf($key, $locale)` names the catalog locale it uses. - Validation and rendering add no text. ## Meta flags and settings The pack defines no meta flags of its own. It reads the small business flag of the core, `Meta::FLAG_SMALL_BUSINESS` (`small_business`), set by `quittio.seller.small_business`, `small_business` of `Quittio::create()`, a Managed issuer or `->flag()` ([Small businesses](#small-businesses)). The pack has no settings: there is no `quittio.countries.at` section and no configuration file to publish ([Settings of a pack](configuration.md#settings-of-a-pack-quittiocountriescode)). It has no builder macros either. ## Defaults For pack authors and for reference, this is how `CountryAT` fills the [`CountryPack` contract](country-packs.md#the-countrypack-contract): | Hook | Austria | |---|---| | `defaults()` | currency `EUR`, time zone `Europe/Vienna`, locale `de`, paper `A4`, letter layout `free`, profile `en16931`, payment QR `girocode`, default VAT presets `at.standard` and `at.small_business` | | `profiles()` | [`CiusAtNat`, `CiusAtGov`](#profiles) | | `taxPresets()` | every case of [`VatPreset`](#tax-presets) | | `rules()` | the [UStG rules](#ustg-rules) `AT-USTG-01` to `AT-USTG-12` | | `buyerCountryRules()` | none | | `formatRules()` | [`AustrianFormatRule`](#format-choice) | | `mandatoryOutput()` | [mandatory PDF output](#mandatory-pdf-output) | | `legalTexts()` | [`LegalTexts::catalog()`](#legal-texts) | | `numberingRules()` | pattern `RE-{Y}-{seq:4}`, reset `yearly`, resets `never`, `yearly`, `monthly`, gapless, number consumed on rejection | | `retention()` | 7 years from the end of the calendar year | | `dunningLaw()`, `referenceRates()` | [UGB and ABGB values, OeNB base rate](#late-payment) | | `correctionPolicy()` | [credit note, cancel and reissue, Austrian titles](#cancellations-and-corrections) | | `readers()` | [`EbInterfaceReader`](#ebinterface) | | `letterLayouts()`, `paymentQr()`, `addressFormatter()` | defaults of the core: `free`, the EPC GiroCode of the core, the international address format | | `translationPath()` | `resources/lang` of the package | - **Locale.** German (`de`), unless the run, the invoice or the configuration sets another ([Translations and locales](templates.md#translations-and-locales)). Dates are printed as `dd.MM.yyyy`. - **Paper and letter layout.** A4 ([Paper size](templates.md#paper-size)) and the free layout without a norm ([Letter layouts](templates.md#letter-layouts)). The pack has no Austrian letter layout. - **Numbering.** `RE-{Y}-{seq:4}`, e.g. `RE-2026-0042`, reset every year: a consecutive number with one or more series that identifies the invoice once (section 11 (1) no. 3 lit. h UStG). The Managed layer uses it when neither the issuer nor the configuration sets a pattern ([`NumberingRules`](country-packs.md#numberingrules)). - **Retention.** `new RetentionRule(7, fromEndOfCalendarYear: true)`: invoices are kept for seven years from the end of the calendar year (section 11 (2) UStG, section 132 BAO). An invoice issued on 5 October 2026 is kept until 31 December 2033. Longer periods for property related supplies (section 18 (10) UStG) are not modelled ([`RetentionRule`](country-packs.md#retentionrule)). - **Correction policy.** See [Cancellations and corrections](#cancellations-and-corrections). ## Translations The pack ships German and English catalogs in `resources/lang/{de,en}/` (`CountryAT::locales()` returns `['de', 'en']`): - `rules.php`: message and hint of every rule (`AT-USTG-*`, `AT-NAT-*`, `AT-GOV-*`); - `tax.php`: the exemption reason texts of the presets, including `at.exempt` for `VatPreset::exempt()` (placeholder `:paragraph`); - `legal.php`: the label "Gutschrift" and the default interest descriptions. They are registered as the namespace `quittio-at` (e.g. `quittio-at::rules.AT-USTG-03.message`). `CountryAT::registerTranslations()` registers them lazily, so presets work without a `Quittio` instance. Rule messages and preset texts in other locales fall back to English, legal texts to German. Validation messages are written in the language set by `validation.locale` ([Messages and translations](validation.md#messages-and-translations)). **Laravel.** Laravel's translator is used, so the usual override files apply: `lang/vendor/quittio-at/{locale}/rules.php`, `tax.php` and `legal.php`, also for additional locales ([Laravel: translations](laravel.md#translations)). A file only needs the keys you change: ```php // lang/vendor/quittio-at/de/tax.php return [ 'at.reverse_charge_eu' => 'Reverse Charge – Übergang der Steuerschuld auf den Leistungsempfänger', ]; ``` **Without Laravel.** Register a directory with `{locale}/{group}.php` files under the namespace of the pack after creating the `Quittio` instance; later paths override earlier ones: ```php use Quittio\Core\I18n\Translations; use Quittio\Core\Quittio; use Quittio\Country\AT\CountryAT; $quittio = Quittio::create([], [new CountryAT]); Translations::translator()->addPath(__DIR__.'/lang', CountryAT::TRANSLATION_NAMESPACE); // e.g. lang/de/tax.php ``` A changed reverse charge text still satisfies `AT-USTG-06`, because the rule accepts the current texts of the reverse charge presets. Texts defined in PHP cannot be translated through files: the correction policy titles (German and English, fallback English) and the number and date format of the default interest descriptions (German for German locales, otherwise ISO dates). ## Known limitations - The legal wording, references and defaults follow the law and official sources of October 2026 and have not been reviewed by an Austrian tax adviser. Later changes of the law need a new release. - ebInterface is not a format of `render()`; use `EbInterfaceWriter`. `validateFile()` does not check ebInterface files against their schema ([ebInterface](#ebinterface)). - There is no Austrian letter layout (ÖNORM A 1080 was withdrawn without a successor), no Laravel service provider and no settings. - The shipped base rate table ends with 1 July 2026. Later rates must be added with `withRate()`; there is no configuration key and no automatic update ([Base rate table](#base-rate-table)). - There are no builder macros for Austrian special cases: the "Gutschrift" note, prepayment invoices and the conversion of foreign currency amounts are set with the general builder methods. - `AT-USTG-10` cannot read a conversion method stated in a note and only warns. - Longer retention periods for property related supplies (section 18 (10) UStG) are not modelled. - The documents layer checks the flat rate of section 458 UGB within one reminder only (once per claim, not for consumers); across reminders the application must track it (the Managed layer does not). When a consumer is in default is not modelled. - The pack defines no buyer country rules and no exporters. <!-- Source: https://quittio.dev/docs/country-be --> # Belgium (`quittio/country-be`) > **Not reviewed by a tax adviser yet.** The legal wording, rules and defaults of this pack follow the law and the official sources as of October 2026, but have not been reviewed by a Belgian tax adviser. Check the mentions and rates of your invoices before you rely on them. Quittio is no tax or legal advice; the business that issues an invoice remains responsible for it. Until the review the pack is not covered by the [compatibility promise](compatibility.md#country-packs-without-tax-review): a minor release may change it. The Belgian pack implements the invoice mentions of the Belgian VAT Code (Wetboek van de belasting over de toegevoegde waarde / Code de la TVA) and of Royal Decree No. 1 (Koninklijk besluit nr. 1, "KB nr. 1" / Arrêté royal n° 1, "A.R. n° 1"), the e-invoicing obligation of 2026 with Peppol BIS Billing 3.0, the use of languages in the language regions, and the law on late payment of 2 August 2002. Its class is `Quittio\Country\BE\CountryBE` (code `BE`, translation namespace `quittio-be`). Its texts exist in Dutch, French, German and English. - **Legal references.** This page writes Belgian legal references in English form: "Art. 5 § 1, 10° Royal Decree No. 1" is article 5, paragraph 1, point 10 of the decree. Values that the pack stores or prints keep their Dutch or French form, e.g. "KB nr. 1, art. 20". - **Business terms.** Codes such as BT-31 are the business terms of EN 16931, the European standard for e-invoices ([E-invoicing basics](concepts.md#en-16931-and-business-terms)). ## Installation ```bash composer require quittio/country-be ``` The pack is not part of `quittio/quittio`. Install it next to `quittio/quittio` (with Laravel) or next to `quittio/core` (without Laravel). It is developed in [`packages/country-be`](https://github.com/Quittio/quittio/tree/master/packages/country-be) of the monorepo and published as the read-only repository [Quittio/country-be](https://github.com/Quittio/country-be); open issues and pull requests in the monorepo. - **Laravel.** The pack declares itself in its `composer.json` under `extra.quittio.country-packs`, so Laravel finds it after the installation; there is nothing to register ([Registering packs: Laravel](country-packs.md#laravel)). The pack has no service provider and no configuration file of its own. Its one setting goes into `config/quittio.php` ([Settings](#settings)). - **Without Laravel.** Pass the pack to `Quittio::create()`: ```php use Quittio\Core\Quittio; use Quittio\Country\BE\CountryBE; $quittio = Quittio::create(['country' => 'BE'], [new CountryBE]); ``` `'country' => 'BE'` makes Belgium the default country for invoices whose seller has no country code. With several packs, pass them all, e.g. `[new CountryBE, new CountryDE]`, or add one later with `$quittio->registerCountry(new CountryBE)` ([Registering packs: Without Laravel](country-packs.md#without-laravel)). ## When it applies The pack leads every invoice whose seller is in Belgium (seller country code `BE`), or that is rendered with `->country('BE')`. It then checks the Belgian rules, chooses Peppol BIS for domestic business invoices, completes the Peppol endpoints and provides the defaults: the locale `nl_BE` (unless the invoice or the configuration sets one), A4 paper and the payment QR code. For an invoice from another country to a buyer in Belgium, the pack only registers its translations. It has no rules for the buyer side (`buyerCountryRules()`), and its format rule applies only when the seller is in Belgium as well. How Quittio picks the leading pack and the buyer pack is described in [How a pack is selected](country-packs.md#how-a-pack-is-selected). ## Common tasks | You want to | Read | |---|---| | Set the VAT rate or an exemption on a line | [Tax presets](#tax-presets) | | Invoice as a small business without VAT | [Small businesses](#small-businesses) | | Know which format Quittio picks for a Belgian customer | [Format choice](#format-choice) | | Send an invoice through Peppol | [Format choice](#format-choice), [Peppol endpoints](#peppol-endpoints) | | Choose the language of the invoice | [Languages and language regions](#languages-and-language-regions) | | Look up a validation code such as `BE-VAT-04` or `BE-LANG-01` | [Rules](#rules) | | Print a QR code for the bank transfer | [Payment QR code](#payment-qr-code) | | Send a reminder with default interest | [Late payment](#late-payment) | | Cancel or correct an invoice | [Cancellations and corrections](#cancellations-and-corrections) | | Change the wording of a mention or rule message | [Translations](#translations) | | Copy a complete invoice | [Complete example](#complete-example) | ## Tax presets A tax preset is a ready-made VAT treatment for an invoice line. It sets the VAT category (BT-151) and the rate, and for exempt supplies also the exemption reason code (BT-121) and text (BT-120). Use a preset instead of a bare category and rate: the line then carries the wording of the mention, and the Belgian rules recognise the case. How presets work in general is described in [Building invoices: Tax presets](building-invoices.md#tax-presets). The categories are the codes of EN 16931: `S` standard rate, `Z` zero rated, `E` exempt, `AE` reverse charge, `K` intra-community supply, `G` export outside the EU, `O` not subject to VAT ([Categories](building-invoices.md#categories)). `Quittio\Country\BE\Tax\VatPreset` is a string-backed enum that implements `TaxPreset`. Apply it per line: ```php use Quittio\Core\Builder\InvoiceBuilder; use Quittio\Core\Enums\UnitCode; use Quittio\Country\BE\Tax\VatPreset; $builder = InvoiceBuilder::make() ->deliveryDate('2026-03-02') // ... number, seller, buyer, payment ->line('Consultancy', netPrice: '120.00', quantity: 8, unit: UnitCode::Hour, vat: VatPreset::Standard) // 21 % ->line('Hotel night', netPrice: '110.00', quantity: 2, unit: UnitCode::Day, vat: VatPreset::Accommodation) // 12 %: supplied on 2 March 2026 ->line('Renovation works', netPrice: '5000.00', vat: VatPreset::ReverseChargeDomestic) // "Verlegging van heffing – KB nr. 1, art. 20" // an exemption without its own case: the legal reference as text ->line('Training', netPrice: '300.00', vat: VatPreset::exempt('artikel 44, § 2, 4°, Wetboek btw')); ``` | Case | Key | Category | Rate | Code (BT-121) | Use | |---|---|---|---|---|---| | `Standard` | `be.standard` | `S` | 21 | – | Standard rate | | `Intermediate` | `be.intermediate` | `S` | 12 | – | Intermediate rate | | `Reduced` | `be.reduced` | `S` | 6 | – | Reduced rate | | `Accommodation` | `be.accommodation` | `S` | 12 from 1 March 2026, 6 before (by supply date) | – | Accommodation in hotels and campsites | | `ZeroRated` | `be.zero_rated` | `Z` | 0 | – | Zero rate, e.g. for daily newspapers | | `SmallBusiness` | `be.small_business` | `E` | 0 | – | Small business exemption scheme (Art. 56bis VAT Code); see [Small businesses](#small-businesses) | | `ReverseChargeDomestic` | `be.reverse_charge_domestic` | `AE` | 0 | `VATEX-EU-AE` | Domestic reverse charge, e.g. works on immovable property (Art. 20 Royal Decree No. 1) | | `ReverseChargeEu` | `be.reverse_charge_eu` | `AE` | 0 | `VATEX-EU-AE` | Service to a business in another member state, which owes the VAT (Art. 196 of the VAT Directive 2006/112/EC) | | `IntraCommunitySupply` | `be.intra_community_supply` | `K` | 0 | `VATEX-EU-IC` | Exempt intra-community supply (Art. 39bis VAT Code) | | `Export` | `be.export` | `G` | 0 | `VATEX-EU-G` | Exempt export (Art. 39 VAT Code) | | `NotTaxableInBelgium` | `be.not_taxable` | `O` | none | `VATEX-EU-O` | Supply not taxable in Belgium (place of supply abroad) | | `MarginSecondHand` | `be.margin_second_hand` | `E` | 0 | `VATEX-EU-F` | Margin scheme, second-hand goods (Art. 58 § 4 VAT Code) | | `MarginArt` | `be.margin_art` | `E` | 0 | `VATEX-EU-I` | Margin scheme, works of art (Art. 58 § 4 VAT Code) | | `MarginAntiques` | `be.margin_antiques` | `E` | 0 | `VATEX-EU-J` | Margin scheme, collectors' items and antiques (Art. 58 § 4 VAT Code) | | `TravelAgency` | `be.travel_agency` | `E` | 0 | `VATEX-EU-D` | Margin scheme of travel agencies (Art. 58 § 3 VAT Code) | | `VatPreset::exempt(string $paragraph, $code = null)` | `be.exempt` | `E` | 0 | `$code` (enum, raw code or string) | Any other exemption, e.g. `artikel 44, § 2, 1° Wetboek btw` | The codes in column BT-121 are VATEX codes, the standard codes for the reason of an exemption. The rates are those of Royal Decree No. 20 on the VAT rates; `Quittio\Country\BE\Tax\TaxTables` holds them (`STANDARD_RATE`, `INTERMEDIATE_RATE`, `REDUCED_RATE`, `ACCOMMODATION_RATE`). **Dated rate.** `Accommodation` is the only preset with a dated rate. A line takes the rate that applied on its supply date: 6 % up to 28 February 2026, 12 % from 1 March 2026 (`TaxTables::accommodationRateOn($date)`). The supply date is determined as for the German presets ([Germany: Tax presets](country-packs.md#tax-presets)): the end of the line period, its start, the VAT point date, the delivery date, the end of the invoicing period or the issue date. `VatPreset::Accommodation->rate()` returns the rate of today (time zone Europe/Brussels), `VatPreset::Accommodation->on($date)` the preset with the rate of a date. The other presets have one rate. **Texts.** `Standard`, `Intermediate`, `Reduced`, `Accommodation` and `ZeroRated` carry no text, because EN 16931 forbids an exemption reason for categories `S` and `Z` (BR-S-10, BR-Z-10). The other presets print an exemption reason (BT-120) from `resources/lang/{nl,fr,de,en}/tax.php`: | Key | Dutch | French | |---|---|---| | `be.small_business` | Bijzondere vrijstellingsregeling kleine ondernemingen | Régime particulier de franchise des petites entreprises | | `be.reverse_charge_domestic` | Verlegging van heffing – KB nr. 1, art. 20 | Autoliquidation – A.R. n° 1, art. 20 | | `be.reverse_charge_eu` | Verlegging van heffing – artikel 196 Richtlijn 2006/112/EG | Autoliquidation – article 196 de la directive 2006/112/CE | | `be.intra_community_supply` | Vrijgestelde intracommunautaire levering – artikel 39bis Wetboek btw | Livraison intracommunautaire exemptée – article 39bis du Code de la TVA | | `be.export` | Vrijgestelde uitvoer – artikel 39 Wetboek btw | Exportation exemptée – article 39 du Code de la TVA | | `be.not_taxable` | Niet in België belastbaar (plaats van de handeling in het buitenland) | Non imposable en Belgique (lieu de l'opération à l'étranger) | | `be.margin_second_hand` | Bijzondere regeling – gebruikte goederen | Régime particulier – biens d'occasion | | `be.margin_art` | Bijzondere regeling – kunstvoorwerpen | Régime particulier – objets d'art | | `be.margin_antiques` | Bijzondere regeling – voorwerpen voor verzamelingen of antiquiteiten | Régime particulier – objets de collection et d'antiquité | | `be.travel_agency` | Bijzondere regeling – reisbureaus | Régime particulier – agences de voyages | | `be.exempt` | Vrijgesteld van btw – :paragraph | Exempté de la TVA – :paragraph | The German and English texts are in the same files ([Translations](#translations)). How presets behave: - **Language.** The text is taken in the invoice locale (`->locale()` on the builder) when the line is built. The enum presets use Dutch when the invoice has no locale; a regional locale such as `fr_BE` or `nl_BE` takes the text of its language. `VatPreset::exempt()` (a `Quittio\Country\BE\Tax\CustomVatPreset`) behaves the same: Dutch without a locale, the text of the language for a regional locale. - **Preset key.** The key stays on the line (`$line->vat->presetKey`). The small business detection of `BE-VAT-06` and the [format choice](#format-choice) rely on it. - **VAT breakdown.** Category, rate, code and text flow into the VAT breakdown (BG-23), and the PDF lists the texts in its legal notes. - **Lookup by key**, e.g. from a database column: `VatPreset::from('be.standard')`, `VatPreset::fromKey($key)` (null for keys of other packs), `(new CountryBE)->taxPresets()->get('be.standard')` or, across all installed packs, `$quittio->countries()->taxPreset('be.standard')`. `be.exempt` is not part of the collection. - **Default VAT.** Lines without `vat:` take the [default VAT](building-invoices.md#default-vat). With `CountryDefaultVat` (installed by the Laravel integration) that is `VatPreset::Standard` for a Belgian seller, and `VatPreset::SmallBusiness` for a small business invoice. ### Small businesses A small business under the exemption scheme (Art. 56bis VAT Code) charges no VAT. Mark its invoices in one of two ways: - Use `VatPreset::SmallBusiness` on every line. Its text "Bijzondere vrijstellingsregeling kleine ondernemingen" / "Régime particulier de franchise des petites entreprises" appears in the VAT breakdown and the PDF. - Or flag the invoice with `->flag(Meta::FLAG_SMALL_BUSINESS)` (in Laravel `quittio.seller.small_business = true`, without Laravel `'small_business' => true` in `Quittio::create()`; applied by `Quittio::invoice()` and `$quittio->invoice()`). The flag does not set texts; lines without `vat:` then get `VatPreset::SmallBusiness` through the default VAT. Either way, `BE-VAT-06` reports every VAT row with a VAT amount as an error. A small business invoice to a Belgian business is still sent through Peppol ([Format choice](#format-choice)). ## Rules The pack checks the mentions of Art. 5 of Royal Decree No. 1 and Art. 53 of the VAT Code, and the use of languages. These rules apply to every invoice of a Belgian seller, independent of the format. They run at validation level L3 ([Validation levels](validation.md#validation-levels)); the class is `Quittio\Country\BE\Rules\VatCodeRules`. | Code | Severity | Check | |---|---|---| | `BE-VAT-01` | error | The seller's VAT number (BT-31), or that of its tax representative, is stated (Art. 5 § 1, 3° Royal Decree No. 1). | | `BE-VAT-02` | error | The addresses of seller and buyer are complete: street (BT-35, BT-50), post code (BT-38, BT-53) and city (BT-37, BT-52) (Art. 5 § 1, 5° Royal Decree No. 1). One message per missing field. | | `BE-VAT-03` | warning | An invoice to a business (not a consumer) with an address in Belgium states the buyer's VAT number (BT-48) (Art. 5 § 1, 4° Royal Decree No. 1). The mention is required if the buyer files VAT returns, which Quittio cannot know, hence a warning. | | `BE-VAT-04` | error | Every VAT row of category `AE` (reverse charge) has a text (BT-120) that contains a reverse charge statement: "verlegging", "autoliquidation", "Steuerschuld", "reverse charge" or the text of a reverse charge preset in any of the pack's languages (Art. 5 § 1, 10° Royal Decree No. 1). | | `BE-VAT-05` | error | Every VAT row of category `E`, `K` or `G` has the reference to the provision as text (BT-120); a VATEX code alone is not enough (Art. 5 § 1, 10° Royal Decree No. 1). | | `BE-VAT-06` | error | A small business invoice (flag `Meta::FLAG_SMALL_BUSINESS` or a line with `VatPreset::SmallBusiness`) has no VAT row with a VAT amount (Art. 56bis VAT Code). | | `BE-VAT-07` | error, warning in XML | A self-billed invoice (self-billed type code) has a note (BT-22) with "self-billing", "autofacturation", "zelffacturering", "Gutschrift", "factuur uitgereikt door de afnemer" or "facture émise par le preneur" (Art. 5 § 1, 12° Royal Decree No. 1). When the invoice is validated for an XML format, the type code labels it already, so the missing words are a warning; for a document without XML they are an error. | | `BE-VAT-08` | warning | The invoice is issued by the 15th day of the month following the supply (Art. 53 § 2 VAT Code). The supply date is the latest of the delivery date (BT-72), the end of the invoicing period (BG-14) and the end of each line period; without any of them the rule does not check. Not checked for consumers, credit notes, corrected invoices and prepayment invoices. A late invoice stays valid, hence a warning. | | `BE-LANG-01` | warning | A business in the Dutch, French or German language region invoices customers in Belgium in the language of its region (language decrees of the Flemish and French Communities; for the German language region Art. 52 of the laws on the use of languages in administrative matters of 18 July 1966). Brussels-Capital is not checked. See [Languages and language regions](#languages-and-language-regions). | The messages and hints exist in Dutch, French, German and English. To switch a rule off or change its severity, e.g. `BE-LANG-01` for a business that knows its language obligations, use `validation.rules` ([Switching rules off and changing their severity](validation.md#switching-rules-off-and-changing-their-severity)). For Peppol invoices the Peppol rules apply on top of these ([Peppol rules](validation.md#peppol-rules)). The one you meet most often is `PEPPOL-EN16931-R003`: a Peppol invoice needs a buyer reference (BT-10, `->buyerReference()`) or a purchase order reference (BT-13, `->purchaseOrderReference()`). ### Mandatory PDF output After rendering, the mandatory field guard checks that the PDF shows certain values ([Templates: mandatory field guard](templates.md#mandatory-field-guard)). `CountryBE::mandatoryOutput()` adds these Belgian values to the base fields: | Condition | Access key | Description | Legal basis | |---|---|---|---| | the seller or its tax representative has a VAT number | `seller.vatId\|taxRepresentative.vatId` | VAT number of the seller | Art. 5 § 1, 3° KB nr. 1 | | the buyer has a VAT number | `buyer.vatId` | VAT number of the buyer | Art. 5 § 1, 4° KB nr. 1 | | each VAT row of category `AE`, `K`, `G` or `E` | `vatRows[i].label` or the legal note with its BT-120 text | reverse charge or exemption mention | Art. 5 § 1, 10° KB nr. 1 | The default templates print all of them. ## Format choice Since 1 January 2026 invoices between businesses established in Belgium are structured e-invoices, by default Peppol BIS Billing 3.0 (law of 6 February 2024). The pack's format rule, `Quittio\Country\BE\Formats\BelgianFormatRule`, chooses the format `peppol` (profile `peppol`) when: - the buyer is not a consumer, - seller and buyer both have an address in Belgium, - and the invoice does not consist only of exempt lines (category `E`) other than `VatPreset::SmallBusiness`. The last point leaves out businesses that only perform exempt supplies (Art. 44 VAT Code). The pack decides it per invoice from the lines: an invoice whose lines are all of category `E`, for example with `VatPreset::exempt()` or a margin scheme preset, is not forced to Peppol. Every other invoice keeps the automatic choice of the core ([Automatic choice](formats.md#automatic-choice)): a consumer gets a PDF, a business in another EU country ZUGFeRD, unless a [Peppol lookup](formats.md#peppol-lookup) finds it in the Peppol network. A format you request yourself (`->format('pdf')`, [Requesting a format](formats.md#requesting-a-format)) always wins over the rule. The format `peppol` produces UBL XML only ([Peppol BIS Billing 3.0](formats.md#peppol-bis-billing-30)). Render a PDF next to it with `->formats(['peppol', 'pdf'])`; the PDF carries a note that it is a readable copy of the e-invoice and that only the XML is binding. Sending the XML through a Peppol access point is not part of this pack. ### Peppol endpoints Peppol addresses seller and buyer by their electronic address (BT-34, BT-49). Belgian businesses are identified by their enterprise number (ondernemingsnummer / numéro d'entreprise) with the scheme `0208`. The pack completes the addresses before calculation and validation (`CountryBE::complete()`): a seller or buyer without electronic address and with a Belgian VAT number gets the enterprise number of that VAT number as endpoint. `BE0712345630` becomes `<cbc:EndpointID schemeID="0208">0712345630</cbc:EndpointID>`. An electronic address you set yourself is kept: ```php ->buyer(Party::make('Voorbeeld Handel NV') ->vatId('BE0765432146') ->address('Korenmarkt 10', '9000', 'Gent', 'BE') ->electronicAddress('0765432146', '0208')) // or another scheme Peppol accepts ``` The setting `peppol_endpoints = false` turns the completion off ([Settings](#settings)). A Peppol invoice without electronic addresses then fails the Peppol rules. `Quittio\Country\BE\Support\EnterpriseNumber` checks and formats enterprise numbers: ten digits, the first one `0` or `1`, the last two 97 minus the first eight modulo 97. | Method | Result | |---|---| | `EnterpriseNumber::normalize('BE 0712 345 630')` | `'0712345630'`: the ten digits, a leading `0` added to nine digits; null for other lengths | | `EnterpriseNumber::isValid('0712.345.630')` | `true` when the check digits are right | | `EnterpriseNumber::fromVatId('BE0712345630')` | `'0712345630'`; null for a VAT number of another country or with wrong check digits | | `EnterpriseNumber::format('712345630')` | `'0712.345.630'`, the usual notation | | `EnterpriseNumber::SCHEME` | `'0208'` | ## Languages and language regions The pack's default locale is `nl_BE`. It applies when neither the render call, the invoice (`->locale()`) nor the configuration (`quittio.defaults.locale`) sets one ([Translations and locales](templates.md#translations-and-locales)). The core has labels in Dutch, French, German and English, so `nl_BE`, `fr_BE` and `de_BE` print in the language with Belgian number and date formats. Belgian law ties the language of an invoice to the language region of the business's place of operation: the decrees on the use of languages of the Flemish Community (decree of 19 July 1973) and of the French Community (decree of 30 June 1982) require documents that the law prescribes, such as invoices, in the language of the region. `BE-LANG-01` warns when a seller in a language region invoices a customer in Belgium in another language. Set the locale that matches the seller: | Seller in | Post codes | Locale | `BE-LANG-01` | |---|---|---|---| | Dutch language region (Flanders) | 1500–3999, 8000–9999 | `nl_BE` | warns for other languages | | French language region (Wallonia without the German-speaking municipalities) | 1300–1499, 4000–7999 except 4700–4791 | `fr_BE` | warns for other languages | | German language region (Eupen, Kelmis, Lontzen, Raeren, Bütgenbach, Büllingen, Amel, St. Vith, Burg-Reuland) | 4700–4791 | `de_BE` | warns for other languages | | Bilingual region Brussels-Capital | 1000–1299 | `nl_BE` or `fr_BE` | not checked | - The rule checks only invoices whose seller and buyer both have an address in Belgium, consumers included. - It compares the language part of the locale (`fr` of `fr_BE`) with the region. The locale is the invoice's, otherwise the locale of the run, so an invoice without locale counts as Dutch, the pack's default. A business in Wallonia should therefore always set `->locale('fr_BE')`. - `Quittio\Country\BE\Support\LanguageRegion::of($postcode)` returns the region of a post code: `LanguageRegion::DUTCH` (`nl`), `FRENCH` (`fr`), `GERMAN` (`de`), `BILINGUAL` (`bilingual`) or null for a post code that is not Belgian. The pack derives the region from the post code alone. - The pack does not choose the locale from the seller's region by itself; the warning points out a mismatch instead ([Known limitations](#known-limitations)). ## Payment QR code The pack sets the payment QR code to `girocode` (`CountryDefaults::$paymentQr`) and ships no generator of its own. With the default QR mode `auto`, the PDF prints the EPC GiroCode, the QR code of the European Payments Council for SEPA credit transfers, when the currency is EUR, the payment means is a credit transfer with a valid IBAN and an amount is due ([Payment QR codes](templates.md#payment-qr-codes)). The structured communication of Belgian banks (OGM/VCS, "overschrijving met gestructureerde mededeling" / "virement avec communication structurée", in the form `+++090/9337/55493+++`) can be passed as remittance information (BT-83): ```php ->payment(PaymentMeansCode::SepaCreditTransfer, iban: 'BE68539007547034', remittanceInformation: '+++090/9337/55493+++') ``` The pack does not check its check digits (modulo 97), and the GiroCode carries it as unstructured remittance text, not in the field for a structured reference that the Febelfin guidelines for QR codes on invoices ask for ([Known limitations](#known-limitations)). ## Late payment When a customer pays late, the law on late payment of 2 August 2002 gives the seller interest and, from business debtors, a flat rate of 40 EUR. The pack provides these values and the reference rates. Quittio's documents do not apply them by themselves: calculate the interest with `Quittio\Core\Dunning\DefaultInterest` and pass the results to a payment reminder ([Documents: payment reminders](documents.md#payment-reminders)). `CountryBE::dunningLaw()` (also `CountryBE::belgianDunningLaw()`) returns: | Value | Belgium | |---|---| | Interest for business debtors | reference rate plus 8 percentage points | | Interest for consumers | fixed rate of 4.50 % (`b2cFixedRate`), the legal interest rate of 2026 | | Flat rate for business debtors | 40.00 EUR | | Day count | 365 days | | Consumer default | not set (`consumerDefaultAfterDays` null) | | Reference rate | "Referentie-interestvoet (wet van 2 augustus 2002)" | The law adds 8 points to the main refinancing rate of the European Central Bank on the first day of the half-year and rounds the sum up to the next half point; the FPS Finance (Federal Public Service Finance) publishes the result. `Quittio\Country\BE\Dunning\ReferenceRateTable` therefore holds the published rates minus 8 points, so that the sum is the published rate: 2.50 for 2026, which gives 10.50 %. The table starts with 1 January 2023 and ends with the second half of 2026. ```php use Brick\Money\Money; use Quittio\Core\Builder\Party; use Quittio\Core\Documents\DocumentBuilder; use Quittio\Core\Dunning\DefaultInterest; use Quittio\Core\Quittio; use Quittio\Core\Support\Date; use Quittio\Country\BE\CountryBE; $quittio = Quittio::create(['country' => 'BE'], [new CountryBE]); $interest = DefaultInterest::forCountry(new CountryBE); // reference rates and law of the pack $reminder = DocumentBuilder::paymentReminder(1) // first reminder, "1. aanmaning" ->number('H-2026-0007') ->issueDate('2026-10-20') ->locale('nl_BE') ->seller(Party::make('Voorbeeld Software BV')->vatId('BE0712345630')->address('Markt 1', '8000', 'Brugge', 'BE')) ->buyer(Party::make('Voorbeeld Handel NV')->vatId('BE0765432146')->address('Korenmarkt 10', '9000', 'Gent', 'BE')) ->creditTransfer('BE68539007547034') ->openItem('F-2026-0042', '2026-08-03', '1210.00', dueDate: '2026-09-02') // first day with interest: the day after the due date; 2026-10-20 is the first day without interest ->interestCharge(...$interest->calculate(Money::of('1210.00', 'EUR'), Date::parse('2026-09-03'), Date::parse('2026-10-20'))) ->flatRate('F-2026-0042') // 40.00 EUR for this claim ->deadline('2026-11-03'); $result = $quittio->document($reminder->build())->render(); $result->save(__DIR__.'/'.$result->filename()); // 1._aanmaning_H-2026-0007.pdf ``` - **Interest.** From 3 September to 19 October 2026 the rate is 10.50 %; on 1,210.00 EUR this gives 16.36 EUR for 47 days. A period that spans a change of the reference rate is split into one charge per rate. Pass `consumer: true` for a consumer: one charge at 4.50 %, whatever the dates. - **Flat rate.** `flatRate($claim)` adds the 40.00 EUR once per claim; the builder rejects it for a consumer and twice for the same claim in one reminder ([Payment reminders](documents.md#payment-reminders)). `$interest->flatRate()` returns the amount. - **Later rates.** For a day after 31 December 2026, `calculate()` throws an `InvalidArgumentException` ("No Belgian reference rate is known …"). Add the rate of a new half-year, the published rate minus 8 points, with `withRate()`: ```php use Quittio\Core\Dunning\DefaultInterest; use Quittio\Country\BE\CountryBE; use Quittio\Country\BE\Dunning\ReferenceRateTable; $rates = (new ReferenceRateTable)->withRate('2027-01-01', '2.50'); // example value: the published rate minus 8 points $interest = new DefaultInterest($rates, CountryBE::belgianDunningLaw()); ``` - **Consumers.** The legal interest rate changes every year, but the pack has one fixed rate of 4.50 %, which it applies to any period. For another year, pass your own `DunningLaw` with the rate of that year as `b2cFixedRate` to `new DefaultInterest(...)`. The rules of Book XIX of the Code of Economic Law on consumer debts are not modelled ([Known limitations](#known-limitations)). - **Descriptions.** `DefaultInterest::forCountry()` returns charges without a description; the reminder prints the default label of the core, e.g. "Nalatigheidsinterest 10,5 % per jaar op 1.210,00 € van 03/09/2026 tot 19/10/2026". ## Settings The pack has one setting, under `quittio.countries.be` ([Settings of a pack](configuration.md#settings-of-a-pack-quittiocountriescode)): | Key | Type | Default | Effect | |---|---|---|---| | `countries.be.peppol_endpoints` | bool | `true` | Seller and buyer without electronic address get the enterprise number of their Belgian VAT number as Peppol endpoint (scheme `0208`, [Peppol endpoints](#peppol-endpoints)). `false` = set the electronic addresses yourself. | The pack has no configuration file to publish. In Laravel, set the key in `config/quittio.php`; without Laravel, pass the same array to `Quittio::create()`: ```php laravel 'countries' => [ 'be' => ['peppol_endpoints' => false], ], ``` ```php plain use Quittio\Core\Quittio; use Quittio\Country\BE\CountryBE; $quittio = Quittio::create(['country' => 'BE', 'countries' => ['be' => ['peppol_endpoints' => false]]], [new CountryBE]); ``` The pack defines no meta flags of its own. It reads the core flag `Meta::FLAG_SMALL_BUSINESS` ([Small businesses](#small-businesses)). ## Defaults `CountryBE::defaults()`: | Value | Belgium | Effect | |---|---|---| | `locale` | `nl_BE` | last fallback for the render and validation locale ([Languages and language regions](#languages-and-language-regions)) | | `currency` | `EUR` | shown by `quittio:countries`; not applied to invoices | | `timezone` | `Europe/Brussels` | informational; also the time zone of `VatPreset::Accommodation->rate()` | | `paper` | `A4` | [Paper size](templates.md#paper-size) | | `letterLayout` | `free` | the pack has no letter layouts of its own ([Letter layouts](templates.md#letter-layouts)) | | `profile` | `peppol` | shown by `quittio:countries`; the format rule chooses Peppol where it applies ([Format choice](#format-choice)) | | `paymentQr` | `girocode` | [Payment QR code](#payment-qr-code) | | `vatPreset`, `smallBusinessVatPreset` | `be.standard`, `be.small_business` | [Default VAT](building-invoices.md#default-vat) | ### Numbering `CountryBE::numberingRules()` is used by Managed numbering ([Managed: numbering](managed.md#numbering)). An invoice needs a sequential number in one or more series (Art. 5 § 1, 2° Royal Decree No. 1). | Property | Belgium | |---|---| | `defaultPattern` | `F-{Y}-{seq:4}`, e.g. `F-2026-0042` | | `defaultReset` | `yearly` | | `allowedResets` | `never`, `yearly` (no monthly reset) | | `gapless`, `numberConsumedOnRejection` | `true`, `true` (declared, see [NumberingRules](country-packs.md#numberingrules)) | ### Retention `CountryBE::retention()` returns `new RetentionRule(7, fromEndOfCalendarYear: true)`: invoices are kept for seven years from the end of the calendar year of issue (Art. 60 § 3 VAT Code as amended by the law of 18 December 2025, for VAT due from 2023). An invoice issued on 5 October 2026 is kept until 31 December 2033. The Managed layer stores this date ([Managed: retention and deletion](managed.md#retention-and-deletion)). ### Cancellations and corrections `CountryBE::correctionPolicy()` cancels with a credit note (type code 381, positive amounts) and corrects by cancelling and issuing a new invoice ([CorrectionPolicy](country-packs.md#correctionpolicy), [Building invoices: cancellations and corrections](building-invoices.md#cancellations-and-corrections)). The titles: | Kind | Dutch | French | German | English | |---|---|---|---|---| | `cancellation` | Creditnota | Note de crédit | Gutschrift | Credit note | | `correction` | Verbeterde factuur | Facture rectificative | Berichtigte Rechnung | Corrected invoice | | `self_billed` | Zelffacturering | Autofacturation | Gutschrift (Selbstfakturierung) | Self-billed invoice | A self-billed invoice still needs the words in a note for `BE-VAT-07`, e.g. `->note('Zelffacturering')`. ## Translations The pack ships catalogs in Dutch, French, German and English in `resources/lang/{nl,fr,de,en}/`: - `rules.php`: message and hint of every rule (`BE-VAT-01` to `BE-VAT-08`, `BE-LANG-01`); - `tax.php`: the exemption reason texts of the presets, including `be.exempt` for `VatPreset::exempt()` (placeholder `:paragraph`). They are registered as the namespace `quittio-be`, e.g. `quittio-be::rules.BE-VAT-08.message`. `CountryBE::registerTranslations()` registers them lazily, so presets work without a `Quittio` instance. A regional locale such as `fr_BE` takes the texts of its language; other locales fall back to English. `CountryBE::locales()` lists the shipped locales (`de`, `en`, `fr`, `nl`). The correction policy titles are defined in PHP and cannot be changed through files. With Laravel, Laravel's translator is used, so the usual override files apply: `lang/vendor/quittio-be/{locale}/rules.php` and `tax.php`, also for additional locales. A file needs only the keys it changes. Without Laravel, add a directory of your own after the pack has registered its texts; a path added later overrides earlier ones: ```php use Quittio\Core\I18n\Translations; use Quittio\Core\Quittio; use Quittio\Country\BE\CountryBE; $quittio = Quittio::create(['country' => 'BE'], [new CountryBE]); CountryBE::registerTranslations(); // lang/nl/rules.php: return ['BE-VAT-03' => ['hint' => 'Vraag het btw-nummer van de klant op.']]; Translations::translator()->addPath(__DIR__.'/lang', CountryBE::TRANSLATION_NAMESPACE); ``` Change the wording of a legal mention in `tax.php` only after checking it; the rules `BE-VAT-04` and `BE-VAT-05` read the texts. ## The Belgian pack's hooks For pack authors, this is how `CountryBE` fills the [`CountryPack` contract](country-packs.md#the-countrypack-contract): | Hook | Belgium | |---|---| | `defaults()` | [Defaults](#defaults) | | `profiles()` | none (the core profile `peppol` is used) | | `taxPresets()` | every case of [`VatPreset`](#tax-presets) | | `rules()` | [`BE-VAT-01` to `BE-VAT-08` and `BE-LANG-01`](#rules) | | `buyerCountryRules()` | none | | `formatRules()` | [`BelgianFormatRule`](#format-choice) | | `mandatoryOutput()` | [mandatory PDF output](#mandatory-pdf-output) | | `legalTexts()` | none | | `numberingRules()` | [pattern `F-{Y}-{seq:4}`, resets `never` and `yearly`](#numbering) | | `retention()` | [7 years from the end of the calendar year](#retention) | | `dunningLaw()` | [law of 2 August 2002](#late-payment) | | `correctionPolicy()` | [credit note, cancel and reissue](#cancellations-and-corrections) | | `letterLayouts()`, `paymentQr()`, `addressFormatter()` | defaults: `free`, EPC GiroCode, international address format | | `translationPath()` | `resources/lang` of the package | | `complete()` (`CompletesInvoices`) | [Peppol endpoints](#peppol-endpoints) | | `referenceRates()` (`ProvidesReferenceRates`) | [`ReferenceRateTable`](#late-payment) | ## Known limitations - The legal wording, rules and defaults have not been reviewed by a Belgian tax adviser (see the notice at the top). - The locale is not chosen from the seller's language region; `BE-LANG-01` points out a mismatch instead. The language rules beyond the main language are not modelled either: Flanders allows a second binding version only for customers in another EU or EEA state, the French language region an additional language of the parties' choice, Brussels Dutch or French. - Structured communication (OGM/VCS, `+++…+++`, check digits modulo 97) is not checked, and the GiroCode carries it as unstructured text instead of in the reference field (EPC069-12 version 002) as the Febelfin guidelines for QR codes on invoices ask. - There is no Laravel service provider with a configuration file; set the one setting in `config/quittio.php` ([Settings](#settings)). - Consumer debts (Book XIX of the Code of Economic Law): the free first reminder, the waiting period of 14 calendar days, interest of at most the reference rate plus 8 points and the agreed flat rates (20 EUR, 30 EUR plus 10 %, 65 EUR plus 5 %, at most 2,000 EUR) are not modelled. The consumer rate is one fixed rate of 4.50 %. - Reference rates from 2027: `ReferenceRateTable` ends with the second half of 2026; add later half-years with `withRate()`. - Sending through a Peppol access point is not part of the pack. - The pack has no rules for foreign sellers invoicing Belgian buyers, and no exporters or readers. ## Complete example A software company in Bruges invoices a trading company in Ghent for ten hours of web development and a handbook. Both are businesses in Belgium, so the pack chooses Peppol BIS, adds the enterprise numbers as Peppol endpoints and checks the Belgian mentions. The seller is in the Dutch language region, so the invoice is in Dutch. ```php <?php require __DIR__.'/vendor/autoload.php'; use Quittio\Core\Builder\InvoiceBuilder; use Quittio\Core\Builder\Party; use Quittio\Core\Enums\PaymentMeansCode; use Quittio\Core\Enums\UnitCode; use Quittio\Core\Quittio; use Quittio\Core\Tax\CountryDefaultVat; use Quittio\Country\BE\CountryBE; use Quittio\Country\BE\Tax\VatPreset; $quittio = Quittio::create(['country' => 'BE'], [new CountryBE]); InvoiceBuilder::useDefaultVat(new CountryDefaultVat($quittio->countries())); // lines without vat: 21 % $invoice = InvoiceBuilder::make() ->number('F-2026-0042') ->issueDate('2026-10-05') ->deliveryDate('2026-09-30') // invoice by 15 October (BE-VAT-08) ->locale('nl_BE') // Bruges: Dutch language region (BE-LANG-01) ->buyerReference('PO-4711') // Peppol needs BT-10 or BT-13 ->seller(Party::make('Voorbeeld Software BV') ->vatId('BE0712345630') // enterprise number 0712.345.630 ->address('Markt 1', '8000', 'Brugge', 'BE') ->contact('An Peeters', '+32 50 12 34 56', 'facturen@voorbeeld-software.example')) ->buyer(Party::make('Voorbeeld Handel NV') ->vatId('BE0765432146') ->address('Korenmarkt 10', '9000', 'Gent', 'BE')) ->line('Webontwikkeling', netPrice: '95.00', quantity: 10, unit: UnitCode::Hour) // 21 % ->line('Handboek', netPrice: '40.00', vat: VatPreset::Reduced) // 6 % ->payment(PaymentMeansCode::SepaCreditTransfer, iban: 'BE68539007547034', remittanceInformation: '+++090/9337/55493+++') ->dueInDays(30) ->build(); // Peppol BIS (the binding e-invoice) and a readable PDF from one calculation $result = $quittio->make($invoice)->formats(['peppol', 'pdf'])->render(); $result->format(); // "peppol" $result->save(__DIR__.'/'.$result->filename()); // Factuur_F-2026-0042.xml $result->as('pdf')->save(__DIR__.'/'.$result->as('pdf')->filename()); // Factuur_F-2026-0042.pdf $result->validation()->isValid(); // true, no errors or warnings $result->data()->seller->electronicAddress?->value; // "0712345630", scheme 0208 echo $result->data()->totals->amountDue; // EUR 1191.90 ``` - `render()` calculates, validates and renders. An error, e.g. a missing address (`BE-VAT-02`) or a missing buyer reference (`PEPPOL-EN16931-R003`), throws a `ValidationException`; warnings such as `BE-VAT-03` or `BE-LANG-01` are in `$result->validation()->warnings()`. To check without rendering, call `$quittio->make($invoice)->check()` ([Validation](validation.md)). - The XML contains `<cbc:EndpointID schemeID="0208">0712345630</cbc:EndpointID>` for the seller and `0765432146` for the buyer ([Peppol endpoints](#peppol-endpoints)). Hand it to your Peppol access point. - The PDF is in Dutch ("Factuur", "Totaal incl. btw"), with Belgian date formats and a GiroCode for the transfer. - With Laravel, the seller and its bank account come from `config/quittio.php`, and `Quittio::invoice()` starts the invoice ([Laravel integration](laravel.md#starting-invoices)). Set `defaults.country` to `BE` for invoices whose seller has no country code. <!-- Source: https://quittio.dev/docs/country-ch --> # Switzerland (`quittio/country-ch`) > **Not reviewed by a tax adviser yet.** The legal wording, rules and defaults of this pack follow the law and the official sources as of October 2026, but have not been reviewed by a Swiss tax adviser. Check the mentions and rates of your invoices before you rely on them. Quittio is no tax or legal advice; the business that issues an invoice remains responsible for it. Until the review the pack is not covered by the [compatibility promise](compatibility.md#country-packs-without-tax-review): a minor release may change it. The Swiss pack implements the invoice requirements of the Swiss VAT act (MWSTG, Mehrwertsteuergesetz) and of its ordinance (MWSTV, Mehrwertsteuerverordnung), the Swiss QR bill and the rule on default interest of the Swiss Code of Obligations (OR, Obligationenrecht). Its class is `Quittio\Country\CH\CountryCH` (code `CH`, translation namespace `quittio-ch`). Switzerland has no e-invoicing obligation. The focus of the pack is therefore the payment: an invoice of a Swiss seller in CHF or EUR with a Swiss or Liechtenstein bank account gets the QR bill, a payment part with receipt whose code banking apps can scan. This page writes Swiss legal references in English form: "Art. 26 (2) lit. a MWSTG" stands for "Art. 26 Abs. 2 Bst. a MWSTG". Texts that the pack prints keep their German, French or Italian form; the French and Italian texts name the act LTVA and LIVA. ## Installation ```bash composer require quittio/country-ch ``` The pack is not part of `quittio/quittio`. Install it next to `quittio/quittio` (Laravel) or next to `quittio/core`. It is developed in [`packages/country-ch`](https://github.com/Quittio/quittio/tree/master/packages/country-ch) of the monorepo and published as the read-only repository [Quittio/country-ch](https://github.com/Quittio/country-ch); please open issues and pull requests in the monorepo. - **Laravel.** The pack declares itself in its `composer.json` (`extra.quittio.country-packs`), so Laravel finds it after the installation; there is nothing to register ([Registering packs](country-packs.md#registering-packs)). The pack has no service provider and no configuration file of its own. Its one setting goes into `config/quittio.php` ([Meta flags and settings](#meta-flags-and-settings)). `php artisan quittio:countries` lists it ([Artisan commands](commands.md#quittiocountries)). - **Without Laravel.** Pass the pack to `Quittio::create()`: ```php use Quittio\Core\Quittio; use Quittio\Country\CH\CountryCH; $quittio = Quittio::create(['country' => 'CH'], [new CountryCH]); $quittio->countries()->get('CH'); // the registered CountryCH ``` `'country' => 'CH'` makes Switzerland the default country for invoices whose seller has no country code; it is optional. ## When it applies The pack leads every invoice whose seller has the country code `CH` (BT-40). It then checks the [MWSTG rules](#rules), prints the [QR bill](#qr-bill), applies the [rounding to 5 Rappen](#rounding-to-5-rappen) when asked for, and provides its [defaults](#defaults): the locale `de_CH` (unless the invoice or the configuration sets one), A4 paper and the Swiss VAT labels. How Quittio chooses the leading pack is described in [How a pack is selected](country-packs.md#how-a-pack-is-selected). - **Currencies.** The rules apply to invoices in any currency. The QR bill is printed for invoices in CHF and EUR only; the rounding to 5 Rappen applies to CHF only. - **Liechtenstein.** Switzerland and Liechtenstein form one area of application of the VAT (treaty of 28 November 1994); Liechtenstein takes over the material provisions of the Swiss VAT law into its own law. The pack therefore also leads the invoices of sellers with the country code `LI` ([`VatTerritory::vatCountry()`](country-packs.md#how-a-pack-is-selected)), and an invoice between Switzerland and Liechtenstein is domestic. The rules cite the Swiss MWSTG. The QR bill accepts bank accounts of Liechtenstein (IBAN `LI…`). - **Buyers in Switzerland.** The pack defines no rules for buyers, so it adds nothing to an invoice of a foreign seller to a Swiss buyer. - **Formats.** The pack defines no profiles and no format rules. The automatic choice of Quittio gives an invoice between two Swiss businesses the format `zugferd` (a PDF with embedded EN 16931 XML) and an invoice to a buyer in another country usually a plain `pdf` ([Automatic choice](formats.md#automatic-choice)). Request `->format('pdf')` when your customers want no XML in the PDF. ## Common tasks | You want to | Read | |---|---| | Set the VAT rate or an exemption on a line | [Tax presets](#tax-presets) | | Invoice without VAT registration | [Sellers not registered for VAT](#sellers-not-registered-for-vat) | | Look up a validation code such as `CH-MWSTG-02` | [Rules](#rules) | | Print the QR bill with a QR reference or a Creditor Reference | [QR bill](#qr-bill), [References](#references) | | Create or check a QR reference or a Creditor Reference | [The classes `QrReference` and `CreditorReference`](#the-classes-qrreference-and-creditorreference) | | Round the amount due to 5 Rappen | [Rounding to 5 Rappen](#rounding-to-5-rappen) | | Send a reminder with default interest | [Late payment](#late-payment) | | Change a label such as "MWST-Nr." | [Languages](#languages) | | See a complete invoice | [Complete example](#complete-example) | ## Tax presets A tax preset is a ready-made VAT treatment for an invoice line: it sets the VAT category (BT-151), the rate and, for supplies without VAT, the exemption reason code (BT-121) and text (BT-120). The categories are the codes of EN 16931 (`S` standard rate, `E` exempt, `G` export, `O` not subject to VAT; see [Categories](building-invoices.md#categories)). How presets work in general is described in [Building invoices: Tax presets](building-invoices.md#tax-presets). `Quittio\Country\CH\Tax\VatPreset` is a string-backed enum. Apply it per line: ```php use Quittio\Core\Builder\InvoiceBuilder; use Quittio\Core\Enums\UnitCode; use Quittio\Country\CH\Tax\VatPreset; $builder = InvoiceBuilder::make() // ... seller, buyer, payment ->line('Software development', netPrice: '145.00', quantity: 12, unit: UnitCode::Hour, vat: VatPreset::Standard) // 8.1 % ->line('Specialist book', netPrice: '39.00', quantity: 2, unit: UnitCode::Piece, vat: VatPreset::Reduced) // 2.6 % ->line('Hotel room', netPrice: '180.00', quantity: 2, unit: UnitCode::Day, vat: VatPreset::Accommodation) // 3.8 % // an excluded supply with its legal reference; // the invoice prints "Von der Steuer ausgenommen nach Art. 21 Abs. 2 Ziff. 11 MWSTG" ->line('Course fee', netPrice: '400.00', vat: VatPreset::excluded('Art. 21 Abs. 2 Ziff. 11 MWSTG')); ``` | Case | Key | Category | Rate | Code (BT-121) | Use | |---|---|---|---|---|---| | `Standard` | `ch.standard` | `S` | 8.1 (of the supply date) | – | Standard rate (Art. 25 (1) MWSTG) | | `Reduced` | `ch.reduced` | `S` | 2.6 (of the supply date) | – | Reduced rate (Art. 25 (2) MWSTG), e.g. food, books, medicines | | `Accommodation` | `ch.accommodation` | `S` | 3.8 (of the supply date) | – | Special rate for accommodation (Art. 25 (4) MWSTG) | | `Excluded` | `ch.excluded` | `E` | 0 | – | Supply excluded from the tax, without input tax deduction (Art. 21 MWSTG) | | `VatPreset::excluded(string $paragraph, $code = null)` | `ch.excluded` | `E` | 0 | `$code` (enum, raw code or string) | An excluded supply that names its case, e.g. `Art. 21 Abs. 2 Ziff. 3 MWSTG` | | `Export` | `ch.export` | `G` | 0 | `VATEX-EU-G` | Supply exempt from the tax with input tax deduction, e.g. an export (Art. 23 MWSTG) | | `NotTaxableInSwitzerland` | `ch.not_taxable` | `O` | none | `VATEX-EU-O` | Supply whose place is abroad (Art. 7 and 8 MWSTG), not taxable in Switzerland | | `NotRegistered` | `ch.not_registered` | `O` | none | `VATEX-EU-O` | Seller not registered for VAT, e.g. below a turnover of CHF 100,000 (Art. 10 (2) MWSTG); see [below](#sellers-not-registered-for-vat) | The codes in column BT-121 are VATEX codes, the standard codes for the reason of an exemption. `VatPreset::excluded()` returns a `Quittio\Country\CH\Tax\CustomVatPreset` with the key `ch.excluded`; it carries a code only when you pass one. ### Rates by supply date `Standard`, `Reduced` and `Accommodation` take the rate that applied on the supply date of the line (`Quittio\Country\CH\Tax\TaxTables`). The supply date is determined by the core (`Quittio\Core\Tax\SupplyDate`), as described for the [German presets](country-packs.md#tax-presets): the end of the line period, its start, the VAT point date, the delivery date, the end of the invoicing period or the issue date, in this order. | From | `Standard` | `Reduced` | `Accommodation` | |---|---|---|---| | 1 January 2011 | 8.0 | 2.5 | 3.8 | | 1 January 2018 | 7.7 | 2.5 | 3.7 | | 1 January 2024 | 8.1 | 2.6 | 3.8 | The first row also applies to supplies before 2011. A supply of December 2023 invoiced in 2024 therefore gets 7.7 %: ```php use Quittio\Core\Builder\InvoiceBuilder; use Quittio\Country\CH\Tax\VatPreset; InvoiceBuilder::make() ->issueDate('2024-02-01') ->deliveryDate('2023-12-15') ->line('Consulting', netPrice: '100.00', vat: VatPreset::Standard); // 7.7 % ``` `VatPreset::Standard->rate()` returns the rate of today in the time zone `Europe/Zurich`. `TaxTables::standardRateOn(Date $date)`, `reducedRateOn()` and `accommodationRateOn()` return the rate of a date. Not included: the increase of the standard rate to 8.5 % and of the accommodation rate to 4.0 % (the reduced rate stays at 2.6 %), on which the vote of 29 November 2026 decides; the Federal Council sets the date, at the earliest 2028. The law limits the accommodation rate to the end of 2027; an extension until 2031 is not yet in force. The tables keep the current rates after these dates until a new release changes them. ### Sellers not registered for VAT A seller that is not registered for VAT uses `VatPreset::NotRegistered` on every line. The invoice then shows no VAT, and the PDF prints the note "Nicht im MWST-Register eingetragen; keine Mehrwertsteuer". The rule [`CH-MWSTG-05`](#rules) reports VAT on an invoice that has such a line. Such a seller has no VAT identifier. EN 16931 still requires an identifier of the seller in the XML (BR-CO-26: BT-29, BT-30 or BT-31), so give one, e.g. the company's UID number as registration number: ```php use Quittio\Core\Builder\Party; $seller = Party::make('Atelier Gerber') ->legalRegistration('CHE-109.322.551') // BT-30 ->address('Rue du Marché 4', '1204', 'Genève', 'CH'); ``` The pack names `ch.not_registered` as the preset for small businesses (`CountryDefaults::$smallBusinessVatPreset`). An invoice with the flag `Meta::FLAG_SMALL_BUSINESS` (in Laravel `quittio.seller.small_business = true`, see [Seller](configuration.md#seller), without Laravel `'small_business' => true` in `Quittio::create()`; applied by `Quittio::invoice()` and `$quittio->invoice()`) therefore gives lines without `vat()` the preset `NotRegistered`. The flag itself triggers no Swiss rule; `CH-MWSTG-05` looks at the presets of the lines. ### Default VAT and lookup Lines without `vat()` take the [default VAT](building-invoices.md#default-vat). With `CountryDefaultVat` (installed by the Laravel integration, or by `InvoiceBuilder::useDefaultVat(new CountryDefaultVat($quittio->countries()))` without Laravel) that is `VatPreset::Standard` for a Swiss seller and `VatPreset::NotRegistered` for an invoice flagged as small business. In Laravel, `quittio.defaults.vat` can name another key, e.g. `'ch.reduced'`. A stored key is resolved with `VatPreset::from('ch.standard')`, `VatPreset::fromKey($key)` (null for keys of other packs), `(new CountryCH)->taxPresets()->get('ch.standard')` or, across all installed packs, `$quittio->countries()->taxPreset('ch.standard')`. The key stays on the line (`$line->vat->presetKey`); `CH-MWSTG-05` relies on it. ### Exemption texts `Standard`, `Reduced` and `Accommodation` carry no text, because EN 16931 allows no exemption reason for category `S`. The other presets print an exemption reason (BT-120) from `resources/lang/{de,fr,it,en}/tax.php`: | Key | German | French | Italian | English | |---|---|---|---|---| | `ch.excluded` | Von der Steuer ausgenommene Leistung (Art. 21 MWSTG) | Prestation exclue du champ de l'impôt (art. 21 LTVA) | Prestazione esclusa dall'imposta (art. 21 LIVA) | Supply excluded from VAT (Art. 21 MWSTG) | | `ch.excluded_by` (`VatPreset::excluded()`) | Von der Steuer ausgenommen nach :paragraph | Exclue du champ de l'impôt selon :paragraph | Esclusa dall'imposta secondo :paragraph | Excluded from VAT under :paragraph | | `ch.export` | Von der Steuer befreite Ausfuhr (Art. 23 MWSTG) | Exportation exonérée de l'impôt (art. 23 LTVA) | Esportazione esente dall'imposta (art. 23 LIVA) | Export exempt from VAT (Art. 23 MWSTG) | | `ch.not_taxable` | Nicht im Inland steuerbare Leistung (Ort der Leistung im Ausland) | Prestation non imposable sur le territoire suisse (lieu de la prestation à l'étranger) | Prestazione non imponibile in territorio svizzero (luogo della prestazione all'estero) | Not taxable in Switzerland (place of supply abroad) | | `ch.not_registered` | Nicht im MWST-Register eingetragen; keine Mehrwertsteuer | Non inscrit au registre des assujettis à la TVA ; pas de TVA | Non iscritto nel registro dei contribuenti IVA; nessuna IVA | Not registered for Swiss VAT; no VAT charged | - **Language.** The text is taken in the invoice locale (`->locale()` on the builder) when the invoice is built. Without a locale, the presets use German. The enum presets also find the text of a regional locale such as `fr_CH` (it takes the French text). `VatPreset::excluded()` behaves the same. - **PDF.** The PDF lists the texts in its legal notes, below the totals. - **Your own texts.** The texts come from the translation files of the pack and can be overridden like its labels ([Languages](#languages)). ## Rules The pack checks the elements of an invoice that Art. 26 (2) MWSTG requires, as far as the data shows them. The rules are of level L3 ([Validation levels](validation.md#validation-levels)) and apply independent of the format. An error stops rendering in the default validation mode `error`; a warning does not ([Errors while rendering](validation.md#errors-while-rendering)). | Code | Severity | Field | Check | |---|---|---|---| | `CH-MWSTG-01` | error | BT-37 (`seller.address.city`) | The place of the seller must be given (Art. 26 (2) lit. a MWSTG). The rule checks the city; the name is required by EN 16931 anyway (BR-6). | | `CH-MWSTG-02` | error | BT-31 (`seller.vatId`) | An invoice that charges VAT (a VAT amount other than zero in the VAT breakdown) must state the UID number under which the seller is registered for VAT (Art. 26 (2) lit. a MWSTG). The VAT identifier of a tax representative (BT-63) is accepted as well. | | `CH-MWSTG-03` | warning | BT-31 (`seller.vatId`) | A UID number (a VAT identifier that starts with `CHE`) should carry the note of the VAT registration, e.g. `CHE-123.456.789 MWST`. Accepted are the notes `MWST`, `TVA` and `IVA`, in any case. VAT identifiers of other countries are not checked. | | `CH-MWSTG-04` | error | BT-52 (`buyer.address.city`) | The place of the buyer must be given (Art. 26 (2) lit. b MWSTG). Exception: a till receipt up to CHF 400 (Art. 57 MWSTV), see below. | | `CH-MWSTG-05` | error | BT-117 (`vatBreakdown[].taxAmount`) | A seller that is not registered for VAT must not charge VAT; VAT shown is owed by reason of the invoice (Art. 27 (2) MWSTG). The rule applies when any line uses `VatPreset::NotRegistered` and reports every row of the VAT breakdown with a VAT amount other than zero. | - **Till receipts.** `MwstgRules::isTillReceipt(InvoiceData $invoice)` is true for a calculated invoice in CHF whose total including VAT (BT-112) is at most CHF 400 (`TaxTables::TILL_RECEIPT_LIMIT`). Such an invoice may leave out the buyer's place. EN 16931 still requires a buyer name (BR-7), e.g. "Barverkauf" (cash sale). - **UID numbers.** The builder removes spaces from VAT identifiers, but keeps one before the note of the VAT registration of a UID number (`MWST`, `TVA` or `IVA`): `->vatId('CHE-123.456.789 MWST')` and `->vatId('CHE-123.456.789MWST')` are both stored and printed as "CHE-123.456.789 MWST". `CH-MWSTG-03` accepts both forms. - **Other elements.** Art. 26 (2) MWSTG also names the date or period of the supply, the kind and extent of the supply, the amount and the rate. Quittio's EN 16931 rules and the [mandatory field guard](templates.md#mandatory-field-guard) cover these values; the pack has no rule of its own for them. - **Messages.** The messages exist in German, French, Italian and English (`resources/lang/{de,fr,it,en}/rules.php`, keys such as `quittio-ch::rules.CH-MWSTG-02.message`); other locales get English. Most German and English messages have a hint with the builder method that fixes the error. - **Switching rules off.** Like every rule, a Swiss rule can be switched off or changed in severity with `validation.rules` ([Switching rules off](validation.md#switching-rules-off-and-changing-their-severity)). ### Mandatory PDF output `CountryCH::mandatoryOutput()` adds two values to the [mandatory field guard](templates.md#mandatory-field-guard), which checks that the template prints them: | Value | When | Legal basis | |---|---|---| | `seller.vatId`: the UID number with the note MWST | the seller has a VAT identifier | Art. 26 (2) lit. a MWSTG | | `servicePeriod`, `deliveryDate` or `delivery.date`: the date or period of the supply | the invoice has a delivery date or an invoicing period | Art. 26 (2) lit. c MWSTG | The default templates print both. The guard matters only for your own templates. ## QR bill `Quittio\Country\CH\QrBill\SwissQrBillGenerator` (key `swiss-qr-bill`) creates the Swiss QR Code (Swiss Payments Code `SPC`, version `0200`) after the Swiss Implementation Guidelines QR-bill 2.3 of SIX, and its payment part with receipt. `CountryCH::paymentQr()` returns it, and the pack's defaults name `swiss-qr-bill` as payment QR code, so the default QR mode `auto` uses it for every invoice the pack leads ([Payment QR codes](templates.md#payment-qr-codes)). The default templates print it after the [payment slip layout of the core](templates.md#payment-slips): at the bottom of a page of its own, the code at 46 × 46 mm with the Swiss cross in the middle, the headings in the language of the invoice, the texts in [Liberation Sans](templates.md#fonts). The PDF stays PDF/A-3b; the pack's tests check this with veraPDF. ### When the code is printed The generator creates a code when all of these hold: - the currency is CHF or EUR; - the invoice has a credit transfer account (BG-17) with a valid IBAN of Switzerland or Liechtenstein (21 characters, `CH…` or `LI…`); the first such account is used; - the seller's address has a post code, a city and a two-letter country code; - the amount due (BT-115) is more than zero and at most 999,999,999.99; - with a QR-IBAN, a QR reference can be found or built ([References](#references)). As for every payment QR code, Quittio prints none on credit notes, negative invoices and self-billed invoices. Without a code the invoice is printed as usual, without the extra page. ### References A QR-IBAN is an IBAN with an institution identification (positions 5 to 9) from 30000 to 31999; `SwissQrBillGenerator::isQrIban(string $iban)` tells it apart. A QR-IBAN needs a QR reference, an ordinary IBAN takes a Creditor Reference or no reference. The generator reads the remittance information (BT-83, `remittanceInformation:` of `->payment()`): | Account | Remittance information (BT-83) | Reference in the code | Unstructured message | |---|---|---|---| | QR-IBAN | a valid QR reference | `QRR` with that reference | the invoice number | | QR-IBAN | anything else or empty | `QRR` with the QR reference of the digits of the invoice number (`RE-2026-0042` becomes `000000000000000000202600427`) | the remittance information, otherwise the invoice number | | QR-IBAN | anything else or empty, and the invoice number has no digits or more than 26 | no code | – | | IBAN | a valid Creditor Reference | `SCOR` with that reference (upper case, without spaces) | the invoice number | | IBAN | anything else or empty | `NON`, no reference | the remittance information, otherwise the invoice number | The generator never builds a Creditor Reference on its own. To print one with an ordinary IBAN, pass it as remittance information: ```php use Quittio\Core\Enums\PaymentMeansCode; use Quittio\Country\CH\QrBill\CreditorReference; $builder->payment( PaymentMeansCode::SepaCreditTransfer, iban: 'CH93 0076 2011 6238 5295 7', remittanceInformation: CreditorReference::fromCharactersOf('RE-2026-0043'), // RF70RE20260043 ); ``` ### Parties, amount and message - **Creditor.** The account name of the credit transfer account (`accountName:` of `->payment()`), otherwise the seller's name, with the seller's address. - **Debtor.** The buyer, if its address has a post code, a city and a two-letter country code. Otherwise the debtor fields stay empty, and the slip shows the field "Zahlbar durch (Name/Adresse)" to fill in by hand. - **Addresses** are structured (address type `S`): name, street, building number, post code, town and country. A building number at the end of the first address line becomes the building number: "Bahnhofstrasse 12" gives the street "Bahnhofstrasse" and the number "12"; forms such as "12a" or "12-14" are recognised as well. - **Ultimate creditor.** Always empty; the guidelines reserve it for future use. - **Amount.** The amount due (BT-115) with two decimals, after prepaid amounts and a [rounding amount](#rounding-to-5-rappen). - **Text.** Characters outside the character set of the guidelines are removed and line breaks become spaces. Names, streets and messages are cut to the lengths of the guidelines (name and street 70, building number and post code 16, town 35, message 140 characters). `$generator->payload($invoice)` returns the content of the code for a calculated invoice, or null when no code can be created. The `payment.qrCode` node of the [view model](templates.md#payment) holds it as `payload`, with the type `swiss-qr-bill` and the printed values in `slip`. ### What is printed | Part | Payment part | Receipt | |---|---|---| | Title | "Zahlteil" | "Empfangsschein" | | "Konto / Zahlbar an" | IBAN in groups of four, creditor name and address | the same | | "Referenz" | QR reference in blocks (`00 00000 00000 00000 02026 00427`) or Creditor Reference in groups of four; left out without reference | the same | | "Zusätzliche Informationen" | the unstructured message | – | | "Zahlbar durch" | debtor name and address, or the empty field "Zahlbar durch (Name/Adresse)" | the same | | "Währung", "Betrag" | currency and amount with a space as thousands separator (`1 960.95`) | the same | | "Annahmestelle" | – | the acceptance point | The note "Vor der Einzahlung abzutrennen" (separate before paying in) is printed at the separation line. Addresses outside Switzerland get the country code before the post code, e.g. "LI-9490 Vaduz". The headings are printed in the language of the invoice locale: German, French, Italian or English ([Languages](#languages)); other languages get German. The Swiss cross is a PNG image and needs the PHP extension GD (`SwissCross::dataUri()` returns null without it). ### The QR mode The payment QR mode `auto` (the default, `pdf.payment_qr.type` in Laravel, `Presentation::$paymentQr`) and the mode `swiss-qr-bill` both print the QR bill of the pack. A generator registered with `setPaymentQrGenerator()` (Laravel: `pdf.payment_qr.generator`) takes precedence in both modes, for the invoices of every country. The mode `none` prints no code, `girocode` an EPC GiroCode, which exists for EUR only ([Payment QR codes](templates.md#payment-qr-codes)). ### Payment reminders A [payment reminder](documents.md#payment-reminders) of a Swiss seller gets the Swiss QR Code over the total of the reminder, with the open invoice numbers as unstructured message. With a QR-IBAN its reference is the QR reference of the digits of the reminder number (`M-2026-0003` gives `000000000000000000202600037`). The reminder gets the payment part and receipt like an invoice, with the total of the reminder as amount, on a page of its own at the end. ### The classes `QrReference` and `CreditorReference` `Quittio\Country\CH\QrBill\QrReference` is the QR reference of the Swiss QR bill: 27 digits, the last a check digit after modulo 10 recursive. It goes with a QR-IBAN only. | Method | Result | |---|---| | `isValid(string $reference): bool` | whether the reference (spaces allowed) has 27 digits and a correct check digit | | `fromDigitsOf(string $value): ?string` | the QR reference of the digits of `$value`, padded with zeros to 26 digits, plus the check digit; null without digits or with more than 26 | | `checkDigit(string $digits): string` | the check digit of a string of digits | | `format(string $reference): string` | the reference in blocks for printing: two digits, then blocks of five | `Quittio\Country\CH\QrBill\CreditorReference` is the Creditor Reference of ISO 11649: `RF`, two check digits (modulo 97-10) and up to 21 letters and digits. It goes with an ordinary IBAN. | Method | Result | |---|---| | `isValid(string $reference): bool` | whether the reference (spaces allowed, any case) has correct check digits | | `fromCharactersOf(string $value): ?string` | the Creditor Reference of the letters and digits of `$value`; null without any or with more than 21 | | `format(string $reference): string` | the reference in groups of four for printing | ```php use Quittio\Country\CH\QrBill\CreditorReference; use Quittio\Country\CH\QrBill\QrReference; QrReference::fromDigitsOf('RE-2026-0042'); // "000000000000000000202600427" QrReference::format('000000000000000000202600427'); // "00 00000 00000 00000 02026 00427" QrReference::isValid('21 00000 00003 13947 14300 09017'); // true CreditorReference::fromCharactersOf('539007547034'); // "RF18539007547034" CreditorReference::format('RF18539007547034'); // "RF18 5390 0754 7034" CreditorReference::isValid('RF18 5390 0754 7034'); // true ``` A QR reference made from the invoice number lets you match an incoming payment to the invoice by its digits. If your bank or your accounting gives you QR references of another structure, pass them as remittance information; the generator uses a valid one as it is. ## Rounding to 5 Rappen Amounts in CHF are usually rounded to 5 Rappen (0.05 CHF) in Switzerland. The pack can round the amount due to a multiple of 0.05 by adding a rounding amount (BT-114). The VAT and the line amounts stay unchanged, and the XML carries the rounding amount, so the e-invoice stays consistent. Switch the rounding on per invoice with the flag `CountryCH::FLAG_CASH_ROUNDING` (`ch.cash_rounding`), or for all invoices with the setting `cash_rounding` ([Meta flags and settings](#meta-flags-and-settings)): ```php use Quittio\Country\CH\CountryCH; $builder->flag(CountryCH::FLAG_CASH_ROUNDING); ``` - **When.** `CountryCH::complete()` adds the rounding amount when Quittio renders or prepares the invoice (`render()`, `check()`, `prepare()`), not when it is built. `$result->data()` holds the rounded invoice. - **How.** Half up to 0.05: an amount due of 108.12 becomes 108.10 (rounding amount −0.02), 108.14 becomes 108.15 (+0.01). `Quittio\Country\CH\Rounding\CashRounding::round(BigDecimal $amount)` rounds a single amount, `CashRounding::apply(InvoiceData $invoice)` an invoice. - **Only CHF.** Invoices in another currency are not rounded. - **Your own rounding wins.** An invoice with a rounding amount of its own (`->rounding('0.00')`, see [Prepaid amounts and rounding](building-invoices.md#prepaid-amounts-and-rounding)) is not changed. With the setting switched on, `->rounding('0.00')` therefore keeps a single invoice unrounded; removing the flag does not. - **The QR bill** carries the rounded amount due. ## Late payment Under Art. 104 OR a debtor in default owes 5 % default interest a year. `CountryCH::dunningLaw()` returns these values ([`DunningLaw`](country-packs.md#dunninglaw)): | Value | Switzerland | |---|---| | Interest for business debtors | 5 % fixed (`b2bFixedRate`) | | Interest for consumers | 5 % fixed (`b2cFixedRate`) | | Reference rate | none | | Flat rate for business debtors | none | | Day count | 365 days | | Consumer default after days | not set | As in other countries, Quittio's documents do not apply these values by themselves. `Quittio\Core\Dunning\DefaultInterest::forCountry(new CountryCH)` calculates the interest; because both rates are fixed (`DunningLaw::hasFixedRates()`), the pack needs no reference rate table, and every period is one charge at 5 %. Pass the charges to a payment reminder ([Payment reminders](documents.md#payment-reminders)): ```php use Brick\Money\Money; use Quittio\Core\Builder\Party; use Quittio\Core\Documents\DocumentBuilder; use Quittio\Core\Dunning\DefaultInterest; use Quittio\Core\Quittio; use Quittio\Core\Support\Date; use Quittio\Country\CH\CountryCH; $quittio = Quittio::create([], [new CountryCH]); $reminder = DocumentBuilder::paymentReminder(1) // first reminder ("1. Mahnung") ->number('M-2026-0003') ->issueDate('2026-12-10') ->currency('CHF') ->seller(Party::make('Bergsoft AG')->vatId('CHE-123.456.788 MWST')->address('Bahnhofstrasse 12', '8001', 'Zürich', 'CH')) ->buyer(Party::make('Muster GmbH')->address('Marktgasse 28', '3011', 'Bern', 'CH')) ->creditTransfer('CH93 0076 2011 6238 5295 7') ->openItem('RE-2026-0042', '2026-10-05', '1960.95', dueDate: '2026-11-04'); // 5 % for the whole time; the end date is exclusive, so 10 December is the last day with interest $reminder->interestCharge(...DefaultInterest::forCountry(new CountryCH)->calculate( Money::of('1960.95', 'CHF'), Date::parse('2026-11-05'), Date::parse('2026-12-11'), )); $result = $quittio->document($reminder->build())->render(); // 1._Mahnung_M-2026-0003.pdf ``` - The charges have no description of their own; the reminder prints the default text, e.g. "Verzugszinsen 5 % p. a. auf 1'960.95 CHF vom 05.11.2026 bis 10.12.2026". - `calculate()` takes `consumer: true` for consumers; the rate is the same. `flatRate()` of `DefaultInterest` returns null, because the pack's dunning law has no flat rate. `DocumentBuilder::flatRate()` adds the flat rate of the EU late payment directive (40.00 by default); it does not belong on a Swiss reminder. - Quittio does not check whether and since when the debtor is in default; you pass the first day with interest. ## Meta flags and settings The pack reads one meta flag and one setting. Meta flags are set on the builder with `->flag()` ([Presentation and metadata](building-invoices.md#presentation-and-metadata)). | Flag | Value | Effect | |---|---|---| | `CountryCH::FLAG_CASH_ROUNDING` | `ch.cash_rounding` | [rounding to 5 Rappen](#rounding-to-5-rappen) of this invoice | | `Meta::FLAG_SMALL_BUSINESS` | `small_business` | lines without `vat()` get `VatPreset::NotRegistered` ([Sellers not registered for VAT](#sellers-not-registered-for-vat)) | Settings of the pack live under `quittio.countries.ch` ([Settings of a pack](configuration.md#settings-of-a-pack-quittiocountriescode)): | Key | Type | Default | Effect | |---|---|---|---| | `cash_rounding` | bool | `false` | `true` rounds every invoice in CHF to 5 Rappen, as the flag does for one invoice | The pack has no configuration file to publish. In Laravel, add the section to `config/quittio.php`; without Laravel, pass it to `Quittio::create()`: ```php laravel 'countries' => [ 'ch' => ['cash_rounding' => true], ], ``` ```php plain use Quittio\Core\Quittio; use Quittio\Country\CH\CountryCH; $quittio = Quittio::create(['countries' => ['ch' => ['cash_rounding' => true]]], [new CountryCH]); ``` The value must be the boolean `true`; a string such as `'1'` does not switch the rounding on. ## Defaults How `CountryCH` fills the [`CountryPack` contract](country-packs.md#the-countrypack-contract): | Hook | Switzerland | |---|---| | `defaults()` | currency `CHF`, time zone `Europe/Zurich`, locale `de_CH` (Swiss formats such as 1'590.00, German texts), paper `A4`, letter layout `free`, profile `en16931`, payment QR `swiss-qr-bill`, default VAT presets `ch.standard` and `ch.not_registered` ([CountryDefaults](country-packs.md#countrydefaults)) | | `taxPresets()` | every case of [`VatPreset`](#tax-presets) | | `rules()` | the [MWSTG rules](#rules) `CH-MWSTG-01` to `CH-MWSTG-05` | | `buyerCountryRules()`, `formatRules()`, `profiles()`, `legalTexts()` | none | | `mandatoryOutput()` | [UID number and date of the supply](#mandatory-pdf-output) | | `paymentQr()` | [`SwissQrBillGenerator`](#qr-bill) | | `complete()` | [rounding to 5 Rappen](#rounding-to-5-rappen) (capability `CompletesInvoices`) | | `numberingRules()` | pattern `RE-{Y}-{seq:4}`, reset `yearly`, resets `never`, `yearly`, `monthly`, not gapless | | `retention()` | 10 years from the end of the calendar year | | `dunningLaw()` | [5 % fixed, no flat rate](#late-payment) | | `correctionPolicy()` | credit note, cancel and reissue, Swiss titles | | `letterLayouts()`, `addressFormatter()` | defaults: the layout `free`, international address format | | `translationPath()` | `resources/lang` of the package | - **Locale.** `de_CH` is the last fallback of the render locale: the locale of the call, of the invoice and of the configuration come first ([Translations and locales](templates.md#translations-and-locales)). Amounts and dates follow the regional locale with `ext-intl`, e.g. 1'960.95 CHF and 05.10.2026. - **Currency, time zone, profile.** They are informational and not applied to invoices ([CountryDefaults](country-packs.md#countrydefaults)). The builder starts with EUR, also in Laravel, so set `->currency('CHF')` on every invoice in Swiss francs. - **Paper and layout.** A4 and the layout `free` (address field 45 mm from the top, no fold marks). Swiss letter layouts are not included ([Known limitations](#known-limitations)). - **Numbering.** Swiss law prescribes no numbering; unique numbers are good practice. The pattern is the default of [Managed numbering](managed.md#numbering). The pack declares numbers as not gapless. - **Retention.** Ten years from the end of the calendar year (Art. 70 (2) MWSTG, Art. 958f OR): an invoice issued on 5 October 2026 is kept until 31 December 2036. 20 years for immovable property (Art. 70 (3) MWSTG) are not modelled. ### Cancellations and corrections An invoice is cancelled by a credit note (type code 381 with positive amounts) and corrected by cancelling it and issuing a new one ([CorrectionPolicy](country-packs.md#correctionpolicy), [Cancellations and corrections](building-invoices.md#cancellations-and-corrections)). The titles: | Kind | German | French | Italian | English | |---|---|---|---|---| | `cancellation` | Gutschrift | Note de crédit | Nota di credito | Credit note | | `correction` | Korrigierte Rechnung | Facture corrigée | Fattura corretta | Corrected invoice | | `self_billed` | Gutschrift (Selbstfakturierung) | Autofacturation | Autofatturazione | Self-billed invoice | A regional locale takes the title of its language (`de_CH` → "Gutschrift", `fr_CH` → "Note de crédit"); other languages get the English title. A cancellation takes the locale of the original, then the configured locale, then the pack default `de_CH`. Pass `title:` to `cancellation()` for another title. The titles are defined in PHP and cannot be changed through translation files. ## Languages The pack ships texts in German, French, Italian and English (`resources/lang/{de,fr,it,en}/`): | File | Content | Languages | |---|---|---| | `rules.php` | messages and hints of the [rules](#rules) | de, fr, it, en | | `tax.php` | [exemption texts](#exemption-texts) of the presets | de, fr, it, en | | `qrbill.php` | headings of payment part and receipt | de, fr, it, en | | `labels.php` | Swiss words for labels of the core | de, fr | The German labels replace the core's VAT words with the Swiss ones: "MWST" instead of "USt." (e.g. "MWST 8.1 %", "8.1 % MWST auf 1'740.00 CHF") and "MWST-Nr." for the VAT identifier. The French labels name the VAT identifier "N° TVA (IDE)". All other labels come from the core. - **Italian.** The core has labels and code names in German, English, French and Dutch, not in Italian. An invoice with an Italian locale (`it` or `it_CH`) therefore has English labels ("Invoice", "VAT"), while the exemption texts, rule messages and QR bill headings are Italian. - **Romansh.** Headings in Romansh, which version 2.4 of the guidelines adds (valid from 14 November 2026), are not included. A Romansh locale gets German headings on the QR bill and English texts otherwise. - **QR bill headings.** The guidelines prescribe them; do not change them. The texts are registered as the namespace `quittio-ch` (e.g. `quittio-ch::labels.vat_id`, `quittio-ch::tax.ch.export`). In Laravel, override them in `lang/vendor/quittio-ch/{locale}/labels.php`, `rules.php` or `tax.php`. A file needs only the keys you change: ```php // lang/vendor/quittio-ch/de/labels.php: "UID" instead of "MWST-Nr." return ['vat_id' => 'UID']; ``` Without Laravel, add a directory with the same structure after `Quittio::create()`; later paths win over earlier ones: ```php use Quittio\Core\I18n\Translations; Translations::translator()->addPath(__DIR__.'/lang', 'quittio-ch'); // lang/de/labels.php ``` `CountryCH::locales()` lists the languages the pack ships, `CountryCH::registerTranslations()` registers the texts lazily, so the presets work without a `Quittio` instance. Labels of a single invoice can also be changed with `Presentation::$labels` ([Translations and locales](templates.md#translations-and-locales)). ## Known limitations - The legal wording, rules and defaults have not been reviewed by a Swiss tax adviser (see the note at the top). - The VAT rates of the vote of 29 November 2026 and a change of the accommodation rate after 2027 are not included ([Rates by supply date](#rates-by-supply-date)). - QR bill: billing information (syntax S1 of Swico, maintained by SIX since version 2.4 of the guidelines), alternative procedures and the "do not use for payment" bill are not supported yet. Headings in Romansh are missing. - eBill (through a network partner of SIX) is not supported. - Swiss letter layouts with the window left or right (SN 10130:2026 "Geschäftsbrief", which replaced SN 010130; Swiss Post specifications for the address window) are not included; the pack uses the layout `free`. - Labels and code names in Italian are missing in the core; Italian invoices show English labels. - There is no Laravel service provider with a configuration file of the pack; the setting `cash_rounding` goes into `config/quittio.php`. - 20 years of retention for immovable property are not modelled. ## Complete example A Swiss software company invoices a business in Bern: development work at the standard rate and two books at the reduced rate, paid to a QR-IBAN, rounded to 5 Rappen. The script checks the invoice, renders it and saves the PDF with the QR bill on its second page. It runs without Laravel; in Laravel, start with `Quittio::invoice()` instead of `InvoiceBuilder::make()` and leave out `Quittio::create()` and `useDefaultVat()`. ```php <?php require __DIR__.'/vendor/autoload.php'; use Quittio\Core\Builder\InvoiceBuilder; use Quittio\Core\Builder\Party; use Quittio\Core\Enums\PaymentMeansCode; use Quittio\Core\Enums\UnitCode; use Quittio\Core\Quittio; use Quittio\Core\Tax\CountryDefaultVat; use Quittio\Country\CH\CountryCH; use Quittio\Country\CH\Tax\VatPreset; $quittio = Quittio::create([], [new CountryCH]); InvoiceBuilder::useDefaultVat(new CountryDefaultVat($quittio->countries())); // lines without vat(): VatPreset::Standard $invoice = InvoiceBuilder::make() ->number('RE-2026-0042') ->issueDate('2026-10-05') ->deliveryDate('2026-09-30') ->currency('CHF') ->seller(Party::make('Bergsoft AG') ->vatId('CHE-123.456.788 MWST') ->address('Bahnhofstrasse 12', '8001', 'Zürich', 'CH') ->contact('Lea Meier', '+41 44 123 45 67', 'rechnung@bergsoft.example')) ->buyer(Party::make('Muster GmbH')->address('Marktgasse 28', '3011', 'Bern', 'CH')) ->line('Softwareentwicklung', netPrice: '145.00', quantity: 12, unit: UnitCode::Hour) // 8.1 % ->line('Fachbuch', netPrice: '39.00', quantity: 2, unit: UnitCode::Piece, vat: VatPreset::Reduced) // 2.6 % ->payment(PaymentMeansCode::SepaCreditTransfer, iban: 'CH44 3199 9123 0008 8901 2') // QR-IBAN ->dueInDays(30) ->flag(CountryCH::FLAG_CASH_ROUNDING) ->build(); // Validate without rendering: EN 16931 and the MWSTG rules $check = $quittio->make($invoice)->check(); foreach ($check->messages as $message) { echo "[{$message->code}] {$message->message}\n"; } if ($check->isValid()) { $result = $quittio->make($invoice)->render(); // format zugferd: PDF with EN 16931 XML $path = $result->save(__DIR__.'/invoices/'); // invoices/Rechnung_RE-2026-0042.pdf echo $result->data()->totals->roundingAmount, "\n"; // CHF -0.02 echo $result->data()->totals->amountDue, "\n"; // CHF 1960.95 } ``` What the invoice contains: - Net amount 1'818.00 CHF, 8.1 % MWST on 1'740.00 CHF (140.94 CHF) and 2.6 % MWST on 78.00 CHF (2.03 CHF), total 1'960.97 CHF, rounding −0.02 CHF, amount due 1'960.95 CHF. - The date of the supply ("Leistungsdatum 30.09.2026") in the header and the UID number ("MWST-Nr. CHE-123.456.788 MWST") in the footer, as the [mandatory output](#mandatory-pdf-output) requires. - On the second page the payment part and the receipt: account CH44 3199 9123 0008 8901 2 with Bergsoft AG, the QR reference `00 00000 00000 00000 02026 00427` made from the invoice number, "RE-2026-0042" as additional information, the buyer under "Zahlbar durch" and the amount 1 960.95 CHF. With an ordinary IBAN instead of the QR-IBAN, the code has no reference (`NON`) unless the remittance information is a Creditor Reference ([References](#references)). With the locale `fr_CH` (`->locale('fr_CH')` before `build()`), labels, exemption texts and the QR bill headings are French ("Section paiement", "Récépissé"). <!-- Source: https://quittio.dev/docs/country-fr --> # France (`quittio/country-fr`) > **Not reviewed by a tax adviser yet.** The legal wording, rules and defaults of this pack follow the law and the official sources as of October 2026, but have not been reviewed by a French tax adviser. Check the mentions and rates of your invoices before you rely on them. Quittio is no tax or legal advice; the business that issues an invoice remains responsible for it. Until the review the pack is not covered by the [compatibility promise](compatibility.md#country-packs-without-tax-review): a minor release may change it. The French pack implements the mentions obligatoires of French invoices, i.e. the details an invoice must state. They come from the French Tax Code (Code général des impôts, CGI: art. 242 nonies A of annex II), with the new mentions of the e-invoicing reform from 1 September 2026, and from the Commercial Code (Code de commerce) for invoices between businesses. The pack also covers the late payment penalties. Its class is `Quittio\Country\FR\CountryFR` (code `FR`, translation namespace `quittio-fr`). It covers metropolitan France and Monaco. The overseas departments have VAT rates of their own, which are not modelled. The pack provides: - [tax presets](#tax-presets) for the French rates, the franchise en base, autoliquidation (reverse charge), intra-community supplies, exports and the margin schemes; - the [rules](#rules) `FR-CGI-01` to `FR-CGI-09`, `FR-COM-01` and `FR-COM-02`; - the texts that cite the Code des impositions sur les biens et services (CIBS) instead of the CGI on invoices issued from 1 January 2027 ([From the CGI to the CIBS](#from-the-cgi-to-the-cibs)); - Factur-X for domestic invoices between businesses ([Format choice](#format-choice)); - the late payment mention and the mention of VAT on debits, added while rendering ([Mentions added by the pack](#mentions-added-by-the-pack)); - the ECB rate table and the values for late payment penalties ([Late payment](#late-payment)); - a SIREN and SIRET check ([SIREN and SIRET](#siren-and-siret)), defaults, correction titles ("Avoir") and French and English texts. This page writes French legal references in their French form ("art. 242 nonies A of annex II to the CGI", "art. L441-10 Code de commerce"). French terms such as avoir or autoliquidation are explained on first use. ## Installation ```bash composer require quittio/country-fr ``` The pack is not part of `quittio/quittio`. Install it next to `quittio/quittio` or next to `quittio/core`. It is developed in the monorepo [Quittio/quittio](https://github.com/Quittio/quittio/tree/master/packages/country-fr) and published as the read-only repository [Quittio/country-fr](https://github.com/Quittio/country-fr). Please open issues and pull requests in the monorepo. - **Laravel.** The pack declares itself in its `composer.json` (`extra.quittio.country-packs`), so Laravel finds it after the installation. There is nothing to register. The pack has no service provider and no configuration file of its own; its one setting goes into `config/quittio.php` ([Meta flags and settings](#meta-flags-and-settings)). - **Without Laravel.** Pass `new CountryFR` to `Quittio::create()`, or register it later with `registerCountry()` ([Registering packs](country-packs.md#registering-packs)): ```php use Quittio\Core\Quittio; use Quittio\Country\FR\CountryFR; $quittio = Quittio::create(['country' => 'FR'], [new CountryFR]); ``` The presets, `Siren` and `LegalTexts` work without a `Quittio` instance: `CountryFR::registerTranslations()` registers the texts when they are first needed. ## When it applies The pack leads every invoice whose seller is in France (seller country code `FR`, BT-40). It then checks the French rules, chooses the format, completes the invoice and provides the defaults: the French locale (unless the invoice or the configuration sets one), A4 paper and the EPC GiroCode. For an invoice from another country to a buyer in France, only the format rules of the pack apply, and the French format rule has no opinion on cross-border invoices. Details are in [How a pack is selected](country-packs.md#how-a-pack-is-selected). - **Monaco.** Monaco belongs to the French VAT territory ([`VatTerritory`](country-packs.md#vatterritory)). A buyer in Monaco counts as a buyer in France for the rules and the format choice. The pack also leads the invoices of sellers with the country code `MC` ([How a pack is selected](country-packs.md#how-a-pack-is-selected)). A business in Monaco has no SIREN: `FR-CGI-01` does not ask a seller in Monaco for one, and `FR-CGI-08` does not ask a buyer in Monaco for one. - **Overseas departments.** Addresses in `FR` with a post code starting with `97` or `98` lie outside the French VAT territory in Quittio. A buyer there is no buyer "in France" for `FR-CGI-08` and the format rule, and the resolver treats the invoice as cross-border. ## Common tasks | You want to | Read | |---|---| | Add the new mentions of the e-invoicing reform | [The four new mentions](#the-four-new-mentions) | | Know which texts cite the CIBS from 2027 | [From the CGI to the CIBS](#from-the-cgi-to-the-cibs) | | Set the VAT rate or an exemption on a line | [Tax presets](#tax-presets) | | Invoice as a small business without VAT (franchise en base) | [Small businesses](#small-businesses-franchise-en-base) | | Invoice with reverse charge, an intra-community supply or an export | [Reverse charge, intra-community supplies and exports](#reverse-charge-intra-community-supplies-and-exports) | | Look up a validation code such as `FR-CGI-08` or `FR-COM-02` | [Rules](#rules) | | Check or extract a SIREN | [SIREN and SIRET](#siren-and-siret) | | Know which format Quittio picks | [Format choice](#format-choice) | | Change or switch off the late payment mention | [Mentions added by the pack](#mentions-added-by-the-pack), [Meta flags and settings](#meta-flags-and-settings) | | Calculate late payment penalties for a reminder | [Late payment](#late-payment) | | Cancel or correct an invoice (avoir) | [Credit notes, corrections and self-billing](#credit-notes-corrections-and-self-billing) | | Change a text or add a language | [Translations](#translations) | | See a complete invoice | [Complete example](#complete-example) | ## E-invoicing reform All businesses receive e-invoices from 1 September 2026; large and mid-sized businesses issue them from that date, all others from 1 September 2027. They are exchanged through an approved platform (plateforme agréée) in Factur-X, UBL or CII. The pack chooses Factur-X for domestic invoices to businesses ([Format choice](#format-choice)). The connection to the platforms and e-reporting are not part of this pack, nor are the business rules of the French specifications (BR-FR-…); see [Known limitations](#known-limitations). ### The four new mentions From 1 September 2026 an invoice states four new mentions. The pack checks two of them, adds one and leaves one to you: | Mention | How to set it | Checked by | |---|---|---| | The buyer's SIREN, for a business established in France | `->legalRegistration('901234567', '0002')` on the buyer (BT-47, scheme `0002` = SIREN) | `FR-CGI-08` (warning) | | The category of the operation: supply of goods, services or both | `->businessProcess('B1')` for goods, `'S1'` for services, `'M1'` for both (operation category, BT-23) | `FR-CGI-09` (warning) | | The delivery address, if it differs from the buyer's address | `->deliverTo($name, $address)` (deliver-to address, BG-15) | not checked | | The option to pay VAT on debits (option pour le paiement de la taxe d'après les débits) | `->flag(CountryFR::FLAG_VAT_ON_DEBITS)`: the pack adds "Option pour le paiement de la taxe d'après les débits" | added by `complete()` | ```php use Quittio\Core\Builder\InvoiceBuilder; use Quittio\Core\Data\Party\Address; use Quittio\Country\FR\CountryFR; $builder = InvoiceBuilder::make() // number, dates, seller, lines … ->businessProcess('M1') // goods and services (BT-23) ->buyer(fn ($b) => $b ->name('Boutique Exemple SARL') ->vatId('FR15901234567') ->legalRegistration('901234567', '0002') // SIREN of the buyer (BT-47) ->address('5 avenue de l\'Opéra', '75001', 'Paris', 'FR')) ->deliverTo('Boutique Exemple SARL, entrepôt', new Address('FR', '8 rue des Entrepôts', city: 'Saint-Denis', postcode: '93200')) ->flag(CountryFR::FLAG_VAT_ON_DEBITS); // the seller opted to pay VAT on debits ``` - The rules `FR-CGI-08` and `FR-CGI-09` apply to invoices with an issue date (BT-2) from 1 September 2026 (`FrenchRules::REFORM_DATE`) and not to consumers. They are warnings, so an invoice without these mentions still renders. - The operation category is written to the XML as business process (BT-23), e.g. `<ram:ID>S1</ram:ID>` in Factur-X. ## From the CGI to the CIBS On 1 January 2027 the VAT rules of the CGI move into the Code des impositions sur les biens et services (CIBS); ordonnance n° 2026-671 of 27 July 2026 postponed the date from 1 September 2026. References to the CGI, also in the mentions of an invoice, remain accepted until 30 June 2028 (art. 46 II ordonnance n° 2025-1247, BOI-RES-TVA-000253). Art. 242 nonies A of annex II stays in the CGI; its 12° accepts the reference to the CGI, to the VAT Directive or any other mention of the exemption. On invoices issued from 1 January 2027 (`VatPreset::CIBS_FROM`), the pack replaces the texts of three presets by texts that cite the CIBS: | Case | Issued until 31 December 2026 | Issued from 1 January 2027 | |---|---|---| | `SmallBusiness` | TVA non applicable, art. 293 B du CGI | TVA non applicable, art. L. 233-3 du CIBS | | `IntraCommunitySupply` | Exonération de TVA, article 262 ter I du CGI | Exonération de TVA, article L. 213-12, 1° du CIBS | | `Export` | Exonération de TVA, article 262 I du CGI | Exonération de TVA, article L. 213-12, 2° du CIBS | In English the texts read "VAT not applicable, art. 293 B of the French Tax Code (CGI)", "VAT exempt, article 262 ter I CGI" and "VAT exempt, article 262 I CGI", and from 2027 "VAT not applicable, art. L. 233-3 of the French Code on Taxes on Goods and Services (CIBS)", "VAT exempt, article L. 213-12, 1° CIBS" and "VAT exempt, article L. 213-12, 2° CIBS". Art. L. 213-12 CIBS states the exemptions of intra-European supplies (1°) and exports (2°); art. L. 213-13 and L. 213-14 set their conditions. Art. L. 233-3 defines the small business under the franchise. A decree or the BOFiP may still prescribe other wording. How the replacement works: - **Where.** `CountryFR::complete()` replaces the texts. The render pipeline calls it for the leading pack in `render()`, `check()` and `prepare()`, before calculation and validation ([`CompletesInvoices`](country-packs.md#the-countrypack-contract)). The data of the builder (`$builder->build()`) therefore still has the CGI texts. The rendered data (`$result->data()`, `$prepared->data`), the XML and the PDF have the CIBS texts. - **What.** The exemption reason of every line (sub lines included), of document level allowances and charges and of the VAT breakdown (BT-120). - **When.** The issue date (BT-2) decides, not the date of the supply. An invoice of 4 January 2027 for a delivery in December 2026 cites the CIBS. - **Which texts.** Only texts that equal a CGI text of the three presets word for word, in one of the locales the pack ships (`fr`, `en`), with the translations in use. Texts of your own stay as they are, e.g. `VatPreset::exempt('article 261-4-1° du CGI')` or a changed wording. The comparison is by text, not by preset: a text of your own that equals one of the three texts exactly is replaced as well (`VatPreset::exempt('article 262 I du CGI')` gives the same text as `Export`). The texts of the other presets (Autoliquidation, the margin schemes, not taxable in France) do not change. `VatPreset::exemptionReasonOn()` returns the text for an issue date, e.g. to store or show it yourself: ```php use Quittio\Core\Support\Date; use Quittio\Country\FR\Tax\VatPreset; VatPreset::Export->exemptionReason(); // "Exonération de TVA, article 262 I du CGI" VatPreset::Export->exemptionReasonOn(Date::of(2026, 12, 31)); // "Exonération de TVA, article 262 I du CGI" VatPreset::Export->exemptionReasonOn(Date::of(2027, 1, 4)); // "Exonération de TVA, article L. 213-12, 2° du CIBS" VatPreset::Export->exemptionReasonOn(Date::of(2027, 1, 4), 'en'); // "VAT exempt, article L. 213-12, 2° CIBS" ``` For the other presets `exemptionReasonOn()` returns the same text as `exemptionReason()`. ## Tax presets A tax preset is a ready-made VAT treatment for an invoice line. It sets the VAT category (BT-151) and the rate, and for the other categories also the exemption reason code (BT-121) and text (BT-120). Use a preset instead of a bare category and rate: the line then carries the wording the pack expects, and the rules recognise the case. The categories are the codes of EN 16931 ([Categories](building-invoices.md#categories)). `Quittio\Country\FR\Tax\VatPreset` is a string-backed enum that implements `TaxPreset`. Apply it per line: ```php use Quittio\Core\Builder\InvoiceBuilder; use Quittio\Core\Enums\UnitCode; use Quittio\Country\FR\Tax\VatPreset; $builder = InvoiceBuilder::make() ->locale('fr') ->line('Développement web', netPrice: '90.00', quantity: 10, unit: UnitCode::Hour, vat: VatPreset::Standard) ->line(fn ($l) => $l->name('Maintenance')->netPrice('120.00')->vat(VatPreset::Intermediate)) // an exemption without a case of its own: the legal reference as text ->line('Soins', netPrice: '60.00', unit: UnitCode::Piece, vat: VatPreset::exempt('article 261-4-1° du CGI')); ``` | Case | Key | Category | Rate | Code (BT-121) | Text (BT-120), French | |---|---|---|---|---|---| | `Standard` | `fr.standard` | `S` | 20 | – | – | | `Intermediate` | `fr.intermediate` | `S` | 10 | – | – | | `Reduced` | `fr.reduced` | `S` | 5.5 | – | – | | `Particular` | `fr.particular` | `S` | 2.1 | – | – | | `SmallBusiness` | `fr.small_business` | `E` | 0 | – | TVA non applicable, art. 293 B du CGI (CIBS from 2027) | | `ReverseChargeDomestic` | `fr.reverse_charge_domestic` | `AE` | 0 | `VATEX-EU-AE` | Autoliquidation | | `ReverseChargeEu` | `fr.reverse_charge_eu` | `AE` | 0 | `VATEX-EU-AE` | Autoliquidation | | `IntraCommunitySupply` | `fr.intra_community_supply` | `K` | 0 | `VATEX-EU-IC` | Exonération de TVA, article 262 ter I du CGI (CIBS from 2027) | | `Export` | `fr.export` | `G` | 0 | `VATEX-EU-G` | Exonération de TVA, article 262 I du CGI (CIBS from 2027) | | `NotTaxableInFrance` | `fr.not_taxable` | `O` | none | `VATEX-EU-O` | TVA non applicable en France (lieu de la prestation hors de France) | | `MarginSecondHand` | `fr.margin_second_hand` | `E` | 0 | `VATEX-EU-F` | Régime particulier – Biens d'occasion | | `MarginArt` | `fr.margin_art` | `E` | 0 | `VATEX-EU-I` | Régime particulier – Objets d'art | | `MarginAntiques` | `fr.margin_antiques` | `E` | 0 | `VATEX-EU-J` | Régime particulier – Objets de collection et d'antiquité | | `TravelAgency` | `fr.travel_agency` | `E` | 0 | `VATEX-EU-D` | Régime particulier – Agences de voyages | | `VatPreset::exempt(string $paragraph, $code = null)` | `fr.exempt` | `E` | 0 | `$code` (enum, raw code or string) | Exonération de TVA, `$paragraph` | The English texts are in `resources/lang/en/tax.php`, e.g. "Reverse charge (autoliquidation)", "Not subject to French VAT (place of supply outside France)", "Margin scheme – Second-hand goods" and "VAT exempt, :paragraph". The docblocks of the cases name the provisions behind them: art. 283-2 nonies CGI (domestic reverse charge, e.g. subcontracting in construction), art. 283-2 CGI and art. 196 VAT Directive (services to a business in another member state), art. 297 A CGI (margin schemes) and art. 266-1 e CGI (travel agencies). How presets behave: - **Language.** The text is taken in the invoice locale (`->locale()` on the builder) when the line is built. The enum presets and `VatPreset::exempt()` (a `Quittio\Country\FR\Tax\CustomVatPreset`) use French when the invoice has no locale. Other locales without a text of their own fall back to English. - **Rates.** The rates are fixed values; the pack keeps no table of earlier rates. `Standard`, `Intermediate`, `Reduced` and `Particular` carry no text, because EN 16931 forbids an exemption reason for category `S`. - **Preset key.** The key stays on the line (`$line->vat->presetKey`). The small business detection of `FR-CGI-02` and `FR-CGI-06` relies on it. - **VAT breakdown and PDF.** Category, rate, code and text flow into the VAT breakdown (BG-23), as described in [Building invoices: tax presets](building-invoices.md#tax-presets). The PDF lists the texts in its legal notes. - **Default VAT.** Lines without `vat:` take the [default VAT](building-invoices.md#default-vat). In Laravel that is `VatPreset::Standard` for a French seller (`CountryDefaults::$vatPreset`) unless `quittio.defaults.vat` names another preset, and `VatPreset::SmallBusiness` for a small business. Without Laravel, install `CountryDefaultVat` yourself. - **Lookup by key**, e.g. from a database column: `VatPreset::from('fr.standard')`, `VatPreset::fromKey($key)` (null for keys of other packs), `(new CountryFR)->taxPresets()->get('fr.standard')` or, across all installed packs, `$quittio->countries()->taxPreset('fr.standard')`. `fr.exempt` is not part of the collection. ### Small businesses (franchise en base) A small business under the franchise en base (art. 293 B CGI) charges no VAT. Mark the invoice as a small business invoice and use `VatPreset::SmallBusiness` on every line: - **Flag.** `quittio.seller.small_business = true` in Laravel ([Configuration: small businesses](configuration.md#small-businesses)), `'small_business' => true` in `Quittio::create()` without Laravel (applied by `Quittio::invoice()` and `$quittio->invoice()`), or `->flag(Meta::FLAG_SMALL_BUSINESS)` on the builder. With the flag, lines without `vat:` get `VatPreset::SmallBusiness` from the default VAT. - **Rules.** A small business invoice is one with the flag or with a line that uses `VatPreset::SmallBusiness` (`FrenchRules::isSmallBusinessInvoice()`). It needs no VAT number of the seller (`FR-CGI-02`), and any VAT amount in its breakdown is an error (`FR-CGI-06`). - **EN 16931.** The rule BR-E-02 of EN 16931 requires the seller's VAT identifier (BT-31), tax registration identifier (BT-32, `->taxNumber()`) or the VAT identifier of a tax representative (BT-63) on every invoice with category `E`. The pack fills in none of them, so a small business invoice without any of them fails with `BR-E-02`, also as plain PDF. - **From 2027** the text cites art. L. 233-3 CIBS ([From the CGI to the CIBS](#from-the-cgi-to-the-cibs)). ### Reverse charge, intra-community supplies and exports - **Autoliquidation** (reverse charge, category `AE`): the buyer owes the VAT. Use `ReverseChargeDomestic` or `ReverseChargeEu`. Their texts contain "Autoliquidation" in both languages, which `FR-CGI-04` requires in the VAT breakdown. A category `AE` with a text of your own fails unless the text contains the word. - **Intra-community supplies** (`IntraCommunitySupply`, category `K`) and **exports** (`Export`, category `G`): `FR-CGI-05` requires the reference to the provision as text; a code alone is not enough. The presets provide it. - **Other exemptions**: `VatPreset::exempt('article …')` with the reference to the provision, and optionally a VATEX code as second argument. - **VAT identifiers.** The pack has no rule of its own for the buyer's VAT number. The EN 16931 rules of the categories apply (e.g. BR-AE-02, BR-IC-02). ## Rules `Quittio\Country\FR\Rules\FrenchRules::all()` (level L3) checks the mentions of a French invoice under art. 242 nonies A of annex II to the CGI and art. L441-9 Code de commerce. The rules apply to every invoice of a French seller, in every format including a plain PDF. Messages and hints are in French and English. Switch a rule off or change its severity with `validation.rules` ([Switching rules off](validation.md#switching-rules-off-and-changing-their-severity)). | Rule | Severity (BT, path) | Reported when | Legal basis named | Fix | |---|---|---|---|---| | `FR-CGI-01` | error (BT-30 `seller.legalRegistration`) | The seller (not in Monaco) has no legal registration identifier, or its value is neither a SIREN nor a SIRET with valid check digits (`Siren::isSiren()`, `Siren::isSiret()`). Spaces are ignored; the scheme is not checked. | art. 242 nonies A annex II CGI, art. R123-237 Code de commerce | `->legalRegistration('812345676', '0002')` on the seller, or a SIRET with scheme `0009`. | | `FR-CGI-02` | error (BT-31 `seller.vatId`) | Neither the seller nor its tax representative has a VAT number, and the invoice is no [small business invoice](#small-businesses-franchise-en-base). | art. 242 nonies A annex II CGI | `->vatId()` on the seller. | | `FR-CGI-03` | error per missing field (BT-35, BT-38, BT-37 of the seller; BT-50, BT-53, BT-52 of the buyer) | Street (address line 1), post code or city of the seller or the buyer is empty, also for consumers. | art. 242 nonies A annex II CGI | Complete both addresses. | | `FR-CGI-04` | error per VAT row (BT-120 `vatBreakdown[i].exemptionReason`) | A VAT row of category `AE` whose exemption reason does not contain "autoliquidation" (case-insensitive). | art. 242 nonies A annex II CGI | `VatPreset::ReverseChargeDomestic` or `ReverseChargeEu`. | | `FR-CGI-05` | error per VAT row (BT-120 `vatBreakdown[i].exemptionReason`) | A VAT row of category `E`, `K` or `G` without exemption reason text, e.g. with a VATEX code only. | art. 242 nonies A annex II CGI | A preset, or `VatPreset::exempt()` with the reference. | | `FR-CGI-06` | error per VAT row (BT-117 `vatBreakdown[i].taxAmount`) | A small business invoice has a VAT row whose VAT amount is not zero. | art. 293 B CGI; VAT shown is owed by reason of the invoice (art. 283-3 CGI) | `VatPreset::SmallBusiness` on every line. | | `FR-CGI-07` | error (BT-22 `notes`); warning when the XML is written (option `syntax`) | A self-billed type code (389, 261, 527), and no note contains "autofacturation" or "self-billing" (case-insensitive). | art. 242 nonies A annex II CGI | Add the note, see [Self-billing](#credit-notes-corrections-and-self-billing). | | `FR-CGI-08` | warning (BT-47 `buyer.legalRegistration`) | Issue date from 1 September 2026, the buyer is no consumer, its address lies in France (not in Monaco, post codes `97…` and `98…` excluded), and its legal registration identifier yields no SIREN (`Siren::of()`: a SIREN, a SIRET or a French VAT number). The scheme is not checked. | art. 242 nonies A annex II CGI | `->legalRegistration('901234567', '0002')` on the buyer. | | `FR-CGI-09` | warning (BT-23 `businessProcess`) | Issue date from 1 September 2026, the buyer is no consumer (in France or abroad), and the business process (BT-23) is not one of `FrenchRules::OPERATION_CATEGORIES`. | art. 242 nonies A annex II CGI | `->businessProcess('S1')` for services, `'B1'` for goods, `'M1'` for both. | | `FR-COM-01` | error (BT-9 `dueDate`) | The buyer is no consumer, the invoice is no credit note, and it has neither a due date (BT-9) nor a payment terms text (BT-20). | art. L441-9 Code de commerce | `->dueDate()` or `->paymentTerms()`. | | `FR-COM-02` | warning (BT-22 `notes`) | The buyer is no consumer, the invoice is no credit note, and neither a note nor the payment terms text contains "pénalit" or "penalt" (case-insensitive). The rule looks for this word only; it does not check the indemnity of 40 EUR or the discount. | art. L441-9 Code de commerce | Keep the [late payment mention](#mentions-added-by-the-pack) on, or write a note of your own. | - **Operation categories.** `FrenchRules::OPERATION_CATEGORIES` holds the codes `B1`, `S1`, `M1`, `B2`, `S2`, `M2`, `S3`, `B4`, `S4`, `M4`, `S5`, `S6`, `B7` and `S7` of the French specifications (cadre de facturation). The messages and hints name `B1`, `S1` and `M1`; the pack does not explain the other codes. - **Self-billing in XML.** `FR-CGI-07` is a warning when the run writes XML (Factur-X, CII, UBL), where the type code marks the invoice as self-billed, and an error for a plain PDF. - **Credit notes.** `FR-COM-01` and `FR-COM-02` skip credit notes (avoirs). Helpers used by the rules and available to you: - `FrenchRules::isSmallBusinessInvoice($invoice)`: the flag `small_business` is set, or a line uses `VatPreset::SmallBusiness`; - `FrenchRules::inFrance($address)`: the address lies in the French VAT territory (with Monaco, without the overseas departments); - `FrenchRules::REFORM_DATE` (`2026-09-01`) and `FrenchRules::OPERATION_CATEGORIES`. ## SIREN and SIRET SIREN (nine digits) and SIRET (fourteen digits, starting with the SIREN) are the numbers of the French business register. Both end with a Luhn check digit. SIRET numbers of La Poste (SIREN 356000000) use a sum of digits instead, which `Siren` knows. Set the seller's number as legal registration identifier (BT-30) with scheme `0002` (SIREN) or `0009` (SIRET), and the buyer's SIREN as BT-47. `Quittio\Country\FR\Support\Siren`: | Method | Returns | |---|---| | `Siren::isSiren(string $value): bool` | nine digits with a valid check digit; other characters such as spaces are ignored | | `Siren::isSiret(string $value): bool` | fourteen digits with valid check digits of the SIRET and of its SIREN (La Poste: sum of digits) | | `Siren::of(?string $value): ?string` | the SIREN of a SIREN, a SIRET or a French VAT number (`FR` + two check digits + SIREN), or null when none with a valid check digit can be read | ```php use Quittio\Country\FR\Support\Siren; Siren::isSiren('812 345 676'); // true Siren::isSiret('81234567600017'); // true Siren::of('FR19812345676'); // "812345676", from a VAT number Siren::of('81234567600017'); // "812345676", from a SIRET Siren::of('812345677'); // null: wrong check digit ``` In a VAT number, `Siren::of()` checks the SIREN only, not the two check digits in front of it. For the VAT number checks of the core see [VAT identifiers and VIES](validation.md#vat-identifiers-and-vies). ## Format choice Without `->format()`, Quittio chooses the format for each invoice ([Automatic choice](formats.md#automatic-choice)). `Quittio\Country\FR\Formats\FrenchFormatRule` returns a choice for domestic invoices between businesses and null (no opinion) otherwise: | Condition | Format | Profile | |---|---|---| | The buyer is no consumer, and the addresses of seller and buyer lie in France (`FrenchRules::inFrance()`: Monaco included, post codes `97…` and `98…` excluded) | `zugferd` (Factur-X) | `en16931` | | otherwise | – (null) | – | Factur-X and ZUGFeRD are the same standard: a PDF/A-3 with the CII XML embedded ([ZUGFeRD and Factur-X](formats.md#zugferd-and-factur-x)). - **Peppol.** The rule decides before the Peppol lookup of the resolver, so a domestic business invoice is Factur-X even when the buyer is reachable via Peppol. - **Profile.** The rule asks for EN 16931 whatever profile is configured. When the invoice uses features of EXTENDED (e.g. sub lines), the resolver still upgrades it ([Upgrade to profile EXTENDED](formats.md#upgrade-to-profile-extended)). - **Everything else** follows the general order of the resolver: consumers get `pdf`; a cross-border invoice within the EU VAT territory gets `zugferd` with the configured profile; an invoice to a buyer outside it (also in the overseas departments) gets `pdf`. - **Explicit formats.** An explicit `->format()` or a configured `quittio.defaults.format` always wins, e.g. `->format('ubl')` or `->format('cii')` for a platform that expects UBL or CII. - **Sending.** Quittio produces the file. Sending it through an approved platform is not part of this pack, and the pack does not check whether an invoice must be an e-invoice. ## Mentions added by the pack `CountryFR` implements `CompletesInvoices`. While rendering, `complete()` adds up to two notes (BT-22) to the invoice, after the notes it already has. Like the [CIBS texts](#from-the-cgi-to-the-cibs), they appear in the rendered data, the XML and the PDF, not in the data of the builder. | Note | Subject code | Added when | |---|---|---| | Late payment mention | `PMT` | the buyer is no consumer, the invoice is no credit note, the setting `payment_mentions` is not `false`, and no note contains "pénalit" or "penalt" (case-insensitive) | | VAT on debits | `TXD` | the flag `CountryFR::FLAG_VAT_ON_DEBITS` is set, and no note contains "débits" or "debits" | The late payment mention in French: > En cas de retard de paiement, des pénalités sont dues au taux de refinancement de la Banque centrale européenne majoré de 10 points, ainsi qu'une indemnité forfaitaire pour frais de recouvrement de 40 € (art. L441-10 du Code de commerce). Pas d'escompte pour paiement anticipé. And in English: > In case of late payment, penalties at the refinancing rate of the European Central Bank plus 10 points and a fixed indemnity of EUR 40 for recovery costs are due (art. L441-10 of the French Commercial Code). No discount for early payment. - **Language.** The language of the invoice locale (`->locale()` on the builder) if the pack ships it (`fr`, `en`), French otherwise and without a locale. A locale passed to the run (`->locale()` on the pending invoice) does not change the notes. - **Your own wording.** A note of your own that contains "pénalités" (e.g. with an agreed rate or a discount) replaces the mention: the pack adds nothing, and `FR-COM-02` is satisfied. The pack does not look at the payment terms text; penalties stated only there do not stop the mention. - **Switching it off.** `payment_mentions = false` in `quittio.countries.fr` ([Meta flags and settings](#meta-flags-and-settings)). Then state the penalties yourself, otherwise `FR-COM-02` warns. - **No duplicates.** Running `complete()` again on completed data adds nothing. ## Late payment Art. L441-10 Code de commerce: the refinancing rate of the ECB on the first day of the half-year plus 10 points (12.40 % in the second half of 2026) and a fixed indemnity of 40 EUR. `EcbRateTable` holds the ECB rates from 2023; add later half-years with `withRate()`. Consumers owe the legal interest rate (art. 1231-6 Code civil). Its category depends on the creditor (art. L313-2 Code monétaire et financier): a business claims the rate for all other cases, 2.75 % in the second half of 2026 (`b2cFixedRate`; it changes every half-year), not the rate for creditors who are individuals (6.84 %). Quittio's documents do not apply these values by themselves: calculate the penalties with `DefaultInterest` and pass them to a payment reminder ([Documents: payment reminders](documents.md#payment-reminders)). `CountryFR::dunningLaw()` (also as `CountryFR::frenchDunningLaw()`) returns these values ([`DunningLaw`](country-packs.md#dunninglaw)): | Value | France | |---|---| | Penalties for business debtors (`b2bInterestPoints`) | ECB rate plus 10.00 points | | Interest for consumers (`b2cFixedRate`) | 2.75 % fixed, for the whole period | | Fixed indemnity for business debtors (`b2bFlatRate`) | 40.00 EUR | | Day count | 365 days | | Consumer default (`consumerDefaultAfterDays`) | none | | Reference rate (`referenceRateName`) | "Taux de refinancement de la BCE (art. L441-10 Code de commerce)" | `CountryFR::referenceRates()` returns a `Quittio\Country\FR\Dunning\EcbRateTable`, so `DefaultInterest::forCountry(new CountryFR)` works without further set-up: | Method | Result | |---|---| | `__construct(array $rates = EcbRateTable::PUBLISHED)` | the rates by the first day of the half-year (ISO date => percent); `PUBLISHED` runs from 1 January 2023 to 1 July 2026 (2.40 %) | | `withRate(string $from, string $rate): self` | a copy with the rate of one more half-year, e.g. `withRate('2027-01-01', '…')` | | `rateOn(Date $date): BigDecimal` | the rate of the day | | `periods(Date $from, Date $until): array` | the periods of equal rate between the two dates (`until` exclusive) | | `validUntil(): Date` | the first day without a known rate: 1 January 2027 for the shipped table | Days the table does not cover throw an `InvalidArgumentException` ("No ECB reference rate is known after 2026-12-31. Add it with withRate()."). ```php use Brick\Money\Money; use Quittio\Core\Documents\DocumentBuilder; use Quittio\Core\Dunning\DefaultInterest; use Quittio\Core\Support\Date; use Quittio\Country\FR\CountryFR; $interest = DefaultInterest::forCountry(new CountryFR); // invoice F-2026-00042 of 1,620.00 EUR, due on 4 November 2026: // penalties from 5 November; 20 December is the first day without $charges = $interest->calculate(Money::of('1620.00', 'EUR'), Date::parse('2026-11-05'), Date::parse('2026-12-20')); // one charge of 12.40 % (ECB rate 2.40 % + 10 points) over 45 days: 24.77 EUR $reminder = DocumentBuilder::paymentReminder(1) ->number('R-2026-0007') ->seller(fn ($s) => $s->name('Atelier Numérique SAS')->vatId('FR19812345676')->address('12 rue de la République', '69002', 'Lyon', 'FR')) ->buyer(fn ($b) => $b->name('Boutique Exemple SARL')->address('5 avenue de l\'Opéra', '75001', 'Paris', 'FR')) ->openItem('F-2026-00042', '2026-10-05', '1620.00', dueDate: '2026-11-04') ->interestCharge(...$charges) ->flatRate('F-2026-00042') // the fixed indemnity of 40.00 EUR for this invoice ->build(); ``` For a period after the shipped table, add the rate and pass the table with the law: ```php use Brick\Money\Money; use Quittio\Core\Dunning\DefaultInterest; use Quittio\Core\Support\Date; use Quittio\Country\FR\CountryFR; use Quittio\Country\FR\Dunning\EcbRateTable; $ecbRate = '2.40'; // placeholder: the rate the ECB applies on 1 January 2027 $interest = new DefaultInterest((new EcbRateTable)->withRate('2027-01-01', $ecbRate), CountryFR::frenchDunningLaw()); $charges = $interest->calculate(Money::of('1620.00', 'EUR'), Date::parse('2026-12-05'), Date::parse('2027-02-01')); ``` - **Descriptions.** `DefaultInterest::forCountry()` creates the charges without a description; the reminder then prints its default label ("Default interest … p.a. …"). Pass `description:` to `interest()` for a wording of your own. - **Day count.** The pack counts on 365 days (`InterestCharge::$dayCount`); `interestCharge()` takes it over. - **Consumers.** `calculate(…, consumer: true)` charges the fixed 2.75 % for the whole period, also for days in another half-year, and needs no ECB rate. For another half-year, pass a `DunningLaw` with the rate of that half-year as `b2cFixedRate`. - **Fixed indemnity.** `$interest->flatRate()` returns 40.00 EUR; `DocumentBuilder::flatRate($claim)` adds it once per claim and refuses it for consumers ([Documents: payment reminders](documents.md#payment-reminders)). ## Meta flags and settings Meta flags mark special cases on the invoice (`InvoiceData::$meta->flags`, set with `->flag()`): | Constant | Value | Effect | |---|---|---| | `CountryFR::FLAG_VAT_ON_DEBITS` | `fr.vat_on_debits` | `complete()` adds "Option pour le paiement de la taxe d'après les débits" ([Mentions added by the pack](#mentions-added-by-the-pack)) | | `Meta::FLAG_SMALL_BUSINESS` | `small_business` | small business invoice: no VAT number required (`FR-CGI-02`), no VAT allowed (`FR-CGI-06`), default VAT `VatPreset::SmallBusiness` | Settings of the pack live under `quittio.countries.fr` ([Settings of a pack](configuration.md#settings-of-a-pack-quittiocountriescode)): | Key | Type | Default | Effect | |---|---|---|---| | `countries.fr.payment_mentions` | bool | `true` | `false` = no late payment mention on invoices between businesses | The pack ships no configuration file, so `php artisan quittio:install` publishes none. Set the key in `config/quittio.php`; without Laravel, pass the same array to `Quittio::create()`: ```php laravel 'countries' => [ 'fr' => ['payment_mentions' => false], ], ``` ```php plain use Quittio\Core\Quittio; use Quittio\Country\FR\CountryFR; $quittio = Quittio::create(['country' => 'FR', 'countries' => ['fr' => ['payment_mentions' => false]]], [new CountryFR]); ``` `complete()` receives these settings from the render pipeline. When you call `(new CountryFR)->complete($invoice, $settings)` yourself, pass them as second argument. ## Defaults How `CountryFR` fills the [`CountryPack` contract](country-packs.md#the-countrypack-contract): | Hook | France | |---|---| | `defaults()` | currency `EUR`, time zone `Europe/Paris`, locale `fr`, paper `A4`, letter layout `free`, profile `en16931`, payment QR `girocode`, default VAT presets `fr.standard` and `fr.small_business` ([`CountryDefaults`](country-packs.md#countrydefaults)) | | `taxPresets()` | every case of [`VatPreset`](#tax-presets) | | `rules()` | the [rules](#rules) `FR-CGI-01` to `FR-CGI-09`, `FR-COM-01`, `FR-COM-02` | | `buyerCountryRules()`, `profiles()`, `legalTexts()`, `letterLayouts()`, `exporters()`, `readers()` | none (defaults of `AbstractCountryPack`) | | `formatRules()` | [`FrenchFormatRule`](#format-choice) | | `mandatoryOutput()` | [mandatory PDF output](#mandatory-pdf-output) | | `complete()` | [CIBS texts](#from-the-cgi-to-the-cibs) and [mentions](#mentions-added-by-the-pack) | | `numberingRules()` | pattern `F-{Y}-{seq:5}`, reset `yearly`, resets `never` and `yearly`, gapless | | `retention()` | ten years from the end of the calendar year | | `dunningLaw()`, `referenceRates()` | [late payment values and ECB rates](#late-payment) | | `correctionPolicy()` | [credit note, cancel and reissue, French titles](#credit-notes-corrections-and-self-billing) | | `paymentQr()`, `addressFormatter()` | defaults: EPC GiroCode ([Payment QR codes](templates.md#payment-qr-codes)), international address format | | `translationPath()` | `resources/lang` of the package | - **Numbering.** A unique number of a continuous chronological series (art. 242 nonies A annex II CGI). Unless the issuer or the configuration sets a pattern, the Managed layer numbers French invoices `F-2026-00001`, `F-2026-00002` … and resets the sequence every year; a monthly reset is rejected ([Managed: numbering](managed.md#numbering), [`NumberingRules`](country-packs.md#numberingrules)). - **Retention.** Ten years (art. L123-22 Code de commerce). `retention()` returns `new RetentionRule(10, fromEndOfCalendarYear: true)`: an invoice issued on 5 October 2026 is kept until 31 December 2036. The Managed layer stores this date ([Managed: retention and deletion](managed.md#retention-and-deletion)). - **Locale.** French is the last fallback of the render and validation locale, after the run option, the invoice locale and `quittio.defaults.locale` ([Translations and locales](templates.md#translations-and-locales)). The core labels exist in French. ### Credit notes, corrections and self-billing `CountryFR::correctionPolicy()` sets how invoices of a French seller are cancelled and corrected ([Building invoices: cancellations and corrections](building-invoices.md#cancellations-and-corrections)): - **Cancellation strategy `credit_note`:** a cancellation is a credit note (avoir, type code 381) with positive amounts. - **Correction strategy `cancel_and_reissue`:** the Managed layer corrects an invoice by cancelling it and issuing a new one. Change them with `quittio.corrections.cancellation_strategy` and `quittio-managed.correction.strategy`. The policy sets these document titles: | Kind | French | English | |---|---|---| | `cancellation` | Avoir | Credit note | | `correction` | Facture rectificative | Corrected invoice | | `self_billed` | Autofacturation | Self-billed invoice | Other locales use the English titles. A cancellation of a self-billed invoice is titled "Avoir" as well; the pack defines no title for `price_reduction`. A self-billed invoice (autofacturation: the buyer issues the invoice in the seller's name) needs the mention "Autofacturation" in a note (`FR-CGI-07`). The title alone does not satisfy the rule. Add the note with the text of the pack: ```php use Quittio\Core\Builder\InvoiceBuilder; use Quittio\Core\Enums\InvoiceTypeCode; use Quittio\Country\FR\Texts\LegalTexts; $builder = InvoiceBuilder::make() ->type(InvoiceTypeCode::SelfBilledInvoice) ->note(LegalTexts::text(LegalTexts::SELF_BILLING, 'fr')); // "Autofacturation" ``` ## Mandatory PDF output After rendering, the mandatory field guard checks that the PDF shows certain values ([Templates: mandatory field guard](templates.md#mandatory-field-guard)). `CountryFR::mandatoryOutput()` adds these French values to the base fields ([Mandatory output](country-packs.md#mandatory-output)): | Condition | Access key | Description | Legal basis | |---|---|---|---| | the seller has a legal registration identifier | `seller.legalRegistration\|issuer.legalRegistration` | SIREN of the seller | art. R123-237 Code de commerce | | the seller has a VAT number | `seller.vatId\|taxRepresentative.vatId` | VAT number of the seller | art. 242 nonies A annexe II CGI | | the buyer is no consumer and the invoice has a due date | `dueDate\|paymentTerms.lines[*]` | due date | art. L441-9 Code de commerce | | each VAT row of category `AE`, `K`, `G` or `E` | `vatRows[i].label` or the legal note with its BT-120 text | reverse charge or exemption mention | art. 242 nonies A annexe II CGI | ## Translations The pack ships French and English texts in `resources/lang/{fr,en}/`: - `rules.php`: message and hint of every rule (`FR-CGI-01` to `FR-CGI-09`, `FR-COM-01`, `FR-COM-02`); - `tax.php`: the exemption reason texts of the presets, `fr.exempt` for `VatPreset::exempt()` (placeholder `:paragraph`) and the CIBS texts (`fr.small_business_cibs`, `fr.intra_community_supply_cibs`, `fr.export_cibs`); - `legal.php`: the late payment mention (`late_payment`), the mention of VAT on debits (`vat_on_debits`) and "Autofacturation" (`self_billing`), read through `Quittio\Country\FR\Texts\LegalTexts::text($key, $locale)`. They are registered as the namespace `quittio-fr` (e.g. `quittio-fr::rules.FR-CGI-08.message`). `CountryFR::registerTranslations()` registers them lazily, so presets work without a `Quittio` instance. `CountryFR::locales()` lists the locales the pack ships (`en`, `fr`). Fallbacks: - rule messages and preset texts: English for other locales; - legal texts (`LegalTexts::text()`): French for other languages; - correction titles (defined in PHP): English for other locales. To change a text, override the key in your own file: - **Laravel:** `lang/vendor/quittio-fr/{locale}/rules.php`, `tax.php` or `legal.php`, also for additional locales. - **Without Laravel:** register a directory with `{locale}/{group}.php` files after the pack's own. Keys you leave out keep the texts of the pack. ```php use Quittio\Core\I18n\Translations; use Quittio\Country\FR\CountryFR; CountryFR::registerTranslations(); Translations::translator()->addPath(__DIR__.'/lang', CountryFR::TRANSLATION_NAMESPACE); // e.g. lang/fr/legal.php ``` The CIBS replacement compares with the preset texts of the translations in use, so a changed CGI text is still replaced by its CIBS text from 2027. Rule messages follow the validation locale ([Messages and translations](validation.md#messages-and-translations)). ## Known limitations - The legal wording, rules and defaults follow the law and the official sources of October 2026 and have not been reviewed by a French tax adviser. Later changes of the law need a new release. - Connection to approved platforms, lifecycle statuses and e-reporting (planned as quittio/fr-platforms). - The French business rules BR-FR-… (norm AFNOR XP Z12-012, external specifications of the DGFiP) and the FEC export (art. A47 A-1 LPF). - Overseas rates: 8.5 %, 2.1 %, 1.75 % and 1.05 % in Guadeloupe, Martinique and La Réunion (art. 296 and 296 bis CGI); no VAT in Guyane and Mayotte (art. 294 CGI). - ECB rates from 2027: `EcbRateTable` ends with the second half of 2026; add later half-years with `withRate()`. The consumer rate of 2.75 % is the one of the second half of 2026 and is not dated. - The pack does not check whether an invoice must be an e-invoice, the delivery address of the reform, or the content of the late payment mention beyond the word "pénalités" (`FR-COM-02`). - `FR-CGI-01` and `FR-CGI-08` check the number, not its scheme (`0002`, `0009`), and do not look the number up in the business register. - The pack defines no buyer country rules, profiles, legal text catalog, exporters or readers. ## Complete example A web agency in Lyon invoices a shop in Paris for services in October 2026. Quittio chooses Factur-X (EN 16931), adds the late payment mention and validates the invoice with the French rules: ```php use Quittio\Core\Builder\InvoiceBuilder; use Quittio\Core\Enums\PaymentMeansCode; use Quittio\Core\Enums\UnitCode; use Quittio\Core\Quittio; use Quittio\Country\FR\CountryFR; use Quittio\Country\FR\Tax\VatPreset; $quittio = Quittio::create(['country' => 'FR'], [new CountryFR]); $invoice = InvoiceBuilder::make() ->number('F-2026-00042') ->issueDate('2026-10-05') ->deliveryDate('2026-09-30') ->currency('EUR') ->locale('fr') ->businessProcess('S1') // services (BT-23) ->seller(fn ($s) => $s ->name('Atelier Numérique SAS') ->vatId('FR19812345676') ->legalRegistration('812345676', '0002') // SIREN of the seller (BT-30) ->address('12 rue de la République', '69002', 'Lyon', 'FR') ->contact('Claire Martin', '+33 4 72 00 00 00', 'factures@atelier-numerique.example')) ->buyer(fn ($b) => $b ->name('Boutique Exemple SARL') ->vatId('FR15901234567') ->legalRegistration('901234567', '0002') // SIREN of the buyer (BT-47) ->address('5 avenue de l\'Opéra', '75001', 'Paris', 'FR')) ->paymentTerms(fn ($t) => $t->dueInDays(30)) ->payment(PaymentMeansCode::SepaCreditTransfer, iban: 'FR1420041010050500013M02606') ->line('Développement web', netPrice: '90.00', quantity: 10, unit: UnitCode::Hour, vat: VatPreset::Standard) ->line('Formation des utilisateurs', netPrice: '450.00', unit: UnitCode::Day, vat: VatPreset::Standard) ->build(); $result = $quittio->make($invoice)->render(); $result->format(); // "zugferd": Factur-X with the profile EN 16931 $result->validation()->errors(); // [] $result->data()->notes; // the late payment mention, added by the pack $result->save('F-2026-00042.pdf'); // net 1,350.00 EUR, VAT 270.00 EUR, total 1,620.00 EUR ``` `$quittio->make($invoice)->check()` returns the same validation result without rendering the PDF ([Checking without rendering](validation.md#checking-without-rendering)). <!-- Source: https://quittio.dev/docs/troubleshooting --> # Troubleshooting This page lists the errors that people new to Quittio meet most often, with the cause and the fix. Most of them come from validation: Quittio checks every invoice against the rules of the e-invoicing standards before it renders it ([Rules and validation](concepts.md#rules-and-validation)). ## Reading an error message An invalid invoice stops the rendering with a `Quittio\Core\Validation\ValidationException`. Its message lists every error with the rule code, the field and a hint: ```text The invoice is not valid (2 errors): [BR-CO-25] BT-9: In case the amount due for payment (BT-115) is positive, either the payment due date (BT-9) or the payment terms (BT-20) shall be present. Add a payment target with ->dueInDays(14) or a due date with ->dueDate(). [DE-USTG-03] BT-72: The date of the supply or service must be stated: delivery date (BT-72), invoicing period (BG-14) or periods on all lines (BG-26) (section 14 (4) no. 6 UStG). Set ->deliveryDate(), even if it equals the invoice date, or ->invoicingPeriod(). ``` - `[BR-CO-25]` is the rule. The prefix tells where it comes from: `BR-` EN 16931, `BR-DE-` XRechnung, `DE-USTG-` the German VAT Act, `QUITTIO-` Quittio itself ([rule codes](concepts.md#rules-and-validation)). - `BT-9` is the field ([business terms](concepts.md#en-16931-and-business-terms)); the [Field reference](field-reference.md) shows where each field is in the data model. - The indented line is the hint: usually the builder method that fixes the error. Warnings do not stop the rendering; they are in `$result->validation()`. `->check()` instead of `->render()` validates without rendering and returns all findings without throwing, which helps while you build an invoice step by step ([Validation](validation.md)). The messages are in the language of your Laravel application (`app()->getLocale()`). `quittio.validation.locale` sets another language, `'invoice'` uses the language of the invoice ([Messages and translations](validation.md#messages-and-translations)). Without Laravel they are in the language of the invoice unless the core setting `validation.locale` names another one. ## Errors while building These errors are thrown by `build()` or `render()` before any validation, as `Quittio\Core\Exceptions\InvalidInvoiceData` or `InvalidArgumentException`. ### "Floats are not accepted" ```text Floats are not accepted for amounts, prices, rates and quantities (19.99 given) … ``` Amounts, prices, rates and quantities must be strings or integers: `netPrice: '19.99'`, not `netPrice: 19.99`. A float such as 0.1 cannot be stored exactly, and invoices must be exact to the cent. Values from the database are usually strings already; cast decimals with `(string)`. ### "Missing VAT information of line 1 (BG-30)" The line has no VAT rate. In Laravel every line without `vat:` gets the default VAT (19 % for a German seller, `quittio.defaults.vat`). Without Laravel there is no default: set the VAT per line (`vat: VatPreset::Standard`), for the invoice with `->defaultVat(VatPreset::Standard)`, or once for the application with `InvoiceBuilder::useDefaultVat(…)` ([Default VAT](building-invoices.md#default-vat)). ### "Missing seller postal address (BG-5)" and other "Missing …" A required part of the invoice is missing entirely; the message names it and its field number. With `Quittio::invoice()` the seller comes from `config/quittio.php`: fill in `seller.address` (street, postcode, city, country) there ([Configuration](configuration.md)). Without Laravel, call `->address(…)` on the `Party::make()` under `seller` in `Quittio::create()`; a configured seller without address already fails there with a `ConfigurationException`. For the buyer, call `->buyer(Party::make('…')->address(…))`. ## Validation errors ### Seller address incomplete (DE-USTG-01) The address of the seller or buyer lacks street, postcode, city or country; the message names the party and the missing fields. German invoices need the full address of both parties. For the seller, check `seller.address` in `config/quittio.php` (without Laravel, `->address(…)` of `seller` in `Quittio::create()`). ### Seller identifier missing (BR-CO-26, BR-S-02, DE-USTG-02) The seller has neither a VAT identification number nor a tax number. Set `seller.vat_id` or `seller.tax_number` in `config/quittio.php` (or `->vatId()` / `->taxNumber()` on the seller). A small business with a tax number only also needs a seller identifier or a trade register number for EN 16931 (`seller.identifiers` or `seller.legal_registration`, rule `BR-CO-26`). ### Date of supply missing (DE-USTG-03) German invoices must state when the goods were delivered or the service was performed, even if it is the invoice date. Add `->deliveryDate('2026-09-30')`, an invoicing period, or a period on every line (`Line::make(…)->period(…)`). ### Payment due date missing (BR-CO-25) An invoice with an amount to pay needs a due date or payment terms: `->dueInDays(14)` or `->dueDate('2026-10-17')`. In Laravel `quittio.defaults.due_days` (default 14) adds a due date to every invoice without one, without Laravel `due_days` of `Quittio::create()` (no default). The error therefore appears when that key is `null` or, without Laravel, not set. ### XRechnung needs more fields (QUITTIO-PROFILE-REQUIRED, BR-DE-…) XRechnung (public buyers in Germany) requires fields that other formats leave optional. A typical first attempt reports several errors at once: | Field | Set with | |---|---| | Buyer reference, the Leitweg-ID of the authority (BT-10) | `->buyerReference('04011000-12345-03')` | | Seller contact: name, phone, e-mail (BG-6) | `seller.contact` in the configuration, or `->contact(…)` on the seller | | Electronic address of seller and buyer (BT-34, BT-49) | `seller.electronic_address` in the configuration; `->electronicAddress('ap@kunde.de', 'EM')` on the buyer | | Payment instructions (BG-16) | `seller.bank_accounts` in the configuration, or `->payment(…)` | See the [public sector example](examples.md#public-sector) and [German format choice](country-packs.md#format-choice). ### Peppol rejects the electronic address (PEPPOL-EN16931-CL008) Peppol delivers to the electronic address (BT-34, BT-49), so it must be a Peppol participant identifier. EN 16931 also allows an e-mail address (`EM`), Peppol does not, nor the other letter schemes and a few newer codes of the EAS list. Use the scheme under which the party is registered in Peppol, e.g. `->electronicAddress('DE123456789', '9930')` (German VAT number) or `->electronicAddress('4000001000005', '0088')` (GLN); for the seller set `seller.electronic_address` in the configuration. ZUGFeRD and XRechnung keep accepting `EM`. ### Small business with VAT (DE-USTG-09) The seller is marked as a small business (`seller.small_business`, German Kleinunternehmer under section 19 UStG), but a line carries VAT. Small businesses charge no VAT: with the small business setting, lines without `vat:` get the small business preset automatically; remove explicit `vat:` values from the lines. ## Rendering and PDF ### "The format … produces e-invoice XML and cannot be rendered with a watermark" Drafts and previews carry a watermark and must never pass as an e-invoice, so they cannot be rendered in a format with XML. Render drafts with `->render('pdf')` or `'html'` ([Watermark](templates.md#watermark)). ### "The template does not output mandatory information" An own template (or a changed partial) does not print a value the invoice must show, e.g. the VAT identifier or the date of supply; the message lists the missing values. Print them, or start from a copy of the default template (`php artisan make:quittio-template`). See [Mandatory field guard](templates.md#mandatory-field-guard). ### Logo errors - "The logo file … does not exist": the path in `pdf.logo` is relative or wrong; use an absolute path such as `storage_path('app/logo.png')`. - SVG logos in PDF/A documents (ZUGFeRD, XRechnung PDF) need the PHP extension `imagick`; use a PNG otherwise. - In HTML output a local logo path is not visible in a browser; use a URL or data URI there. Details: [Logos](templates.md#logos). ### Characters are missing in the PDF The default font Geist covers Latin and Cyrillic, not Greek. Set `pdf.font = 'inter'` for Greek names or texts, or register a font that has the characters ([Fonts](templates.md#fonts)). ### A long line item starts on the next page A table row is never split between two pages. When a line with a very long description does not fit below the invoice details, it moves to the next page as a whole. Shorten the description or move details to a note or an attachment. ### "Invalid colour" or "Invalid font name" Colours in `pdf.colors` must be hex values (`#2741d9`), fonts plain family names that are registered (`geist`, `inter` or an entry of `pdf.fonts`). ## External validators ### KOSIT-UNAVAILABLE, VERAPDF-UNAVAILABLE The KoSIT validator (official check of XRechnung and EN 16931) or veraPDF (PDF/A check) is enabled in `validation.levels` but could not run, usually because Java, Docker or the validator files are missing. By default (`fail_on_unavailable = true` in `validation.drivers.kosit` and `validation.drivers.verapdf`) this is an error and the rendering stops, so that an invoice is never sent unchecked by mistake. Install the validator as described in [Validation](validation.md#kosit-validator-l5), remove `kosit` or `verapdf` from `validation.levels`, or set `fail_on_unavailable` to `false` to get a warning instead. ## Still stuck? - Look at the invoice the way Quittio sees it: `Quittio::make($invoice)->prepare()` shows the chosen format, profile and all findings without rendering. - Render the sample invoices: `php artisan quittio:preview --scenario=simple` shows whether configuration and template work. - Validate an existing file: `php artisan quittio:validate invoice.xml` ([Artisan commands](commands.md)). - Compare with a complete example on [Examples](examples.md). - Questions about sending, the German e-invoicing obligation, Java or temporary files: [FAQ](faq.md). <!-- Source: https://quittio.dev/docs/faq --> # FAQ Short answers to questions that come up before and after the first invoice, with links to the pages that explain the details. For error messages, see [Troubleshooting](troubleshooting.md). ## Does Quittio send invoices? No. Quittio creates, validates, reads and renders invoices; how they reach the buyer is up to your application: - **E-mail:** attach the result to a mailable; `RenderedInvoice` implements Laravel's `Attachable` ([Laravel integration](laravel.md)). - **Peppol:** the format `peppol` writes UBL according to Peppol BIS Billing 3.0. Sending it needs a Peppol access point, a service provider connected to the network; hand it the XML from `$result->xml()` ([Peppol BIS Billing 3.0](formats.md#peppol-bis-billing-30)). A Peppol lookup lets the automatic choice pick `peppol` for buyers that are reachable there ([Peppol lookup](formats.md#peppol-lookup)). - **Public buyers in Germany:** upload the XRechnung to the portal the authority names, or send it via Peppol ([Examples: Public sector](examples.md#public-sector)). ## Which format meets the German e-invoicing obligation? Since 1 January 2025 every business in Germany must be able to receive e-invoices. Sending them becomes mandatory step by step: the transitional rules of section 27 (38) UStG still allow other invoices for domestic business-to-business supplies until the end of 2026, and in 2027 for businesses whose total turnover of the previous year was at most 800,000 euros. From 2028 domestic business invoices must be e-invoices. Invoices to consumers and small amount invoices up to 250 euros are not affected ([E-invoicing basics](concepts.md)). An e-invoice in this sense is a structured format that conforms to EN 16931. With Quittio these are: | Format | Profile | |---|---| | `zugferd` / `factur-x` (PDF with embedded XML) | `en16931` (the default) or `extended`; not `minimum` or `basic-wl` | | `xrechnung-cii`, `xrechnung-ubl` | `xrechnung` (required for public buyers) | | `cii`, `ubl` | `en16931` | | `peppol` | `peppol` | A plain `pdf` is no e-invoice. MINIMUM and BASIC WL carry no lines and do not conform to EN 16931; the validation warns with `QUITTIO-PROFILE-NOT-EINVOICE`. The German country pack chooses `zugferd` for domestic business invoices, XRechnung for public buyers and `pdf` for consumers and small amount invoices ([German format choice](country-packs.md#format-choice)). If you choose another format yourself, it checks the obligation by the supply date: a warning during the transition (`DE-EINVOICE-02`), an error once an e-invoice is required (`DE-EINVOICE-01`, [E-invoice obligation](country-packs.md#e-invoice-obligation)). This is a summary, not legal advice. The legal wording of the country pack was reviewed by a tax adviser in October 2026; see the legal review and the disclaimer in the README of the repository. ## Do I need Java? Only for the official Schematron check (validation level L5) with the KoSIT validator, which runs on Java. Building, calculating, validating levels L1 to L4 and L7, writing XML, rendering PDF/A and reading invoices are pure PHP. The KoSIT validator can run as a daemon in another container or on another host, so the PHP application itself does not need Java ([KoSIT validator](validation.md#kosit-validator-l5)). The PDF/A check (L6) uses veraPDF, locally or through Docker. Both are off by default. ## Which exceptions does reading throw? Reading throws only when the file cannot be read as an invoice at all: `UnsafeXmlException` (too large, not well-formed, DOCTYPE, limits), `PdfException` (encrypted, malformed or too large PDF) and `UnreadableInvoiceException` (unknown format, ZUGFeRD 1.0, a PDF without embedded invoice, a missing file). All three implement `Quittio\Core\Exceptions\QuittioException`. Everything else, for example totals that differ from a recalculation, becomes a finding of the result ([Reading: Errors](reading.md#errors)). ```php laravel use Quittio\Core\Exceptions\QuittioException; use Quittio\Laravel\Facades\Quittio; try { $read = Quittio::readFile($path); } catch (QuittioException $e) { // not an invoice Quittio can read: reject the upload } ``` ```php plain use Quittio\Core\Exceptions\QuittioException; try { $read = $quittio->readFile($path); } catch (QuittioException $e) { // not an invoice Quittio can read: reject the upload } ``` Without Laravel, `$quittio` is the instance created in [Without Laravel](getting-started.md#without-laravel). ## Where does mPDF write temporary files? mPDF needs a writable temporary directory for fonts and images; Quittio also caches prepared logos in its `logos` subdirectory. In Laravel it is `pdf.cache_path` (default `storage/framework/cache/quittio`), without Laravel `temp_dir` of the configuration (default `sys_get_temp_dir()/quittio-mpdf`). On read-only file systems and in containers, point it to a writable volume ([Configuration](configuration.md)). ## How much time and memory does rendering take? It depends on the template, the number of lines and pages, logos and fonts. Measure it on your server with the sample invoices: ```bash php artisan quittio:benchmark --scenario=many-lines --count=20 ``` The command prints the average, minimum, 95th percentile and maximum time and the peak memory ([Artisan commands](commands.md)). Invoices over several pages take longer, because the line table is laid out again for the carry-over at each page break. For many invoices at once, render in the queue. ## What happens to queued invoices after an update? A queued render (`->queue()->save()`) stores the invoice as a versioned JSON snapshot and the render options as versioned JSON, not as PHP objects. When the data model changes between the dispatch and the run of the job, the configured upcasters bring the snapshot up to date (`quittio.snapshots.upcasters`), so the job renders the current model ([Queueing](laravel.md#queueing), [Snapshots](configuration.md#snapshots)). Queued documents (`Quittio::document($quote)->queue()->save()`) work the same way with their own snapshot version and `quittio.snapshots.document_upcasters` ([Documents: queueing](documents.md#queueing)). Let the queue run empty before an update anyway, as for any job whose code changes. <!-- Source: https://quittio.dev/docs/compatibility --> # Versioning and compatibility Quittio follows [Semantic Versioning](https://semver.org). This page says what that promise covers, so you know what can change under you in an update and what cannot. ## Releases Since 1.0: - **Patch releases** (1.0.0 → 1.0.1) fix bugs and security issues. They do not remove or rename anything you use. A fix can still change behaviour that was wrong, e.g. reject data that produced invalid XML before. - **Minor releases** (1.0 → 1.1) add features. They do not break the public API; what they replace keeps working as a deprecated alias (see [Deprecations](#deprecations)). - **Major releases** (1.x → 2.0) may break the public API. Every break is listed in the [changelog](https://github.com/Quittio/quittio/blob/master/CHANGELOG.md) under "Changed" or "Removed", with what to do. Before 1.0, minor releases could break the public API. The [upgrade guide](upgrading.md) lists what changed from 0.x to 1.0. ## What the promise covers The public API is everything below that is not marked `@internal`: | Area | Covered | |---|---| | PHP classes | Public classes, methods, properties and constants in `Quittio\Core`, `Quittio\Laravel` and `Quittio\Country\DE`: builders, data objects, `Quittio\Core\Quittio`, the facade and `QuittioManager`, results, events, exceptions | | Contracts | Interfaces you implement, such as `CountryPack`, `ValidationDriver`, `Rule`, `PdfRenderer`, `TemplateEngine`, `XmlSerializer`, `FormatReader`, `FormatResolver`, `SnapshotUpcaster`, `PaymentQrGenerator`, `VatIdVerifier`, `InvoiceDefaults`. A method is added to an interface only in a major release; base classes such as `AbstractCountryPack` and `AbstractProfile` get new methods with a default implementation. New abilities of packs and profiles come as optional capability interfaces (`Countries\Capabilities\*`, `Profiles\Capabilities\*`), which are covered like the other contracts. | | Configuration | The keys of `config/quittio.php` and of the country packs (`quittio.countries.de`, `config/quittio/countries/de.php`), their meaning and defaults, and the environment variables. A renamed key or variable keeps working under its old name until the next major release. | | Rule codes | Codes of findings, both official (`BR-CO-10`, `BR-DE-1`, `PEPPOL-EN16931-R001`) and Quittio's (`QUITTIO-…`). A code keeps its meaning; its message text is not covered. Rule overrides (`validation.rules`, `Quittio::extend('rule', …)`) address rules by these codes. | | Events | Class names and payload properties of the events in `Quittio\Laravel\Events` | | View model | The keys templates read (`$invoice->seller->name`, also in array syntax) and their types, described by the node classes in `Quittio\Core\View\Model` ([Typed nodes](templates.md#typed-nodes)). New keys may be added. | | Stored data | The snapshot formats of `InvoiceData::toSnapshot()` and `DocumentData::toSnapshot()` and the array format of `RenderOptions::toArray()`. A new version comes with an upcaster or a reader for the old one, so stored invoices and queued jobs stay readable. | | Commands | Names, arguments, options and exit codes of the Artisan commands | | Output | XML that conforms to the profile. The XML of the same data changes only when a standard or a profile changes, or to fix a conformance error. | ## What it does not cover - Classes and methods marked `@internal`, e.g. `XPathReader`, `XmlBuilder`, the PDF parser in `Pdf\Parsing`, `ConfigMapper`, `CountryPackDiscovery`, the section factories of the view model in `View\Internal`, the preview controller and the command classes. Use the public contract instead: implement `FormatReader` instead of extending `XPathReader`, call the commands instead of their classes. - Private and protected members of final classes. - The markup and CSS of the shipped templates. Templates you published (`--tag=quittio-views`) are yours; a release lists template changes so you can merge them. - The bytes of rendered PDFs, the wording of messages and labels, and the exact layout. - New findings: a minor release may add rules. A new rule reports a warning unless a standard makes it an error; such errors are listed in the changelog. - Data that follows its publisher: code lists, base rates, KoSIT configurations and Peppol rules are updated when they change upstream. ## Deprecations A deprecated method, class, configuration key or environment variable - is marked `@deprecated` with its replacement, so your IDE and static analysis show it, - is listed under "Deprecated" in the changelog, - keeps working until the next major release. The deprecations of 0.x were removed in 1.0. ## Country packs without tax review `quittio/country-at`, `quittio/country-ch`, `quittio/country-be` and `quittio/country-fr` are released together with the other packages and carry the same version, but no tax adviser of their country has reviewed them yet. Until that review they are not covered by the promise: a minor release may change their classes, configuration keys, rule codes and output where the review or a correction of the national rules requires it. Every such change is listed in the changelog. A reviewed pack says so in its README and documentation page, and from that release on it is covered like `quittio/country-de`. The order of the reviews is on the [roadmap](https://quittio.dev/roadmap). ## Supported versions | Dependency | Supported | |---|---| | PHP | 8.3 and newer | | Laravel | the current major release (13). A new Laravel major is supported in the next Quittio minor release, which then drops the previous one. | Security fixes are released for the latest minor release. <!-- Source: https://quittio.dev/docs/upgrading --> # Upgrading from 0.x to 1.0 Quittio 1.0 removes what the 0.x releases deprecated and fixes the public API: from now on only a major release breaks it ([Versioning and compatibility](compatibility.md)). This page lists every break and what to do. If your application runs on 0.8 without deprecation notices, most of the steps below do not apply. Two ways to find the calls that are affected before you update: - **Static analysis.** PHPStan with [phpstan-deprecation-rules](https://github.com/phpstan/phpstan-deprecation-rules) reports every call of deprecated code. - **Runtime notices.** The old builder macros and `config/quittio-de.php` report an `E_USER_DEPRECATED` in 0.8. Laravel writes them to the `deprecations` log channel when one is configured. ## Composer ```bash composer require quittio/quittio:^1.0 # without Laravel composer require quittio/core:^1.0 quittio/country-de:^1.0 ``` All packages are released together and carry the same version. The country packs for Austria, Switzerland, Belgium and France are not covered by the compatibility promise until a tax adviser of their country has reviewed them ([Country packs without tax review](compatibility.md#country-packs-without-tax-review)). ## Methods of `Quittio\Core\Quittio` The `with…()` methods that changed the instance are gone. Elsewhere in Quittio, `with…()` returns a changed copy; these methods never did, so they were renamed in 0.2: | Removed | Use instead | |---|---| | `withSerializer()` | `addSerializer()` | | `withValidator()` | `addValidator()` | | `withoutValidators()` | `clearValidators()` | | `withRenderer()` | `setRenderer()` | | `withTemplateEngine()` | `setTemplateEngine()` | | `withPaymentQrGenerator()` | `setPaymentQrGenerator()` | | `withFormatResolver()` | `setFormatResolver()` | The new methods behave exactly like the old ones: they change the instance and return it. ## Formats | Removed | Use instead | |---|---| | `FormatRegistry::XRECHNUNG_CII` | `Quittio\Country\DE\Formats\XRechnungFormats::CII` | | `FormatRegistry::XRECHNUNG_UBL` | `Quittio\Country\DE\Formats\XRechnungFormats::UBL` | | `DefaultFormatResolver::EU_COUNTRIES` | `Quittio\Core\Countries\VatTerritory::EU_MEMBER_STATES` | The formats `xrechnung-cii` and `xrechnung-ubl` and the alias `xrechnung` come from the German country pack only. In Laravel nothing changes, because the pack is discovered automatically. Without Laravel, pass the pack to `Quittio::create()` if you render XRechnung: ```php use Quittio\Core\Quittio; use Quittio\Country\DE\CountryDE; $quittio = Quittio::create(countryPacks: [new CountryDE]); ``` ## German country pack ### Tax presets `VatPreset::Standard19` and `VatPreset::Reduced7` are gone. `VatPreset::Standard` and `VatPreset::Reduced` replace them and take the rate of the supply date, e.g. 16 % and 5 % for supplies from July to December 2020 ([Tax presets](country-packs.md#tax-presets)). ```php use Quittio\Country\DE\Tax\VatPreset; // 0.x $line->vat(VatPreset::Standard19); // 1.0 $line->vat(VatPreset::Standard); ``` Invoices stored with 0.2 or earlier carry the preset keys `de.standard_19` and `de.reduced_7` on their lines. These keys stay readable: snapshots, `quittio.defaults.vat`, `(new CountryDE)->taxPresets()->get()` and `VatPreset::fromKey()` find `Standard` and `Reduced` for them. `VatPreset::from()` and `tryFrom()` no longer know them, though. If you keep preset keys in a column of your own and look them up with `from()`, switch to `fromKey()`: ```php use Quittio\Country\DE\Tax\VatPreset; use UnexpectedValueException; // 0.x: throws a ValueError in 1.0 for "de.standard_19" $preset = VatPreset::from($item->tax_preset); // 1.0 $preset = VatPreset::fromKey($item->tax_preset) ?? throw new UnexpectedValueException('Unknown preset '.$item->tax_preset); ``` Or update the column once, e.g. `UPDATE order_items SET tax_preset = 'de.standard' WHERE tax_preset = 'de.standard_19'` (and `de.reduced` for `de.reduced_7`). `VatPreset::canonical()` is gone as well: it turned the removed cases into `Standard` and `Reduced`, which `fromKey()` now returns directly. The old keys are available as `VatPreset::LEGACY_STANDARD_KEY` and `VatPreset::LEGACY_REDUCED_KEY`. ### Builder macros The macros of 0.2 directly on the builder are gone. The German special cases are reached with `->de()`: | Removed | Use instead | |---|---| | `->smallAmount()` | `->de()->smallAmount()` | | `->propertyRelatedService()` | `->de()->propertyRelatedService()` | | `->newVehicle()` | `->de()->newVehicle()` | | `->selfBilled()` | `->de()->selfBilled()` | | `->deductAdvance($advance)` | `->de()->deductAdvance($advance)` | | `->consumerDefaultNotice()` | `->de()->consumerDefaultNotice()` | Each method of `->de()` returns the builder, so the chain continues as before. The IDE stub `stubs/InvoiceBuilder.stub.php` describes `de()` only. ### Constants | Removed | Use instead | |---|---| | `Flags::SMALL_AMOUNT_LIMIT` | `TaxTables::smallAmountLimitOn($date)`: the limit depends on the date (150.00 EUR before 2017) | | `GermanInvoiceMacros::ADVANCE_TYPES` | `GermanInvoice::ADVANCE_TYPES` | ## Laravel configuration ### Environment variables The names of 0.1.0 are no longer read. Rename them in your `.env`: | Removed | Use instead | |---|---| | `QUITTIO_COUNTRY` | `QUITTIO_DEFAULT_COUNTRY` | | `QUITTIO_VALIDATION` | `QUITTIO_VALIDATION_MODE` | | `QUITTIO_GUARD` | `QUITTIO_MANDATORY_FIELD_GUARD` | | `QUITTIO_DISK` | `QUITTIO_STORAGE_DISK` | | `QUITTIO_PREVIEW` | `QUITTIO_PREVIEW_ENABLED` | A published `config/quittio.php` of 0.1 still reads the old names. Compare it with the current file (`php artisan vendor:publish --tag=quittio-config --force` overwrites it) or rename the variables in both places. ### `config/quittio-de.php` The German settings of 0.3 and earlier are no longer read. So that settings such as `prior_year_turnover_above_800k` are not lost unnoticed, the application refuses to start with a `RuntimeException` while `config/quittio-de.php` exists. Move its keys to `config/quittio/countries/de.php` and delete the old file: ```bash php artisan vendor:publish --tag=quittio-de-config # config/quittio/countries/de.php rm config/quittio-de.php rm -f bootstrap/cache/config.php # if the configuration is cached ``` See [Country pack Germany](configuration.md#country-pack-germany-quittiocountriesde) for the keys. ## Named arguments `DocumentBuilder::creditTransfer()` names its first parameter `$accountId`, like `InvoiceBuilder::creditTransfer()`. Only calls with a named argument change: ```php // 0.x $document->creditTransfer(iban: 'DE02120300000000202051'); // 1.0 $document->creditTransfer(accountId: 'DE02120300000000202051'); ``` <!-- Source: https://quittio.dev/docs/field-reference --> # Field reference Generated from the mapping attributes of the data model (`php tools/docs/generate.php`). Do not edit by hand. Paths use the property names of `InvoiceData`; `[]` marks lists. "Level" is the lowest Factur-X/ZUGFeRD profile that carries the field at this path (a part is never written without its parent, e.g. the buyer address starts with BASIC WL). | Path | BT | Card. | Level | CII | UBL | Notes | |---|---|---|---|---|---|---| | `number` | BT-1 | 1 | MINIMUM | `rsm:ExchangedDocument/ram:ID` | `cbc:ID` | | | `issueDate` | BT-2 | 1 | MINIMUM | `rsm:ExchangedDocument/ram:IssueDateTime` | `cbc:IssueDate` | | | `typeCode` | BT-3 | 1 | MINIMUM | `rsm:ExchangedDocument/ram:TypeCode` | `cbc:InvoiceTypeCode \| cbc:CreditNoteTypeCode` | | | `currency` | BT-5 | 1 | MINIMUM | `ram:ApplicableHeaderTradeSettlement/ram:InvoiceCurrencyCode` | `cbc:DocumentCurrencyCode` | | | `seller` | BG-4 | 1 | MINIMUM | `ram:ApplicableHeaderTradeAgreement/ram:SellerTradeParty` | `cac:AccountingSupplierParty` | | | `seller.name` | BT-27 | 1 | MINIMUM | `ram:SellerTradeParty/ram:Name` | `cac:AccountingSupplierParty/cac:Party/cac:PartyLegalEntity/cbc:RegistrationName` | | | `seller.address` | BG-5 | 1 | MINIMUM | `ram:SellerTradeParty/ram:PostalTradeAddress` | `cac:AccountingSupplierParty/cac:Party/cac:PostalAddress` | | | `seller.address.countryCode` | BT-40 | 1 | MINIMUM | `ram:CountryID` | `cac:Country/cbc:IdentificationCode` | | | `seller.address.line1` | BT-35 | 0..1 | BASIC WL | `ram:LineOne` | `cbc:StreetName` | | | `seller.address.line2` | BT-36 | 0..1 | BASIC WL | `ram:LineTwo` | `cbc:AdditionalStreetName` | | | `seller.address.line3` | BT-162 | 0..1 | BASIC WL | `ram:LineThree` | `cac:AddressLine/cbc:Line` | | | `seller.address.city` | BT-37 | 0..1 | BASIC WL | `ram:CityName` | `cbc:CityName` | | | `seller.address.postcode` | BT-38 | 0..1 | BASIC WL | `ram:PostcodeCode` | `cbc:PostalZone` | | | `seller.address.subdivision` | BT-39 | 0..1 | BASIC WL | `ram:CountrySubDivisionName` | `cbc:CountrySubentity` | | | `seller.tradingName` | BT-28 | 0..1 | BASIC WL | `ram:SellerTradeParty/ram:SpecifiedLegalOrganization/ram:TradingBusinessName` | `cac:PartyName/cbc:Name` | | | `seller.identifiers[]` | BT-29 | 0..n | BASIC WL | `ram:SellerTradeParty/ram:ID \| ram:GlobalID` | `cac:PartyIdentification/cbc:ID` | | | `seller.identifiers[].value` | | | | | | | | `seller.identifiers[].scheme` | | | | | | | | `seller.legalRegistration` | BT-30 | 0..1 | MINIMUM | `ram:SellerTradeParty/ram:SpecifiedLegalOrganization/ram:ID` | `cac:PartyLegalEntity/cbc:CompanyID` | | | `seller.legalRegistration.value` | | | | | | | | `seller.legalRegistration.scheme` | | | | | | | | `seller.vatId` | BT-31 | 0..1 | MINIMUM | `ram:SpecifiedTaxRegistration/ram:ID[@schemeID="VA"]` | `cac:PartyTaxScheme[cac:TaxScheme/cbc:ID="VAT"]/cbc:CompanyID` | | | `seller.taxNumber` | BT-32 | 0..1 | MINIMUM | `ram:SpecifiedTaxRegistration/ram:ID[@schemeID="FC"]` | `cac:PartyTaxScheme[cac:TaxScheme/cbc:ID!="VAT"]/cbc:CompanyID` | | | `seller.additionalLegalInfo` | BT-33 | 0..1 | EN 16931 | `ram:SellerTradeParty/ram:Description` | `cac:PartyLegalEntity/cbc:CompanyLegalForm` | | | `seller.electronicAddress` | BT-34 | 0..1 | BASIC WL | `ram:SellerTradeParty/ram:URIUniversalCommunication/ram:URIID` | `cbc:EndpointID` | required in xrechnung, peppol | | `seller.electronicAddress.value` | | | | | | | | `seller.electronicAddress.scheme` | | | | | | | | `seller.contact` | BG-6 | 0..1 | EN 16931 | `ram:SellerTradeParty/ram:DefinedTradeContact` | `cac:Contact` | required in xrechnung | | `seller.contact.name` | BT-41 | 0..1 | EN 16931 | `ram:PersonName` | `cbc:Name` | | | `seller.contact.phone` | BT-42 | 0..1 | EN 16931 | `ram:TelephoneUniversalCommunication/ram:CompleteNumber` | `cbc:Telephone` | | | `seller.contact.email` | BT-43 | 0..1 | EN 16931 | `ram:EmailURIUniversalCommunication/ram:URIID` | `cbc:ElectronicMail` | | | `buyer` | BG-7 | 1 | MINIMUM | `ram:ApplicableHeaderTradeAgreement/ram:BuyerTradeParty` | `cac:AccountingCustomerParty` | | | `buyer.name` | BT-44 | 1 | MINIMUM | `ram:BuyerTradeParty/ram:Name` | `cac:AccountingCustomerParty/cac:Party/cac:PartyLegalEntity/cbc:RegistrationName` | | | `buyer.address` | BG-8 | 1 | BASIC WL | `ram:BuyerTradeParty/ram:PostalTradeAddress` | `cac:AccountingCustomerParty/cac:Party/cac:PostalAddress` | | | `buyer.address.countryCode` | BT-55 | 1 | BASIC WL | `ram:CountryID` | `cac:Country/cbc:IdentificationCode` | | | `buyer.address.line1` | BT-50 | 0..1 | BASIC WL | `ram:LineOne` | `cbc:StreetName` | | | `buyer.address.line2` | BT-51 | 0..1 | BASIC WL | `ram:LineTwo` | `cbc:AdditionalStreetName` | | | `buyer.address.line3` | BT-163 | 0..1 | BASIC WL | `ram:LineThree` | `cac:AddressLine/cbc:Line` | | | `buyer.address.city` | BT-52 | 0..1 | BASIC WL | `ram:CityName` | `cbc:CityName` | | | `buyer.address.postcode` | BT-53 | 0..1 | BASIC WL | `ram:PostcodeCode` | `cbc:PostalZone` | | | `buyer.address.subdivision` | BT-54 | 0..1 | BASIC WL | `ram:CountrySubDivisionName` | `cbc:CountrySubentity` | | | `buyer.tradingName` | BT-45 | 0..1 | EN 16931 | `ram:BuyerTradeParty/ram:SpecifiedLegalOrganization/ram:TradingBusinessName` | `cac:PartyName/cbc:Name` | | | `buyer.identifier` | BT-46 | 0..1 | BASIC WL | `ram:BuyerTradeParty/ram:ID \| ram:GlobalID` | `cac:PartyIdentification/cbc:ID` | | | `buyer.identifier.value` | | | | | | | | `buyer.identifier.scheme` | | | | | | | | `buyer.legalRegistration` | BT-47 | 0..1 | MINIMUM | `ram:BuyerTradeParty/ram:SpecifiedLegalOrganization/ram:ID` | `cac:PartyLegalEntity/cbc:CompanyID` | | | `buyer.legalRegistration.value` | | | | | | | | `buyer.legalRegistration.scheme` | | | | | | | | `buyer.vatId` | BT-48 | 0..1 | BASIC WL | `ram:BuyerTradeParty/ram:SpecifiedTaxRegistration/ram:ID[@schemeID="VA"]` | `cac:PartyTaxScheme/cbc:CompanyID` | | | `buyer.electronicAddress` | BT-49 | 0..1 | BASIC WL | `ram:BuyerTradeParty/ram:URIUniversalCommunication/ram:URIID` | `cbc:EndpointID` | required in xrechnung, peppol | | `buyer.electronicAddress.value` | | | | | | | | `buyer.electronicAddress.scheme` | | | | | | | | `buyer.contact` | BG-9 | 0..1 | EN 16931 | `ram:BuyerTradeParty/ram:DefinedTradeContact` | `cac:Contact` | | | `buyer.contact.name` | BT-56 | 0..1 | EN 16931 | `ram:PersonName` | `cbc:Name` | | | `buyer.contact.phone` | BT-57 | 0..1 | EN 16931 | `ram:TelephoneUniversalCommunication/ram:CompleteNumber` | `cbc:Telephone` | | | `buyer.contact.email` | BT-58 | 0..1 | EN 16931 | `ram:EmailURIUniversalCommunication/ram:URIID` | `cbc:ElectronicMail` | | | `buyer.isConsumer` | | | | | | internal | | `lines[]` | BG-25 | 1..n | BASIC | `rsm:SupplyChainTradeTransaction/ram:IncludedSupplyChainTradeLineItem` | `cac:InvoiceLine \| cac:CreditNoteLine` | | | `lines[].id` | BT-126 | 1 | BASIC | `ram:AssociatedDocumentLineDocument/ram:LineID` | `cbc:ID` | | | `lines[].quantity` | BT-129 | 1 | BASIC | `ram:SpecifiedLineTradeDelivery/ram:BilledQuantity` | `cbc:InvoicedQuantity \| cbc:CreditedQuantity` | | | `lines[].unit` | BT-130 | 1 | BASIC | `ram:SpecifiedLineTradeDelivery/ram:BilledQuantity/@unitCode` | `cbc:InvoicedQuantity/@unitCode \| cbc:CreditedQuantity/@unitCode` | | | `lines[].price` | BG-29 | 1 | BASIC | `ram:SpecifiedLineTradeAgreement` | `cac:Price` | | | `lines[].price.netPrice` | BT-146 | 1 | BASIC | `ram:NetPriceProductTradePrice/ram:ChargeAmount` | `cac:Price/cbc:PriceAmount` | | | `lines[].price.discount` | BT-147 | 0..1 | BASIC | `ram:GrossPriceProductTradePrice/ram:AppliedTradeAllowanceCharge/ram:ActualAmount` | `cac:Price/cac:AllowanceCharge/cbc:Amount` | | | `lines[].price.grossPrice` | BT-148 | 0..1 | BASIC | `ram:GrossPriceProductTradePrice/ram:ChargeAmount` | `cac:Price/cac:AllowanceCharge/cbc:BaseAmount` | | | `lines[].price.baseQuantity` | BT-149 | 0..1 | BASIC | `ram:NetPriceProductTradePrice/ram:BasisQuantity` | `cac:Price/cbc:BaseQuantity` | | | `lines[].price.baseQuantityUnit` | BT-150 | 0..1 | BASIC | `ram:NetPriceProductTradePrice/ram:BasisQuantity/@unitCode` | `cac:Price/cbc:BaseQuantity/@unitCode` | | | `lines[].price.priceInclVat` | | | | | | internal | | `lines[].vat` | BG-30 | 1 | BASIC | `ram:SpecifiedLineTradeSettlement/ram:ApplicableTradeTax` | `cac:Item/cac:ClassifiedTaxCategory` | | | `lines[].vat.category` | BT-151 | 1 | BASIC | `ram:ApplicableTradeTax/ram:CategoryCode` | `cac:ClassifiedTaxCategory/cbc:ID` | | | `lines[].vat.rate` | BT-152 | 0..1 | BASIC | `ram:ApplicableTradeTax/ram:RateApplicablePercent` | `cac:ClassifiedTaxCategory/cbc:Percent` | | | `lines[].vat.exemptionReason` | | | | | | internal | | `lines[].vat.exemptionReasonCode` | | | | | | internal | | `lines[].vat.presetKey` | | | | | | internal | | `lines[].item` | BG-31 | 1 | BASIC | `ram:SpecifiedTradeProduct` | `cac:Item` | | | `lines[].item.name` | BT-153 | 1 | BASIC | `ram:SpecifiedTradeProduct/ram:Name` | `cac:Item/cbc:Name` | | | `lines[].item.description` | BT-154 | 0..1 | EN 16931 | `ram:SpecifiedTradeProduct/ram:Description` | `cac:Item/cbc:Description` | | | `lines[].item.sellerId` | BT-155 | 0..1 | EN 16931 | `ram:SpecifiedTradeProduct/ram:SellerAssignedID` | `cac:Item/cac:SellersItemIdentification/cbc:ID` | | | `lines[].item.buyerId` | BT-156 | 0..1 | EN 16931 | `ram:SpecifiedTradeProduct/ram:BuyerAssignedID` | `cac:Item/cac:BuyersItemIdentification/cbc:ID` | | | `lines[].item.standardId` | BT-157 | 0..1 | BASIC | `ram:SpecifiedTradeProduct/ram:GlobalID` | `cac:Item/cac:StandardItemIdentification/cbc:ID` | | | `lines[].item.standardId.value` | | | | | | | | `lines[].item.standardId.scheme` | | | | | | | | `lines[].item.classifications[]` | BT-158 | 0..n | EN 16931 | `ram:SpecifiedTradeProduct/ram:DesignatedProductClassification` | `cac:Item/cac:CommodityClassification` | | | `lines[].item.classifications[].code` | | | | | | | | `lines[].item.classifications[].listId` | | | | | | | | `lines[].item.classifications[].listVersion` | | | | | | | | `lines[].item.originCountry` | BT-159 | 0..1 | EN 16931 | `ram:SpecifiedTradeProduct/ram:OriginTradeCountry/ram:ID` | `cac:Item/cac:OriginCountry/cbc:IdentificationCode` | | | `lines[].item.attributes[]` | BG-32 | 0..n | EN 16931 | `ram:SpecifiedTradeProduct/ram:ApplicableProductCharacteristic` | `cac:Item/cac:AdditionalItemProperty` | | | `lines[].item.attributes[].name` | BT-160 | 1 | EN 16931 | `ram:ApplicableProductCharacteristic/ram:Description` | `cac:AdditionalItemProperty/cbc:Name` | | | `lines[].item.attributes[].value` | BT-161 | 1 | EN 16931 | `ram:ApplicableProductCharacteristic/ram:Value` | `cac:AdditionalItemProperty/cbc:Value` | | | `lines[].note` | BT-127 | 0..1 | BASIC | `ram:AssociatedDocumentLineDocument/ram:IncludedNote/ram:Content` | `cbc:Note` | | | `lines[].objectId` | BT-128 | 0..1 | EN 16931 | `ram:SpecifiedLineTradeSettlement/ram:AdditionalReferencedDocument[ram:TypeCode="130"]` | `cac:DocumentReference[cbc:DocumentTypeCode="130"]/cbc:ID` | | | `lines[].objectId.value` | | | | | | | | `lines[].objectId.scheme` | | | | | | | | `lines[].netAmount` | BT-131 | 1 | BASIC | `ram:SpecifiedLineTradeSettlement/ram:SpecifiedTradeSettlementLineMonetarySummation/ram:LineTotalAmount` | `cbc:LineExtensionAmount` | calculated | | `lines[].orderLineReference` | BT-132 | 0..1 | EN 16931 | `ram:SpecifiedLineTradeAgreement/ram:BuyerOrderReferencedDocument/ram:LineID` | `cac:OrderLineReference/cbc:LineID` | | | `lines[].buyerAccountingReference` | BT-133 | 0..1 | EN 16931 | `ram:SpecifiedLineTradeSettlement/ram:ReceivableSpecifiedTradeAccountingAccount/ram:ID` | `cbc:AccountingCost` | | | `lines[].period` | BG-26 | 0..1 | BASIC | `ram:SpecifiedLineTradeSettlement/ram:BillingSpecifiedPeriod` | `cac:InvoicePeriod` | | | `lines[].period.start` | BT-134 | | | | | | | `lines[].period.end` | BT-135 | | | | | | | `lines[].allowances[]` | BG-27 | 0..n | BASIC | `ram:SpecifiedLineTradeSettlement/ram:SpecifiedTradeAllowanceCharge` | `cac:AllowanceCharge` | | | `lines[].allowances[].amount` | BT-136 | 1 | BASIC | `ram:SpecifiedTradeAllowanceCharge/ram:ActualAmount` | `cac:AllowanceCharge/cbc:Amount` | | | `lines[].allowances[].baseAmount` | BT-137 | 0..1 | BASIC | `ram:BasisAmount` | `cbc:BaseAmount` | | | `lines[].allowances[].percent` | BT-138 | 0..1 | BASIC | `ram:CalculationPercent` | `cbc:MultiplierFactorNumeric` | | | `lines[].allowances[].reason` | BT-139 | 0..1 | BASIC | `ram:Reason` | `cbc:AllowanceChargeReason` | | | `lines[].allowances[].reasonCode` | BT-140 | 0..1 | BASIC | `ram:ReasonCode` | `cbc:AllowanceChargeReasonCode` | | | `lines[].charges[]` | BG-28 | 0..n | BASIC | `ram:SpecifiedLineTradeSettlement/ram:SpecifiedTradeAllowanceCharge` | `cac:AllowanceCharge` | | | `lines[].charges[].amount` | BT-141 | 1 | BASIC | `ram:SpecifiedTradeAllowanceCharge/ram:ActualAmount` | `cac:AllowanceCharge/cbc:Amount` | | | `lines[].charges[].baseAmount` | BT-142 | 0..1 | BASIC | `ram:BasisAmount` | `cbc:BaseAmount` | | | `lines[].charges[].percent` | BT-143 | 0..1 | BASIC | `ram:CalculationPercent` | `cbc:MultiplierFactorNumeric` | | | `lines[].charges[].reason` | BT-144 | 0..1 | BASIC | `ram:Reason` | `cbc:AllowanceChargeReason` | | | `lines[].charges[].reasonCode` | BT-145 | 0..1 | BASIC | `ram:ReasonCode` | `cbc:AllowanceChargeReasonCode` | | | `lines[].subLines[]` | | | | | | internal | | `lines[].lineReferences[]` | | | | | | EXTENDED only | | `lines[].lineReferences[].id` | | | | | | | | `lines[].lineReferences[].kind` | | | | | | | | `lines[].lineReferences[].lineId` | | | | | | | | `lines[].lineReferences[].issueDate` | | | | | | | | `lines[].lineReferences[].typeCode` | | | | | | | | `lines[].lineReferences[].description` | | | | | | | | `lines[].extended` | | | | | | EXTENDED only | | `lines[].extended.lineStatusReasonCode` | | | | | | EXTENDED only | | `lines[].extended.shipTo` | | | | | | EXTENDED only | | `lines[].extended.shipTo.name` | | | | | | | | `lines[].extended.shipTo.address` | | | | | | | | `lines[].extended.shipTo.address.countryCode` | BT-40 | 1 | EXTENDED | `ram:CountryID` | `cac:Country/cbc:IdentificationCode` | | | `lines[].extended.shipTo.address.line1` | BT-35 | 0..1 | EXTENDED | `ram:LineOne` | `cbc:StreetName` | | | `lines[].extended.shipTo.address.line2` | BT-36 | 0..1 | EXTENDED | `ram:LineTwo` | `cbc:AdditionalStreetName` | | | `lines[].extended.shipTo.address.line3` | BT-162 | 0..1 | EXTENDED | `ram:LineThree` | `cac:AddressLine/cbc:Line` | | | `lines[].extended.shipTo.address.city` | BT-37 | 0..1 | EXTENDED | `ram:CityName` | `cbc:CityName` | | | `lines[].extended.shipTo.address.postcode` | BT-38 | 0..1 | EXTENDED | `ram:PostcodeCode` | `cbc:PostalZone` | | | `lines[].extended.shipTo.address.subdivision` | BT-39 | 0..1 | EXTENDED | `ram:CountrySubDivisionName` | `cbc:CountrySubentity` | | | `lines[].extended.shipTo.identifiers[]` | | | | | | | | `lines[].extended.shipTo.identifiers[].value` | | | | | | | | `lines[].extended.shipTo.identifiers[].scheme` | | | | | | | | `lines[].extended.shipTo.vatId` | | | | | | | | `lines[].extended.shipTo.contact` | | | | | | | | `lines[].extended.shipTo.contact.name` | BT-41 | 0..1 | EXTENDED | `ram:PersonName` | `cbc:Name` | | | `lines[].extended.shipTo.contact.phone` | BT-42 | 0..1 | EXTENDED | `ram:TelephoneUniversalCommunication/ram:CompleteNumber` | `cbc:Telephone` | | | `lines[].extended.shipTo.contact.email` | BT-43 | 0..1 | EXTENDED | `ram:EmailURIUniversalCommunication/ram:URIID` | `cbc:ElectronicMail` | | | `lines[].extended.deliveryDate` | | | | | | EXTENDED only | | `lines[].extended.includedProducts[]` | | | | | | EXTENDED only | | `lines[].extended.includedProducts[].name` | | | | | | | | `lines[].extended.includedProducts[].quantity` | | | | | | | | `lines[].extended.includedProducts[].unit` | | | | | | | | `lines[].extended.includedProducts[].description` | | | | | | | | `lines[].extended.includedProducts[].sellerId` | | | | | | | | `lines[].presentation` | | | | | | PDF only | | `lines[].presentation.groupId` | | | | | | | | `lines[].presentation.highlight` | | | | | | | | `lines[].presentation.showGrossPrice` | | | | | | | | `taxCurrency` | BT-6 | 0..1 | BASIC WL | `ram:ApplicableHeaderTradeSettlement/ram:TaxCurrencyCode` | `cbc:TaxCurrencyCode` | | | `taxPointDate` | BT-7 | 0..1 | BASIC WL | `ram:ApplicableTradeTax/ram:TaxPointDate` | `cbc:TaxPointDate` | | | `taxPointDateCode` | BT-8 | 0..1 | BASIC WL | `ram:ApplicableTradeTax/ram:DueDateTypeCode` | `cac:InvoicePeriod/cbc:DescriptionCode` | | | `dueDate` | BT-9 | 0..1 | BASIC WL | `ram:SpecifiedTradePaymentTerms/ram:DueDateDateTime` | `cbc:DueDate (CreditNote: cac:PaymentMeans/cbc:PaymentDueDate)` | | | `buyerReference` | BT-10 | 0..1 | MINIMUM | `ram:ApplicableHeaderTradeAgreement/ram:BuyerReference` | `cbc:BuyerReference` | required in xrechnung | | `projectReference` | BT-11 | 0..1 | EN 16931 | `ram:ApplicableHeaderTradeAgreement/ram:SpecifiedProcuringProject` | `cac:ProjectReference/cbc:ID` | | | `projectReference.id` | | | | | | | | `projectReference.name` | | | | | | | | `contractReference` | BT-12 | 0..1 | BASIC WL | `ram:ContractReferencedDocument/ram:IssuerAssignedID` | `cac:ContractDocumentReference/cbc:ID` | | | `purchaseOrderReference` | BT-13 | 0..1 | MINIMUM | `ram:BuyerOrderReferencedDocument/ram:IssuerAssignedID` | `cac:OrderReference/cbc:ID` | | | `salesOrderReference` | BT-14 | 0..1 | EN 16931 | `ram:SellerOrderReferencedDocument/ram:IssuerAssignedID` | `cac:OrderReference/cbc:SalesOrderID` | | | `receivingAdviceReference` | BT-15 | 0..1 | EN 16931 | `ram:ReceivingAdviceReferencedDocument/ram:IssuerAssignedID` | `cac:ReceiptDocumentReference/cbc:ID` | | | `despatchAdviceReference` | BT-16 | 0..1 | BASIC WL | `ram:DespatchAdviceReferencedDocument/ram:IssuerAssignedID` | `cac:DespatchDocumentReference/cbc:ID` | | | `tenderReference` | BT-17 | 0..1 | EN 16931 | `ram:AdditionalReferencedDocument[ram:TypeCode="50"]/ram:IssuerAssignedID` | `cac:OriginatorDocumentReference/cbc:ID` | | | `invoicedObject` | BT-18 | 0..1 | EN 16931 | `ram:AdditionalReferencedDocument[ram:TypeCode="130"]/ram:IssuerAssignedID` | `cac:AdditionalDocumentReference[cbc:DocumentTypeCode="130"]/cbc:ID` | | | `invoicedObject.value` | | | | | | | | `invoicedObject.scheme` | | | | | | | | `buyerAccountingReference` | BT-19 | 0..1 | BASIC WL | `ram:ReceivableSpecifiedTradeAccountingAccount/ram:ID` | `cbc:AccountingCost` | | | `paymentTerms` | BT-20 | 0..1 | BASIC WL | `ram:SpecifiedTradePaymentTerms` | `cac:PaymentTerms` | | | `paymentTerms.text` | BT-20 | 0..1 | BASIC WL | `ram:SpecifiedTradePaymentTerms/ram:Description` | `cac:PaymentTerms/cbc:Note` | | | `paymentTerms.dueDays` | | | | | | internal | | `paymentTerms.discounts[]` | | | | | | internal | | `paymentTerms.discounts[].days` | | | | | | | | `paymentTerms.discounts[].percent` | | | | | | | | `paymentTerms.discounts[].baseAmount` | | | | | | | | `paymentTerms.lateFeeTerms` | | | | | | internal | | `paymentTerms.lateFeeTerms.days` | | | | | | | | `paymentTerms.lateFeeTerms.percent` | | | | | | | | `paymentTerms.lateFeeTerms.text` | | | | | | | | `notes[]` | BG-1 | 0..n | BASIC WL | `rsm:ExchangedDocument/ram:IncludedNote` | `cbc:Note` | | | `notes[].content` | BT-22 | 1 | BASIC WL | `ram:IncludedNote/ram:Content` | `cbc:Note` | | | `notes[].subjectCode` | BT-21 | 0..1 | BASIC WL | `ram:IncludedNote/ram:SubjectCode` | `cbc:Note (prefix #CODE#)` | | | `businessProcess` | BT-23 | 0..1 | MINIMUM | `ram:BusinessProcessSpecifiedDocumentContextParameter/ram:ID` | `cbc:ProfileID` | | | `precedingInvoices[]` | BG-3 | 0..n | BASIC WL | `ram:InvoiceReferencedDocument` | `cac:BillingReference` | | | `precedingInvoices[].number` | BT-25 | 1 | BASIC WL | `ram:InvoiceReferencedDocument/ram:IssuerAssignedID` | `cac:BillingReference/cac:InvoiceDocumentReference/cbc:ID` | | | `precedingInvoices[].issueDate` | BT-26 | 0..1 | BASIC WL | `ram:InvoiceReferencedDocument/ram:FormattedIssueDateTime` | `cac:BillingReference/cac:InvoiceDocumentReference/cbc:IssueDate` | | | `payee` | BG-10 | 0..1 | BASIC WL | `ram:PayeeTradeParty` | `cac:PayeeParty` | | | `payee.name` | BT-59 | 1 | BASIC WL | `ram:PayeeTradeParty/ram:Name` | `cac:PayeeParty/cac:PartyName/cbc:Name` | | | `payee.identifier` | BT-60 | 0..1 | BASIC WL | `ram:PayeeTradeParty/ram:ID \| ram:GlobalID` | `cac:PayeeParty/cac:PartyIdentification/cbc:ID` | | | `payee.identifier.value` | | | | | | | | `payee.identifier.scheme` | | | | | | | | `payee.legalRegistration` | BT-61 | 0..1 | BASIC WL | `ram:PayeeTradeParty/ram:SpecifiedLegalOrganization/ram:ID` | `cac:PayeeParty/cac:PartyLegalEntity/cbc:CompanyID` | | | `payee.legalRegistration.value` | | | | | | | | `payee.legalRegistration.scheme` | | | | | | | | `sellerTaxRepresentative` | BG-11 | 0..1 | BASIC WL | `ram:SellerTaxRepresentativeTradeParty` | `cac:TaxRepresentativeParty` | | | `sellerTaxRepresentative.name` | BT-62 | 1 | BASIC WL | `ram:SellerTaxRepresentativeTradeParty/ram:Name` | `cac:TaxRepresentativeParty/cac:PartyName/cbc:Name` | | | `sellerTaxRepresentative.vatId` | BT-63 | 1 | BASIC WL | `ram:SpecifiedTaxRegistration/ram:ID[@schemeID="VA"]` | `cac:PartyTaxScheme/cbc:CompanyID` | | | `sellerTaxRepresentative.address` | BG-12 | 1 | BASIC WL | `ram:PostalTradeAddress` | `cac:PostalAddress` | | | `sellerTaxRepresentative.address.countryCode` | BT-69 | 1 | BASIC WL | `ram:CountryID` | `cac:Country/cbc:IdentificationCode` | | | `sellerTaxRepresentative.address.line1` | BT-64 | 0..1 | BASIC WL | `ram:LineOne` | `cbc:StreetName` | | | `sellerTaxRepresentative.address.line2` | BT-65 | 0..1 | BASIC WL | `ram:LineTwo` | `cbc:AdditionalStreetName` | | | `sellerTaxRepresentative.address.line3` | BT-164 | 0..1 | BASIC WL | `ram:LineThree` | `cac:AddressLine/cbc:Line` | | | `sellerTaxRepresentative.address.city` | BT-66 | 0..1 | BASIC WL | `ram:CityName` | `cbc:CityName` | | | `sellerTaxRepresentative.address.postcode` | BT-67 | 0..1 | BASIC WL | `ram:PostcodeCode` | `cbc:PostalZone` | | | `sellerTaxRepresentative.address.subdivision` | BT-68 | 0..1 | BASIC WL | `ram:CountrySubDivisionName` | `cbc:CountrySubentity` | | | `delivery` | BG-13 | 0..1 | BASIC WL | `ram:ApplicableHeaderTradeDelivery` | `cac:Delivery` | | | `delivery.recipientName` | BT-70 | 0..1 | BASIC WL | `ram:ShipToTradeParty/ram:Name` | `cac:Delivery/cac:DeliveryParty/cac:PartyName/cbc:Name` | | | `delivery.locationId` | BT-71 | 0..1 | BASIC WL | `ram:ShipToTradeParty/ram:ID \| ram:GlobalID` | `cac:Delivery/cac:DeliveryLocation/cbc:ID` | | | `delivery.locationId.value` | | | | | | | | `delivery.locationId.scheme` | | | | | | | | `delivery.actualDeliveryDate` | BT-72 | 0..1 | BASIC WL | `ram:ActualDeliverySupplyChainEvent/ram:OccurrenceDateTime` | `cac:Delivery/cbc:ActualDeliveryDate` | | | `delivery.address` | BG-15 | 0..1 | BASIC WL | `ram:ShipToTradeParty/ram:PostalTradeAddress` | `cac:Delivery/cac:DeliveryLocation/cac:Address` | | | `delivery.address.countryCode` | BT-80 | 1 | BASIC WL | `ram:CountryID` | `cac:Country/cbc:IdentificationCode` | | | `delivery.address.line1` | BT-75 | 0..1 | BASIC WL | `ram:LineOne` | `cbc:StreetName` | | | `delivery.address.line2` | BT-76 | 0..1 | BASIC WL | `ram:LineTwo` | `cbc:AdditionalStreetName` | | | `delivery.address.line3` | BT-165 | 0..1 | BASIC WL | `ram:LineThree` | `cac:AddressLine/cbc:Line` | | | `delivery.address.city` | BT-77 | 0..1 | BASIC WL | `ram:CityName` | `cbc:CityName` | | | `delivery.address.postcode` | BT-78 | 0..1 | BASIC WL | `ram:PostcodeCode` | `cbc:PostalZone` | | | `delivery.address.subdivision` | BT-79 | 0..1 | BASIC WL | `ram:CountrySubDivisionName` | `cbc:CountrySubentity` | | | `invoicingPeriod` | BG-14 | 0..1 | BASIC WL | `ram:BillingSpecifiedPeriod` | `cac:InvoicePeriod` | | | `invoicingPeriod.start` | BT-73 | | | | | | | `invoicingPeriod.end` | BT-74 | | | | | | | `paymentInstructions` | BG-16 | 0..1 | BASIC WL | `ram:SpecifiedTradeSettlementPaymentMeans` | `cac:PaymentMeans` | required in xrechnung | | `paymentInstructions.meansCode` | BT-81 | 1 | BASIC WL | `ram:SpecifiedTradeSettlementPaymentMeans/ram:TypeCode` | `cac:PaymentMeans/cbc:PaymentMeansCode` | | | `paymentInstructions.meansText` | BT-82 | 0..1 | EN 16931 | `ram:SpecifiedTradeSettlementPaymentMeans/ram:Information` | `cac:PaymentMeans/cbc:PaymentMeansCode/@name` | | | `paymentInstructions.remittanceInformation` | BT-83 | 0..1 | BASIC WL | `ram:PaymentReference` | `cac:PaymentMeans/cbc:PaymentID` | | | `paymentInstructions.creditTransfers[]` | BG-17 | 0..n | BASIC WL | `ram:SpecifiedTradeSettlementPaymentMeans` | `cac:PaymentMeans` | | | `paymentInstructions.creditTransfers[].accountId` | BT-84 | 1 | BASIC WL | `ram:PayeePartyCreditorFinancialAccount/ram:IBANID \| ram:ProprietaryID` | `cac:PayeeFinancialAccount/cbc:ID` | | | `paymentInstructions.creditTransfers[].accountName` | BT-85 | 0..1 | EN 16931 | `ram:PayeePartyCreditorFinancialAccount/ram:AccountName` | `cac:PayeeFinancialAccount/cbc:Name` | | | `paymentInstructions.creditTransfers[].serviceProviderId` | BT-86 | 0..1 | EN 16931 | `ram:PayeeSpecifiedCreditorFinancialInstitution/ram:BICID` | `cac:PayeeFinancialAccount/cac:FinancialInstitutionBranch/cbc:ID` | | | `paymentInstructions.card` | BG-18 | 0..1 | EN 16931 | `ram:SpecifiedTradeSettlementPaymentMeans/ram:ApplicableTradeSettlementFinancialCard` | `cac:PaymentMeans/cac:CardAccount` | | | `paymentInstructions.card.primaryAccountNumber` | BT-87 | 1 | EN 16931 | `ram:ApplicableTradeSettlementFinancialCard/ram:ID` | `cac:CardAccount/cbc:PrimaryAccountNumberID` | | | `paymentInstructions.card.holderName` | BT-88 | 0..1 | EN 16931 | `ram:ApplicableTradeSettlementFinancialCard/ram:CardholderName` | `cac:CardAccount/cbc:HolderName` | | | `paymentInstructions.directDebit` | BG-19 | 0..1 | BASIC WL | `ram:SpecifiedTradeSettlementPaymentMeans/ram:PayerPartyDebtorFinancialAccount` | `cac:PaymentMeans/cac:PaymentMandate` | | | `paymentInstructions.directDebit.mandateReference` | BT-89 | 0..1 | BASIC WL | `ram:SpecifiedTradePaymentTerms/ram:DirectDebitMandateID` | `cac:PaymentMandate/cbc:ID` | | | `paymentInstructions.directDebit.creditorId` | BT-90 | 0..1 | BASIC WL | `ram:CreditorReferenceID` | `cac:AccountingSupplierParty/cac:Party/cac:PartyIdentification/cbc:ID[@schemeID="SEPA"]` | | | `paymentInstructions.directDebit.debitedAccountId` | BT-91 | 0..1 | BASIC WL | `ram:PayerPartyDebtorFinancialAccount/ram:IBANID` | `cac:PaymentMandate/cac:PayerFinancialAccount/cbc:ID` | | | `allowances[]` | BG-20 | 0..n | BASIC WL | `ram:SpecifiedTradeAllowanceCharge[ram:ChargeIndicator/udt:Indicator="false"]` | `cac:AllowanceCharge[cbc:ChargeIndicator="false"]` | | | `allowances[].amount` | BT-92 | 1 | BASIC WL | `ram:SpecifiedTradeAllowanceCharge/ram:ActualAmount` | `cac:AllowanceCharge/cbc:Amount` | | | `allowances[].vatCategory` | BT-95 | 1 | BASIC WL | `ram:CategoryTradeTax/ram:CategoryCode` | `cac:TaxCategory/cbc:ID` | | | `allowances[].vatRate` | BT-96 | 0..1 | BASIC WL | `ram:CategoryTradeTax/ram:RateApplicablePercent` | `cac:TaxCategory/cbc:Percent` | | | `allowances[].baseAmount` | BT-93 | 0..1 | BASIC WL | `ram:BasisAmount` | `cbc:BaseAmount` | | | `allowances[].percent` | BT-94 | 0..1 | BASIC WL | `ram:CalculationPercent` | `cbc:MultiplierFactorNumeric` | | | `allowances[].reason` | BT-97 | 0..1 | BASIC WL | `ram:Reason` | `cbc:AllowanceChargeReason` | | | `allowances[].reasonCode` | BT-98 | 0..1 | BASIC WL | `ram:ReasonCode` | `cbc:AllowanceChargeReasonCode` | | | `allowances[].exemptionReason` | | | | | | internal | | `allowances[].exemptionReasonCode` | | | | | | internal | | `charges[]` | BG-21 | 0..n | BASIC WL | `ram:SpecifiedTradeAllowanceCharge[ram:ChargeIndicator/udt:Indicator="true"]` | `cac:AllowanceCharge[cbc:ChargeIndicator="true"]` | | | `charges[].amount` | BT-99 | 1 | BASIC WL | `ram:SpecifiedTradeAllowanceCharge/ram:ActualAmount` | `cac:AllowanceCharge/cbc:Amount` | | | `charges[].vatCategory` | BT-102 | 1 | BASIC WL | `ram:CategoryTradeTax/ram:CategoryCode` | `cac:TaxCategory/cbc:ID` | | | `charges[].vatRate` | BT-103 | 0..1 | BASIC WL | `ram:CategoryTradeTax/ram:RateApplicablePercent` | `cac:TaxCategory/cbc:Percent` | | | `charges[].baseAmount` | BT-100 | 0..1 | BASIC WL | `ram:BasisAmount` | `cbc:BaseAmount` | | | `charges[].percent` | BT-101 | 0..1 | BASIC WL | `ram:CalculationPercent` | `cbc:MultiplierFactorNumeric` | | | `charges[].reason` | BT-104 | 0..1 | BASIC WL | `ram:Reason` | `cbc:AllowanceChargeReason` | | | `charges[].reasonCode` | BT-105 | 0..1 | BASIC WL | `ram:ReasonCode` | `cbc:AllowanceChargeReasonCode` | | | `charges[].exemptionReason` | | | | | | internal | | `charges[].exemptionReasonCode` | | | | | | internal | | `totals` | BG-22 | 1 | MINIMUM | `ram:SpecifiedTradeSettlementHeaderMonetarySummation` | `cac:LegalMonetaryTotal` | calculated | | `totals.lineNetSum` | BT-106 | 1 | BASIC WL | `ram:LineTotalAmount` | `cac:LegalMonetaryTotal/cbc:LineExtensionAmount` | calculated | | `totals.netTotal` | BT-109 | 1 | MINIMUM | `ram:TaxBasisTotalAmount` | `cac:LegalMonetaryTotal/cbc:TaxExclusiveAmount` | calculated | | `totals.grossTotal` | BT-112 | 1 | MINIMUM | `ram:GrandTotalAmount` | `cac:LegalMonetaryTotal/cbc:TaxInclusiveAmount` | calculated | | `totals.amountDue` | BT-115 | 1 | MINIMUM | `ram:DuePayableAmount` | `cac:LegalMonetaryTotal/cbc:PayableAmount` | calculated | | `totals.allowanceSum` | BT-107 | 0..1 | BASIC WL | `ram:AllowanceTotalAmount` | `cac:LegalMonetaryTotal/cbc:AllowanceTotalAmount` | calculated | | `totals.chargeSum` | BT-108 | 0..1 | BASIC WL | `ram:ChargeTotalAmount` | `cac:LegalMonetaryTotal/cbc:ChargeTotalAmount` | calculated | | `totals.vatTotal` | BT-110 | 0..1 | MINIMUM | `ram:TaxTotalAmount (currencyID = BT-5)` | `cac:TaxTotal/cbc:TaxAmount` | calculated | | `totals.vatTotalInTaxCurrency` | BT-111 | 0..1 | BASIC WL | `ram:TaxTotalAmount (currencyID = BT-6)` | `cac:TaxTotal/cbc:TaxAmount` | calculated | | `totals.prepaidAmount` | BT-113 | 0..1 | BASIC WL | `ram:TotalPrepaidAmount` | `cac:LegalMonetaryTotal/cbc:PrepaidAmount` | | | `totals.roundingAmount` | BT-114 | 0..1 | BASIC WL | `ram:RoundingAmount` | `cac:LegalMonetaryTotal/cbc:PayableRoundingAmount` | | | `vatBreakdown[]` | BG-23 | 1..n | BASIC WL | `ram:ApplicableTradeTax` | `cac:TaxTotal/cac:TaxSubtotal` | calculated | | `vatBreakdown[].taxableAmount` | BT-116 | 1 | BASIC WL | `ram:ApplicableTradeTax/ram:BasisAmount` | `cac:TaxSubtotal/cbc:TaxableAmount` | calculated | | `vatBreakdown[].taxAmount` | BT-117 | 1 | BASIC WL | `ram:ApplicableTradeTax/ram:CalculatedAmount` | `cac:TaxSubtotal/cbc:TaxAmount` | calculated | | `vatBreakdown[].category` | BT-118 | 1 | BASIC WL | `ram:ApplicableTradeTax/ram:CategoryCode` | `cac:TaxSubtotal/cac:TaxCategory/cbc:ID` | calculated | | `vatBreakdown[].rate` | BT-119 | 0..1 | BASIC WL | `ram:ApplicableTradeTax/ram:RateApplicablePercent` | `cac:TaxSubtotal/cac:TaxCategory/cbc:Percent` | calculated | | `vatBreakdown[].exemptionReason` | BT-120 | 0..1 | BASIC WL | `ram:ApplicableTradeTax/ram:ExemptionReason` | `cac:TaxSubtotal/cac:TaxCategory/cbc:TaxExemptionReason` | | | `vatBreakdown[].exemptionReasonCode` | BT-121 | 0..1 | BASIC WL | `ram:ApplicableTradeTax/ram:ExemptionReasonCode` | `cac:TaxSubtotal/cac:TaxCategory/cbc:TaxExemptionReasonCode` | | | `attachments[]` | BG-24 | 0..n | EN 16931 | `ram:AdditionalReferencedDocument[ram:TypeCode="916"]` | `cac:AdditionalDocumentReference` | | | `attachments[].id` | BT-122 | 1 | EN 16931 | `ram:AdditionalReferencedDocument/ram:IssuerAssignedID` | `cac:AdditionalDocumentReference/cbc:ID` | | | `attachments[].description` | BT-123 | 0..1 | EN 16931 | `ram:AdditionalReferencedDocument/ram:Name` | `cac:AdditionalDocumentReference/cbc:DocumentDescription` | | | `attachments[].externalUri` | BT-124 | 0..1 | EN 16931 | `ram:AdditionalReferencedDocument/ram:URIID` | `cac:AdditionalDocumentReference/cac:Attachment/cac:ExternalReference/cbc:URI` | | | `attachments[].content` | BT-125 | 0..1 | EN 16931 | `ram:AdditionalReferencedDocument/ram:AttachmentBinaryObject` | `cac:AdditionalDocumentReference/cac:Attachment/cbc:EmbeddedDocumentBinaryObject` | | | `attachments[].mimeType` | BT-125-1 | 0..1 | EN 16931 | `ram:AttachmentBinaryObject/@mimeCode` | `cbc:EmbeddedDocumentBinaryObject/@mimeCode` | | | `attachments[].filename` | BT-125-2 | 0..1 | EN 16931 | `ram:AttachmentBinaryObject/@filename` | `cbc:EmbeddedDocumentBinaryObject/@filename` | | | `prepaidAmount` | | | | | | | | `roundingAmount` | | | | | | | | `extended` | | | | | | EXTENDED only | | `extended.invoicer` | | | | | | EXTENDED only | | `extended.invoicer.name` | | | | | | | | `extended.invoicer.address` | | | | | | | | `extended.invoicer.address.countryCode` | BT-40 | 1 | EXTENDED | `ram:CountryID` | `cac:Country/cbc:IdentificationCode` | | | `extended.invoicer.address.line1` | BT-35 | 0..1 | EXTENDED | `ram:LineOne` | `cbc:StreetName` | | | `extended.invoicer.address.line2` | BT-36 | 0..1 | EXTENDED | `ram:LineTwo` | `cbc:AdditionalStreetName` | | | `extended.invoicer.address.line3` | BT-162 | 0..1 | EXTENDED | `ram:LineThree` | `cac:AddressLine/cbc:Line` | | | `extended.invoicer.address.city` | BT-37 | 0..1 | EXTENDED | `ram:CityName` | `cbc:CityName` | | | `extended.invoicer.address.postcode` | BT-38 | 0..1 | EXTENDED | `ram:PostcodeCode` | `cbc:PostalZone` | | | `extended.invoicer.address.subdivision` | BT-39 | 0..1 | EXTENDED | `ram:CountrySubDivisionName` | `cbc:CountrySubentity` | | | `extended.invoicer.identifiers[]` | | | | | | | | `extended.invoicer.identifiers[].value` | | | | | | | | `extended.invoicer.identifiers[].scheme` | | | | | | | | `extended.invoicer.vatId` | | | | | | | | `extended.invoicer.contact` | | | | | | | | `extended.invoicer.contact.name` | BT-41 | 0..1 | EXTENDED | `ram:PersonName` | `cbc:Name` | | | `extended.invoicer.contact.phone` | BT-42 | 0..1 | EXTENDED | `ram:TelephoneUniversalCommunication/ram:CompleteNumber` | `cbc:Telephone` | | | `extended.invoicer.contact.email` | BT-43 | 0..1 | EXTENDED | `ram:EmailURIUniversalCommunication/ram:URIID` | `cbc:ElectronicMail` | | | `extended.invoicee` | | | | | | EXTENDED only | | `extended.invoicee.name` | | | | | | | | `extended.invoicee.address` | | | | | | | | `extended.invoicee.address.countryCode` | BT-40 | 1 | EXTENDED | `ram:CountryID` | `cac:Country/cbc:IdentificationCode` | | | `extended.invoicee.address.line1` | BT-35 | 0..1 | EXTENDED | `ram:LineOne` | `cbc:StreetName` | | | `extended.invoicee.address.line2` | BT-36 | 0..1 | EXTENDED | `ram:LineTwo` | `cbc:AdditionalStreetName` | | | `extended.invoicee.address.line3` | BT-162 | 0..1 | EXTENDED | `ram:LineThree` | `cac:AddressLine/cbc:Line` | | | `extended.invoicee.address.city` | BT-37 | 0..1 | EXTENDED | `ram:CityName` | `cbc:CityName` | | | `extended.invoicee.address.postcode` | BT-38 | 0..1 | EXTENDED | `ram:PostcodeCode` | `cbc:PostalZone` | | | `extended.invoicee.address.subdivision` | BT-39 | 0..1 | EXTENDED | `ram:CountrySubDivisionName` | `cbc:CountrySubentity` | | | `extended.invoicee.identifiers[]` | | | | | | | | `extended.invoicee.identifiers[].value` | | | | | | | | `extended.invoicee.identifiers[].scheme` | | | | | | | | `extended.invoicee.vatId` | | | | | | | | `extended.invoicee.contact` | | | | | | | | `extended.invoicee.contact.name` | BT-41 | 0..1 | EXTENDED | `ram:PersonName` | `cbc:Name` | | | `extended.invoicee.contact.phone` | BT-42 | 0..1 | EXTENDED | `ram:TelephoneUniversalCommunication/ram:CompleteNumber` | `cbc:Telephone` | | | `extended.invoicee.contact.email` | BT-43 | 0..1 | EXTENDED | `ram:EmailURIUniversalCommunication/ram:URIID` | `cbc:ElectronicMail` | | | `extended.ultimateCustomer` | | | | | | EXTENDED only | | `extended.ultimateCustomer.name` | | | | | | | | `extended.ultimateCustomer.address` | | | | | | | | `extended.ultimateCustomer.address.countryCode` | BT-40 | 1 | EXTENDED | `ram:CountryID` | `cac:Country/cbc:IdentificationCode` | | | `extended.ultimateCustomer.address.line1` | BT-35 | 0..1 | EXTENDED | `ram:LineOne` | `cbc:StreetName` | | | `extended.ultimateCustomer.address.line2` | BT-36 | 0..1 | EXTENDED | `ram:LineTwo` | `cbc:AdditionalStreetName` | | | `extended.ultimateCustomer.address.line3` | BT-162 | 0..1 | EXTENDED | `ram:LineThree` | `cac:AddressLine/cbc:Line` | | | `extended.ultimateCustomer.address.city` | BT-37 | 0..1 | EXTENDED | `ram:CityName` | `cbc:CityName` | | | `extended.ultimateCustomer.address.postcode` | BT-38 | 0..1 | EXTENDED | `ram:PostcodeCode` | `cbc:PostalZone` | | | `extended.ultimateCustomer.address.subdivision` | BT-39 | 0..1 | EXTENDED | `ram:CountrySubDivisionName` | `cbc:CountrySubentity` | | | `extended.ultimateCustomer.identifiers[]` | | | | | | | | `extended.ultimateCustomer.identifiers[].value` | | | | | | | | `extended.ultimateCustomer.identifiers[].scheme` | | | | | | | | `extended.ultimateCustomer.vatId` | | | | | | | | `extended.ultimateCustomer.contact` | | | | | | | | `extended.ultimateCustomer.contact.name` | BT-41 | 0..1 | EXTENDED | `ram:PersonName` | `cbc:Name` | | | `extended.ultimateCustomer.contact.phone` | BT-42 | 0..1 | EXTENDED | `ram:TelephoneUniversalCommunication/ram:CompleteNumber` | `cbc:Telephone` | | | `extended.ultimateCustomer.contact.email` | BT-43 | 0..1 | EXTENDED | `ram:EmailURIUniversalCommunication/ram:URIID` | `cbc:ElectronicMail` | | | `extended.shipFrom` | | | | | | EXTENDED only | | `extended.shipFrom.name` | | | | | | | | `extended.shipFrom.address` | | | | | | | | `extended.shipFrom.address.countryCode` | BT-40 | 1 | EXTENDED | `ram:CountryID` | `cac:Country/cbc:IdentificationCode` | | | `extended.shipFrom.address.line1` | BT-35 | 0..1 | EXTENDED | `ram:LineOne` | `cbc:StreetName` | | | `extended.shipFrom.address.line2` | BT-36 | 0..1 | EXTENDED | `ram:LineTwo` | `cbc:AdditionalStreetName` | | | `extended.shipFrom.address.line3` | BT-162 | 0..1 | EXTENDED | `ram:LineThree` | `cac:AddressLine/cbc:Line` | | | `extended.shipFrom.address.city` | BT-37 | 0..1 | EXTENDED | `ram:CityName` | `cbc:CityName` | | | `extended.shipFrom.address.postcode` | BT-38 | 0..1 | EXTENDED | `ram:PostcodeCode` | `cbc:PostalZone` | | | `extended.shipFrom.address.subdivision` | BT-39 | 0..1 | EXTENDED | `ram:CountrySubDivisionName` | `cbc:CountrySubentity` | | | `extended.shipFrom.identifiers[]` | | | | | | | | `extended.shipFrom.identifiers[].value` | | | | | | | | `extended.shipFrom.identifiers[].scheme` | | | | | | | | `extended.shipFrom.vatId` | | | | | | | | `extended.shipFrom.contact` | | | | | | | | `extended.shipFrom.contact.name` | BT-41 | 0..1 | EXTENDED | `ram:PersonName` | `cbc:Name` | | | `extended.shipFrom.contact.phone` | BT-42 | 0..1 | EXTENDED | `ram:TelephoneUniversalCommunication/ram:CompleteNumber` | `cbc:Telephone` | | | `extended.shipFrom.contact.email` | BT-43 | 0..1 | EXTENDED | `ram:EmailURIUniversalCommunication/ram:URIID` | `cbc:ElectronicMail` | | | `extended.deliveryTermsCode` | | | | | | EXTENDED only | | `extended.additionalReferences[]` | | | | | | EXTENDED only | | `extended.additionalReferences[].id` | | | | | | | | `extended.additionalReferences[].kind` | | | | | | | | `extended.additionalReferences[].lineId` | | | | | | | | `extended.additionalReferences[].issueDate` | | | | | | | | `extended.additionalReferences[].typeCode` | | | | | | | | `extended.additionalReferences[].description` | | | | | | | | `extended.installments[]` | | | | | | EXTENDED only | | `extended.installments[].dueDate` | | | | | | | | `extended.installments[].amount` | | | | | | | | `extended.installments[].description` | | | | | | | | `extended.additionalPaymentInstructions[]` | | | | | | EXTENDED only | | `extended.additionalPaymentInstructions[].meansCode` | BT-81 | 1 | EXTENDED | `ram:SpecifiedTradeSettlementPaymentMeans/ram:TypeCode` | `cac:PaymentMeans/cbc:PaymentMeansCode` | | | `extended.additionalPaymentInstructions[].meansText` | BT-82 | 0..1 | EXTENDED | `ram:SpecifiedTradeSettlementPaymentMeans/ram:Information` | `cac:PaymentMeans/cbc:PaymentMeansCode/@name` | | | `extended.additionalPaymentInstructions[].remittanceInformation` | BT-83 | 0..1 | EXTENDED | `ram:PaymentReference` | `cac:PaymentMeans/cbc:PaymentID` | | | `extended.additionalPaymentInstructions[].creditTransfers[]` | BG-17 | 0..n | EXTENDED | `ram:SpecifiedTradeSettlementPaymentMeans` | `cac:PaymentMeans` | | | `extended.additionalPaymentInstructions[].creditTransfers[].accountId` | BT-84 | 1 | EXTENDED | `ram:PayeePartyCreditorFinancialAccount/ram:IBANID \| ram:ProprietaryID` | `cac:PayeeFinancialAccount/cbc:ID` | | | `extended.additionalPaymentInstructions[].creditTransfers[].accountName` | BT-85 | 0..1 | EXTENDED | `ram:PayeePartyCreditorFinancialAccount/ram:AccountName` | `cac:PayeeFinancialAccount/cbc:Name` | | | `extended.additionalPaymentInstructions[].creditTransfers[].serviceProviderId` | BT-86 | 0..1 | EXTENDED | `ram:PayeeSpecifiedCreditorFinancialInstitution/ram:BICID` | `cac:PayeeFinancialAccount/cac:FinancialInstitutionBranch/cbc:ID` | | | `extended.additionalPaymentInstructions[].card` | BG-18 | 0..1 | EXTENDED | `ram:SpecifiedTradeSettlementPaymentMeans/ram:ApplicableTradeSettlementFinancialCard` | `cac:PaymentMeans/cac:CardAccount` | | | `extended.additionalPaymentInstructions[].card.primaryAccountNumber` | BT-87 | 1 | EXTENDED | `ram:ApplicableTradeSettlementFinancialCard/ram:ID` | `cac:CardAccount/cbc:PrimaryAccountNumberID` | | | `extended.additionalPaymentInstructions[].card.holderName` | BT-88 | 0..1 | EXTENDED | `ram:ApplicableTradeSettlementFinancialCard/ram:CardholderName` | `cac:CardAccount/cbc:HolderName` | | | `extended.additionalPaymentInstructions[].directDebit` | BG-19 | 0..1 | EXTENDED | `ram:SpecifiedTradeSettlementPaymentMeans/ram:PayerPartyDebtorFinancialAccount` | `cac:PaymentMeans/cac:PaymentMandate` | | | `extended.additionalPaymentInstructions[].directDebit.mandateReference` | BT-89 | 0..1 | EXTENDED | `ram:SpecifiedTradePaymentTerms/ram:DirectDebitMandateID` | `cac:PaymentMandate/cbc:ID` | | | `extended.additionalPaymentInstructions[].directDebit.creditorId` | BT-90 | 0..1 | EXTENDED | `ram:CreditorReferenceID` | `cac:AccountingSupplierParty/cac:Party/cac:PartyIdentification/cbc:ID[@schemeID="SEPA"]` | | | `extended.additionalPaymentInstructions[].directDebit.debitedAccountId` | BT-91 | 0..1 | EXTENDED | `ram:PayerPartyDebtorFinancialAccount/ram:IBANID` | `cac:PaymentMandate/cac:PayerFinancialAccount/cbc:ID` | | | `xrechnungExtension` | | | | | | XRechnung extension only | | `xrechnungExtension.thirdPartyPayments[]` | | | | | | XRechnung extension only | | `xrechnungExtension.thirdPartyPayments[].type` | | | | | | | | `xrechnungExtension.thirdPartyPayments[].amount` | | | | | | | | `xrechnungExtension.thirdPartyPayments[].description` | | | | | | | | `presentation` | | | | | | PDF only | | `presentation.template` | | | | | | PDF only | | `presentation.logo` | | | | | | PDF only | | `presentation.colors` | | | | | | PDF only | | `presentation.colors.primary` | | | | | | | | `presentation.colors.text` | | | | | | | | `presentation.colors.muted` | | | | | | | | `presentation.colors.secondary` | | | | | | | | `presentation.font` | | | | | | PDF only | | `presentation.senderLine` | | | | | | PDF only | | `presentation.letterLayout` | | | | | | PDF only | | `presentation.salutation` | | | | | | PDF only | | `presentation.introText` | | | | | | PDF only | | `presentation.closingText` | | | | | | PDF only | | `presentation.footerColumns[]` | | | | | | PDF only | | `presentation.lineGroups[]` | | | | | | PDF only | | `presentation.lineGroups[].id` | | | | | | | | `presentation.lineGroups[].title` | | | | | | | | `presentation.lineGroups[].showSubtotal` | | | | | | | | `presentation.showGrossPrices` | | | | | | PDF only | | `presentation.showItemNumbers` | | | | | | PDF only | | `presentation.paymentQr` | | | | | | PDF only | | `presentation.watermark` | | | | | | PDF only | | `presentation.paper` | | | | | | PDF only | | `presentation.labels[]` | | | | | | PDF only | | `presentation.title` | | | | | | PDF only | | `presentation.explicit[]` | | | | | | PDF only | | `meta` | | | | | | internal | | `meta.locale` | | | | | | internal | | `meta.timezone` | | | | | | internal | | `meta.exchangeRate` | | | | | | internal | | `meta.exchangeRateDate` | | | | | | internal | | `meta.custom[]` | | | | | | internal | | `meta.source` | | | | | | internal | | `meta.flags[]` | | | | | | internal | | `standardVersion` | | | | | | internal | <!-- Source: https://quittio.dev/docs/ai --> # AI assistants This page shows how coding assistants such as Claude Code, Cursor or GitHub Copilot can read this documentation, so that they write code for the current version of Quittio. There are three ways: plain Markdown files, an MCP server, and the guidelines and the skill that Quittio ships for [Laravel Boost](https://laravel.com/docs/boost). You can use any of them alone. ## Markdown and llms.txt Every page of this documentation is also available as plain Markdown: add `.md` to its address, e.g. [`https://quittio.dev/docs/getting-started.md`](https://quittio.dev/docs/getting-started.md). Two files list or contain all pages, in the [llms.txt](https://llmstxt.org) format for language models: | File | Content | |---|---| | [`/docs/llms.txt`](https://quittio.dev/docs/llms.txt) | Index of all pages with a short description | | [`/docs/llms-full.txt`](https://quittio.dev/docs/llms-full.txt) | All pages in one file | The files under `/docs` describe the latest release. The development version and older versions have their own files under their path, e.g. `/docs/next/llms.txt` and `/docs/0.6/llms.txt` (version switcher in the navigation). The preview of the unreleased [Managed layer](managed.md) is left out of the Markdown files, both lists and the MCP server below, so that assistants do not write code for a package that cannot be installed yet. ## MCP server `https://quittio.dev/docs/mcp` is a read-only [MCP](https://modelcontextprotocol.io) server for this documentation. MCP (Model Context Protocol) is a standard that lets an assistant call the tools of a server. The server uses the Streamable HTTP transport and needs no authentication. It answers with the documentation of the latest release, the version under `/docs`. | Tool | Arguments | Returns | |---|---|---| | `search_docs` | `query`, optional `limit` (1–20, default 5) | The best matching sections with page, anchor, URL and an excerpt | | `get_page` | `page` (name such as `getting-started`, a title or a URL), optional `section` (anchor or heading) | The page or section as Markdown; long pages without a section return their outline | | `list_pages` | – | All pages with name, title, URL and description | ### Connecting an assistant Claude Code: ```bash claude mcp add --transport http quittio-docs https://quittio.dev/docs/mcp ``` Cursor (`.cursor/mcp.json`): ```json { "mcpServers": { "quittio-docs": { "url": "https://quittio.dev/docs/mcp" } } } ``` VS Code with GitHub Copilot (`.vscode/mcp.json`): ```json { "servers": { "quittio-docs": { "type": "http", "url": "https://quittio.dev/docs/mcp" } } } ``` Claude Desktop and claude.ai: Settings → Connectors → Add custom connector, URL `https://quittio.dev/docs/mcp`. ## Laravel Boost [Laravel Boost](https://laravel.com/docs/boost) loads AI guidelines and skills from the packages of a Laravel application. Guidelines are short rules the assistant always receives; a skill holds longer instructions that are loaded when a task needs them. Quittio ships both, in `quittio/quittio` and in `quittio/laravel`: | Path in the package | Content | |---|---| | `resources/boost/guidelines/core.blade.php` | Short guidelines that are always loaded: what Quittio is, the main rules (builder, tax presets, strings for amounts), a rendering example | | `resources/boost/skills/quittio-development/SKILL.md` | The skill `quittio-development`, loaded when an assistant works with invoices: building, rendering, validating, cancelling, reading and testing | Boost only reads packages that the application requires directly in its `composer.json`. After installing or updating Quittio, run: ```bash php artisan boost:install ``` Both files point the assistant to this documentation and to the [MCP server](#mcp-server) for details.