Skip to content

Commit

Permalink
Merge pull request #300 from invopop/fix-ch-tax-code
Browse files Browse the repository at this point in the history
Fixing Swiss tax ID issue
  • Loading branch information
samlown authored May 30, 2024
2 parents ad6ca21 + 0e6842d commit 1d8b0c3
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions regimes/ch/tax_identity.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
12 changes: 10 additions & 2 deletions regimes/ch/tax_identity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
{
Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion version.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 1d8b0c3

Please sign in to comment.