Source code for aeat.domain.modelos._filing_repository
"""Domain-side filing-record catalogue port surface.This module owns the pure filing-record catalogue vocabulary: the:class:`ModeloRecordPersistenceError` raised at the storage boundary, the:func:`upsert_filing_record` pure mutator, and the namespace / schema-versionconstants that name the persisted envelope contract. The concrete encryptedSQL repository lives in the persistence adapter:class:`~aeat.adapters.persistence.profile.modelos_filing.ModeloRecordCatalogueRepository`,behind the read-side:class:`~aeat.domain.modelos.ModeloRecordCatalogueRepositoryProtocol`; thedomain package depends only on the structural port."""from__future__importannotationsfrom...core.loggingimportget_loggerfrom._errorsimportModeloErrorfrom._filing_recordimportModeloRecord,ModeloRecordCatalogue_LOGGER=get_logger(__name__)# namespace string preserved across rename to avoid orphaning persisted envelopes_FILING_NAMESPACE="aeat.domain.modelos.filing_records"_FILING_OBJECT_KEY="catalogue"_FILING_CATALOGUE_VERSION=1_FILING_PERSISTENCE_MESSAGE="errors.fail.fail_modelo_filing_record_persistence"
[docs]classModeloRecordPersistenceError(ModeloError):"""Raised when the filing-record catalogue cannot be persisted or loaded. This wraps storage-boundary failures from :class:`~aeat.adapters.persistence.profile.modelos_filing.ModeloRecordCatalogueRepository` while preserving translated recovery context for callers. """
[docs]defupsert_filing_record(catalogue:ModeloRecordCatalogue,record:ModeloRecord)->ModeloRecordCatalogue:"""Return a new :class:`ModeloRecordCatalogue` with ``record`` inserted or replaced. Args: catalogue: Source catalogue to update. record: The :class:`ModeloRecord` to insert or replace. """mapping=dict(catalogue.records)mapping[record.filing_record_id]=recordreturnModeloRecordCatalogue(records=mapping)