French bank-account identifier helpers (RIB / IBAN).
A RIB (Relevé d'Identité Bancaire) is bank ++ branch ++ account ++ key
where bank (code établissement) is 5 digits, branch (code guichet) 5,
account (numéro de compte) 11, and key (clé RIB) 2, for 23 characters
total. Account numbers may contain letters, which are folded to digits before
the key is computed.
This module centralises the RIB key computation and IBAN derivation used both
when reading statements (CFONB.Statement.rib/1, iban/1) and when emitting
transfer orders (CFONB.Virement), where a supplied IBAN must be decomposed
and its key verified before the account coordinates are written out.
Summary
Functions
Decomposes a French IBAN into its RIB components, verifying both the IBAN check digits (ISO 7064 mod-97-10) and the embedded RIB key.
Returns the French IBAN derived from bank, branch and account.
Computes the 2-digit French RIB key for the given bank, branch and
account (returned as a zero-padded string).
Returns the 23-character RIB (bank ++ branch ++ account ++ key).
Functions
@spec from_iban(String.t()) :: {:ok, %{bank: String.t(), branch: String.t(), account: String.t(), key: String.t()}} | {:error, term()}
Decomposes a French IBAN into its RIB components, verifying both the IBAN check digits (ISO 7064 mod-97-10) and the embedded RIB key.
Returns {:ok, %{bank: ..., branch: ..., account: ..., key: ...}} or
{:error, reason}. Spaces in the input are ignored.
Returns the French IBAN derived from bank, branch and account.
Computes the 2-digit French RIB key for the given bank, branch and
account (returned as a zero-padded string).
Raises ArgumentError when no key is derivable: blank or non-numeric
bank/branch, or an account containing characters outside [0-9A-Za-z].
Statements parsed from files with blank or free-form account zones fall in
that case — check the fields before calling.
Returns the 23-character RIB (bank ++ branch ++ account ++ key).