From 3cc389daeeca98eb5a0a2a49ff97ae9e20a1ecec Mon Sep 17 00:00:00 2001 From: Sam Lown Date: Mon, 30 Sep 2024 10:30:16 +0000 Subject: [PATCH 1/3] PT: Fix invoice tags --- CHANGELOG.md | 6 ++++++ addons/pt/saft/saft.go | 3 --- addons/pt/saft/scenarios.go | 22 ++-------------------- regimes/pt/invoices.go | 20 ++++++++++++++++++++ regimes/pt/pt.go | 4 ++++ 5 files changed, 32 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b35c1567..a67f0d7c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to GOBL will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). See also the [GOBL versions](https://docs.gobl.org/overview/versions) documentation site for more details. +## [v0.200.1] + +### Fixed + +- `pt`: moving invoice tags from saft addon to regime, ensure defaults present. + ## [v0.200.0] Another ~~significant~~ epic release. Introducing "add-ons" which move the normalization and validation rules from Tax Regimes to specific packages that need to be enabled inside a document to be used. diff --git a/addons/pt/saft/saft.go b/addons/pt/saft/saft.go index 1d9d30b9..f3689b8c 100644 --- a/addons/pt/saft/saft.go +++ b/addons/pt/saft/saft.go @@ -23,9 +23,6 @@ func newAddon() *tax.AddonDef { i18n.EN: "Portugal SAF-T", }, Extensions: extensions, - Tags: []*tax.TagSet{ - invoiceTags, - }, Normalizer: normalize, Scenarios: scenarios, Validator: validate, diff --git a/addons/pt/saft/scenarios.go b/addons/pt/saft/scenarios.go index d4350784..7c0dea04 100644 --- a/addons/pt/saft/scenarios.go +++ b/addons/pt/saft/scenarios.go @@ -3,32 +3,14 @@ package saft import ( "github.com/invopop/gobl/bill" "github.com/invopop/gobl/cbc" - "github.com/invopop/gobl/i18n" + "github.com/invopop/gobl/regimes/pt" "github.com/invopop/gobl/tax" ) -// Invoice type tags -const ( - TagInvoiceReceipt cbc.Key = "invoice-receipt" -) - var scenarios = []*tax.ScenarioSet{ invoiceScenarios, } -var invoiceTags = &tax.TagSet{ - Schema: bill.ShortSchemaInvoice, - List: []*cbc.KeyDefinition{ - { - Key: TagInvoiceReceipt, - Name: i18n.String{ - i18n.EN: "Invoice-receipt", - i18n.PT: "Fatura-recibo", - }, - }, - }, -} - var invoiceScenarios = &tax.ScenarioSet{ Schema: bill.ShortSchemaInvoice, List: []*tax.Scenario{ @@ -52,7 +34,7 @@ var invoiceScenarios = &tax.ScenarioSet{ if !ok { return false } - return inv.HasTags(TagInvoiceReceipt) || inv.Totals.Paid() + return inv.HasTags(pt.TagInvoiceReceipt) || inv.Totals.Paid() }, Ext: tax.Extensions{ ExtKeyInvoiceType: "FR", diff --git a/regimes/pt/invoices.go b/regimes/pt/invoices.go index ca3ac8c9..2e1922b9 100644 --- a/regimes/pt/invoices.go +++ b/regimes/pt/invoices.go @@ -2,12 +2,32 @@ package pt import ( "github.com/invopop/gobl/bill" + "github.com/invopop/gobl/cbc" + "github.com/invopop/gobl/i18n" "github.com/invopop/gobl/num" "github.com/invopop/gobl/org" "github.com/invopop/gobl/tax" "github.com/invopop/validation" ) +// Invoice type tags +const ( + TagInvoiceReceipt cbc.Key = "invoice-receipt" +) + +var invoiceTags = &tax.TagSet{ + Schema: bill.ShortSchemaInvoice, + List: []*cbc.KeyDefinition{ + { + Key: TagInvoiceReceipt, + Name: i18n.String{ + i18n.EN: "Invoice-receipt", + i18n.PT: "Fatura-recibo", + }, + }, + }, +} + type invoiceValidator struct { inv *bill.Invoice } diff --git a/regimes/pt/pt.go b/regimes/pt/pt.go index 399b6fd3..81f27b66 100644 --- a/regimes/pt/pt.go +++ b/regimes/pt/pt.go @@ -6,6 +6,7 @@ import ( "github.com/invopop/gobl/cbc" "github.com/invopop/gobl/currency" "github.com/invopop/gobl/i18n" + "github.com/invopop/gobl/regimes/common" "github.com/invopop/gobl/tax" ) @@ -42,6 +43,9 @@ func New() *tax.RegimeDef { Extensions: extensionKeys, Validator: Validate, Normalizer: Normalize, + Tags: []*tax.TagSet{ + common.InvoiceTags().Merge(invoiceTags), + }, Corrections: []*tax.CorrectionDefinition{ { Schema: bill.ShortSchemaInvoice, From ec7b0fecafc8fa8fbb2d276f528c0a6fb6a6a91f Mon Sep 17 00:00:00 2001 From: Sam Lown Date: Mon, 30 Sep 2024 10:33:35 +0000 Subject: [PATCH 2/3] Adding quick test for simplified invoice receipts in PT --- regimes/pt/invoices_test.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/regimes/pt/invoices_test.go b/regimes/pt/invoices_test.go index 3530740f..466a4f8e 100644 --- a/regimes/pt/invoices_test.go +++ b/regimes/pt/invoices_test.go @@ -7,6 +7,7 @@ import ( "github.com/invopop/gobl/cal" "github.com/invopop/gobl/num" "github.com/invopop/gobl/org" + "github.com/invopop/gobl/regimes/pt" "github.com/invopop/gobl/tax" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -51,6 +52,14 @@ func TestValidInvoice(t *testing.T) { require.NoError(t, inv.Validate()) } +func TestValidSimplifiedInvoice(t *testing.T) { + inv := validInvoice() + inv.SetTags(tax.TagSimplified, pt.TagInvoiceReceipt) + inv.Customer = nil + require.NoError(t, inv.Calculate()) + require.NoError(t, inv.Validate()) +} + func TestLineValidation(t *testing.T) { inv := validInvoice() inv.Lines[0].Quantity = num.MakeAmount(-1, 0) From 54d92f4823a554ab84c109c097cbc10c43fa5e17 Mon Sep 17 00:00:00 2001 From: Sam Lown Date: Mon, 30 Sep 2024 10:36:56 +0000 Subject: [PATCH 3/3] Release 0.200.1 --- data/addons/pt-saft-v1.json | 14 -------- data/regimes/pt.json | 65 +++++++++++++++++++++++++++++++++++++ version.go | 2 +- 3 files changed, 66 insertions(+), 15 deletions(-) diff --git a/data/addons/pt-saft-v1.json b/data/addons/pt-saft-v1.json index aa9ce4e5..6542da3e 100644 --- a/data/addons/pt-saft-v1.json +++ b/data/addons/pt-saft-v1.json @@ -292,20 +292,6 @@ ] } ], - "tags": [ - { - "schema": "bill/invoice", - "list": [ - { - "key": "invoice-receipt", - "name": { - "en": "Invoice-receipt", - "pt": "Fatura-recibo" - } - } - ] - } - ], "scenarios": [ { "schema": "bill/invoice", diff --git a/data/regimes/pt.json b/data/regimes/pt.json index b9965060..ae35a157 100644 --- a/data/regimes/pt.json +++ b/data/regimes/pt.json @@ -7,6 +7,71 @@ "time_zone": "Europe/Lisbon", "country": "PT", "currency": "EUR", + "tags": [ + { + "schema": "bill/invoice", + "list": [ + { + "key": "simplified", + "name": { + "de": "Vereinfachte Rechnung", + "en": "Simplified Invoice", + "es": "Factura Simplificada", + "it": "Fattura Semplificata" + }, + "desc": { + "de": "Wird für B2C-Transaktionen verwendet, wenn die Kundendaten nicht verfügbar sind. Bitte wenden Sie sich an die örtlichen Behörden, um die Grenzwerte zu ermitteln.", + "en": "Used for B2C transactions when the client details are not available, check with local authorities for limits.", + "es": "Usado para transacciones B2C cuando los detalles del cliente no están disponibles, consulte con las autoridades locales para los límites.", + "it": "Utilizzato per le transazioni B2C quando i dettagli del cliente non sono disponibili, controllare con le autorità locali per i limiti." + } + }, + { + "key": "reverse-charge", + "name": { + "de": "Umkehr der Steuerschuld", + "en": "Reverse Charge", + "es": "Inversión del Sujeto Pasivo", + "it": "Inversione del soggetto passivo" + } + }, + { + "key": "self-billed", + "name": { + "de": "Rechnung durch den Leistungsempfänger", + "en": "Self-billed", + "es": "Facturación por el destinatario", + "it": "Autofattura" + } + }, + { + "key": "customer-rates", + "name": { + "de": "Kundensätze", + "en": "Customer rates", + "es": "Tarifas aplicables al destinatario", + "it": "Aliquote applicabili al destinatario" + } + }, + { + "key": "partial", + "name": { + "de": "Teilweise", + "en": "Partial", + "es": "Parcial", + "it": "Parziale" + } + }, + { + "key": "invoice-receipt", + "name": { + "en": "Invoice-receipt", + "pt": "Fatura-recibo" + } + } + ] + } + ], "extensions": [ { "key": "pt-region", diff --git a/version.go b/version.go index ef587087..46445b41 100644 --- a/version.go +++ b/version.go @@ -8,7 +8,7 @@ import ( type Version string // VERSION is the current version of the GOBL library. -const VERSION Version = "v0.200.0" +const VERSION Version = "v0.200.1" // Semver parses and returns semver func (v Version) Semver() *semver.Version {