aeat.application.registry._diff module

Year-to-year registry revision diff for one modelo.

Surfaces what changed in the AEAT filing rulebook between two ModeloRevision instances of the same modelo: added/removed/renumbered casillas, changed formulas, changed legal_refs, changed parameters (rates/thresholds), and added/removed bindings.

Revision resolution reuses the same period_selector.includes_year primitive bindings_for_year() already uses (see _registry_discovery): given a bare filing year, exactly one revision must cover it, or the request is refused naming the modelo’s declared revisions.

See also

ValidatedRegistryAuthority

Loads and validates the ModeloDefinition this module diffs two revisions from.

ModeloRevision

The versioned ruleset compared by diff_registry_revisions().

class CasillaDiff(**data)[source]

Bases: BaseModel

A minimal projection of one added or removed casilla.

Parameters:
  • id (CasillaId)

  • number (str)

  • label (str)

id: _CasillaId
number: str
label: str
class RenumberedCasilla(**data)[source]

Bases: BaseModel

A casilla whose continuidad_id persisted but whose id/number changed.

Tracks a casilla whose stable continuidad_id persisted but whose AEAT printed number (or canonical registry id) changed across revisions.

Parameters:
  • continuidad_id (str)

  • from_id (CasillaId)

  • from_number (str)

  • to_id (CasillaId)

  • to_number (str)

continuidad_id: str
from_id: _CasillaId
from_number: str
to_id: _CasillaId
to_number: str
class FormulaDiff(**data)[source]

Bases: BaseModel

One formula whose expression, rounding, or legal grounding changed.

Parameters:
  • id (FormulaId)

  • target_casilla_id (CasillaId)

  • from_expression (dict[str, object])

  • to_expression (dict[str, object])

  • from_legal_refs (tuple[LegalRefId, ...])

  • to_legal_refs (tuple[LegalRefId, ...])

id: _FormulaId
target_casilla_id: _CasillaId
from_expression: dict[str, object]
to_expression: dict[str, object]
class ParameterDiff(**data)[source]

Bases: BaseModel

One parameter (rate/threshold/bracket table) whose declared value changed.

Parameters:
  • id (ParameterId)

  • data_type (str)

  • from_legal_refs (tuple[LegalRefId, ...])

  • to_legal_refs (tuple[LegalRefId, ...])

id: _ParameterId
data_type: str
class BindingDiff(**data)[source]

Bases: BaseModel

A minimal projection of one added or removed data binding.

Parameters:
id: str
source: str
class RegistryRevisionDiffReport(**data)[source]

Bases: BaseModel

Structured year-to-year diff between two revisions of one modelo.

Parameters:
modelo: str
from_year: int
to_year: int
from_revision_id: _RevisionId
to_revision_id: _RevisionId
same_revision: bool
added_casillas: tuple[CasillaDiff, ...]
removed_casillas: tuple[CasillaDiff, ...]
renumbered_casillas: tuple[RenumberedCasilla, ...]
added_formulas: tuple[_FormulaId, ...]
removed_formulas: tuple[_FormulaId, ...]
changed_formulas: tuple[FormulaDiff, ...]
added_parameters: tuple[_ParameterId, ...]
removed_parameters: tuple[_ParameterId, ...]
changed_parameters: tuple[ParameterDiff, ...]
added_bindings: tuple[BindingDiff, ...]
removed_bindings: tuple[BindingDiff, ...]
diff_registry_revisions(modelo, *, from_year, to_year, registry_root=None, source_root=None)[source]

Diff the two registry revisions covering from_year and to_year.

Each bare filing year resolves to exactly one covering ModeloRevision via period_selector.includes_year (the same primitive bindings_for_year() uses); a year with no covering revision, or with more than one, is refused naming the modelo’s declared revision ids.

Return type:

RegistryRevisionDiffReport

Returns:

A RegistryRevisionDiffReport enumerating casilla adds, removes, and continuidad-tracked renumbers; formula, parameter, and binding adds/removes/changes; and revision-level legal_refs deltas. Diffing a modelo against itself for two years that resolve to the same revision id returns an all-empty report with same_revision=True.

Parameters:
  • modelo (str)

  • from_year (int)

  • to_year (int)

  • registry_root (Path | None)

  • source_root (Path | None)