Source code for aeat.domain.calculations.registry._schema_rounding
"""Rounding-code schema axis for registry formulas."""from__future__importannotationsfromenumimportStrEnumfromtypingimportAnnotatedfrompydanticimportBeforeValidator__all__=["RegistryRoundingCode","RegistryRoundingCodeValue"]
[docs]classRegistryRoundingCode(StrEnum):"""Closed rounding-code vocabulary for formula results."""MONEY_2="money-2"INTEGER="integer"
def_coerce_rounding_code(value:object)->object:"""Hydrate a raw TOML rounding string into :class:`RegistryRoundingCode`."""ifisinstance(value,str)andnotisinstance(value,RegistryRoundingCode):returnRegistryRoundingCode(value)returnvalueRegistryRoundingCodeValue=Annotated[RegistryRoundingCode|None,BeforeValidator(_coerce_rounding_code)]