aeat.adapters.outbound.aeat.sede._observation_store module

Persistence helpers for read-only filed-declaration observations.

Persists each filed-declaration observation as an Envelope record through SecureObjectRepository, keyed by declaration identity so a prior filing can be retrieved without re-fetching it from the sede. Each envelope is classified at SensitivityClass FINANCIAL and encrypted via the active MasterKeyProvider.

Artefact bytes are stored under adapters.persistence.storage.AEAT_FILED_DECLARATION_ARTEFACTS_NAMESPACE; filed-declaration observation envelopes are stored under adapters.persistence.storage.AEAT_FILED_DECLARATION_OBSERVATIONS_NAMESPACE; IVA wallet observation envelopes are stored under adapters.persistence.storage.AEAT_IVA_WALLET_OBSERVATIONS_NAMESPACE. Those namespace definitions provide the schema version, key grammar, profile scope, and full-custody disposition for each row family.

class FiledDeclaracionObservationStore(root, *, master_key_provider=None, objects=None)[source]

Bases: object

Persist captured AEAT filed data through encrypted SQL namespaces.

The store writes raw captured artefact bytes to adapters.persistence.storage.AEAT_FILED_DECLARATION_ARTEFACTS_NAMESPACE. It wraps FiledDeclaracionObservation and IvaCompensationWalletObservation payloads in Envelope records before writing them to their dedicated FINANCIAL namespaces through SecureObjectRepository.

Parameters:
persist_artefact(observation_key, artefact, body)[source]

Persist one captured artefact and return its FiledDeclaracionArtefact storage reference.

Artefact bytes are stored under adapters.persistence.storage.AEAT_FILED_DECLARATION_ARTEFACTS_NAMESPACE using the body SHA-256 as the natural object key.

Return type:

FiledDeclaracionArtefact

Parameters:
load_artefact(storage_ref)[source]

Return plaintext artefact bytes from an encrypted storage reference.

The reference resolves into adapters.persistence.storage.AEAT_FILED_DECLARATION_ARTEFACTS_NAMESPACE.

Return type:

bytes

Parameters:

storage_ref (str)

persist_observation(observation)[source]

Persist a normalized observation manifest and return its logical object path.

The envelope row is stored under adapters.persistence.storage.AEAT_FILED_DECLARATION_OBSERVATIONS_NAMESPACE.

Return type:

Path

Parameters:

observation (FiledDeclaracionObservation)

load_observation(path)[source]

Load and decrypt a FiledDeclaracionObservation from the encrypted store.

The encrypted row is read from adapters.persistence.storage.AEAT_FILED_DECLARATION_OBSERVATIONS_NAMESPACE.

Return type:

FiledDeclaracionObservation

Parameters:

path (Path)

list_observations()[source]

Return FiledDeclaracionObservation records from the active encrypted backend.

Rows are scanned from adapters.persistence.storage.AEAT_FILED_DECLARATION_OBSERVATIONS_NAMESPACE.

Return type:

tuple[FiledDeclaracionObservation, ...]

persist_iva_wallet_observation(observation)[source]

Persist a read-only IVA wallet observation and return its logical path.

The envelope row is stored under adapters.persistence.storage.AEAT_IVA_WALLET_OBSERVATIONS_NAMESPACE.

Return type:

Path

Parameters:

observation (IvaCompensationWalletObservation)

load_iva_wallet_observation(path)[source]

Load and decrypt an IvaCompensationWalletObservation from path.

The encrypted row is read from adapters.persistence.storage.AEAT_IVA_WALLET_OBSERVATIONS_NAMESPACE.

Return type:

IvaCompensationWalletObservation

Parameters:

path (Path)

list_iva_wallet_observations()[source]

Return IvaCompensationWalletObservation records from the active encrypted backend.

Rows are scanned from adapters.persistence.storage.AEAT_IVA_WALLET_OBSERVATIONS_NAMESPACE.

Return type:

tuple[IvaCompensationWalletObservation, ...]

filed_declaracion_observation_object_key(modelo, ejercicio, period, expediente_id)[source]

Return the secure-object natural key for a filed-declaration observation.

The key is the hash grammar declared by adapters.persistence.storage.AEAT_FILED_DECLARATION_OBSERVATIONS_NAMESPACE.

Return type:

str

Parameters:
iva_compensation_wallet_observation_object_key(taxpayer_nif, target_year, target_period, captured_at)[source]

Return the secure-object natural key for an IVA-wallet observation.

The key is the hash grammar declared by adapters.persistence.storage.AEAT_IVA_WALLET_OBSERVATIONS_NAMESPACE.

Return type:

str

Parameters:
  • taxpayer_nif (str)

  • target_year (int)

  • target_period (Period)

  • captured_at (str)