cadrumo.domain.calculations.registry.temporal module¶
Temporal selection for registry-backed modelo revisions.
Selects exactly one ModeloRevision from a ModeloDefinition
given a filing year, period, and optional date constraint.
- class RevisionSelectionMetadata(**data)[source]¶
Bases:
RegistryModelComplete immutable metadata required by the canonical revision selector.
- id: RevisionId¶
- valid_from: date¶
- valid_to: date | None¶
- period_selector: PeriodSelector¶
- deadline_windows: tuple[DeadlineWindowDefinition, ...]¶
- contains_date(coordinate)[source]¶
Return whether the coordinate lies inside the governed period window.
- classmethod from_revision(revision)[source]¶
Project exactly the fields consumed by temporal selection.
Core types:
ModeloRevision.- Return type:
- Parameters:
revision (ModeloRevision)
- class ModeloDirectoryMetadata(**data)[source]¶
Bases:
RegistryModelComplete modelo-level metadata without duplicating revision payloads.
- id: str¶
- title_localization_key: str¶
- official_name_localization_key: str¶
- tax_domain: str¶
- cadence: ModeloCadence¶
- jurisdiction: Literal['ES-AEAT']¶
- calculation_class: CalculationClassField¶
- output_sensitivity: SensitivityClassField¶
- capabilities: ModeloFilingCapabilities¶
- legal_refs: LegalRefs¶
- source_refs: SourceRefs¶
- inception: ModeloInceptionField | None¶
- pending_ejercicio_ordenes: PendingEjercicioOrdenes¶
- property title: str¶
Return the strict official-Spanish Modelo title, as the materialized view does.
- classmethod from_modelo(modelo)[source]¶
Capture every modelo field needed to reconstruct a selected snapshot.
Core types:
ModeloDefinition.- Return type:
- Parameters:
modelo (ModeloDefinition)
- class RevisionEndpointSourceEnrollment(**data)[source]¶
Bases:
RegistryModelSmall source-membership projection for one historical endpoint.
- revision_id: RevisionId¶
- source_refs: SourceRefs¶
- revision_endpoint_source_ids(modelo, revision)[source]¶
Return the compiler’s canonical source-enrollment basis for one endpoint.
Core types:
ModeloDefinition,ModeloRevision.- Return type:
- Parameters:
modelo (ModeloDefinition)
revision (ModeloRevision)
- class ModeloRevisionDirectory(**data)[source]¶
Bases:
RegistryModelPoint-addressed revision selection metadata for one modelo.
- modelo_id: str¶
- modelo: ModeloDirectoryMetadata¶
- revisions: tuple[RevisionSelectionMetadata, ...]¶
- endpoint_source_enrollments: tuple[RevisionEndpointSourceEnrollment, ...]¶
- pending_ejercicio_ordenes: tuple[PendingEjercicioOrden, ...]¶
- supported_filing_years: SupportedFilingYearsCatalogue | None¶
- endpoint_source_ids(revision_id)[source]¶
Return the admitted source ids for one exact revision endpoint.
- materialize(revision)[source]¶
Reconstruct one immutable modelo view around a selected revision of this directory.
The view carries only the selected payload; its revision-identity references still resolve against every revision this directory declares.
- Raises:
RegistryValidationError – When the view is not a valid modelo, for example when the revision references one its directory lacks.
- Parameters:
revision (ModeloRevision)
- Return type:
Core types:
ModeloRevision.- Return type:
- Parameters:
revision (ModeloRevision)
- classmethod from_modelo(modelo, *, support=None)[source]¶
Build a deterministic directory without embedding revision payloads.
Core types:
ModeloDefinition.- Return type:
- Parameters:
modelo (ModeloDefinition)
support (SupportedFilingYearsCatalogue | None)
- class RevisionTemporalResolution(revision, requested_filing_year, authored_filing_year, projection_direction)[source]¶
Bases:
GenericAn authored revision selected for one requested filing coordinate.
- Parameters:
revision (RevisionT)
requested_filing_year (int)
authored_filing_year (int)
projection_direction (TemporalProjectionDirection)
-
projection_direction:
TemporalProjectionDirection¶
- revision_temporal_resolution(revision, *, filing_year, period, support)[source]¶
Describe requested identity and authored provenance for a selected revision.
- Return type:
RevisionTemporalResolution[TypeVar(RevisionT, bound=_SelectableRevision)]- Parameters:
revision (RevisionT)
filing_year (int)
period (str | None)
support (SupportedFilingYearsCatalogue | None)
- select_revision_for_year(modelo, *, filing_year, on=None, support=None)[source]¶
Select exactly one revision for a filing year and effective date.
This is the year-only authority for read-only revision-wide surfaces such as bindings discovery. Callers that already have its revision may materialise a snapshot with that explicit
revision_idrather than independently selecting again.- Parameters:
modelo (
ModeloDefinition) – TheModeloDefinitionwhose declared revisions are searched for the one matchingfiling_yearandon.filing_year (
int) – AEAT filing year used to narrow revisions by theirperiod_selector.on (
date|None) – Optional reference date at which the revision must be the applicable design: inside the tax periods it governs, or inside a filing window it declares for this coordinate.support (
SupportedFilingYearsCatalogue|None) – Optional registry envelope that hard-gates the request and carries a year beyond its authored horizon back to that horizon.
- Return type:
- select_revision_metadata_for_year(directory, *, filing_year, on=None, support=None)[source]¶
Select metadata with the exact canonical year-scoped rules.
- Return type:
- Parameters:
directory (ModeloRevisionDirectory)
filing_year (int)
on (date | None)
support (SupportedFilingYearsCatalogue | None)
- select_revision(modelo, *, filing_year, period, on=None, revision_id=None, support=None)[source]¶
Select exactly one
ModeloRevisionfor a filing period.- Parameters:
modelo (
ModeloDefinition) – TheModeloDefinitionto select a revision from.filing_year (
int) – AEAT filing year used to narrow revisions byperiod_selector.period (
str) – Period token (e.g."1T","0A","ALTA"); case-insensitive against the revision’s declared periods.on (
date|None) – Optional reference date at which the revision must be the applicable design: inside the tax periods it governs, or inside a filing window it declares for this coordinate.revision_id (
TypeAliasType|None) – Optional explicit revision id; restricts candidates to the matching revision when supplied.support (
SupportedFilingYearsCatalogue|None) – Optional registry envelope that hard-gates the request and carries a year beyond its authored horizon back to that horizon.
- Return type:
- select_revision_metadata(directory, *, filing_year, period, on=None, revision_id=None, support=None)[source]¶
Select complete revision metadata through the canonical period rules.
- Return type:
- Parameters:
directory (ModeloRevisionDirectory)
filing_year (int)
period (str)
on (date | None)
revision_id (RevisionId | None)
support (SupportedFilingYearsCatalogue | None)
- select_authored_revision_metadata(directory, *, filing_year, period, on=None)[source]¶
Select the revision the law applies to a coordinate, outside the support envelope.
The support envelope gates what the product will FILE, not which design the law applied to a past period. Reading a carried prior filing needs the latter, so this selects only among revisions whose own period selector covers the exact coordinate and never projects a year onto another authored edition.
- Return type:
- Parameters:
directory (ModeloRevisionDirectory)
filing_year (int)
period (str)
on (date | None)