Skip to content

Commit

Permalink
Merge pull request #442 from invopop/cef-vatex
Browse files Browse the repository at this point in the history
Adding CEF VATEX catalogue
  • Loading branch information
samlown authored Dec 12, 2024
2 parents c7664f4 + e8b88a1 commit e8e9fb2
Show file tree
Hide file tree
Showing 50 changed files with 7,611 additions and 2,961 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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,20 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
- `bill`: `Tax.MergeExtensions` convenience method for adding extensions to tax objects and avoid nil panics.
- `cbc`: `Key.Pop` method for splitting keys with sub-keys, e.g. `cbc.Key("a+b").Pop() == cbc.Key("a")`.
- `in`: added Indian regime
- `cef`: catalogue for CEF VATEX reason codes.
- `untdid`: 1153 - `untdid-reference` (Reference Code Qualifier) and 7143 - `untdid-item-type` (Item Type Identification) extenions.

### 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.
- `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

- `bill`: corrected issues around correction definitions and merging types.
- `bill`: removed `Outlays` from totals.

## [v0.206.1] - 2024-11-28

Expand Down
7 changes: 0 additions & 7 deletions bill/totals.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ type Totals struct {
// Rounding amount to apply to the invoice in case the total and payable
// amounts don't quite match.
Rounding *num.Amount `json:"rounding,omitempty" jsonschema:"title=Rounding"`
// Total paid in outlays that need to be reimbursed
Outlays *num.Amount `json:"outlays,omitempty" jsonschema:"title=Outlay Totals"`
// Total amount to be paid after applying taxes and outlays.
Payable num.Amount `json:"payable" jsonschema:"title=Payable"`
// Total amount already paid in advance.
Expand All @@ -51,7 +49,6 @@ func (t *Totals) ValidateWithContext(ctx context.Context) error {
validation.Field(&t.Tax),
validation.Field(&t.TotalWithTax),
validation.Field(&t.Rounding),
validation.Field(&t.Outlays),
validation.Field(&t.Payable),
validation.Field(&t.Advances),
validation.Field(&t.Due),
Expand All @@ -70,7 +67,6 @@ func (t *Totals) reset(zero num.Amount) {
t.Tax = zero
t.TotalWithTax = zero
// t.Rounding = nil // may have been provided externally
t.Outlays = nil
t.Payable = zero
t.Advances = nil
t.Due = nil
Expand Down Expand Up @@ -99,9 +95,6 @@ func (t *Totals) round(zero num.Amount) {
t.Total = t.Total.Rescale(e)
t.Tax = t.Tax.Rescale(e)
t.TotalWithTax = t.TotalWithTax.Rescale(e)
if t.Outlays != nil {
*t.Outlays = t.Outlays.Rescale(e)
}
t.Payable = t.Payable.Rescale(e)
if t.Advances != nil {
*t.Advances = t.Advances.Rescale(e)
Expand Down
1 change: 1 addition & 0 deletions catalogues/catalogues.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package catalogues

import (
// Ensure all the catalogues are registered
_ "github.com/invopop/gobl/catalogues/cef"
_ "github.com/invopop/gobl/catalogues/iso"
_ "github.com/invopop/gobl/catalogues/untdid"
)
17 changes: 17 additions & 0 deletions catalogues/cef/cef.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Package cef provides codes issue by the "Connecting Europe Facility"
// (CEF Digital) initiative.
package cef

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

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

const (
// ExtKeyVATEX is used for the CEF VATEX exemption codes.
ExtKeyVATEX cbc.Key = "cef-vatex"
)
16 changes: 16 additions & 0 deletions catalogues/cef/cef_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package cef_test

import (
"testing"

_ "github.com/invopop/gobl"
"github.com/invopop/gobl/tax"
"github.com/stretchr/testify/assert"
)

func TestInit(t *testing.T) {
// Test that the catalogue is registered
ed := tax.ExtensionForKey("cef-vatex")
assert.NotNil(t, ed)
assert.Equal(t, "cef-vatex", ed.Key.String())
}
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.

105 changes: 0 additions & 105 deletions catalogues/untdid/allowance.go

This file was deleted.

Loading

0 comments on commit e8e9fb2

Please sign in to comment.