Spanish e-invoice (Veri*Factu / AEAT) validator: NIF/CIF/NIE checksum, SHA-256 chained hash, and QR URL builder per Spanish Tax Agency spec.
Project description
verifactu-validator — Spanish AEAT Veri*Factu Invoice Validator
Days until Veri*Factu becomes mandatory: 29 (target date: 2026-07-01)
Spanish anti-fraud invoicing law (RD 1007/2023) requires every B2B/B2C invoice issued in Spain to be signed with a chained SHA-256 hash and to embed a QR code pointing to the AEAT verification endpoint.
verifactu-validator is a tiny, zero-dependency Python library that lets you:
- Validate Spanish NIF / CIF / NIE identifiers (real checksum algorithm).
- Build the SHA-256 chained hash of an invoice exactly as the AEAT spec requires (previous-hash + invoice fields, hex output).
- Build the Veri*Factu QR URL pointing to the AEAT TIKE-CONT endpoint.
- Run a CLI:
verifactu validate invoice.xml→ prints OK/FAIL per rule.
Quick start
from verifactu_validator import validate_nif, build_invoice_hash, build_qr_url
# 1. Validate a Spanish tax ID
assert validate_nif("12345678Z") # individual NIF
assert validate_nif("B12345678") # company CIF (example)
# 2. Build a chained SHA-256 hash (AEAT Veri*Factu spec)
h = build_invoice_hash(
previous_hash="0" * 64,
issuer_nif="B12345678",
invoice_number="F2026/0001",
issue_date="2026-07-01",
total_amount="121.00",
)
# 3. Build the QR URL embedded in the printed invoice
url = build_qr_url(
issuer_nif="B12345678",
invoice_number="F2026/0001",
issue_date="2026-07-01",
total_amount="121.00",
)
print(url)
# https://prewww2.aeat.es/wlpl/TIKE-CONT/ValidarQR?nif=B12345678&numserie=F2026%2F0001&fecha=01-07-2026&importe=121.00
CLI usage:
verifactu --help
verifactu validate path/to/invoice.xml
verifactu nif 12345678Z
verifactu hash --prev 000...0 --nif B12345678 --num F2026/0001 --date 2026-07-01 --total 121.00
verifactu qr --nif B12345678 --num F2026/0001 --date 2026-07-01 --total 121.00
Why this library exists
The Veri*Factu mandate is the biggest compliance shake-up Spanish SMBs have seen in a decade. Most accounting / ERP teams need a drop-in helper to:
- Pre-flight customer master data (NIF/CIF columns are full of typos).
- Compute the chained hash before posting an invoice.
- Generate the QR PNG that goes on the printed PDF.
This library covers exactly that surface. It is deliberately small so it can be vendored, audited, and certified without pulling a giant dependency tree into your ERP.
Full Odoo module: €369 one-off
This validator is the open-source nucleus of our commercial Odoo app:
Veri*Factu for Odoo 17 / 18 / 19 — full submission to AEAT, chained hash storage, QR on every PDF report, audit log, declarative re-send, multi-company, ready for July 2026.
€369 one-off — flexigotech.com/verifactu
If you just need the algorithms, this PyPI package is MIT-licensed and free forever. If you need the full ERP integration, buy the Odoo module.
Installation
pip install verifactu-validator
Requires Python 3.10+. Zero runtime dependencies.
Publishing (for maintainers)
pip install build twine
python -m build
twine upload dist/*
A GitHub Actions workflow (.github/workflows/ci.yml) runs the test suite on
every push and pull request.
License
MIT © 2026 FlexiGoTech
Made by FlexiGoTech in Barcelona. We build Odoo App Store modules for Spanish, French, German and EU compliance: Veri*Factu, France PDP, XRechnung, Whistleblowing, Mirakl/Decathlon connectors, AliExpress connector. See the full catalogue at flexigotech.com.
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 verifactu_validator-0.1.0.tar.gz.
File metadata
- Download URL: verifactu_validator-0.1.0.tar.gz
- Upload date:
- Size: 15.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fafcfc9e5745f411bec06a42975f5f4117cd090e27017d73319626ef0c45f6ea
|
|
| MD5 |
fd8410035c6f2e36ddb1e275df5b7897
|
|
| BLAKE2b-256 |
caa3d68b5e5243ddc347f0e99dd4038039582e6889755fb4cb86f04692f7cf9f
|
File details
Details for the file verifactu_validator-0.1.0-py3-none-any.whl.
File metadata
- Download URL: verifactu_validator-0.1.0-py3-none-any.whl
- Upload date:
- Size: 12.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6b4fc12ef024246155545553ed72eb15fc22e21c1c9fc484462e63dfd7edb616
|
|
| MD5 |
912eb8a58c12f47685648f116ca0374c
|
|
| BLAKE2b-256 |
a2ea5dba5ce7ef42a6a8a392f34bf40e7d2dfa2b7b070123050c1d115950d7bb
|