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_register

Typed register payload models persisted here.

adapters.persistence.profile.bienes_inversion

Sibling profile-local secure-object adapter whose shape this mirrors.

load_prorrata_register()[source]

Load the register, returning an empty register when absent.

Return type:

ProrrataRegister

Returns:

Persisted ProrrataRegister, or an empty one when no envelope exists.

save_prorrata_register(register)[source]

Persist register as 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 entry in the encrypted register by its key.

Parameters:

entry (ProrrataRegisterEntry) – The per-ejercicio entry to insert or update.

Return type:

ProrrataRegister

Returns:

The updated ProrrataRegister including the entry.

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

Bases: object

Governed repository for the encrypted register singleton.

The singleton row is owned by adapters.persistence.storage.PROFILE_PRORRATA_REGISTER_NAMESPACE and persisted through adapters.persistence.storage.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:

ProrrataRegister

Returns:

Decrypted ProrrataRegister.

Raises:

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

save(register)[source]

Persist register as FINANCIAL-class ciphertext.

Parameters:

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

Return type:

None

to_secure_object_write(register)[source]

Return the secure-object upsert for register without 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:

SecureObjectWrite

Parameters:

register (ProrrataRegister)

upsert_entry(entry)[source]

Atomically add or replace entry by 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:

ProrrataRegister

Returns:

The ProrrataRegister including the entry.

upsert_sector_definition(definition)[source]

Atomically add or replace a differentiated-sector definition by its sector_id.

The register carries one SectorDefinition per sector_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:

ProrrataRegister

Returns:

The updated ProrrataRegister including the definition.