From 5d5604444f1f5a20fa65494e36077a838f5b4184 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luismi=20Cavall=C3=A9?= Date: Fri, 18 Oct 2024 13:12:03 +0000 Subject: [PATCH 1/3] Map `it-sdi-vat-collect` ext to `EsigibilitaIVA` --- go.mod | 2 +- go.sum | 4 ++-- items.go | 2 ++ items_test.go | 1 + test/data/invoice-simple.json | 8 +++++--- test/data/out/invoice-simple.xml | 5 +++-- 6 files changed, 14 insertions(+), 8 deletions(-) diff --git a/go.mod b/go.mod index dfa503f..31e8054 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.22 toolchain go1.22.5 require ( - github.com/invopop/gobl v0.202.0 + github.com/invopop/gobl v0.202.1-0.20241018130847-fc3cade6decf github.com/invopop/xmldsig v0.8.0 github.com/lestrrat-go/libxml2 v0.0.0-20240521004304-a75c203ac627 github.com/spf13/cobra v1.8.1 diff --git a/go.sum b/go.sum index 1b9398e..423e404 100644 --- a/go.sum +++ b/go.sum @@ -22,8 +22,8 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= -github.com/invopop/gobl v0.202.0 h1:iUKk7FCKHbEKzuK7qAIxRkZAuh/8g09F9+Ufvs7aWbM= -github.com/invopop/gobl v0.202.0/go.mod h1:DmPohPel8b3ta4nDKnXRNzWQlB89cN74e0/WwPUEZUU= +github.com/invopop/gobl v0.202.1-0.20241018130847-fc3cade6decf h1:WJMnbrPhDaYaFmxUXi63ZKWgNkvAzybrr5p16jM2tdA= +github.com/invopop/gobl v0.202.1-0.20241018130847-fc3cade6decf/go.mod h1:DmPohPel8b3ta4nDKnXRNzWQlB89cN74e0/WwPUEZUU= github.com/invopop/jsonschema v0.12.0 h1:6ovsNSuvn9wEQVOyc72aycBMVQFKz7cPdMJn10CvzRI= github.com/invopop/jsonschema v0.12.0/go.mod h1:ffZ5Km5SWWRAIN6wbDXItl95euhFz2uON45H2qjYt+0= github.com/invopop/validation v0.7.0 h1:NBPLqvYGmLZLQuk5jh0PbaBBetJW7f2VEk/BTWJkGBU= diff --git a/items.go b/items.go index 6ec65fb..2649124 100644 --- a/items.go +++ b/items.go @@ -33,6 +33,7 @@ type datiRiepilogo struct { Natura string `xml:",omitempty"` ImponibileImporto string Imposta string + EsigibilitaIVA string `xml:"EsigibilitaIVA,omitempty"` RiferimentoNormativo string `xml:",omitempty"` } @@ -96,6 +97,7 @@ func generateTaxSummary(inv *bill.Invoice) []*datiRiepilogo { Natura: exemptExtensionCode(rateTotal.Ext), ImponibileImporto: formatAmount(&rateTotal.Base), Imposta: formatAmount(&rateTotal.Amount), + EsigibilitaIVA: rateTotal.Ext[sdi.ExtKeyVATCollect].String(), RiferimentoNormativo: findRiferimentoNormativo(rateTotal), }) } diff --git a/items_test.go b/items_test.go index 7b99a3a..9540c10 100644 --- a/items_test.go +++ b/items_test.go @@ -54,6 +54,7 @@ func TestDatiRiepilogo(t *testing.T) { dr = doc.FatturaElettronicaBody[0].DatiBeniServizi.DatiRiepilogo[1] assert.Equal(t, "N2.2", dr.Natura) + assert.Equal(t, "S", dr.EsigibilitaIVA) assert.Equal(t, "Non soggette - altri casi", dr.RiferimentoNormativo) }) } diff --git a/test/data/invoice-simple.json b/test/data/invoice-simple.json index fa77531..ede906c 100644 --- a/test/data/invoice-simple.json +++ b/test/data/invoice-simple.json @@ -4,7 +4,7 @@ "uuid": "679a2f25-7483-11ec-9722-7ea2cb436ff6", "dig": { "alg": "sha256", - "val": "308a3db3311dbfee897317f2d7ce0248613a1863c1a8ef3c48a318126cea37a3" + "val": "31aa7d353238f099904c230ffa2a72725eaf6e2bbf81e4f0bed9ee4556dd0a02" } }, "doc": { @@ -149,7 +149,8 @@ "cat": "VAT", "rate": "exempt", "ext": { - "it-sdi-exempt": "N2.2" + "it-sdi-exempt": "N2.2", + "it-sdi-vat-collect": "S" } } ], @@ -201,7 +202,8 @@ { "key": "exempt", "ext": { - "it-sdi-exempt": "N2.2" + "it-sdi-exempt": "N2.2", + "it-sdi-vat-collect": "S" }, "base": "100.00", "amount": "0.00" diff --git a/test/data/out/invoice-simple.xml b/test/data/out/invoice-simple.xml index 7144818..f992353 100644 --- a/test/data/out/invoice-simple.xml +++ b/test/data/out/invoice-simple.xml @@ -112,6 +112,7 @@ N2.2 100.00 0.00 + S Non soggette - altri casi @@ -132,7 +133,7 @@ - afVc/dLmBshNk73aKEWZoEqvj0ori61V31Moy9pRSph1r7o6LP0fc4HAt0oB4BlHE235RinSa511O1/s3Ymylg== + kXFHHbaDi8rueCqtC/b3RGTAdhY4juP38/QTO/lSe5P4X4X/NePVKWfr1M7DzHN/vt1FDIn72fauxTbZsK2/hQ== @@ -143,7 +144,7 @@ 7Tj/Vr2iDe5KuUvZfrT8ntgjkAtz6zIeztpC/liVkbigGbZLGFHcMpSsVtsRc+WIqqwsB7AwFVjqjSIKIDI3uw== - eGlesXdqlAmvek6lJ05ZAEh2ahm7Awwi9DdrKr+GzqpFVB2cgjGczxkmpu921URG94h6AiPFIbZNurOC/mEIGlloB74+kXNCn8grC0Ld6PMzqbu9YVOSZGqfHDhJWQUcPucjMIdJt7EbN17YOjLJKJML23o5B/SytHPJU8s+l8ZUMv8Frv+91mCyGbhGNSIDXHAHDfC5hkrqrLbDUFnwMWw7IZKNiRt6akMhFEjMc/st/yrkcUKGiGdVzwhIDsOlTRXERzBn1AwjXtdh8vQt3f/hvXg0NQ1H8GjhwOWP3j8yzlqh4JK4jzUzRlBRyxzy1jXu6BAvv1sh0Ip5cgBrgQ== + Wb6DhXTJsVbf7cCG1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BTByMDcWMWh0dHBzOi8vd3d3LmNlcnQuZm5tdC5lcy9wZHMvUERTQUNVc3Vhcmlvc19lcy5wZGYTAmVzMDcWMWh0dHBzOi8vd3d3LmNlcnQuZm5tdC5lcy9wZHMvUERTQUNVc3Vhcmlvc19lbi5wZGYTAmVuMIG1BgNVHR8Ega0wgaowgaeggaSggaGGgZ5sZGFwOi8vbGRhcHVzdS5jZXJ0LmZubXQuZXMvY249Q1JMMzc0OCxjbj1BQyUyMEZOTVQlMjBVc3VhcmlvcyxvdT1DRVJFUyxvPUZOTVQtUkNNLGM9RVM/Y2VydGlmaWNhdGVSZXZvY2F0aW9uTGlzdDtiaW5hcnk/YmFzZT9vYmplY3RjbGFzcz1jUkxEaXN0cmlidXRpb25Qb2ludDANBgkqhkiG9w0BAQsFAAOCAQEAH4t5/v/SLsm/dXRDw4QblCmTX+5pgXJ+4G1Lb3KTSPtDJ0UbQiAMUx+iqDDOoMHU5H7po/HZLJXgNwvKLoiLbl5/q6Mqasif87fa6awNkuz/Y6dvXw0UOJh+Ud/Wrk0EyaP9ZtrLVsraUOobNyS6g+lOrCxRrNxGRK2yAeotO6LEo1y3b7CB+Amd2jDq8lY3AtCYlrhuCaTf0AD9IBYYmigHzFD/VH5a8uG95l6J85FQG7tMsG6UQHFM2EmNhpbrYH+ihetz3UhzcC5Fd/P1X7pGBymQgbCyBjCRf/HEVzyoHL72uMp2I4JXX4v8HABZT8xtlDY4LE0am9keJhaNcg== From 888a9dc38baf5c4bd5eb3dcd2b1a0089c519408d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luismi=20Cavall=C3=A9?= Date: Mon, 21 Oct 2024 15:45:00 +0000 Subject: [PATCH 2/3] Use renamed extension --- go.mod | 2 +- go.sum | 4 ++-- items.go | 2 +- test/data/invoice-simple.json | 6 +++--- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/go.mod b/go.mod index 31e8054..2abd6fb 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.22 toolchain go1.22.5 require ( - github.com/invopop/gobl v0.202.1-0.20241018130847-fc3cade6decf + github.com/invopop/gobl v0.202.1-0.20241021152920-7b87944f2161 github.com/invopop/xmldsig v0.8.0 github.com/lestrrat-go/libxml2 v0.0.0-20240521004304-a75c203ac627 github.com/spf13/cobra v1.8.1 diff --git a/go.sum b/go.sum index 423e404..2ec5233 100644 --- a/go.sum +++ b/go.sum @@ -22,8 +22,8 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= -github.com/invopop/gobl v0.202.1-0.20241018130847-fc3cade6decf h1:WJMnbrPhDaYaFmxUXi63ZKWgNkvAzybrr5p16jM2tdA= -github.com/invopop/gobl v0.202.1-0.20241018130847-fc3cade6decf/go.mod h1:DmPohPel8b3ta4nDKnXRNzWQlB89cN74e0/WwPUEZUU= +github.com/invopop/gobl v0.202.1-0.20241021152920-7b87944f2161 h1:UxdbBX6V2Kztdm6fnbCkL3pMp/10YHv0yUR/1ZjTPtg= +github.com/invopop/gobl v0.202.1-0.20241021152920-7b87944f2161/go.mod h1:DmPohPel8b3ta4nDKnXRNzWQlB89cN74e0/WwPUEZUU= github.com/invopop/jsonschema v0.12.0 h1:6ovsNSuvn9wEQVOyc72aycBMVQFKz7cPdMJn10CvzRI= github.com/invopop/jsonschema v0.12.0/go.mod h1:ffZ5Km5SWWRAIN6wbDXItl95euhFz2uON45H2qjYt+0= github.com/invopop/validation v0.7.0 h1:NBPLqvYGmLZLQuk5jh0PbaBBetJW7f2VEk/BTWJkGBU= diff --git a/items.go b/items.go index 2649124..8b6ddc4 100644 --- a/items.go +++ b/items.go @@ -97,7 +97,7 @@ func generateTaxSummary(inv *bill.Invoice) []*datiRiepilogo { Natura: exemptExtensionCode(rateTotal.Ext), ImponibileImporto: formatAmount(&rateTotal.Base), Imposta: formatAmount(&rateTotal.Amount), - EsigibilitaIVA: rateTotal.Ext[sdi.ExtKeyVATCollect].String(), + EsigibilitaIVA: rateTotal.Ext[sdi.ExtKeyVATLiability].String(), RiferimentoNormativo: findRiferimentoNormativo(rateTotal), }) } diff --git a/test/data/invoice-simple.json b/test/data/invoice-simple.json index ede906c..c8168f8 100644 --- a/test/data/invoice-simple.json +++ b/test/data/invoice-simple.json @@ -4,7 +4,7 @@ "uuid": "679a2f25-7483-11ec-9722-7ea2cb436ff6", "dig": { "alg": "sha256", - "val": "31aa7d353238f099904c230ffa2a72725eaf6e2bbf81e4f0bed9ee4556dd0a02" + "val": "8847b795133eae7756b0aa2905df3b065d5f8bde1b8d593ccc988d2196489fc3" } }, "doc": { @@ -150,7 +150,7 @@ "rate": "exempt", "ext": { "it-sdi-exempt": "N2.2", - "it-sdi-vat-collect": "S" + "it-sdi-vat-liability": "S" } } ], @@ -203,7 +203,7 @@ "key": "exempt", "ext": { "it-sdi-exempt": "N2.2", - "it-sdi-vat-collect": "S" + "it-sdi-vat-liability": "S" }, "base": "100.00", "amount": "0.00" From 616d1aad562afb96129728116d76716070dcf928 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luismi=20Cavall=C3=A9?= Date: Mon, 21 Oct 2024 16:08:18 +0000 Subject: [PATCH 3/3] Upgrade to released GOBL --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 2abd6fb..c6adba9 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.22 toolchain go1.22.5 require ( - github.com/invopop/gobl v0.202.1-0.20241021152920-7b87944f2161 + github.com/invopop/gobl v0.203.0 github.com/invopop/xmldsig v0.8.0 github.com/lestrrat-go/libxml2 v0.0.0-20240521004304-a75c203ac627 github.com/spf13/cobra v1.8.1 diff --git a/go.sum b/go.sum index 2ec5233..14bfaa7 100644 --- a/go.sum +++ b/go.sum @@ -22,8 +22,8 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= -github.com/invopop/gobl v0.202.1-0.20241021152920-7b87944f2161 h1:UxdbBX6V2Kztdm6fnbCkL3pMp/10YHv0yUR/1ZjTPtg= -github.com/invopop/gobl v0.202.1-0.20241021152920-7b87944f2161/go.mod h1:DmPohPel8b3ta4nDKnXRNzWQlB89cN74e0/WwPUEZUU= +github.com/invopop/gobl v0.203.0 h1:41aIW+gZfyVcP0G0kz+IX4w8AMSx9EgbnALpn0s9CzA= +github.com/invopop/gobl v0.203.0/go.mod h1:DmPohPel8b3ta4nDKnXRNzWQlB89cN74e0/WwPUEZUU= github.com/invopop/jsonschema v0.12.0 h1:6ovsNSuvn9wEQVOyc72aycBMVQFKz7cPdMJn10CvzRI= github.com/invopop/jsonschema v0.12.0/go.mod h1:ffZ5Km5SWWRAIN6wbDXItl95euhFz2uON45H2qjYt+0= github.com/invopop/validation v0.7.0 h1:NBPLqvYGmLZLQuk5jh0PbaBBetJW7f2VEk/BTWJkGBU=