> ## 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`

## Correction Definitions

Auto-generation of corrective invoices or credit and debit notes is
supported.

### 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

### bill/invoice

<Accordion title="standard, corrective, credit-note, debit-note">
  **Filters:**

  * **Types:** `standard`, `corrective`, `credit-note`, `debit-note`

  **Output:**

  * **Extensions:** `es-facturae-doc-type:FC`
</Accordion>

<Accordion title="#simplified">
  **Filters:**

  * **Tags:** `simplified`

  **Output:**

  * **Extensions:** `es-facturae-doc-type:FA`
</Accordion>

<Accordion title="#self-billed">
  **Filters:**

  * **Tags:** `self-billed`

  **Output:**

  * **Extensions:** `es-facturae-doc-type:AF`
</Accordion>

<Accordion title="standard">
  **Filters:**

  * **Types:** `standard`

  **Output:**

  * **Extensions:** `es-facturae-invoice-class:OO`
</Accordion>

<Accordion title="corrective, credit-note, debit-note">
  **Filters:**

  * **Types:** `corrective`, `credit-note`, `debit-note`

  **Output:**

  * **Extensions:** `es-facturae-invoice-class:OR`
</Accordion>

<Accordion title="#summary">
  **Filters:**

  * **Tags:** `summary`

  **Output:**

  * **Extensions:** `es-facturae-invoice-class:OC`
</Accordion>

<Accordion title="standard, #copy">
  **Filters:**

  * **Types:** `standard`
  * **Tags:** `copy`

  **Output:**

  * **Extensions:** `es-facturae-invoice-class:CO`
</Accordion>

<Accordion title="corrective, #copy">
  **Filters:**

  * **Types:** `corrective`
  * **Tags:** `copy`

  **Output:**

  * **Extensions:** `es-facturae-invoice-class:CR`
</Accordion>

<Accordion title="standard, #copy, #summary">
  **Filters:**

  * **Types:** `standard`
  * **Tags:** `copy`, `summary`

  **Output:**

  * **Extensions:** `es-facturae-invoice-class:CC`
</Accordion>

## 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 title="es-facturae-subsidy">
  | Code | Name |
  | ---- | ---- |
  | `S`  | Yes  |
  | `N`  | No   |
</Accordion>

### FacturaE: Document Type

<Accordion title="es-facturae-doc-type">
  | Code | Name                |
  | ---- | ------------------- |
  | `FC` | Commercial Invoice  |
  | `FA` | Simplified Invoice  |
  | `AF` | Self-billed Invoice |
</Accordion>

### FacturaE: Invoice Class

<Accordion title="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    |
</Accordion>

### FacturaE Change

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

<Accordion title="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 |
</Accordion>

## Validation Rules

<AccordionGroup>
  <Accordion title="bill.Invoice">
    | Field                     | Test                                                                                                                                     | Validation Code / Message                                                                                                         |
    | ------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
    | <small>Invoice</small>    | <ul class="gobl-test"><li>Can convert to \[EUR]</li></ul>                                                                                | `GOBL-ES-FACTURAE-BILL-INVOICE-07`<br />Invoice must be in EUR or provide exchange rate for conversion                            |
    | `customer.tax_id.code`    | <ul class="gobl-test"><li>Code in \[ES]</li><li class="gobl-test-present">Present</li></ul>                                              | `GOBL-ES-FACTURAE-BILL-INVOICE-01`<br />Customer tax ID code is required for Spanish customers                                    |
    | `tax`                     | <ul class="gobl-test"><li class="gobl-test-present">Present</li></ul>                                                                    | `GOBL-ES-FACTURAE-BILL-INVOICE-02`<br />Tax object is required with ext document type and invoice classes                         |
    | `tax.ext`                 | <ul class="gobl-test"><li>Ext require \[es-facturae-doc-type, es-facturae-invoice-class]</li></ul>                                       | `GOBL-ES-FACTURAE-BILL-INVOICE-03`<br />Tax ext require 'es-facturae-doc-type' and 'es-facturae-invoice-class' extensions         |
    | `preceding`               | <ul class="gobl-test"><li>Invoice type in \[credit-note, corrective, debit-note]</li><li class="gobl-test-present">Present</li></ul>     | `GOBL-ES-FACTURAE-BILL-INVOICE-04`<br />Preceding document reference is required for credit-note, corrective, debit-note invoices |
    | `preceding[*].issue_date` | <ul class="gobl-test"><li>Invoice type in \[credit-note, corrective, debit-note]</li><li class="gobl-test-present">Present</li></ul>     | `GOBL-ES-FACTURAE-BILL-INVOICE-05`<br />Preceding document issue date is required                                                 |
    | `preceding[*].ext`        | <ul class="gobl-test"><li>Invoice type in \[credit-note, corrective, debit-note]</li><li>Ext require \[es-facturae-correction]</li></ul> | `GOBL-ES-FACTURAE-BILL-INVOICE-06`<br />Preceding document ext require 'es-facturae-correction' extension                         |
  </Accordion>
</AccordionGroup>
