Skip to content

be: let a bank account carry its country and read or write its iban - #46

Merged
landsman merged 3 commits into
mainfrom
bank-account-iban
Nov 10, 2026
Merged

landsman merged 3 commits into
mainfrom
bank-account-iban

Conversation

@landsman

@landsman landsman commented Nov 10, 2026 •

Copy link
Copy Markdown
Owner

Slovak banks write accounts as IBANs, and a Czech and a Slovak account can share digits and a bank code, which BankAccount could not tell apart. Groundwork for ČSOB SK and Tatra banka.

  • country(), Country CZ or SK, an enum of its own, first in the record; part of equality, so the same digits in two countries are two accounts.
  • parse(text, country) reads a local form. There is no default country: a local form does not say it, and a default would quietly read a Slovak account as Czech. The one-argument parse is gone; every call, in the parsers, tests and the Spring Boot caller test, now names CZ (58 calls).
  • parseIban(text), with or without spaces, checks ISO 13616's modulo 97 and then the same modulo 11 rule as the local form; only CZ and SK. iban() writes it back; a local form and its IBAN compare equal.
  • Both countries share the numbering and the modulo 11 weights: checked on a real Slovak IBAN from a public ČSOB SK sample, which passes both checks (the sample's anonymised payer IBAN passes neither).

Breaking, fine before 1.0: BankAccount gains a component and loses parse(String).

Tests: the ČNB sample account both ways, the Slovak IBAN, round trip, two countries apart, bad check digits, a modulo 11 failure behind valid check digits, a German IBAN. They caught one real bug on the way: the IBAN's parts were first passed in IBAN order (bank code first) to a constructor that takes the prefix first. Breaking the modulo 97 or the modulo 11 check each fails a test. make build: green.

@landsman
landsman merged commit ad76dee into main Nov 10, 2026
5 checks passed
@landsman
landsman deleted the bank-account-iban branch November 10, 2026 22:48
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.

1 participant