Source code for aeat.application.calculations._ports
"""Structural calculation ports for read-only filed declaration data.These runtime-checkable protocols declare the subset of AEAT filed-declarationrecords that the calculations application layer reads without importing theSede adapter. Concrete records such as:class:`~adapters.outbound.aeat.sede.FiledDeclaracionObservation`,:class:`~adapters.outbound.aeat.sede.FiledDeclaracionArtefact`, and:class:`~adapters.outbound.aeat.sede.ObservedCasillaValue` satisfy theseports structurally while remaining adapter-owned evidence records.See Also: :mod:`application.calculations._iva_compensation_history`: Consumes :class:`FiledDeclaracionObservationProtocol` for Modelo 303 period states and Modelo 390 annual cross-checks. :mod:`application.live`: Captures filed declarations and promotes registry-consumable observations into local encrypted stores."""from__future__importannotationsfromcollections.abcimportSequencefromdatetimeimportdatetimefromtypingimportProtocol,runtime_checkablefrom...coreimportPeriodfrom...domain.calculations.registryimportCasillaId
[docs]@runtime_checkableclassFiledDeclaracionArtefactProtocol(Protocol):"""Minimal artefact surface read by calculation evidence consumers. The concrete :class:`~adapters.outbound.aeat.sede.FiledDeclaracionArtefact` carries more capture metadata, but calculation history only needs the artefact kind and hash witness to choose submitted-file evidence where it is present. """@propertydefkind(self)->str:"""Artefact kind identifier, for example ``submitted_file``."""...@propertydefsha256(self)->str|None:"""SHA-256 hex digest of the artefact, when available."""...
[docs]@runtime_checkableclassObservedCasillaValueProtocol(Protocol):"""Minimal casilla-observation surface read by calculations. Values arrive as read-only evidence from an adapter-owned :class:`~adapters.outbound.aeat.sede.ObservedCasillaValue`. The application treats ``casilla_id`` as a canonical ``CasillaId`` string and validates it against the resolved registry snapshot before using the value. """@propertydefsource_artefact_kind(self)->str:"""Source artefact kind that produced this observation."""...@propertydefcasilla_id(self)->CasillaId:"""Canonical ``CasillaId`` string observed in the filed artefact."""...@propertydefvalue(self)->str:"""Raw string value for the casilla observation."""...
[docs]@runtime_checkableclassFiledDeclaracionObservationProtocol(Protocol):"""Structural interface for a filed AEAT declaration observation. The application layer depends on this protocol rather than the concrete :class:`~adapters.outbound.aeat.sede.FiledDeclaracionObservation` model, eliminating the application-to-adapter import edge. The surface is intentionally limited to the fields consumed by :func:`~application.calculations._iva_compensation_history.iva_compensation_state_from_filed_observation` and :func:`~application.calculations._iva_compensation_history.iva_compensation_annual_summary_from_filed_observation`. """@propertydefmodelo(self)->str:"""AEAT modelo identifier (e.g. '303')."""...@propertydefejercicio(self)->int:"""Tax year (fiscal year) for this declaration."""...@propertydefperiod(self)->Period:"""Typed :class:`~core.Period` for the declaration."""...@propertydefexpediente_id(self)->str:"""AEAT expediente identifier."""...@propertydefstatus(self)->str:"""Filing status string."""...@propertydefpresented_at(self)->datetime:"""Timestamp when the declaration was presented to AEAT."""...@propertydefauthenticated_identity(self)->str:"""NIF of the authenticated taxpayer who presented the declaration."""...@propertydefartefacts(self)->Sequence[FiledDeclaracionArtefactProtocol]:"""Sequence of artefacts attached to this declaration. Each element satisfies :class:`FiledDeclaracionArtefactProtocol`. """...@propertydefcasillas(self)->Sequence[ObservedCasillaValueProtocol]:"""Sequence of :class:`ObservedCasillaValueProtocol` values extracted from the declaration."""...