Skip to main content

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

PyPI version Python License: MIT CI

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:

  1. Validate Spanish NIF / CIF / NIE identifiers (real checksum algorithm).
  2. Build the SHA-256 chained hash of an invoice exactly as the AEAT spec requires (previous-hash + invoice fields, hex output).
  3. Build the Veri*Factu QR URL pointing to the AEAT TIKE-CONT endpoint.
  4. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

verifactu_validator-0.1.0.tar.gz (15.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

verifactu_validator-0.1.0-py3-none-any.whl (12.4 kB view details)

Uploaded Python 3

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

Hashes for verifactu_validator-0.1.0.tar.gz
Algorithm Hash digest
SHA256 fafcfc9e5745f411bec06a42975f5f4117cd090e27017d73319626ef0c45f6ea
MD5 fd8410035c6f2e36ddb1e275df5b7897
BLAKE2b-256 caa3d68b5e5243ddc347f0e99dd4038039582e6889755fb4cb86f04692f7cf9f

See more details on using hashes here.

File details

Details for the file verifactu_validator-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for verifactu_validator-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6b4fc12ef024246155545553ed72eb15fc22e21c1c9fc484462e63dfd7edb616
MD5 912eb8a58c12f47685648f116ca0374c
BLAKE2b-256 a2ea5dba5ce7ef42a6a8a392f34bf40e7d2dfa2b7b070123050c1d115950d7bb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page