# Facturae validation rules of the Spanish public sector Orden HAP/1650/2015, Facturae 3.2.x description of 6 June 2017

Source: https://xmlvalid.com/rules/sets/es-facturae

> 27 rules by xmlvalid, after the validation rules of Orden HAP/1650/2015 (anexo II) and the formulas of the Facturae format (MIT). Source: https://www.boe.es/boe/dias/2015/08/06/pdfs/BOE-A-2015-8844.pdf

- [FACTURAE-1.5.2](https://xmlvalid.com/rules/FACTURAE-1.5.2.md) (error): InvoicesCount (…) is not the number of invoices in the file (…).
- [FACTURAE-1.5.3](https://xmlvalid.com/rules/FACTURAE-1.5.3.md) (error): TotalInvoicesAmount (…) is not the sum of the invoices' InvoiceTotal (…).
- [FACTURAE-1.5.4](https://xmlvalid.com/rules/FACTURAE-1.5.4.md) (error): The batch's TotalOutstandingAmount (…) is not the sum of the invoices' TotalOutstandingAmount (…).
- [FACTURAE-1.5.5](https://xmlvalid.com/rules/FACTURAE-1.5.5.md) (error): The batch's TotalExecutableAmount (…) is not the sum of the invoices' TotalExecutableAmount (…).
- [FACTURAE-3.1.5.1](https://xmlvalid.com/rules/FACTURAE-3.1.5.1.md) (error): TotalGrossAmount (…) is not the sum of the lines' GrossAmount (…).
- [FACTURAE-3.1.5.4](https://xmlvalid.com/rules/FACTURAE-3.1.5.4.md) (error): TotalGeneralDiscounts (…) is not the sum of the GeneralDiscounts (…).
- [FACTURAE-3.1.5.5](https://xmlvalid.com/rules/FACTURAE-3.1.5.5.md) (error): TotalGeneralSurcharges (…) is not the sum of the GeneralSurcharges (…).
- [FACTURAE-3.1.5.7](https://xmlvalid.com/rules/FACTURAE-3.1.5.7.md) (error): TotalTaxOutputs (…) is not the sum of the tax and equivalence surcharge amounts in TaxesOutputs (…).
- [FACTURAE-3.1.5.14](https://xmlvalid.com/rules/FACTURAE-3.1.5.14.md) (error): TotalOutstandingAmount (…) must be InvoiceTotal - (subsidies + TotalPaymentsOnAccount) (…).
- [FACTURAE-3.1.5.15](https://xmlvalid.com/rules/FACTURAE-3.1.5.15.md) (error): TotalPaymentsOnAccount (…) is not the sum of the PaymentOnAccountAmount (…).
- [FACTURAE-3.1.5.17](https://xmlvalid.com/rules/FACTURAE-3.1.5.17.md) (error): TotalExecutableAmount (…) must be TotalOutstandingAmount - amounts withheld - payment in kind + TotalReimbursableExpenses + TotalFinancialExpenses (…).
- [FACTURAE-3.1.6.1.17](https://xmlvalid.com/rules/FACTURAE-3.1.6.1.17.md) (error): TotalCost (…) is not Quantity × UnitPriceWithoutTax (…).
- [FACTURAE-3.1.6.1.20](https://xmlvalid.com/rules/FACTURAE-3.1.6.1.20.md) (error): GrossAmount (…) is not TotalCost - DiscountAmount + ChargeAmount (…).
- [HAP1650-3a](https://xmlvalid.com/rules/HAP1650-3a.md) (error): The invoice number (InvoiceNumber) is empty.
- [HAP1650-4b](https://xmlvalid.com/rules/HAP1650-4b.md) (error): A corrective invoice (InvoiceClass …) needs Corrective with the correction method….
- [HAP1650-5b](https://xmlvalid.com/rules/HAP1650-5b.md) (error): The …'s NIF (…) doesn't follow the rules a Spanish NIF is formed by: its check character doesn't match.
- [HAP1650-5d](https://xmlvalid.com/rules/HAP1650-5d.md) (error): The … is a person (Individual), so Name and FirstSurname must not be empty.
- [HAP1650-5e](https://xmlvalid.com/rules/HAP1650-5e.md) (error): The … is a legal entity, so CorporateName must not be empty.
- [HAP1650-5f](https://xmlvalid.com/rules/HAP1650-5f.md) (error): The assignee's tax number (FactoringAssignmentData/Assignee) is the seller's (…); they must differ.
- [HAP1650-6a](https://xmlvalid.com/rules/HAP1650-6a.md) (error): In an invoice in euros, a line's TotalCost (…) must be Quantity × UnitPriceWithoutTax rounded to cents (…), its GrossAmount (…) TotalCost - discounts + charges (…), and its other amounts rounded to cents….
- [HAP1650-6b](https://xmlvalid.com/rules/HAP1650-6b.md) (error): In an invoice in euros, TotalGrossAmount (…) must be the sum of the lines' GrossAmount (…), and every amount must be rounded to cents….
- [HAP1650-6d](https://xmlvalid.com/rules/HAP1650-6d.md) (error): TotalGrossAmountBeforeTaxes is positive, so TotalTaxesWithheld may not be negative (…).
- [HAP1650-6e](https://xmlvalid.com/rules/HAP1650-6e.md) (error): TotalGrossAmountBeforeTaxes (…) must be TotalGrossAmount - TotalGeneralDiscounts + TotalGeneralSurcharges (…).
- [HAP1650-6f](https://xmlvalid.com/rules/HAP1650-6f.md) (error): InvoiceTotal (…) must be TotalGrossAmountBeforeTaxes + TotalTaxOutputs - TotalTaxesWithheld (…).
- [HAP1650-8a](https://xmlvalid.com/rules/HAP1650-8a.md) (error): The buyer is a public administration (NIF …), so its administrative centres must give all three DIR3 codes: the accounting office (01), the managing body (02) and the processing unit (03)….
- [HAP1650-9b](https://xmlvalid.com/rules/HAP1650-9b.md) (error): The line's description (ItemDescription) is empty.
- [XV-ES-01](https://xmlvalid.com/rules/XV-ES-01.md) (error): A Spanish NIF has no valid check character, so the AEAT won't find it in its census ('…' in BuyerParty/TaxIdentificationNumber).
