aeat.adapters.persistence.profile.inventory module¶
Encrypted SQL persistence for actividad economica inventory ledgers.
InventoryLedger payloads are grouped in
InventoryLedgerDocument and stored as
FINANCIAL adapters.persistence.storage.SensitivityClass
secure objects in the primary database through
adapters.persistence.storage.SecureObjectRepository. The
singleton namespace, default object key, schema version, and custody contract
come from
adapters.persistence.storage.PROFILE_INVENTORY_LEDGER_NAMESPACE.
See also
domain.contribuyente.inventoryTyped inventory ledger, movement, and valuation payload models persisted here.
application.inventoryApplication service layer that validates inventory commands before this adapter writes the encrypted secure object.
- load_inventory()[source]¶
Load inventory ledgers from the encrypted ledger.
- Return type:
- Returns:
Tuple of
InventoryLedgerrecords, empty when no envelope exists.
- save_inventory(ledgers)[source]¶
Persist
ledgersas a governed FINANCIAL-class secure object.The storage contract comes from
adapters.persistence.storage.PROFILE_INVENTORY_LEDGER_NAMESPACE.- Parameters:
ledgers (
tuple[InventoryLedger,...]) – Inventory ledgers to persist.- Return type:
Path- Returns:
Logical path identifying the secure object.
- create_inventory_ledger(ledger)[source]¶
Atomically create
ledgerand refuse duplicate (actividad, year) pairs.- Parameters:
ledger (
InventoryLedger) – Inventory ledger to insert.- Return type:
- Returns:
The updated
InventoryLedgerDocumentincluding the newly inserted ledger.
- record_movement(actividad_id, movement, *, year)[source]¶
Append
movementto an existing activity-and-year inventory ledger.- Parameters:
actividad_id (
str) – Identifier of the actividad economica owning the ledger.movement (
MovementRecord) – Movement record to append.year (
int) – Tax year of the target ledger.
- Return type:
- Returns:
The updated
InventoryLedger.
- class InventoryLedgerRepository(*, objects=None)[source]¶
Bases:
objectGoverned repository for the encrypted
InventoryLedgerDocumentsingleton.The singleton row is owned by
adapters.persistence.storage.PROFILE_INVENTORY_LEDGER_NAMESPACEand persisted throughadapters.persistence.storage.SecureObjectRepository.- Parameters:
objects (SecureObjectRepository | None)
- load()[source]¶
Load the ledger, returning an empty document when absent.
- Return type:
- Returns:
Decrypted
InventoryLedgerDocument.- Raises:
InventoryLedgerError – When the envelope exists but cannot be loaded or decrypted.
- save(document)[source]¶
Persist
documentas FINANCIAL-class ciphertext.The classification, schema version, namespace, and object key are taken from
adapters.persistence.storage.PROFILE_INVENTORY_LEDGER_NAMESPACE.- Parameters:
document (
InventoryLedgerDocument) – Ledger document to encrypt and write.- Return type:
- create(ledger)[source]¶
Atomically create
ledgerand refuse duplicate actividad/year pairs.- Parameters:
ledger (
InventoryLedger) – Inventory ledger to insert.- Return type:
- Returns:
The
InventoryLedgerDocumentincluding the new ledger.- Raises:
InventoryLedgerError – When a ledger with the same
(actividad_id, year)pair exists.
- record_movement(actividad_id, movement, *, year)[source]¶
Atomically append
movementto the target activity-and-year ledger.The domain valuation guard (rejecting movements that would produce an invalid valuation) is owned by the application inventory service, which runs it before invoking persistence; this adapter performs the storage append only and runs no domain calculation.
- Parameters:
actividad_id (
str) – Identifier of the owning actividad economica.movement (
MovementRecord) – Movement record to append.year (
int) – Tax year of the target ledger.
- Return type:
- Returns:
The updated
InventoryLedger.- Raises:
InventoryLedgerError – When the target ledger does not exist or the movement id is duplicated.