aeat.adapters.persistence.profile.assets module

Encrypted SQL persistence for actividad economica asset and amortizacion ledgers.

AssetRecord, AssetsLedgerDocument, and AmortizacionLedger payloads are 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 contracts come from adapters.persistence.storage.PROFILE_ASSETS_LEDGER_NAMESPACE and adapters.persistence.storage.PROFILE_ASSETS_AMORTIZATION_LEDGER_NAMESPACE.

See also

domain.contribuyente.assets

Typed asset and amortizacion payload models persisted here.

adapters.persistence.profile.inventory

Sibling profile-local secure-object adapter for stock valuation ledgers.

load_assets()[source]

Load persisted asset records from the encrypted ledger.

Return type:

tuple[AssetRecord, ...]

Returns:

Tuple of AssetRecord entries, empty when the ledger is absent.

save_assets(assets)[source]

Persist assets as a governed FINANCIAL-class encrypted envelope.

The storage contract comes from adapters.persistence.storage.PROFILE_ASSETS_LEDGER_NAMESPACE.

Parameters:

assets (tuple[AssetRecord, ...]) – Asset records to persist.

Return type:

Path

Returns:

Logical secure-object marker for the persisted ledger.

add_asset(asset)[source]

Atomically add asset to the encrypted asset ledger.

Parameters:

asset (AssetRecord) – Asset record to insert.

Return type:

AssetsLedgerDocument

Returns:

The updated AssetsLedgerDocument including the newly inserted asset.

load_amortizacion_ledger()[source]

Load the amortizacion ledger, returning an empty ledger when absent.

Return type:

AmortizacionLedger

Returns:

Persisted AmortizacionLedger or an empty one when no envelope exists.

save_amortizacion_ledger(ledger)[source]

Persist ledger as a governed FINANCIAL-class encrypted envelope.

The storage contract comes from adapters.persistence.storage.PROFILE_ASSETS_AMORTIZATION_LEDGER_NAMESPACE.

Parameters:

ledger (AmortizacionLedger) – Amortizacion ledger to persist.

Return type:

Path

Returns:

Logical secure-object marker for the persisted ledger.

class AssetsLedgerRepository(*, objects=None)[source]

Bases: object

Governed repository for the encrypted AssetsLedgerDocument singleton.

The singleton row is owned by adapters.persistence.storage.PROFILE_ASSETS_LEDGER_NAMESPACE and persisted through adapters.persistence.storage.SecureObjectRepository.

Parameters:

objects (SecureObjectRepository | None)

property envelope_path: Path

Logical path retained for callers that display the storage target.

property lock_target: Path

Logical lock marker; SQL transactions govern writes.

load()[source]

Load the ledger, returning an empty document when absent.

Return type:

AssetsLedgerDocument

Returns:

Decrypted AssetsLedgerDocument.

Raises:

AssetRecordError – When the envelope exists but cannot be loaded or decrypted.

save(document)[source]

Persist document as FINANCIAL-class ciphertext.

The classification, schema version, namespace, and object key are taken from adapters.persistence.storage.PROFILE_ASSETS_LEDGER_NAMESPACE.

Parameters:

document (AssetsLedgerDocument) – Ledger document to encrypt and write.

Return type:

None

add(asset)[source]

Atomically add asset and refuse duplicate identifiers.

Parameters:

asset (AssetRecord) – Asset record to insert.

Return type:

AssetsLedgerDocument

Returns:

The AssetsLedgerDocument including the new asset.

Raises:

AssetRecordError – When an asset with the same identifier already exists.

class AmortizacionLedgerRepository(*, objects=None)[source]

Bases: object

Governed repository for the encrypted AmortizacionLedger singleton.

Mirrors AssetsLedgerRepository for amortizacion entries; the payload type is AmortizacionLedger. Its singleton row is owned by adapters.persistence.storage.PROFILE_ASSETS_AMORTIZATION_LEDGER_NAMESPACE and persisted through adapters.persistence.storage.SecureObjectRepository.

Parameters:

objects (SecureObjectRepository | None)

property envelope_path: Path

Logical path retained for callers that display the storage target.

property lock_target: Path

Logical lock marker; SQL transactions govern writes.

load()[source]

Load the ledger, returning an empty document when absent.

Return type:

AmortizacionLedger

Returns:

Decrypted AmortizacionLedger.

Raises:

AssetRecordError – When the envelope exists but cannot be loaded or decrypted.

save(ledger)[source]

Persist ledger as FINANCIAL-class ciphertext.

The classification, schema version, namespace, and object key are taken from adapters.persistence.storage.PROFILE_ASSETS_AMORTIZATION_LEDGER_NAMESPACE.

Parameters:

ledger (AmortizacionLedger) – Amortizacion ledger to encrypt and write.

Return type:

None