aeat.adapters.persistence.profile.prorrata_register module¶
Encrypted SQL persistence for the cross-period IVA prorrata register.
The domain.prorrata_register.ProrrataRegister document is stored as a
FINANCIAL adapters.persistence.storage.SensitivityClass secure
object 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_PRORRATA_REGISTER_NAMESPACE.
The register is authoritative primary state (the taxpayer’s per-ejercicio provisional and settled prorrata percentages, seeded from the stamped prior settlement observation), not a rebuildable cache; it therefore carries a strict save/load/equality roundtrip plus an anti-tautology proof.
See also
domain.prorrata_registerTyped register payload models persisted here.
adapters.persistence.profile.bienes_inversionSibling profile-local secure-object adapter whose shape this mirrors.
- load_prorrata_register()[source]¶
Load the register, returning an empty register when absent.
- Return type:
- Returns:
Persisted
ProrrataRegister, or an empty one when no envelope exists.
- save_prorrata_register(register)[source]¶
Persist
registeras a governed FINANCIAL-class encrypted envelope.- Parameters:
register (
ProrrataRegister) – Register document to encrypt and write.- Return type:
Path- Returns:
Logical secure-object marker for the persisted register.
- declare_prorrata_entry(entry)[source]¶
Atomically add or replace
entryin the encrypted register by its key.- Parameters:
entry (
ProrrataRegisterEntry) – The per-ejercicio entry to insert or update.- Return type:
- Returns:
The updated
ProrrataRegisterincluding the entry.
- class ProrrataRegisterRepository(*, bucket_id=None, objects=None)[source]¶
Bases:
objectGoverned repository for the encrypted register singleton.
The singleton row is owned by
adapters.persistence.storage.PROFILE_PRORRATA_REGISTER_NAMESPACEand persisted throughadapters.persistence.storage.SecureObjectRepository.- Parameters:
bucket_id (str | None)
objects (SecureObjectRepository | None)
- load()[source]¶
Load the register, returning an empty document when absent.
- Return type:
- Returns:
Decrypted
ProrrataRegister.- Raises:
ProrrataRegisterError – When the envelope exists but cannot be loaded or decrypted.
- save(register)[source]¶
Persist
registeras FINANCIAL-class ciphertext.- Parameters:
register (
ProrrataRegister) – Register document to encrypt and write.- Return type:
- to_secure_object_write(register)[source]¶
Return the secure-object upsert for
registerwithout committing it.The filing persistence path co-emits the settled prorrata register with the filed revision and filing catalogue in one secure-object transaction, mirroring the participation-index write pattern.
- Return type:
- Parameters:
register (ProrrataRegister)
- upsert_entry(entry)[source]¶
Atomically add or replace
entryby its(ejercicio, sector_id)key.The register carries one entry per
(ejercicio, sector_id)key across the ejercicio’s lifecycle (provisional seed then definitive settlement), so declaring an entry for an existing key replaces it rather than raising.- Parameters:
entry (
ProrrataRegisterEntry) – The entry to insert or update.- Return type:
- Returns:
The
ProrrataRegisterincluding the entry.
- upsert_sector_definition(definition)[source]¶
Atomically add or replace a differentiated-sector definition by its
sector_id.The register carries one
SectorDefinitionpersector_id(LIVA arts. 9.1.c / 101); declaring a sector whose id already exists replaces it rather than raising. Existing per-ejercicio entries are preserved, so the operator can declare the partition and the per-sector entries in either order.- Parameters:
definition (
SectorDefinition) – The differentiated-sector partition entry to insert or update.- Return type:
- Returns:
The updated
ProrrataRegisterincluding the definition.