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_inversionTyped register payload models persisted here.
adapters.persistence.profile.inventorySibling profile-local secure-object adapter using the same storage kernel.
- class BienesInversionIvaRegisterRepository(*, bucket_id=None, objects=None)[source]¶
Bases:
objectGoverned repository for the encrypted register singleton.
The singleton row is owned by
adapters.persistence.storage.secure_object_namespaces.PROFILE_BIENES_INVERSION_IVA_REGISTER_NAMESPACEand persisted throughadapters.persistence.storage.sql.secure_objects.SecureObjectRepository.- Parameters:
bucket_id (str | None)
objects (SecureObjectRepository | None)
- load()[source]¶
Load the register, returning an empty document when absent.
- Return type:
- Returns:
Decrypted
BienesInversionIvaRegister.- Raises:
BienInversionRecordError – When the envelope exists but cannot be loaded or decrypted.
- save(register)[source]¶
Persist
registeras FINANCIAL-class ciphertext.- Parameters:
register (
BienesInversionIvaRegister) – Register document to encrypt and write.- Return type:
- add(record)[source]¶
Atomically add
recordand 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:
- Returns:
The
BienesInversionIvaRegisterincluding the new record.- Raises:
BienInversionRecordError – When a record with the same identifier already exists.
SecureObjectRevisionConflictError – When contention persists across every attempt.