> ## 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 SII V1.x

Key: `es-sii-v1`

## Sources

* [Suministro Inmediato de Información (SII) at AEAT portal](https://sede.agenciatributaria.gob.es/Sede/iva/suministro-inmediato-informacion.html)

## 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-sii-doc-type`

## Scenarios

### bill/invoice

<Accordion title="Standard Invoice">
  **Filters:**

  * **Types:** `standard`

  **Output:**

  * **Extensions:** `es-sii-doc-type:F1`
</Accordion>

<Accordion title="Simplified Invoice">
  **Filters:**

  * **Types:** `standard`
  * **Tags:** `simplified`

  **Output:**

  * **Extensions:** `es-sii-doc-type:F2`
</Accordion>

<Accordion title="Replacement Invoice">
  **Filters:**

  * **Types:** `standard`
  * **Tags:** `replacement`

  **Output:**

  * **Extensions:** `es-sii-doc-type:F3`
</Accordion>

<Accordion title="Simplified Corrective Invoice">
  **Filters:**

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

  **Output:**

  * **Extensions:** `es-sii-doc-type:R5`
</Accordion>

## Extensions

### Invoice Type

Code used to identify the type of invoice being sent or received. This will be determined
automatically by GOBL during normalization according to the scenario definitions.

The following codes are not covered by GOBL's scenarios and will need to be set manually if
needed: `F4`, `F5`, `F6`, `R2`, `R3`, `R4`, `AJ`, `LC`.

Maps to the `TipoFactura` field. Values correspond to the L2\_EMI (issued invoices) and
L2\_RECI (received invoices) lists.

<Accordion title="es-sii-doc-type">
  | Code | Name                                                |
  | ---- | --------------------------------------------------- |
  | `F1` | Invoice (Article 6, 7.2 and 7.3 of RD 1619/2012)    |
  | `F2` | Simplified invoice (Article 6.1.d) of RD 1619/2012) |
  | `F3` | Invoice issued as replacement of simplified invoice |
  | `F4` | Summary entry of invoices                           |
  | `F5` | Imports (DUA)                                       |
  | `F6` | Accounting justifications                           |
  | `R1` | Rectified invoice: articles 80.1, 80.2, and 80.6    |
  | `R2` | Rectified invoice: article 80.3                     |
  | `R3` | Rectified invoice: article 80.4                     |
  | `R4` | Rectified invoice: other                            |
  | `R5` | Rectified invoice: simplified invoices              |
  | `AJ` | Profit margin adjustment                            |
  | `LC` | Customs - Complementary settlement                  |
</Accordion>

### Corrective Invoice Type

Correction type code used to identify the type of correction being made.

Code is determined automatically according to the invoice type:

| Invoice Type  | Code |
| ------------- | ---- |
| `corrective`  | `S`  |
| `credit-note` | `I`  |
| `debit-note`  | `I`  |

Maps to the `TipoRectificativa` field. Values correspond to the L5 list.

<Accordion title="es-sii-correction-type">
  | Code | Name         |
  | ---- | ------------ |
  | `S`  | Substitution |
  | `I`  | Differences  |
</Accordion>

### Exemption Reason

Exemption code used to explain why the operation is exempt from taxes.

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

Maps to the field `CausaExencion`. Values correspond to the L9 list.

Note: This extension is **mutually exclusive** with `es-sii-outside-scope`.

<Accordion title="es-sii-exempt">
  | Code | Name                                                                                                     |
  | ---- | -------------------------------------------------------------------------------------------------------- |
  | `E1` | Exempt pursuant to Art. 20 (internal operations).                                                        |
  | `E2` | Exempt pursuant to Art. 21 (exports of goods).                                                           |
  | `E3` | Exempt pursuant to Art. 22 (operations asimilated to exports).                                           |
  | `E4` | Exempt pursuant to Art. 23 and 24 (temporary deposit, customs and fiscal regimes, and other situations). |
  | `E5` | Exempt pursuant to Art. 25 (delivery of goods destined to another Member State).                         |
  | `E6` | Exempt pursuant to other reasons                                                                         |
</Accordion>

### Type of Operation Outside Scope

Type of operation not subject to VAT.

This extension is used to determine which tax amount field should be reported in the SII
payload:

* `other` will set the `ImportePorArticulos7_14_Otros` field.
* `location` will set the `ImporteTAIReglasLocalizacion` field.

GOBL will attempt to automatically assign operation type codes based on tax key:

| Operation Type | Tax Key                   |
| -------------- | ------------------------- |
| `other`        | `outside-scope`           |
| `location`     | `outside-scope` (default) |

Doesn't map directly to any field. Used internally to determine how to report the tax amount.

Note: This extension is **mutually exclusive** with `es-sii-exempt`.

<Accordion title="es-sii-outside-scope">
  | Code       | Name                                   |
  | ---------- | -------------------------------------- |
  | `other`    | Outside scope - Articles 7, 14, others |
  | `location` | Outside scope - Due to location rules  |
</Accordion>

### Special Regime or Relevance Key

Identify the regime applied to the operation.

The regime key must be assigned for each tax combo. If no regime key is provided, GOBL will
try to assign a code from the following tax combo contexts:

| Combo Context  | Regime Code |
| -------------- | ----------- |
| Key `standard` | `01`        |
| Key `export`   | `02`        |

Maps to the field `ClaveRegimenEspecialOTrascendencia`. Values correspond to the L3.1
(issued invoices) and L3.2 (received invoices) lists.

<Accordion title="es-sii-regime">
  | Code | Name                                                                                                                                                                         |
  | ---- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
  | `01` | General regime operation                                                                                                                                                     |
  | `02` | Export (L3.1) / Operations for which businesses pay compensation in acquisitions from individuals under the special regime for agriculture, livestock, and fishing (L3.2)    |
  | `03` | Special regime for used goods, art objects, antiques and collectibles                                                                                                        |
  | `04` | Special regime for investment gold                                                                                                                                           |
  | `05` | Special regime for travel agencies                                                                                                                                           |
  | `06` | Special regime for VAT/IGIC groups (Advanced Level)                                                                                                                          |
  | `07` | Special cash accounting regime                                                                                                                                               |
  | `08` | Operations subject to IPSI / IGIC (Tax on Production, Services and Imports / Canary Islands General Indirect Tax)                                                            |
  | `09` | Billing of travel agency services acting as mediators in name and on behalf of others                                                                                        |
  | `10` | Collection of professional fees or rights on behalf of third parties                                                                                                         |
  | `11` | Business premises rental operations                                                                                                                                          |
  | `12` | Business premises rental operations not subject to withholding                                                                                                               |
  | `13` | Business premises rental operations subject and not subject to withholding (L3.1) / Invoice corresponding to an import (reported without being associated with a DUA) (L3.2) |
  | `14` | Invoice with pending VAT/IGIC accrual in work certifications for Public Administration (L3.1) / First half of 2017 and other invoices prior to inclusion in the SII (L3.2)   |
  | `15` | Invoice with pending VAT/IGIC accrual in successive tract operations                                                                                                         |
  | `16` | First half of 2017 and other invoices prior to inclusion in the SII                                                                                                          |
  | `17` | Operation covered by one of the regimes provided for in Chapter XI of Title IX (OSS and IOSS)                                                                                |
</Accordion>

### Identification Type

Identity code used to identify the type of identity document used by the customer.

The regular Party Tax Identity is preferred over using a specific identity type code, and
will be mapped automatically as follows:

* Spanish Tax IDs will be mapped to the `NIF` field.
* EU Tax IDs will be mapped to the `IDOtro\IDType` field with code `02`.
* Non-EU Tax IDs will be mapped to the `IDOtro\IDType` field with code `04`.

SII will perform validation on both Spanish and EU Tax IDs, so it is important to provide
the correct details.

The following identity `key` values will be mapped automatically to an extension by the
addon:

| Identity Key | Code |
| ------------ | ---- |
| `passport`   | `03` |
| `foreign`    | `04` |
| `resident`   | `05` |
| `other`      | `06` |

The `07` "not registered in census" code is not mapped automatically, but can be provided
directly if needed.

Example identity of a UK passport:

```
{
	"identities": [
		{
			"key": "passport",
			"country": "GB",
			"code": "123456789"
		}
	]
}
```

Will be normalized to:

```
{
	"identities": [
		{
			"key": "passport",
			"country": "GB",
			"code": "123456789",
			"ext": {
				"es-sii-identity-type": "03"
			}
		}
	]
}
```

Maps to the field `IDOtro\IDType`. Values correspond to the L4 list.

<Accordion title="es-sii-identity-type">
  | Code | Name                      |
  | ---- | ------------------------- |
  | `02` | NIF-VAT Identity (VIES)   |
  | `03` | Passport                  |
  | `04` | Foreign Identity Document |
  | `05` | Residential Certificate   |
  | `06` | Other Identity Document   |
  | `07` | Not registered in census  |
</Accordion>

### Simplified Invoice Art. 7.2 and 7.3, RD 1619/2012

This extension covers a specific use-case when the customer specifically requests that the
invoice includes their fiscal details, but they are not registered for tax.

Can only be true when the invoice type (`TipoFactura`) is one of: `F1`, `F3`, `R1`, `R2`,
`R3`, or `R4`.

Maps to the `FacturaSimplificadaArticulos7.2_7.3` field. Values correspond to the L26 list.

<Accordion title="es-sii-simplified-art7273">
  | Code | Name |
  | ---- | ---- |
  | `S`  | Yes  |
  | `N`  | No   |
</Accordion>

### Issued by Third Party or Recipient

Indicates whether the invoice is issued by a third party or by the customer themselves.

The default value is `N` (No).

The `self-billed` tag will automatically set this extension in the invoice to `S` (Yes).

If the `issuer` field is set in the invoice's ordering section, then this extension will be
set to `S` (Yes) too.

Maps to the field `EmitidaPorTercerosODestinatario`. Values correspond to the L10 list.

<Accordion title="es-sii-third-party-issuer">
  | Code | Name |
  | ---- | ---- |
  | `S`  | Yes  |
  | `N`  | No   |
</Accordion>

### Product Type

Product type code used to differentiate between goods and services for the purpose of
reporting breakdowns in the SII format.

This extension is used to determine the type of operation breakdown when generating the SII
report. When provided, the value will be used to generate the `DesgloseTipoOperacion` field,
selecting between `PrestacionServices` (provision of services) or `Entrega` (delivery of
goods).

This extension is optional; if not provided, the breakdown will use `DesgloseFactura` instead
of `DesgloseTipoOperacion`.

Doesn't map directly to any field. Used internally to structure the breakdown data.

<Accordion title="es-sii-product">
  | Code       | Name                  |
  | ---------- | --------------------- |
  | `goods`    | Delivery of goods     |
  | `services` | Provision of services |
</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-SII-BILL-INVOICE-15`<br />Invoice must be in EUR or provide exchange rate for conversion              |
    | `preceding`               | <ul class="gobl-test"><li>Invoice type in \[corrective]</li><li class="gobl-test-present">Present</li></ul>                                       | `GOBL-ES-SII-BILL-INVOICE-01`<br />Preceding documents are required for corrective invoices                    |
    | `preceding[*].issue_date` | <ul class="gobl-test"><li class="gobl-test-present">Present</li></ul>                                                                             | `GOBL-ES-SII-BILL-INVOICE-02`<br />Preceding issue date is required                                            |
    | `preceding[*].tax`        | <ul class="gobl-test"><li>Invoice type in \[corrective]</li><li class="gobl-test-present">Present</li></ul>                                       | `GOBL-ES-SII-BILL-INVOICE-03`<br />Preceding invoice tax data is required for corrective invoices              |
    | `customer`                | <ul class="gobl-test"><li>Not simplified</li><li class="gobl-test-present">Present</li></ul>                                                      | `GOBL-ES-SII-BILL-INVOICE-04`<br />Customer is required                                                        |
    | `customer`                | <ul class="gobl-test"><li>Not simplified</li><li>Has tax\_id or identity</li></ul>                                                                | `GOBL-ES-SII-BILL-INVOICE-05`<br />Must have a tax\_id, or an identity with ext 'es-sii-identity-type'         |
    | `customer.tax_id.code`    | <ul class="gobl-test"><li>Not simplified</li><li class="gobl-test-present">Present</li></ul>                                                      | `GOBL-ES-SII-BILL-INVOICE-06`<br />Customer tax ID must have a code                                            |
    | `tax`                     | <ul class="gobl-test"><li class="gobl-test-present">Present</li></ul>                                                                             | `GOBL-ES-SII-BILL-INVOICE-07`<br />Tax object is required with extensions                                      |
    | `tax.ext`                 | <ul class="gobl-test"><li>Ext require \[es-sii-doc-type]</li></ul>                                                                                | `GOBL-ES-SII-BILL-INVOICE-08`<br />Tax extension 'es-sii-doc-type' is required                                 |
    | `tax.ext`                 | <ul class="gobl-test"><li>Ext 'es-sii-doc-type' in \[R1, R2, R3, R4, R5]</li><li>Ext require \[es-sii-correction-type]</li></ul>                  | `GOBL-ES-SII-BILL-INVOICE-09`<br />Tax extension 'es-sii-correction-type' is required                          |
    | `tax.ext`                 | <ul class="gobl-test"><li>Invoice type in \[standard]</li><li>Ext 'es-sii-doc-type' in \[F1, F2, F3]</li></ul>                                    | `GOBL-ES-SII-BILL-INVOICE-10`<br />Tax extension 'es-sii-doc-type' for standard invoices must be F1, F2, or F3 |
    | `tax.ext`                 | <ul class="gobl-test"><li>Invoice type in \[corrective, credit-note, debit-note]</li><li>Ext 'es-sii-doc-type' in \[R1, R2, R3, R4, R5]</li></ul> | `GOBL-ES-SII-BILL-INVOICE-11`<br />Doc type extension for corrective invoices must be R1, R2, R3, R4, or R5    |
    | `notes[*].text`           | <ul class="gobl-test"><li>General note</li><li>Length between 0 and 500</li></ul>                                                                 | `GOBL-ES-SII-BILL-INVOICE-12`<br />General note text must be 500 characters or less                            |
    | `lines`                   | <ul class="gobl-test"><li>Consistent product</li></ul>                                                                                            | `GOBL-ES-SII-BILL-INVOICE-13`<br />'es-sii-product' must be present in all tax combos or none                  |
    | `lines`                   | <ul class="gobl-test"><li>Same regime</li></ul>                                                                                                   | `GOBL-ES-SII-BILL-INVOICE-14`<br />'es-sii-regime' must be the same in all tax combos                          |
  </Accordion>

  <Accordion title="tax.Combo">
    | Field | Test                                                                                                          | Validation Code / Message                                                                                    |
    | ----- | ------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ |
    | `ext` | <ul class="gobl-test"><li>Sii vat/igic</li><li>Ext require \[es-sii-regime]</li></ul>                         | `GOBL-ES-SII-TAX-COMBO-01`<br />Extension 'es-sii-regime' is required                                        |
    | `ext` | <ul class="gobl-test"><li>Has outside scope</li><li>Ext exclude \[es-sii-exempt]</li></ul>                    | `GOBL-ES-SII-TAX-COMBO-03`<br />Extension 'es-sii-exempt' must not be set when 'es-sii-outside-scope' is set |
    | `ext` | <ul class="gobl-test"><li>Ext 'es-sii-regime' in \[01]</li><li>Ext 'es-sii-exempt' not in \[E2, E3]</li></ul> | `GOBL-ES-SII-TAX-COMBO-04`<br />Exempt codes E2 and E3 not allowed with 'es-sii-regime' 01                   |
    | `ext` | <ul class="gobl-test"><li>Has percent</li><li>Ext exclude \[es-sii-exempt]</li></ul>                          | `GOBL-ES-SII-TAX-COMBO-02`<br />Extension 'es-sii-exempt' must not be set when percent is set                |
  </Accordion>
</AccordionGroup>
