aeat.application.live._filed_observation_persistence module¶
Persist filed AEAT observations into calculation-history repositories.
Filed Sede rows are promoted to registry-grounded CasillaObservation
records, matching ModeloRecord filings are stamped with justificante
evidence, and the enrolment is appended through
BucketEventHistoryRepository.
The module treats AEAT live captures as official external evidence only after
the captured justificante matches the filed observation and an existing current
ModeloRecord. It never creates the filing record itself and refuses to
overwrite conflicting ExternalEvidence.
See also
aeat.domain.modelos.ExternalEvidenceKindClosed evidence-kind catalogue; live captures stamp
AEAT_LIVE_CAPTURE.aeat.application.calculations.CalculationObservationRepositoryRepository that receives the registry-grounded filed-declaration observations consumed by cross-period resolvers.
- class FiledJustificanteEnrollmentResult(justificante_csvs=(), filing_record_ids=(), conflicting_filing_record_ids=())[source]¶
Bases:
objectJustificante metadata and current filing records enrolled from filed history.
- Parameters:
- persist_filed_calculation_observation(observation, *, repository=None, justificante_csvs=())[source]¶
Promote one AEAT filed-declaration observation into calculation history.
The persisted row is a registry-grounded
aeat.domain.calculations.registry.RegistryModeloObservationstamped with the law-selected registry revision when it can be resolved.- Return type:
- Parameters:
observation (FiledDeclaracionObservation)
repository (CalculationObservationRepository | None)
- persist_latest_filed_calculation_observations(observations, *, justificante_csvs_by_observation=None)[source]¶
Persist only the latest captured observation per modelo/year/period.
- persist_filed_justificante_metadata(observation, *, store, repository=None)[source]¶
Persist parsed justificante metadata from a filed-declaration observation.
The observation store owns encrypted artefact bytes. This function reads those bytes into memory, verifies the artefact manifest, parses the PDF without creating a plaintext temp file, and saves only justificantes that match the observation’s modelo, ejercicio, typed period, and authenticated taxpayer identity.
- Return type:
- Parameters:
observation (FiledDeclaracionObservation)
store (FiledDeclaracionObservationStore)
repository (JustificanteRepository | None)
- enroll_filed_justificante_evidence(observation, *, store, bucket_id, justificante_repository=None, filing_repository=None)[source]¶
Persist matching justificante metadata and stamp matching current filings.
A filing is stamped only when the parsed
Justificantematches the observation, the authenticated identity, and the currentModeloRecord. Existing matching evidence is accepted idempotently; conflicting evidence is reported rather than overwritten.- Return type:
- Returns:
A
FiledJustificanteEnrollmentResultof saved CSVs and stamped filing records.- Parameters:
observation (FiledDeclaracionObservation)
store (FiledDeclaracionObservationStore)
bucket_id (str)
justificante_repository (JustificanteRepository | None)
filing_repository (ModeloRecordCatalogueRepositoryProtocol | None)
- persist_iva_compensation_history_observations_strict(observations)[source]¶
Persist latest Modelo 303 observations and verify each history row reloads.
- Return type:
- Parameters:
observations (tuple[FiledDeclaracionObservation, ...])
- latest_declarations_by_period(declarations)[source]¶
Return the latest
Declaracionper period from register rows.- Return type:
- Parameters:
declarations (tuple[Declaracion, ...])