🧾 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.
Metadata
Release files for belegradar 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| belegradar-0.1.0.tar.gz | 32.2 kB | With provenance | Details for belegradar-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| belegradar-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for belegradar-0.1.0-py3-none-any.whl |
Total release size: 44.4 kB
Release files / belegradar-0.1.0.tar.gz
| Download URL | belegradar-0.1.0.tar.gz |
|---|---|
| Size | 32.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
277bd3bb0b4316e6c4e30209ff004fe0de8a9592a2ef4d2f7a1ea931f0771204
|
|
BLAKE2b-256 checksum How to use checksums |
159c3a725f9ebd081a05ca2212d363bd290a4959315563a8ce1a45effef14954
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 6, 2026.
Transparency logRelease files / belegradar-0.1.0-py3-none-any.whl
| Download URL | belegradar-0.1.0-py3-none-any.whl |
|---|---|
| Size | 12.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
06666a0517ca8f81ccee90c951dfa759e1491de7de6358e1e8d97c02cce8a152
|
|
BLAKE2b-256 checksum How to use checksums |
a28bd40afd10bfcd7779c03485305fb668f2a3958cc0a8a36ecac3d1e98a27e0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 6, 2026.
Transparency logSecurity for belegradar 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for belegradar-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 6, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.