Skip to content

Register ISO 7064 mod 97-10 checksum for BA, not BT (#264)#292

Merged
mdomke merged 1 commit into
mdomke:mainfrom
CedricConday:fix/264-bosnia-checksum-country-code
Jun 30, 2026
Merged

Register ISO 7064 mod 97-10 checksum for BA, not BT (#264)#292
mdomke merged 1 commit into
mdomke:mainfrom
CedricConday:fix/264-bosnia-checksum-country-code

Conversation

@CedricConday

Copy link
Copy Markdown
Contributor

Closes #264

In schwifty/checksum/iso7064_mod97_10.py the ISO 7064 mod 97-10 national checksum algorithm is registered for BT:

# Bosnia and Herzegovina (BT)
...
@checksum.register("BT", "ME", "MK", "PT", "RS", "SI", "TL")

But the country code for Bosnia and Herzegovina is BABT is Bhutan, which is not part of the IBAN registry. So the algorithm was attached to a non-IBAN country, and BA IBANs never had their national checksum validated:

>>> from schwifty import IBAN
# valid IBAN-level checksum, invalid national check digits
>>> IBAN("BA551290079401028400", validate_bban=True)   # accepted (bug)

Fix

Register the algorithm for BA instead of BT.

Verified that Bosnia genuinely uses this algorithm: real BA IBANs (e.g. BA391290079401028494, BA391011606058553319) pass validate_bban=True, while a BA IBAN with corrupted national check digits is now correctly rejected with InvalidBBANChecksum. The other countries in the list (ME/MK/PT/RS/SI/TL) are unchanged.

Tests

Added two assertions to test_validate_national_checksum (valid BA passes, corrupted BA raises). They fail on main and pass with the fix. Full suite stays green (395 tests). Added a CHANGELOG entry.

The ISO 7064 mod 97-10 national checksum algorithm was registered for the
country code 'BT' (Bhutan, which has no IBAN), although the comment names
Bosnia and Herzegovina. Bosnia's country code is 'BA', so BA IBANs never
had their national checksum validated and an IBAN with invalid national
check digits passed validate_bban.

Register the algorithm for 'BA'. Verified against real BA IBANs (they pass)
and a BA IBAN with corrupted national check digits (now correctly rejected).

Closes mdomke#264.
@codecov

codecov Bot commented Jun 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.97%. Comparing base (5b1b0a1) to head (291c644).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #292      +/-   ##
==========================================
- Coverage   94.30%   93.97%   -0.34%     
==========================================
  Files          22       22              
  Lines        1211     1211              
  Branches       93       93              
==========================================
- Hits         1142     1138       -4     
- Misses         55       58       +3     
- Partials       14       15       +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mdomke mdomke merged commit 475c736 into mdomke:main Jun 30, 2026
11 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wrong country code

2 participants