fix Belgium IBAN incorrect checksum #2165 #2175
Open
+7
−8
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Signed-off-by: xeirzo <>
What does this change
This change adds a fix to the BBAN, IBAN checksum generation and validation by changing the generation formula, and rewriting the tests to be more precise.
What was wrong
According to https://www.ibancalculator.com there is an issue with both the IBAN and BBAN checksum generation,
BBAN
The calculator site verifies to true when using the later version,
moreover in https://www.ecbs.org/iban/belgium-bank-account-number.html there's an example of a valid BBAN that supports my claim.
Valid BBAN : 539007547034.
5390075470 is the account number and 34 is the resulting checksum,
if we use 5390075470 % 97 we get 34.
If we use 97 - (5390075470 % 97) we get 63 which is not the example given above (539007547034),
which further proves the point.
IBAN:
The wiki elaborates on how to generate a checksum for the IBAN under Processing -> Algorithms.
in the previous version the mod calculation was done before converting chars to numbers and rearranging the IBAN which is incorrect, this version fixes this.
In addition the test for the IBAN didn't check if the resulting IBAN checksum is valid and only checked if the country code was added, and overall string structure.
How this fixes it
By changing the method of calculation of the IBAN/BBAN checksums and making the tests cover the checksum generation it fixes the problem.
fixes #2165 which emerged from #2142
Checklist
make lint