diff --git a/CHANGELOG.md b/CHANGELOG.md index cb09e557..285e190c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to GOBL will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). See also the [GOBL versions](https://docs.gobl.org/overview/versions) documentation site for more details. +## [v0.78.1] - 2024-05-30 + +### Fixed + +- CH: fixing tax ID checksum validation that ends in `0`. + ## [v0.78.0] - 2024-05-23 ### Added diff --git a/regimes/ch/tax_identity.go b/regimes/ch/tax_identity.go index 9216c004..6b9e110c 100644 --- a/regimes/ch/tax_identity.go +++ b/regimes/ch/tax_identity.go @@ -84,6 +84,9 @@ func commercialCheck(val string) error { if total == 10 { return errors.New("invalid code") } + if total == 11 { + total = 0 + } lastNum := int(val[9] - '0') if lastNum != int(total) { diff --git a/regimes/ch/tax_identity_test.go b/regimes/ch/tax_identity_test.go index 578afaec..ec633167 100644 --- a/regimes/ch/tax_identity_test.go +++ b/regimes/ch/tax_identity_test.go @@ -57,9 +57,12 @@ func TestValidateTaxIdentity(t *testing.T) { {name: "good 1", code: "E100416306"}, {name: "good 2", code: "E284156502"}, {name: "good 3", code: "E432825998"}, + {name: "good 4", code: "E115400550"}, + {name: "good 5", code: "E424414541"}, + {name: "good 6", code: "E123456788"}, { name: "zeros", - code: "E000000000", + code: "E000000001", err: "checksum mismatch", }, { @@ -84,9 +87,14 @@ func TestValidateTaxIdentity(t *testing.T) { }, { name: "bad checksum", - code: "E116276850", + code: "E116276851", err: "checksum mismatch", }, + { + name: "invalid code", + code: "E100426306", + err: "invalid code", + }, } for _, tt := range tests { diff --git a/version.go b/version.go index 7fd7957a..be2ed50e 100644 --- a/version.go +++ b/version.go @@ -8,7 +8,7 @@ import ( type Version string // VERSION is the current version of the GOBL library. -const VERSION Version = "v0.78.0" +const VERSION Version = "v0.78.1" // Semver parses and returns semver func (v Version) Semver() *semver.Version {