Source code for aeat.adapters.persistence.profile.justificante
"""Governed-persistence repository for parsed justificante metadata.Justificante metadata captures AEAT verification identifiers, operatoridentity, timestamps, and verification URLs. The structured metadata isstored as encrypted byte objects in the primary SQL backend at:class:`~adapters.persistence.storage.SensitivityClass` ``AUDIT``sensitivity; no plaintext metadata JSON or envelope file lands on disk.This concrete repository is the persistence adapter for the:class:`~domain.justificante.Justificante` audit-sink record. It lives inthe persistence adapter (not in :mod:`~domain.justificante`) because itsbase :class:`~adapters.persistence.storage.SecureBoundRepository` isSQL/crypto-coupled; the domain package owns only the pure record and itsparser. No domain-layer caller consumes the repository, so no domain port isdeclared (the prior zero-consumer ``_protocols.py`` was removed on 2026-06-01);the application layer constructs this concrete directly.See Also: :class:`~domain.justificante.Justificante` Payload model encrypted by this repository. :class:`~adapters.persistence.storage.SecureObjectRepository` SQL object store underlying the bound repository."""from__future__importannotationsfromcollections.abcimportIteratorfromtypingimportClassVar,overridefrom....domain.justificanteimportJustificantefrom..storageimportSecureBoundRepository,SensitivityClass
[docs]classJustificanteRepository(SecureBoundRepository[Justificante]):"""Encrypted AUDIT repository for :class:`Justificante` metadata. The :class:`~adapters.persistence.storage.SecureBoundRepository` base stores each :class:`Justificante` in a :class:`~adapters.persistence.storage.Envelope` row under the AUDIT justificante-metadata namespace. The AEAT CSV is the natural key, so list and iteration APIs expose persisted receipt metadata without reading plaintext metadata from disk. """namespace:ClassVar[str]="aeat.domain.justificante.metadata"sensitivity:ClassVar[SensitivityClass]=SensitivityClass.AUDITschema_version:ClassVar[int]=1
[docs]deflist_csvs(self)->tuple[str,...]:"""Return every justificante CSV persisted in this repository, in lexicographic order."""returntuple(sorted(self.iter_ids()))
[docs]defiter_justificantes(self)->Iterator[Justificante]:"""Yield every persisted justificante, in lexicographic CSV order. Returns: Iterator over :class:`Justificante` records. """yield fromsorted(self.iter_records(),key=self.extract_identifier)