Low-level fixed-width field formatting for emitting CFONB records — the
symmetric counterpart of the decoders in CFONB.
Two alignment rules, per the CFONB brochure:
- numeric zones are right-aligned and zero-filled (
numeric/2), - alphanumeric zones are left-aligned and space-filled (
alpha/2), restricted to the permitted character set (sanitize/1).
Amounts are encoded as unsigned integer cents (centimes/2) — note this is a
different encoding from the signed "montant" of the 120 statement format.
Functions raise ArgumentError on data that cannot be represented (negative
amount, more than two decimals, numeric overflow); callers are expected to
validate user input first.
Summary
Functions
Formats an alphanumeric zone: sanitized, left-aligned, space-filled, and
truncated to len.
A reserved zone of len spaces.
Encodes a euro %Decimal{} amount as unsigned integer cents, right-aligned
and zero-filled to len (default 16). Raises on a negative amount or on more
than two decimal places.
Formats a settlement date as JJMMA — day, month, and the single trailing
digit of the year, per the CFONB 160 spec. A nil date yields five spaces.
Formats a numeric zone: right-aligned, zero-filled to len. Accepts an
integer or a digit string. Raises if the value does not fit in len.
Uppercases, strips accents, and replaces any character outside the permitted
CFONB set with a space. nil becomes an empty string.
Whether the euro amount is representable as a whole number of cents (at most
two decimal places). Single source of the precision rule used both by
centimes/2 and by callers validating input up front.
Functions
@spec alpha(String.t() | nil, pos_integer()) :: String.t()
Formats an alphanumeric zone: sanitized, left-aligned, space-filled, and
truncated to len.
@spec blank(non_neg_integer()) :: String.t()
A reserved zone of len spaces.
@spec centimes(Decimal.t(), pos_integer()) :: String.t()
Encodes a euro %Decimal{} amount as unsigned integer cents, right-aligned
and zero-filled to len (default 16). Raises on a negative amount or on more
than two decimal places.
Formats a settlement date as JJMMA — day, month, and the single trailing
digit of the year, per the CFONB 160 spec. A nil date yields five spaces.
@spec numeric(integer() | String.t(), pos_integer()) :: String.t()
Formats a numeric zone: right-aligned, zero-filled to len. Accepts an
integer or a digit string. Raises if the value does not fit in len.
Uppercases, strips accents, and replaces any character outside the permitted
CFONB set with a space. nil becomes an empty string.
Whether the euro amount is representable as a whole number of cents (at most
two decimal places). Single source of the precision rule used both by
centimes/2 and by callers validating input up front.