"""Company fixed FX rates used for CNY-equivalent management summaries.""" from __future__ import annotations from decimal import ROUND_HALF_UP, Decimal # Units of each supported currency per CNY. These are company policy rates, # not a live market feed; display callers must keep the native breakdown too. FIXED_CURRENCY_PER_CNY: dict[str, Decimal] = { "CNY": Decimal("1.000"), "JPY": Decimal("20.000"), "SGD": Decimal("0.190"), "USD": Decimal("0.140"), } SUPPORTED_FIXED_CURRENCIES = tuple(FIXED_CURRENCY_PER_CNY) def to_cny(amount: Decimal, currency: str) -> Decimal: rate = FIXED_CURRENCY_PER_CNY.get(currency.upper()) if rate is None: raise ValueError(f"Unsupported fixed-FX currency: {currency}") return (amount / rate).quantize(Decimal("0.01"), rounding=ROUND_HALF_UP)