aeat.domain.calculations.registry._formula_runtime_irnr module¶
IRNR / Modelo 210 formula-op evaluators for the registry runtime.
Extracted from _formula_runtime to
keep that module under its size budget (aeat-architecture-boundaries,
registry-resolver-family-extraction). Holds the two IRNR-specific formula
ops – irnr_resolve_tipo_gravamen and m210_resolve_base_imponible –
and their private argument-resolution and rate-computation helpers. Dispatch
still lives in _evaluate_expression(),
which imports this module at package level and calls
evaluate_irnr_resolve_tipo_gravamen() /
evaluate_m210_resolve_base_imponible() exactly as it calls the sibling
_formula_runtime_ops helpers. The
shared error types, the unresolved-outcome reason enum, and the generic
numeric-casilla-value accessor live in _formula_runtime_ops (not in
_formula_runtime itself) so this module can depend on them without a
runtime import cycle back into the dispatcher module.
See also
_formula_runtimeOwns the dispatcher and
_EvalContext._formula_runtime_opsOwns the shared unresolved-formula error types,
RegistryUnresolvedOutcomeReason, andnumeric_casilla_value().
- evaluate_irnr_resolve_tipo_gravamen(expression, ctx)[source]¶
Resolve the IRNR tipo de gravamen rate, applying any treaty override.
The single tipo-de-gravamen resolution path for every IRNR consumer (Modelo 210 today, the retenciones-a-no-residentes modelos when they land). It resolves the TRLIRNR domestic baseline and, when the profile declares a fiscal-residence country, consults the cross-cutting
ConvenioAuthorityprojected onto the snapshot. On a matched override it branches on the typedConvenioOverrideKind:flatreplaces the domestic rate outright,ceilingappliesmin(domestic, treaty)so “más favorable” is computed rather than assumed,allocation_domestic_tariffdelegates the amount to the domestic tariff (the Art. 25.1.b progressive pension tariff forpension, the baseline rate otherwise),exemptdrives the source-state rate to zero.
A declared treaty country with no override row yields a typed unresolved outcome (
no-silent-under-declaration); the application verification layer converts it into a finding post-engine.- Return type:
- Parameters:
expression (FormulaExpression)
ctx (_EvalContext)
- evaluate_m210_resolve_base_imponible(expression, ctx)[source]¶
Resolve M210 base imponible, including Art. 24.6 and Art. 13.1.h branches.
Non-imputed Art. 24.1 tipos start from
rendimientos_integros. Art. 24.6 permits deducting linked expenses when the filer is in the EU/EEA path, represented bytipo_renta='ue_residente'or an EU/EEAcountry_of_fiscal_residencebinding. Forinmobiliaria, the operator applies the LIRPF Art. 85 imputation mechanics reached through TRLIRNR Arts. 13.1.h and 24.5; own-use imputation admits no expenses.- Return type:
- Parameters:
expression (FormulaExpression)
ctx (_EvalContext)