aeat.domain.calculations.registry._validate_orden_aplicabilidad module

The D3 orden_aplicabilidad gate for a ModeloRevision.

D3 / Ruling 4 (period-revision-resolution ADR)

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 registry-calculation-legal-grounding).

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

S24 / Ruling 5 boundary (R3):

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 validate_bracket_table_temporal_coverage(); a wrong-but-present bracket value is a legal-grounding defect, NOT a resolution defect.

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.

S24 connective gate (Ruling 5 boundary):

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.