Skip to content

Commit

Permalink
Merge pull request #118 from RamonBalthazar/fix-french-checksum-zero-pad
Browse files Browse the repository at this point in the history
fix: French VAT checksum failing for leading zero
  • Loading branch information
koblas committed Jun 5, 2024
2 parents ece62d1 + ef5e5c1 commit 90768b7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/fr/tva.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ describe('fr/tva', () => {
'23334175221',
'K7399859412',
'4Z123456782',
'04494887854', // First digit of checksum is 0
'FR04494887854', // First digit of checksum is 0
'FR84323140392',
])('validate:%s', value => {
const result = validate(value);
Expand Down
2 changes: 1 addition & 1 deletion src/fr/tva.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ const impl: Validator = {
if (strings.isdigits(check)) {
const sum = (12 + 3 * (parseInt(back, 10) % 97)) % 97;

if (String(sum) !== check) {
if (sum !== parseInt(check, 10)) {
return { isValid: false, error: new exceptions.InvalidChecksum() };
}
} else {
Expand Down

0 comments on commit 90768b7

Please sign in to comment.