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.ExternalEvidenceKind

Closed evidence-kind catalogue; live captures stamp AEAT_LIVE_CAPTURE.

aeat.application.calculations.CalculationObservationRepository

Repository 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: object

Justificante metadata and current filing records enrolled from filed history.

Parameters:
  • justificante_csvs (tuple[str, ...])

  • filing_record_ids (tuple[str, ...])

  • conflicting_filing_record_ids (tuple[str, ...])

justificante_csvs: tuple[str, ...]
filing_record_ids: tuple[str, ...]
conflicting_filing_record_ids: tuple[str, ...]
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.RegistryModeloObservation stamped with the law-selected registry revision when it can be resolved.

Return type:

str

Parameters:
persist_latest_filed_calculation_observations(observations, *, justificante_csvs_by_observation=None)[source]

Persist only the latest captured observation per modelo/year/period.

Return type:

tuple[str, ...]

Parameters:
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:

tuple[str, ...]

Parameters:
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 Justificante matches the observation, the authenticated identity, and the current ModeloRecord. Existing matching evidence is accepted idempotently; conflicting evidence is reported rather than overwritten.

Return type:

FiledJustificanteEnrollmentResult

Returns:

A FiledJustificanteEnrollmentResult of saved CSVs and stamped filing records.

Parameters:
persist_iva_compensation_history_observations_strict(observations)[source]

Persist latest Modelo 303 observations and verify each history row reloads.

Return type:

tuple[str, ...]

Parameters:

observations (tuple[FiledDeclaracionObservation, ...])

latest_declarations_by_period(declarations)[source]

Return the latest Declaracion per period from register rows.

Return type:

tuple[Declaracion, ...]

Parameters:

declarations (tuple[Declaracion, ...])