aeat.domain.fincas._tier_resolver module

LIRPF art. 23.2 four-tier auto-resolver post Ley 12/2023.

Implements the BOE priority order (90 → 70 → 60 → 50, highest applicable wins) per disposición final segunda apartado uno of Ley 12/2023, de 24 de mayo (BOE-A-2023-12203).

Effective-date dispatch:

  • period_year < ejercicio_amendment_year (default 2024) → flat 60 % under the pre-amendment art. 23.2 wording, regardless of contract date.

  • period_year >= ejercicio_amendment_year AND contract_celebration_date < ley_12_2023_in_force_date (2023-05-26) → flat 60 % under DT 38ª (LIRPF redacción vigente a 31/12/2021).

  • Otherwise → four-tier dispatch.

LAU art. 17.6 non-compliance forfeits the reducción entirely (domain.fincas.ReduccionTier.FORFEIT_LAU_17_6) — checked before any tier evaluation per the closing paragraph of the rewritten apartado 2.

Tier 70-b-1 (joven inquilino) carries a per-co-tenant qualifying share: BOE explicitly states “Cuando existan varios arrendatarios de una misma vivienda, esta reducción se aplicará sobre la parte del rendimiento neto que proporcionalmente corresponda a los arrendatarios que cumplan los requisitos previstos en esta letra”. The resolver returns qualifying_share = qualifying_co_tenant_count / tenant_count for that tier; every other tier returns share=1.

LEY_12_2023_IN_FORCE_DATE: date

Entry-into-force date of Ley 12/2023 (BOE-A-2023-12203). Contracts celebrated on or after this date are subject to the new four-tier framework once the IRPF amendment also takes legal effect.

DEFAULT_EJERCICIO_AMENDMENT_YEAR: int

First ejercicio in which the new IRPF apartado 2 art. 23 wording applies (Ley 12/2023 disposición final novena segundo párrafo).

REHAB_LOOKBACK_DAYS: int

2 años anteriores interpreted as 730 calendar days (2 * 365). The BOE wording (“en los dos años anteriores a la fecha de la celebración del contrato”) permits exact-day arithmetic; the project picks 730-day lookback as the deterministic boundary.

PRIOR_RENT_REBAJA_THRESHOLD: Decimal

más de un 5 por ciento. Strict > comparison — exactly 5 % does not qualify (BOE wording is “en más de un 5 por ciento”, not “en al menos un 5 por ciento”).

Type:

Tier 90-a threshold

JOVEN_TENANT_AGE_MAX: int

“una edad comprendida entre 18 y 35 años”).

Type:

Tier 70-b-1 inclusive age range (BOE

class TierResolution(**data)[source]

Bases: BaseModel

Outcome of a single resolve_reduccion() invocation.

Variables:
  • tier – Closed-enum tier identifier.

  • reduccion_pct – Numeric reducción percentage as a Decimal in [0, 1]. Multiplied by qualifying_share and the per-contract rendimiento neto positivo to compute the rental reduction amount.

  • qualifying_share – Fraction of rendimiento neto eligible for the tier reducción. Always 1 except for tier 70-b-1 with mixed-qualification co-tenants.

  • legal_refs – Registry legal-reference ids grounding the resolution in the bundled legal catalogue and corpus.

Parameters:
tier: ReduccionTier
reduccion_pct: Decimal
qualifying_share: Decimal
legal_refs: tuple[LegalRefId, ...]
resolve_reduccion(contract, finca, period_year, *, ejercicio_amendment_year=None)[source]

Resolve the LIRPF art. 23.2 reducción tier for contract in period_year.

Parameters:
  • contract (Arrendamiento) – The per-contract metadata record.

  • finca (Finca) – The owning finca (provides is_stressed_area).

  • period_year (int) – Ejercicio for which the reducción is being computed.

  • ejercicio_amendment_year (int | None) – First ejercicio on which the new apartado 2 wording applies (default 2024 per Ley 12/2023 disposición final novena).

Return type:

TierResolution

Returns:

TierResolution carrying the tier, the numeric reducción percentage, the qualifying share, and the registry legal-reference ids.

Raises:

TierResolutionError – If finca.use_type is not eligible for the LIRPF Art. 23.2 reducción — the article applies only to arrendamientos de bienes inmuebles destinados a     vivienda, which the second paragraph excludes for touristic / temporary rentals and which the use-type mapping further excludes for commercial premises and non-rented use types.