Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing invalid tax op code for simplified invoices #21

Merged
merged 2 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ jobs:

steps:
- name: Check out code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version-file: "go.mod"
id: go

- name: Lint
uses: golangci/golangci-lint-action@v2
uses: golangci/golangci-lint-action@v6
with:
version: v1.58
4 changes: 2 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ jobs:

steps:
- name: Check out code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version-file: "go.mod"
id: go
Expand Down
19 changes: 12 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,21 +150,22 @@ Invoice tax tags can be added to invoice documents in order to reflect a special
The following extension can be applied to each line tax:

- `es-tbai-product` – allows to correctly group the invoice's lines taxes in the TicketBAI breakdowns (a.k.a. desgloses). These are the valid values:
- `services` - indicates that the product being sold is a service (as opposed to a physical good). Services are accounted in the `DesgloseTipoOperacion > PrestacionServicios` breakdown of invoices to foreign customers. By default, all items are considered services.
- `goods` - indicates that the product being sold is a physical good. Products are accounted in the `DesgloseTipoOperacion > Entrega` breakdown of invoices to foreign customers.
- `resale` - indicates that a line item is sold without modification from a provider under the Equalisation Charge scheme. (This implies that the `OperacionEnRecargoDeEquivalenciaORegimenSimplificado` tag will be set to `S`).

- `services` - indicates that the product being sold is a service (as opposed to a physical good). Services are accounted in the `DesgloseTipoOperacion > PrestacionServicios` breakdown of invoices to foreign customers. By default, all items are considered services.
- `goods` - indicates that the product being sold is a physical good. Products are accounted in the `DesgloseTipoOperacion > Entrega` breakdown of invoices to foreign customers.
- `resale` - indicates that a line item is sold without modification from a provider under the Equalisation Charge scheme. (This implies that the `OperacionEnRecargoDeEquivalenciaORegimenSimplificado` tag will be set to `S`).

- `es-tbai-exemption` - identifies the specific TicketBAI reason code as to why taxes should not be applied to the line according to the whole set of exemptions or not-subject scenarios defined in the law. It has to be set along with the tax rate value of `exempt`. These are the valid values:
- `E1` – Exenta por el artículo 20 de la Norma Foral del IVA
- `E1` – Exenta por el artículo 20 de la Norma Foral del IVA
- `E2` – Exenta por el artículo 21 de la Norma Foral del IVA
- `E3` – Exenta por el artículo 22 de la Norma Foral del IVA
- `E4` – Exenta por el artículo 23 y 24 de la Norma Foral del IVA
- `E5` – Exenta por el artículo 25 de la Norma Foral del IVA
- `E6` – Exenta por otra causa
- `OT` – No sujeto por el artículo 7 de la Norma Foral de IVA / Otros supuestos
- `RL` – No sujeto por reglas de localización (*)
- `RL` – No sujeto por reglas de localización (\*)

_(*) As noted elsewhere, `RL` will be set automatically set in invoices using the `customer-rates` tax tag. It can also be set explicitly using the `es-tbai-exemption` extension in invoices not using that tag._
_(\*) As noted elsewhere, `RL` will be set automatically set in invoices using the `customer-rates` tax tag. It can also be set explicitly using the `es-tbai-exemption` extension in invoices not using that tag._

### Use-Cases

Expand All @@ -181,6 +182,10 @@ Under what situations should the TicketBAI system be expected to function:

Some sample test data is available in the `./test` directory.

If you make any modifications to the source YAML files, the JSON envelopes will need to be updated.
If you make any modifications to the source YAML files, the JSON envelopes will need to be updated, for example:

```bash
gobl build -i --envelop test/data/invoice-es-es-b2c.yaml > test/data/invoice-es-es-b2c.json
```

Make sure you have the GOBL CLI installed ([more details](https://docs.gobl.org/quick-start/cli)).
2 changes: 1 addition & 1 deletion internal/doc/invoice.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func newRetencionSoportada(inv *bill.Invoice) string {
func newClaves(inv *bill.Invoice) []IDClave {
claves := []IDClave{}

if partyTaxCountry(inv.Customer) != "ES" {
if inv.Customer != nil && partyTaxCountry(inv.Customer) != "ES" {
claves = append(claves, IDClave{
ClaveRegimenIvaOpTrascendencia: "02",
})
Expand Down
166 changes: 166 additions & 0 deletions test/data/invoice-es-es-b2c.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
{
"$schema": "https://gobl.org/draft-0/envelope",
"head": {
"uuid": "0192d3c7-2dc5-74cf-b263-5892feb44432",
"dig": {
"alg": "sha256",
"val": "23d0b836e1ae2222abad42dd134fb2b972f27d991e97b1fc06db5b0dc0788e46"
}
},
"doc": {
"$schema": "https://gobl.org/draft-0/bill/invoice",
"$regime": "ES",
"$tags": [
"simplified"
],
"uuid": "7fe11346-a0ce-11ee-b8f0-e6a7901137ed",
"type": "standard",
"series": "SIMPL",
"code": "0002",
"issue_date": "2023-12-18",
"currency": "EUR",
"supplier": {
"name": "Provide One S.L.",
"tax_id": {
"country": "ES",
"code": "B98602642"
},
"addresses": [
{
"num": "42",
"street": "San Frantzisko",
"locality": "Bilbo",
"region": "Bizkaia",
"code": "48003",
"country": "ES"
}
],
"emails": [
{
"addr": "billing@example.com"
}
]
},
"lines": [
{
"i": 1,
"quantity": "20",
"item": {
"name": "Development services",
"price": "90.00",
"unit": "h"
},
"sum": "1800.00",
"discounts": [
{
"percent": "10%",
"amount": "180.00",
"reason": "Special discount"
}
],
"taxes": [
{
"cat": "VAT",
"rate": "standard",
"percent": "21.0%",
"ext": {
"es-tbai-product": "services"
}
}
],
"total": "1620.00"
},
{
"i": 2,
"quantity": "1",
"item": {
"name": "Some merch",
"price": "90.00"
},
"sum": "90.00",
"taxes": [
{
"cat": "VAT",
"rate": "standard",
"percent": "21.0%",
"ext": {
"es-tbai-product": "goods"
}
}
],
"total": "90.00"
},
{
"i": 3,
"quantity": "1",
"item": {
"name": "Some essential needs merch",
"price": "30.00"
},
"sum": "30.00",
"taxes": [
{
"cat": "VAT",
"rate": "reduced",
"percent": "10.0%",
"ext": {
"es-tbai-product": "goods"
}
}
],
"total": "30.00"
}
],
"totals": {
"sum": "1740.00",
"total": "1740.00",
"taxes": {
"categories": [
{
"code": "VAT",
"rates": [
{
"key": "standard",
"ext": {
"es-tbai-product": "services"
},
"base": "1620.00",
"percent": "21.0%",
"amount": "340.20"
},
{
"key": "standard",
"ext": {
"es-tbai-product": "goods"
},
"base": "90.00",
"percent": "21.0%",
"amount": "18.90"
},
{
"key": "reduced",
"ext": {
"es-tbai-product": "goods"
},
"base": "30.00",
"percent": "10.0%",
"amount": "3.00"
}
],
"amount": "362.10"
}
],
"sum": "362.10"
},
"tax": "362.10",
"total_with_tax": "2102.10",
"payable": "2102.10"
},
"notes": [
{
"key": "general",
"text": "Some random description"
}
]
}
}
62 changes: 62 additions & 0 deletions test/data/invoice-es-es-b2c.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
$schema: "https://gobl.org/draft-0/bill/invoice"
$tags:
- "simplified"
uuid: "7fe11346-a0ce-11ee-b8f0-e6a7901137ed"
currency: "EUR"
issue_date: "2023-12-18"
series: "SIMPL"
code: "0002"

supplier:
tax_id:
country: "ES"
code: "B98602642" # random
name: "Provide One S.L."
emails:
- addr: "billing@example.com"
addresses:
- num: "42"
street: "San Frantzisko"
locality: "Bilbo"
region: "Bizkaia"
code: "48003"
country: "ES"

lines:
- quantity: 20
item:
name: "Development services"
price: "90.00"
unit: "h"
discounts:
- percent: "10%"
reason: "Special discount"
taxes:
- cat: VAT
rate: standard
ext:
es-tbai-product: "services"
# es-tbai-not-subject: "RL" # set automatically
- quantity: 1
item:
name: "Some merch"
price: "90.00"
taxes:
- cat: VAT
rate: standard
ext:
es-tbai-product: "goods"
# es-tbai-not-subject: "RL" # set automatically
- quantity: 1
item:
name: "Some essential needs merch"
price: "30.00"
taxes:
- cat: VAT
rate: reduced
ext:
es-tbai-product: "goods"
# es-tbai-not-subject: "RL" # set automatically
notes:
- key: "general"
text: "Some random description"
Loading