Skip to content

Commit

Permalink
Fix bug in nl-be vat generation (#455)
Browse files Browse the repository at this point in the history
* Generate valid BE VAT number

* Add comments

* 🐛 Make sure checksum is always 2 chars long
  • Loading branch information
robvankeilegom committed Feb 22, 2022
1 parent a8e53bd commit 42d0ba6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Faker/Provider/nl_BE/Payment.php
Expand Up @@ -44,6 +44,6 @@ public static function vat($spacedNationalPrefix = true)
$checksum = 97 - fmod($firstSeven, 97);

// '0' + 7 numbers + checksum
return sprintf('%s0%s%s', $prefix, $firstSeven, $checksum);
return sprintf('%s0%s%02d', $prefix, $firstSeven, $checksum);
}
}
2 changes: 2 additions & 0 deletions test/Faker/Provider/nl_BE/PaymentTest.php
Expand Up @@ -33,6 +33,8 @@ private function validateChecksum($vat)

// Mod97 check on first 8 digits
$checksum = 97 - fmod(substr($numbers, 0, 8), 97);
// Make sure checksum is 2 characters long
$checksum = sprintf('%02d', $checksum);

self::assertEquals((string) $checksum, substr($numbers, 8, 10));
}
Expand Down

0 comments on commit 42d0ba6

Please sign in to comment.