from .money_currency_digits_data import CURRENCY_DIGITS 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,))