aeat.adapters.persistence.profile.invoices module

Governed-persistence repository for the invoice catalogue.

InvoiceCatalogueRepository is the sanctioned read/write path for the InvoiceCatalogue. It stores the catalogue as an encrypted byte object via SecureObjectRepository at FINANCIAL SensitivityClass using an Envelope wrapper; no plaintext invoice row, JSON catalogue, or envelope file lands on disk.

This concrete repository is the persistence adapter behind the read-side InvoiceCatalogueRepositoryProtocol. It lives in the persistence adapter (not in domain.invoices) because its secure-object coupling is SQL/crypto-bound; the domain package owns only the typed InvoiceCatalogue model, its narrow port, and the InvoicePersistenceError boundary error.

class InvoiceCatalogueRepository(*, bucket_id=None, objects=None)[source]

Bases: object

Repository over encrypted SQL-backed InvoiceCatalogue storage.

adapters.persistence.storage.INVOICE_CATALOGUE_NAMESPACE is the central profile-local namespace, schema-version, sensitivity, and singleton-key contract for the encrypted invoice catalogue row. The InvoiceCatalogue payload is wrapped in Envelope before SecureObjectRepository persists it, and to_secure_object_write() exposes the same write for transaction/event co-commit paths. This class exposes the concrete load/save implementation behind InvoiceCatalogueRepositoryProtocol.

Parameters:
property bucket_id: str | None

Return the profile bucket id when this repository resolved one.

exists()[source]

Return whether an invoice catalogue has been persisted.

Return type:

bool

load()[source]

Return the persisted catalogue or an empty catalogue if absent.

Return type:

InvoiceCatalogue

Returns:

The deserialised InvoiceCatalogue, or a fresh empty instance when no database object is present.

Raises:
  • ClassificationError – If the persisted object’s classification is not SensitivityClass.FINANCIAL.

  • EnvelopeVersionError – If the envelope schema version is higher than the consumer supports.

save(catalogue)[source]

Persist catalogue atomically under the file lock.

The on-disk database value is an encrypted Envelope BLOB at the SensitivityClass FINANCIAL classification declared by adapters.persistence.storage.INVOICE_CATALOGUE_NAMESPACE. No plaintext invoice row lands on disk.

Parameters:

catalogue (InvoiceCatalogue) – The InvoiceCatalogue to persist.

Return type:

None

to_secure_object_write(catalogue)[source]

Return the secure-object upsert for catalogue without committing it.

The returned SecureObjectWrite carries the same Envelope and SensitivityClass classification that save() would persist directly.

Parameters:

catalogue (InvoiceCatalogue) – The InvoiceCatalogue to serialise.

Return type:

SecureObjectWrite