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

Key: `es-tbai-v1`

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

## Extensions

### TicketBAI Region Code

Region codes are used by TicketBAI to differentiate between the different
subdivisions of the Basque Country. This is used to determine the correct
API endpoint to use when submitting documents.

<Accordion title="es-tbai-region">
  | Code | Name     |
  | ---- | -------- |
  | `VI` | Araba    |
  | `BI` | Bizkaia  |
  | `SS` | Gipuzkoa |
</Accordion>

### TicketBAI Product Key

Product keys are used by TicketBAI to differentiate between -exported- goods
and services. It may be useful to classify all products regardless of wether
they are exported or not.

There is an additional exception case for goods that are resold without modification
when the supplier is in the simplified tax regime. For must purposes this special
case can be ignored.

If no product key is provided, the default is "services".

<Accordion title="es-tbai-product">
  | Code       | Name                                                                    |
  | ---------- | ----------------------------------------------------------------------- |
  | `goods`    | Delivery of goods                                                       |
  | `services` | Provision of services                                                   |
  | `resale`   | Resale of goods without modification by vendor in the simplified regime |
</Accordion>

### TicketBAI Exemption code

Codes used by TicketBAI for both "exempt", "not-subject", and reverse
charge transactions. In the TicketBAI format these are separated,
but in order to simplify GOBL and be more closely aligned with
other countries we've combined them into one.

The follow mappings will be made automatically by GOBL during normalization.

| Tax Key           | Exemption Codes            |
| ----------------- | -------------------------- |
| `exempt`          | `E1` (default), `E6`       |
| `export`          | `E2` (default), `E3`, `E4` |
| `intra-community` | `E5`                       |
| `reverse-charge`  | `S2`                       |
| `outside-scope`   | `OT`, `RL`, `VT`, `IE`     |

<Accordion title="es-tbai-exemption">
  | Code | Name                                                                                                                         |
  | ---- | ---------------------------------------------------------------------------------------------------------------------------- |
  | `E1` | Exempt: pursuant to Article 20 of the Foral VAT Law                                                                          |
  | `E2` | Exempt: pursuant to Article 21 of the Foral VAT Law                                                                          |
  | `E3` | Exempt: pursuant to Article 22 of the Foral VAT Law                                                                          |
  | `E4` | Exempt: pursuant to Articles 23 and 24 of the Foral VAT Law                                                                  |
  | `E5` | Exempt: pursuant to Article 25 of the Foral VAT law                                                                          |
  | `E6` | Exempt: pursuant to other reasons                                                                                            |
  | `OT` | Not subject: pursuant to Article 7 of the VAT Law - other cases of non-subject                                               |
  | `RL` | Not subject: pursuant to localization rules                                                                                  |
  | `VT` | Not subject: sales made on behalf of third parties (amount not computable for VAT or IRPF purposes)                          |
  | `IE` | Not subject in the TAI due to localization rules, but foreign tax, IPS/IGIC or VAT from another EU member state is passed on |
  | `S2` | Subject and not exempt: with reverse charge                                                                                  |
</Accordion>

### TicketBAI Rectification Type Code

Corrected or rectified invoices that need to be sent in the TicketBAI format
require a specific type code to be defined alongside the preceding invoice
data.

<Accordion title="es-tbai-correction">
  | Code | Name                                                                                                   |
  | ---- | ------------------------------------------------------------------------------------------------------ |
  | `R1` | Rectified invoice: error based on law and Article 80 One, Two and Six of the Provincial Tax Law of VAT |
  | `R2` | Rectified invoice: error based on law and Article 80 Three of the Provincial Tax Law of VAT            |
  | `R3` | Rectified invoice: error based on law and Article 80 Four of the Provincial Tax Law of VAT             |
  | `R4` | Rectified invoice: Other                                                                               |
  | `R5` | Rectified invoice: simplified invoices                                                                 |
</Accordion>

### Activity Code (Bizkaia)

Economic activity code (epígrafe) for individual issuers submitting through
Bizkaia's LROE Modelo 140 register. Not required for organisations, who
file through Modelo 240.

<Accordion title="es-tbai-bi-activity">
  Pattern: `^\d{1,7}$`
</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-TBAI-BILL-INVOICE-09`<br />Invoice must be in EUR or provide exchange rate for conversion                    |
    | `tax`                     | <ul class="gobl-test"><li class="gobl-test-present">Present</li></ul>                                                                | `GOBL-ES-TBAI-BILL-INVOICE-01`<br />Tax is required                                                                   |
    | `tax.ext`                 | <ul class="gobl-test"><li>Ext require \[es-tbai-region]</li></ul>                                                                    | `GOBL-ES-TBAI-BILL-INVOICE-02`<br />Extension 'es-tbai-region' is required                                            |
    | `customer`                | <ul class="gobl-test"><li>Non-simplified</li><li class="gobl-test-present">Present</li></ul>                                         | `GOBL-ES-TBAI-BILL-INVOICE-03`<br />Customer is required for non-simplified invoices                                  |
    | `customer.tax_id`         | <ul class="gobl-test"><li>Non-simplified</li><li class="gobl-test-present">Present</li></ul>                                         | `GOBL-ES-TBAI-BILL-INVOICE-08`<br />Customer tax ID is required                                                       |
    | `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-TBAI-BILL-INVOICE-04`<br />Preceding documents are required for credit-note, corrective, debit-note invoices |
    | `preceding[*].issue_date` | <ul class="gobl-test"><li class="gobl-test-present">Present</li></ul>                                                                | `GOBL-ES-TBAI-BILL-INVOICE-05`<br />Preceding issue date is required                                                  |
    | `preceding[*].ext`        | <ul class="gobl-test"><li>Ext require \[es-tbai-correction]</li></ul>                                                                | `GOBL-ES-TBAI-BILL-INVOICE-06`<br />Preceding ext 'es-tbai-correction' is required                                    |
    | `notes`                   | <ul class="gobl-test"><li>Has general note</li></ul>                                                                                 | `GOBL-ES-TBAI-BILL-INVOICE-07`<br />With key 'general' missing                                                        |
    | `supplier.ext`            | <ul class="gobl-test"><li>Bizkaia individual</li><li>Ext require \[es-tbai-bi-activity]</li></ul>                                    | `GOBL-ES-TBAI-BILL-INVOICE-10`<br />Extension 'es-tbai-bi-activity' is required for Bizkaia individuals               |
    | `supplier.ext`            | <ul class="gobl-test"><li>Ext 'es-tbai-bi-activity' matches pattern '^\d{1,7}\$'</li></ul>                                           | `GOBL-ES-TBAI-BILL-INVOICE-11`<br />Extension 'es-tbai-bi-activity' must be a valid Bizkaia activity code (epígrafe)  |
  </Accordion>

  <Accordion title="tax.Combo">
    | Field | Test                                                                                         | Validation Code / Message                                                                        |
    | ----- | -------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------ |
    | `ext` | <ul class="gobl-test"><li>Exempt vat/igic</li><li>Ext require \[es-tbai-exemption]</li></ul> | `GOBL-ES-TBAI-TAX-COMBO-01`<br />Extension 'es-tbai-exemption' is required for exempt tax combos |
  </Accordion>
</AccordionGroup>
