Source code for aeat.domain.fincas._repository_ports
"""Read-side repository ports for rental-register aggregation.These :class:`~typing.Protocol` declarations are the hexagonal boundarybetween the pure :mod:`domain.fincas` aggregation logic and theORM-backed concrete repositories that live in the persistence adapter(:mod:`adapters.persistence.profile.fincas`). The aggregationfunctions in :mod:`._aggregates` annotate against these ports and dependonly on the read methods they call, never on SQLAlchemy or the storagemapper rows — keeping the domain layer free of adapter coupling.The concrete adapter repositories satisfy these ports structurally; noexplicit subclassing is required. Each port declares exactly the readmethod the aggregation pipeline consumes (interface segregation), so aport change is a real change to what the domain needs.The port set is :class:`FincaReader`, :class:`ArrendamientoReader`,:class:`FincaRendimientoReader`, :class:`FincaGastoReader`, and:class:`FincaAmortizacionLedgerReader`; each returns the corresponding:class:`Finca`, :class:`Arrendamiento`, :class:`FincaRendimientoRecord`,:class:`FincaGasto`, or :class:`FincaAmortizacionLedgerEntry` record. Theadapter implementations are:class:`~adapters.persistence.profile.fincas.FincaRepository`,:class:`~adapters.persistence.profile.fincas.ArrendamientoRepository`,:class:`~adapters.persistence.profile.fincas.FincaRendimientoRepository`,:class:`~adapters.persistence.profile.fincas.FincaGastoRepository`, and:class:`~adapters.persistence.profile.fincas.FincaAmortizacionLedgerRepository`."""from__future__importannotationsfromtypingimportProtocolfrom._modelsimport(Arrendamiento,Finca,FincaAmortizacionLedgerEntry,FincaGasto,FincaRendimientoRecord,)
[docs]classFincaReader(Protocol):"""Read port over the :class:`Finca` register."""
[docs]deflist_all(self)->list[Finca]:"""Return every persisted :class:`Finca` record."""...
[docs]classArrendamientoReader(Protocol):"""Read port over the :class:`Arrendamiento` (rental contract) register."""
[docs]deflist_for_finca(self,finca_id:int)->list[Arrendamiento]:"""Return every :class:`Arrendamiento` attached to ``finca_id``."""...
[docs]classFincaRendimientoReader(Protocol):"""Read port over the :class:`FincaRendimientoRecord` income register."""
[docs]defget_for_contract_period(self,contract_id:int,period_year:int,)->FincaRendimientoRecord|None:"""Return the :class:`FincaRendimientoRecord` for ``contract_id`` in ``period_year``, or ``None``."""...
[docs]classFincaGastoReader(Protocol):"""Read port over the :class:`FincaGasto` expense register."""
[docs]deflist_for_finca_period(self,finca_id:int,period_year:int)->list[FincaGasto]:"""Return every :class:`FincaGasto` for ``finca_id`` within ``period_year``."""...
[docs]classFincaAmortizacionLedgerReader(Protocol):"""Read port over the :class:`FincaAmortizacionLedgerEntry` ledger."""
[docs]deflist_for_finca(self,finca_id:int)->list[FincaAmortizacionLedgerEntry]:"""Return every :class:`FincaAmortizacionLedgerEntry` attached to ``finca_id``."""...