Skip to content

Commit

Permalink
Move catalogues to JSON sources
Browse files Browse the repository at this point in the history
  • Loading branch information
samlown committed Dec 12, 2024
1 parent b08d4d1 commit 38afdfb
Show file tree
Hide file tree
Showing 52 changed files with 83 additions and 8,146 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ jobs:
- name: Lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.58
version: v1.62
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
- `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.
- `tax`: Catalogue definitions now loaded from JSON source as opposed to Go code. This improves memory efficiency, especially when the source data is large.

### Fixed

Expand Down
16 changes: 5 additions & 11 deletions catalogues/cef/cef.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,14 @@ package cef

import (
"github.com/invopop/gobl/cbc"
"github.com/invopop/gobl/i18n"
"github.com/invopop/gobl/tax"
)

func init() {
tax.RegisterCatalogueDef(newCatalogue())
tax.RegisterCatalogueDef("cef.json")
}

func newCatalogue() *tax.CatalogueDef {
return &tax.CatalogueDef{
Key: "cef",
Name: i18n.NewString("Connecting Europe Facility (CEF)"),
Extensions: []*cbc.Definition{
extVATEX,
},
}
}
const (
// ExtKeyVATEX is used for the CEF VATEX exemption codes.
ExtKeyVATEX cbc.Key = "cef-vatex"
)
258 changes: 0 additions & 258 deletions catalogues/cef/vatex.go

This file was deleted.

4 changes: 4 additions & 0 deletions catalogues/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ func main() {
}
}

// generate will output the JSON definitions of the catalogues to the data directory.
// Please not that in the case of Catalogues specifically, the source data is the JSON
// output. This implies that any changes to structures or refactoring will be reflected
// in the output, despite having the same source.
func generate() error {
for _, cd := range tax.AllCatalogueDefs() {
doc, err := schema.NewObject(cd)
Expand Down
16 changes: 5 additions & 11 deletions catalogues/iso/iso.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,14 @@ package iso

import (
"github.com/invopop/gobl/cbc"
"github.com/invopop/gobl/i18n"
"github.com/invopop/gobl/tax"
)

func init() {
tax.RegisterCatalogueDef(newCatalogue())
tax.RegisterCatalogueDef("iso.json")
}

func newCatalogue() *tax.CatalogueDef {
return &tax.CatalogueDef{
Key: "iso",
Name: i18n.NewString("ISO/IEC Data Elements"),
Extensions: []*cbc.Definition{
extSchemeID,
},
}
}
const (
// ExtKeySchemeID is used by the ISO 6523 scheme identifier.
ExtKeySchemeID cbc.Key = "iso-scheme-id"
)
26 changes: 0 additions & 26 deletions catalogues/iso/scheme_id.go

This file was deleted.

Loading

0 comments on commit 38afdfb

Please sign in to comment.