aeat.application.live package¶
Application facade for explicit read-only AEAT live workflows.
Every remote navigation path enters through the live-read access gate before it
authenticates or opens an AEAT sede surface. Most surfaces use
_session.active_verified_session(); IVA remote-state
acquisition enforces the same read gate before coordinating its filed-history and
wallet reads. The package has no live-submit surface: captured notifications,
expedientes, filed declarations, justificantes, IVA wallet rows, Borrador 100
snapshots, and verification checks are local evidence objects, not remote filing
mutations.
Live capture services persist encrypted active-bucket evidence through
adapters.persistence.storage.SecureObjectRepository or the
snapshot repositories re-exported by this facade. Parsed filed-declaration
observations are typed as
domain.calculations.registry.CasillaObservation rows and routed
through domain.calculations.registry.ValidatedRegistryAuthority
to bind them to the correct revision. Justificante capture may stamp the
matching current domain.modelos.ModeloRecord with
domain.modelos.ExternalEvidence only after the local filing record
already exists.
Snapshot payloads that depend on an authenticated taxpayer carry a normalised
authenticated_identity when the upstream AEAT session exposes it. The
notifications snapshot id includes that identity so captures from different
taxpayers do not collapse to the same local row; expedientes and notifications
calendar projection compares the snapshot identity and row-level taxpayer ids
against the expected active-profile tax id before surfacing observed events.
Persisted capture/enrolment orchestration emits bucket events with sanitized
summary payloads; non-persisting read/list surfaces remain event-free.
IVA remote-state helpers separate stored-evidence reads from live acquisition.
load_iva_remote_state() returns the local
IvaRemoteStateStoredEvidenceReport without
contacting AEAT, while
capture_iva_remote_state() returns an
IvaRemoteStateAcquisitionReport, persists a
redacted IvaRemoteStateAcquisitionManifest, and
reports each remote surface independently so partial failures remain explicit.
See also
enroll_filed_justificante_evidence()Filed-history path that persists justificante metadata and stamps current filing records with live-capture evidence.
SecureSnapshotRepositoryBucket-scoped encrypted snapshot repository base used by live snapshot services.
application.overviewLocal-only summary surface that reads captured live evidence without contacting AEAT and filters calendar events by active-profile identity.
- class JustificanteCaptureOutcome(snapshot, justificante, filing_record)[source]¶
Bases:
objectOutcome of one live justificante pull and local filing-evidence enrolment.
The
JustificanteCaptureSnapshotis always the persisted live evidence.justificanteis populated only when the PDF parsed into domain metadata, andfiling_recordis populated only when an existing currentdomain.modelos.ModeloRecordcould be stamped with livedomain.modelos.ExternalEvidence.- Parameters:
snapshot (JustificanteCaptureSnapshot)
justificante (Justificante | None)
filing_record (ModeloRecord | None)
-
snapshot:
JustificanteCaptureSnapshot¶
-
justificante:
Justificante|None¶
-
filing_record:
ModeloRecord|None¶
- property justificante_metadata_registered: bool¶
Return whether the captured receipt parsed into stored justificante metadata.
- async capture_expedientes(*, bucket_id, modelo, year)[source]¶
Live-walk the AEAT declaration register and persist a bucket-scoped snapshot.
Uses
walk_declarations_register(the same register adapter the filed-data list/capture verbs drive), wraps the typed declarations in anExpedientesCapture, and persists throughExpedientesServiceagainst the active bucket. The helper obtains its session via_session.active_verified_session(), so the read access gate is enforced before any remote contact.
- async capture_expedientes_bulk(*, bucket_id, year_from, year_to, modelos=None)[source]¶
Live-walk AEAT declaration-register rows and return an
ExpedientesBulkCaptureReport.
- async capture_notifications(*, bucket_id)[source]¶
Live-fetch DEHú notifications and persist a bucket-scoped snapshot.
The flow is:
_AeatAccessGate.require_live_read()— keeps pytest live reads behind the live-test opt-in while allowing operator reads to continue to auth/profile/read-only guards._ensure_authenticated_aeat_session(operation="live-notifications-read")— acquires or refreshes the authenticated session (e.g. triggers a Cl@ve Móvil push).fetch_notifications_query— drives Playwright against the authenticated DEHú surface and parses the HTML response.NotificationsService.capture— persists the typed snapshot in the active bucket under theaeat.application.live.notificationsnamespace.Bucket event
live.notifications.snapshot_capturedis emitted by the caller through the standard bucket-event repository so this function stays unit-testable against a stubbed snapshot.
- Parameters:
bucket_id (
str) – The active profile bucket id the notification snapshot is scoped to.- Returns:
A tuple of (snapshot_id, fetched_row_count, persisted_at).
- async capture_justificante_snapshot(*, bucket_id, modelo, year, period, session_provider=<function _default_justificante_session>, declarations_provider=<function _default_justificante_declarations>, expedientes_provider=<function _default_justificante_expedientes>, justificante_provider=<function _default_justificante_capture>)[source]¶
Live-pull the AEAT justificante for one work unit and persist it.
The flow gates entry through
_active_verified_session(therequire_live_read+ authenticated-session boundary), resolves the period-correct expediente by cross-referencing the period-bearing declarations register against the procedure tree (resolve_period_expediente()), pulls the signed PDF viacapture_justificante, and persists it throughJustificanteCaptureSnapshotServiceunder the active bucket.The four
*_providerseams default to the live sede implementations; tests inject canned typed records to exercise the wiring offline without a network round-trip. The persistence path always uses the real service.- Return type:
- Returns:
The persisted
JustificanteCaptureSnapshot.- Parameters:
bucket_id (str)
modelo (str)
year (int)
period (Period)
session_provider (Callable[[], Awaitable[tuple[AeatSession, Settings]]])
declarations_provider (Callable[[...], Awaitable[Sequence[Declaracion]]])
expedientes_provider (Callable[[...], Awaitable[Sequence[Expediente]]])
justificante_provider (Callable[[...], Awaitable[SedeCapture]])
- async capture_justificante_snapshot_outcome(*, bucket_id, modelo, year, period, session_provider=<function _default_justificante_session>, declarations_provider=<function _default_justificante_declarations>, expedientes_provider=<function _default_justificante_expedientes>, justificante_provider=<function _default_justificante_capture>)[source]¶
Live-pull one AEAT justificante and report local filing-evidence enrolment.
The persisted
JustificanteCaptureSnapshotis the durable evidence. Metadata registration and current-record evidence stamping are best-effort follow-up steps reported separately inJustificanteCaptureOutcome. A missing local filing record does not discard the captured receipt.- Return type:
- Returns:
A
JustificanteCaptureOutcomewith the capture and enrolment result.- Parameters:
bucket_id (str)
modelo (str)
year (int)
period (Period)
session_provider (Callable[[], Awaitable[tuple[AeatSession, Settings]]])
declarations_provider (Callable[[...], Awaitable[Sequence[Declaracion]]])
expedientes_provider (Callable[[...], Awaitable[Sequence[Expediente]]])
justificante_provider (Callable[[...], Awaitable[SedeCapture]])
Submodules¶
- aeat.application.live._borrador_100 module
BorradorSnapshotNotFoundErrorBorrador100SnapshotBorrador100Snapshot.snapshot_idBorrador100Snapshot.bucket_idBorrador100Snapshot.modeloBorrador100Snapshot.filing_yearBorrador100Snapshot.periodBorrador100Snapshot.captured_atBorrador100Snapshot.source_urlBorrador100Snapshot.stateBorrador100Snapshot.binding_valuesBorrador100Snapshot.superseded_by_snapshot_idBorrador100Snapshot.discarded_atBorrador100Snapshot.discarded_byBorrador100Snapshot.discard_reason
borrador_100_snapshot_object_key()derive_borrador_100_snapshot_id()Borrador100SnapshotRepositoryBorrador100SnapshotService
- aeat.application.live._censo module
- aeat.application.live._errors module
LiveIvaAcquisitionFailureModeLiveIvaAcquisitionFailureMode.AUTHENTICATEDLiveIvaAcquisitionFailureMode.NO_CLAVE_PROMPTLiveIvaAcquisitionFailureMode.OPERATOR_TIMEOUTLiveIvaAcquisitionFailureMode.QR_REQUIREDLiveIvaAcquisitionFailureMode.CERTIFICATE_REQUIREDLiveIvaAcquisitionFailureMode.WRONG_IDENTITYLiveIvaAcquisitionFailureMode.AEAT_403LiveIvaAcquisitionFailureMode.DOM_DRIFTLiveIvaAcquisitionFailureMode.PENDING_CLAVE_REQUESTLiveIvaAcquisitionFailureMode.LIVE_NAVIGATION_FAILEDLiveIvaAcquisitionFailureMode.UNKNOWN
LiveApplicationErrorLiveApplicationInputErrorLiveIvaSurfaceTimeoutErrorclassify_live_iva_acquisition_failure()
- aeat.application.live._expedientes module
- aeat.application.live._filed_data module
- aeat.application.live._filed_data_capture module
- aeat.application.live._filed_observation_persistence module
- aeat.application.live._iva_remote_state module
IvaRemoteStateAcquisitionManifestRepositorylist_iva_compensation_history()load_iva_remote_state()capture_iva_compensation_history()persist_and_reconcile_iva_compensation_wallet()capture_iva_compensation_wallet()capture_iva_remote_state()build_iva_remote_state_acquisition_report()persist_iva_remote_state_acquisition_report()load_iva_remote_state_acquisition_manifest()list_iva_remote_state_acquisition_manifests()
- aeat.application.live._justificante module
JustificanteCaptureSnapshotNotFoundErrorJustificanteCaptureSnapshotJustificanteCaptureSnapshot.snapshot_idJustificanteCaptureSnapshot.bucket_idJustificanteCaptureSnapshot.modeloJustificanteCaptureSnapshot.filing_yearJustificanteCaptureSnapshot.periodJustificanteCaptureSnapshot.expediente_idJustificanteCaptureSnapshot.csvJustificanteCaptureSnapshot.pdf_sha256JustificanteCaptureSnapshot.pdf_base64JustificanteCaptureSnapshot.source_kindJustificanteCaptureSnapshot.captured_atJustificanteCaptureSnapshot.stateJustificanteCaptureSnapshot.superseded_by_snapshot_idJustificanteCaptureSnapshot.discarded_atJustificanteCaptureSnapshot.discarded_byJustificanteCaptureSnapshot.discard_reasonJustificanteCaptureSnapshot.decoded_pdf_bytes()
justificante_capture_snapshot_object_key()derive_justificante_capture_snapshot_id()resolve_period_expediente()JustificanteCaptureSnapshotRepositoryJustificanteCaptureSnapshotServiceparse_capture_to_justificante()register_capture_justificante_metadata()reconcile_capture()register_capture_as_filing_evidence()stamp_capture_evidence_if_filed()
- aeat.application.live._notifications module
NotificationsSnapshotNotFoundErrorPersistedNotificationsSnapshotPersistedNotificationsSnapshot.snapshot_idPersistedNotificationsSnapshot.bucket_idPersistedNotificationsSnapshot.captured_atPersistedNotificationsSnapshot.source_urlPersistedNotificationsSnapshot.authenticated_identityPersistedNotificationsSnapshot.rowsPersistedNotificationsSnapshot.persisted_at
notifications_snapshot_object_key()NotificationsService
- aeat.application.live._remote_state_models module
FiledDataCaptureReportFiledDataCaptureReport.output_rootFiledDataCaptureReport.modeloFiledDataCaptureReport.yearFiledDataCaptureReport.captured_countFiledDataCaptureReport.observation_pathsFiledDataCaptureReport.artefact_refsFiledDataCaptureReport.justificante_metadata_countFiledDataCaptureReport.justificante_csvsFiledDataCaptureReport.filing_evidence_stamped_countFiledDataCaptureReport.filing_record_idsFiledDataCaptureReport.filing_evidence_conflict_countFiledDataCaptureReport.filing_evidence_conflict_record_idsFiledDataCaptureReport.casilla_countFiledDataCaptureReport.calculation_observation_countFiledDataCaptureReport.calculation_observation_keys
FiledDataCaptureFailureRowBulkFiledDataCaptureReportBulkFiledDataCaptureReport.output_rootBulkFiledDataCaptureReport.modelosBulkFiledDataCaptureReport.year_fromBulkFiledDataCaptureReport.year_toBulkFiledDataCaptureReport.captured_countBulkFiledDataCaptureReport.failed_countBulkFiledDataCaptureReport.observation_pathsBulkFiledDataCaptureReport.artefact_refsBulkFiledDataCaptureReport.justificante_metadata_countBulkFiledDataCaptureReport.justificante_csvsBulkFiledDataCaptureReport.filing_evidence_stamped_countBulkFiledDataCaptureReport.filing_record_idsBulkFiledDataCaptureReport.filing_evidence_conflict_countBulkFiledDataCaptureReport.filing_evidence_conflict_record_idsBulkFiledDataCaptureReport.casilla_countBulkFiledDataCaptureReport.calculation_observation_countBulkFiledDataCaptureReport.calculation_observation_keysBulkFiledDataCaptureReport.failures
ExpedientesBulkCaptureFailureRowExpedientesBulkCaptureReportExpedientesBulkCaptureReport.bucket_idExpedientesBulkCaptureReport.modelosExpedientesBulkCaptureReport.year_fromExpedientesBulkCaptureReport.year_toExpedientesBulkCaptureReport.captured_snapshot_countExpedientesBulkCaptureReport.declaration_countExpedientesBulkCaptureReport.snapshot_idsExpedientesBulkCaptureReport.failures
SourceFiledDataCaptureReportSourceFiledDataCaptureReport.output_rootSourceFiledDataCaptureReport.target_modeloSourceFiledDataCaptureReport.target_yearSourceFiledDataCaptureReport.target_periodSourceFiledDataCaptureReport.captured_countSourceFiledDataCaptureReport.observation_pathsSourceFiledDataCaptureReport.artefact_refsSourceFiledDataCaptureReport.justificante_metadata_countSourceFiledDataCaptureReport.justificante_csvsSourceFiledDataCaptureReport.filing_evidence_stamped_countSourceFiledDataCaptureReport.filing_record_idsSourceFiledDataCaptureReport.filing_evidence_conflict_countSourceFiledDataCaptureReport.filing_evidence_conflict_record_idsSourceFiledDataCaptureReport.casilla_countSourceFiledDataCaptureReport.calculation_observation_countSourceFiledDataCaptureReport.calculation_observation_keys
IvaWalletCaptureReportIvaWalletCaptureReport.taxpayer_refIvaWalletCaptureReport.target_yearIvaWalletCaptureReport.target_periodIvaWalletCaptureReport.observation_pathIvaWalletCaptureReport.decision_keyIvaWalletCaptureReport.row_countIvaWalletCaptureReport.total_pendingIvaWalletCaptureReport.selected_authorityIvaWalletCaptureReport.selected_amountIvaWalletCaptureReport.local_recurrence_amountIvaWalletCaptureReport.divergenceIvaWalletCaptureReport.blockedIvaWalletCaptureReport.captured_at
IvaCompensationHistoryRowIvaCompensationHistoryRow.yearIvaCompensationHistoryRow.periodIvaCompensationHistoryRow.statusIvaCompensationHistoryRow.presented_atIvaCompensationHistoryRow.prior_pending_amountIvaCompensationHistoryRow.applied_amountIvaCompensationHistoryRow.pending_for_later_amountIvaCompensationHistoryRow.period_result_amountIvaCompensationHistoryRow.final_result_amountIvaCompensationHistoryRow.generated_amountIvaCompensationHistoryRow.available_end_amount
IvaCompensationCarryForwardLotRowIvaCompensationCarryForwardLotRow.taxpayer_refIvaCompensationCarryForwardLotRow.source_filing_yearIvaCompensationCarryForwardLotRow.source_periodIvaCompensationCarryForwardLotRow.generated_amountIvaCompensationCarryForwardLotRow.applied_amountIvaCompensationCarryForwardLotRow.remaining_amountIvaCompensationCarryForwardLotRow.age_yearsIvaCompensationCarryForwardLotRow.expiry_review_stateIvaCompensationCarryForwardLotRow.source_observation_key
IvaWalletAuthorityDecisionRowIvaWalletAuthorityDecisionRow.taxpayer_refIvaWalletAuthorityDecisionRow.target_yearIvaWalletAuthorityDecisionRow.target_periodIvaWalletAuthorityDecisionRow.selected_authorityIvaWalletAuthorityDecisionRow.selected_amountIvaWalletAuthorityDecisionRow.wallet_amountIvaWalletAuthorityDecisionRow.local_recurrence_amountIvaWalletAuthorityDecisionRow.override_amountIvaWalletAuthorityDecisionRow.divergenceIvaWalletAuthorityDecisionRow.blockedIvaWalletAuthorityDecisionRow.stale_walletIvaWalletAuthorityDecisionRow.reasonIvaWalletAuthorityDecisionRow.wallet_captured_atIvaWalletAuthorityDecisionRow.decided_atIvaWalletAuthorityDecisionRow.authority_sources
IvaCompensationHistoryReportIvaCompensationHistoryReport.row_countIvaCompensationHistoryReport.rowsIvaCompensationHistoryReport.as_of_yearIvaCompensationHistoryReport.carry_forward_lot_countIvaCompensationHistoryReport.carry_forward_lotsIvaCompensationHistoryReport.unallocated_applied_amountIvaCompensationHistoryReport.authority_decision_countIvaCompensationHistoryReport.authority_decisions
StoredIvaWalletObservationRowStoredIvaRemoteStateAcquisitionRowStoredIvaRemoteStateAcquisitionRow.acquisition_refStoredIvaRemoteStateAcquisitionRow.captured_atStoredIvaRemoteStateAcquisitionRow.auth_statusStoredIvaRemoteStateAcquisitionRow.auth_outcome_modeStoredIvaRemoteStateAcquisitionRow.auth_failure_modeStoredIvaRemoteStateAcquisitionRow.auth_failure_typeStoredIvaRemoteStateAcquisitionRow.auth_diagnostic_refStoredIvaRemoteStateAcquisitionRow.auth_provider_kindStoredIvaRemoteStateAcquisitionRow.auth_reused_persisted_sessionStoredIvaRemoteStateAcquisitionRow.year_fromStoredIvaRemoteStateAcquisitionRow.year_toStoredIvaRemoteStateAcquisitionRow.target_yearStoredIvaRemoteStateAcquisitionRow.target_periodStoredIvaRemoteStateAcquisitionRow.filed_history_succeededStoredIvaRemoteStateAcquisitionRow.wallet_succeededStoredIvaRemoteStateAcquisitionRow.surfaces
IvaRemoteStateStoredEvidenceReportIvaCompensationHistoryCaptureReportIvaCompensationHistoryCaptureReport.output_rootIvaCompensationHistoryCaptureReport.year_fromIvaCompensationHistoryCaptureReport.year_toIvaCompensationHistoryCaptureReport.captured_countIvaCompensationHistoryCaptureReport.observation_pathsIvaCompensationHistoryCaptureReport.artefact_refsIvaCompensationHistoryCaptureReport.casilla_countIvaCompensationHistoryCaptureReport.calculation_observation_countIvaCompensationHistoryCaptureReport.calculation_observation_keysIvaCompensationHistoryCaptureReport.reloaded_history_countIvaCompensationHistoryCaptureReport.reloaded_rowsIvaCompensationHistoryCaptureReport.failed_declaration_countIvaCompensationHistoryCaptureReport.failed_declarations
LiveIvaReadSurfaceLiveIvaReadStatusLiveIvaReadOutcomeLiveIvaAuthOutcomeIvaRemoteStateAcquisitionReportIvaRemoteStateAcquisitionReport.acquisition_manifest_idIvaRemoteStateAcquisitionReport.output_rootIvaRemoteStateAcquisitionReport.year_fromIvaRemoteStateAcquisitionReport.year_toIvaRemoteStateAcquisitionReport.target_yearIvaRemoteStateAcquisitionReport.target_periodIvaRemoteStateAcquisitionReport.authIvaRemoteStateAcquisitionReport.filed_historyIvaRemoteStateAcquisitionReport.walletIvaRemoteStateAcquisitionReport.outcomesIvaRemoteStateAcquisitionReport.filed_history_succeededIvaRemoteStateAcquisitionReport.wallet_succeeded
IvaRemoteStateAcquisitionSurfaceManifestIvaRemoteStateAcquisitionSurfaceManifest.surfaceIvaRemoteStateAcquisitionSurfaceManifest.statusIvaRemoteStateAcquisitionSurfaceManifest.outcome_modeIvaRemoteStateAcquisitionSurfaceManifest.failure_modeIvaRemoteStateAcquisitionSurfaceManifest.failure_typeIvaRemoteStateAcquisitionSurfaceManifest.failure_contextIvaRemoteStateAcquisitionSurfaceManifest.captured_countIvaRemoteStateAcquisitionSurfaceManifest.calculation_observation_countIvaRemoteStateAcquisitionSurfaceManifest.reloaded_history_countIvaRemoteStateAcquisitionSurfaceManifest.wallet_row_countIvaRemoteStateAcquisitionSurfaceManifest.decision_refIvaRemoteStateAcquisitionSurfaceManifest.selected_authorityIvaRemoteStateAcquisitionSurfaceManifest.divergenceIvaRemoteStateAcquisitionSurfaceManifest.blocked
IvaRemoteStateAcquisitionManifestIvaRemoteStateAcquisitionManifest.acquisition_idIvaRemoteStateAcquisitionManifest.captured_atIvaRemoteStateAcquisitionManifest.year_fromIvaRemoteStateAcquisitionManifest.year_toIvaRemoteStateAcquisitionManifest.target_yearIvaRemoteStateAcquisitionManifest.target_periodIvaRemoteStateAcquisitionManifest.authIvaRemoteStateAcquisitionManifest.filed_history_succeededIvaRemoteStateAcquisitionManifest.wallet_succeededIvaRemoteStateAcquisitionManifest.surfaces
- aeat.application.live._remote_state_outcomes module
- aeat.application.live._session module
- aeat.application.live._snapshot_base module
- aeat.application.live._verify module