cadrumo.domain.calculations.registry.orden_applicability module

The orden_aplicabilidad gate for a ModeloRevision.

Every revision’s orden_aplicabilidad field declares the legal-catalogue LegalReference id(s) of the ordenes ministeriales that approve or amend the modelo form for this revision’s applicability window. The gate is strict:

  • Every revision MUST declare at least one entry; missing entries are a hard failure.

  • Every declared entry MUST resolve in the legal catalogue with a corpus_ref (per aeat-calculation-grounding).

  • Every declared entry MUST also appear in (or be merged into) legal_refs so existing snapshot ref-collection carries it.

For *-y-siguientes (open-ended) revisions the orden_aplicabilidad MUST cite the orden establishing the open-ended applicability — the connective gate ensuring even the “y siguientes” claim is BOE-anchored. Per-year norm values inside the open-ended revision (rate brackets, thresholds) are the parameter-bracket layer’s responsibility gated by cadrumo.domain.calculations.registry.validate_revision_rules.validate_bracket_table_temporal_coverage; a wrong-but-present bracket value is a legal-grounding defect, NOT a resolution defect.

class RevisionLegalApplicabilityWindow(starts_on, closes_on)[source]

Bases: object

Presentation-aware interval an applicability authority must overlap.

ModeloRevision.valid_from / valid_to describe the tax-period revision, while annual and informative forms are commonly approved and filed in the following calendar year. Declared deadline windows therefore extend a bounded revision through its latest legally grounded presentation close. An open-ended revision keeps an open upper bound: a later amendment can legitimately be one of its applicability authorities.

Parameters:
  • starts_on (date)

  • closes_on (date | None)

starts_on: date
closes_on: date | None
classmethod from_revision(revision)[source]

Derive the inclusive revision-plus-presentation interval for a ModeloRevision.

Return type:

RevisionLegalApplicabilityWindow

Parameters:

revision (ModeloRevision)

overlaps(reference)[source]

Return whether reference reaches anywhere in this interval.

A norm that takes effect AFTER this window closes can still ground it: an informativa Orden published at the end of December is effective the following January while governing the ejercicio just ended. The catalogue states that explicitly through governs_periods_from, which the reference schema enforces to be strictly earlier than effective_from precisely because it declares retroactive reach. Comparing effective_from alone therefore refuses a citation the catalogue already says governs these periods.

Return type:

bool

Parameters:

reference (LegalReference)

validate_orden_aplicabilidad(scope, modelo_id, revision, legal_catalogue)[source]

Validate the orden_aplicabilidad gate for one revision.

Returned failures MUST block registry load: missing applicability Ordenes, dangling entries, corpus-less entries, and entries absent from legal_refs are all current-data defects.

Connective gate:

For open-ended *-y-siguientes revisions (valid_to is None and period_selector.year_from is set) the orden_aplicabilidad MUST be non-empty — the open-ended applicability claim MUST be BOE-anchored.

Parameters:
Return type:

list[str]

Returns:

A list of load-blocking failures.

orden_aplicabilidad_hard_failures(scope, modelo_id, revision, legal_catalogue)[source]

Return load-blocking failures of the orden_aplicabilidad gate.

Parameters:
Return type:

list[str]

Returns:

A list of load-blocking failures.