Metadata-Version: 2.4
Name: verifactu-validator
Version: 0.1.0
Summary: Spanish e-invoice (Veri*Factu / AEAT) validator: NIF/CIF/NIE checksum, SHA-256 chained hash, and QR URL builder per Spanish Tax Agency spec.
Author-email: FlexiGoTech <comercial@flexigobe.com>
Maintainer-email: FlexiGoTech <comercial@flexigobe.com>
License: MIT
Project-URL: Homepage, https://flexigotech.com/verifactu
Project-URL: Documentation, https://flexigotech.com/verifactu
Project-URL: Repository, https://github.com/Flexigobe/verifactu-validator
Project-URL: Bug Tracker, https://github.com/Flexigobe/verifactu-validator/issues
Project-URL: Commercial Odoo Module, https://flexigotech.com/verifactu
Keywords: aeat,verifactu,spain,einvoice,odoo,facturae,compliance,invoice,sii,tributaria
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Financial and Insurance Industry
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Office/Business :: Financial :: Accounting
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Natural Language :: Spanish
Classifier: Natural Language :: English
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: dev
Requires-Dist: pytest>=7.4; extra == "dev"
Requires-Dist: pytest-cov>=4.1; extra == "dev"
Requires-Dist: ruff>=0.4; extra == "dev"
Requires-Dist: build>=1.0; extra == "dev"
Requires-Dist: twine>=4.0; extra == "dev"
Dynamic: license-file

# verifactu-validator — Spanish AEAT Veri*Factu Invoice Validator

[![PyPI version](https://img.shields.io/pypi/v/verifactu-validator.svg)](https://pypi.org/project/verifactu-validator/)
[![Python](https://img.shields.io/pypi/pyversions/verifactu-validator.svg)](https://pypi.org/project/verifactu-validator/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![CI](https://github.com/Flexigobe/verifactu-validator/actions/workflows/ci.yml/badge.svg)](https://github.com/Flexigobe/verifactu-validator/actions/workflows/ci.yml)

> **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

```python
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:

```bash
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

```bash
pip install verifactu-validator
```

Requires Python **3.10+**. Zero runtime dependencies.

## Publishing (for maintainers)

```bash
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](https://flexigotech.com)

---

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](https://flexigotech.com).
