# VeriFactu

## What is VeriFactu

VeriFactu is the electronic invoicing system established by RD 1007/2023 and Order HAC/1177/2024. It applies to all **Invoicing Computer Systems (SIF)** operating in Spain.

Its objective is to guarantee the traceability of invoices and prevent tax fraud. Each invoice generates a digital footprint (hash) that is chained to the previous one, forming an immutable record verifiable by the AEAT.

## How Frihet Complies

VeriFactu compliance in Frihet is **always active**. There is no toggle, no extra configuration, no module to activate. Frihet is one of the few ERPs that includes VeriFactu by default in all plans -- see the [full features](https://www.frihet.io/es/features).

Everything happens in the background when creating or modifying invoices:

- The SHA-256 hash is automatically calculated on the server
- The QR code is generated in each PDF
- Tax fields are locked after registration
- The hash chain is maintained continuously

The user does not need to do anything special to comply with VeriFactu.

## SHA-256 Hash Chain

Each invoice generates an SHA-256 hash on the server. This hash is chained with the hash of the previous invoice, forming an immutable chain that guarantees the integrity of the record.

### Creation Hash

When creating an invoice, the hash is calculated from 8 fields:

| Field | Description |
|-------|-------------|
| NIF emisor | Issuer tax identification |
| Invoice number | Full number (series + sequence) |
| Issue date | In DD-MM-YYYY format |
| Invoice type | F1, F2, R1-R5 |
| Total tax amount | Sum of all taxes |
| Total amount | Invoice total |
| Previous hash | Hash of the immediately preceding invoice |
| Registration date/time | Timestamp of generation moment |

### Cancellation Hash

When cancelling an invoice, a cancellation hash is generated with 5 fields:

| Field | Description |
|-------|-------------|
| NIF emisor | Issuer NIF |
| Invoice number | Number of the cancelled document |
| Issue date | Original invoice date |
| Previous hash | Hash of the previous invoice in the chain |
| Registration date/time | Cancellation timestamp |

The critical hash fields are immutable once calculated. They cannot be edited after hash generation.

## Invoice Types (TipoFactura)

Frihet automatically assigns the invoice type based on the document's characteristics:

| Code | Type | Description |
|--------|------|-------------|
| F1 | Full invoice | Standard invoice (assigned by default) |
| F2 | Simplified invoice | Invoices under 400 EUR without recipient's NIF |
| R1 | Rectifying (art. 80.1-2, 80.6 LIVA) | Errors, retroactive discounts (most common) |
| R2 | Rectifying (art. 80.3 LIVA) | Insolvency proceedings (concurso de acreedores) |
| R3 | Rectifying (art. 80.4 LIVA) | Wholly or partly uncollectible debt |
| R4 | Rectifying (rest) | Other cases |
| R5 | Simplified rectifying | Rectifying simplified invoice |

F2 is automatically assigned when the amount is less than 400 EUR and the recipient does not have an NIF.

## VAT Regime Keys (ClaveRegimenIVA)

The regime key identifies the type of tax operation. Frihet assigns the general regime (01) by default.

| Code | Regime |
|--------|---------|
| 01 | General regime |
| 02 | Export |
| 03 | Special regime for used goods |
| 04 | Special regime for investment gold |
| 05 | Special regime for travel agencies |
| 06 | Special regime for groups of entities |
| 07 | Special regime for cash-basis accounting |
| 08 | Operations subject to IPSI/IGIC |

## AEAT QR on Invoices

All PDF invoices generated by Frihet include a verification QR code that links to the AEAT's electronic headquarters.

**QR URL format:**

```
https://www2.agenciatributaria.gob.es/wlpl/TIKE-CONT/ValidarQR?nif={NIF}&numserie={NUM}&fecha={DD-MM-YYYY}&importe={TOTAL}
```

Next to the QR, the text appears: *"Invoice verifiable at the AEAT electronic headquarters"*.

:::info
The QR code only appears when the tax profile has an NIF configured in **Settings** → **Tax profile**.
:::

## Software Declaration of Conformity

The declaration of conformity complies with Art. 20 of RD 1007/2023. It is visible in **Settings** → **Tax profile** and contains the following data:

| Field | Value |
|-------|-------|
| Software | Frihet ERP v1.0 |
| Manufacturer | (Configured in **Settings** > **Compliance** > **VeriFactu**) |
| Manufacturer NIF | (Configured in **Settings** > **Compliance** > **VeriFactu**) |
| Hash chain | SHA-256 |
| Regulations | RD 1007/2023, Orden HAC/1177/2024 |

## Relationship with Tax Forms

VeriFactu focuses on invoice traceability (hash, QR, immutability). The [quarterly tax forms](./modelos-fiscales) are an additional step where declarations to be submitted to the Treasury are calculated:

- [Modelo 303 (IVA)](./modelo-303) — for Peninsula and Balearic Islands
- [Modelo 420 (IGIC)](./modelo-420) — for Canary Islands
- [Modelo 130 (IRPF)](./modelo-130) — for all self-employed individuals

VeriFactu data (invoice type, regime key) is automatically included in the [record books](./libro-registro) exported by Frihet.

## Phase 3: Submission to AEAT

Phase 3 of VeriFactu allows the automatic submission of invoicing records directly to the AEAT using SOAP/XML messages signed with a digital certificate. With this phase active, each invoice issued or cancelled is transmitted to the AEAT's SII system in the background.

The submission requires a valid digital certificate (.pfx or .p12) configured in **Settings** > **Compliance**. It can be activated in sandbox mode for testing before moving to production.

For complete documentation on configuration, submission statuses, retries, and troubleshooting, refer to the [Submission to AEAT guide](./verifactu-fase3).

:::info Compliance Timeline
Companies (S.L., S.A.): January 1, 2027. Self-employed: July 1, 2027 (RDL 15/2025).
:::

## Applicable Regulations

- **Ley 11/2021** (Ley Antifraude) — Art. 29.2.j) LGT
- **RD 1007/2023** — Reglamento VeriFactu (RRSIF)
- **Orden HAC/1177/2024** — Technical Specifications
- **RDL 15/2025** — Deadline Extension

---

**Next:** [Submission to AEAT (Phase 3)](./verifactu-fase3) | [Immutability and Record-keeping](./inmutabilidad)
