Invoice/receipt structured extraction with validation, built for the DACH market (VAT breakdown, IBAN checksum, USt-IdNr, paragraph 14 UStG check)
Project description
🧾 belegradar
Invoice and receipt extraction with validation, built for the DACH market.
pip install belegradar
Turn a PDF invoice into validated structured data: vendor, line items, VAT breakdown per rate (MwSt-Aufschluesselung), totals, checksum-validated IBAN, and a paragraph 14 UStG required-fields check, with a flag on anything that does not add up.
The design rule: the LLM reads, plain Python verifies. The model copies
values verbatim; deterministic code does all locale number parsing
(1.234,56 vs 1,234.56), date parsing, and arithmetic checks.
Quickstart
from belegradar import extract_text, extract_invoice, validate
text = extract_text(open("invoice.pdf", "rb").read()) # raises on scans
invoice, tokens = extract_invoice(text) # needs GROQ_API_KEY
report = validate(invoice)
print(invoice.vendor_name, invoice.gross_total, invoice.currency)
for flag in report.flags:
print(flag.severity, flag.field, flag.message)
print("Pflichtangaben:", report.pflichtangaben)
What it validates (no LLM involved)
gross_total == net_total + sum(VAT amounts), within rounding tolerance- line items sum to
net_total; eachquantity * unit_price == total - each VAT bucket:
rate% of base == amount - IBAN ISO 13616 mod-97 checksum, pure Python
- VAT id country formats (DE/AT/CH/NL/FR/GB, extendable)
- paragraph 14 UStG Pflichtangaben: presence of every field a German invoice must carry to be valid for input-tax deduction
Utilities
from belegradar import iban_is_valid, vat_id_is_valid
iban_is_valid("DE89 3704 0044 0532 0130 00") # True (spaces tolerated)
vat_id_is_valid("ATU12345678") # True
Honest constraints
- Text-layer PDFs only. Scanned or photographed invoices raise
NoTextLayerError. There is no reliable free OCR at zero infrastructure cost, and pretending would produce silently wrong data. OCR is a roadmap item. - Extraction is not perfect; the product stance is extraction with validation and flags, which is what real back-office workflows need.
- The LLM provider is swappable (Groq by default via
GROQ_API_KEY); it is never trusted with arithmetic or locale conversion.
Used in production by
The live demo at beleg.nagysolution.com runs this package. Accuracy is measured by an eval suite over a gallery of fake invoices; results are published in the repository.
License
MIT. Built by Nandor Nagy as part of a public portfolio.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file belegradar-0.1.0.tar.gz.
File metadata
- Download URL: belegradar-0.1.0.tar.gz
- Upload date:
- Size: 32.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
277bd3bb0b4316e6c4e30209ff004fe0de8a9592a2ef4d2f7a1ea931f0771204
|
|
| MD5 |
40d54a38e7a896e3e942d597f41735b0
|
|
| BLAKE2b-256 |
159c3a725f9ebd081a05ca2212d363bd290a4959315563a8ce1a45effef14954
|
Provenance
The following attestation bundles were made for belegradar-0.1.0.tar.gz:
Publisher:
release.yml on n3ndor/belegradar
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
belegradar-0.1.0.tar.gz -
Subject digest:
277bd3bb0b4316e6c4e30209ff004fe0de8a9592a2ef4d2f7a1ea931f0771204 - Sigstore transparency entry: 2085123312
- Sigstore integration time:
-
Permalink:
n3ndor/belegradar@b589ae0a14dbb429ca2813a98d9cf0bad1c49d46 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/n3ndor
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@b589ae0a14dbb429ca2813a98d9cf0bad1c49d46 -
Trigger Event:
push
-
Statement type:
File details
Details for the file belegradar-0.1.0-py3-none-any.whl.
File metadata
- Download URL: belegradar-0.1.0-py3-none-any.whl
- Upload date:
- Size: 12.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
06666a0517ca8f81ccee90c951dfa759e1491de7de6358e1e8d97c02cce8a152
|
|
| MD5 |
6516a45f17aa3b89b93d1b7022f1eebf
|
|
| BLAKE2b-256 |
a28bd40afd10bfcd7779c03485305fb668f2a3958cc0a8a36ecac3d1e98a27e0
|
Provenance
The following attestation bundles were made for belegradar-0.1.0-py3-none-any.whl:
Publisher:
release.yml on n3ndor/belegradar
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
belegradar-0.1.0-py3-none-any.whl -
Subject digest:
06666a0517ca8f81ccee90c951dfa759e1491de7de6358e1e8d97c02cce8a152 - Sigstore transparency entry: 2085123321
- Sigstore integration time:
-
Permalink:
n3ndor/belegradar@b589ae0a14dbb429ca2813a98d9cf0bad1c49d46 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/n3ndor
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@b589ae0a14dbb429ca2813a98d9cf0bad1c49d46 -
Trigger Event:
push
-
Statement type: