cadrumo.adapters.persistence.profile.bienes_inversion module

Encrypted SQL persistence for the capital-goods IVA regularización register.

The domain.bienes_inversion.register.BienesInversionIvaRegister document is stored as a FINANCIAL SensitivityClass secure object in the primary database through adapters.persistence.storage.sql.secure_objects.SecureObjectRepository. The singleton namespace, default object key, schema version, and custody contracts come from adapters.persistence.storage.secure_object_namespaces.PROFILE_BIENES_INVERSION_IVA_REGISTER_NAMESPACE.

The register is authoritative primary state (the operator declares each tracked capital good), not a rebuildable cache; it therefore carries a strict save/load/equality roundtrip plus an anti-tautology proof.

See also

domain.bienes_inversion

Typed register payload models persisted here.

adapters.persistence.profile.inventory

Sibling profile-local secure-object adapter using the same storage kernel.

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

Bases: object

Governed repository for the encrypted register singleton.

The singleton row is owned by adapters.persistence.storage.secure_object_namespaces.PROFILE_BIENES_INVERSION_IVA_REGISTER_NAMESPACE and persisted through adapters.persistence.storage.sql.secure_objects.SecureObjectRepository.

Parameters:
property envelope_path: Path

Logical path retained for callers that display the storage target.

load()[source]

Load the register, returning an empty document when absent.

Return type:

BienesInversionIvaRegister

Returns:

Decrypted BienesInversionIvaRegister.

Raises:

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

save(register)[source]

Persist register as FINANCIAL-class ciphertext.

Parameters:

register (BienesInversionIvaRegister) – Register document to encrypt and write.

Return type:

None

add(record)[source]

Atomically add record and refuse duplicate identifiers.

The register is a singleton row, so adding one record rewrites the whole document. Read, duplicate-check, rebuild, and write ran unguarded, so two callers adding DIFFERENT capital goods both read the same register and the later write silently discarded the earlier record – a lost update the duplicate check could never notice, because the two records never met in one document.

The mutation now runs through the shared revision-guarded unit of work: the write carries the revision the register was read at, and a concurrent write makes it re-read and re-apply rather than overwrite. The duplicate check lives inside the mutation so it is re-evaluated against the newly-current register on every attempt.

Parameters:

record (BienInversionIvaRecord) – Capital-good record to insert.

Return type:

BienesInversionIvaRegister

Returns:

The BienesInversionIvaRegister including the new record.

Raises: