aeat.application.overview._calendar_evidence module¶
Calendar event dedup and filing-evidence reconciliation for the overview read model.
Extracted from _calendar (size-budget
split) to keep the calendar module and its build_overview_calendar
entry point under their line-count overrides. This module owns two
cohesive concerns:
Deterministic dedup of observed
OverviewCalendarEventrows across multiple local snapshots (_calendar_event_sort_key,_dedupe_calendar_events), shared by every calendar-events builder.Reconciling already-loaded local and AEAT-side signals – filed Modelo records, observed register events, filed-declaration observations, persisted calculation observations, live justificante captures, and loaded justificante metadata – into typed
OverviewCalendarFilingEvidencerows (calendar_filing_evidence_from_sources()), and merging that evidence back onto calendar entries and events.
This module is local-only and pure with respect to I/O, exactly like its parent: it never starts a live AEAT read and never verifies a justificante by fetching external state; it only reconciles evidence the caller has already loaded.
See also
aeat.application.overview._calendarComposes
calendar_filing_evidence_from_sources()and the other builders here intobuild_overview_calendar().aeat.application.overviewPublic facade that re-exports
calendar_filing_evidence_from_sources().
- calendar_filing_evidence_from_sources(*, filing_records=(), observed_events=(), filed_declaration_observations=(), verified_filed_declaration_artefact_refs=(), verified_filed_declaration_artefact_csvs=None, calculation_observations=(), justificante_capture_snapshots=(), justificantes=(), expected_tax_id=None)[source]¶
Build
OverviewCalendarFilingEvidencefrom local records and observed AEAT signals.The function is pure and intentionally accepts already-loaded records. CLI/storage code owns I/O; this projection only reconciles the existing local
ModeloRecordcatalogue, calendar-visible AEAT register events,FiledDeclaracionObservationrows, persisted calculation observations from justificante capture,JustificanteCaptureSnapshotrows, and already-loaded justificante metadata. Thefiling_recordsare filedModeloRecordrows whose external justificante references are only promoted tojustificante_verifiedwhen matching persisted metadata exists for the same CSV/model/year/period/taxpayer. Filed-declaration observations are only promoted tojustificante_verifiedwhen their justificante artefact storage reference is listed inverified_filed_declaration_artefact_refsby the storage layer that loaded and hashed the encrypted artefact body.The result keeps
OverviewLocalFilingStateandOverviewAeatSubmissionStateindependent so imported AEAT baselines, local filings, observed submissions, and verified justificantes do not overwrite each other’s meaning.- Return type:
- Parameters:
filing_records (tuple[ModeloRecord, ...])
observed_events (tuple[OverviewCalendarEvent, ...])
filed_declaration_observations (tuple[FiledDeclaracionObservation, ...])
verified_filed_declaration_artefact_csvs (Mapping[str, str] | None)
justificante_capture_snapshots (tuple[JustificanteCaptureSnapshot, ...])
justificantes (tuple[Justificante, ...])
expected_tax_id (str | None)