> ## Documentation Index
> Fetch the complete documentation index at: https://docs.gobl.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Spain FacturaE

Key: `es-facturae-v3`

Module: [github.com/invopop/gobl.es.facturae](https://github.com/invopop/gobl.es.facturae)

## Correction Definitions

### Extension Keys

One or all of the following extensions may be required as part of the correction
options. See the [Extensions](#extensions) section for possible values.

* `es-facturae-correction`

## Scenarios

Scenarios attach notes and extensions to a document when its filters match.
[Read more about scenarios](https://docs.gobl.org/overview/scenarios.md).

> [accordion] bill/invoice
>
> | Tags | Type | Output |
> | - | - | - |
> | - | `standard` `corrective` `credit-note` `debit-note` | `{  "ext": {    "es-facturae-doc-type": "FC"  }}` |
> | `simplified` | - | `{  "ext": {    "es-facturae-doc-type": "FA"  }}` |
> | `self-billed` | - | `{  "ext": {    "es-facturae-doc-type": "AF"  }}` |
> | - | `standard` | `{  "ext": {    "es-facturae-invoice-class": "OO"  }}` |
> | - | `corrective` `credit-note` `debit-note` | `{  "ext": {    "es-facturae-invoice-class": "OR"  }}` |
> | `summary` | - | `{  "ext": {    "es-facturae-invoice-class": "OC"  }}` |
> | `copy` | `standard` | `{  "ext": {    "es-facturae-invoice-class": "CO"  }}` |
> | `copy` | `corrective` | `{  "ext": {    "es-facturae-invoice-class": "CR"  }}` |
> | `copy` `summary` | `standard` | `{  "ext": {    "es-facturae-invoice-class": "CC"  }}` |

## Extensions

### FacturaE: Subsidy

Indicates that an advance payment came from a public grant or subsidy. Set on a payment Record's `ext` map; replaces the previous `pay.Record.Grant` boolean field.

> [accordion] es-facturae-subsidy
>
> | Code | Name |
> | - | - |
> | `S` | Yes |
> | `N` | No |

### FacturaE: Document Type

> [accordion] es-facturae-doc-type
>
> | Code | Name |
> | - | - |
> | `FC` | Commercial Invoice |
> | `FA` | Simplified Invoice |
> | `AF` | Self-billed Invoice |

### FacturaE: Invoice Class

> [accordion] es-facturae-invoice-class
>
> | Code | Name |
> | - | - |
> | `OO` | Original |
> | `OR` | Corrective Original |
> | `OC` | Summary Original |
> | `CO` | Copy of the Original |
> | `CR` | Copy of the Corrective |
> | `CC` | Copy of the Summary |

### FacturaE Change

FacturaE requires a specific and single code that explains why the previous invoice is being corrected.

> [accordion] es-facturae-correction
>
> | Code | Name |
> | - | - |
> | `01` | Invoice code |
> | `02` | Invoice series |
> | `03` | Issue date |
> | `04` | Name and surnames/Corporate name - Issuer (Sender) |
> | `05` | Name and surnames/Corporate name - Receiver |
> | `06` | Issuer's Tax Identification Number |
> | `07` | Receiver's Tax Identification Number |
> | `08` | Supplier's address |
> | `09` | Customer's address |
> | `10` | Item line |
> | `11` | Applicable Tax Rate |
> | `12` | Applicable Tax Amount |
> | `13` | Applicable Date/Period |
> | `14` | Invoice Class |
> | `15` | Legal literals |
> | `16` | Taxable Base |
> | `80` | Calculation of tax outputs |
> | `81` | Calculation of tax inputs |
> | `82` | Taxable Base modified due to return of packages and packaging materials |
> | `83` | Taxable Base modified due to discounts and rebates |
> | `84` | Taxable Base modified due to firm court ruling or administrative decision |
> | `85` | Taxable Base modified due to unpaid outputs where there is a judgement opening insolvency proceedings |

## Validation Rules

Validation rules check each struct against a set of assertions and report any
failures with a unique code and message.
[Read more about validation](https://docs.gobl.org/overview/validation.md).

> [accordion] bill.Invoice
>
> | Field | Test | Validation Code / Message | | |
> | - | - | - | - | - |
> | Invoice | <ul><li>Can convert to \[EUR]</li></ul> | `GOBL-ES-FACTURAE-BILL-INVOICE-07` Invoice must be in EUR or provide exchange rate for conversion (FacturaE: InvoiceIssueData/ExchangeRateDetails; Art. 10.1 RD 1496/2003) | | |
> | `supplier` | <ul><li>Address country</li></ul> | `GOBL-ES-FACTURAE-BILL-INVOICE-09` Supplier address country is required (FacturaE: SellerParty/LegalEntity | Individual/OverseasAddress/CountryCode) | |
> | `supplier` | <ul><li>Individual person</li></ul> | `GOBL-ES-FACTURAE-BILL-INVOICE-10` Supplier person is required for individuals (FacturaE: SellerParty/Individual) | | |
> | `supplier.addresses` | <ul><li>Present</li></ul> | `GOBL-ES-FACTURAE-BILL-INVOICE-08` Supplier address is required (FacturaE: SellerParty/LegalEntity | Individual/AddressInSpain | OverseasAddress) |
> | `customer` | <ul><li>Tax ID present</li><li>Address country</li></ul> | `GOBL-ES-FACTURAE-BILL-INVOICE-12` Customer address country is required (FacturaE: BuyerParty/LegalEntity | Individual/OverseasAddress/CountryCode) | |
> | `customer` | <ul><li>Tax ID present</li><li>Individual person</li></ul> | `GOBL-ES-FACTURAE-BILL-INVOICE-13` Customer person is required for individuals (FacturaE: BuyerParty/Individual) | | |
> | `customer.addresses` | <ul><li>Tax ID present</li><li>Present</li></ul> | `GOBL-ES-FACTURAE-BILL-INVOICE-11` Customer address is required (FacturaE: BuyerParty/LegalEntity | Individual/AddressInSpain | OverseasAddress) |
> | `customer.tax_id.code` | <ul><li>Code in \[ES]</li><li>Present</li></ul> | `GOBL-ES-FACTURAE-BILL-INVOICE-01` Customer tax ID code is required for Spanish customers (FacturaE: BuyerParty/TaxIdentification/TaxIdentificationNumber) | | |
> | `tax` | <ul><li>Present</li></ul> | `GOBL-ES-FACTURAE-BILL-INVOICE-02` Tax object is required with ext document type and invoice classes (FacturaE: InvoiceHeader/InvoiceDocumentType, InvoiceHeader/InvoiceClass) | | |
> | `tax.ext` | <ul><li>Ext require \[es-facturae-doc-type, es-facturae-invoice-class]</li></ul> | `GOBL-ES-FACTURAE-BILL-INVOICE-03` Tax ext require 'es-facturae-doc-type' and 'es-facturae-invoice-class' extensions (FacturaE: InvoiceHeader/InvoiceDocumentType, InvoiceHeader/InvoiceClass) | | |
> | `preceding` | <ul><li>Invoice type in \[credit-note, corrective, debit-note]</li><li>Present</li></ul> | `GOBL-ES-FACTURAE-BILL-INVOICE-04` Preceding document reference is required for credit-note, corrective, debit-note invoices (FacturaE: InvoiceHeader/Corrective) | | |
> | `preceding[*].issue_date` | <ul><li>Invoice type in \[credit-note, corrective, debit-note]</li><li>Present</li></ul> | `GOBL-ES-FACTURAE-BILL-INVOICE-05` Preceding document issue date is required (FacturaE: Corrective/TaxPeriod) | | |
> | `preceding[*].ext` | <ul><li>Invoice type in \[credit-note, corrective, debit-note]</li><li>Ext require \[es-facturae-correction]</li></ul> | `GOBL-ES-FACTURAE-BILL-INVOICE-06` Preceding document ext require 'es-facturae-correction' extension (FacturaE: Corrective/ReasonCode) | | |

> [accordion] pay.DueDate
>
> | Field | Test | Validation Code / Message |
> | - | - | - |
> | `amount` | <ul><li>Present</li><li>Not zero</li></ul> | `GOBL-ES-FACTURAE-PAY-DUEDATE-01` Amount is required (FacturaE: PaymentDetails/Installment/InstallmentAmount) |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.