Skip to content

Commit

Permalink
Fixing Swiss tax ID issue
Browse files Browse the repository at this point in the history
  • Loading branch information
samlown committed May 30, 2024
1 parent ad6ca21 commit a1203fb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
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

0 comments on commit a1203fb

Please sign in to comment.