aeat.adapters.persistence.profile.modelos_filing module¶
Encrypted SQL repository for the modelo filing-record catalogue.
ModeloRecordCatalogueRepository persists and loads
ModeloRecord entries in a ModeloRecordCatalogue via
SecureObjectRepository at
FINANCIAL SensitivityClass
using an Envelope wrapper. The
catalogue is stored as a single encrypted BLOB per profile bucket.
This concrete repository is the persistence adapter behind the read-side
ModeloRecordCatalogueRepositoryProtocol. It lives
in the persistence adapter (not in modelos) because its
secure-object coupling is SQL/crypto-bound; the domain package owns only the
typed ModeloRecordCatalogue model and its pure mutators.
See also
_modelo_runtimeBucket-id resolution and runtime secure-object factory shared by modelo persistence adapters.
ModeloRecordCatalogueDomain catalogue payload encrypted by this repository.
ModeloRecordCatalogueRepositoryProtocolDomain port this concrete persistence adapter implements.
MODELO_FILING_RECORD_CATALOGUE_NAMESPACECentral namespace, sensitivity, schema-version, and singleton-key contract for these secure objects.
modelos_work_unitsSibling work-unit catalogue repository whose current/filed pointers reference filing records stored here.
file_modelo_revision()Application service that writes local/internal filing state through the modelo catalogue repositories.
- class ModeloRecordCatalogueRepository(*, bucket_id=None, objects=None)[source]¶
Bases:
objectRepository over encrypted SQL-backed filing-record catalogue storage.
MODELO_FILING_RECORD_CATALOGUE_NAMESPACEis the central namespace, schema-version, sensitivity, and singleton-key contract for the encryptedModeloRecordCataloguerow. The catalogue payload keeps member-scoped current/history lookups in the domain type, while this repository wraps it inEnvelopeand writes it throughSecureObjectRepository. It exposes the concrete load/save implementation behindModeloRecordCatalogueRepositoryProtocol.- Parameters:
bucket_id (str | None)
objects (SecureObjectRepository | None)
- property bucket_id: str | None¶
Profile bucket this repository reads from and writes to.
A bucket is the per-profile partition that isolates one taxpayer’s encrypted records from another’s. Returns the resolved bucket identifier, or
Nonewhen the repository was constructed against an injectedSecureObjectRepositoryand no bucket id was supplied.
- exists()[source]¶
Report whether a persisted filing-record catalogue exists.
Returns
Truewhen an encrypted catalogue BLOB has already been written for this bucket,Falseotherwise. This is a presence check only; it neither decrypts nor validates the stored payload. Callloadto retrieve and verify the catalogue contents.- Return type:
- load()[source]¶
Load and decrypt the filing-record catalogue from storage.
A modelo is an AEAT tax form, and each filing record is the durable receipt that a calculation revision (a dated, immutable result for that form) was filed for a given form, year, and period. The whole catalogue is persisted as one encrypted FINANCIAL-class BLOB and returned as a
ModeloRecordCatalogue.Returns an empty catalogue when nothing has been persisted yet.
- Return type:
- Returns:
The decrypted
ModeloRecordCataloguefor this bucket.- Raises:
ModeloRecordPersistenceError – If the stored envelope fails its sensitivity-class or schema-version integrity checks, or if its on-disk classification is not FINANCIAL, or if it was written at a schema version newer than this consumer supports.
- save(catalogue)[source]¶
Persist the filing-record catalogue as a single encrypted BLOB.
Wraps
cataloguein aFINANCIAL-classEnvelopestamped with the current schema version and write timestamp, then writes it through the secure object store. The entire catalogue is rewritten as one encrypted object per bucket, replacing any prior catalogue for this bucket.- Parameters:
catalogue (
ModeloRecordCatalogue) – TheModeloRecordCatalogueto encrypt and store.- Return type:
- to_secure_object_write(catalogue)[source]¶
Return the secure-object upsert for
cataloguewithout committing it.The returned
SecureObjectWritecarries the sameEnvelopeandSensitivityClassclassification thatsave()would persist directly.- Return type:
- Parameters:
catalogue (ModeloRecordCatalogue)
- save_with_secure_object_writes(catalogue, extra_writes)[source]¶
Persist
catalogueplus related secure objects in one unit of work.- Parameters:
catalogue (
ModeloRecordCatalogue) – TheModeloRecordCatalogueto persist.extra_writes (
tuple[SecureObjectWrite,...]) – AdditionalSecureObjectWriteobjects to commit atomically with the catalogue.
- Return type: