Source code for cadrumo.domain.notifications.sancion
"""Canonical domain readings for notification documents.The inbound notification adapter parses external document bytes, but thetyped reading is an application/domain fact that can be persisted andconsumed without depending on that adapter."""from__future__importannotationsfromdecimalimportDecimalfromtypingimportLiteralfrompydanticimportBaseModel,Fieldfrom...core.decimal.constantsimportMONEY_ZEROfrom...core.identity.aeat_certificadoimportAeatCertificadoIdfrom...core.identity.aeat_clave_liquidacionimportAeatClaveLiquidacionfrom...core.identity.digestimportContentDigestfrom...core.modelsimportSTRICT_FROZEN_CONFIG
[docs]classSancionLiquidacion(BaseModel):"""The typed reading of one AEAT sanción / liquidación document. Every field is a figure printed on the document. Nothing here is derived, defaulted or inferred: an absent reducción is ``None``, never ``0``, so a reducción AEAT did not grant is distinguishable from one it granted at zero. """model_config=STRICT_FROZEN_CONFIGcertificado_id:AeatCertificadoIdclave_liquidacion:AeatClaveLiquidacionreferencia:str=Field(min_length=1,max_length=64)nif:str=Field(min_length=8,max_length=16)objeto_tributario:Literal["sancion","liquidacion"]base_sancion:Decimalporcentaje_minimo:Decimalsancion_resultante:Decimalreduccion_conformidad:Decimal|None=Nonereduccion_pronto_pago:Decimal|None=Nonediferencia:Decimal|None=Noneimporte_a_ingresar:Decimaldocument_sha256:ContentDigestmode:Literal["read"]="read"@propertydefreducciones_total(self)->Decimal:"""Return the sum of every reducción the document actually printed."""return(self.reduccion_conformidadorMONEY_ZERO)+(self.reduccion_pronto_pagoorMONEY_ZERO)