Repository navigation
fix(no_NO): use Luhn check digit for Postgiro (0000) BBANs - #2468
Open
DYNOSuprovo wants to merge 2 commits into
Open
DYNOSuprovo wants to merge 2 commits into
DYNOSuprovo wants to merge 2 commits into
Conversation
Signed-off-by: DYNOSuprovo <DYNOSuprovo@users.noreply.github.com>
Signed-off-by: DYNOSuprovo <DYNOSuprovo@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What does this change
Updates
faker.providers.bank.no_NO.Provider.bbanto compute a Luhn (modulus 10) check digit when the 4-digit bank register prefix is0000(Postgiro), and adds a deterministic regression test inTestNoNo.What was wrong
Norwegian 11-digit account numbers (BBANs) normally use a MOD11 check digit over all 10 preceding digits. However, when the 4-digit bank register number is
0000(the Postgiro code), the remaining 7 digits form a Postgiro account number whose check digit uses Luhn (modulus 10), as validated bystdnum.no.kontonr/stdnum.iban.validate. Becauseno_NO'sbban()always applied MOD11, any generated BBAN starting with0000(~1 in 10,000 draws) had an invalid Postgiro check digit ~90% of the time, causingTestNoNo.test_iban_stdnum(iban_validator.validate(faker.iban())) to fail whenever0000was drawn.How this fixes it
When
first_10.startswith("0000"),bban()computes the check digit over the 6-digit Postgiro account body (first_10[4:]) usingcalculate_luhn.Fixes #2464
Checklist
make lint