Catch invalid e-invoices in your CI, in one command
Lire en français
lintvoice runs the official rules on your e-invoices: the European standard's, then each country's, starting with France. It works offline, with no Java, no server and no account: your invoices are never sent anywhere.
Never a false all-clear. When a rule set could not run on a file, lintvoice exits with code 4 and says the check is incomplete instead of "no errors" (exit codes).
Each failing rule is named, with its official message and, for the totals and VAT, the computation with your invoice's own values. On lintvoice.com, a rule's page says in plain words what it checks and how to fix an invoice that fails it.
Today it runs:
- EN 16931 (the European e-invoicing standard), for CII and UBL;
- Factur-X 1.09.2 profile rules, for Factur-X PDFs;
- BR-FR, the French reform rules published by FNFE-MPE (France_RFE), when the seller is in France.
lintvoice reads CII XML, UBL XML (invoices and credit notes) and Factur-X / ZUGFeRD PDFs. Results are grouped by rule (e.g. one missing VAT number shows up once, not for every faulty invoice line).
Before 1.0, options and the JSON output may still change.
Quick start
uvx lintvoice rules install # once: downloads the pinned rule packs
uvx lintvoice check invoice.pdf
uvx lintvoice check invoices/ --format json
Or pip install lintvoice (Python 3.10 or later). Each release also ships its wheel and sdist on GitHub Releases, if PyPI is out of reach: pip install lintvoice-<version>-py3-none-any.whl.
In a container, with the rule packs inside the image:
docker build -t lintvoice . # after `uv build`, from a checkout
docker run --rm -v "$PWD:/work" lintvoice check invoices/
The image runs as an unprivileged user (UID 10001).
✗ demo.pdf
Factur-X EN 16931 · CII · PDF (factur-x.xml)
BR-FR rules applied: the seller's country is FR.
7 errors in 6 rules.
error BR-FR-16_BT-152 ×2
BT-152: Le taux de TVA (BT-152) doit être exprimé en pourcentage … Taux fourni : "21".
at /CrossIndustryInvoice/SupplyChainTradeTransaction/IncludedSupplyChainTradeLineItem/… (+1 more)
The values behind an error
For the totals and VAT rules (BR-CO-10 to 17, BR-S-08 and BR-S-09), lintvoice shows the computation with the
invoice's own values:
error BR-CO-15 ×1
1025.00 (BT-109) + 205.00 (BT-110) = 1230.00; the invoice states 1231.00 (BT-112), a gap of 1.00
A rule checked for each VAT rate shows the rate that fails:
error BR-CO-17 ×1
At the rate 20 % (S): 1025.00 (BT-116) × 20 % (BT-119) = 205.00; the invoice states 207.00
(BT-117), a gap of 2.00
In JSON, each file carries values: the business terms read from the invoice (terms, with the identifier
schemes given), its lines (each with its own allowances, charges and item attributes), its notes, its
vat_breakdown, its document level allowances and charges, and its supporting documents. A
failing totals or VAT rule carries computation: its parts, the expected and stated amounts, the gap and, for
a rule checked for each VAT rate, the VAT breakdown that fails (group). Where each business term is read, in CII and UBL, is data:
src/lintvoice/terms.json.
One rule
--rule ID answers for one business rule (several --rule may be given): the rule fails, finds no error, does not
apply to the invoice (and why), or could not be checked. The full rule sets run as usual; the answer reads that rule
only, and the other rules' errors are summed up in one line:
lintvoice check --rule BR-CO-15 invoice.pdf
BR-CO-15: fails
...
Other rules: no errors.
Whether a rule applies comes from the official files: each one reports the rule contexts that fired on the invoice,
and each rule sits in one context. A rule does not apply when the French rules do not run (the seller is not in
France), when it exists only for the other syntax (CII or UBL) or for another invoice profile, or when the invoice does
not hold what it checks. In JSON, each file carries rules: for each rule asked, its answer (fails, warns,
no-error, does-not-apply, not-checked) and, when it does not apply, the reason (seller-not-in-france,
other-syntax, other-profile, not-in-invoice).
The XML inside a PDF
lintvoice extract invoice.pdf writes the XML attached to the PDF, the invoice's electronic data that the rules check, to invoice.xml.
In CI
lintvoice check exits with 1 when a file has errors, so the job fails. --fail-on warning makes warnings fail it
too. The rule packs are downloaded once and cached, and every later run checks offline.
GitHub Actions:
name: invoices
on: [push, pull_request]
permissions:
contents: read
env:
LINTVOICE_VERSION: "0.8.0" # the version you tested
jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: astral-sh/setup-uv@v10.4.0
- uses: actions/cache@v6
with:
path: ~/.cache/lintvoice
key: lintvoice-rules-${{ env.LINTVOICE_VERSION }}
- run: uvx "lintvoice@$LINTVOICE_VERSION" rules install
- run: uvx "lintvoice@$LINTVOICE_VERSION" check invoices/
GitLab CI:
invoices:
image: python:3.13-slim
variables:
LINTVOICE_VERSION: "0.8.0" # the version you tested
LINTVOICE_RULES_DIR: "$CI_PROJECT_DIR/.lintvoice-rules"
cache:
key: lintvoice-rules-$LINTVOICE_VERSION
paths: [.lintvoice-rules/]
script:
- pip install "lintvoice==$LINTVOICE_VERSION"
- lintvoice rules install
- lintvoice check invoices/
Reports a CI system shows where you review the change, with --format:
| Format |
For |
What you get |
github |
a GitHub Actions run |
an annotation per failing rule and file, on the run and on the pull request's files |
sarif |
GitHub code scanning, and other SARIF 2.1.0 readers |
one result per place a rule fails |
junit |
any system that reads JUnit XML |
one test case per file |
gitlab |
GitLab merge requests |
a Code Quality report |
--output FILE writes the report to a file; the text report still goes to the log:
lintvoice check invoices/ --format sarif --output lintvoice.sarif
A failing rule points at its line in an XML invoice. An invoice inside a PDF has no line to point at: the report
names the file.
- Name the folder that holds your invoices, not
.: GitLab only caches folders inside the project, and the rule
packs come with the official example invoices, which a check of the whole project would read too.
- The log names what judged the invoices: the report's first line gives the version of lintvoice and of each rule
set that ran, and
lintvoice --version lists the pinned rule packs.
- For a script,
--format json writes the same report as JSON. Its format_version (1 today) changes only when a
field is renamed, removed or changes meaning; new fields may appear within a version. exit_code and fail_on say
how the run ended, and each file has a status: ok, errors, incomplete, unreadable, and warnings with
--fail-on warning.
From a coding agent
A skill (Agent Skills format) tells a coding agent when to run lintvoice, how to read
the result and where each rule is explained.
- Claude Code:
claude plugin marketplace add lintvoice/lintvoice, then claude plugin install lintvoice@lintvoice.
To receive updates, turn on auto-update for the marketplace in /plugin, under Marketplaces.
- Other agents (Codex, Cursor, GitHub Copilot, Gemini CLI…):
npx skills add lintvoice/lintvoice; npx skills update
brings the latest version.
Rule packs: what lintvoice downloads, and why
lintvoice ships no rule files. lintvoice rules install downloads each pack once, from its upstream source, at a pinned version:
- What: the official validation artefacts: Schematron sources, the XSLT compiled from them, and the XML schemas.
- Why: you get the exact official rules, under their own licences. lintvoice follows the official releases instead of rewriting rules.
- When:
- only when you run
lintvoice rules install;
- never when the package is installed or imported, and never during a check;
- after that, every check runs offline.
- How it is checked:
- over https only;
- the EN 16931 archives against their SHA-256;
- France_RFE, which GitHub archives on the fly, against a SHA-256 of the 207 files kept;
- a changed file, or an archive entry outside the pack folder, stops the install.
- Not downloaded into the packs: FranceRFE's folders that hold AFNOR documents (`Z.notes&_docs/
,Z.example/`) are never extracted.
- No other network use: a checked file cannot make lintvoice fetch anything, since a file that declares a DOCTYPE is refused.
Packs go to ~/.cache/lintvoice/rules (or $XDG_CACHE_HOME, $LINTVOICE_RULES_DIR, --rules-dir). lintvoice rules list shows what is installed.
What runs on which file
| File |
Schema |
Rules |
| Factur-X PDF, or CII with a Factur-X profile id |
Factur-X 1.09.2 (BASIC WL, EN 16931, EXTENDED) |
EN 16931 (except MINIMUM, BASIC WL), Factur-X profile rules, BR-FR (except MINIMUM) |
CII XML with urn:cen.eu:en16931:2017 |
CII D22B |
EN 16931, BR-FR |
| Factur-X PDF or CII with France's EXTENDED-CTC-FR profile id |
CII D22B |
EN 16931 in France's version for this profile (EXTENDED-CTC-FR 1.4.0.04), BR-FR |
| UBL invoice or credit note |
UBL 2.1 |
EN 16931, BR-FR |
- BR-FR runs when the seller's country (BT-40) is FR.
--rules en16931,factur-x,br-fr forces it, --rules en16931 limits the check to EN 16931.
- A file is read in the encoding it declares (UTF-8, ISO-8859-1, UTF-16…), as XML allows. XRechnung and Peppol ask for UTF-8: a note says so when such an invoice uses another encoding, since no rule file can check it.
- A bare CII XML gets the Factur-X profile rules only when asked (
--rules …,factur-x), since urn:cen.eu:en16931:2017 is also plain CII.
- An EXTENDED-CTC-FR invoice gets France's version of the EN 16931 rules, in place of the CEN's file. France_RFE derives it from the CEN's file for the profile's groups of lines (one invoice for several sellers, each with its sub-invoice): it rewrites the rules on totals and VAT for them and leaves out those they would break, such as BR-CO-10.
Exit codes
| Code |
Meaning |
| 0 |
No errors (warnings do not change the exit code, unless --fail-on warning) |
| 1 |
At least one file has errors, or warnings with --fail-on warning |
| 2 |
A file could not be read as an invoice, no file was found, or a rule asked with --rule is not in the official rule files |
| 3 |
Rule packs are not installed |
| 4 |
No errors found, but a rule set could not run on a file: its official rule file stopped with an error. The check is incomplete, so lintvoice does not say "no errors" |
| 130 |
Interrupted (Ctrl-C) |
With --rule, the codes speak of the rules asked: 1 when one of them fails, 4 when one of them could not be checked.
Not checked yet
- PDF/A-3 validation of Factur-X PDFs (needs veraPDF).
- XRechnung and Peppol BIS rules: those invoices get EN 16931 only, and the report says so.
- Factur-X MINIMUM and BASIC profile rules: France_RFE 1.4.0.04 does not ship them.
- Chorus Pro's own rules for its historic channels.
- BR-FR messages are in French, as FNFE-MPE writes them.
Development
uv sync
uv run pytest # functional tests; the first run downloads the packs into .rules-cache/
uv run pytest -m corpus # only the official EN 16931 examples
The tests drive the command line on generated invoices (tests/invoices.py) and on the official examples. They check that:
- checks never touch the network;
- France_RFE's AFNOR documents are never installed.
Licence
The code is under the MIT licence. The rule packs keep their own licences (table above) and are not part of this package. The Docker image bundles third-party components: see THIRD_PARTY_NOTICES.md.