from decimal import ROUND_HALF_UP, Decimal


def to_money(value):
    """Consistent monetary values by handling quantizing and rounding"""
    if not value:
        value = Decimal("0")
    if not isinstance(value, Decimal):
        raise ValueError("Expected a Decimal")
    return value.quantize(Decimal("0.01"), rounding=ROUND_HALF_UP)
