Functional Weave
Code in Python

money.currency-digits@1.0.0

impl/python.py

485 bytes · the Python implementation · view raw

Imports name this capability’s declared dependencies, which fune builds next to it in your project; each one links to its page.

from .money_currency_digits_data import CURRENCY_DIGITS  ← this capability’s own data, compiled from data/currency-digits.json into the same file by fune build


def currency_digits(currency: str) -> int:
    """Decimal places in a currency's minor unit, per ISO 4217.

    Dividing by 100 is wrong for yen, won, dinar and a few dozen others, so
    anything moving between minor and major units asks here.
    """
    for row in CURRENCY_DIGITS:
        if row.code == currency:
            return row.digits
    raise ValueError('no ISO 4217 minor unit for currency "%s"' % (currency,))