Skip to content

Commit e8e9fb2

Browse files
authored
Merge pull request #442 from invopop/cef-vatex
Adding CEF VATEX catalogue
2 parents c7664f4 + e8b88a1 commit e8e9fb2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+7611
-2961
lines changed

.github/workflows/lint.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ jobs:
2424
- name: Lint
2525
uses: golangci/golangci-lint-action@v6
2626
with:
27-
version: v1.58
27+
version: v1.62

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,20 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
1515
- `bill`: `Tax.MergeExtensions` convenience method for adding extensions to tax objects and avoid nil panics.
1616
- `cbc`: `Key.Pop` method for splitting keys with sub-keys, e.g. `cbc.Key("a+b").Pop() == cbc.Key("a")`.
1717
- `in`: added Indian regime
18+
- `cef`: catalogue for CEF VATEX reason codes.
19+
- `untdid`: 1153 - `untdid-reference` (Reference Code Qualifier) and 7143 - `untdid-item-type` (Item Type Identification) extenions.
1820

1921
### Changed
2022

2123
- `tax`: renamed `ExtensionsRequires` to `ExtensionsRequire`, to bring in line with `ExtensionsExclude`.
2224
- `cbc`: refactored `KeyDefinition` and `ValueDefinition` into a single `Definition` object that supports `key` and `code`.
2325
- `tax`: removed `ExtValue` and replaced with `cbc.Code` which is now much more flexible.
26+
- `tax`: Catalogue definitions now loaded from JSON source as opposed to Go code. This improves memory efficiency, especially when the source data is large.
2427

2528
### Fixed
2629

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

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

bill/totals.go

-7
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ type Totals struct {
2929
// Rounding amount to apply to the invoice in case the total and payable
3030
// amounts don't quite match.
3131
Rounding *num.Amount `json:"rounding,omitempty" jsonschema:"title=Rounding"`
32-
// Total paid in outlays that need to be reimbursed
33-
Outlays *num.Amount `json:"outlays,omitempty" jsonschema:"title=Outlay Totals"`
3432
// Total amount to be paid after applying taxes and outlays.
3533
Payable num.Amount `json:"payable" jsonschema:"title=Payable"`
3634
// Total amount already paid in advance.
@@ -51,7 +49,6 @@ func (t *Totals) ValidateWithContext(ctx context.Context) error {
5149
validation.Field(&t.Tax),
5250
validation.Field(&t.TotalWithTax),
5351
validation.Field(&t.Rounding),
54-
validation.Field(&t.Outlays),
5552
validation.Field(&t.Payable),
5653
validation.Field(&t.Advances),
5754
validation.Field(&t.Due),
@@ -70,7 +67,6 @@ func (t *Totals) reset(zero num.Amount) {
7067
t.Tax = zero
7168
t.TotalWithTax = zero
7269
// t.Rounding = nil // may have been provided externally
73-
t.Outlays = nil
7470
t.Payable = zero
7571
t.Advances = nil
7672
t.Due = nil
@@ -99,9 +95,6 @@ func (t *Totals) round(zero num.Amount) {
9995
t.Total = t.Total.Rescale(e)
10096
t.Tax = t.Tax.Rescale(e)
10197
t.TotalWithTax = t.TotalWithTax.Rescale(e)
102-
if t.Outlays != nil {
103-
*t.Outlays = t.Outlays.Rescale(e)
104-
}
10598
t.Payable = t.Payable.Rescale(e)
10699
if t.Advances != nil {
107100
*t.Advances = t.Advances.Rescale(e)

catalogues/catalogues.go

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package catalogues
55

66
import (
77
// Ensure all the catalogues are registered
8+
_ "github.com/invopop/gobl/catalogues/cef"
89
_ "github.com/invopop/gobl/catalogues/iso"
910
_ "github.com/invopop/gobl/catalogues/untdid"
1011
)

catalogues/cef/cef.go

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Package cef provides codes issue by the "Connecting Europe Facility"
2+
// (CEF Digital) initiative.
3+
package cef
4+
5+
import (
6+
"github.com/invopop/gobl/cbc"
7+
"github.com/invopop/gobl/tax"
8+
)
9+
10+
func init() {
11+
tax.RegisterCatalogueDef("cef.json")
12+
}
13+
14+
const (
15+
// ExtKeyVATEX is used for the CEF VATEX exemption codes.
16+
ExtKeyVATEX cbc.Key = "cef-vatex"
17+
)

catalogues/cef/cef_test.go

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package cef_test
2+
3+
import (
4+
"testing"
5+
6+
_ "github.com/invopop/gobl"
7+
"github.com/invopop/gobl/tax"
8+
"github.com/stretchr/testify/assert"
9+
)
10+
11+
func TestInit(t *testing.T) {
12+
// Test that the catalogue is registered
13+
ed := tax.ExtensionForKey("cef-vatex")
14+
assert.NotNil(t, ed)
15+
assert.Equal(t, "cef-vatex", ed.Key.String())
16+
}

catalogues/generate.go

+4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ func main() {
1919
}
2020
}
2121

22+
// generate will output the JSON definitions of the catalogues to the data directory.
23+
// Please not that in the case of Catalogues specifically, the source data is the JSON
24+
// output. This implies that any changes to structures or refactoring will be reflected
25+
// in the output, despite having the same source.
2226
func generate() error {
2327
for _, cd := range tax.AllCatalogueDefs() {
2428
doc, err := schema.NewObject(cd)

catalogues/iso/iso.go

+5-11
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,14 @@ package iso
44

55
import (
66
"github.com/invopop/gobl/cbc"
7-
"github.com/invopop/gobl/i18n"
87
"github.com/invopop/gobl/tax"
98
)
109

1110
func init() {
12-
tax.RegisterCatalogueDef(newCatalogue())
11+
tax.RegisterCatalogueDef("iso.json")
1312
}
1413

15-
func newCatalogue() *tax.CatalogueDef {
16-
return &tax.CatalogueDef{
17-
Key: "iso",
18-
Name: i18n.NewString("ISO/IEC Data Elements"),
19-
Extensions: []*cbc.Definition{
20-
extSchemeID,
21-
},
22-
}
23-
}
14+
const (
15+
// ExtKeySchemeID is used by the ISO 6523 scheme identifier.
16+
ExtKeySchemeID cbc.Key = "iso-scheme-id"
17+
)

catalogues/iso/scheme_id.go

-26
This file was deleted.

catalogues/untdid/allowance.go

-105
This file was deleted.

0 commit comments

Comments
 (0)