Source code for aeat.application.ledger._protocols
"""Application-layer port protocols for the ledger service.Defines structural :class:`typing.Protocol` interfaces consumed by:mod:`aeat.application.ledger._actions_import` so that the application layerdepends only on these protocol types, not on concrete adapter classes."""from__future__importannotationsfromcollections.abcimportIteratorfrompathlibimportPathfromtypingimportTYPE_CHECKING,Protocol,runtime_checkableifTYPE_CHECKING:from...adapters.inbound.financial.providersimportParsedLedgerRow,ProviderValidation
[docs]@runtime_checkableclassFinancialProviderProtocol(Protocol):"""Protocol satisfied by any file-backed raw transaction provider. Covers exactly the two methods called by the ledger import service: :meth:`ingest` and :meth:`validate_source`. Adapter-internal helpers (``_build_provenance``, ``_read_source_bytes``, etc.) remain private to the adapter implementation. """
[docs]defingest(self,path:Path)->Iterator[ParsedLedgerRow]:"""Yield parsed ledger rows from ``path``. Each yielded item is a :class:`ParsedLedgerRow` (a magnitude :class:`RawTransaction` plus its :class:`TransactionDirection`) parsed from the provider-format file at ``path``. """...
[docs]defvalidate_source(self,path:Path)->ProviderValidation:"""Validate ``path`` and return a :class:`ProviderValidation` result."""...