aeat.domain.calculations.registry._snapshot module

Immutable snapshot creation for registry-backed calculations.

Validates a ModeloDefinition and selects the matching ModeloRevision for a filing context, then assembles the immutable RegistrySnapshot that downstream consumers (formula engine, export resolver, coverage auditor) depend on.

This module only has the supplied modelo and catalogues. Cross-model relation closure needs the full registry tree and is enforced by ValidatedRegistryAuthority / RegistryValidator.validate_registry() before production snapshots are served.

build_snapshot(modelo, catalogues, *, source_root, filing_year, period, on=None, revision_id=None)[source]

Validate modelo and return the selected immutable snapshot.

This helper performs model-local validation and snapshot-local reference checks. It cannot validate cross-model relation closure because it does not receive the full modelo tree; production callers should request snapshots through ValidatedRegistryAuthority.

Parameters:
  • modelo (ModeloDefinition) – The ModeloDefinition to validate and snapshot.

  • catalogues (RegistryCatalogues) – Legal and source catalogues for validation.

  • source_root (Path) – Filesystem root for resolving source artefacts.

  • filing_year (int) – The filing year to select a revision for.

  • period (str) – The filing period to select a revision for.

  • on (date | None) – Optional reference date for revision selection.

  • revision_id (str | None) – Optional explicit revision identifier to select.

Return type:

RegistrySnapshot

Returns:

The validated RegistrySnapshot for the requested filing context.

build_validated_snapshot(modelo, catalogues, *, filing_year, period, on=None, revision_id=None)[source]

Return a selected RegistrySnapshot for an already validated modelo.

The precondition is model-local. Callers that need cross-model relation closure must validate the full registry tree first, normally by using ValidatedRegistryAuthority.

Parameters:
  • modelo (ModeloDefinition) – The validated ModeloDefinition whose revision is selected.

  • catalogues (RegistryCatalogues) – Legal and source catalogues used to populate the snapshot.

  • filing_year (int) – The filing year to select a revision for.

  • period (str) – The filing period to select a revision for.

  • on (date | None) – Optional reference date for revision selection.

  • revision_id (str | None) – Optional explicit revision identifier to select.

Return type:

RegistrySnapshot

Returns:

The selected RegistrySnapshot.