"""General utilities.""" from decimal import Decimal def as_decimal(value: int | float | None) -> Decimal: """Convert a value to a Decimal. Args: value (int | float | None): Value to convert. Returns: Decimal: Decimal representation of the value. """ if not value: return Decimal(0) return Decimal(str(value))