From 4aee03e653c65da3658dc37e83854fc9793d55ca Mon Sep 17 00:00:00 2001 From: Sam Lown Date: Thu, 5 Dec 2024 16:30:54 +0000 Subject: [PATCH 1/5] Moving from Key and Value Definitions to a single struct --- addons/br/nfse/extensions.go | 44 +- addons/br/nfse/identities.go | 2 +- addons/br/nfse/invoices_test.go | 3 +- addons/br/nfse/tax_combo_test.go | 3 +- addons/co/dian/extensions.go | 24 +- addons/co/dian/identities.go | 2 +- addons/co/dian/invoices_test.go | 3 +- addons/de/xrechnung/invoices.go | 5 +- addons/es/facturae/extensions.go | 70 +- addons/es/tbai/extensions.go | 56 +- addons/es/verifactu/bill.go | 12 +- addons/es/verifactu/extensions.go | 86 +- addons/eu/en16931/tax_combo.go | 5 +- addons/gr/mydata/extensions.go | 286 +++---- addons/gr/mydata/scenarios.go | 2 +- addons/gr/mydata/tax_combo.go | 2 +- addons/it/sdi/extensions.go | 258 +++--- addons/it/sdi/inboxes.go | 2 +- addons/it/sdi/scenarios.go | 2 +- addons/mx/cfdi/extensions.go | 168 ++-- addons/mx/cfdi/invoice_test.go | 5 +- addons/mx/cfdi/item.go | 4 +- addons/mx/cfdi/item_test.go | 9 +- addons/mx/cfdi/party.go | 3 +- addons/pt/saft/extensions.go | 82 +- addons/pt/saft/scenarios.go | 108 +-- bill/charges.go | 2 +- bill/discounts.go | 2 +- bill/invoice_correct.go | 4 +- bill/invoice_correct_test.go | 2 +- bill/invoice_type.go | 2 +- catalogues/iso/iso.go | 2 +- catalogues/iso/scheme_id.go | 2 +- catalogues/untdid/allowance.go | 80 +- catalogues/untdid/charge.go | 732 +++++++++--------- catalogues/untdid/document_type.go | 220 +++--- catalogues/untdid/payment_means.go | 340 ++++---- catalogues/untdid/tax_category.go | 46 +- catalogues/untdid/untdid.go | 2 +- cbc/cbc.go | 3 +- cbc/definition.go | 161 ++++ ..._definition_test.go => definition_test.go} | 18 +- cbc/key_definition.go | 100 --- cbc/notes.go | 4 +- cbc/value_definition.go | 29 - cbc/value_definition_test.go | 18 - internal/cli/bulk_test.go | 2 +- pay/means_key.go | 2 +- regimes/co/party.go | 5 +- regimes/common/invoice_tags.go | 2 +- regimes/de/de.go | 2 +- regimes/de/identities.go | 2 +- regimes/es/es.go | 8 +- regimes/es/identities.go | 2 +- regimes/es/scenarios.go | 2 +- regimes/it/identities.go | 2 +- regimes/it/it.go | 6 +- regimes/mx/invoice.go | 8 +- regimes/mx/invoice_test.go | 11 +- regimes/pl/extensions.go | 22 +- regimes/pl/invoices_test.go | 3 +- regimes/pl/pay.go | 2 +- regimes/pl/scenarios.go | 2 +- regimes/pt/extensions.go | 10 +- regimes/pt/invoices.go | 2 +- regimes/pt/migrations.go | 4 +- regimes/pt/migrations_test.go | 5 +- tax/addons.go | 6 +- tax/catalogue.go | 2 +- tax/extensions.go | 65 +- tax/extensions_test.go | 33 +- tax/regime_def.go | 14 +- tax/scenario.go | 12 +- tax/scenario_test.go | 6 +- tax/tags.go | 2 +- tax/tags_test.go | 8 +- 76 files changed, 1616 insertions(+), 1651 deletions(-) create mode 100644 cbc/definition.go rename cbc/{key_definition_test.go => definition_test.go} (74%) delete mode 100644 cbc/key_definition.go delete mode 100644 cbc/value_definition.go delete mode 100644 cbc/value_definition_test.go diff --git a/addons/br/nfse/extensions.go b/addons/br/nfse/extensions.go index 4dbe1faa..a41d5154 100644 --- a/addons/br/nfse/extensions.go +++ b/addons/br/nfse/extensions.go @@ -21,7 +21,7 @@ const ( ExtKeySpecialRegime = "br-nfse-special-regime" ) -var extensions = []*cbc.KeyDefinition{ +var extensions = []*cbc.Definition{ { Key: ExtKeyCNAE, Name: i18n.String{ @@ -45,16 +45,16 @@ var extensions = []*cbc.KeyDefinition{ i18n.EN: "Fiscal Incentive", i18n.PT: "Incentivo Fiscal", }, - Values: []*cbc.ValueDefinition{ + Values: []*cbc.Definition{ { - Value: "1", + Code: "1", Name: i18n.String{ i18n.EN: "Has incentive", i18n.PT: "Possui incentivo", }, }, { - Value: "2", + Code: "2", Name: i18n.String{ i18n.EN: "Does not have incentive", i18n.PT: "Não possui incentivo", @@ -78,51 +78,51 @@ var extensions = []*cbc.KeyDefinition{ i18n.EN: "ISS Liability", i18n.PT: "Exigibilidade ISS", }, - Values: []*cbc.ValueDefinition{ + Values: []*cbc.Definition{ { - Value: "1", + Code: "1", Name: i18n.String{ i18n.EN: "Liable", i18n.PT: "Exigível", }, }, { - Value: "2", + Code: "2", Name: i18n.String{ i18n.EN: "Not subject", i18n.PT: "Não incidência", }, }, { - Value: "3", + Code: "3", Name: i18n.String{ i18n.EN: "Exempt", i18n.PT: "Isenção", }, }, { - Value: "4", + Code: "4", Name: i18n.String{ i18n.EN: "Export", i18n.PT: "Exportação", }, }, { - Value: "5", + Code: "5", Name: i18n.String{ i18n.EN: "Immune", i18n.PT: "Imunidade", }, }, { - Value: "6", + Code: "6", Name: i18n.String{ i18n.EN: "Suspended Judicially", i18n.PT: "Suspensa por Decisão Judicial", }, }, { - Value: "7", + Code: "7", Name: i18n.String{ i18n.EN: "Suspended Administratively", i18n.PT: "Suspensa por Processo Administrativo", @@ -181,16 +181,16 @@ var extensions = []*cbc.KeyDefinition{ i18n.EN: "Opting for “Simples Nacional” regime", i18n.PT: "Optante pelo Simples Nacional", }, - Values: []*cbc.ValueDefinition{ + Values: []*cbc.Definition{ { - Value: "1", + Code: "1", Name: i18n.String{ i18n.EN: "Opt-in", i18n.PT: "Optante", }, }, { - Value: "2", + Code: "2", Name: i18n.String{ i18n.EN: "Opt-out", i18n.PT: "Não optante", @@ -216,44 +216,44 @@ var extensions = []*cbc.KeyDefinition{ i18n.EN: "Special Tax Regime", i18n.PT: "Regime Especial de Tributação", }, - Values: []*cbc.ValueDefinition{ + Values: []*cbc.Definition{ { - Value: "1", + Code: "1", Name: i18n.String{ i18n.EN: "Municipal micro-enterprise", i18n.PT: "Microempresa municipal", }, }, { - Value: "2", + Code: "2", Name: i18n.String{ i18n.EN: "Estimated", i18n.PT: "Estimativa", }, }, { - Value: "3", + Code: "3", Name: i18n.String{ i18n.EN: "Professional Society", i18n.PT: "Sociedade de profissionais", }, }, { - Value: "4", + Code: "4", Name: i18n.String{ i18n.EN: "Cooperative", i18n.PT: "Cooperativa", }, }, { - Value: "5", + Code: "5", Name: i18n.String{ i18n.EN: "Single micro-entrepreneur (MEI)", i18n.PT: "Microempreendedor individual (MEI)", }, }, { - Value: "6", + Code: "6", Name: i18n.String{ i18n.EN: "Micro-enterprise or Small Business (ME EPP)", i18n.PT: "Microempresa ou Empresa de Pequeno Porte (ME EPP).", diff --git a/addons/br/nfse/identities.go b/addons/br/nfse/identities.go index b7f65512..c6703fd8 100644 --- a/addons/br/nfse/identities.go +++ b/addons/br/nfse/identities.go @@ -15,7 +15,7 @@ const ( IdentityKeyNationalReg = "br-nfse-national-reg" ) -var identities = []*cbc.KeyDefinition{ +var identities = []*cbc.Definition{ { Key: IdentityKeyMunicipalReg, Name: i18n.String{ diff --git a/addons/br/nfse/invoices_test.go b/addons/br/nfse/invoices_test.go index 050e5984..505506f1 100644 --- a/addons/br/nfse/invoices_test.go +++ b/addons/br/nfse/invoices_test.go @@ -5,6 +5,7 @@ import ( "github.com/invopop/gobl/addons/br/nfse" "github.com/invopop/gobl/bill" + "github.com/invopop/gobl/cbc" "github.com/invopop/gobl/num" "github.com/invopop/gobl/org" "github.com/invopop/gobl/tax" @@ -232,7 +233,7 @@ func TestSuppliersNormalization(t *testing.T) { tests := []struct { name string supplier *org.Party - out tax.ExtValue + out cbc.Code }{ { name: "no supplier", diff --git a/addons/br/nfse/tax_combo_test.go b/addons/br/nfse/tax_combo_test.go index 86e6b982..b80220c6 100644 --- a/addons/br/nfse/tax_combo_test.go +++ b/addons/br/nfse/tax_combo_test.go @@ -4,6 +4,7 @@ import ( "testing" "github.com/invopop/gobl/addons/br/nfse" + "github.com/invopop/gobl/cbc" "github.com/invopop/gobl/regimes/br" "github.com/invopop/gobl/tax" "github.com/stretchr/testify/assert" @@ -60,7 +61,7 @@ func TestTaxComboNormalization(t *testing.T) { tests := []struct { name string tc *tax.Combo - out tax.ExtValue + out cbc.Code }{ { name: "no tax combo", diff --git a/addons/co/dian/extensions.go b/addons/co/dian/extensions.go index 159d403c..c9f6ae0c 100644 --- a/addons/co/dian/extensions.go +++ b/addons/co/dian/extensions.go @@ -13,7 +13,7 @@ const ( ExtKeyDebitCode cbc.Key = "co-dian-debit-code" ) -var extensions = []*cbc.KeyDefinition{ +var extensions = []*cbc.Definition{ { Key: ExtKeyMunicipality, Name: i18n.String{ @@ -42,9 +42,9 @@ var extensions = []*cbc.KeyDefinition{ i18n.EN: "DIAN correction code for credit notes", i18n.ES: "Código de corrección DIAN para notas de crédito", }, - Values: []*cbc.ValueDefinition{ + Values: []*cbc.Definition{ { - Value: "1", + Code: "1", Name: i18n.String{ i18n.EN: "Partial refund", i18n.ES: "Devolución parcial", @@ -55,7 +55,7 @@ var extensions = []*cbc.KeyDefinition{ }, }, { - Value: "2", + Code: "2", Name: i18n.String{ i18n.EN: "Revoked", i18n.ES: "Anulación", @@ -66,7 +66,7 @@ var extensions = []*cbc.KeyDefinition{ }, }, { - Value: "3", + Code: "3", Name: i18n.String{ i18n.EN: "Discount", i18n.ES: "Descuento", @@ -77,7 +77,7 @@ var extensions = []*cbc.KeyDefinition{ }, }, { - Value: "4", + Code: "4", Name: i18n.String{ i18n.EN: "Adjustment", i18n.ES: "Ajuste", @@ -88,7 +88,7 @@ var extensions = []*cbc.KeyDefinition{ }, }, { - Value: "5", + Code: "5", Name: i18n.String{ i18n.EN: "Other", i18n.ES: "Otros", @@ -106,30 +106,30 @@ var extensions = []*cbc.KeyDefinition{ i18n.EN: "DIAN correction code for debit notes", i18n.ES: "Código de corrección DIAN para notas de débito", }, - Values: []*cbc.ValueDefinition{ + Values: []*cbc.Definition{ { - Value: "1", + Code: "1", Name: i18n.String{ i18n.EN: "Interest", i18n.ES: "Intereses", }, }, { - Value: "2", + Code: "2", Name: i18n.String{ i18n.EN: "Pending charges", i18n.ES: "Gastos por cobrar", }, }, { - Value: "3", + Code: "3", Name: i18n.String{ i18n.EN: "Change in value", i18n.ES: "Cambio del valor", }, }, { - Value: "4", + Code: "4", Name: i18n.String{ i18n.EN: "Other", i18n.ES: "Otros", diff --git a/addons/co/dian/identities.go b/addons/co/dian/identities.go index 7fa8f6e8..a7efd2ff 100644 --- a/addons/co/dian/identities.go +++ b/addons/co/dian/identities.go @@ -23,7 +23,7 @@ const ( KeyCompanyID cbc.Key = "dian-company-id" ) -var identities = []*cbc.KeyDefinition{ +var identities = []*cbc.Definition{ { Key: IdentityKeyCivilRegister, Name: i18n.String{ diff --git a/addons/co/dian/invoices_test.go b/addons/co/dian/invoices_test.go index 62402927..c0d97973 100644 --- a/addons/co/dian/invoices_test.go +++ b/addons/co/dian/invoices_test.go @@ -7,6 +7,7 @@ import ( "github.com/invopop/gobl/addons/co/dian" "github.com/invopop/gobl/bill" "github.com/invopop/gobl/cal" + "github.com/invopop/gobl/cbc" "github.com/invopop/gobl/currency" "github.com/invopop/gobl/num" "github.com/invopop/gobl/org" @@ -175,7 +176,7 @@ func TestBasicCreditNoteValidation(t *testing.T) { err = inv.Validate() assert.NoError(t, err) assert.Contains(t, inv.Preceding[0].Ext, dian.ExtKeyCreditCode) - assert.Equal(t, inv.Preceding[0].Ext[dian.ExtKeyCreditCode], tax.ExtValue("2")) + assert.Equal(t, inv.Preceding[0].Ext[dian.ExtKeyCreditCode], cbc.Code("2")) inv.Preceding[0].Ext["foo"] = "bar" err = inv.Validate() diff --git a/addons/de/xrechnung/invoices.go b/addons/de/xrechnung/invoices.go index c00a98c0..7438f5a7 100644 --- a/addons/de/xrechnung/invoices.go +++ b/addons/de/xrechnung/invoices.go @@ -3,12 +3,13 @@ package xrechnung import ( "github.com/invopop/gobl/bill" "github.com/invopop/gobl/catalogues/untdid" + "github.com/invopop/gobl/cbc" "github.com/invopop/gobl/tax" "github.com/invopop/validation" ) // BR-DE-17 - restricted subset of UNTDID document type codes -var validInvoiceUNTDIDDocumentTypeValues = []tax.ExtValue{ +var validInvoiceUNTDIDDocumentTypeValues = []cbc.Code{ "326", // Partial "380", // Commercial "384", // Corrected @@ -47,7 +48,7 @@ func validateInvoiceTax(value any) error { } return validation.ValidateStruct(tx, validation.Field(&tx.Ext, - tax.ExtensionsHasValues(untdid.ExtKeyTaxCategory, validInvoiceUNTDIDDocumentTypeValues...), + tax.ExtensionsHasCodes(untdid.ExtKeyTaxCategory, validInvoiceUNTDIDDocumentTypeValues...), validation.Skip, ), ) diff --git a/addons/es/facturae/extensions.go b/addons/es/facturae/extensions.go index 9d9b59e4..de11b7cf 100644 --- a/addons/es/facturae/extensions.go +++ b/addons/es/facturae/extensions.go @@ -12,30 +12,30 @@ const ( ExtKeyInvoiceClass cbc.Key = "es-facturae-invoice-class" ) -var extensions = []*cbc.KeyDefinition{ +var extensions = []*cbc.Definition{ { Key: ExtKeyDocType, Name: i18n.String{ i18n.EN: "FacturaE: Document Type", i18n.ES: "FacturaE: Tipo de Documento", }, - Values: []*cbc.ValueDefinition{ + Values: []*cbc.Definition{ { - Value: "FC", + Code: "FC", Name: i18n.String{ i18n.EN: "Commercial Invoice", i18n.ES: "Factura Comercial", }, }, { - Value: "FA", + Code: "FA", Name: i18n.String{ i18n.EN: "Simplified Invoice", i18n.ES: "Factura Simplificada", }, }, { - Value: "AF", + Code: "AF", Name: i18n.String{ i18n.EN: "Self-billed Invoice", i18n.ES: "Auto-Factura", @@ -49,44 +49,44 @@ var extensions = []*cbc.KeyDefinition{ i18n.EN: "FacturaE: Invoice Class", i18n.ES: "FacturaE: Clase de Factura", }, - Values: []*cbc.ValueDefinition{ + Values: []*cbc.Definition{ { - Value: "OO", + Code: "OO", Name: i18n.String{ i18n.EN: "Original", i18n.ES: "Original", }, }, { - Value: "OR", + Code: "OR", Name: i18n.String{ i18n.EN: "Corrective Original", i18n.ES: "Original Rectificativa", }, }, { - Value: "OC", + Code: "OC", Name: i18n.String{ i18n.EN: "Summary Original", i18n.ES: "Original Recapitulativa", }, }, { - Value: "CO", + Code: "CO", Name: i18n.String{ i18n.EN: "Copy of the Original", i18n.ES: "Duplicado Original", }, }, { - Value: "CR", + Code: "CR", Name: i18n.String{ i18n.EN: "Copy of the Corrective", i18n.ES: "Duplicado Rectificativa", }, }, { - Value: "CC", + Code: "CC", Name: i18n.String{ i18n.EN: "Copy of the Summary", i18n.ES: "Duplicado Recapitulativa", @@ -105,156 +105,156 @@ var extensions = []*cbc.KeyDefinition{ i18n.ES: "FacturaE requiere un código específico y único que explique por qué se está corrigiendo la factura anterior.", }, // Codes take from FacturaE XSD - Values: []*cbc.ValueDefinition{ + Values: []*cbc.Definition{ { - Value: "01", + Code: "01", Name: i18n.String{ i18n.EN: "Invoice code", i18n.ES: "Número de la factura", }, }, { - Value: "02", + Code: "02", Name: i18n.String{ i18n.EN: "Invoice series", i18n.ES: "Serie de la factura", }, }, { - Value: "03", + Code: "03", Name: i18n.String{ i18n.EN: "Issue date", i18n.ES: "Fecha expedición", }, }, { - Value: "04", + Code: "04", Name: i18n.String{ i18n.EN: "Name and surnames/Corporate name - Issuer (Sender)", i18n.ES: "Nombre y apellidos/Razón Social-Emisor", }, }, { - Value: "05", + Code: "05", Name: i18n.String{ i18n.EN: "Name and surnames/Corporate name - Receiver", i18n.ES: "Nombre y apellidos/Razón Social-Receptor", }, }, { - Value: "06", + Code: "06", Name: i18n.String{ i18n.EN: "Issuer's Tax Identification Number", i18n.ES: "Identificación fiscal Emisor/obligado", }, }, { - Value: "07", + Code: "07", Name: i18n.String{ i18n.EN: "Receiver's Tax Identification Number", i18n.ES: "Identificación fiscal Receptor", }, }, { - Value: "08", + Code: "08", Name: i18n.String{ i18n.EN: "Supplier's address", i18n.ES: "Domicilio Emisor/Obligado", }, }, { - Value: "09", + Code: "09", Name: i18n.String{ i18n.EN: "Customer's address", i18n.ES: "Domicilio Receptor", }, }, { - Value: "10", + Code: "10", Name: i18n.String{ i18n.EN: "Item line", i18n.ES: "Detalle Operación", }, }, { - Value: "11", + Code: "11", Name: i18n.String{ i18n.EN: "Applicable Tax Rate", i18n.ES: "Porcentaje impositivo a aplicar", }, }, { - Value: "12", + Code: "12", Name: i18n.String{ i18n.EN: "Applicable Tax Amount", i18n.ES: "Cuota tributaria a aplicar", }, }, { - Value: "13", + Code: "13", Name: i18n.String{ i18n.EN: "Applicable Date/Period", i18n.ES: "Fecha/Periodo a aplicar", }, }, { - Value: "14", + Code: "14", Name: i18n.String{ i18n.EN: "Invoice Class", i18n.ES: "Clase de factura", }, }, { - Value: "15", + Code: "15", Name: i18n.String{ i18n.EN: "Legal literals", i18n.ES: "Literales legales", }, }, { - Value: "16", + Code: "16", Name: i18n.String{ i18n.EN: "Taxable Base", i18n.ES: "Base imponible", }, }, { - Value: "80", + Code: "80", Name: i18n.String{ i18n.EN: "Calculation of tax outputs", i18n.ES: "Cálculo de cuotas repercutidas", }, }, { - Value: "81", + Code: "81", Name: i18n.String{ i18n.EN: "Calculation of tax inputs", i18n.ES: "Cálculo de cuotas retenidas", }, }, { - Value: "82", + Code: "82", Name: i18n.String{ i18n.EN: "Taxable Base modified due to return of packages and packaging materials", i18n.ES: "Base imponible modificada por devolución de envases / embalajes", }, }, { - Value: "83", + Code: "83", Name: i18n.String{ i18n.EN: "Taxable Base modified due to discounts and rebates", i18n.ES: "Base imponible modificada por descuentos y bonificaciones", }, }, { - Value: "84", + Code: "84", Name: i18n.String{ i18n.EN: "Taxable Base modified due to firm court ruling or administrative decision", i18n.ES: "Base imponible modificada por resolución firme, judicial o administrativa", }, }, { - Value: "85", + Code: "85", Name: i18n.String{ i18n.EN: "Taxable Base modified due to unpaid outputs where there is a judgement opening insolvency proceedings", i18n.ES: "Base imponible modificada cuotas repercutidas no satisfechas. Auto de declaración de concurso", diff --git a/addons/es/tbai/extensions.go b/addons/es/tbai/extensions.go index 69b0bdbf..325068cf 100644 --- a/addons/es/tbai/extensions.go +++ b/addons/es/tbai/extensions.go @@ -14,7 +14,7 @@ const ( ExtKeyCorrection cbc.Key = "es-tbai-correction" ) -var extensions = []*cbc.KeyDefinition{ +var extensions = []*cbc.Definition{ { Key: ExtKeyRegion, Name: i18n.String{ @@ -28,23 +28,23 @@ var extensions = []*cbc.KeyDefinition{ API endpoint to use when submitting documents. `), }, - Values: []*cbc.ValueDefinition{ + Values: []*cbc.Definition{ { - Value: "VI", + Code: "VI", Name: i18n.String{ i18n.EN: "Araba", i18n.ES: "Álava", }, }, { - Value: "BI", + Code: "BI", Name: i18n.String{ i18n.EN: "Bizkaia", i18n.ES: "Vizcaya", }, }, { - Value: "SS", + Code: "SS", Name: i18n.String{ i18n.EN: "Gipuzkoa", i18n.ES: "Guipúzcoa", @@ -69,23 +69,23 @@ var extensions = []*cbc.KeyDefinition{ case can be ignored. `), }, - Values: []*cbc.ValueDefinition{ + Values: []*cbc.Definition{ { - Value: "goods", + Code: "goods", Name: i18n.String{ i18n.EN: "Delivery of goods", i18n.ES: "Entrega de bienes", }, }, { - Value: "services", + Code: "services", Name: i18n.String{ i18n.EN: "Provision of services", i18n.ES: "Prestacion de servicios", }, }, { - Value: "resale", + Code: "resale", Name: i18n.String{ i18n.EN: "Resale of goods without modification by vendor in the simplified regime", i18n.ES: "Reventa de bienes sin modificación por vendedor en regimen simplificado", @@ -107,72 +107,72 @@ var extensions = []*cbc.KeyDefinition{ other countries we've combined them into one. `), }, - Values: []*cbc.ValueDefinition{ + Values: []*cbc.Definition{ { - Value: "E1", + Code: "E1", Name: i18n.String{ i18n.EN: "Exempt: pursuant to Article 20 of the Foral VAT Law", i18n.ES: "Exenta: por el artículo 20 de la Norma Foral del IVA", }, }, { - Value: "E2", + Code: "E2", Name: i18n.String{ i18n.EN: "Exempt: pursuant to Article 21 of the Foral VAT Law", i18n.ES: "Exenta: por el artículo 21 de la Norma Foral del IVA", }, }, { - Value: "E3", + Code: "E3", Name: i18n.String{ i18n.EN: "Exempt: pursuant to Article 22 of the Foral VAT Law", i18n.ES: "Exenta: por el artículo 22 de la Norma Foral del IVA", }, }, { - Value: "E4", + Code: "E4", Name: i18n.String{ i18n.EN: "Exempt: pursuant to Articles 23 and 24 of the Foral VAT Law", i18n.ES: "Exenta: por el artículos 23 y 24 de la Norma Foral del IVA", }, }, { - Value: "E5", + Code: "E5", Name: i18n.String{ i18n.EN: "Exempt: pursuant to Article 25 of the Foral VAT law", i18n.ES: "Exenta: por el artículo 25 de la Norma Foral del IVA", }, }, { - Value: "E6", + Code: "E6", Name: i18n.String{ i18n.EN: "Exempt: pursuant to other reasons", i18n.ES: "Exenta: por otra causa", }, }, { - Value: "OT", + Code: "OT", Name: i18n.String{ i18n.EN: "Not subject: pursuant to Article 7 of the VAT Law - other cases of non-subject", i18n.ES: "No sujeto: por el artículo 7 de la Ley del IVA - otros supuestos de no sujeción", }, }, { - Value: "RL", + Code: "RL", Name: i18n.String{ i18n.EN: "Not subject: pursuant to localization rules", i18n.ES: "No sujeto: por reglas de localización", }, }, { - Value: "VT", + Code: "VT", Name: i18n.String{ i18n.EN: "Not subject: sales made on behalf of third parties (amount not computable for VAT or IRPF purposes)", i18n.ES: "No sujeto: ventas realizadas por cuenta de terceros (importe no computable a efectos de IVA ni de IRPF)", }, }, { - Value: "IE", + Code: "IE", Name: i18n.String{ i18n.EN: "Not subject in the TAI due to localization rules, but foreign tax, IPS/IGIC or VAT from another EU member state is passed on", i18n.ES: "No sujeto en el TAI por reglas de localización, pero repercute impuesto extranjero, IPS/IGIC o IVA de otro estado miembro UE", @@ -182,7 +182,7 @@ var extensions = []*cbc.KeyDefinition{ // S1 is the default value for regular invoices, so we don't need to include it here // alongside the exemption codes. { - Value: "S1", + Code: "S1", Name: i18n.String{ i18n.EN: "Subject and not exempt: without reverse charge", i18n.ES: "Sujeto y no exenta: sin inversión del sujeto pasivo", @@ -190,7 +190,7 @@ var extensions = []*cbc.KeyDefinition{ }, */ { - Value: "S2", + Code: "S2", Name: i18n.String{ i18n.EN: "Subject and not exempt: with reverse charge", i18n.ES: "Sujeto y no exenta: con inversión del sujeto pasivo", @@ -212,9 +212,9 @@ var extensions = []*cbc.KeyDefinition{ `), }, // Codes taken from TicketBAI XSD - Values: []*cbc.ValueDefinition{ + Values: []*cbc.Definition{ { - Value: "R1", + Code: "R1", Name: i18n.String{ i18n.EN: "Rectified invoice: error based on law and Article 80 One, Two and Six of the Provincial Tax Law of VAT", i18n.ES: "Factura rectificativa: error fundado en derecho y Art. 80 Uno, Dos y Seis de la Norma Foral del IVA", @@ -222,7 +222,7 @@ var extensions = []*cbc.KeyDefinition{ }, }, { - Value: "R2", + Code: "R2", Name: i18n.String{ i18n.ES: "Factura rectificativa: artículo 80 Tres de la Norma Foral del IVA", i18n.EN: "Rectified invoice: error based on law and Article 80 Three of the Provincial Tax Law of VAT", @@ -230,7 +230,7 @@ var extensions = []*cbc.KeyDefinition{ }, }, { - Value: "R3", + Code: "R3", Name: i18n.String{ i18n.ES: "Factura rectificativa: artículo 80 Cuatro de la Norma Foral del IVA", i18n.EN: "Rectified invoice: error based on law and Article 80 Four of the Provincial Tax Law of VAT", @@ -238,7 +238,7 @@ var extensions = []*cbc.KeyDefinition{ }, }, { - Value: "R4", + Code: "R4", Name: i18n.String{ i18n.ES: "Factura rectificativa: Resto", i18n.EN: "Rectified invoice: Other", @@ -246,7 +246,7 @@ var extensions = []*cbc.KeyDefinition{ }, }, { - Value: "R5", + Code: "R5", Name: i18n.String{ i18n.ES: "Factura rectificativa: facturas simplificadas", i18n.EN: "Rectified invoice: simplified invoices", diff --git a/addons/es/verifactu/bill.go b/addons/es/verifactu/bill.go index 4104e6d2..56c2adc9 100644 --- a/addons/es/verifactu/bill.go +++ b/addons/es/verifactu/bill.go @@ -83,13 +83,13 @@ func validateInvoice(inv *bill.Invoice) error { ) } -var docTypesStandard = []tax.ExtValue{ // Standard invoices +var docTypesStandard = []cbc.Code{ // Standard invoices "F1", "F2", } -var docTypesCreditDebit = []tax.ExtValue{ // Credit or Debit notes +var docTypesCreditDebit = []cbc.Code{ // Credit or Debit notes "R1", "R2", "R3", "R4", "R5", } -var docTypesCorrective = []tax.ExtValue{ // Substitutions +var docTypesCorrective = []cbc.Code{ // Substitutions "F3", "R1", "R2", "R3", "R4", "R5", } @@ -101,21 +101,21 @@ func validateInvoiceTax(it cbc.Key) validation.RuleFunc { tax.ExtensionsRequire(ExtKeyDocType), validation.When( it.In(bill.InvoiceTypeStandard), - tax.ExtensionsHasValues( + tax.ExtensionsHasCodes( ExtKeyDocType, docTypesStandard..., ), ), validation.When( it.In(bill.InvoiceTypeCreditNote, bill.InvoiceTypeDebitNote), - tax.ExtensionsHasValues( + tax.ExtensionsHasCodes( ExtKeyDocType, docTypesCreditDebit..., ), ), validation.When( it.In(bill.InvoiceTypeCorrective), - tax.ExtensionsHasValues( + tax.ExtensionsHasCodes( ExtKeyDocType, docTypesCorrective..., ), diff --git a/addons/es/verifactu/extensions.go b/addons/es/verifactu/extensions.go index 5b0c114a..ce405351 100644 --- a/addons/es/verifactu/extensions.go +++ b/addons/es/verifactu/extensions.go @@ -15,7 +15,7 @@ const ( ExtKeyRegime cbc.Key = "es-verifactu-regime" ) -var extensions = []*cbc.KeyDefinition{ +var extensions = []*cbc.Definition{ { Key: ExtKeyDocType, Name: i18n.String{ @@ -29,58 +29,58 @@ var extensions = []*cbc.KeyDefinition{ * https://www.boe.es/diario_boe/txt.php?id=BOE-A-2024-22138 `), }, - Values: []*cbc.ValueDefinition{ + Values: []*cbc.Definition{ { - Value: "F1", + Code: "F1", Name: i18n.String{ i18n.EN: "Invoice (Article 6, 7.2 and 7.3 of RD 1619/2012)", i18n.ES: "Factura (Art. 6, 7.2 y 7.3 del RD 1619/2012)", }, }, { - Value: "F2", + Code: "F2", Name: i18n.String{ i18n.EN: "Simplified invoice (Article 6.1.d) of RD 1619/2012)", i18n.ES: "Factura Simplificada (Art. 6.1.d) del RD 1619/2012)", }, }, { - Value: "F3", + Code: "F3", Name: i18n.String{ i18n.EN: "Invoice issued as a replacement for simplified invoices that have been billed and declared.", i18n.ES: "Factura emitida en sustitución de facturas simplificadas facturadas y declaradas.", }, }, { - Value: "R1", + Code: "R1", Name: i18n.String{ i18n.EN: "Rectified invoice: error based on law and Article 80 One, Two and Six LIVA", i18n.ES: "Factura rectificativa: error fundado en derecho y Art. 80 Uno, Dos y Seis LIVA", }, }, { - Value: "R2", + Code: "R2", Name: i18n.String{ i18n.ES: "Factura rectificativa: artículo 80.3", i18n.EN: "Rectified invoice: error based on law and Article 80.3", }, }, { - Value: "R3", + Code: "R3", Name: i18n.String{ i18n.ES: "Factura rectificativa: artículo 80.4", i18n.EN: "Rectified invoice: error based on law and Article 80.4", }, }, { - Value: "R4", + Code: "R4", Name: i18n.String{ i18n.ES: "Factura rectificativa: Resto", i18n.EN: "Rectified invoice: Other", }, }, { - Value: "R5", + Code: "R5", Name: i18n.String{ i18n.ES: "Factura rectificativa: facturas simplificadas", i18n.EN: "Rectified invoice: simplified invoices", @@ -101,16 +101,16 @@ var extensions = []*cbc.KeyDefinition{ Corrective invoices will be marked as "S", while credit and debit notes as "I". `), }, - Values: []*cbc.ValueDefinition{ + Values: []*cbc.Definition{ { - Value: "S", + Code: "S", Name: i18n.String{ i18n.EN: "Substitution", i18n.ES: "Por Sustitución", }, }, { - Value: "I", + Code: "I", Name: i18n.String{ i18n.EN: "Differences", i18n.ES: "Por Diferencias", @@ -134,30 +134,30 @@ var extensions = []*cbc.KeyDefinition{ * https://sede.agenciatributaria.gob.es/Sede/impuestos-tasas/iva/iva-libros-registro-iva-traves-aeat/preguntas-frecuentes/3-libro-registro-facturas-expedidas.html?faqId=b5556c3d02bc9510VgnVCM100000dc381e0aRCRD `), }, - Values: []*cbc.ValueDefinition{ + Values: []*cbc.Definition{ { - Value: "S1", + Code: "S1", Name: i18n.String{ i18n.EN: "Subject and Not Exempt - Without reverse charge", i18n.ES: "Operación Sujeta y No exenta - Sin inversión del sujeto pasivo", }, }, { - Value: "S2", + Code: "S2", Name: i18n.String{ i18n.EN: "Subject and Not Exempt - With reverse charge", i18n.ES: "Operación Sujeta y No exenta - Con Inversión del sujeto pasivo", }, }, { - Value: "N1", + Code: "N1", Name: i18n.String{ i18n.EN: "Not Subject - Articles 7, 14, others", i18n.ES: "Operación No Sujeta artículo 7, 14, otros", }, }, { - Value: "N2", + Code: "N2", Name: i18n.String{ i18n.EN: "Not Subject - Due to location rules", i18n.ES: "Operación No Sujeta por Reglas de localización", @@ -176,44 +176,44 @@ var extensions = []*cbc.KeyDefinition{ Exemption code used to explain why the operation is exempt from taxes. `), }, - Values: []*cbc.ValueDefinition{ + Values: []*cbc.Definition{ { - Value: "E1", + Code: "E1", Name: i18n.String{ i18n.EN: "Exempt: pursuant to Article 20. Exemptions in internal operations.", i18n.ES: "Exenta: por el artículo 20. Exenciones en operaciones interiores.", }, }, { - Value: "E2", + Code: "E2", Name: i18n.String{ i18n.EN: "Exempt: pursuant to Article 21. Exemptions in exports of goods.", i18n.ES: "Exenta: por el artículo 21. Exenciones en las exportaciones de bienes.", }, }, { - Value: "E3", + Code: "E3", Name: i18n.String{ i18n.EN: "Exempt: pursuant to Article 22. Exemptions in operations asimilated to exports.", i18n.ES: "Exenta: por el artículo 22. Exenciones en las operaciones asimiladas a las exportaciones.", }, }, { - Value: "E4", + Code: "E4", Name: i18n.String{ i18n.EN: "Exempt: pursuant to Articles 23 and 24. Exemptions related to temporary deposit, customs and fiscal regimes, and other situations.", i18n.ES: "Exenta: por el artículos 23 y 24. Exenciones relativas a las situaciones de depósito temporal, regímenes aduaneros y fiscales, y otras situaciones.", }, }, { - Value: "E5", + Code: "E5", Name: i18n.String{ i18n.EN: "Exempt: pursuant to Article 25. Exemptions in the delivery of goods destined to another Member State.", i18n.ES: "Exenta: por el artículo 25. Exenciones en las entregas de bienes destinados a otro Estado miembro.", }, }, { - Value: "E6", + Code: "E6", Name: i18n.String{ i18n.EN: "Exempt: pursuant to other reasons", i18n.ES: "Exenta: por otra causa", @@ -232,121 +232,121 @@ var extensions = []*cbc.KeyDefinition{ Identify the type of VAT or IGIC regime applied to the operation. This list combines lists L8A which include values for VAT, and L8B for IGIC. `), }, - Values: []*cbc.ValueDefinition{ + Values: []*cbc.Definition{ { - Value: "01", + Code: "01", Name: i18n.String{ i18n.EN: "General regime operation", i18n.ES: "Operación de régimen general", }, }, { - Value: "02", + Code: "02", Name: i18n.String{ i18n.EN: "Export", i18n.ES: "Exportación", }, }, { - Value: "03", + Code: "03", Name: i18n.String{ i18n.EN: "Special regime for used goods, art objects, antiques and collectibles", i18n.ES: "Operaciones a las que se aplique el régimen especial de bienes usados, objetos de arte, antigüedades y objetos de colección", }, }, { - Value: "04", + Code: "04", Name: i18n.String{ i18n.EN: "Special regime for investment gold", i18n.ES: "Régimen especial del oro de inversión", }, }, { - Value: "05", + Code: "05", Name: i18n.String{ i18n.EN: "Special regime for travel agencies", i18n.ES: "Régimen especial de las agencias de viajes", }, }, { - Value: "06", + Code: "06", Name: i18n.String{ i18n.EN: "Special regime for VAT/IGIC groups (Advanced Level)", i18n.ES: "Régimen especial grupo de entidades en IVA/IGIC (Nivel Avanzado)", }, }, { - Value: "07", + Code: "07", Name: i18n.String{ i18n.EN: "Special cash accounting regime", i18n.ES: "Régimen especial del criterio de caja", }, }, { - Value: "08", + Code: "08", Name: i18n.String{ i18n.EN: "Operations subject to a different regime", i18n.ES: "Operaciones sujetas a un régimen diferente", }, }, { - Value: "09", + Code: "09", Name: i18n.String{ i18n.EN: "Billing of travel agency services acting as mediators in name and on behalf of others", i18n.ES: "Facturación de las prestaciones de servicios de agencias de viaje que actúan como mediadoras en nombre y por cuenta ajena", }, }, { - Value: "10", + Code: "10", Name: i18n.String{ i18n.EN: "Collection of professional fees or rights on behalf of third parties", i18n.ES: "Cobros por cuenta de terceros de honorarios profesionales o de derechos derivados de la propiedad industrial", }, }, { - Value: "11", + Code: "11", Name: i18n.String{ i18n.EN: "Business premises rental operations", i18n.ES: "Operaciones de arrendamiento de local de negocio", }, }, { - Value: "14", + Code: "14", Name: i18n.String{ i18n.EN: "Invoice with pending VAT/IGIC accrual in work certifications for Public Administration", i18n.ES: "Factura con IVA/IGIC pendiente de devengo en certificaciones de obra cuyo destinatario sea una Administración Pública", }, }, { - Value: "15", + Code: "15", Name: i18n.String{ i18n.EN: "Invoice with pending VAT/IGIC accrual in successive tract operations", i18n.ES: "Factura con IVA/IGIC pendiente de devengo en operaciones de tracto sucesivo", }, }, { - Value: "17", + Code: "17", Name: i18n.String{ i18n.EN: "Operation under OSS and IOSS regimes (VAT) / Special regime for retail traders. (IGIC)", i18n.ES: "Operación acogida a alguno de los regímenes previstos en el capítulo XI del título IX (OSS e IOSS, IVA) / Régimen especial de comerciante minorista. (IGIC)", }, }, { - Value: "18", + Code: "18", Name: i18n.String{ i18n.EN: "Equivalence surcharge (VAT) / Special regime for small traders or retailers (IGIC)", i18n.ES: "Recargo de equivalencia (IVA) / Régimen especial del pequeño comerciante o minorista (IGIC)", }, }, { - Value: "19", + Code: "19", Name: i18n.String{ i18n.EN: "Operations included in the Special Regime for Agriculture, Livestock and Fisheries", i18n.ES: "Operaciones de actividades incluidas en el Régimen Especial de Agricultura, Ganadería y Pesca (REAGYP)", }, }, { - Value: "20", + Code: "20", Name: i18n.String{ i18n.EN: "Simplified regime (VAT only)", i18n.ES: "Régimen simplificado (IVA only)", diff --git a/addons/eu/en16931/tax_combo.go b/addons/eu/en16931/tax_combo.go index 85ccb130..6ce9fdf0 100644 --- a/addons/eu/en16931/tax_combo.go +++ b/addons/eu/en16931/tax_combo.go @@ -2,6 +2,7 @@ package en16931 import ( "github.com/invopop/gobl/catalogues/untdid" + "github.com/invopop/gobl/cbc" "github.com/invopop/gobl/regimes/es" "github.com/invopop/gobl/tax" "github.com/invopop/validation" @@ -18,7 +19,7 @@ var taxCategoryMap = tax.Extensions{ } // acceptedTaxCategories as defined by the EN 16931 code list values data. -var acceptedTaxCategories = []tax.ExtValue{ +var acceptedTaxCategories = []cbc.Code{ "S", "Z", "E", "AE", "K", "G", "O", "L", "M", } @@ -53,7 +54,7 @@ func validateTaxCombo(tc *tax.Combo) error { return validation.ValidateStruct(tc, validation.Field(&tc.Ext, tax.ExtensionsRequire(untdid.ExtKeyTaxCategory), - tax.ExtensionsHasValues(untdid.ExtKeyTaxCategory, acceptedTaxCategories...), + tax.ExtensionsHasCodes(untdid.ExtKeyTaxCategory, acceptedTaxCategories...), validation.Skip, ), ) diff --git a/addons/gr/mydata/extensions.go b/addons/gr/mydata/extensions.go index 4b188a04..7d4233a7 100644 --- a/addons/gr/mydata/extensions.go +++ b/addons/gr/mydata/extensions.go @@ -17,65 +17,65 @@ const ( InvoiceTypeRetailPrefix = "11." ) -var extensions = []*cbc.KeyDefinition{ +var extensions = []*cbc.Definition{ { Key: ExtKeyVATRate, Name: i18n.String{ i18n.EN: "VAT rate", i18n.EL: "Κατηγορία ΦΠΑ", }, - Values: []*cbc.ValueDefinition{ + Values: []*cbc.Definition{ { - Value: "1", + Code: "1", Name: i18n.String{ i18n.EN: "Standard rate", i18n.EL: "Κανονικός συντελεστής", }, }, { - Value: "2", + Code: "2", Name: i18n.String{ i18n.EN: "Reduced rate", i18n.EL: "Μειωμένος συντελεστής", }, }, { - Value: "3", + Code: "3", Name: i18n.String{ i18n.EN: "Super-Reduced Rate", i18n.EL: "Υπερμειωμένος συντελεστής", }, }, { - Value: "4", + Code: "4", Name: i18n.String{ i18n.EN: "Standard rate (Island)", i18n.EL: "Κανονικός συντελεστής (Νησί)", }, }, { - Value: "5", + Code: "5", Name: i18n.String{ i18n.EN: "Reduced rate (Island)", i18n.EL: "Μειωμένος συντελεστής (Νησί)", }, }, { - Value: "6", + Code: "6", Name: i18n.String{ i18n.EN: "Super-reduced rate (Island)", i18n.EL: "Υπερμειωμένος συντελεστής (Νησί)", }, }, { - Value: "7", + Code: "7", Name: i18n.String{ i18n.EN: "Without VAT", i18n.EL: "Άνευ ΦΠΑ", }, }, { - Value: "8", + Code: "8", Name: i18n.String{ i18n.EN: "Records without VAT (e.g. Payroll, Amortisations)", i18n.EL: "Εγγραφές χωρίς ΦΠΑ (πχ Μισθοδοσία, Αποσβέσεις)", @@ -89,317 +89,317 @@ var extensions = []*cbc.KeyDefinition{ i18n.EN: "Invoice type", i18n.EL: "Είδος παραστατικού", }, - Values: []*cbc.ValueDefinition{ + Values: []*cbc.Definition{ { - Value: "1.1", + Code: "1.1", Name: i18n.String{ i18n.EN: "Sales Invoice", i18n.EL: "Τιμολόγιο Πώλησης", }, }, { - Value: "1.2", + Code: "1.2", Name: i18n.String{ i18n.EN: "Sales Invoice/Intra-community Supplies", i18n.EL: "Τιμολόγιο Πώλησης/Ενδοκοινοτικές Παραδόσεις", }, }, { - Value: "1.3", + Code: "1.3", Name: i18n.String{ i18n.EN: "Sales Invoice/Third Country Supplies", i18n.EL: "Τιμολόγιο Πώλησης/Παραδόσεις Τρίτων Χωρών", }, }, { - Value: "1.4", + Code: "1.4", Name: i18n.String{ i18n.EN: "Sales Invoice/Sale on Behalf of Third Parties", i18n.EL: "Τιμολόγιο Πώλησης/Πώληση για Λογαριασμό Τρίτων", }, }, { - Value: "1.5", + Code: "1.5", Name: i18n.String{ i18n.EN: "Sales Invoice/Clearance of Sales on Behalf of Third Parties – Fees from Sales on Behalf of Third Parties", i18n.EL: "Τιμολόγιο Πώλησης/Εκκαθάριση Πωλήσεων Τρίτων - Αμοιβή από Πωλήσεις Τρίτων", }, }, { - Value: "1.6", + Code: "1.6", Name: i18n.String{ i18n.EN: "Sales Invoice/Supplemental Accounting Source Document", i18n.EL: "Τιμολόγιο Πώλησης/Συμπληρωματικό Παραστατικό", }, }, { - Value: "2.1", + Code: "2.1", Name: i18n.String{ i18n.EN: "Service Rendered Invoice", i18n.EL: "Τιμολόγιο Παροχής Υπηρεσιών", }, }, { - Value: "2.2", + Code: "2.2", Name: i18n.String{ i18n.EN: "Intra-community Service Rendered Invoice", i18n.EL: "Τιμολόγιο Παροχής/Ενδοκοινοτική Παροχή Υπηρεσιών", }, }, { - Value: "2.3", + Code: "2.3", Name: i18n.String{ i18n.EN: "Third Country Service Rendered Invoice", i18n.EL: "Τιμολόγιο Παροχής/Παροχή Υπηρεσιών σε λήπτη Τρίτης Χώρας", }, }, { - Value: "2.4", + Code: "2.4", Name: i18n.String{ i18n.EN: "Service Rendered Invoice/Supplemental Accounting Source Document", i18n.EL: "Τιμολόγιο Παροχής/Συμπληρωματικό Παραστατικό", }, }, { - Value: "3.1", + Code: "3.1", Name: i18n.String{ i18n.EN: "Proof of Expenditure (non-liable Issuer)", i18n.EL: "Τίτλος Κτήσης (μη υπόχρεος Εκδότης)", }, }, { - Value: "3.2", + Code: "3.2", Name: i18n.String{ i18n.EN: "Proof of Expenditure (denial of issuance by liable Issuer)", i18n.EL: "Τίτλος Κτήσης (άρνηση έκδοσης από υπόχρεο Εκδότη)", }, }, { - Value: "5.1", + Code: "5.1", Name: i18n.String{ i18n.EN: "Credit Invoice/Associated", i18n.EL: "Πιστωτικό Τιμολόγιο/Συσχετιζόμενο", }, }, { - Value: "5.2", + Code: "5.2", Name: i18n.String{ i18n.EN: "Credit Invoice/Non-Associated", i18n.EL: "Πιστωτικό Τιμολόγιο/Μη Συσχετιζόμενο", }, }, { - Value: "6.1", + Code: "6.1", Name: i18n.String{ i18n.EN: "Self-Delivery Record", i18n.EL: "Στοιχείο Αυτοπαράδοσης", }, }, { - Value: "6.2", + Code: "6.2", Name: i18n.String{ i18n.EN: "Self-Supply Record", i18n.EL: "Στοιχείο Ιδιοχρησιμοποίησης", }, }, { - Value: "7.1", + Code: "7.1", Name: i18n.String{ i18n.EN: "Contract – Income", i18n.EL: "Συμβόλαιο - Έσοδο", }, }, { - Value: "8.1", + Code: "8.1", Name: i18n.String{ i18n.EN: "Rents – Income", i18n.EL: "Ενοίκια - Έσοδο", }, }, { - Value: "8.2", + Code: "8.2", Name: i18n.String{ i18n.EN: "Special Record – Accommodation Tax Collection/Payment Receipt", i18n.EL: "Ειδικό Στοιχείο – Απόδειξης Είσπραξης Φόρου Διαμονής", }, }, { - Value: "11.1", + Code: "11.1", Name: i18n.String{ i18n.EN: "Retail Sales Receipt", i18n.EL: "ΑΛΠ", }, }, { - Value: "11.2", + Code: "11.2", Name: i18n.String{ i18n.EN: "Service Rendered Receipt", i18n.EL: "ΑΠΥ", }, }, { - Value: "11.3", + Code: "11.3", Name: i18n.String{ i18n.EN: "Simplified Invoice", i18n.EL: "Απλοποιημένο Τιμολόγιο", }, }, { - Value: "11.4", + Code: "11.4", Name: i18n.String{ i18n.EN: "Retail Sales Credit Note", i18n.EL: "Πιστωτικό Στοιχ. Λιανικής", }, }, { - Value: "11.5", + Code: "11.5", Name: i18n.String{ i18n.EN: "Retail Sales Receipt on Behalf of Third Parties", i18n.EL: "Απόδειξη Λιανικής Πώλησης για Λογ/σμό Τρίτων", }, }, { - Value: "13.1", + Code: "13.1", Name: i18n.String{ i18n.EN: "Expenses – Domestic/Foreign Retail Transaction Purchases", i18n.EL: "Έξοδα - Αγορές Λιανικών Συναλλαγών ημεδαπής / αλλοδαπής", }, }, { - Value: "13.2", + Code: "13.2", Name: i18n.String{ i18n.EN: "Domestic/Foreign Retail Transaction Provision", i18n.EL: "Παροχή Λιανικών Συναλλαγών ημεδαπής / αλλοδαπής", }, }, { - Value: "13.3", + Code: "13.3", Name: i18n.String{ i18n.EN: "Shared Utility Bills", i18n.EL: "Κοινόχρηστα", }, }, { - Value: "13.4", + Code: "13.4", Name: i18n.String{ i18n.EN: "Subscriptions", i18n.EL: "Συνδρομές", }, }, { - Value: "13.30", + Code: "13.30", Name: i18n.String{ i18n.EN: "Self-Declared Entity Accounting Source Documents (Dynamic)", i18n.EL: "Παραστατικά Οντότητας ως Αναγράφονται από την ίδια (Δυναμικό)", }, }, { - Value: "13.31", + Code: "13.31", Name: i18n.String{ i18n.EN: "Domestic/Foreign Retail Sales Credit Note", i18n.EL: "Πιστωτικό Στοιχ. Λιανικής ημεδαπής / αλλοδαπής", }, }, { - Value: "14.1", + Code: "14.1", Name: i18n.String{ i18n.EN: "Invoice/Intra-community Acquisitions", i18n.EL: "Τιμολόγιο / Ενδοκοινοτικές Αποκτήσεις", }, }, { - Value: "14.2", + Code: "14.2", Name: i18n.String{ i18n.EN: "Invoice/Third Country Acquisitions", i18n.EL: "Τιμολόγιο / Αποκτήσεις Τρίτων Χωρών", }, }, { - Value: "14.3", + Code: "14.3", Name: i18n.String{ i18n.EN: "Invoice/Intra-community Services Receipt", i18n.EL: "Τιμολόγιο / Ενδοκοινοτική Λήψη Υπηρεσιών", }, }, { - Value: "14.4", + Code: "14.4", Name: i18n.String{ i18n.EN: "Invoice/Third Country Services Receipt", i18n.EL: "Τιμολόγιο / Λήψη Υπηρεσιών Τρίτων Χωρών", }, }, { - Value: "14.5", + Code: "14.5", Name: i18n.String{ i18n.EN: "EFKA", i18n.EL: "ΕΦΚΑ και λοιποί Ασφαλιστικοί Οργανισμοί", }, }, { - Value: "14.30", + Code: "14.30", Name: i18n.String{ i18n.EN: "Self-Declared Entity Accounting Source Documents (Dynamic)", i18n.EL: "Παραστατικά Οντότητας ως Αναγράφονται από την ίδια (Δυναμικό)", }, }, { - Value: "14.31", + Code: "14.31", Name: i18n.String{ i18n.EN: "Domestic/Foreign Credit Note", i18n.EL: "Πιστωτικό ημεδαπής / αλλοδαπής", }, }, { - Value: "15.1", + Code: "15.1", Name: i18n.String{ i18n.EN: "Contract-Expense", i18n.EL: "Συμβόλαιο - Έξοδο", }, }, { - Value: "16.1", + Code: "16.1", Name: i18n.String{ i18n.EN: "Rent-Expense", i18n.EL: "Ενοίκιο Έξοδο", }, }, { - Value: "17.1", + Code: "17.1", Name: i18n.String{ i18n.EN: "Payroll", i18n.EL: "Μισθοδοσία", }, }, { - Value: "17.2", + Code: "17.2", Name: i18n.String{ i18n.EN: "Amortisations", i18n.EL: "Αποσβέσεις", }, }, { - Value: "17.3", + Code: "17.3", Name: i18n.String{ i18n.EN: "Other Income Adjustment/Regularisation Entries – Accounting Base", i18n.EL: "Λοιπές Εγγραφές Τακτοποίησης Εσόδων - Λογιστική Βάση", }, }, { - Value: "17.4", + Code: "17.4", Name: i18n.String{ i18n.EN: "Other Income Adjustment/Regularisation Entries – Tax Base", i18n.EL: "Λοιπές Εγγραφές Τακτοποίησης Εσόδων - Φορολογική Βάση", }, }, { - Value: "17.5", + Code: "17.5", Name: i18n.String{ i18n.EN: "Other Expense Adjustment/Regularisation Entries – Accounting Base", i18n.EL: "Λοιπές Εγγραφές Τακτοποίησης Εξόδων - Λογιστική Βάση", }, }, { - Value: "17.6", + Code: "17.6", Name: i18n.String{ i18n.EN: "Other Expense Adjustment/Regularisation Entries – Tax Base", i18n.EL: "Λοιπές Εγγραφές Τακτοποίησης Εξόδων - Φορολογική Βάση", @@ -413,51 +413,51 @@ var extensions = []*cbc.KeyDefinition{ i18n.EN: "Payment means", i18n.EL: "Τρόπος Πληρωμής", }, - Values: []*cbc.ValueDefinition{ + Values: []*cbc.Definition{ { - Value: "1", + Code: "1", Name: i18n.String{ i18n.EN: "Domestic Payments Account Number", i18n.EL: "Επαγ. Λογαριασμός Πληρωμών Ημεδαπής", }, }, { - Value: "2", + Code: "2", Name: i18n.String{ i18n.EN: "Foreign Payments Account Number", i18n.EL: "Επαγ. Λογαριασμός Πληρωμών Αλλοδαπής", }, }, { - Value: "3", + Code: "3", Name: i18n.String{ i18n.EN: "Cash", i18n.EL: "Μετρητά", }, }, { - Value: "4", + Code: "4", Name: i18n.String{ i18n.EN: "Check", i18n.EL: "Επιταγή", }, }, { - Value: "5", + Code: "5", Name: i18n.String{ i18n.EN: "On credit", i18n.EL: "Επί Πιστώσει", }, }, { - Value: "6", + Code: "6", Name: i18n.String{ i18n.EN: "Web Banking", i18n.EL: "Web Banking", }, }, { - Value: "7", + Code: "7", Name: i18n.String{ i18n.EN: "POS / e-POS", i18n.EL: "POS / e-POS", @@ -471,219 +471,219 @@ var extensions = []*cbc.KeyDefinition{ i18n.EN: "VAT exemption cause", i18n.EL: "Κατηγορία Αιτίας Εξαίρεσης ΦΠΑ", }, - Values: []*cbc.ValueDefinition{ + Values: []*cbc.Definition{ { - Value: "1", + Code: "1", Name: i18n.String{ i18n.EN: "Without VAT - article 3 of the VAT code", i18n.EL: "Χωρίς ΦΠΑ - άρθρο 3 του Κώδικα ΦΠΑ", }, }, { - Value: "2", + Code: "2", Name: i18n.String{ i18n.EN: "Without VAT - article 5 of the VAT code", i18n.EL: "Χωρίς ΦΠΑ - άρθρο 5 του Κώδικα ΦΠΑ", }, }, { - Value: "3", + Code: "3", Name: i18n.String{ i18n.EN: "Without VAT - article 13 of the VAT code", i18n.EL: "Χωρίς ΦΠΑ - άρθρο 13 του Κώδικα ΦΠΑ", }, }, { - Value: "4", + Code: "4", Name: i18n.String{ i18n.EN: "Without VAT - article 14 of the VAT code", i18n.EL: "Χωρίς ΦΠΑ - άρθρο 14 του Κώδικα ΦΠΑ", }, }, { - Value: "5", + Code: "5", Name: i18n.String{ i18n.EN: "Without VAT - article 16 of the VAT code", i18n.EL: "Χωρίς ΦΠΑ - άρθρο 16 του Κώδικα ΦΠΑ", }, }, { - Value: "6", + Code: "6", Name: i18n.String{ i18n.EN: "Without VAT - article 19 of the VAT code", i18n.EL: "Χωρίς ΦΠΑ - άρθρο 19 του Κώδικα ΦΠΑ", }, }, { - Value: "7", + Code: "7", Name: i18n.String{ i18n.EN: "Without VAT - article 22 of the VAT code", i18n.EL: "Χωρίς ΦΠΑ - άρθρο 22 του Κώδικα ΦΠΑ", }, }, { - Value: "8", + Code: "8", Name: i18n.String{ i18n.EN: "Without VAT - article 24 of the VAT code", i18n.EL: "Χωρίς ΦΠΑ - άρθρο 24 του Κώδικα ΦΠΑ", }, }, { - Value: "9", + Code: "9", Name: i18n.String{ i18n.EN: "Without VAT - article 25 of the VAT code", i18n.EL: "Χωρίς ΦΠΑ - άρθρο 25 του Κώδικα ΦΠΑ", }, }, { - Value: "10", + Code: "10", Name: i18n.String{ i18n.EN: "Without VAT - article 26 of the VAT code", i18n.EL: "Χωρίς ΦΠΑ - άρθρο 26 του Κώδικα ΦΠΑ", }, }, { - Value: "11", + Code: "11", Name: i18n.String{ i18n.EN: "Without VAT - article 27 of the VAT code", i18n.EL: "Χωρίς ΦΠΑ - άρθρο 27 του Κώδικα ΦΠΑ", }, }, { - Value: "12", + Code: "12", Name: i18n.String{ i18n.EN: "Without VAT - article 27 - Seagoing Vessels of the VAT code", i18n.EL: "Χωρίς ΦΠΑ - άρθρο 27 - Πλοία Ανοικτής Θαλάσσης του Κώδικα ΦΠΑ", }, }, { - Value: "13", + Code: "13", Name: i18n.String{ i18n.EN: "Without VAT - article 27.1.γ - Seagoing Vessels of the VAT code", i18n.EL: "Χωρίς ΦΠΑ - άρθρο 27.1.γ - Πλοία Ανοικτής Θαλάσσης του Κώδικα ΦΠΑ", }, }, { - Value: "14", + Code: "14", Name: i18n.String{ i18n.EN: "Without VAT - article 28 of the VAT code", i18n.EL: "Χωρίς ΦΠΑ - άρθρο 28 του Κώδικα ΦΠΑ", }, }, { - Value: "15", + Code: "15", Name: i18n.String{ i18n.EN: "Without VAT - article 39 of the VAT code", i18n.EL: "Χωρίς ΦΠΑ - άρθρο 39 του Κώδικα ΦΠΑ", }, }, { - Value: "16", + Code: "16", Name: i18n.String{ i18n.EN: "Without VAT - article 39a of the VAT code", i18n.EL: "Χωρίς ΦΠΑ - άρθρο 39α του Κώδικα ΦΠΑ", }, }, { - Value: "17", + Code: "17", Name: i18n.String{ i18n.EN: "Without VAT - article 40 of the VAT code", i18n.EL: "Χωρίς ΦΠΑ - άρθρο 40 του Κώδικα ΦΠΑ", }, }, { - Value: "18", + Code: "18", Name: i18n.String{ i18n.EN: "Without VAT - article 41 of the VAT code", i18n.EL: "Χωρίς ΦΠΑ - άρθρο 41 του Κώδικα ΦΠΑ", }, }, { - Value: "19", + Code: "19", Name: i18n.String{ i18n.EN: "Without VAT - article 47 of the VAT code", i18n.EL: "Χωρίς ΦΠΑ - άρθρο 47 του Κώδικα ΦΠΑ", }, }, { - Value: "20", + Code: "20", Name: i18n.String{ i18n.EN: "VAT included - article 43 of the VAT code", i18n.EL: "ΦΠΑ εμπεριεχόμενος - άρθρο 43 του Κώδικα ΦΠΑ", }, }, { - Value: "21", + Code: "21", Name: i18n.String{ i18n.EN: "VAT included - article 44 of the VAT code", i18n.EL: "ΦΠΑ εμπεριεχόμενος - άρθρο 44 του Κώδικα ΦΠΑ", }, }, { - Value: "22", + Code: "22", Name: i18n.String{ i18n.EN: "VAT included - article 45 of the VAT code", i18n.EL: "ΦΠΑ εμπεριεχόμενος - άρθρο 45 του Κώδικα ΦΠΑ", }, }, { - Value: "23", + Code: "23", Name: i18n.String{ i18n.EN: "VAT included - article 46 of the VAT code", i18n.EL: "ΦΠΑ εμπεριεχόμενος - άρθρο 46 του Κώδικα ΦΠΑ", }, }, { - Value: "24", + Code: "24", Name: i18n.String{ i18n.EN: "Without VAT - article 6 of the VAT code", i18n.EL: "Χωρίς ΦΠΑ - άρθρο 6 του Κώδικα ΦΠΑ", }, }, { - Value: "25", + Code: "25", Name: i18n.String{ i18n.EN: "Without VAT - ΠΟΛ.1029/1995", i18n.EL: "Χωρίς ΦΠΑ - ΠΟΛ.1029/1995", }, }, { - Value: "26", + Code: "26", Name: i18n.String{ i18n.EN: "Without VAT - ΠΟΛ.1167/2015", i18n.EL: "Χωρίς ΦΠΑ - ΠΟΛ.1167/2015", }, }, { - Value: "27", + Code: "27", Name: i18n.String{ i18n.EN: "Without VAT - Other VAT exceptions", i18n.EL: "Λοιπές Εξαιρέσεις ΦΠΑ", }, }, { - Value: "28", + Code: "28", Name: i18n.String{ i18n.EN: "Without VAT - Article 24 (b) (1) of the VAT Code (Tax Free)", i18n.EL: "Χωρίς ΦΠΑ – άρθρο 24 περ. β' παρ.1 του Κώδικα ΦΠΑ, (Tax Free)", }, }, { - Value: "29", + Code: "29", Name: i18n.String{ i18n.EN: "Without VAT - Article 47b of the VAT Code (OSS non-EU scheme)", i18n.EL: "Χωρίς ΦΠΑ – άρθρο 47β, του Κώδικα ΦΠΑ (OSS μη ενωσιακό καθεστώς)", }, }, { - Value: "30", + Code: "30", Name: i18n.String{ i18n.EN: "Without VAT - Article 47c of the VAT Code (OSS EU scheme)", i18n.EL: "Χωρίς ΦΠΑ – άρθρο 47γ, του Κώδικα ΦΠΑ (OSS ενωσιακό καθεστώς)", }, }, { - Value: "31", + Code: "31", Name: i18n.String{ i18n.EN: "Excluding VAT - Article 47d of the VAT Code (IOSS)", i18n.EL: "Χωρίς ΦΠΑ – άρθρο 47δ του Κώδικα ΦΠΑ (IOSS)", @@ -697,79 +697,79 @@ var extensions = []*cbc.KeyDefinition{ i18n.EN: "Income Classification Category", i18n.EL: "Κωδικός Κατηγορίας Χαρακτηρισμού Εσόδων", }, - Values: []*cbc.ValueDefinition{ + Values: []*cbc.Definition{ { - Value: "category1_1", + Code: "category1_1", Name: i18n.String{ i18n.EN: "Commodity Sale Income (+)/(-)", i18n.EL: "Έσοδα από Πώληση Εμπορευμάτων (+)/(-)", }, }, { - Value: "category1_2", + Code: "category1_2", Name: i18n.String{ i18n.EN: "Product Sale Income (+)/(-)", i18n.EL: "Έσοδα από Πώληση Προϊόντων (+)/(-)", }, }, { - Value: "category1_3", + Code: "category1_3", Name: i18n.String{ i18n.EN: "Provision of Services Income (+)/(-)", i18n.EL: "Έσοδα από Παροχή Υπηρεσιών (+)/(-)", }, }, { - Value: "category1_4", + Code: "category1_4", Name: i18n.String{ i18n.EN: "Sale of Fixed Assets Income (+)/(-)", i18n.EL: "Έσοδα από Πώληση Παγίων (+)/(-)", }, }, { - Value: "category1_5", + Code: "category1_5", Name: i18n.String{ i18n.EN: "Other Income/Profits (+)/(-)", i18n.EL: "Λοιπά Έσοδα/ Κέρδη (+)/(-)", }, }, { - Value: "category1_6", + Code: "category1_6", Name: i18n.String{ i18n.EN: "Self-Deliveries/Self-Supplies (+)/(-)", i18n.EL: "Αυτοπαραδόσεις / Ιδιοχρησιμοποιήσεις (+)/(-)", }, }, { - Value: "category1_7", + Code: "category1_7", Name: i18n.String{ i18n.EN: "Income on behalf of Third Parties (+)/(-)", i18n.EL: "Έσοδα για λ/σμο τρίτων (+)/(-)", }, }, { - Value: "category1_8", + Code: "category1_8", Name: i18n.String{ i18n.EN: "Past fiscal years income (+)/(-)", i18n.EL: "Έσοδα προηγούμενων χρήσεων (+)/ (-)", }, }, { - Value: "category1_9", + Code: "category1_9", Name: i18n.String{ i18n.EN: "Future fiscal years income (+)/(-)", i18n.EL: "Έσοδα επομένων χρήσεων (+)/(-)", }, }, { - Value: "category1_10", + Code: "category1_10", Name: i18n.String{ i18n.EN: "Other Income Adjustment/Regularisation Entries (+)/(-)", i18n.EL: "Λοιπές Εγγραφές Τακτοποίησης Εσόδων (+)/(-)", }, }, { - Value: "category1_95", + Code: "category1_95", Name: i18n.String{ i18n.EN: "Other Income-related Information (+)/(-)", i18n.EL: "Λοιπά Πληροφοριακά Στοιχεία Εσόδων (+)/(-)", @@ -783,240 +783,240 @@ var extensions = []*cbc.KeyDefinition{ i18n.EN: "Income Classification Type", i18n.EL: "Κωδικός Τύπου Χαρακτηρισμού Εσόδων", }, - Values: []*cbc.ValueDefinition{ + Values: []*cbc.Definition{ { - Value: "E3_106", + Code: "E3_106", Name: i18n.String{ i18n.EN: "Self-Production of Fixed Assets – Self-Deliveries – Destroying inventory/Commodities", i18n.EL: "Ιδιοπαραγωγή παγίων - Αυτοπαραδόσεις - Καταστροφές αποθεμάτων/Εμπορεύματα", }, }, { - Value: "E3_205", + Code: "E3_205", Name: i18n.String{ i18n.EN: "Self-Production of Fixed Assets – Self-Deliveries – Destroying inventory/Raw and other materials", i18n.EL: "Ιδιοπαραγωγή παγίων - Αυτοπαραδόσεις - Καταστροφές αποθεμάτων/Πρώτες ύλες και λοιπά υλικά", }, }, { - Value: "E3_210", + Code: "E3_210", Name: i18n.String{ i18n.EN: "Self-Production of Fixed Assets – Self-Deliveries – Destroying inventory/Products and production in progress", i18n.EL: "Ιδιοπαραγωγή παγίων - Αυτοπαραδόσεις - Καταστροφές αποθεμάτων/Προϊόντα και παραγωγή σε εξέλιξη", }, }, { - Value: "E3_305", + Code: "E3_305", Name: i18n.String{ i18n.EN: "Self-Production of Fixed Assets – Self-Deliveries – Destroying inventory/Raw and other materials", i18n.EL: "Ιδιοπαραγωγή παγίων - Αυτοπαραδόσεις – Καταστροφές αποθεμάτων/Πρώτες ύλες και λοιπά υλικά", }, }, { - Value: "E3_310", + Code: "E3_310", Name: i18n.String{ i18n.EN: "Self-Production of Fixed Assets – Self-Deliveries – Destroying inventory/Products and production in progress", i18n.EL: "Ιδιοπαραγωγή παγίων - Αυτοπαραδόσεις - Καταστροφές αποθεμάτων/Προϊόντα και παραγωγή σε εξέλιξη", }, }, { - Value: "E3_318", + Code: "E3_318", Name: i18n.String{ i18n.EN: "Self-Production of Fixed Assets – Self-Deliveries – Destroying inventory/Production expenses", i18n.EL: "Ιδιοπαραγωγή παγίων - Αυτοπαραδόσεις - Καταστροφές αποθεμάτων/Έξοδα παραγωγής", }, }, { - Value: "E3_561_001", + Code: "E3_561_001", Name: i18n.String{ i18n.EN: "Wholesale Sales of Goods and Services – for Traders", i18n.EL: "Πωλήσεις αγαθών και υπηρεσιών Χονδρικές - Επιτηδευματιών", }, }, { - Value: "E3_561_002", + Code: "E3_561_002", Name: i18n.String{ i18n.EN: "Wholesale Sales of Goods and Services pursuant to article 39a paragraph 5 of the VAT Code (Law 2859/2000)", i18n.EL: "Πωλήσεις αγαθών και υπηρεσιών Χονδρικές βάσει άρθρου 39α παρ 5 του Κώδικα Φ.Π.Α. (Ν.2859/2000)", }, }, { - Value: "E3_561_003", + Code: "E3_561_003", Name: i18n.String{ i18n.EN: "Retail Sales of Goods and Services – Private Clientele", i18n.EL: "Πωλήσεις αγαθών και υπηρεσιών Λιανικές - Ιδιωτική Πελατεία", }, }, { - Value: "E3_561_004", + Code: "E3_561_004", Name: i18n.String{ i18n.EN: "Retail Sales of Goods and Services pursuant to article 39a paragraph 5 of the VAT Code (Law 2859/2000)", i18n.EL: "Πωλήσεις αγαθών και υπηρεσιών Λιανικές βάσει άρθρου 39α παρ 5 του Κώδικα Φ.Π.Α. (Ν.2859/2000)", }, }, { - Value: "E3_561_005", + Code: "E3_561_005", Name: i18n.String{ i18n.EN: "Intra-Community Foreign Sales of Goods and Services", i18n.EL: "Πωλήσεις αγαθών και υπηρεσιών Εξωτερικού Ενδοκοινοτικές", }, }, { - Value: "E3_561_006", + Code: "E3_561_006", Name: i18n.String{ i18n.EN: "Third Country Foreign Sales of Goods and Services", i18n.EL: "Πωλήσεις αγαθών και υπηρεσιών Εξωτερικού Τρίτες Χώρες", }, }, { - Value: "E3_561_007", + Code: "E3_561_007", Name: i18n.String{ i18n.EN: "Other Sales of Goods and Services", i18n.EL: "Πωλήσεις αγαθών και υπηρεσιών Λοιπά", }, }, { - Value: "E3_562", + Code: "E3_562", Name: i18n.String{ i18n.EN: "Other Ordinary Income", i18n.EL: "Λοιπά συνήθη έσοδα", }, }, { - Value: "E3_563", + Code: "E3_563", Name: i18n.String{ i18n.EN: "Credit Interest and Related Income", i18n.EL: "Πιστωτικοί τόκοι και συναφή έσοδα", }, }, { - Value: "E3_564", + Code: "E3_564", Name: i18n.String{ i18n.EN: "Credit Exchange Differences", i18n.EL: "Πιστωτικές συναλλαγματικές διαφορές", }, }, { - Value: "E3_565", + Code: "E3_565", Name: i18n.String{ i18n.EN: "Income from Participations", i18n.EL: "Έσοδα συμμετοχών", }, }, { - Value: "E3_566", + Code: "E3_566", Name: i18n.String{ i18n.EN: "Profits from Disposing Non-Current Assets", i18n.EL: "Κέρδη από διάθεση μη κυκλοφορούντων περιουσιακών στοιχείων", }, }, { - Value: "E3_567", + Code: "E3_567", Name: i18n.String{ i18n.EN: "Profits from the Reversal of Provisions and Impairments", i18n.EL: "Κέρδη από αναστροφή προβλέψεων και απομειώσεων", }, }, { - Value: "E3_568", + Code: "E3_568", Name: i18n.String{ i18n.EN: "Profits from Measurement at Fair Value", i18n.EL: "Κέρδη από επιμέτρηση στην εύλογη αξία", }, }, { - Value: "E3_570", + Code: "E3_570", Name: i18n.String{ i18n.EN: "Extraordinary income and profits", i18n.EL: "Ασυνήθη έσοδα και κέρδη", }, }, { - Value: "E3_595", + Code: "E3_595", Name: i18n.String{ i18n.EN: "Self-Production Expenses", i18n.EL: "Έξοδα σε ιδιοπαραγωγή", }, }, { - Value: "E3_596", + Code: "E3_596", Name: i18n.String{ i18n.EN: "Subsidies - Grants", i18n.EL: "Επιδοτήσεις - Επιχορηγήσεις", }, }, { - Value: "E3_597", + Code: "E3_597", Name: i18n.String{ i18n.EN: "Subsidies – Grants for Investment Purposes – Expense Coverage", i18n.EL: "Επιδοτήσεις - Επιχορηγήσεις για επενδυτικούς σκοπούς - κάλυψη δαπανών", }, }, { - Value: "E3_880_001", + Code: "E3_880_001", Name: i18n.String{ i18n.EN: "Wholesale Sales of Fixed Assets", i18n.EL: "Πωλήσεις Παγίων Χονδρικές", }, }, { - Value: "E3_880_002", + Code: "E3_880_002", Name: i18n.String{ i18n.EN: "Retail Sales of Fixed Assets", i18n.EL: "Πωλήσεις Παγίων Λιανικές", }, }, { - Value: "E3_880_003", + Code: "E3_880_003", Name: i18n.String{ i18n.EN: "Intra-Community Foreign Sales of Fixed Assets", i18n.EL: "Πωλήσεις Παγίων Εξωτερικού Ενδοκοινοτικές", }, }, { - Value: "E3_880_004", + Code: "E3_880_004", Name: i18n.String{ i18n.EN: "Third Country Foreign Sales of Fixed Assets", i18n.EL: "Πωλήσεις Παγίων Εξωτερικού Τρίτες Χώρες", }, }, { - Value: "E3_881_001", + Code: "E3_881_001", Name: i18n.String{ i18n.EN: "Wholesale Sales on behalf of Third Parties", i18n.EL: "Πωλήσεις για λογ/σμο Τρίτων Χονδρικές", }, }, { - Value: "E3_881_002", + Code: "E3_881_002", Name: i18n.String{ i18n.EN: "Retail Sales on behalf of Third Parties", i18n.EL: "Πωλήσεις για λογ/σμο Τρίτων Λιανικές", }, }, { - Value: "E3_881_003", + Code: "E3_881_003", Name: i18n.String{ i18n.EN: "Intra-Community Foreign Sales on behalf of Third Parties", i18n.EL: "Πωλήσεις για λογ/σμο Τρίτων Εξωτερικού Ενδοκοινοτικές", }, }, { - Value: "E3_881_004", + Code: "E3_881_004", Name: i18n.String{ i18n.EN: "Third Country Foreign Sales on behalf of Third Parties", i18n.EL: "Πωλήσεις για λογ/σμο Τρίτων Εξωτερικού Τρίτες Χώρες", }, }, { - Value: "E3_598_001", + Code: "E3_598_001", Name: i18n.String{ i18n.EN: "Sales of goods belonging to excise duty", i18n.EL: "Πωλήσεις αγαθών που υπάγονται σε ΕΦΚ", }, }, { - Value: "E3_598_003", + Code: "E3_598_003", Name: i18n.String{ i18n.EN: "Sales on behalf of farmers through an agricultural cooperative e.t.c.", i18n.EL: "Πωλήσεις για λογαριασμό αγροτών μέσω αγροτικού συνεταιρισμού κ.λ.π.", diff --git a/addons/gr/mydata/scenarios.go b/addons/gr/mydata/scenarios.go index 217279fe..35e0bc34 100644 --- a/addons/gr/mydata/scenarios.go +++ b/addons/gr/mydata/scenarios.go @@ -18,7 +18,7 @@ const ( var invoiceTags = &tax.TagSet{ Schema: bill.ShortSchemaInvoice, - List: []*cbc.KeyDefinition{ + List: []*cbc.Definition{ { Key: TagIslands, Name: i18n.String{ diff --git a/addons/gr/mydata/tax_combo.go b/addons/gr/mydata/tax_combo.go index 6e60600e..12d3d1dc 100644 --- a/addons/gr/mydata/tax_combo.go +++ b/addons/gr/mydata/tax_combo.go @@ -7,7 +7,7 @@ import ( "github.com/invopop/validation" ) -var taxComboMapVAT = map[cbc.Key]tax.ExtValue{ +var taxComboMapVAT = map[cbc.Key]cbc.Code{ tax.RateStandard: "1", tax.RateReduced: "2", tax.RateSuperReduced: "3", diff --git a/addons/it/sdi/extensions.go b/addons/it/sdi/extensions.go index 8fd6ec9f..92e3a300 100644 --- a/addons/it/sdi/extensions.go +++ b/addons/it/sdi/extensions.go @@ -18,7 +18,7 @@ const ( ExtKeyVATLiability cbc.Key = "it-sdi-vat-liability" ) -var extensions = []*cbc.KeyDefinition{ +var extensions = []*cbc.Definition{ { Key: ExtKeyFormat, Name: i18n.String{ @@ -35,16 +35,16 @@ var extensions = []*cbc.KeyDefinition{ bodies and must use the "FPA12" format. `), }, - Values: []*cbc.ValueDefinition{ + Values: []*cbc.Definition{ { - Value: "FPA12", + Code: "FPA12", Name: i18n.String{ i18n.EN: "Public Administration", i18n.IT: "Pubblica Amministrazione", }, }, { - Value: "FPR12", + Code: "FPR12", Name: i18n.String{ i18n.EN: "Private Parties (default)", i18n.IT: "Soggetti Privati (predefinito)", @@ -64,156 +64,156 @@ var extensions = []*cbc.KeyDefinition{ used to determine the correct schema to use when validating the document. `), }, - Values: []*cbc.ValueDefinition{ + Values: []*cbc.Definition{ { - Value: "TD01", + Code: "TD01", Name: i18n.String{ i18n.EN: "Regular Invoice", i18n.IT: "Fattura", }, }, { - Value: "TD02", + Code: "TD02", Name: i18n.String{ i18n.EN: "Advance or down payment on invoice", i18n.IT: "Acconto / anticipo su fattura", }, }, { - Value: "TD03", + Code: "TD03", Name: i18n.String{ i18n.EN: "Advance or down payment on freelance invoice", i18n.IT: "Acconto / anticipo su parcella", }, }, { - Value: "TD04", + Code: "TD04", Name: i18n.String{ i18n.EN: "Credit Note", i18n.IT: "Nota di credito", }, }, { - Value: "TD05", + Code: "TD05", Name: i18n.String{ i18n.EN: "Debit Note", i18n.IT: "Nota di debito", }, }, { - Value: "TD06", + Code: "TD06", Name: i18n.String{ i18n.EN: "Freelancer invoice with retained taxes", i18n.IT: "Parcella", }, }, { - Value: "TD07", + Code: "TD07", Name: i18n.String{ i18n.EN: "Simplified Invoice", i18n.IT: "Fattura Semplificata", }, }, { - Value: "TD08", + Code: "TD08", Name: i18n.String{ i18n.EN: "Simplified Credit Note", i18n.IT: "Nota di credito semplificata", }, }, { - Value: "TD09", + Code: "TD09", Name: i18n.String{ i18n.EN: "Simplified Debit Note", i18n.IT: "Nota di debito semplificata", }, }, { - Value: "TD16", + Code: "TD16", Name: i18n.String{ i18n.EN: "Reverse charge", i18n.IT: "Integrazione fattura reverse charge interno", }, }, { - Value: "TD17", + Code: "TD17", Name: i18n.String{ i18n.EN: "Self-billed Import", i18n.IT: "Integrazione/autofattura per acquisto servizi da estero", }, }, { - Value: "TD18", + Code: "TD18", Name: i18n.String{ i18n.EN: "Self-billed EU Goods Import", i18n.IT: "Integrazione per acquisto beni intracomunitari", }, }, { - Value: "TD19", + Code: "TD19", Name: i18n.String{ i18n.EN: "Self-billed Goods Import", i18n.IT: "Integrazione/autofattura per acquisto beni ex art.17 c.2 DPR 633/72", }, }, { - Value: "TD20", + Code: "TD20", Name: i18n.String{ i18n.EN: "Self-billed Regularization", i18n.IT: "Autofattura per regolarizzazione e integrazione delle fatture - art.6 c.8 d.lgs.471/97 o art.46 c.5 D.L.331/93", }, }, { - Value: "TD21", + Code: "TD21", Name: i18n.String{ i18n.EN: "Self-billed invoice when ceiling exceeded", i18n.IT: "Autofattura per splafonamento", }, }, { - Value: "TD22", + Code: "TD22", Name: i18n.String{ i18n.EN: "Self-billed for goods extracted from VAT warehouse", i18n.IT: "Estrazione beni da Deposito IVA", }, }, { - Value: "TD23", + Code: "TD23", Name: i18n.String{ i18n.EN: "Self-billed for goods extracted from VAT warehouse with VAT payment", i18n.IT: "Estrazione beni da Deposito IVA con versamento IVA", }, }, { - Value: "TD24", + Code: "TD24", Name: i18n.String{ i18n.EN: "Deferred invoice ex art.21, c.4, lett. a) DPR 633/72", i18n.IT: "Fattura differita - art.21 c.4 lett. a", }, }, { - Value: "TD25", + Code: "TD25", Name: i18n.String{ i18n.EN: "Deferred invoice ex art.21, c.4, third period lett. b) DPR 633/72", i18n.IT: "Fattura differita - art.21 c.4 terzo periodo lett. b", }, }, { - Value: "TD26", + Code: "TD26", Name: i18n.String{ i18n.EN: "Sale of depreciable assets and for internal transfers (ex art.36 DPR 633/72", i18n.IT: "Cessione di beni ammortizzabili e per passaggi interni - art.36 DPR 633/72", }, }, { - Value: "TD27", + Code: "TD27", Name: i18n.String{ i18n.EN: "Self-billed for self consumption or for free transfer without recourse", i18n.IT: "Fattura per autoconsumo o per cessioni gratuite senza rivalsa", }, }, { - Value: "TD28", + Code: "TD28", Name: i18n.String{ i18n.EN: "Purchases from San Marino with VAT (paper invoice)", i18n.IT: "Acquisti da San Marino con IVA (fattura cartacea)", @@ -227,76 +227,76 @@ var extensions = []*cbc.KeyDefinition{ i18n.EN: "Fiscal Regime Code", i18n.IT: "Codice Regime Fiscale", }, - Values: []*cbc.ValueDefinition{ - {Value: "RF01", Name: i18n.String{ + Values: []*cbc.Definition{ + {Code: "RF01", Name: i18n.String{ i18n.EN: "Ordinary", i18n.IT: "Regime Ordinario", }}, - {Value: "RF02", Name: i18n.String{ + {Code: "RF02", Name: i18n.String{ i18n.EN: "Minimum taxpayers (Art. 1, section 96-117, Italian Law 244/07)", i18n.IT: "Regime dei contribuenti minimi (art. 1,c.96-117, L. 244/2007)", }}, - {Value: "RF04", Name: i18n.String{ + {Code: "RF04", Name: i18n.String{ i18n.EN: "Agriculture and connected activities and fishing (Arts. 34 and 34-bis, Italian Presidential Decree 633/72)", i18n.IT: "Agricoltura e attività connesse e pesca (artt. 34 e 34-bis, D.P.R. 633/1972)", }}, - {Value: "RF05", Name: i18n.String{ + {Code: "RF05", Name: i18n.String{ i18n.EN: "Sale of salts and tobaccos (Art. 74, section 1, Italian Presidential Decree 633/72)", i18n.IT: "Vendita sali e tabacchi (art. 74, c.1, D.P.R. 633/1972)", }}, - {Value: "RF06", Name: i18n.String{ + {Code: "RF06", Name: i18n.String{ i18n.EN: "Match sales (Art. 74, section 1, Italian Presidential Decree 633/72)", i18n.IT: "Commercio dei fiammiferi (art. 74, c.1, D.P.R. 633/1972)", }}, - {Value: "RF07", Name: i18n.String{ + {Code: "RF07", Name: i18n.String{ i18n.EN: "Publishing (Art. 74, section 1, Italian Presidential Decree 633/72)", i18n.IT: "Editoria (art. 74, c.1, D.P.R. 633/1972)", }}, - {Value: "RF08", Name: i18n.String{ + {Code: "RF08", Name: i18n.String{ i18n.EN: "Management of public telephone services (Art. 74, section 1, Italian Presidential Decree 633/72)", i18n.IT: "Gestione di servizi di telefonia pubblica (art. 74, c.1, D.P.R. 633/1972)", }}, - {Value: "RF09", Name: i18n.String{ + {Code: "RF09", Name: i18n.String{ i18n.EN: "Resale of public transport and parking documents (Art. 74, section 1, Italian Presidential Decree 633/72)", i18n.IT: "Rivendita di documenti di trasporto pubblico e di sosta (art. 74, c.1, D.P.R. 633/1972)", }}, - {Value: "RF10", Name: i18n.String{ + {Code: "RF10", Name: i18n.String{ i18n.EN: "Entertainment, gaming and other activities referred to by the tariff attached to Italian Presidential Decree 640/72 (Art. 74, section 6, Italian Presidential Decree 633/72)", i18n.IT: "Intrattenimenti, giochi e altre attività di cui alla tariffa allegata al D.P.R. 640/72 (art. 74, c.6, D.P.R. 633/1972)", }}, - {Value: "RF11", Name: i18n.String{ + {Code: "RF11", Name: i18n.String{ i18n.EN: "Travel and tourism agencies (Art. 74-ter, Italian Presidential Decree 633/72)", i18n.IT: "Agenzie di viaggi e turismo (art. 74-ter, D.P.R. 633/1972)", }}, - {Value: "RF12", Name: i18n.String{ + {Code: "RF12", Name: i18n.String{ i18n.EN: "Farmhouse accommodation/restaurants (Art. 5, section 2, Italian law 413/91)", i18n.IT: "Agriturismo (art. 5, c.2, L. 413/1991)", }}, - {Value: "RF13", Name: i18n.String{ + {Code: "RF13", Name: i18n.String{ i18n.EN: "Door-to-door sales (Art. 25-bis, section 6, Italian Presidential Decree 600/73)", i18n.IT: "Vendite a domicilio (art. 25-bis, c.6, D.P.R. 600/1973)", }}, - {Value: "RF14", Name: i18n.String{ + {Code: "RF14", Name: i18n.String{ i18n.EN: "Resale of used goods, artworks, antiques or collector's items (Art. 36, Italian Decree Law 41/95)", i18n.IT: "Rivendita di beni usati, di oggetti d’arte, d’antiquariato o da collezione (art. 36, D.L. 41/1995)", }}, - {Value: "RF15", Name: i18n.String{ + {Code: "RF15", Name: i18n.String{ i18n.EN: "Artwork, antiques or collector's items auction agencies (Art. 40-bis, Italian Decree Law 41/95)", i18n.IT: "Agenzie di vendite all’asta di oggetti d’arte, antiquariato o da collezione (art. 40-bis, D.L. 41/1995)", }}, - {Value: "RF16", Name: i18n.String{ + {Code: "RF16", Name: i18n.String{ i18n.EN: "VAT paid in cash by P.A. (Art. 6, section 5, Italian Presidential Decree 633/72)", i18n.IT: "IVA per cassa P.A. (art. 6, c.5, D.P.R. 633/1972)", }}, - {Value: "RF17", Name: i18n.String{ + {Code: "RF17", Name: i18n.String{ i18n.EN: "VAT paid in cash by subjects with business turnover below Euro 200,000 (Art. 7, Italian Decree Law 185/2008)", i18n.IT: "IVA per cassa (art. 32-bis, D.L. 83/2012)", }}, - {Value: "RF19", Name: i18n.String{ + {Code: "RF19", Name: i18n.String{ i18n.EN: "Flat rate (Art. 1, section 54-89, Italian Law 190/2014)", i18n.IT: "Regime forfettario", }}, - {Value: "RF18", Name: i18n.String{ + {Code: "RF18", Name: i18n.String{ i18n.EN: "Other", i18n.IT: "Altro", }}, @@ -309,149 +309,149 @@ var extensions = []*cbc.KeyDefinition{ i18n.EN: "Exemption Code", i18n.IT: "Natura Esenzione", }, - Values: []*cbc.ValueDefinition{ + Values: []*cbc.Definition{ { - Value: "N1", + Code: "N1", Name: i18n.String{ i18n.EN: "Excluded pursuant to Art. 15, DPR 633/72", i18n.IT: "Escluse ex. art. 15 del D.P.R. 633/1972", }, }, { - Value: "N2.1", + Code: "N2.1", Name: i18n.String{ i18n.EN: "Not subject pursuant to Art. 7, DPR 633/72", i18n.IT: "Non soggette ex. art. 7 del D.P.R. 633/72", }, }, { - Value: "N2.2", + Code: "N2.2", Name: i18n.String{ i18n.EN: "Not subject - other", i18n.IT: "Non soggette - altri casi", }, }, { - Value: "N3.1", + Code: "N3.1", Name: i18n.String{ i18n.EN: "Not taxable - exports", i18n.IT: "Non imponibili - esportazioni", }, }, { - Value: "N3.2", + Code: "N3.2", Name: i18n.String{ i18n.EN: "Not taxable - intra-community supplies", i18n.IT: "Non imponibili - cessioni intracomunitarie", }, }, { - Value: "N3.3", + Code: "N3.3", Name: i18n.String{ i18n.EN: "Not taxable - transfers to San Marino", i18n.IT: "Non imponibili - cessioni verso San Marino", }, }, { - Value: "N3.4", + Code: "N3.4", Name: i18n.String{ i18n.EN: "Not taxable - export supplies of goods and services", i18n.IT: "Non Imponibili - operazioni assimilate alle cessioni all'esportazione", }, }, { - Value: "N3.5", + Code: "N3.5", Name: i18n.String{ i18n.EN: "Not taxable - declaration of intent", i18n.IT: "Non imponibili - dichiarazioni d'intento", }, }, { - Value: "N3.6", + Code: "N3.6", Name: i18n.String{ i18n.EN: "Not taxable - other", i18n.IT: "Non imponibili - altre operazioni che non concorrono alla formazione del plafond", }, }, { - Value: "N4", + Code: "N4", Name: i18n.String{ i18n.EN: "Exempt", i18n.IT: "Esenti", }, }, { - Value: "N5", + Code: "N5", Name: i18n.String{ i18n.EN: "Margin regime / VAT not exposed", i18n.IT: "Regime del margine/IVA non esposta in fattura", }, }, { - Value: "N6.1", + Code: "N6.1", Name: i18n.String{ i18n.EN: "Reverse charge - Transfer of scrap and of other recyclable materials", i18n.IT: "Inversione contabile - cessione di rottami e altri materiali di recupero", }, }, { - Value: "N6.2", + Code: "N6.2", Name: i18n.String{ i18n.EN: "Reverse charge - Transfer of gold and pure silver pursuant to law 7/2000 as well as used jewelery to OPO", i18n.IT: "Inversione contabile - cessione di oro e argento ai sensi della legge 7/2000 nonché di oreficeria usata ad OPO", }, }, { - Value: "N6.3", + Code: "N6.3", Name: i18n.String{ i18n.EN: "Reverse charge - Construction subcontracting", i18n.IT: "Inversione contabile - subappalto nel settore edile", }, }, { - Value: "N6.4", + Code: "N6.4", Name: i18n.String{ i18n.EN: "Reverse charge - Transfer of buildings", i18n.IT: "Inversione contabile - cessione di fabbricati", }, }, { - Value: "N6.5", + Code: "N6.5", Name: i18n.String{ i18n.EN: "Reverse charge - Transfer of mobile phones", i18n.IT: "Inversione contabile - cessione di telefoni cellulari", }, }, { - Value: "N6.6", + Code: "N6.6", Name: i18n.String{ i18n.EN: "Reverse charge - Transfer of electronic products", i18n.IT: "Inversione contabile - cessione di prodotti elettronici", }, }, { - Value: "N6.7", + Code: "N6.7", Name: i18n.String{ i18n.EN: "Reverse charge - provisions in the construction and related sectors", i18n.IT: "Inversione contabile - prestazioni comparto edile e settori connessi", }, }, { - Value: "N6.8", + Code: "N6.8", Name: i18n.String{ i18n.EN: "Reverse charge - transactions in the energy sector", i18n.IT: "Inversione contabile - operazioni settore energetico", }, }, { - Value: "N6.9", + Code: "N6.9", Name: i18n.String{ i18n.EN: "Reverse charge - other cases", i18n.IT: "Inversione contabile - altri casi", }, }, { - Value: "N7", + Code: "N7", Name: i18n.String{ i18n.EN: "VAT paid in other EU countries (telecommunications, tele-broadcasting and electronic services provision pursuant to Art. 7 -octies letter a, b, art. 74-sexies Italian Presidential Decree 633/72)", i18n.IT: "IVA assolta in altro stato UE (prestazione di servizi di telecomunicazioni, tele-radiodiffusione ed elettronici ex art. 7-octies lett. a, b, art. 74-sexies DPR 633/72)", @@ -468,226 +468,226 @@ var extensions = []*cbc.KeyDefinition{ i18n.EN: "Retained Tax Payment Reason Code", i18n.IT: "Causale Pagamento Ritenuta", }, - Values: []*cbc.ValueDefinition{ + Values: []*cbc.Definition{ { - Value: "A", + Code: "A", Name: i18n.String{ i18n.EN: "Self-employment services falling within the exercise of habitual art or profession", i18n.IT: "Prestazioni di lavoro autonomo rientranti nell'esercizio di arte o professione abituale;", }, }, { - Value: "B", + Code: "B", Name: i18n.String{ i18n.EN: "Economic use of intellectual works, industrial patents, and processes, formulas or information related to experiences gained in the industrial, commercial or scientific field, by the author or inventor", i18n.IT: "Utilizzazione economica, da parte dell'autore o dell'inventore, di opere dell'ingegno, di brevetti industriali e di processi, formule o informazioni relativi ad esperienze acquisite in campo industriale, commerciale o scientifico;", }, }, { - Value: "C", + Code: "C", Name: i18n.String{ i18n.EN: "Profits deriving from contracts of association in participation and from contracts of co-interest, when the contribution consists exclusively of the provision of labor", i18n.IT: "Utili derivanti da contratti di associazione in partecipazione e da contratti di cointeressenza, quando l'apporto è costituito esclusivamente dalla prestazione di lavoro;", }, }, { - Value: "D", + Code: "D", Name: i18n.String{ i18n.EN: "Profits due to the promoting partners and founding partners of capital companies", i18n.IT: "Utili spettanti ai soci promotori ed ai soci fondatori delle società di capitali;", }, }, { - Value: "E", + Code: "E", Name: i18n.String{ i18n.EN: "Bills of exchange protests levied by municipal secretaries", i18n.IT: "Levata di protesti cambiari da parte dei segretari comunali;", }, }, { - Value: "F", + Code: "F", Name: i18n.String{ i18n.EN: "Allowances paid to honorary justices of the peace and honorary deputy prosecutors", i18n.IT: "Indennità corrisposte ai giudici onorari di pace e ai vice procuratori onorari;", }, }, { - Value: "G", + Code: "G", Name: i18n.String{ i18n.EN: "Allowances paid for the cessation of professional sports activities", i18n.IT: "Indennità corrisposte per la cessazione di attività sportiva professionale", }, }, { - Value: "H", + Code: "H", Name: i18n.String{ i18n.EN: "Allowances paid for the termination of agency relationships of individuals and partnerships, excluding amounts accrued up to December 31, 2003, already allocated for competence and taxed as business income", i18n.IT: "Indennità corrisposte per la cessazione dei rapporti di agenzia delle persone fisiche e delle società di persone con esclusione delle somme maturate entro il 31 dicembre 2003, già imputate per competenza e tassate come reddito d'impresa", }, }, { - Value: "I", + Code: "I", Name: i18n.String{ i18n.EN: "Allowances paid for the cessation of notarial functions", i18n.IT: "Indennità corrisposte per la cessazione da funzioni notarili", }, }, { - Value: "J", + Code: "J", Name: i18n.String{ i18n.EN: "Fees paid to occasional truffle collectors not identified for value-added tax purposes, in relation to the sale of truffles", i18n.IT: "Compensi corrisposti ai raccoglitori occasionali di tartufi non identificati ai fini dell'imposta sul valore aggiunto, in relazione alla cessione di tartufi", }, }, { - Value: "K", + Code: "K", Name: i18n.String{ i18n.EN: "Universal civil service checks referred to in Article 16 of Legislative Decree no. 40 of March 6, 2017", i18n.IT: "Assegni di servizio civile universale di cui all'art.16 del d.lgs. n. 40 del 6 marzo 2017", //nolint:misspell }, }, { - Value: "L", + Code: "L", Name: i18n.String{ i18n.EN: "Income deriving from the economic use of intellectual works, industrial patents, and processes, formulas, and information related to experiences gained in the industrial, commercial or scientific field, which are received by those entitled free of charge (e.g. heirs and legatees of the author and inventor)", i18n.IT: "Redditi derivanti dall'utilizzazione economica di opere dell'ingegno, di brevetti industriali e di processi, formule e informazioni relativi a esperienze acquisite in campo industriale, commerciale o scientifico, che sono percepiti dagli aventi causa a titolo gratuito (ad es. eredi e legatari dell'autore e inventore)", }, }, { - Value: "L1", + Code: "L1", Name: i18n.String{ i18n.EN: "Income deriving from the economic use of intellectual works, industrial patents, and processes, formulas, and information related to experiences gained in the industrial, commercial or scientific field, which are received by subjects who have purchased the rights to their use for valuable consideration", i18n.IT: "Redditi derivanti dall'utilizzazione economica di opere dell'ingegno, di brevetti industriali e di processi, formule e informazioni relativi a esperienze acquisite in campo industriale, commerciale o scientifico, che sono percepiti da soggetti che abbiano acquistato a titolo oneroso i diritti alla loro utilizzazione", }, }, { - Value: "M", + Code: "M", Name: i18n.String{ i18n.EN: "Self-employment services not carried out habitually", i18n.IT: "Prestazioni di lavoro autonomo non esercitate abitualmente", }, }, { - Value: "M1", + Code: "M1", Name: i18n.String{ i18n.EN: "Income deriving from the assumption of obligations to do, not to do, or to allow", i18n.IT: "Redditi derivanti dall'assunzione di obblighi di fare, di non fare o permettere", }, }, { - Value: "M2", + Code: "M2", Name: i18n.String{ i18n.EN: "Self-employment services not carried out habitually for which there is an obligation to register with the Separate ENPAPI Management", i18n.IT: "Prestazioni di lavoro autonomo non esercitate abitualmente per le quali sussiste l'obbligo di iscrizione alla gestione separata enpapi", }, }, { - Value: "N", + Code: "N", Name: i18n.String{ i18n.EN: "Travel allowances, flat-rate reimbursement of expenses, prizes, and fees paid: - in the direct exercise of amateur sports activities; - in relation to coordinated and continuous collaboration relationships of an administrative-managerial nature, not professional, provided in favor of amateur sports companies and associations, and choirs, bands, and amateur theater groups by the director and technical collaborators", i18n.IT: "Indennità di trasferta, rimborso forfetario di spese, premi e compensi erogati: - nell'esercizio diretto di attività sportive dilettantistiche; - in relazione a rapporti di collaborazione coordinata e continuativa di carattere amministrativo-gestionale di natura non professionale resi a favore di società e associazioni sportive dilettantistiche e di cori, bande e filodrammatiche da parte del direttore e dei collaboratori tecnici;", }, }, { - Value: "O", + Code: "O", Name: i18n.String{ i18n.EN: "Self-employment services not carried out habitually, for which there is no obligation to register with the separate management (Circ. INPS n. 104/2001)", i18n.IT: "Prestazioni di lavoro autonomo non esercitate abitualmente, per le quali non sussiste l'obbligo di iscrizione alla gestione separata (circ. inps n. 104/2001)", }, }, { - Value: "O1", + Code: "O1", Name: i18n.String{ i18n.EN: "Income deriving from the assumption of obligations to do, not to do, or to allow, for which there is no obligation to register with the separate management (Circ. INPS n. 104/2001)", i18n.IT: "Redditi derivanti dall'assunzione di obblighi di fare, di non fare o permettere, per le quali non sussiste l'obbligo di iscrizione alla gestione separata (circ. inps n. 104/2001)", }, }, { - Value: "P", + Code: "P", Name: i18n.String{ i18n.EN: "Fees paid to non-resident subjects without a permanent establishment for the use or concession of use of industrial, commercial or scientific equipment located in the State's territory or to Swiss companies or permanent establishments of Swiss companies meeting the requirements of Article 15, paragraph 2 of the Agreement between the European Community and the Swiss Confederation of October 26, 2004 (published in G.U.C.E. of December 29, 2004, no. L385/30)", i18n.IT: "Compensi corrisposti a soggetti non residenti privi di stabile organizzazione per l'uso o la concessione in uso di attrezzature industriali, commerciali o scientifiche che si trovano nel territorio dello stato ovvero a società svizzere o stabili organizzazioni di società svizzere che possiedono i requisiti di cui all'art. 15, comma 2 dell'accordo tra la comunità europea e la confederazione svizzera del 26 ottobre 2004 (pubblicato in g.u.c.e. del 29 dicembre 2004 n. l385/30)", }, }, { - Value: "Q", + Code: "Q", Name: i18n.String{ i18n.EN: "Commissions paid to a single-mandate agent or commercial representative", i18n.IT: "Provvigioni corrisposte ad agente o rappresentante di commercio monomandatario", }, }, { - Value: "R", + Code: "R", Name: i18n.String{ i18n.EN: "Commissions paid to a multi-mandate agent or commercial representative", i18n.IT: "Provvigioni corrisposte ad agente o rappresentante di commercio plurimandatario", }, }, { - Value: "S", + Code: "S", Name: i18n.String{ i18n.EN: "Commissions paid to a commission agent", i18n.IT: "Provvigioni corrisposte a commissionario", }, }, { - Value: "T", + Code: "T", Name: i18n.String{ i18n.EN: "Commissions paid to a broker", i18n.IT: "Provvigioni corrisposte a mediatore", }, }, { - Value: "U", + Code: "U", Name: i18n.String{ i18n.EN: "Commissions paid to a business finder", i18n.IT: "Provvigioni corrisposte a procacciatore di affari", }, }, { - Value: "V", + Code: "V", Name: i18n.String{ i18n.EN: "Commissions paid to a home sales agent; commissions paid to an agent for door-to-door and street sales of daily newspapers and periodicals (Law of February 25, 1987, no. 67)", i18n.IT: "Provvigioni corrisposte a incaricato per le vendite a domicilio; provvigioni corrisposte a incaricato per la vendita porta a porta e per la vendita ambulante di giornali quotidiani e periodici (l. 25 febbraio 1987, n. 67);", }, }, { - Value: "V1", + Code: "V1", Name: i18n.String{ i18n.EN: "Income deriving from non-habitual commercial activities (e.g. commissions paid for occasional services to agents or commercial representatives, brokers, business finders)", i18n.IT: "Redditi derivanti da attività commerciali non esercitate abitualmente (ad esempio, provvigioni corrisposte per prestazioni occasionali ad agente o rappresentante di commercio, mediatore, procacciatore d'affari);", }, }, { - Value: "V2", + Code: "V2", Name: i18n.String{ i18n.EN: "Income from non-habitual services provided by direct home sales agents", i18n.IT: "Redditi derivanti dalle prestazioni non esercitate abitualmente rese dagli incaricati alla vendita diretta a domicilio;", }, }, { - Value: "W", + Code: "W", Name: i18n.String{ i18n.EN: "Considerations paid in 2021 for services related to subcontracting contracts to which the provisions contained in Article 25-ter of Presidential Decree no. 600 of September 29, 1973, have been applied", i18n.IT: "Corrispettivi erogati nel 2021 per prestazioni relative a contratti d'appalto cui si sono resi applicabili le disposizioni contenute nell'art. 25-ter del d.p.r. n. 600 del 29 settembre 1973;", }, }, { - Value: "X", + Code: "X", Name: i18n.String{ i18n.EN: "Fees paid in 2004 by resident companies or entities or by permanent establishments of foreign companies referred to in Article 26-quater, paragraph 1, letters a) and b) of Presidential Decree 600 of September 29, 1973, to companies or permanent establishments of companies located in another EU Member State meeting the requirements of the aforementioned Article 26-quater of Presidential Decree 600 of September 29, 1973, for which a refund of the withholding tax was made in 2006 pursuant to Article 4 of Legislative Decree no. 143 of May 30, 2005", i18n.IT: "Canoni corrisposti nel 2004 da società o enti residenti ovvero da stabili organizzazioni di società estere di cui all'art. 26-quater, comma 1, lett. a) e b) del d.p.r. 600 del 29 settembre 1973, a società o stabili organizzazioni di società, situate in altro stato membro dell'unione europea in presenza dei requisiti di cui al citato art. 26-quater, del d.p.r. 600 del 29 settembre 1973, per i quali è stato effettuato, nell'anno 2006, il rimborso della ritenuta ai sensi dell'art. 4 del d.lgs. 30 maggio 2005 n. 143;", }, }, { - Value: "Y", + Code: "Y", Name: i18n.String{ i18n.EN: "Fees paid from January 1, 2005, to July 26, 2005, by resident companies or entities or by permanent establishments of foreign companies referred to in Article 26-quater, paragraph 1, letters a) and b) of Presidential Decree no. 600 of September 29, 1973, to companies or permanent establishments of companies located in another EU Member State meeting the requirements of the aforementioned Article 26-quater of Presidential Decree 600 of September 29, 1973, for which a refund of the withholding tax was made in 2006 pursuant to Article 4 of Legislative Decree no. 143 of May 30, 2005", i18n.IT: "Canoni corrisposti dal 1° gennaio 2005 al 26 luglio 2005 da società o enti residenti ovvero da stabili organizzazioni di società estere di cui all'art. 26-quater, comma 1, lett. a) e b) del d.p.r. n. 600 del 29 settembre 1973, a società o stabili organizzazioni di società, situate in altro stato membro dell'unione europea in presenza dei requisiti di cui al citato art. 26-quater, del d.p.r. n. 600 del 29 settembre 1973, per i quali è stato effettuato, nell'anno 2006, il rimborso della ritenuta ai sensi dell'art. 4 del d.lgs. 30 maggio 2005 n. 143;", }, }, { - Value: "ZO", + Code: "ZO", Name: i18n.String{ i18n.EN: "Different title from the previous ones", i18n.IT: "Titolo diverso dai precedenti;", @@ -701,163 +701,163 @@ var extensions = []*cbc.KeyDefinition{ i18n.EN: "Payment Means", i18n.IT: "Modalità di Pagamento", }, - Values: []*cbc.ValueDefinition{ + Values: []*cbc.Definition{ { - Value: "MP01", + Code: "MP01", Name: i18n.String{ i18n.EN: "Cash", i18n.IT: "Contanti", }, }, { - Value: "MP02", + Code: "MP02", Name: i18n.String{ i18n.EN: "Check", i18n.IT: "Assegno", }, }, { - Value: "MP03", + Code: "MP03", Name: i18n.String{ i18n.EN: "Banker's Draft", i18n.IT: "Assegno circolare", }, }, { - Value: "MP04", + Code: "MP04", Name: i18n.String{ i18n.EN: "Cash at Treasury", i18n.IT: "Contanti presso Tesoreria", // nolint:misspell }, }, { - Value: "MP05", + Code: "MP05", Name: i18n.String{ i18n.EN: "Bank Transfer", i18n.IT: "Bonifico", }, }, { - Value: "Mp06", + Code: "Mp06", Name: i18n.String{ i18n.EN: "Promissory Note", i18n.IT: "Vaglia cambiario", }, }, { - Value: "MP07", + Code: "MP07", Name: i18n.String{ i18n.EN: "Bank payment slip", i18n.IT: "Bollettino bancario", }, }, { - Value: "MP08", + Code: "MP08", Name: i18n.String{ i18n.EN: "Payment card", i18n.IT: "Carta di pagamento", }, }, { - Value: "MP09", + Code: "MP09", Name: i18n.String{ i18n.EN: "Direct Debit (RID)", i18n.IT: "RID", }, }, { - Value: "MP10", + Code: "MP10", Name: i18n.String{ i18n.EN: "Utilities Direct Debit (RID utenze)", i18n.IT: "RID utenze", }, }, { - Value: "MP11", + Code: "MP11", Name: i18n.String{ i18n.EN: "Fast Direct Debit (RID veloce)", i18n.IT: "RID veloce", }, }, { - Value: "MP12", + Code: "MP12", Name: i18n.String{ i18n.EN: "Direct Debit (RIBA)", i18n.IT: "RIBA", }, }, { - Value: "MP13", + Code: "MP13", Name: i18n.String{ i18n.EN: "Debit Transfer (MAV)", i18n.IT: "MAV", }, }, { - Value: "MP14", + Code: "MP14", Name: i18n.String{ i18n.EN: "Tax Receipt", i18n.IT: "Quietanza erario", }, }, { - Value: "MP15", + Code: "MP15", Name: i18n.String{ i18n.EN: "Transfer on special account", i18n.IT: "Giroconto su conti di contabilità speciale", }, }, { - Value: "MP16", + Code: "MP16", Name: i18n.String{ i18n.EN: "Direct Debit", i18n.IT: "Domiciliazione Bancaria", }, }, { - Value: "MP17", + Code: "MP17", Name: i18n.String{ i18n.EN: "Direct Debit Post Office", i18n.IT: "Domiciliazione Postale", }, }, { - Value: "MP18", + Code: "MP18", Name: i18n.String{ i18n.EN: "Post Office Cheque", i18n.IT: "Bollettino di c/c postale", }, }, { - Value: "MP19", + Code: "MP19", Name: i18n.String{ i18n.EN: "SEPA Direct Debit", i18n.IT: "SEPA Direct Debit", }, }, { - Value: "MP20", + Code: "MP20", Name: i18n.String{ i18n.EN: "SEPA Core Direct Debit", i18n.IT: "SEPA Direct Debit Core", }, }, { - Value: "MP21", + Code: "MP21", Name: i18n.String{ i18n.EN: "SEPA B2B Direct Debit", i18n.IT: "SEPA Direct Debit B2B", }, }, { - Value: "MP22", + Code: "MP22", Name: i18n.String{ i18n.EN: "Deductible Netting", i18n.IT: "Trattenuta su somme già riscosse", }, }, { - Value: "MP23", + Code: "MP23", Name: i18n.String{ i18n.EN: "PagoPA", i18n.IT: "PagoPA", @@ -871,23 +871,23 @@ var extensions = []*cbc.KeyDefinition{ i18n.EN: "VAT Liability", i18n.IT: "Esigibilità dell'IVA", }, - Values: []*cbc.ValueDefinition{ + Values: []*cbc.Definition{ { - Value: "I", + Code: "I", Name: i18n.String{ i18n.EN: "Immediate", i18n.IT: "Immediata", }, }, { - Value: "D", + Code: "D", Name: i18n.String{ i18n.EN: "Deferred", i18n.IT: "Differita", }, }, { - Value: "S", + Code: "S", Name: i18n.String{ i18n.EN: "Split Payment", i18n.IT: "Scissione dei pagamenti", diff --git a/addons/it/sdi/inboxes.go b/addons/it/sdi/inboxes.go index b9d1b733..b47f0567 100644 --- a/addons/it/sdi/inboxes.go +++ b/addons/it/sdi/inboxes.go @@ -11,7 +11,7 @@ const ( KeyInboxPEC cbc.Key = "it-sdi-pec" ) -var inboxes = []*cbc.KeyDefinition{ +var inboxes = []*cbc.Definition{ { Key: KeyInboxCode, Name: i18n.String{ diff --git a/addons/it/sdi/scenarios.go b/addons/it/sdi/scenarios.go index ed686165..afa16774 100644 --- a/addons/it/sdi/scenarios.go +++ b/addons/it/sdi/scenarios.go @@ -29,7 +29,7 @@ const ( // involved, we've focussed here on the most useful. var invoiceTags = &tax.TagSet{ Schema: bill.ShortSchemaInvoice, - List: []*cbc.KeyDefinition{ + List: []*cbc.Definition{ // *** Document Type Tags *** // Sales: { diff --git a/addons/mx/cfdi/extensions.go b/addons/mx/cfdi/extensions.go index ec5c1473..cb451f98 100644 --- a/addons/mx/cfdi/extensions.go +++ b/addons/mx/cfdi/extensions.go @@ -19,23 +19,23 @@ const ( ExtKeyPaymentMeans cbc.Key = "mx-cfdi-payment-means" // name from XML field: FormaPago ) -var extensions = []*cbc.KeyDefinition{ +var extensions = []*cbc.Definition{ { Key: ExtKeyDocType, Name: i18n.String{ i18n.EN: "Document Type", i18n.ES: "Tipo de Comprobante", }, - Values: []*cbc.ValueDefinition{ + Values: []*cbc.Definition{ { - Value: "I", + Code: "I", Name: i18n.String{ i18n.EN: "Invoice", i18n.ES: "Comprobante de Ingreso", }, }, { - Value: "E", + Code: "E", Name: i18n.String{ i18n.EN: "Credit Note", i18n.ES: "Comprobante de Egreso", @@ -49,51 +49,51 @@ var extensions = []*cbc.KeyDefinition{ i18n.EN: "Relation Type", i18n.ES: "Tipo de Relación", }, - Values: []*cbc.ValueDefinition{ + Values: []*cbc.Definition{ { - Value: "01", + Code: "01", Name: i18n.String{ i18n.EN: "Credit note for related documents", i18n.ES: "Nota de crédito de los documentos relacionados", }, }, { - Value: "02", + Code: "02", Name: i18n.String{ i18n.EN: "Debit note for related documents", i18n.ES: "Nota de débito de los documentos relacionados", }, }, { - Value: "03", + Code: "03", Name: i18n.String{ i18n.EN: "Return of goods for related documents", i18n.ES: "Devolución de mercancía sobre los documentos relacionados", }, }, { - Value: "04", + Code: "04", Name: i18n.String{ i18n.EN: "Substitution of the previous CFDI document", i18n.ES: "Sustitución de los CFDI previos", }, }, { - Value: "05", + Code: "05", Name: i18n.String{ i18n.EN: "Transfer of goods for related documents", i18n.ES: "Traslados de mercancías facturados por los documentos relacionados", }, }, { - Value: "06", + Code: "06", Name: i18n.String{ i18n.EN: "Invoice generated by previous transfers", i18n.ES: "Factura generada por los traslados previos", }, }, { - Value: "07", + Code: "07", Name: i18n.String{ i18n.ES: "CFDI por aplicación de anticipo", i18n.EN: "CFDI for advance payment", @@ -131,23 +131,23 @@ var extensions = []*cbc.KeyDefinition{ Código definido en el catálogo del CFDI "c_Impuesto" para el tipo de impuesto. Usado en el campo 'Impuesto'. `), }, - Values: []*cbc.ValueDefinition{ + Values: []*cbc.Definition{ { - Value: "001", + Code: "001", Name: i18n.String{ i18n.EN: "Income Tax", i18n.ES: "Impuesto Sobre la Renta", }, }, { - Value: "002", + Code: "002", Name: i18n.String{ i18n.EN: "Value Added Tax", i18n.ES: "Impuesto al Valor Agregado", }, }, { - Value: "003", + Code: "003", Name: i18n.String{ i18n.EN: "Special Tax on Production and Services", i18n.ES: "Impuesto Especial sobre Producción y Servicios", @@ -182,117 +182,117 @@ var extensions = []*cbc.KeyDefinition{ i18n.EN: "Fiscal regime associated with suppliers and customers.", i18n.ES: "Régimen fiscal asociado con el emisor y receptor.", }, - Values: []*cbc.ValueDefinition{ + Values: []*cbc.Definition{ { - Value: "601", + Code: "601", Name: i18n.String{ i18n.ES: "General de Ley Personas Morales", }, }, { - Value: "603", + Code: "603", Name: i18n.String{ i18n.ES: "Personas Morales con Fines no Lucrativos", }, }, { - Value: "605", + Code: "605", Name: i18n.String{ i18n.ES: "Sueldos y Salarios e Ingresos Asimilados a Salarios", }, }, { - Value: "606", + Code: "606", Name: i18n.String{ i18n.ES: "Arrendamiento", }, }, { - Value: "607", + Code: "607", Name: i18n.String{ i18n.ES: "Régimen de Enajenación o Adquisición de Bienes", }, }, { - Value: "608", + Code: "608", Name: i18n.String{ i18n.ES: "Demás ingresos", }, }, { - Value: "610", + Code: "610", Name: i18n.String{ i18n.ES: "Residentes en el Extranjero sin Establecimiento Permanente en México", }, }, { - Value: "611", + Code: "611", Name: i18n.String{ i18n.ES: "Ingresos por Dividendos (socios y accionistas)", //nolint:misspell }, }, { - Value: "612", + Code: "612", Name: i18n.String{ i18n.ES: "Personas Físicas con Actividades Empresariales y Profesionales", }, }, { - Value: "614", + Code: "614", Name: i18n.String{ i18n.ES: "Ingresos por intereses", }, }, { - Value: "615", + Code: "615", Name: i18n.String{ i18n.ES: "Régimen de los ingresos por obtención de premios", }, }, { - Value: "616", + Code: "616", Name: i18n.String{ i18n.ES: "Sin obligaciones fiscales", }, }, { - Value: "620", + Code: "620", Name: i18n.String{ i18n.ES: "Sociedades Cooperativas de Producción que optan por diferir sus ingresos", }, }, { - Value: "621", + Code: "621", Name: i18n.String{ i18n.ES: "Incorporación Fiscal", }, }, { - Value: "622", + Code: "622", Name: i18n.String{ i18n.ES: "Actividades Agrícolas, Ganaderas, Silvícolas y Pesqueras", }, }, { - Value: "623", + Code: "623", Name: i18n.String{ i18n.ES: "Opcional para Grupos de Sociedades", }, }, { - Value: "624", + Code: "624", Name: i18n.String{ i18n.ES: "Coordinados", }, }, { - Value: "625", + Code: "625", Name: i18n.String{ i18n.ES: "Régimen de las Actividades Empresariales con ingresos a través de Plataformas Tecnológicas", }, }, { - Value: "626", + Code: "626", Name: i18n.String{ i18n.ES: "Régimen Simplificado de Confianza", }, @@ -309,170 +309,170 @@ var extensions = []*cbc.KeyDefinition{ i18n.EN: "Chosen by the customer to indicate the purpose of an invoice.", i18n.ES: "Elegido por el cliente para indicar el propósito de una factura.", }, - Values: []*cbc.ValueDefinition{ + Values: []*cbc.Definition{ { - Value: "G01", + Code: "G01", Name: i18n.String{ i18n.EN: "Acquisition of goods", i18n.ES: "Adquisición de mercancías", }, }, { - Value: "G02", + Code: "G02", Name: i18n.String{ i18n.EN: "Returns, discounts or rebates", i18n.ES: "Devoluciones, descuentos o bonificaciones", }, }, { - Value: "G03", + Code: "G03", Name: i18n.String{ i18n.EN: "General expenses", i18n.ES: "Gastos en general", }, }, { - Value: "I01", + Code: "I01", Name: i18n.String{ i18n.EN: "Construction", i18n.ES: "Construcciones", }, }, { - Value: "I02", + Code: "I02", Name: i18n.String{ i18n.EN: "Office furniture and equipment as investmen", i18n.ES: "Mobiliario y equipo de oficina por inversiones", }, }, { - Value: "I03", + Code: "I03", Name: i18n.String{ i18n.EN: "Transport equipment", i18n.ES: "Equipo de transporte", }, }, { - Value: "I04", + Code: "I04", Name: i18n.String{ i18n.EN: "Computer equipment and accessories", i18n.ES: "Equipo de computo y accesorios", }, }, { - Value: "I05", + Code: "I05", Name: i18n.String{ i18n.EN: "Dies, punches, molds, matrices and other toolin", i18n.ES: "Dados, troqueles, moldes, matrices y herramental", }, }, { - Value: "I06", + Code: "I06", Name: i18n.String{ i18n.EN: "Telephone communications", i18n.ES: "Comunicaciones telefónicas", }, }, { - Value: "I07", + Code: "I07", Name: i18n.String{ i18n.EN: "Satellite communications", i18n.ES: "Comunicaciones satelitales", }, }, { - Value: "I08", + Code: "I08", Name: i18n.String{ i18n.EN: "Other machinery and equipment", i18n.ES: "Otra maquinaria y equipo", }, }, { - Value: "D01", + Code: "D01", Name: i18n.String{ i18n.EN: "Medical and dental fees and hospital expenses", i18n.ES: "Honorarios médicos, dentales y gastos hospitalarios", }, }, { - Value: "D02", + Code: "D02", Name: i18n.String{ i18n.EN: "Medical expenses for disability or incapacity", i18n.ES: "Gastos médicos por incapacidad o discapacidad", }, }, { - Value: "D03", + Code: "D03", Name: i18n.String{ i18n.EN: "Funeral expenses", i18n.ES: "Gastos funerales", }, }, { - Value: "D04", + Code: "D04", Name: i18n.String{ i18n.EN: "Donations", i18n.ES: "Donativos", }, }, { - Value: "D05", + Code: "D05", Name: i18n.String{ i18n.EN: "Interest actually paid on mortgage loans (housing)", i18n.ES: "Intereses reales efectivamente pagados por créditos hipotecarios (casa habitación)", }, }, { - Value: "D06", + Code: "D06", Name: i18n.String{ i18n.EN: "Voluntary contributions to the SAR", i18n.ES: "Aportaciones voluntarias al SAR", }, }, { - Value: "D07", + Code: "D07", Name: i18n.String{ i18n.EN: "Medical insurance premiums", i18n.ES: "Primas por seguros de gastos médicos", }, }, { - Value: "D08", + Code: "D08", Name: i18n.String{ i18n.EN: "Mandatory school transportation expenses", i18n.ES: "Gastos de transportación escolar obligatoria", }, }, { - Value: "D09", + Code: "D09", Name: i18n.String{ i18n.EN: "Deposits in savings accounts, pension plans premiums", i18n.ES: "Depósitos en cuentas para el ahorro, primas que tengan como base planes de pensiones", }, }, { - Value: "D10", + Code: "D10", Name: i18n.String{ i18n.EN: "Payments for educational services (school fees)", i18n.ES: "Pagos por servicios educativos (colegiaturas)", }, }, { - Value: "S01", + Code: "S01", Name: i18n.String{ i18n.EN: "Without tax effects", i18n.ES: "Sin efectos fiscales", }, }, { - Value: "CP01", + Code: "CP01", Name: i18n.String{ i18n.EN: "Payments", i18n.ES: "Pagos", }, }, { - Value: "CN01", + Code: "CN01", Name: i18n.String{ i18n.EN: "Payroll", i18n.ES: "Nómina", @@ -494,156 +494,156 @@ var extensions = []*cbc.KeyDefinition{ Código definido en el catálogo del CFDI "c_FormaPago" para el método de pago. Usado en el campo 'FormaPago'. `), }, - Values: []*cbc.ValueDefinition{ + Values: []*cbc.Definition{ { - Value: "01", + Code: "01", Name: i18n.String{ i18n.EN: "Cash", i18n.ES: "Efectivo", }, }, { - Value: "02", + Code: "02", Name: i18n.String{ i18n.EN: "Check", i18n.ES: "Cheque nominativo", }, }, { - Value: "03", + Code: "03", Name: i18n.String{ i18n.EN: "Electronic Funds Transfer", i18n.ES: "Transferencia electrónica de fondos", }, }, { - Value: "04", + Code: "04", Name: i18n.String{ i18n.EN: "Credit Card", i18n.ES: "Tarjeta de crédito", }, }, { - Value: "05", + Code: "05", Name: i18n.String{ i18n.EN: "Electronic Wallet", i18n.ES: "Monedero electrónico", }, }, { - Value: "06", + Code: "06", Name: i18n.String{ i18n.EN: "Online or Electronic Payment", i18n.ES: "Dinero electrónico", }, }, { - Value: "08", + Code: "08", Name: i18n.String{ i18n.EN: "Grocery Voucher", i18n.ES: "Vales de despensa", }, }, { - Value: "12", + Code: "12", Name: i18n.String{ i18n.EN: "Payment in Kind", i18n.ES: "Dación en pago", }, }, { - Value: "13", + Code: "13", Name: i18n.String{ i18n.EN: "Payment by subrogation", i18n.ES: "Pago por subrogación", }, }, { - Value: "14", + Code: "14", Name: i18n.String{ i18n.EN: "Payment by consignment", i18n.ES: "Pago por consignación", }, }, { - Value: "15", + Code: "15", Name: i18n.String{ i18n.EN: "Debt relief", i18n.ES: "Condonación", }, }, { - Value: "17", + Code: "17", Name: i18n.String{ i18n.EN: "Netting", i18n.ES: "Compensación", }, }, { - Value: "23", + Code: "23", Name: i18n.String{ i18n.EN: "Novation", i18n.ES: "Novación", }, }, { - Value: "24", + Code: "24", Name: i18n.String{ i18n.EN: "Merger", i18n.ES: "Confusión", }, }, { - Value: "25", + Code: "25", Name: i18n.String{ i18n.EN: "Debt remission", i18n.ES: "Remisión de deuda", }, }, { - Value: "26", + Code: "26", Name: i18n.String{ i18n.EN: "Expiration of payment obligation", i18n.ES: "Prescripción o caducidad", }, }, { - Value: "27", + Code: "27", Name: i18n.String{ i18n.EN: "To the creditor's satisfaction", i18n.ES: "A satisfacción del acreedor", }, }, { - Value: "28", + Code: "28", Name: i18n.String{ i18n.EN: "Debit card", i18n.ES: "Tarjeta de débito", }, }, { - Value: "29", + Code: "29", Name: i18n.String{ i18n.EN: "Services card", i18n.ES: "Tarjeta de servicios", }, }, { - Value: "30", + Code: "30", Name: i18n.String{ i18n.EN: "Advance payment", i18n.ES: "Aplicación de anticipos", }, }, { - Value: "31", + Code: "31", Name: i18n.String{ i18n.EN: "Payment via intermediary", i18n.ES: "Intermediario pagos", }, }, { - Value: "99", + Code: "99", Name: i18n.String{ i18n.EN: "Undefined", i18n.ES: "Por definir", diff --git a/addons/mx/cfdi/invoice_test.go b/addons/mx/cfdi/invoice_test.go index 9879bb13..7af201c1 100644 --- a/addons/mx/cfdi/invoice_test.go +++ b/addons/mx/cfdi/invoice_test.go @@ -7,6 +7,7 @@ import ( "github.com/invopop/gobl/addons/mx/cfdi" "github.com/invopop/gobl/bill" "github.com/invopop/gobl/cal" + "github.com/invopop/gobl/cbc" "github.com/invopop/gobl/head" "github.com/invopop/gobl/num" "github.com/invopop/gobl/org" @@ -86,7 +87,7 @@ func TestNormalizeInvoice(t *testing.T) { require.NoError(t, inv.Calculate()) require.NoError(t, inv.Validate()) require.NotNil(t, inv.Tax) - assert.Equal(t, tax.ExtValue("21000"), inv.Tax.Ext[cfdi.ExtKeyIssuePlace]) + assert.Equal(t, cbc.Code("21000"), inv.Tax.Ext[cfdi.ExtKeyIssuePlace]) }) t.Run("with supplier address code", func(t *testing.T) { inv := validInvoice() @@ -101,7 +102,7 @@ func TestNormalizeInvoice(t *testing.T) { require.NoError(t, inv.Calculate()) require.NoError(t, inv.Validate()) require.NotNil(t, inv.Tax) - assert.Equal(t, tax.ExtValue("21000"), inv.Tax.Ext[cfdi.ExtKeyIssuePlace]) + assert.Equal(t, cbc.Code("21000"), inv.Tax.Ext[cfdi.ExtKeyIssuePlace]) }) } diff --git a/addons/mx/cfdi/item.go b/addons/mx/cfdi/item.go index c8fe61e1..d47231ef 100644 --- a/addons/mx/cfdi/item.go +++ b/addons/mx/cfdi/item.go @@ -64,7 +64,7 @@ func normalizeItem(item *org.Item) { if item.Ext == nil { item.Ext = make(tax.Extensions) } - item.Ext[v.Key] = tax.ExtValue(v.Code) + item.Ext[v.Key] = v.Code } else { idents = append(idents, v) } @@ -74,7 +74,7 @@ func normalizeItem(item *org.Item) { for k, v := range item.Ext { if k == ExtKeyProdServ { if itemExtensionNormalizableCodeRegexp.MatchString(v.String()) { - item.Ext[k] = tax.ExtValue(v.String() + "00") + item.Ext[k] = cbc.Code(v.String() + "00") } } } diff --git a/addons/mx/cfdi/item_test.go b/addons/mx/cfdi/item_test.go index b6bd4ae1..e8930d9c 100644 --- a/addons/mx/cfdi/item_test.go +++ b/addons/mx/cfdi/item_test.go @@ -4,6 +4,7 @@ import ( "testing" "github.com/invopop/gobl/addons/mx/cfdi" + "github.com/invopop/gobl/cbc" "github.com/invopop/gobl/org" "github.com/invopop/gobl/tax" "github.com/stretchr/testify/assert" @@ -74,8 +75,8 @@ func TestItemValidation(t *testing.T) { func TestItemIdentityNormalization(t *testing.T) { addon := tax.AddonForKey(cfdi.V4) tests := []struct { - Code tax.ExtValue - Expected tax.ExtValue + Code cbc.Code + Expected cbc.Code }{ { Code: "123456", @@ -101,7 +102,7 @@ func TestItemIdentityNormalization(t *testing.T) { inv.Lines[0].Item.Ext[cfdi.ExtKeyProdServ] = "010101" err := inv.Calculate() require.NoError(t, err) - assert.Equal(t, tax.ExtValue("01010100"), inv.Lines[0].Item.Ext[cfdi.ExtKeyProdServ]) + assert.Equal(t, cbc.Code("01010100"), inv.Lines[0].Item.Ext[cfdi.ExtKeyProdServ]) } func TestItemIdentityMigration(t *testing.T) { @@ -117,5 +118,5 @@ func TestItemIdentityMigration(t *testing.T) { err := inv.Calculate() require.NoError(t, err) - assert.Equal(t, tax.ExtValue("01010101"), inv.Lines[0].Item.Ext[cfdi.ExtKeyProdServ]) + assert.Equal(t, cbc.Code("01010101"), inv.Lines[0].Item.Ext[cfdi.ExtKeyProdServ]) } diff --git a/addons/mx/cfdi/party.go b/addons/mx/cfdi/party.go index 51e6ea23..42964bc0 100644 --- a/addons/mx/cfdi/party.go +++ b/addons/mx/cfdi/party.go @@ -1,6 +1,7 @@ package cfdi import ( + "github.com/invopop/gobl/cbc" "github.com/invopop/gobl/org" "github.com/invopop/gobl/tax" ) @@ -17,7 +18,7 @@ func normalizeParty(p *org.Party) { if p.Ext == nil { p.Ext = make(tax.Extensions) } - p.Ext[v.Key] = tax.ExtValue(v.Code) + p.Ext[v.Key] = cbc.Code(v.Code) } else { idents = append(idents, v) } diff --git a/addons/pt/saft/extensions.go b/addons/pt/saft/extensions.go index 6073522e..39054327 100644 --- a/addons/pt/saft/extensions.go +++ b/addons/pt/saft/extensions.go @@ -12,44 +12,44 @@ const ( ExtKeyInvoiceType cbc.Key = "pt-saft-invoice-type" ) -var extensions = []*cbc.KeyDefinition{ +var extensions = []*cbc.Definition{ { Key: ExtKeyInvoiceType, Name: i18n.String{ i18n.EN: "Invoice Type", i18n.PT: "Tipo de Fatura", }, - Values: []*cbc.ValueDefinition{ + Values: []*cbc.Definition{ { - Value: "FT", + Code: "FT", Name: i18n.String{ i18n.EN: "Standard Invoice", i18n.PT: "Fatura", }, }, { - Value: "FS", + Code: "FS", Name: i18n.String{ i18n.EN: "Simplified Invoice", i18n.PT: "Fatura Simplificada", }, }, { - Value: "FR", + Code: "FR", Name: i18n.String{ i18n.EN: "Invoice-Receipt", i18n.PT: "Fatura-Recibo", }, }, { - Value: "ND", + Code: "ND", Name: i18n.String{ i18n.EN: "Debit Note", i18n.PT: "Nota de Débito", }, }, { - Value: "NC", + Code: "NC", Name: i18n.String{ i18n.EN: "Credit Note", i18n.PT: "Nota de Crédito", @@ -63,37 +63,37 @@ var extensions = []*cbc.KeyDefinition{ i18n.EN: "Tax Rate Code", i18n.PT: "Código da Taxa de Imposto", }, - Values: []*cbc.ValueDefinition{ + Values: []*cbc.Definition{ { - Value: "RED", + Code: "RED", Name: i18n.String{ i18n.EN: "Reduced", i18n.PT: "Redução", }, }, { - Value: "INT", + Code: "INT", Name: i18n.String{ i18n.EN: "Intermediate", i18n.PT: "Intermédio", }, }, { - Value: "NOR", + Code: "NOR", Name: i18n.String{ i18n.EN: "Normal", i18n.PT: "Normal", }, }, { - Value: "ISE", + Code: "ISE", Name: i18n.String{ i18n.EN: "Exempt", i18n.PT: "Isento", }, }, { - Value: "OUT", + Code: "OUT", Name: i18n.String{ i18n.EN: "Other", i18n.PT: "Outro", @@ -107,191 +107,191 @@ var extensions = []*cbc.KeyDefinition{ i18n.EN: "Tax exemption reason code", i18n.PT: "Código do motivo de isenção de imposto", }, - Values: []*cbc.ValueDefinition{ + Values: []*cbc.Definition{ { - Value: "M01", + Code: "M01", Name: i18n.String{ i18n.EN: "Article 16, No. 6 of the VAT code", i18n.PT: "Artigo 16.°, n.° 6 do CIVA", }, }, { - Value: "M02", + Code: "M02", Name: i18n.String{ i18n.EN: "Article 6 of the Decree-Law 198/90 of 19th June", i18n.PT: "Artigo 6.° do Decreto-Lei n.° 198/90, de 19 de junho", }, }, { - Value: "M04", + Code: "M04", Name: i18n.String{ i18n.EN: "Exempt pursuant to article 13 of the VAT code", i18n.PT: "Isento artigo 13.° do CIVA", }, }, { - Value: "M05", + Code: "M05", Name: i18n.String{ i18n.EN: "Exempt pursuant to article 14 of the VAT code", i18n.PT: "Isento artigo 14.° do CIVA", }, }, { - Value: "M06", + Code: "M06", Name: i18n.String{ i18n.EN: "Exempt pursuant to article 15 of the VAT code", i18n.PT: "Isento artigo 15.° do CIVA", }, }, { - Value: "M07", + Code: "M07", Name: i18n.String{ i18n.EN: "Exempt pursuant to article 9 of the VAT code", i18n.PT: "Isento artigo 9.° do CIVA", }, }, { - Value: "M09", + Code: "M09", Name: i18n.String{ i18n.EN: "VAT - does not confer right to deduct / Article 62 paragraph b) of the VAT code", i18n.PT: "IVA - não confere direito a dedução / Artigo 62.° alínea b) do CIVA", }, }, { - Value: "M10", + Code: "M10", Name: i18n.String{ i18n.EN: "VAT - exemption scheme / Article 57 of the VAT code", i18n.PT: "IVA - regime de isenção / Artigo 57.° do CIVA", }, }, { - Value: "M11", + Code: "M11", Name: i18n.String{ i18n.EN: "Special scheme for tobacco / Decree-Law No. 346/85 of 23rd August", i18n.PT: "Regime particular do tabaco / Decreto-Lei n.° 346/85, de 23 de agosto", }, }, { - Value: "M12", + Code: "M12", Name: i18n.String{ i18n.EN: "Margin scheme - Travel agencies / Decree-Law No. 221/85 of 3rd July", i18n.PT: "Regime da margem de lucro - Agências de viagens / Decreto-Lei n.° 221/85, de 3 de julho", }, }, { - Value: "M13", + Code: "M13", Name: i18n.String{ i18n.EN: "Margin scheme - Second-hand goods / Decree-Law No. 199/96 of 18th October", i18n.PT: "Regime da margem de lucro - Bens em segunda mão / Decreto-Lei n.° 199/96, de 18 de outubro", }, }, { - Value: "M14", + Code: "M14", Name: i18n.String{ i18n.EN: "Margin scheme - Works of art / Decree-Law No. 199/96 of 18th October", i18n.PT: "Regime da margem de lucro - Objetos de arte / Decreto-Lei n.° 199/96, de 18 de outubro", }, }, { - Value: "M15", + Code: "M15", Name: i18n.String{ i18n.EN: "Margin scheme - Collector’s items and antiques / Decree-Law No. 199/96 of 18th October", i18n.PT: "Regime da margem de lucro - Objetos de coleção e antiguidades / Decreto-Lei n.° 199/96, de 18 de outubro", }, }, { - Value: "M16", + Code: "M16", Name: i18n.String{ i18n.EN: "Exempt pursuant to Article 14 of the RITI", i18n.PT: "Isento artigo 14.° do RITI", }, }, { - Value: "M19", + Code: "M19", Name: i18n.String{ i18n.EN: "Other exemptions - Temporary exemptions determined by specific legislation", i18n.PT: "Outras isenções - Isenções temporárias determinadas em diploma próprio", }, }, { - Value: "M20", + Code: "M20", Name: i18n.String{ i18n.EN: "VAT - flat-rate scheme / Article 59-D No. 2 of the VAT code", i18n.PT: "IVA - regime forfetário / Artigo 59.°-D n.°2 do CIVA", }, }, { - Value: "M21", + Code: "M21", Name: i18n.String{ i18n.EN: "VAT - does not confer right to deduct (or similar) - Article 72 No. 4 of the VAT code", i18n.PT: "IVA - não confere direito à dedução (ou expressão similar) - Artigo 72.° n.° 4 do CIVA", }, }, { - Value: "M25", + Code: "M25", Name: i18n.String{ i18n.EN: "Consignment goods - Article 38 No. 1 paragraph a) of the VAT code", i18n.PT: "Mercadorias à consignação - Artigo 38.° n.° 1 alínea a) do CIVA", }, }, { - Value: "M30", + Code: "M30", Name: i18n.String{ i18n.EN: "VAT - reverse charge / Article 2 No. 1 paragraph i) of the VAT code", i18n.PT: "IVA - autoliquidação / Artigo 2.° n.° 1 alínea i) do CIVA", }, }, { - Value: "M31", + Code: "M31", Name: i18n.String{ i18n.EN: "VAT - reverse charge / Article 2 No. 1 paragraph j) of the VAT code", i18n.PT: "IVA - autoliquidação / Artigo 2.° n.° 1 alínea j) do CIVA", }, }, { - Value: "M32", + Code: "M32", Name: i18n.String{ i18n.EN: "VAT - reverse charge / Article 2 No. 1 paragraph l) of the VAT code", i18n.PT: "IVA - autoliquidação / Artigo 2.° n.° 1 alínea I) do CIVA", }, }, { - Value: "M33", + Code: "M33", Name: i18n.String{ i18n.EN: "VAT - reverse charge / Article 2 No. 1 paragraph m) of the VAT code", i18n.PT: "IVA - autoliquidação / Artigo 2.° n.° 1 alínea m) do CIVA", }, }, { - Value: "M40", + Code: "M40", Name: i18n.String{ i18n.EN: "VAT - reverse charge / Article 6 No. 6 paragraph a) of the VAT code, to the contrary", i18n.PT: "IVA - autoliquidação / Artigo 6.° n.° 6 alínea a) do CIVA, a contrário", }, }, { - Value: "M41", + Code: "M41", Name: i18n.String{ i18n.EN: "VAT - reverse charge / Article 8 No. 3 of the RITI", i18n.PT: "IVA - autoliquidação / Artigo 8.° n.° 3 do RITI", }, }, { - Value: "M42", + Code: "M42", Name: i18n.String{ i18n.EN: "VAT - reverse charge / Decree-Law No. 21/2007 of 29 January", i18n.PT: "IVA - autoliquidação / Decreto-Lei n.° 21/2007, de 29 de janeiro", }, }, { - Value: "M43", + Code: "M43", Name: i18n.String{ i18n.EN: "VAT - reverse charge / Decree-Law No. 362/99 of 16th September", i18n.PT: "IVA - autoliquidação / Decreto-Lei n.° 362/99, de 16 de setembro", }, }, { - Value: "M99", + Code: "M99", Name: i18n.String{ i18n.EN: "Not subject to tax or not taxed", i18n.PT: "Não sujeito ou não tributado", diff --git a/addons/pt/saft/scenarios.go b/addons/pt/saft/scenarios.go index 7c0dea04..0f6b14a2 100644 --- a/addons/pt/saft/scenarios.go +++ b/addons/pt/saft/scenarios.go @@ -55,8 +55,8 @@ var invoiceScenarios = &tax.ScenarioSet{ // Extension texts { - ExtKey: ExtKeyExemption, - ExtValue: "M01", + ExtKey: ExtKeyExemption, + ExtCode: "M01", Note: &cbc.Note{ Key: cbc.NoteKeyLegal, Src: ExtKeyExemption, @@ -64,8 +64,8 @@ var invoiceScenarios = &tax.ScenarioSet{ }, }, { - ExtKey: ExtKeyExemption, - ExtValue: "M02", + ExtKey: ExtKeyExemption, + ExtCode: "M02", Note: &cbc.Note{ Key: cbc.NoteKeyLegal, Src: ExtKeyExemption, @@ -73,8 +73,8 @@ var invoiceScenarios = &tax.ScenarioSet{ }, }, { - ExtKey: ExtKeyExemption, - ExtValue: "M04", + ExtKey: ExtKeyExemption, + ExtCode: "M04", Note: &cbc.Note{ Key: cbc.NoteKeyLegal, Src: ExtKeyExemption, @@ -82,8 +82,8 @@ var invoiceScenarios = &tax.ScenarioSet{ }, }, { - ExtKey: ExtKeyExemption, - ExtValue: "M05", + ExtKey: ExtKeyExemption, + ExtCode: "M05", Note: &cbc.Note{ Key: cbc.NoteKeyLegal, Src: ExtKeyExemption, @@ -91,8 +91,8 @@ var invoiceScenarios = &tax.ScenarioSet{ }, }, { - ExtKey: ExtKeyExemption, - ExtValue: "M06", + ExtKey: ExtKeyExemption, + ExtCode: "M06", Note: &cbc.Note{ Key: cbc.NoteKeyLegal, Src: ExtKeyExemption, @@ -100,8 +100,8 @@ var invoiceScenarios = &tax.ScenarioSet{ }, }, { - ExtKey: ExtKeyExemption, - ExtValue: "M07", + ExtKey: ExtKeyExemption, + ExtCode: "M07", Note: &cbc.Note{ Key: cbc.NoteKeyLegal, Src: ExtKeyExemption, @@ -109,8 +109,8 @@ var invoiceScenarios = &tax.ScenarioSet{ }, }, { - ExtKey: ExtKeyExemption, - ExtValue: "M09", + ExtKey: ExtKeyExemption, + ExtCode: "M09", Note: &cbc.Note{ Key: cbc.NoteKeyLegal, Src: ExtKeyExemption, @@ -118,8 +118,8 @@ var invoiceScenarios = &tax.ScenarioSet{ }, }, { - ExtKey: ExtKeyExemption, - ExtValue: "M10", + ExtKey: ExtKeyExemption, + ExtCode: "M10", Note: &cbc.Note{ Key: cbc.NoteKeyLegal, Src: ExtKeyExemption, @@ -127,8 +127,8 @@ var invoiceScenarios = &tax.ScenarioSet{ }, }, { - ExtKey: ExtKeyExemption, - ExtValue: "M11", + ExtKey: ExtKeyExemption, + ExtCode: "M11", Note: &cbc.Note{ Key: cbc.NoteKeyLegal, Src: ExtKeyExemption, @@ -136,8 +136,8 @@ var invoiceScenarios = &tax.ScenarioSet{ }, }, { - ExtKey: ExtKeyExemption, - ExtValue: "M12", + ExtKey: ExtKeyExemption, + ExtCode: "M12", Note: &cbc.Note{ Key: cbc.NoteKeyLegal, Src: ExtKeyExemption, @@ -145,8 +145,8 @@ var invoiceScenarios = &tax.ScenarioSet{ }, }, { - ExtKey: ExtKeyExemption, - ExtValue: "M13", + ExtKey: ExtKeyExemption, + ExtCode: "M13", Note: &cbc.Note{ Key: cbc.NoteKeyLegal, Src: ExtKeyExemption, @@ -154,8 +154,8 @@ var invoiceScenarios = &tax.ScenarioSet{ }, }, { - ExtKey: ExtKeyExemption, - ExtValue: "M14", + ExtKey: ExtKeyExemption, + ExtCode: "M14", Note: &cbc.Note{ Key: cbc.NoteKeyLegal, Src: ExtKeyExemption, @@ -163,8 +163,8 @@ var invoiceScenarios = &tax.ScenarioSet{ }, }, { - ExtKey: ExtKeyExemption, - ExtValue: "M15", + ExtKey: ExtKeyExemption, + ExtCode: "M15", Note: &cbc.Note{ Key: cbc.NoteKeyLegal, Src: ExtKeyExemption, @@ -172,8 +172,8 @@ var invoiceScenarios = &tax.ScenarioSet{ }, }, { - ExtKey: ExtKeyExemption, - ExtValue: "M16", + ExtKey: ExtKeyExemption, + ExtCode: "M16", Note: &cbc.Note{ Key: cbc.NoteKeyLegal, Src: ExtKeyExemption, @@ -181,8 +181,8 @@ var invoiceScenarios = &tax.ScenarioSet{ }, }, { - ExtKey: ExtKeyExemption, - ExtValue: "M19", + ExtKey: ExtKeyExemption, + ExtCode: "M19", Note: &cbc.Note{ Key: cbc.NoteKeyLegal, Src: ExtKeyExemption, @@ -190,8 +190,8 @@ var invoiceScenarios = &tax.ScenarioSet{ }, }, { - ExtKey: ExtKeyExemption, - ExtValue: "M20", + ExtKey: ExtKeyExemption, + ExtCode: "M20", Note: &cbc.Note{ Key: cbc.NoteKeyLegal, Src: ExtKeyExemption, @@ -199,8 +199,8 @@ var invoiceScenarios = &tax.ScenarioSet{ }, }, { - ExtKey: ExtKeyExemption, - ExtValue: "M21", + ExtKey: ExtKeyExemption, + ExtCode: "M21", Note: &cbc.Note{ Key: cbc.NoteKeyLegal, Src: ExtKeyExemption, @@ -208,8 +208,8 @@ var invoiceScenarios = &tax.ScenarioSet{ }, }, { - ExtKey: ExtKeyExemption, - ExtValue: "M25", + ExtKey: ExtKeyExemption, + ExtCode: "M25", Note: &cbc.Note{ Key: cbc.NoteKeyLegal, Src: ExtKeyExemption, @@ -217,8 +217,8 @@ var invoiceScenarios = &tax.ScenarioSet{ }, }, { - ExtKey: ExtKeyExemption, - ExtValue: "M30", + ExtKey: ExtKeyExemption, + ExtCode: "M30", Note: &cbc.Note{ Key: cbc.NoteKeyLegal, Src: ExtKeyExemption, @@ -226,8 +226,8 @@ var invoiceScenarios = &tax.ScenarioSet{ }, }, { - ExtKey: ExtKeyExemption, - ExtValue: "M31", + ExtKey: ExtKeyExemption, + ExtCode: "M31", Note: &cbc.Note{ Key: cbc.NoteKeyLegal, Src: ExtKeyExemption, @@ -235,8 +235,8 @@ var invoiceScenarios = &tax.ScenarioSet{ }, }, { - ExtKey: ExtKeyExemption, - ExtValue: "M32", + ExtKey: ExtKeyExemption, + ExtCode: "M32", Note: &cbc.Note{ Key: cbc.NoteKeyLegal, Src: ExtKeyExemption, @@ -244,8 +244,8 @@ var invoiceScenarios = &tax.ScenarioSet{ }, }, { - ExtKey: ExtKeyExemption, - ExtValue: "M33", + ExtKey: ExtKeyExemption, + ExtCode: "M33", Note: &cbc.Note{ Key: cbc.NoteKeyLegal, Src: ExtKeyExemption, @@ -253,8 +253,8 @@ var invoiceScenarios = &tax.ScenarioSet{ }, }, { - ExtKey: ExtKeyExemption, - ExtValue: "M40", + ExtKey: ExtKeyExemption, + ExtCode: "M40", Note: &cbc.Note{ Key: cbc.NoteKeyLegal, Src: ExtKeyExemption, @@ -262,8 +262,8 @@ var invoiceScenarios = &tax.ScenarioSet{ }, }, { - ExtKey: ExtKeyExemption, - ExtValue: "M41", + ExtKey: ExtKeyExemption, + ExtCode: "M41", Note: &cbc.Note{ Key: cbc.NoteKeyLegal, Src: ExtKeyExemption, @@ -271,8 +271,8 @@ var invoiceScenarios = &tax.ScenarioSet{ }, }, { - ExtKey: ExtKeyExemption, - ExtValue: "M42", + ExtKey: ExtKeyExemption, + ExtCode: "M42", Note: &cbc.Note{ Key: cbc.NoteKeyLegal, Src: ExtKeyExemption, @@ -280,8 +280,8 @@ var invoiceScenarios = &tax.ScenarioSet{ }, }, { - ExtKey: ExtKeyExemption, - ExtValue: "M43", + ExtKey: ExtKeyExemption, + ExtCode: "M43", Note: &cbc.Note{ Key: cbc.NoteKeyLegal, Src: ExtKeyExemption, @@ -289,8 +289,8 @@ var invoiceScenarios = &tax.ScenarioSet{ }, }, { - ExtKey: ExtKeyExemption, - ExtValue: "M99", + ExtKey: ExtKeyExemption, + ExtCode: "M99", Note: &cbc.Note{ Key: cbc.NoteKeyLegal, Src: ExtKeyExemption, diff --git a/bill/charges.go b/bill/charges.go index 65f715a2..d7eb95b7 100644 --- a/bill/charges.go +++ b/bill/charges.go @@ -30,7 +30,7 @@ const ( ChargeKeyCleaning cbc.Key = "cleaning" ) -var chargeKeyDefinitions = []*cbc.KeyDefinition{ +var chargeKeyDefinitions = []*cbc.Definition{ { Key: ChargeKeyStampDuty, Name: i18n.NewString("Stamp Duty"), diff --git a/bill/discounts.go b/bill/discounts.go index fadc7361..eb7236ad 100644 --- a/bill/discounts.go +++ b/bill/discounts.go @@ -33,7 +33,7 @@ const ( DiscountKeyYarlyTurnover cbc.Key = "yearly-turnover" ) -var discountKeyDefinitions = []*cbc.KeyDefinition{ +var discountKeyDefinitions = []*cbc.Definition{ { Key: DiscountKeyEarlyCompletion, Name: i18n.NewString("Bonus for works ahead of schedule"), diff --git a/bill/invoice_correct.go b/bill/invoice_correct.go index 2cdc2f0a..da39319f 100644 --- a/bill/invoice_correct.go +++ b/bill/invoice_correct.go @@ -89,7 +89,7 @@ func WithReason(reason string) schema.Option { // WithExtension adds a specific extension combination to the invoice's preceding data, // can be called multiple times. -func WithExtension(key cbc.Key, code tax.ExtValue) schema.Option { +func WithExtension(key cbc.Key, code cbc.Code) schema.Option { return func(o interface{}) { opts := o.(*CorrectionOptions) if opts.Ext == nil { @@ -212,7 +212,7 @@ func (inv *Invoice) CorrectionOptionsSchema() (interface{}, error) { oneOf = make([]*jsonschema.Schema, 0, len(re.Values)) for _, c := range re.Values { ci := &jsonschema.Schema{ - Const: c.Value, + Const: c.Code, Title: c.Name.String(), } if len(c.Desc) > 0 { diff --git a/bill/invoice_correct_test.go b/bill/invoice_correct_test.go index ceeb7953..4cc6e756 100644 --- a/bill/invoice_correct_test.go +++ b/bill/invoice_correct_test.go @@ -156,7 +156,7 @@ func TestCorrectWithOptions(t *testing.T) { assert.Equal(t, pre.Code.String(), "123") assert.Equal(t, pre.IssueDate, cal.NewDate(2022, 6, 13)) assert.Equal(t, pre.Reason, "test refund") - assert.Equal(t, pre.Ext[facturae.ExtKeyCorrection], tax.ExtValue("01")) + assert.Equal(t, pre.Ext[facturae.ExtKeyCorrection], cbc.Code("01")) assert.Equal(t, i.Totals.Payable.String(), "900.00") } diff --git a/bill/invoice_type.go b/bill/invoice_type.go index 5d613518..f6f19092 100644 --- a/bill/invoice_type.go +++ b/bill/invoice_type.go @@ -24,7 +24,7 @@ const ( ) // InvoiceTypes describes each of the InvoiceTypes supported. -var InvoiceTypes = []*cbc.KeyDefinition{ +var InvoiceTypes = []*cbc.Definition{ { Key: InvoiceTypeStandard, Name: i18n.String{ diff --git a/catalogues/iso/iso.go b/catalogues/iso/iso.go index d6e0210c..994b4d4e 100644 --- a/catalogues/iso/iso.go +++ b/catalogues/iso/iso.go @@ -16,7 +16,7 @@ func newCatalogue() *tax.CatalogueDef { return &tax.CatalogueDef{ Key: "iso", Name: i18n.NewString("ISO/IEC Data Elements"), - Extensions: []*cbc.KeyDefinition{ + Extensions: []*cbc.Definition{ extSchemeID, }, } diff --git a/catalogues/iso/scheme_id.go b/catalogues/iso/scheme_id.go index 24aa96c5..6ac5e6d7 100644 --- a/catalogues/iso/scheme_id.go +++ b/catalogues/iso/scheme_id.go @@ -11,7 +11,7 @@ const ( ExtKeySchemeID cbc.Key = "iso-scheme-id" ) -var extSchemeID = &cbc.KeyDefinition{ +var extSchemeID = &cbc.Definition{ Key: ExtKeySchemeID, Name: i18n.NewString("ISO/IEC 6523 Identifier scheme code"), Desc: i18n.NewString(here.Doc(` diff --git a/catalogues/untdid/allowance.go b/catalogues/untdid/allowance.go index 0fe92589..780e6253 100644 --- a/catalogues/untdid/allowance.go +++ b/catalogues/untdid/allowance.go @@ -12,7 +12,7 @@ const ( ExtKeyAllowance cbc.Key = "untdid-allowance" ) -var extAllowance = &cbc.KeyDefinition{ +var extAllowance = &cbc.Definition{ Key: ExtKeyAllowance, Name: i18n.String{ i18n.EN: "UNTDID 5189 Allowance", @@ -24,82 +24,82 @@ var extAllowance = &cbc.KeyDefinition{ values table which focusses on invoices and payments. `), }, - Values: []*cbc.ValueDefinition{ + Values: []*cbc.Definition{ { - Value: "41", - Name: i18n.NewString("Bonus for works ahead of schedule"), + Code: "41", + Name: i18n.NewString("Bonus for works ahead of schedule"), }, { - Value: "42", - Name: i18n.NewString("Other bonus"), + Code: "42", + Name: i18n.NewString("Other bonus"), }, { - Value: "60", - Name: i18n.NewString("Manufacturer’s consumer discount"), + Code: "60", + Name: i18n.NewString("Manufacturer’s consumer discount"), }, { - Value: "62", - Name: i18n.NewString("Due to military status"), + Code: "62", + Name: i18n.NewString("Due to military status"), }, { - Value: "63", - Name: i18n.NewString("Due to work accident"), + Code: "63", + Name: i18n.NewString("Due to work accident"), }, { - Value: "64", - Name: i18n.NewString("Special agreement"), + Code: "64", + Name: i18n.NewString("Special agreement"), }, { - Value: "65", - Name: i18n.NewString("Production error discount"), + Code: "65", + Name: i18n.NewString("Production error discount"), }, { - Value: "66", - Name: i18n.NewString("New outlet discount"), + Code: "66", + Name: i18n.NewString("New outlet discount"), }, { - Value: "67", - Name: i18n.NewString("Sample discount"), + Code: "67", + Name: i18n.NewString("Sample discount"), }, { - Value: "68", - Name: i18n.NewString("End-of-range discount"), + Code: "68", + Name: i18n.NewString("End-of-range discount"), }, { - Value: "70", - Name: i18n.NewString("Incoterm discount"), + Code: "70", + Name: i18n.NewString("Incoterm discount"), }, { - Value: "71", - Name: i18n.NewString("Point of sales threshold allowance"), + Code: "71", + Name: i18n.NewString("Point of sales threshold allowance"), }, { - Value: "88", - Name: i18n.NewString("Material surcharge/deduction"), + Code: "88", + Name: i18n.NewString("Material surcharge/deduction"), }, { - Value: "95", - Name: i18n.NewString("Discount"), + Code: "95", + Name: i18n.NewString("Discount"), }, { - Value: "100", - Name: i18n.NewString("Special rebate"), + Code: "100", + Name: i18n.NewString("Special rebate"), }, { - Value: "102", - Name: i18n.NewString("Fixed long term"), + Code: "102", + Name: i18n.NewString("Fixed long term"), }, { - Value: "103", - Name: i18n.NewString("Temporary"), + Code: "103", + Name: i18n.NewString("Temporary"), }, { - Value: "104", - Name: i18n.NewString("Standard"), + Code: "104", + Name: i18n.NewString("Standard"), }, { - Value: "105", - Name: i18n.NewString("Yearly turnover"), + Code: "105", + Name: i18n.NewString("Yearly turnover"), }, }, } diff --git a/catalogues/untdid/charge.go b/catalogues/untdid/charge.go index 2ba7bf81..3ead2a06 100644 --- a/catalogues/untdid/charge.go +++ b/catalogues/untdid/charge.go @@ -11,7 +11,7 @@ const ( ExtKeyCharge cbc.Key = "untdid-charge" ) -var extCharge = &cbc.KeyDefinition{ +var extCharge = &cbc.Definition{ Key: ExtKeyCharge, Name: i18n.NewString("UNTDID 7161 Charge"), Desc: i18n.String{ @@ -20,734 +20,734 @@ var extCharge = &cbc.KeyDefinition{ EN16931 code lists with extensions for taxes and duties. `), }, - Values: []*cbc.ValueDefinition{ + Values: []*cbc.Definition{ { - Value: "AA", - Name: i18n.NewString("Advertising"), + Code: "AA", + Name: i18n.NewString("Advertising"), }, { - Value: "AAA", - Name: i18n.NewString("Telecommunication"), + Code: "AAA", + Name: i18n.NewString("Telecommunication"), }, { - Value: "AAC", - Name: i18n.NewString("Technical modification"), + Code: "AAC", + Name: i18n.NewString("Technical modification"), }, { - Value: "AAD", - Name: i18n.NewString("Job-order production"), + Code: "AAD", + Name: i18n.NewString("Job-order production"), }, { - Value: "AAE", - Name: i18n.NewString("Outlays"), + Code: "AAE", + Name: i18n.NewString("Outlays"), }, { - Value: "AAF", - Name: i18n.NewString("Off-premises"), + Code: "AAF", + Name: i18n.NewString("Off-premises"), }, { - Value: "AAH", - Name: i18n.NewString("Additional processing"), + Code: "AAH", + Name: i18n.NewString("Additional processing"), }, { - Value: "AAI", - Name: i18n.NewString("Attesting"), + Code: "AAI", + Name: i18n.NewString("Attesting"), }, { - Value: "AAS", - Name: i18n.NewString("Acceptance"), + Code: "AAS", + Name: i18n.NewString("Acceptance"), }, { - Value: "AAT", - Name: i18n.NewString("Rush delivery"), + Code: "AAT", + Name: i18n.NewString("Rush delivery"), }, { - Value: "AAV", - Name: i18n.NewString("Special construction"), + Code: "AAV", + Name: i18n.NewString("Special construction"), }, { - Value: "AAY", - Name: i18n.NewString("Airport facilities"), + Code: "AAY", + Name: i18n.NewString("Airport facilities"), }, { - Value: "AAZ", - Name: i18n.NewString("Concession"), + Code: "AAZ", + Name: i18n.NewString("Concession"), }, { - Value: "ABA", - Name: i18n.NewString("Compulsory storage"), + Code: "ABA", + Name: i18n.NewString("Compulsory storage"), }, { - Value: "ABB", - Name: i18n.NewString("Fuel removal"), + Code: "ABB", + Name: i18n.NewString("Fuel removal"), }, { - Value: "ABC", - Name: i18n.NewString("Into plane"), + Code: "ABC", + Name: i18n.NewString("Into plane"), }, { - Value: "ABD", - Name: i18n.NewString("Overtime"), + Code: "ABD", + Name: i18n.NewString("Overtime"), }, { - Value: "ABF", - Name: i18n.NewString("Tooling"), + Code: "ABF", + Name: i18n.NewString("Tooling"), }, { - Value: "ABK", - Name: i18n.NewString("Miscellaneous"), + Code: "ABK", + Name: i18n.NewString("Miscellaneous"), }, { - Value: "ABL", - Name: i18n.NewString("Additional packaging"), + Code: "ABL", + Name: i18n.NewString("Additional packaging"), }, { - Value: "ABN", - Name: i18n.NewString("Dunnage"), + Code: "ABN", + Name: i18n.NewString("Dunnage"), }, { - Value: "ABR", - Name: i18n.NewString("Containerisation"), + Code: "ABR", + Name: i18n.NewString("Containerisation"), }, { - Value: "ABS", - Name: i18n.NewString("Carton packing"), + Code: "ABS", + Name: i18n.NewString("Carton packing"), }, { - Value: "ABT", - Name: i18n.NewString("Hessian wrapped"), + Code: "ABT", + Name: i18n.NewString("Hessian wrapped"), }, { - Value: "ABU", - Name: i18n.NewString("Polyethylene wrap packing"), + Code: "ABU", + Name: i18n.NewString("Polyethylene wrap packing"), }, { - Value: "ABW", // not in EN16931 - Name: i18n.NewString("Customs duty charge"), + Code: "ABW", // not in EN16931 + Name: i18n.NewString("Customs duty charge"), }, { - Value: "ACF", - Name: i18n.NewString("Miscellaneous treatment"), + Code: "ACF", + Name: i18n.NewString("Miscellaneous treatment"), }, { - Value: "ACG", - Name: i18n.NewString("Enamelling treatment"), + Code: "ACG", + Name: i18n.NewString("Enamelling treatment"), }, { - Value: "ACH", - Name: i18n.NewString("Heat treatment"), + Code: "ACH", + Name: i18n.NewString("Heat treatment"), }, { - Value: "ACI", - Name: i18n.NewString("Plating treatment"), + Code: "ACI", + Name: i18n.NewString("Plating treatment"), }, { - Value: "ACJ", - Name: i18n.NewString("Painting"), + Code: "ACJ", + Name: i18n.NewString("Painting"), }, { - Value: "ACK", - Name: i18n.NewString("Polishing"), + Code: "ACK", + Name: i18n.NewString("Polishing"), }, { - Value: "ACL", - Name: i18n.NewString("Priming"), + Code: "ACL", + Name: i18n.NewString("Priming"), }, { - Value: "ACM", - Name: i18n.NewString("Preservation treatment"), + Code: "ACM", + Name: i18n.NewString("Preservation treatment"), }, { - Value: "ACS", - Name: i18n.NewString("Fitting"), + Code: "ACS", + Name: i18n.NewString("Fitting"), }, { - Value: "ADC", - Name: i18n.NewString("Consolidation"), + Code: "ADC", + Name: i18n.NewString("Consolidation"), }, { - Value: "ADE", - Name: i18n.NewString("Bill of lading"), + Code: "ADE", + Name: i18n.NewString("Bill of lading"), }, { - Value: "ADJ", - Name: i18n.NewString("Airbag"), + Code: "ADJ", + Name: i18n.NewString("Airbag"), }, { - Value: "ADK", - Name: i18n.NewString("Transfer"), + Code: "ADK", + Name: i18n.NewString("Transfer"), }, { - Value: "ADL", - Name: i18n.NewString("Slipsheet"), + Code: "ADL", + Name: i18n.NewString("Slipsheet"), }, { - Value: "ADM", - Name: i18n.NewString("Binding"), + Code: "ADM", + Name: i18n.NewString("Binding"), }, { - Value: "ADN", - Name: i18n.NewString("Repair or replacement of broken returnable package"), + Code: "ADN", + Name: i18n.NewString("Repair or replacement of broken returnable package"), }, { - Value: "ADO", - Name: i18n.NewString("Efficient logistics"), + Code: "ADO", + Name: i18n.NewString("Efficient logistics"), }, { - Value: "ADP", - Name: i18n.NewString("Merchandising"), + Code: "ADP", + Name: i18n.NewString("Merchandising"), }, { - Value: "ADQ", - Name: i18n.NewString("Product mix"), + Code: "ADQ", + Name: i18n.NewString("Product mix"), }, { - Value: "ADR", - Name: i18n.NewString("Other services"), + Code: "ADR", + Name: i18n.NewString("Other services"), }, { - Value: "ADT", - Name: i18n.NewString("Pick-up"), + Code: "ADT", + Name: i18n.NewString("Pick-up"), }, { - Value: "ADW", - Name: i18n.NewString("Chronic illness"), + Code: "ADW", + Name: i18n.NewString("Chronic illness"), }, { - Value: "ADY", - Name: i18n.NewString("New product introduction"), + Code: "ADY", + Name: i18n.NewString("New product introduction"), }, { - Value: "ADZ", - Name: i18n.NewString("Direct delivery"), + Code: "ADZ", + Name: i18n.NewString("Direct delivery"), }, { - Value: "AEA", - Name: i18n.NewString("Diversion"), + Code: "AEA", + Name: i18n.NewString("Diversion"), }, { - Value: "AEB", - Name: i18n.NewString("Disconnect"), + Code: "AEB", + Name: i18n.NewString("Disconnect"), }, { - Value: "AEC", - Name: i18n.NewString("Distribution"), + Code: "AEC", + Name: i18n.NewString("Distribution"), }, { - Value: "AED", - Name: i18n.NewString("Handling of hazardous cargo"), + Code: "AED", + Name: i18n.NewString("Handling of hazardous cargo"), }, { - Value: "AEF", - Name: i18n.NewString("Rents and leases"), + Code: "AEF", + Name: i18n.NewString("Rents and leases"), }, { - Value: "AEH", - Name: i18n.NewString("Location differential"), + Code: "AEH", + Name: i18n.NewString("Location differential"), }, { - Value: "AEI", - Name: i18n.NewString("Aircraft refueling"), + Code: "AEI", + Name: i18n.NewString("Aircraft refueling"), }, { - Value: "AEJ", - Name: i18n.NewString("Fuel shipped into storage"), + Code: "AEJ", + Name: i18n.NewString("Fuel shipped into storage"), }, { - Value: "AEK", - Name: i18n.NewString("Cash on delivery"), + Code: "AEK", + Name: i18n.NewString("Cash on delivery"), }, { - Value: "AEL", - Name: i18n.NewString("Small order processing service"), + Code: "AEL", + Name: i18n.NewString("Small order processing service"), }, { - Value: "AEM", - Name: i18n.NewString("Clerical or administrative services"), + Code: "AEM", + Name: i18n.NewString("Clerical or administrative services"), }, { - Value: "AEN", - Name: i18n.NewString("Guarantee"), + Code: "AEN", + Name: i18n.NewString("Guarantee"), }, { - Value: "AEO", - Name: i18n.NewString("Collection and recycling"), + Code: "AEO", + Name: i18n.NewString("Collection and recycling"), }, { - Value: "AEP", - Name: i18n.NewString("Copyright fee collection"), + Code: "AEP", + Name: i18n.NewString("Copyright fee collection"), }, { - Value: "AES", - Name: i18n.NewString("Veterinary inspection service"), + Code: "AES", + Name: i18n.NewString("Veterinary inspection service"), }, { - Value: "AET", - Name: i18n.NewString("Pensioner service"), + Code: "AET", + Name: i18n.NewString("Pensioner service"), }, { - Value: "AEU", - Name: i18n.NewString("Medicine free pass holder"), + Code: "AEU", + Name: i18n.NewString("Medicine free pass holder"), }, { - Value: "AEV", - Name: i18n.NewString("Environmental protection service"), + Code: "AEV", + Name: i18n.NewString("Environmental protection service"), }, { - Value: "AEW", - Name: i18n.NewString("Environmental clean-up service"), + Code: "AEW", + Name: i18n.NewString("Environmental clean-up service"), }, { - Value: "AEX", - Name: i18n.NewString("National cheque processing service outside account area"), + Code: "AEX", + Name: i18n.NewString("National cheque processing service outside account area"), }, { - Value: "AEY", - Name: i18n.NewString("National payment service outside account area"), + Code: "AEY", + Name: i18n.NewString("National payment service outside account area"), }, { - Value: "AEZ", - Name: i18n.NewString("National payment service within account area"), + Code: "AEZ", + Name: i18n.NewString("National payment service within account area"), }, { - Value: "AJ", - Name: i18n.NewString("Adjustments"), + Code: "AJ", + Name: i18n.NewString("Adjustments"), }, { - Value: "AU", - Name: i18n.NewString("Authentication"), + Code: "AU", + Name: i18n.NewString("Authentication"), }, { - Value: "CA", - Name: i18n.NewString("Cataloguing"), + Code: "CA", + Name: i18n.NewString("Cataloguing"), }, { - Value: "CAB", - Name: i18n.NewString("Cartage"), + Code: "CAB", + Name: i18n.NewString("Cartage"), }, { - Value: "CAD", - Name: i18n.NewString("Certification"), + Code: "CAD", + Name: i18n.NewString("Certification"), }, { - Value: "CAE", - Name: i18n.NewString("Certificate of conformance"), + Code: "CAE", + Name: i18n.NewString("Certificate of conformance"), }, { - Value: "CAF", - Name: i18n.NewString("Certificate of origin"), + Code: "CAF", + Name: i18n.NewString("Certificate of origin"), }, { - Value: "CAI", - Name: i18n.NewString("Cutting"), + Code: "CAI", + Name: i18n.NewString("Cutting"), }, { - Value: "CAJ", - Name: i18n.NewString("Consular service"), + Code: "CAJ", + Name: i18n.NewString("Consular service"), }, { - Value: "CAK", - Name: i18n.NewString("Customer collection"), + Code: "CAK", + Name: i18n.NewString("Customer collection"), }, { - Value: "CAL", - Name: i18n.NewString("Payroll payment service"), + Code: "CAL", + Name: i18n.NewString("Payroll payment service"), }, { - Value: "CAM", - Name: i18n.NewString("Cash transportation"), + Code: "CAM", + Name: i18n.NewString("Cash transportation"), }, { - Value: "CAN", - Name: i18n.NewString("Home banking service"), + Code: "CAN", + Name: i18n.NewString("Home banking service"), }, { - Value: "CAO", - Name: i18n.NewString("Bilateral agreement service"), + Code: "CAO", + Name: i18n.NewString("Bilateral agreement service"), }, { - Value: "CAP", - Name: i18n.NewString("Insurance brokerage service"), + Code: "CAP", + Name: i18n.NewString("Insurance brokerage service"), }, { - Value: "CAQ", - Name: i18n.NewString("Cheque generation"), + Code: "CAQ", + Name: i18n.NewString("Cheque generation"), }, { - Value: "CAR", - Name: i18n.NewString("Preferential merchandising location"), + Code: "CAR", + Name: i18n.NewString("Preferential merchandising location"), }, { - Value: "CAS", - Name: i18n.NewString("Crane"), + Code: "CAS", + Name: i18n.NewString("Crane"), }, { - Value: "CAT", - Name: i18n.NewString("Special colour service"), + Code: "CAT", + Name: i18n.NewString("Special colour service"), }, { - Value: "CAU", - Name: i18n.NewString("Sorting"), + Code: "CAU", + Name: i18n.NewString("Sorting"), }, { - Value: "CAV", - Name: i18n.NewString("Battery collection and recycling"), + Code: "CAV", + Name: i18n.NewString("Battery collection and recycling"), }, { - Value: "CAW", - Name: i18n.NewString("Product take back fee"), + Code: "CAW", + Name: i18n.NewString("Product take back fee"), }, { - Value: "CAX", - Name: i18n.NewString("Quality control released"), + Code: "CAX", + Name: i18n.NewString("Quality control released"), }, { - Value: "CAY", - Name: i18n.NewString("Quality control held"), + Code: "CAY", + Name: i18n.NewString("Quality control held"), }, { - Value: "CAZ", - Name: i18n.NewString("Quality control embargo"), + Code: "CAZ", + Name: i18n.NewString("Quality control embargo"), }, { - Value: "CD", - Name: i18n.NewString("Car loading"), + Code: "CD", + Name: i18n.NewString("Car loading"), }, { - Value: "CG", - Name: i18n.NewString("Cleaning"), + Code: "CG", + Name: i18n.NewString("Cleaning"), }, { - Value: "CS", - Name: i18n.NewString("Cigarette stamping"), + Code: "CS", + Name: i18n.NewString("Cigarette stamping"), }, { - Value: "CT", - Name: i18n.NewString("Count and recount"), + Code: "CT", + Name: i18n.NewString("Count and recount"), }, { - Value: "DAB", - Name: i18n.NewString("Layout/design"), + Code: "DAB", + Name: i18n.NewString("Layout/design"), }, { - Value: "DAC", - Name: i18n.NewString("Assortment allowance"), + Code: "DAC", + Name: i18n.NewString("Assortment allowance"), }, { - Value: "DAD", - Name: i18n.NewString("Driver assigned unloading"), + Code: "DAD", + Name: i18n.NewString("Driver assigned unloading"), }, { - Value: "DAF", - Name: i18n.NewString("Debtor bound"), + Code: "DAF", + Name: i18n.NewString("Debtor bound"), }, { - Value: "DAG", - Name: i18n.NewString("Dealer allowance"), + Code: "DAG", + Name: i18n.NewString("Dealer allowance"), }, { - Value: "DAH", - Name: i18n.NewString("Allowance transferable to the consumer"), + Code: "DAH", + Name: i18n.NewString("Allowance transferable to the consumer"), }, { - Value: "DAI", - Name: i18n.NewString("Growth of business"), + Code: "DAI", + Name: i18n.NewString("Growth of business"), }, { - Value: "DAJ", - Name: i18n.NewString("Introduction allowance"), + Code: "DAJ", + Name: i18n.NewString("Introduction allowance"), }, { - Value: "DAK", - Name: i18n.NewString("Multi-buy promotion"), + Code: "DAK", + Name: i18n.NewString("Multi-buy promotion"), }, { - Value: "DAL", - Name: i18n.NewString("Partnership"), + Code: "DAL", + Name: i18n.NewString("Partnership"), }, { - Value: "DAM", - Name: i18n.NewString("Return handling"), + Code: "DAM", + Name: i18n.NewString("Return handling"), }, { - Value: "DAN", - Name: i18n.NewString("Minimum order not fulfilled charge"), + Code: "DAN", + Name: i18n.NewString("Minimum order not fulfilled charge"), }, { - Value: "DAO", - Name: i18n.NewString("Point of sales threshold allowance"), + Code: "DAO", + Name: i18n.NewString("Point of sales threshold allowance"), }, { - Value: "DAP", - Name: i18n.NewString("Wholesaling discount"), + Code: "DAP", + Name: i18n.NewString("Wholesaling discount"), }, { - Value: "DAQ", - Name: i18n.NewString("Documentary credits transfer commission"), + Code: "DAQ", + Name: i18n.NewString("Documentary credits transfer commission"), }, { - Value: "DL", - Name: i18n.NewString("Delivery"), + Code: "DL", + Name: i18n.NewString("Delivery"), }, { - Value: "EG", - Name: i18n.NewString("Engraving"), + Code: "EG", + Name: i18n.NewString("Engraving"), }, { - Value: "EP", - Name: i18n.NewString("Expediting"), + Code: "EP", + Name: i18n.NewString("Expediting"), }, { - Value: "ER", - Name: i18n.NewString("Exchange rate guarantee"), + Code: "ER", + Name: i18n.NewString("Exchange rate guarantee"), }, { - Value: "FAA", - Name: i18n.NewString("Fabrication"), + Code: "FAA", + Name: i18n.NewString("Fabrication"), }, { - Value: "FAB", - Name: i18n.NewString("Freight equalization"), + Code: "FAB", + Name: i18n.NewString("Freight equalization"), }, { - Value: "FAC", - Name: i18n.NewString("Freight extraordinary handling"), + Code: "FAC", + Name: i18n.NewString("Freight extraordinary handling"), }, { - Value: "FC", - Name: i18n.NewString("Freight service"), + Code: "FC", + Name: i18n.NewString("Freight service"), }, { - Value: "FH", - Name: i18n.NewString("Filling/handling"), + Code: "FH", + Name: i18n.NewString("Filling/handling"), }, { - Value: "FI", - Name: i18n.NewString("Financing"), + Code: "FI", + Name: i18n.NewString("Financing"), }, { - Value: "GAA", - Name: i18n.NewString("Grinding"), + Code: "GAA", + Name: i18n.NewString("Grinding"), }, { - Value: "HAA", - Name: i18n.NewString("Hose"), + Code: "HAA", + Name: i18n.NewString("Hose"), }, { - Value: "HD", - Name: i18n.NewString("Handling"), + Code: "HD", + Name: i18n.NewString("Handling"), }, { - Value: "HH", - Name: i18n.NewString("Hoisting and hauling"), + Code: "HH", + Name: i18n.NewString("Hoisting and hauling"), }, { - Value: "IAA", - Name: i18n.NewString("Installation"), + Code: "IAA", + Name: i18n.NewString("Installation"), }, { - Value: "IAB", - Name: i18n.NewString("Installation and warranty"), + Code: "IAB", + Name: i18n.NewString("Installation and warranty"), }, { - Value: "ID", - Name: i18n.NewString("Inside delivery"), + Code: "ID", + Name: i18n.NewString("Inside delivery"), }, { - Value: "IF", - Name: i18n.NewString("Inspection"), + Code: "IF", + Name: i18n.NewString("Inspection"), }, { - Value: "IN", // not in EN16931 - Name: i18n.NewString("Insurance"), + Code: "IN", // not in EN16931 + Name: i18n.NewString("Insurance"), }, { - Value: "IR", - Name: i18n.NewString("Installation and training"), + Code: "IR", + Name: i18n.NewString("Installation and training"), }, { - Value: "IS", - Name: i18n.NewString("Invoicing"), + Code: "IS", + Name: i18n.NewString("Invoicing"), }, { - Value: "KO", - Name: i18n.NewString("Koshering"), + Code: "KO", + Name: i18n.NewString("Koshering"), }, { - Value: "L1", - Name: i18n.NewString("Carrier count"), + Code: "L1", + Name: i18n.NewString("Carrier count"), }, { - Value: "LA", - Name: i18n.NewString("Labelling"), + Code: "LA", + Name: i18n.NewString("Labelling"), }, { - Value: "LAA", - Name: i18n.NewString("Labour"), + Code: "LAA", + Name: i18n.NewString("Labour"), }, { - Value: "LAB", - Name: i18n.NewString("Repair and return"), + Code: "LAB", + Name: i18n.NewString("Repair and return"), }, { - Value: "LF", - Name: i18n.NewString("Legalisation"), + Code: "LF", + Name: i18n.NewString("Legalisation"), }, { - Value: "MAE", - Name: i18n.NewString("Mounting"), + Code: "MAE", + Name: i18n.NewString("Mounting"), }, { - Value: "MI", - Name: i18n.NewString("Mail invoice"), + Code: "MI", + Name: i18n.NewString("Mail invoice"), }, { - Value: "ML", - Name: i18n.NewString("Mail invoice to each location"), + Code: "ML", + Name: i18n.NewString("Mail invoice to each location"), }, { - Value: "NAA", - Name: i18n.NewString("Non-returnable containers"), + Code: "NAA", + Name: i18n.NewString("Non-returnable containers"), }, { - Value: "OA", - Name: i18n.NewString("Outside cable connectors"), + Code: "OA", + Name: i18n.NewString("Outside cable connectors"), }, { - Value: "PA", - Name: i18n.NewString("Invoice with shipment"), + Code: "PA", + Name: i18n.NewString("Invoice with shipment"), }, { - Value: "PAA", - Name: i18n.NewString("Phosphatizing (steel treatment)"), + Code: "PAA", + Name: i18n.NewString("Phosphatizing (steel treatment)"), }, { - Value: "PC", - Name: i18n.NewString("Packing"), + Code: "PC", + Name: i18n.NewString("Packing"), }, { - Value: "PL", - Name: i18n.NewString("Palletizing"), + Code: "PL", + Name: i18n.NewString("Palletizing"), }, { - Value: "PRV", - Name: i18n.NewString("Price variation"), + Code: "PRV", + Name: i18n.NewString("Price variation"), }, { - Value: "RAB", - Name: i18n.NewString("Repacking"), + Code: "RAB", + Name: i18n.NewString("Repacking"), }, { - Value: "RAC", - Name: i18n.NewString("Repair"), + Code: "RAC", + Name: i18n.NewString("Repair"), }, { - Value: "RAD", - Name: i18n.NewString("Returnable container"), + Code: "RAD", + Name: i18n.NewString("Returnable container"), }, { - Value: "RAF", - Name: i18n.NewString("Restocking"), + Code: "RAF", + Name: i18n.NewString("Restocking"), }, { - Value: "RE", - Name: i18n.NewString("Re-delivery"), + Code: "RE", + Name: i18n.NewString("Re-delivery"), }, { - Value: "RF", - Name: i18n.NewString("Refurbishing"), + Code: "RF", + Name: i18n.NewString("Refurbishing"), }, { - Value: "RH", - Name: i18n.NewString("Rail wagon hire"), + Code: "RH", + Name: i18n.NewString("Rail wagon hire"), }, { - Value: "RV", - Name: i18n.NewString("Loading"), + Code: "RV", + Name: i18n.NewString("Loading"), }, { - Value: "SA", - Name: i18n.NewString("Salvaging"), + Code: "SA", + Name: i18n.NewString("Salvaging"), }, { - Value: "SAA", - Name: i18n.NewString("Shipping and handling"), + Code: "SAA", + Name: i18n.NewString("Shipping and handling"), }, { - Value: "SAD", - Name: i18n.NewString("Special packaging"), + Code: "SAD", + Name: i18n.NewString("Special packaging"), }, { - Value: "SAE", - Name: i18n.NewString("Stamping"), + Code: "SAE", + Name: i18n.NewString("Stamping"), }, { - Value: "SAI", - Name: i18n.NewString("Consignee unload"), + Code: "SAI", + Name: i18n.NewString("Consignee unload"), }, { - Value: "SG", - Name: i18n.NewString("Shrink-wrap"), + Code: "SG", + Name: i18n.NewString("Shrink-wrap"), }, { - Value: "SH", - Name: i18n.NewString("Special handling"), + Code: "SH", + Name: i18n.NewString("Special handling"), }, { - Value: "SM", - Name: i18n.NewString("Special finish"), + Code: "SM", + Name: i18n.NewString("Special finish"), }, { - Value: "ST", // not in EN16931 - Name: i18n.NewString("Stamp duties"), + Code: "ST", // not in EN16931 + Name: i18n.NewString("Stamp duties"), }, { - Value: "SU", - Name: i18n.NewString("Set-up"), + Code: "SU", + Name: i18n.NewString("Set-up"), }, { - Value: "TAB", - Name: i18n.NewString("Tank renting"), + Code: "TAB", + Name: i18n.NewString("Tank renting"), }, { - Value: "TAC", - Name: i18n.NewString("Testing"), + Code: "TAC", + Name: i18n.NewString("Testing"), }, { - Value: "TT", - Name: i18n.NewString("Transportation - third party billing"), + Code: "TT", + Name: i18n.NewString("Transportation - third party billing"), }, { - Value: "TV", - Name: i18n.NewString("Transportation by vendor"), + Code: "TV", + Name: i18n.NewString("Transportation by vendor"), }, { - Value: "TX", // not in EN16931 - Name: i18n.NewString("Tax"), + Code: "TX", // not in EN16931 + Name: i18n.NewString("Tax"), }, { - Value: "V1", - Name: i18n.NewString("Drop yard"), + Code: "V1", + Name: i18n.NewString("Drop yard"), }, { - Value: "V2", - Name: i18n.NewString("Drop dock"), + Code: "V2", + Name: i18n.NewString("Drop dock"), }, { - Value: "WH", - Name: i18n.NewString("Warehousing"), + Code: "WH", + Name: i18n.NewString("Warehousing"), }, { - Value: "XAA", - Name: i18n.NewString("Combine all same day shipment"), + Code: "XAA", + Name: i18n.NewString("Combine all same day shipment"), }, { - Value: "YY", - Name: i18n.NewString("Split pick-up"), + Code: "YY", + Name: i18n.NewString("Split pick-up"), }, { - Value: "ZZZ", - Name: i18n.NewString("Mutually defined"), + Code: "ZZZ", + Name: i18n.NewString("Mutually defined"), }, }, } diff --git a/catalogues/untdid/document_type.go b/catalogues/untdid/document_type.go index c09742d6..ec680bd0 100644 --- a/catalogues/untdid/document_type.go +++ b/catalogues/untdid/document_type.go @@ -11,7 +11,7 @@ const ( ExtKeyDocumentType cbc.Key = "untdid-document-type" ) -var extDocumentTypes = &cbc.KeyDefinition{ +var extDocumentTypes = &cbc.Definition{ Key: ExtKeyDocumentType, Name: i18n.String{ i18n.EN: "UNTDID 1001 Document Type", @@ -25,222 +25,222 @@ var extDocumentTypes = &cbc.KeyDefinition{ Other tax regimes and addons may use their own subset of codes. `), }, - Values: []*cbc.ValueDefinition{ + Values: []*cbc.Definition{ { - Value: "71", - Name: i18n.NewString("Request for payment"), + Code: "71", + Name: i18n.NewString("Request for payment"), }, { - Value: "80", - Name: i18n.NewString("Debit note related to goods or services"), + Code: "80", + Name: i18n.NewString("Debit note related to goods or services"), }, { - Value: "81", - Name: i18n.NewString("Credit note related to goods or services"), + Code: "81", + Name: i18n.NewString("Credit note related to goods or services"), }, { - Value: "82", - Name: i18n.NewString("Metered services invoice"), + Code: "82", + Name: i18n.NewString("Metered services invoice"), }, { - Value: "83", - Name: i18n.NewString("Credit note related to financial adjustments"), + Code: "83", + Name: i18n.NewString("Credit note related to financial adjustments"), }, { - Value: "84", - Name: i18n.NewString("Debit note related to financial adjustments"), + Code: "84", + Name: i18n.NewString("Debit note related to financial adjustments"), }, { - Value: "102", - Name: i18n.NewString("Tax notification"), + Code: "102", + Name: i18n.NewString("Tax notification"), }, { - Value: "130", - Name: i18n.NewString("Invoicing data sheet"), + Code: "130", + Name: i18n.NewString("Invoicing data sheet"), }, { - Value: "202", - Name: i18n.NewString("Direct payment valuation"), + Code: "202", + Name: i18n.NewString("Direct payment valuation"), }, { - Value: "203", - Name: i18n.NewString("Provisional payment valuation"), + Code: "203", + Name: i18n.NewString("Provisional payment valuation"), }, { - Value: "204", - Name: i18n.NewString("Payment valuation"), + Code: "204", + Name: i18n.NewString("Payment valuation"), }, { - Value: "211", - Name: i18n.NewString("Interim application for payment"), + Code: "211", + Name: i18n.NewString("Interim application for payment"), }, { - Value: "218", - Name: i18n.NewString("Final payment request based on completion of work"), + Code: "218", + Name: i18n.NewString("Final payment request based on completion of work"), }, { - Value: "219", - Name: i18n.NewString("Payment request for completed units"), + Code: "219", + Name: i18n.NewString("Payment request for completed units"), }, { - Value: "261", - Name: i18n.NewString("Self billed credit note"), + Code: "261", + Name: i18n.NewString("Self billed credit note"), }, { - Value: "262", - Name: i18n.NewString("Consolidated credit note - goods and services"), + Code: "262", + Name: i18n.NewString("Consolidated credit note - goods and services"), }, { - Value: "295", - Name: i18n.NewString("Price variation invoice"), + Code: "295", + Name: i18n.NewString("Price variation invoice"), }, { - Value: "296", - Name: i18n.NewString("Credit note for price variation"), + Code: "296", + Name: i18n.NewString("Credit note for price variation"), }, { - Value: "308", - Name: i18n.NewString("Delcredere credit note"), + Code: "308", + Name: i18n.NewString("Delcredere credit note"), }, { - Value: "325", - Name: i18n.NewString("Proforma invoice"), + Code: "325", + Name: i18n.NewString("Proforma invoice"), }, { - Value: "326", - Name: i18n.NewString("Partial invoice"), + Code: "326", + Name: i18n.NewString("Partial invoice"), }, { - Value: "380", - Name: i18n.NewString("Standard Invoice"), + Code: "380", + Name: i18n.NewString("Standard Invoice"), }, { - Value: "381", - Name: i18n.NewString("Credit note"), + Code: "381", + Name: i18n.NewString("Credit note"), }, { - Value: "382", - Name: i18n.NewString("Commission note"), + Code: "382", + Name: i18n.NewString("Commission note"), }, { - Value: "383", - Name: i18n.NewString("Debit note"), + Code: "383", + Name: i18n.NewString("Debit note"), }, { - Value: "384", - Name: i18n.NewString("Corrected invoice"), + Code: "384", + Name: i18n.NewString("Corrected invoice"), }, { - Value: "385", - Name: i18n.NewString("Consolidated invoice"), + Code: "385", + Name: i18n.NewString("Consolidated invoice"), }, { - Value: "386", - Name: i18n.NewString("Prepayment invoice"), + Code: "386", + Name: i18n.NewString("Prepayment invoice"), }, { - Value: "387", - Name: i18n.NewString("Hire invoice"), + Code: "387", + Name: i18n.NewString("Hire invoice"), }, { - Value: "388", - Name: i18n.NewString("Tax invoice"), + Code: "388", + Name: i18n.NewString("Tax invoice"), }, { - Value: "389", - Name: i18n.NewString("Self-billed invoice"), + Code: "389", + Name: i18n.NewString("Self-billed invoice"), }, { - Value: "390", - Name: i18n.NewString("Delcredere invoice"), + Code: "390", + Name: i18n.NewString("Delcredere invoice"), }, { - Value: "393", - Name: i18n.NewString("Factored invoice"), + Code: "393", + Name: i18n.NewString("Factored invoice"), }, { - Value: "394", - Name: i18n.NewString("Lease invoice"), + Code: "394", + Name: i18n.NewString("Lease invoice"), }, { - Value: "395", - Name: i18n.NewString("Consignment invoice"), + Code: "395", + Name: i18n.NewString("Consignment invoice"), }, { - Value: "396", - Name: i18n.NewString("Factored credit note"), + Code: "396", + Name: i18n.NewString("Factored credit note"), }, { - Value: "420", - Name: i18n.NewString("Optical Character Reading (OCR) payment credit note"), + Code: "420", + Name: i18n.NewString("Optical Character Reading (OCR) payment credit note"), }, { - Value: "456", - Name: i18n.NewString("Debit advice"), + Code: "456", + Name: i18n.NewString("Debit advice"), }, { - Value: "457", - Name: i18n.NewString("Reversal of debit"), + Code: "457", + Name: i18n.NewString("Reversal of debit"), }, { - Value: "458", - Name: i18n.NewString("Reversal of credit"), + Code: "458", + Name: i18n.NewString("Reversal of credit"), }, { - Value: "527", - Name: i18n.NewString("Self billed debit note"), + Code: "527", + Name: i18n.NewString("Self billed debit note"), }, { - Value: "532", - Name: i18n.NewString("Forwarder's credit note"), + Code: "532", + Name: i18n.NewString("Forwarder's credit note"), }, { - Value: "553", - Name: i18n.NewString("Forwarder's invoice discrepancy report"), + Code: "553", + Name: i18n.NewString("Forwarder's invoice discrepancy report"), }, { - Value: "575", - Name: i18n.NewString("Insurer's invoice"), + Code: "575", + Name: i18n.NewString("Insurer's invoice"), }, { - Value: "623", - Name: i18n.NewString("Forwarder's invoice"), + Code: "623", + Name: i18n.NewString("Forwarder's invoice"), }, { - Value: "633", - Name: i18n.NewString("Port charges documents"), + Code: "633", + Name: i18n.NewString("Port charges documents"), }, { - Value: "751", - Name: i18n.NewString("Invoice information for accounting purposes"), + Code: "751", + Name: i18n.NewString("Invoice information for accounting purposes"), }, { - Value: "780", - Name: i18n.NewString("Freight invoice"), + Code: "780", + Name: i18n.NewString("Freight invoice"), }, { - Value: "817", - Name: i18n.NewString("Claim notification"), + Code: "817", + Name: i18n.NewString("Claim notification"), }, { - Value: "870", - Name: i18n.NewString("Consular invoice"), + Code: "870", + Name: i18n.NewString("Consular invoice"), }, { - Value: "875", - Name: i18n.NewString("Partial construction invoice"), + Code: "875", + Name: i18n.NewString("Partial construction invoice"), }, { - Value: "876", - Name: i18n.NewString("Partial final construction invoice"), + Code: "876", + Name: i18n.NewString("Partial final construction invoice"), }, { - Value: "877", - Name: i18n.NewString("Final construction invoice"), + Code: "877", + Name: i18n.NewString("Final construction invoice"), }, { - Value: "935", - Name: i18n.NewString("Customs invoice"), + Code: "935", + Name: i18n.NewString("Customs invoice"), }, }, } diff --git a/catalogues/untdid/payment_means.go b/catalogues/untdid/payment_means.go index 76b5e2b8..41d9a907 100644 --- a/catalogues/untdid/payment_means.go +++ b/catalogues/untdid/payment_means.go @@ -11,7 +11,7 @@ const ( ExtKeyPaymentMeans cbc.Key = "untdid-payment-means" ) -var extPaymentMeans = &cbc.KeyDefinition{ +var extPaymentMeans = &cbc.Definition{ Key: ExtKeyPaymentMeans, Name: i18n.String{ i18n.EN: "UNTDID 4461 Payment Means", @@ -23,342 +23,342 @@ var extPaymentMeans = &cbc.KeyDefinition{ values table which focusses on invoices and payments. `), }, - Values: []*cbc.ValueDefinition{ + Values: []*cbc.Definition{ { - Value: "1", - Name: i18n.NewString("Instrument not defined"), + Code: "1", + Name: i18n.NewString("Instrument not defined"), }, { - Value: "2", - Name: i18n.NewString("Automated clearing house credit"), + Code: "2", + Name: i18n.NewString("Automated clearing house credit"), }, { - Value: "3", - Name: i18n.NewString("Automated clearing house debit"), + Code: "3", + Name: i18n.NewString("Automated clearing house debit"), }, { - Value: "4", - Name: i18n.NewString("ACH demand debit reversal"), + Code: "4", + Name: i18n.NewString("ACH demand debit reversal"), }, { - Value: "5", - Name: i18n.NewString("ACH demand credit reversal"), + Code: "5", + Name: i18n.NewString("ACH demand credit reversal"), }, { - Value: "6", - Name: i18n.NewString("ACH demand credit"), + Code: "6", + Name: i18n.NewString("ACH demand credit"), }, { - Value: "7", - Name: i18n.NewString("ACH demand debit"), + Code: "7", + Name: i18n.NewString("ACH demand debit"), }, { - Value: "8", - Name: i18n.NewString("Hold"), + Code: "8", + Name: i18n.NewString("Hold"), }, { - Value: "9", - Name: i18n.NewString("National or regional clearing"), + Code: "9", + Name: i18n.NewString("National or regional clearing"), }, { - Value: "10", - Name: i18n.NewString("In cash"), + Code: "10", + Name: i18n.NewString("In cash"), }, { - Value: "11", - Name: i18n.NewString("ACH savings credit reversal"), + Code: "11", + Name: i18n.NewString("ACH savings credit reversal"), }, { - Value: "12", - Name: i18n.NewString("ACH savings debit reversal"), + Code: "12", + Name: i18n.NewString("ACH savings debit reversal"), }, { - Value: "13", - Name: i18n.NewString("ACH savings credit"), + Code: "13", + Name: i18n.NewString("ACH savings credit"), }, { - Value: "14", - Name: i18n.NewString("ACH savings debit"), + Code: "14", + Name: i18n.NewString("ACH savings debit"), }, { - Value: "15", - Name: i18n.NewString("Bookentry credit"), + Code: "15", + Name: i18n.NewString("Bookentry credit"), }, { - Value: "16", - Name: i18n.NewString("Bookentry debit"), + Code: "16", + Name: i18n.NewString("Bookentry debit"), }, { - Value: "17", - Name: i18n.NewString("ACH demand cash concentration/disbursement (CCD) credit"), + Code: "17", + Name: i18n.NewString("ACH demand cash concentration/disbursement (CCD) credit"), }, { - Value: "18", - Name: i18n.NewString("ACH demand cash concentration/disbursement (CCD) debit"), + Code: "18", + Name: i18n.NewString("ACH demand cash concentration/disbursement (CCD) debit"), }, { - Value: "19", - Name: i18n.NewString("ACH demand corporate trade payment (CTP) credit"), + Code: "19", + Name: i18n.NewString("ACH demand corporate trade payment (CTP) credit"), }, { - Value: "20", - Name: i18n.NewString("Cheque"), + Code: "20", + Name: i18n.NewString("Cheque"), }, { - Value: "21", - Name: i18n.NewString("Banker's draft"), + Code: "21", + Name: i18n.NewString("Banker's draft"), }, { - Value: "22", - Name: i18n.NewString("Certified banker's draft"), + Code: "22", + Name: i18n.NewString("Certified banker's draft"), }, { - Value: "23", - Name: i18n.NewString("Bank cheque (issued by a banking or similar establishment)"), + Code: "23", + Name: i18n.NewString("Bank cheque (issued by a banking or similar establishment)"), }, { - Value: "24", - Name: i18n.NewString("Bill of exchange awaiting acceptance"), + Code: "24", + Name: i18n.NewString("Bill of exchange awaiting acceptance"), }, { - Value: "25", - Name: i18n.NewString("Certified cheque"), + Code: "25", + Name: i18n.NewString("Certified cheque"), }, { - Value: "26", - Name: i18n.NewString("Local cheque"), + Code: "26", + Name: i18n.NewString("Local cheque"), }, { - Value: "27", - Name: i18n.NewString("ACH demand corporate trade payment (CTP) debit"), + Code: "27", + Name: i18n.NewString("ACH demand corporate trade payment (CTP) debit"), }, { - Value: "28", - Name: i18n.NewString("ACH demand corporate trade exchange (CTX) credit"), + Code: "28", + Name: i18n.NewString("ACH demand corporate trade exchange (CTX) credit"), }, { - Value: "29", - Name: i18n.NewString("ACH demand corporate trade exchange (CTX) debit"), + Code: "29", + Name: i18n.NewString("ACH demand corporate trade exchange (CTX) debit"), }, { - Value: "30", - Name: i18n.NewString("Credit transfer"), + Code: "30", + Name: i18n.NewString("Credit transfer"), }, { - Value: "31", - Name: i18n.NewString("Debit transfer"), + Code: "31", + Name: i18n.NewString("Debit transfer"), }, { - Value: "32", - Name: i18n.NewString("ACH demand cash concentration/disbursement plus (CCD+)"), + Code: "32", + Name: i18n.NewString("ACH demand cash concentration/disbursement plus (CCD+)"), }, { - Value: "33", - Name: i18n.NewString("ACH demand cash concentration/disbursement plus (CCD+)"), + Code: "33", + Name: i18n.NewString("ACH demand cash concentration/disbursement plus (CCD+)"), }, { - Value: "34", - Name: i18n.NewString("ACH prearranged payment and deposit (PPD)"), + Code: "34", + Name: i18n.NewString("ACH prearranged payment and deposit (PPD)"), }, { - Value: "35", - Name: i18n.NewString("ACH savings cash concentration/disbursement (CCD) credit"), + Code: "35", + Name: i18n.NewString("ACH savings cash concentration/disbursement (CCD) credit"), }, { - Value: "36", - Name: i18n.NewString("ACH savings cash concentration/disbursement (CCD) debit"), + Code: "36", + Name: i18n.NewString("ACH savings cash concentration/disbursement (CCD) debit"), }, { - Value: "37", - Name: i18n.NewString("ACH savings corporate trade payment (CTP) credit"), + Code: "37", + Name: i18n.NewString("ACH savings corporate trade payment (CTP) credit"), }, { - Value: "38", - Name: i18n.NewString("ACH savings corporate trade payment (CTP) debit"), + Code: "38", + Name: i18n.NewString("ACH savings corporate trade payment (CTP) debit"), }, { - Value: "39", - Name: i18n.NewString("ACH savings corporate trade exchange (CTX) credit"), + Code: "39", + Name: i18n.NewString("ACH savings corporate trade exchange (CTX) credit"), }, { - Value: "40", - Name: i18n.NewString("ACH savings corporate trade exchange (CTX) debit"), + Code: "40", + Name: i18n.NewString("ACH savings corporate trade exchange (CTX) debit"), }, { - Value: "41", - Name: i18n.NewString("ACH savings cash concentration/disbursement plus (CCD+)"), + Code: "41", + Name: i18n.NewString("ACH savings cash concentration/disbursement plus (CCD+)"), }, { - Value: "42", - Name: i18n.NewString("Payment to bank account"), + Code: "42", + Name: i18n.NewString("Payment to bank account"), }, { - Value: "43", - Name: i18n.NewString("ACH savings cash concentration/disbursement plus (CCD+)"), + Code: "43", + Name: i18n.NewString("ACH savings cash concentration/disbursement plus (CCD+)"), }, { - Value: "44", - Name: i18n.NewString("Accepted bill of exchange"), + Code: "44", + Name: i18n.NewString("Accepted bill of exchange"), }, { - Value: "45", - Name: i18n.NewString("Referenced home-banking credit transfer"), + Code: "45", + Name: i18n.NewString("Referenced home-banking credit transfer"), }, { - Value: "46", - Name: i18n.NewString("Interbank debit transfer"), + Code: "46", + Name: i18n.NewString("Interbank debit transfer"), }, { - Value: "47", - Name: i18n.NewString("Home-banking debit transfer"), + Code: "47", + Name: i18n.NewString("Home-banking debit transfer"), }, { - Value: "48", - Name: i18n.NewString("Bank card"), + Code: "48", + Name: i18n.NewString("Bank card"), }, { - Value: "49", - Name: i18n.NewString("Direct debit"), + Code: "49", + Name: i18n.NewString("Direct debit"), }, { - Value: "50", - Name: i18n.NewString("Payment by postgiro"), + Code: "50", + Name: i18n.NewString("Payment by postgiro"), }, { - Value: "51", - Name: i18n.NewString("FR, norme 6 97-Telereglement CFONB (French Organisation for"), + Code: "51", + Name: i18n.NewString("FR, norme 6 97-Telereglement CFONB (French Organisation for"), }, { - Value: "52", - Name: i18n.NewString("Urgent commercial payment"), + Code: "52", + Name: i18n.NewString("Urgent commercial payment"), }, { - Value: "53", - Name: i18n.NewString("Urgent Treasury Payment"), + Code: "53", + Name: i18n.NewString("Urgent Treasury Payment"), }, { - Value: "54", - Name: i18n.NewString("Credit card"), + Code: "54", + Name: i18n.NewString("Credit card"), }, { - Value: "55", - Name: i18n.NewString("Debit card"), + Code: "55", + Name: i18n.NewString("Debit card"), }, { - Value: "56", - Name: i18n.NewString("Bankgiro"), + Code: "56", + Name: i18n.NewString("Bankgiro"), }, { - Value: "57", - Name: i18n.NewString("Standing agreement"), + Code: "57", + Name: i18n.NewString("Standing agreement"), }, { - Value: "58", - Name: i18n.NewString("SEPA credit transfer"), + Code: "58", + Name: i18n.NewString("SEPA credit transfer"), }, { - Value: "59", - Name: i18n.NewString("SEPA direct debit"), + Code: "59", + Name: i18n.NewString("SEPA direct debit"), }, { - Value: "60", - Name: i18n.NewString("Promissory note"), + Code: "60", + Name: i18n.NewString("Promissory note"), }, { - Value: "61", - Name: i18n.NewString("Promissory note signed by the debtor"), + Code: "61", + Name: i18n.NewString("Promissory note signed by the debtor"), }, { - Value: "62", - Name: i18n.NewString("Promissory note signed by the debtor and endorsed by a bank"), + Code: "62", + Name: i18n.NewString("Promissory note signed by the debtor and endorsed by a bank"), }, { - Value: "63", - Name: i18n.NewString("Promissory note signed by the debtor and endorsed by a"), + Code: "63", + Name: i18n.NewString("Promissory note signed by the debtor and endorsed by a"), }, { - Value: "64", - Name: i18n.NewString("Promissory note signed by a bank"), + Code: "64", + Name: i18n.NewString("Promissory note signed by a bank"), }, { - Value: "65", - Name: i18n.NewString("Promissory note signed by a bank and endorsed by another"), + Code: "65", + Name: i18n.NewString("Promissory note signed by a bank and endorsed by another"), }, { - Value: "66", - Name: i18n.NewString("Promissory note signed by a third party"), + Code: "66", + Name: i18n.NewString("Promissory note signed by a third party"), }, { - Value: "67", - Name: i18n.NewString("Promissory note signed by a third party and endorsed by a"), + Code: "67", + Name: i18n.NewString("Promissory note signed by a third party and endorsed by a"), }, { - Value: "68", - Name: i18n.NewString("Online payment service"), + Code: "68", + Name: i18n.NewString("Online payment service"), }, { - Value: "69", - Name: i18n.NewString("Transfer Advice"), + Code: "69", + Name: i18n.NewString("Transfer Advice"), }, { - Value: "70", - Name: i18n.NewString("Bill drawn by the creditor on the debtor"), + Code: "70", + Name: i18n.NewString("Bill drawn by the creditor on the debtor"), }, { - Value: "74", - Name: i18n.NewString("Bill drawn by the creditor on a bank"), + Code: "74", + Name: i18n.NewString("Bill drawn by the creditor on a bank"), }, { - Value: "75", - Name: i18n.NewString("Bill drawn by the creditor, endorsed by another bank"), + Code: "75", + Name: i18n.NewString("Bill drawn by the creditor, endorsed by another bank"), }, { - Value: "76", - Name: i18n.NewString("Bill drawn by the creditor on a bank and endorsed by a"), + Code: "76", + Name: i18n.NewString("Bill drawn by the creditor on a bank and endorsed by a"), }, { - Value: "77", - Name: i18n.NewString("Bill drawn by the creditor on a third party"), + Code: "77", + Name: i18n.NewString("Bill drawn by the creditor on a third party"), }, { - Value: "78", - Name: i18n.NewString("Bill drawn by creditor on third party, accepted and"), + Code: "78", + Name: i18n.NewString("Bill drawn by creditor on third party, accepted and"), }, { - Value: "91", - Name: i18n.NewString("Not transferable banker's draft"), + Code: "91", + Name: i18n.NewString("Not transferable banker's draft"), }, { - Value: "92", - Name: i18n.NewString("Not transferable local cheque"), + Code: "92", + Name: i18n.NewString("Not transferable local cheque"), }, { - Value: "93", - Name: i18n.NewString("Reference giro"), + Code: "93", + Name: i18n.NewString("Reference giro"), }, { - Value: "94", - Name: i18n.NewString("Urgent giro"), + Code: "94", + Name: i18n.NewString("Urgent giro"), }, { - Value: "95", - Name: i18n.NewString("Free format giro"), + Code: "95", + Name: i18n.NewString("Free format giro"), }, { - Value: "96", - Name: i18n.NewString("Requested method for payment was not used"), + Code: "96", + Name: i18n.NewString("Requested method for payment was not used"), }, { - Value: "97", - Name: i18n.NewString("Clearing between partners"), + Code: "97", + Name: i18n.NewString("Clearing between partners"), }, { - Value: "98", - Name: i18n.NewString("JP, Electronically Recorded Monetary Claims"), + Code: "98", + Name: i18n.NewString("JP, Electronically Recorded Monetary Claims"), }, { - Value: "ZZZ", - Name: i18n.NewString("Mutually defined"), + Code: "ZZZ", + Name: i18n.NewString("Mutually defined"), }, }, } diff --git a/catalogues/untdid/tax_category.go b/catalogues/untdid/tax_category.go index 392d4885..f432f640 100644 --- a/catalogues/untdid/tax_category.go +++ b/catalogues/untdid/tax_category.go @@ -11,7 +11,7 @@ const ( ExtKeyTaxCategory cbc.Key = "untdid-tax-category" ) -var extTaxCategory = &cbc.KeyDefinition{ +var extTaxCategory = &cbc.Definition{ Key: ExtKeyTaxCategory, Name: i18n.String{ i18n.EN: "UNTDID 3505 Tax Category", @@ -25,129 +25,129 @@ var extTaxCategory = &cbc.KeyDefinition{ Data from https://unece.org/fileadmin/DAM/trade/untdid/d16b/tred/tred5305.htm. `), }, - Values: []*cbc.ValueDefinition{ + Values: []*cbc.Definition{ { - Value: "A", + Code: "A", Name: i18n.String{ i18n.EN: "Mixed tax rate", }, }, { - Value: "AA", + Code: "AA", Name: i18n.String{ i18n.EN: "Lower rate", }, }, { - Value: "AB", + Code: "AB", Name: i18n.String{ i18n.EN: "Exempt for resale", }, }, { - Value: "AC", + Code: "AC", Name: i18n.String{ i18n.EN: "Exempt for resale", }, }, { - Value: "AD", + Code: "AD", Name: i18n.String{ i18n.EN: "Value Added Tax (VAT) due from a previous invoice", }, }, { - Value: "AE", + Code: "AE", Name: i18n.String{ i18n.EN: "VAT Reverse Charge", }, }, { - Value: "B", + Code: "B", Name: i18n.String{ i18n.EN: "Transferred (VAT)", }, }, { - Value: "C", + Code: "C", Name: i18n.String{ i18n.EN: "Duty paid by supplier", }, }, { - Value: "D", + Code: "D", Name: i18n.String{ i18n.EN: "Value Added Tax (VAT) margin scheme - travel agents", }, }, { - Value: "E", + Code: "E", Name: i18n.String{ i18n.EN: "Exempt from tax", }, }, { - Value: "F", + Code: "F", Name: i18n.String{ i18n.EN: "Value Added Tax (VAT) margin scheme - second-hand goods", }, }, { - Value: "G", + Code: "G", Name: i18n.String{ i18n.EN: "Free export item, tax not charged", }, }, { - Value: "H", + Code: "H", Name: i18n.String{ i18n.EN: "Higher rate", }, }, { - Value: "I", + Code: "I", Name: i18n.String{ i18n.EN: "Value Added Tax (VAT) margin scheme - works of art", }, }, { - Value: "J", + Code: "J", Name: i18n.String{ i18n.EN: "Value Added Tax (VAT) margin scheme - collector's items and antiques", }, }, { - Value: "K", + Code: "K", Name: i18n.String{ i18n.EN: "VAT exempt for EEA intra-community supply of goods and services", }, }, { - Value: "L", + Code: "L", Name: i18n.String{ i18n.EN: "Canary Islands general indirect tax", }, }, { - Value: "M", + Code: "M", Name: i18n.String{ i18n.EN: "Tax for production, services and importation in Ceuta and Melilla", }, }, { - Value: "O", + Code: "O", Name: i18n.String{ i18n.EN: "Services outside scope of tax", }, }, { - Value: "S", + Code: "S", Name: i18n.String{ i18n.EN: "Standard Rate", }, }, { - Value: "Z", + Code: "Z", Name: i18n.String{ i18n.EN: "Zero rated goods", }, diff --git a/catalogues/untdid/untdid.go b/catalogues/untdid/untdid.go index 1f79c807..537eea76 100644 --- a/catalogues/untdid/untdid.go +++ b/catalogues/untdid/untdid.go @@ -15,7 +15,7 @@ func newCatalogue() *tax.CatalogueDef { return &tax.CatalogueDef{ Key: "untdid", Name: i18n.NewString("UN/EDIFACT Data Elements"), - Extensions: []*cbc.KeyDefinition{ + Extensions: []*cbc.Definition{ extDocumentTypes, // 1001 extPaymentMeans, // 4461 extAllowance, // 5189 diff --git a/cbc/cbc.go b/cbc/cbc.go index 019b9b87..2e0d2cca 100644 --- a/cbc/cbc.go +++ b/cbc/cbc.go @@ -10,9 +10,8 @@ func init() { Code(""), CodeMap{}, Key(""), - KeyDefinition{}, + Definition{}, Meta{}, Note{}, - ValueDefinition{}, ) } diff --git a/cbc/definition.go b/cbc/definition.go new file mode 100644 index 00000000..c672e8de --- /dev/null +++ b/cbc/definition.go @@ -0,0 +1,161 @@ +package cbc + +import ( + "regexp" + + "github.com/invopop/gobl/i18n" + "github.com/invopop/validation" +) + +// Definition defines properties of a key, code, or other value that has a specific meaning or +// utility. +type Definition struct { + // Key being defined. + Key Key `json:"key" jsonschema:"title=Key"` + // Code this definition represents. + Code Code `json:"code" jsonschema:"title=Code"` + + // Short name for the key. + Name i18n.String `json:"name" jsonschema:"title=Name"` + // Description offering more details about when the key should be used. + Desc i18n.String `json:"desc,omitempty" jsonschema:"title=Description"` + // Meta defines any additional details that may be useful or associated + // with the key. + Meta Meta `json:"meta,omitempty" jsonschema:"title=Meta"` + + // Values defines the possible values associated with the key, which themselves will + // either be keys or codes depending on the context. + Values []*Definition `json:"values,omitempty" jsonschema:"title=Values"` + + // Pattern is used to validate the key value instead of using a fixed value + // from the code or key definitions. + Pattern string `json:"pattern,omitempty" jsonschema:"title=Pattern"` + + // Map helps map local keys to specific codes, useful for converting the + // described key into a local code. + Map CodeMap `json:"map,omitempty" jsonschema:"title=Code Map"` +} + +// Validate ensures the definition looks correct. +func (d *Definition) Validate() error { + err := validation.ValidateStruct(d, + validation.Field(&d.Key, + validation.When( + d.Code == "", + validation.Required.Error("or code are required"), + ), + ), + validation.Field(&d.Code, + validation.When( + d.Key != "", + validation.Empty.Error("must be empty when key is set"), + ), + ), + validation.Field(&d.Name, validation.Required), + validation.Field(&d.Desc), + validation.Field(&d.Values), + validation.Field(&d.Pattern, validation.By(validRegexpPattern)), + ) + return err +} + +// HasCode loops through values and determines if there +// is a match for the code. +func (d *Definition) HasCode(code Code) bool { + cd := d.CodeDef(code) + return cd != nil +} + +// CodeDef searches the list of values and provides the matching definition. +func (d *Definition) CodeDef(code Code) *Definition { + for _, c := range d.Values { + if c.Code == code { + return c + } + } + return nil +} + +// HasKey loops through values and determines if there +// is a match for the key. +func (d *Definition) HasKey(key Key) bool { + cd := d.KeyDef(key) + return cd != nil +} + +// KeyDef searches the list of values and provides the matching definition. +func (d *Definition) KeyDef(key Key) *Definition { + for _, c := range d.Values { + if c.Key == key { + return c + } + } + return nil +} + +// DefinitionKeys helps extract the keys from a list of key definitions. +func DefinitionKeys(list []*Definition) []Key { + keys := make([]Key, 0, len(list)) + for _, item := range list { + keys = append(keys, item.Key) + } + return keys +} + +// DefinitionCodes helps extract the codes from a list of key definitions. +func DefinitionCodes(list []*Definition) []Code { + codes := make([]Code, 0, len(list)) + for _, item := range list { + codes = append(codes, item.Code) + } + return codes +} + +// GetKeyDefinition helps fetch the key definition instance from a list. +func GetKeyDefinition(key Key, list []*Definition) *Definition { + for _, item := range list { + if item.Key == key { + return item + } + } + return nil +} + +// GetCodeDefinition helps fetch the code definition instance from a list. +func GetCodeDefinition(code Code, list []*Definition) *Definition { + for _, item := range list { + if item.Code == code { + return item + } + } + return nil +} + +// InKeyDefs prepares a validation to provide a rule that will determine +// if the keys are in the provided set. +func InKeyDefs(list []*Definition) validation.Rule { + defs := make([]interface{}, len(list)) + for i, item := range list { + defs[i] = item.Key + } + return validation.In(defs...) +} + +// InCodeDefs prepares a validation to provide a rule that will determine +// if the codes are in the provided set. +func InCodeDefs(list []*Definition) validation.Rule { + defs := make([]interface{}, len(list)) + for i, item := range list { + defs[i] = item.Key + } + return validation.In(defs...) +} + +func validRegexpPattern(value any) error { + pattern, ok := value.(string) + if !ok || pattern == "" { + return nil + } + _, err := regexp.Compile(pattern) + return err +} diff --git a/cbc/key_definition_test.go b/cbc/definition_test.go similarity index 74% rename from cbc/key_definition_test.go rename to cbc/definition_test.go index a5a7e270..294d66af 100644 --- a/cbc/key_definition_test.go +++ b/cbc/definition_test.go @@ -9,8 +9,8 @@ import ( "github.com/stretchr/testify/require" ) -func TestKeyDefinitionsWithValues(t *testing.T) { - kd := &cbc.KeyDefinition{ +func TestDefinitionsWithValues(t *testing.T) { + kd := &cbc.Definition{ Key: "key", Name: i18n.String{ i18n.EN: "Name", @@ -20,9 +20,9 @@ func TestKeyDefinitionsWithValues(t *testing.T) { i18n.EN: "Description", i18n.ES: "Descripción", }, - Values: []*cbc.ValueDefinition{ + Values: []*cbc.Definition{ { - Value: "value", + Code: "value", Name: i18n.String{ i18n.EN: "Value", i18n.ES: "Valor", @@ -30,15 +30,15 @@ func TestKeyDefinitionsWithValues(t *testing.T) { }, }, } - assert.True(t, kd.HasValue("value")) - assert.False(t, kd.HasValue("invalid")) - vd := kd.ValueDef("value") + assert.True(t, kd.HasCode("value")) + assert.False(t, kd.HasCode("invalid")) + vd := kd.CodeDef("value") require.NotNil(t, vd) assert.Equal(t, "Value", vd.Name[i18n.EN]) } -func TestKeyDefinitionWithPattern(t *testing.T) { - kd := &cbc.KeyDefinition{ +func TestDefinitionWithPattern(t *testing.T) { + kd := &cbc.Definition{ Key: "key", Name: i18n.String{ i18n.EN: "Name", diff --git a/cbc/key_definition.go b/cbc/key_definition.go deleted file mode 100644 index d439a200..00000000 --- a/cbc/key_definition.go +++ /dev/null @@ -1,100 +0,0 @@ -package cbc - -import ( - "regexp" - - "github.com/invopop/gobl/i18n" - "github.com/invopop/validation" -) - -// KeyDefinition defines properties of a key that is specific for a regime. -type KeyDefinition struct { - // Actual key value. - Key Key `json:"key" jsonschema:"title=Key"` - // Short name for the key. - Name i18n.String `json:"name" jsonschema:"title=Name"` - // Description offering more details about when the key should be used. - Desc i18n.String `json:"desc,omitempty" jsonschema:"title=Description"` - // Meta defines any additional details that may be useful or associated - // with the key. - Meta Meta `json:"meta,omitempty" jsonschema:"title=Meta"` - - // Values defines the possible values associated with the key. - Values []*ValueDefinition `json:"values,omitempty" jsonschema:"title=Values"` - - // Pattern is used to validate the key value instead of using a fixed value - // from the code or key definitions. - Pattern string `json:"pattern,omitempty" jsonschema:"title=Pattern"` - - // Map helps map local keys to specific codes, useful for converting the - // described key into a local code. - Map CodeMap `json:"map,omitempty" jsonschema:"title=Code Map"` -} - -// HasValue loops through values and determines if there -// is a match. -func (kd *KeyDefinition) HasValue(val string) bool { - cd := kd.ValueDef(val) - return cd != nil -} - -// ValueDef searches the list of values defined for the key, and provides -// the matching value definition. -func (kd *KeyDefinition) ValueDef(val string) *ValueDefinition { - for _, c := range kd.Values { - if c.Value == val { - return c - } - } - return nil -} - -// Validate ensures the key definition looks correct in the context of the regime. -func (kd *KeyDefinition) Validate() error { - err := validation.ValidateStruct(kd, - validation.Field(&kd.Key, validation.Required), - validation.Field(&kd.Name, validation.Required), - validation.Field(&kd.Desc), - validation.Field(&kd.Values), - validation.Field(&kd.Pattern, validation.By(validRegexpPattern)), - ) - return err -} - -// DefinitionKeys helps extract the keys from a list of key definitions. -func DefinitionKeys(list []*KeyDefinition) []Key { - keys := make([]Key, len(list)) - for i, item := range list { - keys[i] = item.Key - } - return keys -} - -// GetKeyDefinition helps fetch the key definition instance from a list. -func GetKeyDefinition(key Key, list []*KeyDefinition) *KeyDefinition { - for _, item := range list { - if item.Key == key { - return item - } - } - return nil -} - -// InKeyDefs prepares a validation to provide a rule that will determine -// if the keys are in the provided set. -func InKeyDefs(list []*KeyDefinition) validation.Rule { - defs := make([]interface{}, len(list)) - for i, item := range list { - defs[i] = item.Key - } - return validation.In(defs...) -} - -func validRegexpPattern(value any) error { - pattern, ok := value.(string) - if !ok || pattern == "" { - return nil - } - _, err := regexp.Compile(pattern) - return err -} diff --git a/cbc/notes.go b/cbc/notes.go index 91767ada..1c85a507 100644 --- a/cbc/notes.go +++ b/cbc/notes.go @@ -237,7 +237,7 @@ type Note struct { // Key specifying subject of the text Key Key `json:"key,omitempty" jsonschema:"title=Key"` // Code used for additional data that may be required to identify the note. - Code string `json:"code,omitempty" jsonschema:"title=Code"` + Code Code `json:"code,omitempty" jsonschema:"title=Code"` // Source of this note, especially useful when auto-generated. Src Key `json:"src,omitempty" jsonschema:"title=Source"` // The contents of the note @@ -288,7 +288,7 @@ func (n *Note) WithSrc(src Key) *Note { } // WithCode provides a new copy of the note with the code set. -func (n *Note) WithCode(code string) *Note { +func (n *Note) WithCode(code Code) *Note { nw := *n // copy nw.Code = code return &nw diff --git a/cbc/value_definition.go b/cbc/value_definition.go deleted file mode 100644 index 4515f579..00000000 --- a/cbc/value_definition.go +++ /dev/null @@ -1,29 +0,0 @@ -package cbc - -import ( - "github.com/invopop/gobl/i18n" - "github.com/invopop/validation" -) - -// ValueDefinition describes a specific value and how it maps to a human name -// and description if appropriate. -type ValueDefinition struct { - // Value for which the definition is for. - Value string `json:"value" jsonschema:"title=Value"` - // Short name for the value, if relevant. - Name i18n.String `json:"name,omitempty" jsonschema:"title=Name"` - // Description offering more details about when the value should be used. - Desc i18n.String `json:"desc,omitempty" jsonschema:"title=Description"` - // Meta defines any additional details that may be useful or associated - // with the value. - Meta Meta `json:"meta,omitempty" jsonschema:"title=Meta"` -} - -// Validate ensures the contents of the value definition are valid. -func (vd *ValueDefinition) Validate() error { - return validation.ValidateStruct(vd, - validation.Field(&vd.Value, validation.Required), - validation.Field(&vd.Name, validation.Required), - validation.Field(&vd.Desc), - ) -} diff --git a/cbc/value_definition_test.go b/cbc/value_definition_test.go deleted file mode 100644 index 22f70a25..00000000 --- a/cbc/value_definition_test.go +++ /dev/null @@ -1,18 +0,0 @@ -package cbc_test - -import ( - "testing" - - "github.com/invopop/gobl/cbc" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" -) - -func TestValueDefintionValidation(t *testing.T) { - vd := new(cbc.ValueDefinition) - - err := vd.Validate() - require.Error(t, err) - assert.Contains(t, err.Error(), "value: cannot be blank") - assert.Contains(t, err.Error(), "name: cannot be blank") -} diff --git a/internal/cli/bulk_test.go b/internal/cli/bulk_test.go index 7adfea77..59ecb1ef 100644 --- a/internal/cli/bulk_test.go +++ b/internal/cli/bulk_test.go @@ -648,7 +648,7 @@ func TestBulk(t *testing.T) { //nolint:gocyclo // Following raw message is copied and pasted! (sorry!) Payload: json.RawMessage(`{ "list": [ - "https://gobl.org/draft-0/bill/correction-options", "https://gobl.org/draft-0/bill/invoice", "https://gobl.org/draft-0/cal/date", "https://gobl.org/draft-0/cal/date-time", "https://gobl.org/draft-0/cal/period", "https://gobl.org/draft-0/cbc/code", "https://gobl.org/draft-0/cbc/code-map", "https://gobl.org/draft-0/cbc/key", "https://gobl.org/draft-0/cbc/key-definition", "https://gobl.org/draft-0/cbc/meta", "https://gobl.org/draft-0/cbc/note", "https://gobl.org/draft-0/cbc/value-definition", "https://gobl.org/draft-0/currency/amount", "https://gobl.org/draft-0/currency/code", "https://gobl.org/draft-0/currency/exchange-rate", "https://gobl.org/draft-0/dsig/digest", "https://gobl.org/draft-0/dsig/signature", "https://gobl.org/draft-0/envelope", "https://gobl.org/draft-0/head/header", "https://gobl.org/draft-0/head/link", "https://gobl.org/draft-0/head/stamp", "https://gobl.org/draft-0/i18n/string", "https://gobl.org/draft-0/l10n/code", "https://gobl.org/draft-0/l10n/iso-country-code", "https://gobl.org/draft-0/l10n/tax-country-code", "https://gobl.org/draft-0/note/message", "https://gobl.org/draft-0/num/amount", "https://gobl.org/draft-0/num/percentage", "https://gobl.org/draft-0/org/address", "https://gobl.org/draft-0/org/coordinates", "https://gobl.org/draft-0/org/document-ref", "https://gobl.org/draft-0/org/email", "https://gobl.org/draft-0/org/identity", "https://gobl.org/draft-0/org/image", "https://gobl.org/draft-0/org/inbox", "https://gobl.org/draft-0/org/item", "https://gobl.org/draft-0/org/name", "https://gobl.org/draft-0/org/party", "https://gobl.org/draft-0/org/person", "https://gobl.org/draft-0/org/registration", "https://gobl.org/draft-0/org/telephone", "https://gobl.org/draft-0/org/unit", "https://gobl.org/draft-0/org/website", "https://gobl.org/draft-0/pay/advance", "https://gobl.org/draft-0/pay/instructions", "https://gobl.org/draft-0/pay/terms", "https://gobl.org/draft-0/regimes/mx/food-vouchers", "https://gobl.org/draft-0/regimes/mx/fuel-account-balance", "https://gobl.org/draft-0/schema/object", "https://gobl.org/draft-0/tax/addon-def", "https://gobl.org/draft-0/tax/catalogue-def", "https://gobl.org/draft-0/tax/extensions", "https://gobl.org/draft-0/tax/identity", "https://gobl.org/draft-0/tax/regime-def", "https://gobl.org/draft-0/tax/set", "https://gobl.org/draft-0/tax/total" + "https://gobl.org/draft-0/bill/correction-options", "https://gobl.org/draft-0/bill/invoice", "https://gobl.org/draft-0/cal/date", "https://gobl.org/draft-0/cal/date-time", "https://gobl.org/draft-0/cal/period", "https://gobl.org/draft-0/cbc/code", "https://gobl.org/draft-0/cbc/code-map", "https://gobl.org/draft-0/cbc/definition", "https://gobl.org/draft-0/cbc/key", "https://gobl.org/draft-0/cbc/meta", "https://gobl.org/draft-0/cbc/note", "https://gobl.org/draft-0/currency/amount", "https://gobl.org/draft-0/currency/code", "https://gobl.org/draft-0/currency/exchange-rate", "https://gobl.org/draft-0/dsig/digest", "https://gobl.org/draft-0/dsig/signature", "https://gobl.org/draft-0/envelope", "https://gobl.org/draft-0/head/header", "https://gobl.org/draft-0/head/link", "https://gobl.org/draft-0/head/stamp", "https://gobl.org/draft-0/i18n/string", "https://gobl.org/draft-0/l10n/code", "https://gobl.org/draft-0/l10n/iso-country-code", "https://gobl.org/draft-0/l10n/tax-country-code", "https://gobl.org/draft-0/note/message", "https://gobl.org/draft-0/num/amount", "https://gobl.org/draft-0/num/percentage", "https://gobl.org/draft-0/org/address", "https://gobl.org/draft-0/org/coordinates", "https://gobl.org/draft-0/org/document-ref", "https://gobl.org/draft-0/org/email", "https://gobl.org/draft-0/org/identity", "https://gobl.org/draft-0/org/image", "https://gobl.org/draft-0/org/inbox", "https://gobl.org/draft-0/org/item", "https://gobl.org/draft-0/org/name", "https://gobl.org/draft-0/org/party", "https://gobl.org/draft-0/org/person", "https://gobl.org/draft-0/org/registration", "https://gobl.org/draft-0/org/telephone", "https://gobl.org/draft-0/org/unit", "https://gobl.org/draft-0/org/website", "https://gobl.org/draft-0/pay/advance", "https://gobl.org/draft-0/pay/instructions", "https://gobl.org/draft-0/pay/terms", "https://gobl.org/draft-0/regimes/mx/food-vouchers", "https://gobl.org/draft-0/regimes/mx/fuel-account-balance", "https://gobl.org/draft-0/schema/object", "https://gobl.org/draft-0/tax/addon-def", "https://gobl.org/draft-0/tax/catalogue-def", "https://gobl.org/draft-0/tax/extensions", "https://gobl.org/draft-0/tax/identity", "https://gobl.org/draft-0/tax/regime-def", "https://gobl.org/draft-0/tax/set", "https://gobl.org/draft-0/tax/total" ] }`), IsFinal: false, diff --git a/pay/means_key.go b/pay/means_key.go index 4919d08c..f854b455 100644 --- a/pay/means_key.go +++ b/pay/means_key.go @@ -27,7 +27,7 @@ const ( // MeansKeyDefinitions includes all the payment means keys that // are accepted by GOBL. -var MeansKeyDefinitions = []*cbc.KeyDefinition{ +var MeansKeyDefinitions = []*cbc.Definition{ { Key: MeansKeyAny, Name: i18n.NewString("Any"), diff --git a/regimes/co/party.go b/regimes/co/party.go index 471c9c41..d45ba6dd 100644 --- a/regimes/co/party.go +++ b/regimes/co/party.go @@ -1,6 +1,7 @@ package co import ( + "github.com/invopop/gobl/cbc" "github.com/invopop/gobl/org" "github.com/invopop/gobl/tax" ) @@ -19,7 +20,7 @@ func normalizeParty(p *org.Party) { if p.Ext == nil { p.Ext = make(tax.Extensions) } - p.Ext[extKeyDIANMunicipality] = tax.ExtValue(p.TaxID.Zone) //nolint:staticcheck - p.TaxID.Zone = "" //nolint:staticcheck + p.Ext[extKeyDIANMunicipality] = cbc.Code(p.TaxID.Zone) //nolint:staticcheck + p.TaxID.Zone = "" //nolint:staticcheck } } diff --git a/regimes/common/invoice_tags.go b/regimes/common/invoice_tags.go index dacd27d4..4aaee98e 100644 --- a/regimes/common/invoice_tags.go +++ b/regimes/common/invoice_tags.go @@ -9,7 +9,7 @@ import ( var invoiceTags = &tax.TagSet{ Schema: bill.ShortSchemaInvoice, - List: []*cbc.KeyDefinition{ + List: []*cbc.Definition{ // Simplified invoices are issued when the complete fiscal details of // a customer are not available. { diff --git a/regimes/de/de.go b/regimes/de/de.go index 4722fae0..5e56ddf7 100644 --- a/regimes/de/de.go +++ b/regimes/de/de.go @@ -31,7 +31,7 @@ func New() *tax.RegimeDef { Scenarios: []*tax.ScenarioSet{ invoiceScenarios, }, - IdentityKeys: identityKeyDefinitions, // identities.go + Identities: identityDefinitions, // identities.go Corrections: []*tax.CorrectionDefinition{ { Schema: bill.ShortSchemaInvoice, diff --git a/regimes/de/identities.go b/regimes/de/identities.go index 533613a8..e68c9d64 100644 --- a/regimes/de/identities.go +++ b/regimes/de/identities.go @@ -20,7 +20,7 @@ const ( var taxNumberRegexPattern = regexp.MustCompile(`^\d{2,3}/\d{3}/\d{5}$`) -var identityKeyDefinitions = []*cbc.KeyDefinition{ +var identityDefinitions = []*cbc.Definition{ { Key: IdentityKeyTaxNumber, Name: i18n.String{ diff --git a/regimes/es/es.go b/regimes/es/es.go index 9319e29a..8adb1dcc 100644 --- a/regimes/es/es.go +++ b/regimes/es/es.go @@ -61,10 +61,10 @@ func New() *tax.RegimeDef { Tags: []*tax.TagSet{ common.InvoiceTags().Merge(invoiceTags), }, - IdentityKeys: identityKeyDefinitions, - Categories: taxCategories, - Validator: Validate, - Normalizer: Normalize, + Identities: identityDefinitions, + Categories: taxCategories, + Validator: Validate, + Normalizer: Normalize, Scenarios: []*tax.ScenarioSet{ invoiceScenarios, }, diff --git a/regimes/es/identities.go b/regimes/es/identities.go index d4f10f5c..902eaf7b 100644 --- a/regimes/es/identities.go +++ b/regimes/es/identities.go @@ -6,7 +6,7 @@ import ( "github.com/invopop/gobl/org" ) -var identityKeyDefinitions = []*cbc.KeyDefinition{ +var identityDefinitions = []*cbc.Definition{ { Key: org.IdentityKeyPassport, Name: i18n.String{ diff --git a/regimes/es/scenarios.go b/regimes/es/scenarios.go index 8dfa7294..297717c9 100644 --- a/regimes/es/scenarios.go +++ b/regimes/es/scenarios.go @@ -22,7 +22,7 @@ const ( var invoiceTags = &tax.TagSet{ Schema: bill.ShortSchemaInvoice, - List: []*cbc.KeyDefinition{ + List: []*cbc.Definition{ // Copy of the original document { Key: TagCopy, diff --git a/regimes/it/identities.go b/regimes/it/identities.go index 840778ee..ce411080 100644 --- a/regimes/it/identities.go +++ b/regimes/it/identities.go @@ -24,7 +24,7 @@ const ( // source http://blog.marketto.it/2016/01/regex-validazione-codice-fiscale-con-omocodia/ var taxIDPersonRegexPattern = regexp.MustCompile(`^(?:[A-Z][AEIOU][AEIOUX]|[AEIOU]X{2}|[B-DF-HJ-NP-TV-Z]{2}[A-Z]){2}(?:[\dLMNP-V]{2}(?:[A-EHLMPR-T](?:[04LQ][1-9MNP-V]|[15MR][\dLMNP-V]|[26NS][0-8LMNP-U])|[DHPS][37PT][0L]|[ACELMRT][37PT][01LM]|[AC-EHLMPR-T][26NS][9V])|(?:[02468LNQSU][048LQU]|[13579MPRTV][26NS])B[26NS][9V])(?:[A-MZ][1-9MNP-V][\dLMNP-V]{2}|[A-M][0L](?:[1-9MNP-V][\dLMNP-V]|[0L][1-9MNP-V]))[A-Z]$`) -var identityKeyDefinitions = []*cbc.KeyDefinition{ +var identityKeyDefinitions = []*cbc.Definition{ { Key: IdentityKeyFiscalCode, Name: i18n.String{ diff --git a/regimes/it/it.go b/regimes/it/it.go index 56a83aad..4e12c15a 100644 --- a/regimes/it/it.go +++ b/regimes/it/it.go @@ -24,9 +24,9 @@ func New() *tax.RegimeDef { i18n.EN: "Italy", i18n.IT: "Italia", }, - TimeZone: "Europe/Rome", - IdentityKeys: identityKeyDefinitions, // identities.go - Scenarios: scenarios, // scenarios.go + TimeZone: "Europe/Rome", + Identities: identityKeyDefinitions, // identities.go + Scenarios: scenarios, // scenarios.go Tags: []*tax.TagSet{ common.InvoiceTags(), }, diff --git a/regimes/mx/invoice.go b/regimes/mx/invoice.go index fc2d4925..3f1077ab 100644 --- a/regimes/mx/invoice.go +++ b/regimes/mx/invoice.go @@ -33,8 +33,8 @@ func migrateTaxIDZoneToExtPostCode(p *org.Party) { if p.Ext == nil { p.Ext = make(tax.Extensions) } - p.Ext[extKeyPostCode] = tax.ExtValue(p.TaxID.Zone) //nolint:staticcheck - p.TaxID.Zone = "" //nolint:staticcheck + p.Ext[extKeyPostCode] = cbc.Code(p.TaxID.Zone) //nolint:staticcheck + p.TaxID.Zone = "" //nolint:staticcheck } } @@ -52,7 +52,7 @@ func migrateSupplierExtPostCodeToInvoice(inv *bill.Invoice) { } else if len(inv.Supplier.Addresses) > 0 { addr := inv.Supplier.Addresses[0] if addr.Code != "" { - ext[extKeyIssuePlace] = tax.ExtValue(addr.Code) + ext[extKeyIssuePlace] = addr.Code } } if len(ext) > 0 { @@ -69,7 +69,7 @@ func migrateCustomerExtPostCodeToAddress(inv *bill.Invoice) { if len(inv.Customer.Addresses) == 0 { inv.Customer.Addresses = []*org.Address{{}} } - inv.Customer.Addresses[0].Code = inv.Customer.Ext[extKeyPostCode].Code() + inv.Customer.Addresses[0].Code = inv.Customer.Ext[extKeyPostCode] } } diff --git a/regimes/mx/invoice_test.go b/regimes/mx/invoice_test.go index 2fb3fa1e..652bf536 100644 --- a/regimes/mx/invoice_test.go +++ b/regimes/mx/invoice_test.go @@ -6,6 +6,7 @@ import ( "github.com/invopop/gobl/addons/mx/cfdi" "github.com/invopop/gobl/bill" "github.com/invopop/gobl/cal" + "github.com/invopop/gobl/cbc" "github.com/invopop/gobl/num" "github.com/invopop/gobl/org" "github.com/invopop/gobl/tax" @@ -19,7 +20,7 @@ func TestNormalizeInvoice(t *testing.T) { require.NoError(t, inv.Calculate()) require.NoError(t, inv.Validate()) require.NotNil(t, inv.Tax) - assert.Equal(t, tax.ExtValue("21000"), inv.Tax.Ext[cfdi.ExtKeyIssuePlace]) + assert.Equal(t, cbc.Code("21000"), inv.Tax.Ext[cfdi.ExtKeyIssuePlace]) assert.False(t, inv.Supplier.Ext.Has("mx-cfdi-post-code")) }) t.Run("migrate issue place from supplier ext when no tax ext", func(t *testing.T) { @@ -28,7 +29,7 @@ func TestNormalizeInvoice(t *testing.T) { require.NoError(t, inv.Calculate()) require.NoError(t, inv.Validate()) require.NotNil(t, inv.Tax) - assert.Equal(t, tax.ExtValue("22000"), inv.Tax.Ext[cfdi.ExtKeyIssuePlace]) + assert.Equal(t, cbc.Code("22000"), inv.Tax.Ext[cfdi.ExtKeyIssuePlace]) assert.False(t, inv.Supplier.Ext.Has("mx-cfdi-post-code")) }) t.Run("migrate issue place from supplier tax ID zone", func(t *testing.T) { @@ -39,7 +40,7 @@ func TestNormalizeInvoice(t *testing.T) { require.NoError(t, inv.Calculate()) require.NoError(t, inv.Validate()) require.NotNil(t, inv.Tax) - assert.Equal(t, tax.ExtValue("21000"), inv.Tax.Ext[cfdi.ExtKeyIssuePlace]) + assert.Equal(t, cbc.Code("21000"), inv.Tax.Ext[cfdi.ExtKeyIssuePlace]) assert.False(t, inv.Supplier.Ext.Has("mx-cfdi-post-code")) }) t.Run("does not migrate issue place from address when already present", func(t *testing.T) { @@ -54,7 +55,7 @@ func TestNormalizeInvoice(t *testing.T) { require.NoError(t, inv.Calculate()) require.NoError(t, inv.Validate()) require.NotNil(t, inv.Tax) - assert.Equal(t, tax.ExtValue("21000"), inv.Tax.Ext[cfdi.ExtKeyIssuePlace]) + assert.Equal(t, cbc.Code("21000"), inv.Tax.Ext[cfdi.ExtKeyIssuePlace]) }) t.Run("migrate issue place from supplier address code", func(t *testing.T) { inv := baseInvoice() @@ -69,7 +70,7 @@ func TestNormalizeInvoice(t *testing.T) { require.NoError(t, inv.Calculate()) require.NoError(t, inv.Validate()) require.NotNil(t, inv.Tax) - assert.Equal(t, tax.ExtValue("12345"), inv.Tax.Ext[cfdi.ExtKeyIssuePlace]) + assert.Equal(t, cbc.Code("12345"), inv.Tax.Ext[cfdi.ExtKeyIssuePlace]) }) t.Run("migrate customer post code from ext", func(t *testing.T) { inv := baseInvoice() diff --git a/regimes/pl/extensions.go b/regimes/pl/extensions.go index 300357b5..2ddacb66 100644 --- a/regimes/pl/extensions.go +++ b/regimes/pl/extensions.go @@ -12,16 +12,16 @@ const ( ExtKeyKSeFEffectiveDate = "pl-ksef-effective-date" ) -var extensionKeys = []*cbc.KeyDefinition{ +var extensionKeys = []*cbc.Definition{ { Key: ExtKeyKSeFVATSpecial, Name: i18n.String{ i18n.EN: "Special VAT Extensions for KSeF", i18n.PL: "Rozszerzenia specjalne dla KSeF", }, - Values: []*cbc.ValueDefinition{ + Values: []*cbc.Definition{ { - Value: "taxi", + Code: "taxi", Name: i18n.String{ i18n.EN: "Taxi Rate", i18n.PL: "Ryczałt dla taksówek", @@ -38,9 +38,9 @@ var extensionKeys = []*cbc.KeyDefinition{ Name: i18n.String{ i18n.EN: "Zero VAT Extensions for KSeF", }, - Values: []*cbc.ValueDefinition{ + Values: []*cbc.Definition{ { - Value: "wdt", + Code: "wdt", Name: i18n.String{ i18n.EN: "WDT", i18n.PL: "WDT", @@ -48,7 +48,7 @@ var extensionKeys = []*cbc.KeyDefinition{ // TODO: description required }, { - Value: "domestic", + Code: "domestic", Name: i18n.String{ i18n.EN: "Domestic", i18n.PL: "Krajowy", @@ -56,7 +56,7 @@ var extensionKeys = []*cbc.KeyDefinition{ // TODO: description required }, { - Value: "export", + Code: "export", Name: i18n.String{ i18n.EN: "Export", i18n.PL: "Eksport", @@ -71,9 +71,9 @@ var extensionKeys = []*cbc.KeyDefinition{ i18n.EN: "Effective date code.", i18n.PL: "Kod daty wejścia w życie.", }, - Values: []*cbc.ValueDefinition{ + Values: []*cbc.Definition{ { - Value: "1", + Code: "1", Name: i18n.String{ i18n.EN: "Original", i18n.PL: "Pierwotna", @@ -84,7 +84,7 @@ var extensionKeys = []*cbc.KeyDefinition{ }, }, { - Value: "2", + Code: "2", Name: i18n.String{ i18n.EN: "Correction", i18n.PL: "Korygująca", @@ -95,7 +95,7 @@ var extensionKeys = []*cbc.KeyDefinition{ }, }, { - Value: "3", + Code: "3", Name: i18n.String{ i18n.EN: "Other", i18n.PL: "Inna", diff --git a/regimes/pl/invoices_test.go b/regimes/pl/invoices_test.go index e1417a2d..1ea26fe2 100644 --- a/regimes/pl/invoices_test.go +++ b/regimes/pl/invoices_test.go @@ -5,6 +5,7 @@ import ( "github.com/invopop/gobl/bill" "github.com/invopop/gobl/cal" + "github.com/invopop/gobl/cbc" "github.com/invopop/gobl/currency" "github.com/invopop/gobl/num" "github.com/invopop/gobl/org" @@ -73,7 +74,7 @@ func TestBasicCreditNoteValidation(t *testing.T) { require.NoError(t, err) err = inv.Validate() assert.NoError(t, err) - assert.Equal(t, inv.Preceding[0].Ext[pl.ExtKeyKSeFEffectiveDate], tax.ExtValue("1")) + assert.Equal(t, inv.Preceding[0].Ext[pl.ExtKeyKSeFEffectiveDate], cbc.Code("1")) inv.Preceding[0].Ext["foo"] = "bar" err = inv.Validate() diff --git a/regimes/pl/pay.go b/regimes/pl/pay.go index 91cd6d37..c84428a7 100644 --- a/regimes/pl/pay.go +++ b/regimes/pl/pay.go @@ -15,7 +15,7 @@ const ( MeansKeyMobile cbc.Key = "mobile" ) -var paymentMeansKeyDefinitions = []*cbc.KeyDefinition{ +var paymentMeansKeyDefinitions = []*cbc.Definition{ { Key: pay.MeansKeyCash, Name: i18n.String{ diff --git a/regimes/pl/scenarios.go b/regimes/pl/scenarios.go index ab28aae8..c0656a78 100644 --- a/regimes/pl/scenarios.go +++ b/regimes/pl/scenarios.go @@ -14,7 +14,7 @@ const ( var invoiceTags = &tax.TagSet{ Schema: bill.ShortSchemaInvoice, - List: []*cbc.KeyDefinition{ + List: []*cbc.Definition{ { Key: TagSettlement, Name: i18n.String{ diff --git a/regimes/pt/extensions.go b/regimes/pt/extensions.go index 5003a12f..3b392826 100644 --- a/regimes/pt/extensions.go +++ b/regimes/pt/extensions.go @@ -10,30 +10,30 @@ const ( ExtKeyRegion = "pt-region" ) -var extensionKeys = []*cbc.KeyDefinition{ +var extensionKeys = []*cbc.Definition{ { Key: ExtKeyRegion, Name: i18n.String{ i18n.EN: "Region Code", i18n.PT: "Código da Região", }, - Values: []*cbc.ValueDefinition{ + Values: []*cbc.Definition{ { - Value: "PT", + Code: "PT", Name: i18n.String{ i18n.EN: "Mainland Portugal", i18n.PT: "Portugal Continental", }, }, { - Value: "PT-AC", + Code: "PT-AC", Name: i18n.String{ i18n.EN: "Azores", i18n.PT: "Açores", }, }, { - Value: "PT-MA", + Code: "PT-MA", Name: i18n.String{ i18n.EN: "Madeira", i18n.PT: "Madeira", diff --git a/regimes/pt/invoices.go b/regimes/pt/invoices.go index 2e1922b9..5020024f 100644 --- a/regimes/pt/invoices.go +++ b/regimes/pt/invoices.go @@ -17,7 +17,7 @@ const ( var invoiceTags = &tax.TagSet{ Schema: bill.ShortSchemaInvoice, - List: []*cbc.KeyDefinition{ + List: []*cbc.Definition{ { Key: TagInvoiceReceipt, Name: i18n.String{ diff --git a/regimes/pt/migrations.go b/regimes/pt/migrations.go index fc24b937..f30f536a 100644 --- a/regimes/pt/migrations.go +++ b/regimes/pt/migrations.go @@ -126,7 +126,7 @@ var taxRateVATExemptMigrationMap = []struct { { Key: TaxRateExempt.With(TaxRateSmallRetail), Ext: tax.Extensions{ - KeyATTaxCode: tax.ExtValue("exempt"), + KeyATTaxCode: cbc.Code("exempt"), oldExtKeyExemptionCode: "M09", }, }, @@ -145,7 +145,7 @@ var taxRateVATExemptMigrationMap = []struct { { Key: TaxRateExempt.With(TaxRateMargin).With(TaxRateTravel), Ext: tax.Extensions{ - KeyATTaxCode: tax.ExtValue("exempt"), + KeyATTaxCode: cbc.Code("exempt"), oldExtKeyExemptionCode: "M12", }, }, diff --git a/regimes/pt/migrations_test.go b/regimes/pt/migrations_test.go index 533a49bb..6048d272 100644 --- a/regimes/pt/migrations_test.go +++ b/regimes/pt/migrations_test.go @@ -4,6 +4,7 @@ import ( "testing" "github.com/invopop/gobl/addons/pt/saft" + "github.com/invopop/gobl/cbc" "github.com/invopop/gobl/tax" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -20,7 +21,7 @@ func TestTaxRateMigration(t *testing.T) { t0 := inv.Lines[0].Taxes[0] assert.Equal(t, tax.RateExempt, t0.Rate) - assert.Equal(t, tax.ExtValue("M01"), t0.Ext[saft.ExtKeyExemption]) + assert.Equal(t, cbc.Code("M01"), t0.Ext[saft.ExtKeyExemption]) // Valid new rate inv = validInvoice() @@ -32,5 +33,5 @@ func TestTaxRateMigration(t *testing.T) { t0 = inv.Lines[0].Taxes[0] assert.Equal(t, tax.RateExempt, t0.Rate) - assert.Equal(t, tax.ExtValue("M02"), t0.Ext[saft.ExtKeyExemption]) + assert.Equal(t, cbc.Code("M02"), t0.Ext[saft.ExtKeyExemption]) } diff --git a/tax/addons.go b/tax/addons.go index 521f44be..ac0651b2 100644 --- a/tax/addons.go +++ b/tax/addons.go @@ -34,7 +34,7 @@ type AddonDef struct { Description i18n.String `json:"description,omitempty" jsonschema:"title=Description"` // Extensions defines the list of extensions that are associated with an add-on. - Extensions []*cbc.KeyDefinition `json:"extensions" jsonschema:"title=Extensions"` + Extensions []*cbc.Definition `json:"extensions" jsonschema:"title=Extensions"` // Tags is slice of tag sets that define what can be assigned to each document schema. Tags []*TagSet `json:"tags,omitempty" jsonschema:"title=Tags"` @@ -46,11 +46,11 @@ type AddonDef struct { // Identities that are specific for the add-on and may be validated against or // used during conversion processes. - Identities []*cbc.KeyDefinition `json:"identities,omitempty" jsonschema:"title=Identities"` + Identities []*cbc.Definition `json:"identities,omitempty" jsonschema:"title=Identities"` // Inboxes is a list of keys that are used to identify where copies of // documents can be sent. - Inboxes []*cbc.KeyDefinition `json:"inboxes,omitempty" jsonschema:"title=Inboxes"` + Inboxes []*cbc.Definition `json:"inboxes,omitempty" jsonschema:"title=Inboxes"` // Normalizer performs the normalization rules for the add-on. Normalizer func(doc any) `json:"-"` diff --git a/tax/catalogue.go b/tax/catalogue.go index 9d561481..05393663 100644 --- a/tax/catalogue.go +++ b/tax/catalogue.go @@ -18,7 +18,7 @@ type CatalogueDef struct { // Description is a human readable description of the catalogue. Description i18n.String `json:"description"` // Extensions defines all the extensions offered by the catalogue. - Extensions []*cbc.KeyDefinition `json:"extensions"` + Extensions []*cbc.Definition `json:"extensions"` } // RegisterCatalogueDef will register the catalogue in the global list of catalogues diff --git a/tax/extensions.go b/tax/extensions.go index 9662fb91..8d64e302 100644 --- a/tax/extensions.go +++ b/tax/extensions.go @@ -33,14 +33,10 @@ import ( // examples of how to define and use extensions. // Extensions is a map of extension keys to values. -type Extensions map[cbc.Key]ExtValue - -// ExtValue is a string value that has helper methods to help determine -// if it is a code, key, or regular string. -type ExtValue string +type Extensions map[cbc.Key]cbc.Code type extensionCollection struct { - list map[cbc.Key]*cbc.KeyDefinition + list map[cbc.Key]*cbc.Definition } // extensionsDefs is a global register of all extension definitions @@ -49,23 +45,23 @@ var extensionDefs = newExtensionCollection() func newExtensionCollection() *extensionCollection { return &extensionCollection{ - list: make(map[cbc.Key]*cbc.KeyDefinition), + list: make(map[cbc.Key]*cbc.Definition), } } -func (c *extensionCollection) add(kd *cbc.KeyDefinition) { +func (c *extensionCollection) add(kd *cbc.Definition) { c.list[kd.Key] = kd } // RegisterExtension is used to add any extension definitions to the global // register. This is not expected to be called directly, but rather will // be used by the regimes and addons during their registration processes. -func RegisterExtension(kd *cbc.KeyDefinition) { +func RegisterExtension(kd *cbc.Definition) { extensionDefs.add(kd) } // ExtensionForKey returns the extension definition for the given key or nil. -func ExtensionForKey(key cbc.Key) *cbc.KeyDefinition { +func ExtensionForKey(key cbc.Key) *cbc.Definition { return extensionDefs.list[key] } @@ -90,7 +86,7 @@ func (em Extensions) Validate() error { err[ks] = errors.New("undefined") continue } - if len(kd.Values) > 0 && !kd.HasValue(ev.String()) { + if len(kd.Values) > 0 && !kd.HasCode(ev) { err[ks] = fmt.Errorf("value '%s' invalid", ev) } if kd.Pattern != "" { @@ -114,7 +110,7 @@ func (em Extensions) Validate() error { // or the extensions map is nil. If the key is composed of sub-keys and // no precise match is found, the key will be split until one of the sub // components is found. -func (em Extensions) Get(k cbc.Key) ExtValue { +func (em Extensions) Get(k cbc.Key) cbc.Code { if len(em) == 0 { return "" } @@ -189,7 +185,7 @@ func (em Extensions) Merge(other Extensions) Extensions { // Lookup returns the key for the provided value or an empty // key if not found. This is useful for reverse lookups. -func (em Extensions) Lookup(val ExtValue) cbc.Key { +func (em Extensions) Lookup(val cbc.Code) cbc.Key { for k, v := range em { if v == val { return k @@ -282,18 +278,18 @@ func (v validateExtCodeMap) Validate(value interface{}) error { return nil } -// ExtensionsHasValues returns a validation rule that ensures the extension map's -// key has one of the provided **values**. -func ExtensionsHasValues(key cbc.Key, values ...ExtValue) validation.Rule { +// ExtensionsHascodes returns a validation rule that ensures the extension map's +// key has one of the provided **codes**. +func ExtensionsHasCodes(key cbc.Key, codes ...cbc.Code) validation.Rule { return validateExtCodeValues{ key: key, - values: values, + values: codes, } } type validateExtCodeValues struct { key cbc.Key - values []ExtValue + values []cbc.Code } func (v validateExtCodeValues) Validate(value interface{}) error { @@ -332,36 +328,3 @@ func (Extensions) JSONSchemaExtend(schema *jsonschema.Schema) { cbc.KeyPattern: prop, } } - -// String provides the string representation. -func (ev ExtValue) String() string { - return string(ev) -} - -// In returns true if the value is in the provided list. -func (ev ExtValue) In(values ...ExtValue) bool { - for _, v := range values { - if ev == v { - return true - } - } - return false -} - -// Key returns the key value or empty if the value is a Code. -func (ev ExtValue) Key() cbc.Key { - k := cbc.Key(ev) - if err := k.Validate(); err == nil { - return k - } - return cbc.KeyEmpty -} - -// Code returns the code value or empty if the value is a Key. -func (ev ExtValue) Code() cbc.Code { - c := cbc.Code(ev) - if err := c.Validate(); err == nil { - return c - } - return cbc.CodeEmpty -} diff --git a/tax/extensions_test.go b/tax/extensions_test.go index 57208f09..884cf021 100644 --- a/tax/extensions_test.go +++ b/tax/extensions_test.go @@ -36,23 +36,6 @@ func TestCleanExtensions(t *testing.T) { assert.Equal(t, "foo", em2["key"].String()) } -func TestExtValue(t *testing.T) { - ev := tax.ExtValue("IT") - assert.Equal(t, "IT", ev.String()) - assert.Equal(t, cbc.Code("IT"), ev.Code()) - assert.Equal(t, cbc.KeyEmpty, ev.Key()) - - ev = tax.ExtValue("testing") - assert.Equal(t, "testing", ev.String()) - assert.Equal(t, cbc.Key("testing"), ev.Key()) - assert.Equal(t, cbc.Code("testing"), ev.Code()) - - ev = tax.ExtValue("A $tring") - assert.Equal(t, cbc.CodeEmpty, ev.Code()) - assert.Equal(t, cbc.KeyEmpty, ev.Key()) - assert.Equal(t, "A $tring", ev.String()) -} - func TestExtValidation(t *testing.T) { t.Run("with mexico", func(t *testing.T) { t.Run("test patterns", func(t *testing.T) { @@ -267,14 +250,14 @@ func TestExtensionsExcludeValidation(t *testing.T) { func TestExtensionsHasValues(t *testing.T) { t.Run("nil", func(t *testing.T) { err := validation.Validate(nil, - tax.ExtensionsHasValues(untdid.ExtKeyDocumentType, "326", "389"), + tax.ExtensionsHasCodes(untdid.ExtKeyDocumentType, "326", "389"), ) assert.NoError(t, err) }) t.Run("empty", func(t *testing.T) { em := tax.Extensions{} err := validation.Validate(em, - tax.ExtensionsHasValues(untdid.ExtKeyDocumentType, "326", "389"), + tax.ExtensionsHasCodes(untdid.ExtKeyDocumentType, "326", "389"), ) assert.NoError(t, err) }) @@ -283,7 +266,7 @@ func TestExtensionsHasValues(t *testing.T) { iso.ExtKeySchemeID: "1234", } err := validation.Validate(em, - tax.ExtensionsHasValues(untdid.ExtKeyDocumentType, "326", "389"), + tax.ExtensionsHasCodes(untdid.ExtKeyDocumentType, "326", "389"), ) assert.NoError(t, err) }) @@ -292,7 +275,7 @@ func TestExtensionsHasValues(t *testing.T) { untdid.ExtKeyDocumentType: "326", } err := validation.Validate(em, - tax.ExtensionsHasValues(untdid.ExtKeyDocumentType, "326", "389"), + tax.ExtensionsHasCodes(untdid.ExtKeyDocumentType, "326", "389"), ) assert.NoError(t, err) }) @@ -301,7 +284,7 @@ func TestExtensionsHasValues(t *testing.T) { untdid.ExtKeyDocumentType: "102", } err := validation.Validate(em, - tax.ExtensionsHasValues(untdid.ExtKeyDocumentType, "326", "389"), + tax.ExtensionsHasCodes(untdid.ExtKeyDocumentType, "326", "389"), ) assert.ErrorContains(t, err, "untdid-document-type: invalid value") }) @@ -508,9 +491,3 @@ func TestExtensionGet(t *testing.T) { assert.Equal(t, "value", em.Get("key+foo").String()) }) } - -func TestExtValueIn(t *testing.T) { - ev := tax.ExtValue("IT") - assert.True(t, ev.In("IT", "ES")) - assert.False(t, ev.In("ES", "FR")) -} diff --git a/tax/regime_def.go b/tax/regime_def.go index beb7374e..5b43c344 100644 --- a/tax/regime_def.go +++ b/tax/regime_def.go @@ -60,19 +60,19 @@ type RegimeDef struct { // Extensions defines the keys that can be used for extended or extra data inside the regime that // is specific to the regime and cannot be easily determined from other GOBL structures. // Typically these are used to define local codes for suppliers, customers, products, or tax rates. - Extensions []*cbc.KeyDefinition `json:"extensions,omitempty" jsonschema:"title=Extensions"` + Extensions []*cbc.Definition `json:"extensions,omitempty" jsonschema:"title=Extensions"` - // Identity keys used in addition to regular tax identities and specific for the + // Identities used in addition to regular tax identities and specific for the // regime that may be validated against. - IdentityKeys []*cbc.KeyDefinition `json:"identity_keys,omitempty" jsonschema:"title=Identity Keys"` + Identities []*cbc.Definition `json:"identities,omitempty" jsonschema:"title=Identities"` // PaymentMeansKeys specific for the regime that extend the original // base payment means keys. - PaymentMeansKeys []*cbc.KeyDefinition `json:"payment_means_keys,omitempty" jsonschema:"title=Payment Means Keys"` + PaymentMeansKeys []*cbc.Definition `json:"payment_means_keys,omitempty" jsonschema:"title=Payment Means Keys"` // InboxKeys specific to the regime that can be used to identify where a document // should be forwarded to. - InboxKeys []*cbc.KeyDefinition `json:"inbox_keys,omitempty" jsonschema:"title=Inbox Keys"` + InboxKeys []*cbc.Definition `json:"inbox_keys,omitempty" jsonschema:"title=Inbox Keys"` Scenarios []*ScenarioSet `json:"scenarios,omitempty" jsonschema:"title=Scenarios"` @@ -276,7 +276,7 @@ func (r *RegimeDef) ValidateWithContext(ctx context.Context) error { validation.Field(&r.Zone), validation.Field(&r.Currency), validation.Field(&r.Tags), - validation.Field(&r.IdentityKeys), + validation.Field(&r.Identities), validation.Field(&r.Extensions), validation.Field(&r.PaymentMeansKeys), validation.Field(&r.InboxKeys), @@ -453,7 +453,7 @@ func (r *RegimeDef) RateDef(cat cbc.Code, key cbc.Key) *RateDef { } // ExtensionDef provides the extension definition with a matching key. -func (r *RegimeDef) ExtensionDef(key cbc.Key) *cbc.KeyDefinition { +func (r *RegimeDef) ExtensionDef(key cbc.Key) *cbc.Definition { for _, e := range r.Extensions { if e.Key == key { return e diff --git a/tax/scenario.go b/tax/scenario.go index 2d80ebdf..b9f68e6d 100644 --- a/tax/scenario.go +++ b/tax/scenario.go @@ -49,10 +49,10 @@ type Scenario struct { // Extension key that must be present in the document. ExtKey cbc.Key `json:"ext_key,omitempty" jsonschema:"title=Extension Key"` - // Extension value that along side the key must be present for a match - // to happen. This cannot be used without an `ExtKey`. The value will + // Extension code that along side the key must be present for a match + // to happen. This cannot be used without an `cbc.Code`. The value will // be copied to the note code if needed. - ExtValue ExtValue `json:"ext_value,omitempty" jsonschema:"title=Extension Value"` + ExtCode cbc.Code `json:"ext_code,omitempty" jsonschema:"title=Extension Code"` // Filter defines a custom filter method for when the regular basic filters // are not sufficient. @@ -144,7 +144,7 @@ func (ss *ScenarioSet) SummaryFor(doc ScenarioDocument) *ScenarioSummary { for _, s := range ss.List { if s.match(doc) { if s.Note != nil { - summary.addNote(s.Note.WithCode(s.ExtValue.String())) + summary.addNote(s.Note.WithCode(s.ExtCode)) } for k, v := range s.Codes { summary.Codes[k] = v @@ -192,8 +192,8 @@ func (s *Scenario) match(doc ScenarioDocument) bool { if !ok { continue // try next extension } - if s.ExtValue != "" { - if v == s.ExtValue { + if s.ExtCode != "" { + if v == s.ExtCode { return true } } else { diff --git a/tax/scenario_test.go b/tax/scenario_test.go index 6fd106a9..70844fc6 100644 --- a/tax/scenario_test.go +++ b/tax/scenario_test.go @@ -75,9 +75,9 @@ func TestScenarioSetSummary(t *testing.T) { }, }, { - Types: []cbc.Key{bill.InvoiceTypeStandard}, - ExtKey: "yy-test", - ExtValue: "BAR", + Types: []cbc.Key{bill.InvoiceTypeStandard}, + ExtKey: "yy-test", + ExtCode: "BAR", Note: &cbc.Note{ Key: cbc.NoteKeyLegal, Code: "note2", diff --git a/tax/tags.go b/tax/tags.go index 0eb10958..ab3356dc 100644 --- a/tax/tags.go +++ b/tax/tags.go @@ -26,7 +26,7 @@ type TagSet struct { Schema string `json:"schema" jsonschema:"title=Schema"` // List of tags for the schema - List []*cbc.KeyDefinition `json:"list" jsonschema:"title=List"` + List []*cbc.Definition `json:"list" jsonschema:"title=List"` } // TagSetForSchema will return the tag set for the provided schema, or nil if it does not exist. diff --git a/tax/tags_test.go b/tax/tags_test.go index 76c6d013..fd73a6fc 100644 --- a/tax/tags_test.go +++ b/tax/tags_test.go @@ -12,7 +12,7 @@ import ( func TestTagSetMerge(t *testing.T) { ts1 := &tax.TagSet{ Schema: "bill/invoice", - List: []*cbc.KeyDefinition{ + List: []*cbc.Definition{ { Key: "test1", Name: i18n.String{ @@ -23,7 +23,7 @@ func TestTagSetMerge(t *testing.T) { } ts2 := &tax.TagSet{ Schema: "bill/invoice", - List: []*cbc.KeyDefinition{ + List: []*cbc.Definition{ { Key: "test1", Name: i18n.String{ @@ -49,7 +49,7 @@ func TestTagSetMerge(t *testing.T) { ts4 := &tax.TagSet{ Schema: "note/message", - List: []*cbc.KeyDefinition{ + List: []*cbc.Definition{ { Key: "test3", Name: i18n.String{ @@ -71,7 +71,7 @@ func TestTagSetMerge(t *testing.T) { func TestTaxSetKeys(t *testing.T) { ts1 := &tax.TagSet{ Schema: "bill/invoice", - List: []*cbc.KeyDefinition{ + List: []*cbc.Definition{ { Key: "test1", Name: i18n.String{ From f435472170c6c2c8971fc7bff64afa5abf654062 Mon Sep 17 00:00:00 2001 From: Sam Lown Date: Thu, 5 Dec 2024 21:31:11 +0000 Subject: [PATCH 2/5] Improving a bit of test coverage --- addons/mx/cfdi/item.go | 4 +-- addons/mx/cfdi/item_test.go | 9 +++++ addons/mx/cfdi/party.go | 3 +- addons/mx/cfdi/party_test.go | 7 +++- addons/mx/cfdi/pay.go | 20 +++++------ addons/mx/cfdi/pay_test.go | 67 ++++++++++++++++++++++++++++++++++++ tax/extensions.go | 2 +- 7 files changed, 94 insertions(+), 18 deletions(-) create mode 100644 addons/mx/cfdi/pay_test.go diff --git a/addons/mx/cfdi/item.go b/addons/mx/cfdi/item.go index d47231ef..61d4af81 100644 --- a/addons/mx/cfdi/item.go +++ b/addons/mx/cfdi/item.go @@ -30,11 +30,11 @@ func validateItem(value any) error { } func validItemExtensions(value interface{}) error { - ids, ok := value.(tax.Extensions) + ext, ok := value.(tax.Extensions) if !ok { return nil } - for k, v := range ids { + for k, v := range ext { if k == ExtKeyProdServ { if itemExtensionValidCodeRegexp.MatchString(string(v)) { return nil diff --git a/addons/mx/cfdi/item_test.go b/addons/mx/cfdi/item_test.go index e8930d9c..fac74ad7 100644 --- a/addons/mx/cfdi/item_test.go +++ b/addons/mx/cfdi/item_test.go @@ -55,6 +55,10 @@ func TestItemValidation(t *testing.T) { }, err: "ext: (mx-cfdi-prod-serv: must have 8 digits.)", }, + { + name: "nil", + item: nil, + }, } addon := tax.AddonForKey(cfdi.V4) @@ -114,9 +118,14 @@ func TestItemIdentityMigration(t *testing.T) { Key: cfdi.ExtKeyProdServ, Code: "01010101", }, + { + Key: "other", + Code: "1234", + }, } err := inv.Calculate() require.NoError(t, err) assert.Equal(t, cbc.Code("01010101"), inv.Lines[0].Item.Ext[cfdi.ExtKeyProdServ]) + assert.Equal(t, "1234", inv.Lines[0].Item.Identities[0].Code.String()) } diff --git a/addons/mx/cfdi/party.go b/addons/mx/cfdi/party.go index 42964bc0..abd03eac 100644 --- a/addons/mx/cfdi/party.go +++ b/addons/mx/cfdi/party.go @@ -1,7 +1,6 @@ package cfdi import ( - "github.com/invopop/gobl/cbc" "github.com/invopop/gobl/org" "github.com/invopop/gobl/tax" ) @@ -18,7 +17,7 @@ func normalizeParty(p *org.Party) { if p.Ext == nil { p.Ext = make(tax.Extensions) } - p.Ext[v.Key] = cbc.Code(v.Code) + p.Ext[v.Key] = v.Code } else { idents = append(idents, v) } diff --git a/addons/mx/cfdi/party_test.go b/addons/mx/cfdi/party_test.go index 1b50cc12..b5fec652 100644 --- a/addons/mx/cfdi/party_test.go +++ b/addons/mx/cfdi/party_test.go @@ -21,14 +21,19 @@ func TestMigratePartyIdentities(t *testing.T) { Key: cfdi.ExtKeyUse, Code: "G01", }, + { + Key: "random", + Code: "12345678", + }, }, } addon := tax.AddonForKey(cfdi.V4) addon.Normalizer(customer) - assert.Empty(t, customer.Identities) + assert.Len(t, customer.Identities, 1) assert.Len(t, customer.Ext, 2) assert.Equal(t, "608", customer.Ext[cfdi.ExtKeyFiscalRegime].String()) assert.Equal(t, "G01", customer.Ext[cfdi.ExtKeyUse].String()) + assert.Equal(t, "12345678", customer.Identities[0].Code.String()) } diff --git a/addons/mx/cfdi/pay.go b/addons/mx/cfdi/pay.go index 618988d1..aa777fd1 100644 --- a/addons/mx/cfdi/pay.go +++ b/addons/mx/cfdi/pay.go @@ -60,12 +60,10 @@ func normalizePayInstructions(instr *pay.Instructions) { if instr == nil { return } - extVal := paymentMeansKeyMap[instr.Key] - if extVal != "" { - if instr.Ext == nil { - instr.Ext = make(tax.Extensions) - } - instr.Ext[ExtKeyPaymentMeans] = extVal + if code := paymentMeansKeyMap[instr.Key]; code != "" { + instr.Ext = instr.Ext.Merge(tax.Extensions{ + ExtKeyPaymentMeans: code, + }) } } @@ -73,12 +71,10 @@ func normalizePayAdvance(adv *pay.Advance) { if adv == nil { return } - extVal := paymentMeansKeyMap[adv.Key] - if extVal != "" { - if adv.Ext == nil { - adv.Ext = make(tax.Extensions) - } - adv.Ext[ExtKeyPaymentMeans] = extVal + if code := paymentMeansKeyMap[adv.Key]; code != "" { + adv.Ext = adv.Ext.Merge(tax.Extensions{ + ExtKeyPaymentMeans: code, + }) } } diff --git a/addons/mx/cfdi/pay_test.go b/addons/mx/cfdi/pay_test.go new file mode 100644 index 00000000..a2a38a37 --- /dev/null +++ b/addons/mx/cfdi/pay_test.go @@ -0,0 +1,67 @@ +package cfdi_test + +import ( + "testing" + + "github.com/invopop/gobl/addons/mx/cfdi" + "github.com/invopop/gobl/pay" + "github.com/invopop/gobl/tax" + "github.com/stretchr/testify/assert" +) + +func TestPaymentMeansExtensions(t *testing.T) { + ext := cfdi.PaymentMeansExtensions() + assert.Equal(t, "01", ext.Get(pay.MeansKeyCash).String()) +} + +func TestNormalizePayInstructions(t *testing.T) { + ad := tax.AddonForKey(cfdi.V4) + + t.Run("nil", func(t *testing.T) { + var instr *pay.Instructions + ad.Normalizer(instr) + }) + + t.Run("with match", func(t *testing.T) { + instr := &pay.Instructions{ + Key: pay.MeansKeyOnline.With(cfdi.MeansKeyWallet), + } + ad.Normalizer(instr) + assert.Equal(t, "05", instr.Ext.Get(cfdi.ExtKeyPaymentMeans).String()) + }) +} + +func TestNormalizePayAdvance(t *testing.T) { + ad := tax.AddonForKey(cfdi.V4) + + t.Run("nil", func(t *testing.T) { + var adv *pay.Advance + ad.Normalizer(adv) + }) + + t.Run("with match", func(t *testing.T) { + adv := &pay.Advance{ + Key: pay.MeansKeyOnline.With(cfdi.MeansKeyWallet), + } + ad.Normalizer(adv) + assert.Equal(t, "05", adv.Ext.Get(cfdi.ExtKeyPaymentMeans).String()) + }) +} + +func TestValidatePayTerms(t *testing.T) { + ad := tax.AddonForKey(cfdi.V4) + + t.Run("nil", func(t *testing.T) { + var terms *pay.Terms + ad.Validator(terms) + }) + + t.Run("valid", func(t *testing.T) { + terms := &pay.Terms{ + Key: pay.MeansKeyOnline.With(cfdi.MeansKeyWallet), + Notes: "test", + } + err := ad.Validator(terms) + assert.NoError(t, err) + }) +} diff --git a/tax/extensions.go b/tax/extensions.go index 8d64e302..2889573c 100644 --- a/tax/extensions.go +++ b/tax/extensions.go @@ -278,7 +278,7 @@ func (v validateExtCodeMap) Validate(value interface{}) error { return nil } -// ExtensionsHascodes returns a validation rule that ensures the extension map's +// ExtensionsHasCodes returns a validation rule that ensures the extension map's // key has one of the provided **codes**. func ExtensionsHasCodes(key cbc.Key, codes ...cbc.Code) validation.Rule { return validateExtCodeValues{ From 4d46676bbc5f34eeec6fa8557194d2d8d84010c1 Mon Sep 17 00:00:00 2001 From: Sam Lown Date: Thu, 5 Dec 2024 21:36:46 +0000 Subject: [PATCH 3/5] Changelog and a bit more test coverage --- CHANGELOG.md | 2 ++ bill/invoice_convert_test.go | 18 +++++++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c56bbfc6..0e6dcf57 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p ### Changed - `tax`: renamed `ExtensionsRequires` to `ExtensionsRequire`, to bring in line with `ExtensionsExclude`. +- `cbc`: refactored `KeyDefinition` and `ValueDefinition` into a single `Definition` object that supports `key` and `code`. +- `tax`: removed `ExtValue` and replaced with `cbc.Code` which is now much more flexible. ### Fixed diff --git a/bill/invoice_convert_test.go b/bill/invoice_convert_test.go index 5c502a85..bc9e4694 100644 --- a/bill/invoice_convert_test.go +++ b/bill/invoice_convert_test.go @@ -148,6 +148,18 @@ func TestInvoiceConvertInto(t *testing.T) { }, }, }, + Charges: []*bill.Charge{ + { + Reason: "Testing Charge", + Amount: num.MakeAmount(5000, 2), + }, + }, + Discounts: []*bill.Discount{ + { + Reason: "Testing", + Amount: num.MakeAmount(100, 2), + }, + }, Payment: &bill.Payment{ Advances: []*pay.Advance{ { @@ -160,9 +172,9 @@ func TestInvoiceConvertInto(t *testing.T) { i2, err := i.ConvertInto(currency.USD) assert.NoError(t, err) require.NotNil(t, i2) - assert.Equal(t, "643.72", i2.Payment.Advances[0].Amount.String()) + assert.Equal(t, "671.16", i2.Payment.Advances[0].Amount.String()) assert.Equal(t, "1064.00", i2.Totals.Sum.String()) - assert.Equal(t, "1287.44", i2.Totals.Payable.String()) - assert.Equal(t, "643.72", i2.Totals.Due.String()) + assert.Equal(t, "1342.32", i2.Totals.Payable.String()) + assert.Equal(t, "671.16", i2.Totals.Due.String()) }) } From c9780d2e1caf6893fd15c805b829eb3e1921b162 Mon Sep 17 00:00:00 2001 From: Sam Lown Date: Thu, 5 Dec 2024 21:55:14 +0000 Subject: [PATCH 4/5] adding missing Definition tests --- cbc/definition.go | 10 ++-- cbc/definition_test.go | 107 ++++++++++++++++++++++++++++++++++++++--- 2 files changed, 106 insertions(+), 11 deletions(-) diff --git a/cbc/definition.go b/cbc/definition.go index c672e8de..46c2197f 100644 --- a/cbc/definition.go +++ b/cbc/definition.go @@ -97,7 +97,9 @@ func (d *Definition) KeyDef(key Key) *Definition { func DefinitionKeys(list []*Definition) []Key { keys := make([]Key, 0, len(list)) for _, item := range list { - keys = append(keys, item.Key) + if item.Key != KeyEmpty { + keys = append(keys, item.Key) + } } return keys } @@ -106,7 +108,9 @@ func DefinitionKeys(list []*Definition) []Key { func DefinitionCodes(list []*Definition) []Code { codes := make([]Code, 0, len(list)) for _, item := range list { - codes = append(codes, item.Code) + if item.Code != CodeEmpty { + codes = append(codes, item.Code) + } } return codes } @@ -146,7 +150,7 @@ func InKeyDefs(list []*Definition) validation.Rule { func InCodeDefs(list []*Definition) validation.Rule { defs := make([]interface{}, len(list)) for i, item := range list { - defs[i] = item.Key + defs[i] = item.Code } return validation.In(defs...) } diff --git a/cbc/definition_test.go b/cbc/definition_test.go index 294d66af..86bdd843 100644 --- a/cbc/definition_test.go +++ b/cbc/definition_test.go @@ -5,10 +5,34 @@ import ( "github.com/invopop/gobl/cbc" "github.com/invopop/gobl/i18n" + "github.com/invopop/validation" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) +func TestDefinitionValidation(t *testing.T) { + t.Run("check pattern", func(t *testing.T) { + kd := &cbc.Definition{ + Key: "key", + Name: i18n.String{ + i18n.EN: "Name", + i18n.ES: "Nombre", + }, + Pattern: "^[0-9]{3}$", + } + err := kd.Validate() + assert.NoError(t, err) + + kd.Pattern = "" + err = kd.Validate() + assert.NoError(t, err) + + kd.Pattern = "[foo][" + err = kd.Validate() + assert.ErrorContains(t, err, "pattern: error parsing regexp: missing closing ]: `[`") + }) +} + func TestDefinitionsWithValues(t *testing.T) { kd := &cbc.Definition{ Key: "key", @@ -22,19 +46,86 @@ func TestDefinitionsWithValues(t *testing.T) { }, Values: []*cbc.Definition{ { - Code: "value", + Code: "CODE1", + Name: i18n.String{ + i18n.EN: "Code 1", + i18n.ES: "Código 1", + }, + }, + { + Code: "CODE2", + Name: i18n.String{ + i18n.EN: "Code 2", + i18n.ES: "Código 2", + }, + }, + { + Key: "key1", + Name: i18n.String{ + i18n.EN: "Key 1", + i18n.ES: "Clave 1", + }, + }, + { + Key: "key2", Name: i18n.String{ - i18n.EN: "Value", - i18n.ES: "Valor", + i18n.EN: "Key 2", + i18n.ES: "Clave 2", }, }, }, } - assert.True(t, kd.HasCode("value")) - assert.False(t, kd.HasCode("invalid")) - vd := kd.CodeDef("value") - require.NotNil(t, vd) - assert.Equal(t, "Value", vd.Name[i18n.EN]) + t.Run("for codes", func(t *testing.T) { + assert.True(t, kd.HasCode("CODE1")) + assert.False(t, kd.HasCode("INV")) + vd := kd.CodeDef("CODE1") + require.NotNil(t, vd) + assert.Equal(t, "Code 1", vd.Name[i18n.EN]) + + codes := cbc.DefinitionCodes(kd.Values) + assert.Len(t, codes, 2) + assert.Contains(t, codes, cbc.Code("CODE1")) + assert.Contains(t, codes, cbc.Code("CODE2")) + + cdn := cbc.GetCodeDefinition("FOO", kd.Values) + assert.Nil(t, cdn) + + cd := cbc.GetCodeDefinition("CODE2", kd.Values) + require.NotNil(t, cd) + assert.Equal(t, "Code 2", cd.Name[i18n.EN]) + + err := validation.Validate(cbc.Code("CODE1"), cbc.InCodeDefs(kd.Values)) + assert.NoError(t, err) + + err = validation.Validate(cbc.Code("INV"), cbc.InCodeDefs(kd.Values)) + assert.ErrorContains(t, err, "must be a valid value") + + }) + t.Run("for keys", func(t *testing.T) { + assert.True(t, kd.HasKey("key1")) + assert.False(t, kd.HasKey("bad")) + vd := kd.KeyDef("key1") + require.NotNil(t, vd) + assert.Equal(t, "Key 1", vd.Name[i18n.EN]) + + keys := cbc.DefinitionKeys(kd.Values) + assert.Len(t, keys, 2) + assert.Contains(t, keys, cbc.Key("key1")) + assert.Contains(t, keys, cbc.Key("key2")) + + kdn := cbc.GetKeyDefinition("bad", kd.Values) + assert.Nil(t, kdn) + + kdn = cbc.GetKeyDefinition("key2", kd.Values) + require.NotNil(t, kdn) + assert.Equal(t, "Key 2", kdn.Name[i18n.EN]) + + err := validation.Validate(cbc.Key("key1"), cbc.InKeyDefs(kd.Values)) + assert.NoError(t, err) + + err = validation.Validate(cbc.Key("bad"), cbc.InCodeDefs(kd.Values)) + assert.ErrorContains(t, err, "must be a valid value") + }) } func TestDefinitionWithPattern(t *testing.T) { From 98f196f985376fe28b265f94eeb552363adb2666 Mon Sep 17 00:00:00 2001 From: Sam Lown Date: Fri, 6 Dec 2024 21:44:30 +0000 Subject: [PATCH 5/5] Fixing linter issues --- addons/mx/cfdi/pay_test.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/addons/mx/cfdi/pay_test.go b/addons/mx/cfdi/pay_test.go index a2a38a37..ade7cab9 100644 --- a/addons/mx/cfdi/pay_test.go +++ b/addons/mx/cfdi/pay_test.go @@ -19,7 +19,9 @@ func TestNormalizePayInstructions(t *testing.T) { t.Run("nil", func(t *testing.T) { var instr *pay.Instructions - ad.Normalizer(instr) + assert.NotPanics(t, func() { + ad.Normalizer(instr) + }) }) t.Run("with match", func(t *testing.T) { @@ -36,7 +38,9 @@ func TestNormalizePayAdvance(t *testing.T) { t.Run("nil", func(t *testing.T) { var adv *pay.Advance - ad.Normalizer(adv) + assert.NotPanics(t, func() { + ad.Normalizer(adv) + }) }) t.Run("with match", func(t *testing.T) { @@ -53,7 +57,9 @@ func TestValidatePayTerms(t *testing.T) { t.Run("nil", func(t *testing.T) { var terms *pay.Terms - ad.Validator(terms) + assert.NotPanics(t, func() { + assert.NoError(t, ad.Validator(terms)) + }) }) t.Run("valid", func(t *testing.T) {