> For the complete documentation index, see [llms.txt](https://docs.younium.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.younium.com/e-invoicing-integrations/verifactu.md).

# Verifactu

## Overview

The Verifactu integration supports Spain’s invoice reporting (Verifactu / AEAT SIF) for posted EUR invoices. Younium builds a chained XML record with cryptographic hash (huella), validates it against AEAT’s test service, optionally submits alta registration, attaches XML to the invoice, and can expose QR-related invoicing when enabled in settings.

## Authentication

There is nothing to connect and no credentials to enter. The certificate used to sign submissions to the Spanish tax authority, and the authority's own addresses, are held for the environment rather than per tenant, so Younium signs and submits on your behalf.

The Verifactu settings you manage hold feature choices only.

## Activation and Save settings

There is no activation step. Settings are created for the legal entity the first time you open them, with QR invoicing switched on, and take effect as soon as they are saved. Removing them returns the legal entity to having none.

An invoice must be posted before its Verifactu document can be produced. Younium builds the document and validates it, which lets you confirm an invoice would be accepted before it goes to the tax authority.

## Eligibility

| Rule            | Behaviour                                                                                     |
| --------------- | --------------------------------------------------------------------------------------------- |
| Invoice status  | Must be `Posted` for export API                                                               |
| Currency        | Must be EUR (`Invoice.TotalAmount.CurrencyCode`)                                              |
| Legal entity    | `TaxRegistrationNumber` required (issuer NIF)                                                 |
| Account         | `Name` and `TaxRegistrationNumber` required                                                   |
| Invoice amounts | `TotalAmount` and `Tax` required for amount calculation                                       |
| Credit invoices | Invoice type mapping currently always `F1` (standard); credit support noted as future in code |

## Hash chain

Each record includes `Hash` (current huella) and `PreviousHash` from the prior reporting entry for the legal entity. `VerifactuHashBuilder` implements SHA-256 per AEAT algorithm code `01`.

## Verifactu invoice model mapping (Younium → XML alta)

| Younium Field                                  | Verifactu / XML element                                            |
| ---------------------------------------------- | ------------------------------------------------------------------ |
| `ApplicationLegalEntity.TaxRegistrationNumber` | Issuer `NIF` / `IDEmisorFactura`                                   |
| `ApplicationLegalEntity.Name`                  | Issuer `NombreRazon`                                               |
| `Invoice.InvoiceDate`                          | `FechaExpedicionFactura` (`dd-MM-yyyy`)                            |
| `Invoice.InvoiceNumber`                        | `NumSerieFactura`                                                  |
| `Invoice.Account.Name`                         | Customer `NombreRazon`                                             |
| `Invoice.Account.TaxRegistrationNumber`        | Customer `NIF`                                                     |
| `InvoiceType`                                  | `TipoFactura` (currently `F1`)                                     |
| `TotalAmount - Tax`                            | `BaseImponibleOimporteNoSujeto`                                    |
| `Invoice.Tax.Amount`                           | `CuotaRepercutida`, `CuotaTotal`                                   |
| `Invoice.TotalAmount.Amount`                   | `ImporteTotal`                                                     |
| Derived rate                                   | `TipoImpositivo` (0 if base 0, else tax/base × 100)                |
| Computed hash                                  | `Huella`                                                           |
| Record timestamp                               | `FechaHoraHusoGenRegistro`                                         |
| Fixed                                          | `Impuesto` `01`, `ClaveRegimen` `01`, `CalificacionOperacion` `S1` |
| `Incidencia`                                   | `N`                                                                |

## AEAT request mapping

`AeatAltaRequest` fields populated from invoice and entry:

| Younium Field                   | AEAT request property           |
| ------------------------------- | ------------------------------- |
| Generated XML string            | `RequestXml`                    |
| `Account.TaxRegistrationNumber` | `Nif` (recipient in validation) |
| `Invoice.InvoiceNumber`         | `NumSerie`                      |
| `Invoice.InvoiceDate`           | `Fecha`                         |
| `Invoice.TotalAmount.Amount`    | `Importe`                       |
| Entry `ContentSignature`        | `CurrentHuella`                 |
| `Invoice.Id`                    | `CorrelationId`                 |

## Submit and validate workflow

`CreateAndValidateVerifactuDocument`:

1. Map invoice → `VerifactuInvoice`, build XML, create `IntegrationInvoiceReportingEntry` (status `Pending`).
2. `ValidateAltaAsync` (external test) — failure throws.
3. Returns entry for caller.

`SubmitAndAttachVerifactuInvoice`:

1. `SubmitAltaAsync` to production SIF.
2. If `Estado` is `Aceptada` → `Processed`; else `Failed` and integration log.
3. `AeatBusinessException` → failed status and API exception.
4. Persist entry in `finally`.
5. Attach XML to invoice file storage.

### AEAT estado mapping

| AEAT `Estado`          | Younium entry status |
| ---------------------- | -------------------- |
| `Aceptada`             | `Processed`          |
| Other / business error | `Failed`             |

## QR invoicing

When enabled, Younium generates the QR payload printed on the invoice and its PDF.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.younium.com/e-invoicing-integrations/verifactu.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
