Source code for aeat.domain.modelos._verification_repository
"""Encrypted SQL repository for verification reports.:class:`~aeat.domain.modelos.VerificationReportCatalogueRepository` persistsand loads :class:`VerificationReport` entries in a:class:`VerificationReportCatalogue` via:class:`~aeat.adapters.persistence.storage.SecureObjectRepository` at``FINANCIAL`` :class:`~aeat.adapters.persistence.storage.SensitivityClass`.The catalogue is stored as a single encrypted BLOB per profile bucket andwrapped in :class:`~aeat.adapters.persistence.storage.Envelope` beforeserialisation.The storage contract is declared by:data:`aeat.adapters.persistence.storage.MODELO_VERIFICATION_REPORT_CATALOGUE_NAMESPACE`;its default object key is the singleton ``catalogue`` row."""from__future__importannotationsfromtypingimportTYPE_CHECKINGfrom...core.loggingimportget_loggerfrom._errorsimportModeloErrorfrom._verification_reportimportVerificationReport,VerificationReportCatalogueifTYPE_CHECKING:# pragma: no cover — import-cycle guardpass_LOGGER=get_logger(__name__)_VERIFICATION_NAMESPACE="aeat.domain.modelos.verification_reports"_VERIFICATION_OBJECT_KEY="catalogue"_VERIFICATION_CATALOGUE_VERSION=1_VERIFICATION_PERSISTENCE_MESSAGE="errors.fail.fail_modelo_verification_report_persistence"
[docs]classVerificationReportPersistenceError(ModeloError):"""Raised when the verification-report catalogue cannot be persisted or loaded. This wraps storage-boundary failures from :class:`~aeat.domain.modelos.VerificationReportCatalogueRepository` while preserving translated recovery context for callers. """
[docs]defupsert_verification_report(catalogue:VerificationReportCatalogue,report:VerificationReport,)->VerificationReportCatalogue:"""Return a new catalogue with ``report`` inserted or replaced. Returns: A :class:`VerificationReportCatalogue` with the given report added or updated. """mapping=dict(catalogue.reports)mapping[report.verification_report_id]=reportreturnVerificationReportCatalogue(reports=mapping)