cadrumo.adapters.outbound.aeat.sede.filed_observation_persistence module¶
Concrete adapters for the filed-observation application ports.
The live filed-history service owns only protocols. This module is the outer binding for those protocols: it joins the existing Sede parser and observation store to the encrypted calculation, filing, IVA-history, event, and baseline repositories and the filing-chain reconciliation. Adapter failures are translated at this boundary so an application caller never has to know a Sede or secure-object exception type.
Core types:
ModeloRecord,
SecureObjectRepository.
- class FiledObservationParserAdapter(*args, **kwargs)[source]¶
Bases:
FiledObservationParserPortAdapt receipt parsing and Sede CSV extraction to application types.
- class FiledDeclarationTransformationAdapter(*, operation)[source]¶
Bases:
FiledDeclarationTransformationPortAdapt Sede observation projections to registry-grounded application ports.
- Parameters:
operation (PinnedAuthorityOperation)
- registry_observation(observation)[source]¶
Build the registry-grounded numeric projection.
- Return type:
- Parameters:
observation (FiledObservationProtocol)
- non_numeric_casillas(observation)[source]¶
Return non-numeric observed casillas for the operator projection.
- Return type:
- Parameters:
observation (FiledObservationProtocol)
- class FiledObservationStoreAdapter(*, root, objects)[source]¶
Bases:
FiledObservationPersistencePortAdapt the encrypted Sede observation store to the application port.
- Parameters:
root (Path)
objects (SecureObjectRepository)
- persist_observation(observation)[source]¶
Persist one encrypted observation manifest.
- Return type:
Path- Parameters:
observation (FiledObservationProtocol)
- class CalculationObservationRepositoryAdapter(*, repository)[source]¶
Bases:
FiledCalculationObservationRepositoryPortAdapt the encrypted calculation-observation repository.
- Parameters:
repository (CalculationObservationRepository)
- load_observation(modelo, period)[source]¶
Load one existing calculation-observation envelope.
- Return type:
- Parameters:
- prepare_observation_envelope(observation, *, source_kind, stamped_revision_id, captured_at=None, source_metadata=None, source_headers=())[source]¶
Prepare one validated calculation-observation envelope.
- Return type:
- Parameters:
observation (RegistryModeloObservation)
source_kind (ObservationSourceKind | str)
stamped_revision_id (str)
captured_at (datetime | None)
source_headers (tuple[ObservedHeaderFact, ...])
- save(payload)[source]¶
Persist one prepared calculation-observation envelope.
- Return type:
- Parameters:
payload (ObservationEnvelopePayload)
- class IvaHistoryRepositoryAdapter(*, repository)[source]¶
Bases:
FiledIvaHistoryRepositoryPortAdapt the encrypted IVA compensation-history repository.
- Parameters:
repository (IvaCompensationHistoryRepository)
- class IvaObservationPersistenceAdapter(*args, **kwargs)[source]¶
Bases:
FiledIvaObservationPersistencePortAdapt the canonical atomic Modelo 303/history co-commit operation.
- persist(*, observation_repository, history_repository, envelope, taxpayer_nif, source_observation_key, expediente_id, status, source_artefact_sha256)[source]¶
Atomically persist the calculation envelope and IVA history state.
- Return type:
- Parameters:
observation_repository (FiledCalculationObservationRepositoryPort)
history_repository (FiledIvaHistoryRepositoryPort)
envelope (ObservationEnvelopePayload)
taxpayer_nif (str)
source_observation_key (str)
expediente_id (str | None)
status (str | None)
source_artefact_sha256 (str | None)
- class JustificanteRepositoryAdapter(*, repository)[source]¶
Bases:
JustificanteRepositoryProtocolAdapt encrypted justificante metadata persistence.
- Parameters:
repository (JustificanteRepository)
- save(justificante, /)[source]¶
Persist one parsed receipt.
- Return type:
- Parameters:
justificante (Justificante)
- class FilingRepositoryAdapter(*, repository)[source]¶
Bases:
ModeloRecordCatalogueRepositoryProtocolAdapt encrypted modelo filing-record catalogue persistence.
- Parameters:
repository (ModeloRecordCatalogueRepository)
- save(catalogue)[source]¶
Persist the filing catalogue.
- Return type:
- Parameters:
catalogue (ModeloRecordCatalogue)
- mutate(mutation)[source]¶
Apply one guarded filing-catalogue mutation.
- Return type:
- Parameters:
mutation (Callable[[ModeloRecordCatalogue], ModeloRecordCatalogue])
- to_secure_object_write(catalogue, *, expected_revision_id=None)[source]¶
Prepare a filing-catalogue secure-object write.
- Return type:
- Parameters:
catalogue (ModeloRecordCatalogue)
expected_revision_id (str | None)
- save_with_secure_object_writes(catalogue, extra_writes, *, expected_revision_id=None)[source]¶
Persist filing state and co-emitted writes atomically.
- Return type:
- Parameters:
catalogue (ModeloRecordCatalogue)
extra_writes (tuple[SecureObjectWrite, ...])
expected_revision_id (str | None)
- class BucketEventRepositoryAdapter(*, repository)[source]¶
Bases:
BucketEventHistoryRepositoryProtocolAdapt encrypted bucket-event-history persistence.
- Parameters:
repository (BucketEventHistoryRepository)
- save(catalogue)[source]¶
Persist the event catalogue.
- Return type:
- Parameters:
catalogue (BucketEventHistoryCatalogue)
- to_secure_object_write(catalogue, *, expected_revision_id=None)[source]¶
Prepare an event-catalogue secure-object write.
- Return type:
- Parameters:
catalogue (BucketEventHistoryCatalogue)
expected_revision_id (str | None)
- class FilingReconciliationAdapter(*, work_lifecycle_ports, calculation_repository, filing_repository, justificante_repository, observation_repository)[source]¶
Bases:
FiledFilingReconciliationPortAdapt the filing-chain reconciliation service with explicit repositories.
- Parameters:
work_lifecycle_ports (WorkLifecyclePorts)
calculation_repository (CalculationRevisionCatalogueRepository)
filing_repository (ModeloRecordCatalogueRepository)
justificante_repository (JustificanteRepository)
observation_repository (CalculationObservationRepository)
- reconcile(entry, *, actor, clock)[source]¶
Reconcile one AEAT register entry under the bundled authority.
- Return type:
- Parameters:
entry (AeatRegisterEntry)
actor (str)
clock (datetime)