Source code for cadrumo.application.filing._envelope_modelo_policy
"""Per-modelo policy the modelo-agnostic filing-envelope renderer dispatches to.The envelope GRAMMAR is one contract for every modelo -- prefix roles, relativecloser, emitted-byte total -- and lives in the generic renderer. What is notshared is tax law: which records apply to which taxpayer, and which operatorelections a modelo's records make mandatory. Those stay per modelo, and theyarrive here as a registered row rather than as a branch inside the renderer.Registering a modelo is therefore additive: a new row, and (where the modelo hasconditional records) its own applicability module. A modelo with no row is notrefused -- it simply carries no extra constraint beyond the generic ones therenderer already proves -- because "this modelo declares no conditional recordfamily" is a legitimate state, not an unfinished one."""from__future__importannotationsfromcollections.abcimportCallable,MappingfrompydanticimportBaseModel,ConfigDictfrom...core.modeloimportModelofrom...core.periodimportPeriodfrom...domain.calculations.registry.schemaimportRegistrySnapshotfrom...domain.calculations.registry.schema_exportsimportExportLayoutDefinitionfrom._m303_export_applicabilityimportvalidate_m303_export_applicabilityfrom.producer_snapshotimportFilingProducerSnapshot__all__=["FilingEnvelopeModeloPolicy","filing_envelope_modelo_policy",]#: One modelo's applicability gate, called with the already-selected authority.typeFilingEnvelopeApplicabilityGate=Callable[...,None]
[docs]classFilingEnvelopeModeloPolicy(BaseModel):"""The per-modelo constraints one registered modelo adds to envelope render."""model_config=ConfigDict(frozen=True,extra="forbid",arbitrary_types_allowed=True)#: Whether the modelo's records make the operator's prior-domiciliation#: election a mandatory explicit input rather than a defaulted one.requiresprior_domiciliation_election:bool=False#: The modelo's own exhaustive applicability gate, where it declares one.applicability_gate:FilingEnvelopeApplicabilityGate|None=None
[docs]defvalidate_applicability(self,*,period:Period,registry_snapshot:RegistrySnapshot,layout:ExportLayoutDefinition,producer_snapshot:FilingProducerSnapshot,)->None:"""Run the modelo's own applicability gate, where it registered one. Core types: :class:`~cadrumo.domain.calculations.registry.schema.RegistrySnapshot`. """ifself.applicability_gateisNone:returnself.applicability_gate(period=period,registry_snapshot=registry_snapshot,layout=layout,producer_snapshot=producer_snapshot,)
[docs]deffiling_envelope_modelo_policy(modelo:Modelo)->FilingEnvelopeModeloPolicy:"""Return the registered policy for ``modelo``, or the empty one."""return_POLICY_BY_MODELO.get(modelo,_NO_EXTRA_POLICY)