Skip to content

Commit

Permalink
Merge branch 'main' of github.com:invopop/gobl into hungary
Browse files Browse the repository at this point in the history
  • Loading branch information
Menendez6 committed Oct 28, 2024
2 parents a28b25f + 834477c commit 17e7f0d
Show file tree
Hide file tree
Showing 9 changed files with 232 additions and 10 deletions.
1 change: 1 addition & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
- [ ] I've run `go generate .` to ensure that Schemas and Regime data are up to date.
- [ ] All linter warnings have been reviewed and fixed.
- [ ] I've been obsessive with pointer nil checks to avoid panics.
- [ ] The CHANGELOG.md has been updated with an overview of my changes.
- [ ] Requested a review from @samlown.

10 changes: 6 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,19 @@ 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.

## [Unreleased]
## [v0.203.0]

### Added

- `br`: added basic Brazil regime
- `uuid` - SQL library compatibility for type conversion.
- `uuid`: SQL library compatibility for type conversion.
- `it-sdi-v1`: added `it-sdi-vat-liability` extension for EsigibilitaIVA.

### Fixed

- `bill.Invoice` - remove empty taxes instances.
- `tax.Identity` - support Calculate method to normalize IDs.
- `bill.Invoice`: remove empty taxes instances.
- `tax.Identity`: support Calculate method to normalize IDs.
- `tax.Regime`: properly set regime when alternative codes is given.

## [v0.202.0]

Expand Down
35 changes: 32 additions & 3 deletions addons/it/sdi/extensions.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const (
ExtKeyExempt cbc.Key = "it-sdi-exempt"
ExtKeyRetained cbc.Key = "it-sdi-retained"
ExtKeyPaymentMeans cbc.Key = "it-sdi-payment-means"
ExtKeyVATLiability cbc.Key = "it-sdi-vat-liability"
)

var extensions = []*cbc.KeyDefinition{
Expand All @@ -29,7 +30,7 @@ var extensions = []*cbc.KeyDefinition{
Code used to describe the transmission format of the invoice. By default
the value "FPR12" is used unless the user explicitly sets the value
to something else.
Normally this will only be needed when the invoice is to be sent to governmental
bodies and must use the "FPA12" format.
`),
Expand Down Expand Up @@ -458,7 +459,6 @@ var extensions = []*cbc.KeyDefinition{
},
},
},

{
// Retained reason code determined from the "CausalePagamento" field from FatturaPA.
// Source: https://www.agenziaentrate.gov.it/portale/documents/20143/4115385/CU_istr_2022.pdf
Expand Down Expand Up @@ -695,7 +695,6 @@ var extensions = []*cbc.KeyDefinition{
},
},
},

{
Key: ExtKeyPaymentMeans,
Name: i18n.String{
Expand Down Expand Up @@ -866,4 +865,34 @@ var extensions = []*cbc.KeyDefinition{
},
},
},
{
Key: ExtKeyVATLiability,
Name: i18n.String{
i18n.EN: "VAT Liability",
i18n.IT: "Esigibilità dell'IVA",
},
Values: []*cbc.ValueDefinition{
{
Value: "I",
Name: i18n.String{
i18n.EN: "Immediate",
i18n.IT: "Immediata",
},
},
{
Value: "D",
Name: i18n.String{
i18n.EN: "Deferred",
i18n.IT: "Differita",
},
},
{
Value: "S",
Name: i18n.String{
i18n.EN: "Split Payment",
i18n.IT: "Scissione dei pagamenti",
},
},
},
},
}
30 changes: 30 additions & 0 deletions data/addons/it-sdi-v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -890,6 +890,36 @@
}
}
]
},
{
"key": "it-sdi-vat-liability",
"name": {
"en": "VAT Liability",
"it": "Esigibilità dell'IVA"
},
"values": [
{
"value": "I",
"name": {
"en": "Immediate",
"it": "Immediata"
}
},
{
"value": "D",
"name": {
"en": "Deferred",
"it": "Differita"
}
},
{
"value": "S",
"name": {
"en": "Split Payment",
"it": "Scissione dei pagamenti"
}
}
]
}
],
"tags": [
Expand Down
135 changes: 135 additions & 0 deletions data/regimes/br.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
{
"$schema": "https://gobl.org/draft-0/tax/regime-def",
"name": {
"en": "Brazil",
"pt": "Brasil"
},
"time_zone": "America/Sao_Paulo",
"country": "BR",
"currency": "BRL",
"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"
}
}
]
}
],
"corrections": [
{
"schema": "bill/invoice",
"types": [
"credit-note"
]
}
],
"categories": [
{
"code": "ISS",
"name": {
"en": "ISS",
"pt": "ISS"
},
"title": {
"en": "Municipal Service Tax",
"pt": "Imposto Sobre Serviços"
}
},
{
"code": "ICMS",
"name": {
"en": "ICMS",
"pt": "ICMS"
},
"title": {
"en": "State value-added tax",
"pt": "Imposto sobre Circulação de Mercadorias e Serviços"
}
},
{
"code": "IPI",
"name": {
"en": "IPI",
"pt": "IPI"
},
"title": {
"en": "Federal value-added Tax",
"pt": "Imposto sobre Produtos Industrializados"
}
},
{
"code": "PIS",
"name": {
"en": "PIS",
"pt": "PIS"
},
"title": {
"en": "Social Integration Program",
"pt": "Programa de Integração Social"
},
"retained": true
},
{
"code": "COFINS",
"name": {
"en": "COFINS",
"pt": "COFINS"
},
"title": {
"en": "Contribution for the Financing of Social Security",
"pt": "Contribuição para o Financiamento da Seguridade Social"
},
"retained": true
}
]
}
4 changes: 4 additions & 0 deletions data/schemas/bill/invoice.json
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,10 @@
"const": "BE",
"title": "Belgium"
},
{
"const": "BR",
"title": "Brazil"
},
{
"const": "CA",
"title": "Canada"
Expand Down
5 changes: 3 additions & 2 deletions tax/regime.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ func (r Regime) GetRegime() l10n.TaxCountryCode {
// that the regime is actually defined. Missing regimes will silently replace
// the current regime with an empty value.
func (r *Regime) SetRegime(country l10n.TaxCountryCode) {
if Regimes().For(country.Code()) == nil {
rd := Regimes().For(country.Code())
if rd == nil {
r.Country = ""
return
}
r.Country = country
r.Country = rd.Country
}

// RegimeDef provides the associated regime definition.
Expand Down
20 changes: 20 additions & 0 deletions tax/regimes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package tax_test
import (
"testing"

"github.com/invopop/gobl/l10n"
"github.com/invopop/gobl/tax"
"github.com/stretchr/testify/assert"
)
Expand All @@ -19,3 +20,22 @@ func TestRegimesAltCountryCodes(t *testing.T) {
r := tax.RegimeDefFor("GR")
assert.Equal(t, "EL", r.Country.String())
}

func TestSetRegime(t *testing.T) {
tests := []struct {
reg string
exp string
}{
{"ES", "ES"},
{"GR", "EL"},
{"YY", ""},
}

for _, tt := range tests {
t.Run(tt.reg, func(t *testing.T) {
r := new(tax.Regime)
r.SetRegime(l10n.TaxCountryCode(tt.reg))
assert.Equal(t, tt.exp, r.GetRegime().String())
})
}
}
2 changes: 1 addition & 1 deletion version.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
type Version string

// VERSION is the current version of the GOBL library.
const VERSION Version = "v0.202.0"
const VERSION Version = "v0.203.0"

// Semver parses and returns semver
func (v Version) Semver() *semver.Version {
Expand Down

0 comments on commit 17e7f0d

Please sign in to comment.