Skip to content

Commit

Permalink
Updating schemas and fixing lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
samlown committed Dec 5, 2023
1 parent 786ed2d commit 94e18e1
Show file tree
Hide file tree
Showing 13 changed files with 75 additions and 29 deletions.
2 changes: 2 additions & 0 deletions cbc/key_or_code.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ func (kc KeyOrCode) Validate() error {
return errors.New("value is not a key or code")
}

// JSONSchemaExtend adds to the json schema definition of the
// KeyOrCode type to ensure both key and code patterns are present.
func (KeyOrCode) JSONSchemaExtend(schema *jsonschema.Schema) {
schema.OneOf = []*jsonschema.Schema{
KeyEmpty.JSONSchema(),
Expand Down
2 changes: 1 addition & 1 deletion data/schemas/org/item.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"description": "Country code of where this item was from originally."
},
"ext": {
"$ref": "https://gobl.org/draft-0/cbc/code-map",
"$ref": "https://gobl.org/draft-0/tax/ext-map",
"title": "Ext",
"description": "Extension code map for any additional regime specific codes that may be required."
},
Expand Down
2 changes: 1 addition & 1 deletion data/schemas/org/party.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
"description": "Images that can be used to identify the party visually."
},
"ext": {
"$ref": "https://gobl.org/draft-0/cbc/code-map",
"$ref": "https://gobl.org/draft-0/tax/ext-map",
"title": "Ext",
"description": "Extension code map for any additional regime specific codes that may be required."
},
Expand Down
35 changes: 35 additions & 0 deletions data/schemas/tax/ext-map.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://gobl.org/draft-0/tax/ext-map",
"$ref": "#/$defs/ExtMap",
"$defs": {
"ExtMap": {
"patternProperties": {
"^(?:[a-z]|[a-z0-9][a-z0-9-+]*[a-z0-9])$": {
"oneOf": [
{
"type": "string",
"maxLength": 64,
"minLength": 1,
"pattern": "^(?:[a-z]|[a-z0-9][a-z0-9-+]*[a-z0-9])$",
"title": "Key",
"description": "Text identifier to be used instead of a code for a more verbose but readable identifier."
},
{
"type": "string",
"maxLength": 24,
"minLength": 1,
"pattern": "^[A-Z0-9]+(\\.?[A-Z0-9]+)*$",
"title": "Code",
"description": "Alphanumerical text identifier with upper-case letters, no whitespace, nor symbols."
}
],
"type": "string"
}
},
"type": "object",
"description": "ExtMap is a map of extension keys to either a code or a key."
}
},
"$comment": "Generated with GOBL v0.64.0"
}
11 changes: 9 additions & 2 deletions data/schemas/tax/regime.json
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,14 @@
"title": "Codes",
"description": "Codes describes the list of codes that can be used alongside the Key,\nfor example with identities."
},
"keys": {
"items": {
"$ref": "#/$defs/KeyDefinition"
},
"type": "array",
"title": "Keys",
"description": "Keys is used instead of codes to define a further sub-set of keys that\ncan be used alongside this one."
},
"map": {
"$ref": "https://gobl.org/draft-0/cbc/code-map",
"title": "Map",
Expand Down Expand Up @@ -376,8 +384,7 @@
"$ref": "#/$defs/ScenarioSet"
},
"type": "array",
"title": "Scenarios",
"description": "Sets of scenario definitions for the regime."
"title": "Scenarios"
},
"corrections": {
"items": {
Expand Down
2 changes: 1 addition & 1 deletion data/schemas/tax/set.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"calculated": true
},
"ext": {
"$ref": "https://gobl.org/draft-0/cbc/code-map",
"$ref": "https://gobl.org/draft-0/tax/ext-map",
"title": "Ext",
"description": "Local codes that apply for a given rate or percentage that need to be identified and validated."
}
Expand Down
2 changes: 1 addition & 1 deletion data/schemas/tax/total.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"description": "Optional rate key is required when grouping."
},
"ext": {
"$ref": "https://gobl.org/draft-0/cbc/code-map",
"$ref": "https://gobl.org/draft-0/tax/ext-map",
"title": "Ext",
"description": "If the rate is defined with extensions, they'll be used to group by also."
},
Expand Down
7 changes: 7 additions & 0 deletions regimes/pl/extensions.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ var extensionKeys = []*tax.KeyDefinition{
i18n.EN: "Taxi Rate",
i18n.PL: "Ryczałt dla taksówek",
},
Desc: i18n.String{
i18n.EN: "Special flat rate for taxi drivers.",
i18n.PL: "Specjalna stawka ryczałtu dla taksówkarzy.",
},
},
},
},
Expand All @@ -40,20 +44,23 @@ var extensionKeys = []*tax.KeyDefinition{
i18n.EN: "WDT",
i18n.PL: "WDT",
},
// TODO: description required
},
{
Key: "domestic",
Name: i18n.String{
i18n.EN: "Domestic",
i18n.PL: "Krajowy",
},
// TODO: description required
},
{
Key: "export",
Name: i18n.String{
i18n.EN: "Export",
i18n.PL: "Eksport",
},
// TODO: description required
},
},
},
Expand Down
14 changes: 7 additions & 7 deletions regimes/pl/pay.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ var paymentMeansKeyDefinitions = []*tax.KeyDefinition{
i18n.PL: "Gotówka",
},
Map: cbc.CodeMap{
KeyFA_VATPaymentType: "1",
KeyFAVATPaymentType: "1",
},
},
{
Expand All @@ -34,7 +34,7 @@ var paymentMeansKeyDefinitions = []*tax.KeyDefinition{
i18n.PL: "Karta",
},
Map: cbc.CodeMap{
KeyFA_VATPaymentType: "2",
KeyFAVATPaymentType: "2",
},
},
{
Expand All @@ -44,7 +44,7 @@ var paymentMeansKeyDefinitions = []*tax.KeyDefinition{
i18n.PL: "Bon",
},
Map: cbc.CodeMap{
KeyFA_VATPaymentType: "3",
KeyFAVATPaymentType: "3",
},
},
{
Expand All @@ -54,7 +54,7 @@ var paymentMeansKeyDefinitions = []*tax.KeyDefinition{
i18n.PL: "Czek",
},
Map: cbc.CodeMap{
KeyFA_VATPaymentType: "4",
KeyFAVATPaymentType: "4",
},
},
{
Expand All @@ -64,7 +64,7 @@ var paymentMeansKeyDefinitions = []*tax.KeyDefinition{
i18n.PL: "Kredyt",
},
Map: cbc.CodeMap{
KeyFA_VATPaymentType: "5",
KeyFAVATPaymentType: "5",
},
},
{
Expand All @@ -74,7 +74,7 @@ var paymentMeansKeyDefinitions = []*tax.KeyDefinition{
i18n.PL: "Przelew",
},
Map: cbc.CodeMap{
KeyFA_VATPaymentType: "6",
KeyFAVATPaymentType: "6",
},
},
{
Expand All @@ -84,7 +84,7 @@ var paymentMeansKeyDefinitions = []*tax.KeyDefinition{
i18n.PL: "Mobilna",
},
Map: cbc.CodeMap{
KeyFA_VATPaymentType: "7",
KeyFAVATPaymentType: "7",
},
},
}
6 changes: 3 additions & 3 deletions regimes/pl/pl.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Package it provides the Polish tax regime.
// Package pl provides the Polish tax regime.
package pl

import (
Expand All @@ -16,8 +16,8 @@ func init() {

// Custom keys used typically in meta or codes information.
const (
KeyFA_VATPaymentType cbc.Key = "favat-forma-platnosci" // for mapping to TFormaPlatnosci's codes
KeyFA_VATInvoiceType cbc.Key = "favat-rodzaj-faktury" // for mapping to TRodzajFaktury's codes
KeyFAVATPaymentType cbc.Key = "favat-forma-platnosci" // for mapping to TFormaPlatnosci's codes
KeyFAVATInvoiceType cbc.Key = "favat-rodzaj-faktury" // for mapping to TRodzajFaktury's codes
)

// New instantiates a new Polish regime.
Expand Down
14 changes: 7 additions & 7 deletions regimes/pl/scenarios.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ var invoiceScenarios = &tax.ScenarioSet{
i18n.PL: "Faktura Podstawowa",
},
Codes: cbc.CodeMap{
KeyFA_VATInvoiceType: "VAT",
KeyFAVATInvoiceType: "VAT",
},
},
{
Expand All @@ -49,7 +49,7 @@ var invoiceScenarios = &tax.ScenarioSet{
i18n.PL: `Faktura Zaliczkowa`,
},
Codes: cbc.CodeMap{
KeyFA_VATInvoiceType: "ZAL",
KeyFAVATInvoiceType: "ZAL",
},
},
{
Expand All @@ -60,7 +60,7 @@ var invoiceScenarios = &tax.ScenarioSet{
i18n.PL: "Faktura Rozliczeniowa",
},
Codes: cbc.CodeMap{
KeyFA_VATInvoiceType: "ROZ",
KeyFAVATInvoiceType: "ROZ",
},
},
{
Expand All @@ -71,7 +71,7 @@ var invoiceScenarios = &tax.ScenarioSet{
i18n.PL: "Faktura Uproszczona",
},
Codes: cbc.CodeMap{
KeyFA_VATInvoiceType: "UPR",
KeyFAVATInvoiceType: "UPR",
},
},
{
Expand All @@ -81,7 +81,7 @@ var invoiceScenarios = &tax.ScenarioSet{
i18n.PL: "Faktura Korygująca",
},
Codes: cbc.CodeMap{
KeyFA_VATInvoiceType: "KOR",
KeyFAVATInvoiceType: "KOR",
},
},
{
Expand All @@ -92,7 +92,7 @@ var invoiceScenarios = &tax.ScenarioSet{
i18n.PL: `Faktura korygująca fakturę zaliczkową`,
},
Codes: cbc.CodeMap{
KeyFA_VATInvoiceType: "KOR_ZAL",
KeyFAVATInvoiceType: "KOR_ZAL",
},
},
{
Expand All @@ -103,7 +103,7 @@ var invoiceScenarios = &tax.ScenarioSet{
i18n.PL: "Faktura korygująca fakturę rozliczeniową",
},
Codes: cbc.CodeMap{
KeyFA_VATInvoiceType: "KOR_ROZ",
KeyFAVATInvoiceType: "KOR_ROZ",
},
},
},
Expand Down
5 changes: 0 additions & 5 deletions regimes/pl/tax_categories.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,8 @@ import (

// Tax rates specific to Poland.
const (
TaxRateExempt cbc.Key = "exempt"
TaxRateNotPursuant cbc.Key = "np"
TaxRateNotPursuantArt100 cbc.Key = "np-art100sec1point4"
TaxRateReverseCharge cbc.Key = "reverse-charge"
TaxRateZeroWDT cbc.Key = "zero-wdt"
TaxRateZeroDomestic cbc.Key = "zero-domestic"
TaxRateZeroExport cbc.Key = "zero-export"
)

var taxCategories = []*tax.Category{
Expand Down
2 changes: 1 addition & 1 deletion tax/regime.go
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ func (kd *KeyDefinition) HasCode(code cbc.Code) bool {
return false
}

// HasKeys loops through the key definitions keys and determines if there
// HasKey loops through the key definitions keys and determines if there
// is a match.
func (kd *KeyDefinition) HasKey(key cbc.Key) bool {
for _, c := range kd.Keys {
Expand Down

0 comments on commit 94e18e1

Please sign in to comment.