dodil/erp-brick-payments
DODIL ERP brick: payments
src/brick_payments/domain/money.py
"""Money is an exact Decimal carried to two places (NUMERIC(18,2)); a rate is NUMERIC(19,4). Never a float, and
never summed across currencies: every sum below is taken per currency."""
from decimal import ROUND_HALF_UP, Decimal
CENT = Decimal("0.01")
ZERO = Decimal("0.00")
def money(v) -> Decimal:
return Decimal(str(v)).quantize(CENT, rounding=ROUND_HALF_UP)
def fx(v) -> Decimal:
return Decimal(str(v)).quantize(Decimal("0.0001"), rounding=ROUND_HALF_UP)