XSD+SCH Ministerio de Hacienda (Spain) · 3.2.2

Facturae 3.2.2

The Spanish e-invoice format, required for invoices to the public sector through FACe

About

Facturae is the XML format the Spanish Ministry of Finance publishes for electronic invoices. Suppliers of the public administration have to send it, signed, through FACe or a regional hub; version 3.2.2 is the current one.

One file (Facturae) holds a header with the batch totals, the seller and buyer, and one or more invoices with their taxes, totals and lines.

E-invoicing in Spain: the rules in short and how to check an invoice →

Good to know

  • After the schema, xmlvalid's rules check what the public sector's invoice registers and FACe validate under Orden HAP/1650/2015 and can be seen in the file: the NIF of seller and assignee, names, the corrected invoice of a corrective one, amounts in cents and line totals in euros, the invoice totals, and the formulas of the Facturae format for the batch and the totals. The three DIR3 codes are required when the buyer's NIF is a public administration's (P, Q or S); invoices between businesses don't carry them.
  • Not checked: the XAdES signature, invoices registered before, and whether the DIR3 codes exist.
  • The XML Signature import points at a local copy of the W3C schema; nothing else is changed.
  • The example is by xmlvalid.com: one unsigned invoice to a town council with Spanish VAT at 21%, made-up NIFs with valid check characters and a made-up DIR3 code.

Files

2 files · 192.3 KB · Download all (.zip)

The validator loads all of these with their folder structure, so includes and imports resolve as published

Business rules

Schematron · run in this order

The rules run after the schema check, only when the document matches the schema, and in your browser like the schema check (with SaxonJS by Saxonica). Each finding names its rule, such as BR-CO-15, and the line it points at; each rule has a page with what it checks.

Example document

factura.xml · 5.7 KB · passes the schema and the rules

In CI and from code

The same schema by its name, facturae-3.2.2, through the API.

npx @xmlvalid/cli validate "**/*.xml" --schema facturae-3.2.2
- uses: xmlvalid/validate-action@v1
  with:
    files: "**/*.xml"
    schema: facturae-3.2.2
    api-key: ${{ secrets.XMLVALID_API_KEY }}
curl https://xmlvalid.com/api/v1/validations \
  -H "Authorization: Bearer $XMLVALID_API_KEY" \
  -F document=@factura.xml \
  -F schema=facturae-3.2.2

Free accounts get 100 API validations a month. On Pro, a URL monitor can check a published document against this schema every hour and email you when it breaks. More CI setups