aeat.domain.calculations.registry._schema_formula module

Formula and parameter schema models for the registry.

class FormulaExpression(**data)[source]

Bases: RegistryModel

Parameters:
  • op (Literal['add', 'subtract', 'multiply', 'divide', 'percent', 'less_than', 'less_equal', 'greater_than', 'greater_equal', 'equal', 'sum', 'min', 'max', 'clamp', 'negate', 'copy', 'if_then_else', 'lookup_parameter', 'lookup_bracket', 'lookup_bracket_by_ccaa', 'm100_resolve_renta_inmobiliaria_imputada', 'irnr_resolve_tipo_gravamen', 'm210_resolve_base_imponible', 'lookup_parameter_by_entity_type', 'lookup_bracket_by_entity_type', 'previous_period_value', 'previous_period_sum', 'cross_model_sum', 'age_at_year_end', 'm131_resolve_modulos_previo', 'm131_resolve_modulos_minoracion_empleo', 'm131_resolve_modulos_indice_exceso', 'm131_resolve_modulos_indices_generales', 'm131_resolve_modulos_pequena_dimension_ignorado_flag', 'm131_resolve_modulos_temporada_inicio_conflicto_flag', 'm100_resolve_eo_agraria_indices_correctores', 'm303_resolve_modulos_iva_cuota_devengada', 'm303_resolve_modulos_iva_cuota_minima_pct'] | None)

  • args (tuple[FormulaExpression, ...])

  • casilla_id (CasillaId | None)

  • binding (BindingId | None)

  • date_binding (BindingId | None)

  • parameter (ParameterId | None)

  • relation (RelationId | None)

  • literal (Annotated[Decimal, BeforeValidator(func=~aeat.domain.calculations.registry._schema_scalars._coerce_decimal, json_schema_input_type=PydanticUndefined)] | None)

  • dispatch_table (Mapping[str, ParameterId] | None)

op: FormulaOperator | None
args: tuple[FormulaExpression, ...]
casilla_id: CasillaId | None
binding: BindingId | None
date_binding: BindingId | None
parameter: ParameterId | None
relation: RelationId | None
literal: DecimalValue | None
dispatch_table: Mapping[str, ParameterId] | None
class DatedValue(**data)[source]

Bases: RegistryModel

Parameters:
  • value (Annotated[Decimal, BeforeValidator(func=~aeat.domain.calculations.registry._schema_scalars._coerce_decimal, json_schema_input_type=PydanticUndefined)])

  • date_axis (Literal['filing_period', 'devengo_date', 'transaction_date', 'invoice_date', 'submission_date'])

  • valid_from (date)

  • valid_to (date | None)

value: DecimalValue
date_axis: DateAxis
valid_from: date
valid_to: date | None
class BracketEntry(**data)[source]

Bases: RegistryModel

One row of a piecewise-linear bracket schedule (e.g. an IRPF escala).

Each entry encodes a half-open base-amount interval [lower_bound, upper_bound] plus the cuota previously accumulated up to lower_bound (fixed_addition) and the marginal rate applied to the slice above lower_bound. A None upper_bound declares the open-ended top bracket.

Cuota for a base amount base resolved by lookup_bracket:

cuota = fixed_addition + marginal_rate * (base - lower_bound)

Parameters:
  • lower_bound (Annotated[Decimal, BeforeValidator(func=~aeat.domain.calculations.registry._schema_scalars._coerce_decimal, json_schema_input_type=PydanticUndefined)])

  • upper_bound (Annotated[Decimal, BeforeValidator(func=~aeat.domain.calculations.registry._schema_scalars._coerce_decimal, json_schema_input_type=PydanticUndefined)] | None)

  • fixed_addition (Annotated[Decimal, BeforeValidator(func=~aeat.domain.calculations.registry._schema_scalars._coerce_decimal, json_schema_input_type=PydanticUndefined)])

  • marginal_rate (Annotated[Decimal, BeforeValidator(func=~aeat.domain.calculations.registry._schema_scalars._coerce_decimal, json_schema_input_type=PydanticUndefined)])

  • valid_from (date)

  • valid_to (date | None)

lower_bound: DecimalValue
upper_bound: DecimalValue | None
fixed_addition: DecimalValue
marginal_rate: DecimalValue
valid_from: date
valid_to: date | None
class KeyedBracketEntry(**data)[source]

Bases: RegistryModel

One row of a string-keyed rate-lookup table.

Sister shape to BracketEntry for parameters that dispatch on a categorical enum value rather than a piecewise-linear numeric interval. Each row binds a key (e.g. an IRNR tipo_renta code: general / ue_residente / ganancia_patrimonial / inmobiliaria) to a value (typically a Decimal rate) within a valid_from/valid_to window. Lookup is exact-match on (key, year) — there is no notion of interval overlap because the domain is enum-discrete, not numeric-continuous.

First consumer: M210 IRNR Phase 1 m210-tipo-gravamen-2025 per the m210-irnr-full-engine ADR.

Parameters:
  • key (str)

  • value (Annotated[Decimal, BeforeValidator(func=~aeat.domain.calculations.registry._schema_scalars._coerce_decimal, json_schema_input_type=PydanticUndefined)])

  • valid_from (date)

  • valid_to (date | None)

key: str
value: DecimalValue
valid_from: date
valid_to: date | None
class ParameterDefinition(**data)[source]

Bases: RegistryModel

Parameters:
  • id (ParameterId)

  • data_type (Literal['decimal', 'money', 'integer', 'ratio', 'text', 'boolean', 'bracket_table', 'keyed_bracket_table'])

  • unit (str)

  • values (tuple[DatedValue, ...])

  • brackets (tuple[BracketEntry, ...])

  • keyed_brackets (tuple[KeyedBracketEntry, ...])

  • bracket_axis (Literal['filing_period', 'devengo_date', 'transaction_date', 'invoice_date', 'submission_date'] | None)

  • legal_refs (Annotated[tuple[LegalRefId, ...], FieldInfo(annotation=NoneType, required=True, metadata=[MinLen(min_length=1)])])

  • source_refs (Annotated[tuple[SourceRefId, ...], FieldInfo(annotation=NoneType, required=True, metadata=[MinLen(min_length=1)])])

  • source_citations (tuple[SourceCitation, ...])

id: ParameterId
data_type: Literal['decimal', 'money', 'integer', 'ratio', 'text', 'boolean', 'bracket_table', 'keyed_bracket_table']
unit: str
values: tuple[DatedValue, ...]
brackets: tuple[BracketEntry, ...]
keyed_brackets: tuple[KeyedBracketEntry, ...]
bracket_axis: DateAxis | None
legal_refs: LegalRefs
source_refs: SourceRefs
source_citations: tuple[SourceCitation, ...]