Expand description
French e-invoicing (facture électronique) for Laravel Rust: Factur-X invoices, credit notes and received-invoice checks.
Issue Factur-X (ZUGFeRD-compatible) PDF/A-3 invoices that carry the EN 16931 XML
(profile EN 16931 only). French rules are checked before anything is issued: SIREN/SIRET, VAT
number, mandatory mentions, VAT franchise (art. 293 B), reverse charge. Also credit notes (avoirs),
deposit invoices (acomptes), discounts, gap-free numbering in your database, archive and mail of
the PDF, and inspection of invoices you receive. It talks to your plateforme agréée through the
AFNOR XP Z12-013 API (platform), and writes e-reporting files (ereporting) and
life-cycle statuses (status).
The pages of the package are in its docs/ folder, which laravel facturx:docs prints (index:
docs/llms.txt); laravel facturx:skill installs a skill for coding agents. Every task below is
a compiled program in examples/.
§Issue an invoice
Register FacturXServiceProvider in src/app.rs, describe the seller in .env (see
Configuration), then render the invoice from a handler:
use laravel::container::Inject;
use facturx_laravel_rust::{Address, Customer, Date, FacturX, Invoice, InvoicePdf, Line, Nature};
use rust_decimal::dec;
pub async fn show(facturx: Inject<FacturX>) -> laravel::Result<InvoicePdf> {
let customer = Customer::business(
"Globex SAS",
"222222226",
Address::new("5 avenue des Tilleuls", "75011", "Paris"),
);
let invoice = Invoice::new("F-2026-00042", Date::new(2026, 12, 2)?, customer)
.nature(Nature::Services) // mandatory: Goods, Services or Mixed
.line(Line::new("Accompagnement, décembre", dec!(1), dec!(1500), dec!(20)));
facturx.pdf(&invoice).await
}§Credit note (avoir)
Invoice::credit_note names the invoice it corrects and is owed to the customer.
§Deposit invoice (acompte) and final invoice
Invoice::deposit issues the acompte; Invoice::deducts_deposit takes it back on the final
invoice as a line of quantity −1, before VAT and per rate, so the final invoice states only the
VAT still owed.
§Discounts
Discount::percent and Discount::amount, on a Line or on the whole invoice.
§VAT cases
The franchise (FACTURX_VAT_FRANCHISE), VAT on debits (FACTURX_VAT_ON_DEBITS), and
Exemption::reverse_charge, Exemption::eu_reverse_charge,
Exemption::intra_community and Exemption::export for lines at 0 %.
§Subscriptions
Invoice::period states the period an invoice covers (BG-14) and Invoice::contract the
contract (BT-12). Invoice::payment takes Payment::direct_debit, a SEPA direct debit under
the customer’s mandate (with FACTURX_SEPA_CREDITOR_ID), or Payment::card_ending, a bank
card; a SEPA transfer to FACTURX_IBAN otherwise.
§Marketplaces and billing mandates
Payment::intermediary names the marketplace that collected the payment as payee (BG-10);
Invoice::issued_by states the third party that issues under a billing mandate;
Invoice::self_billed makes a self-billed invoice (types 389, 261, 500, « Autofacturation »).
§Plateforme agréée, e-reporting, statuses
platform::Platform sends invoices, statuses and reports, follows their acknowledgement,
collects what you receive and reads the e-invoicing directory (FACTURX_PLATFORM_*).
ereporting::TransactionsReport and ereporting::PaymentsReport write flux 10: B2C sales
per day, international invoices and their payments. status::Status writes the CDAR
statuses: 212 Encaissée, 210 Refusée and the optional ones.
§Number invoices without gaps
FacturX::next_number, with the database feature: F-2026-00042, in the transaction that saves
the invoice.
§Archive and mail
FacturX::archive files the PDF on a disk and FacturX::mail sends it (feature pdf).
§Validate a received invoice
FacturX::inspect reads a Factur-X or ZUGFeRD PDF, CII or UBL and checks it against the
EN 16931 rules of en16931 and, for a French seller or buyer, the French rules of french
(codes FR-*: identifiers, VAT numbers and rates, number format, decimals, dates, currency,
directory addresses, due date, franchise). Those are this crate’s own checks, not the full
“BR-FR” schematron of the French flow (FNFE-MPE, XP Z12-012).
With the feature official-rules, OfficialRules::inspect runs that schematron too, in its
version 1.4.0.04 (pure Rust, no Java), when a received invoice must meet every rule of the
French flow; laravel facturx:rules downloads it once from its publisher.
§Configuration
The seller and the defaults come from .env. Required to issue an invoice:
FACTURX_SELLER_NAME, FACTURX_SELLER_SIREN, FACTURX_SELLER_STREET,
FACTURX_SELLER_POST_CODE, FACTURX_SELLER_CITY, and FACTURX_SELLER_VAT_NUMBER on an
invoice that charges VAT; Error::SellerNotConfigured names what is missing.
Optional: FACTURX_SELLER_SIRET, FACTURX_SELLER_LEGAL_FORM, FACTURX_SELLER_REGISTRATION,
FACTURX_SELLER_ELECTRONIC_ADDRESS, FACTURX_SELLER_EMAIL, FACTURX_SELLER_PHONE,
FACTURX_SELLER_COUNTRY, FACTURX_IBAN, FACTURX_BIC, FACTURX_SEPA_CREDITOR_ID,
FACTURX_PAYMENT_DAYS,
FACTURX_VAT_FRANCHISE, FACTURX_VAT_FRANCHISE_MENTION, FACTURX_VAT_ON_DEBITS,
FACTURX_LATE_PENALTIES, FACTURX_EARLY_PAYMENT_DISCOUNT, FACTURX_TEMPLATE,
FACTURX_PREFIX, FACTURX_CREDIT_NOTE_PREFIX, FACTURX_DEPOSIT_PREFIX, FACTURX_DISK and
FACTURX_DIRECTORY; for the platform, FACTURX_PLATFORM_FLOW_URL,
FACTURX_PLATFORM_DIRECTORY_URL, FACTURX_PLATFORM_TOKEN (or FACTURX_PLATFORM_TOKEN_URL,
FACTURX_PLATFORM_CLIENT_ID, FACTURX_PLATFORM_CLIENT_SECRET),
FACTURX_PLATFORM_ORGANIZATION_ID and FACTURX_PLATFORM_ID. Their defaults and meaning are in docs/setup.md (laravel facturx:docs
prints where the pages are).
§Test with FacturX::fake()
FacturX::fake checks for real, records instead of rendering, and numbers in memory. Fake the
disk and the mailer with laravel::storage::fake("local") and laravel::mail::fake().
§What it does not do
Produce the MINIMUM, BASIC and EXTENDED profiles, or talk to a platform that has only its own API.
The invoice model and the rules are en16931’s and en16931_formats’s, re-exported for
anything this crate does not wrap.
Re-exports§
pub use en16931;pub use en16931_formats;
Modules§
- ereporting
- E-reporting (flux 10): what the tax administration receives, through the plateforme agréée, about the sales that e-invoicing does not carry. Sales to private persons (B2C), and sales and purchases with businesses not established in France. Both come with the payments collected when VAT is due on receipt (services).
- french
- French rules that EN 16931 does not check.
- identifiers
- SIREN, SIRET and French VAT numbers.
- platform
- The application’s plateforme agréée (PA), through the standard API of AFNOR XP Z12-013 (June 2026): send invoices, life-cycle statuses and e-reporting, follow their acknowledgement, collect what the platform received, and read the e-invoicing directory.
- status
- Life-cycle statuses of an invoice (flux 6, CDAR): what the buyer and the seller say about it after it was sent. Their platforms exchange these statuses, and transmit the mandatory ones to the administration:
- view
- The data a PDF template renders: every value is already formatted the French way, and absent values are empty.
Structs§
- Address
- A postal address.
- Coded
Note - A note with its UNTDID 4451 subject code (BT-21), printed and carried in the XML:
PAIwhen a third party pays part of the invoice,ABUfor a contractual reserve clause,TXDfor a tax declaration… - Corrects
- The invoice a credit note cancels or corrects.
- Customer
- The customer.
- Date
- A calendar day — EN 16931-1 §6.5.9
Date. Type. - Decimal
Decimalrepresents a 128 bit representation of a fixed-precision decimal number. The finite set of values of typeDecimalare of the form m / 10e, where m is an integer such that -296 < m < 296, and e is an integer between 0 and 28 inclusive.- Delivery
- Where and when the goods were delivered.
- Deposit
Paid - A deposit invoice taken back on the final invoice, at one VAT rate.
- Discount
- A discount (remise): a percentage of the amount it applies to, or a fixed amount.
- Exemption
- Why lines at 0 % carry no VAT, when the seller is not under the franchise.
- FacturX
- Issues Factur-X invoices for the configured seller, and inspects received ones.
- FacturX
Config - The
facturxconfiguration, read from the environment. - FacturX
Service Provider - Registers
FacturX, thefacturxconfiguration and thefacturx:*commands. - Inspection
- What a received invoice is worth: the EN 16931 decision and the French findings.
- Invoice
- An invoice, a credit note or a deposit invoice, to issue.
- Invoice
Pdf - A Factur-X PDF. Returned from a handler, it opens in the browser under its invoice number.
- Line
- One line of the invoice.
- Official
Finding - One rule of the official schematron that the invoice breaks.
- Official
Report - What the official rules reported.
- Official
Rules - The official rules of the French flow, loaded once and used for every received invoice.
- Period
- The period an invoice covers (BG-14), both days included.
- Prefixes
- Number prefixes, one series per kind of document and per year:
F-2026-00042. - Prepared
- An invoice that passed every check: the EN 16931 proof and the view its PDF is rendered from.
- Seller
- The business issuing the invoice. Usually built from the configuration.
- Settings
- How the seller invoices: payment terms, VAT regime, numbering, template and archive.
Enums§
- Error
- Why an invoice could not be issued.
- Kind
- What kind of document is issued.
- Nature
- What the invoice is for: a mandatory mention since the e-invoicing reform, and the first letter of the billing framework (BT-23).
- Official
- The official rules of the French flow on a received invoice: the schematron FR CTC that the FNFE-MPE publishes (XP Z12-012).
- Payment
- How the customer pays (BG-16). In JSON,
{"method": "transfer"},{"method": "direct_debit", "mandate": "…", "debtor_iban": "…"}or{"method": "card", "last_digits": "4242"}.
Constants§
- DEFAULT_
EARLY_ PAYMENT_ DISCOUNT - No early-payment discount is granted.
- DEFAULT_
LATE_ PENALTIES - The legal floor for late-payment penalties: three times the legal interest rate.
- DEFAULT_
TEMPLATE - The template rendered by default: the bundled one, or its published copy.
- DEFAULT_
VAT_ FRANCHISE_ MENTION - The mention of the VAT franchise (CGI, art. 293 B). VAT moves to the code des impositions sur
les biens et services on 1 January 2027; invoices may keep citing the CGI until 31 December
2027 (service-public.gouv.fr, F23208).
Settings::vat_franchise_mentiontakes the new wording.
Functions§
- today
- Today’s date in France (Europe/Paris), by the application’s clock.