aeat.domain.calculations.registry._formula_runtime_ops module¶
Formula-runtime operation helpers for registry calculations.
The formula evaluator delegates arithmetic dispatch, dated parameter lookup,
rounding, and input validation here while executing
ModeloRevision formula graphs.
Helpers raise RegistryValidationError
so domain.calculations.registry._formula_runtime.calculate_registry_snapshot()
reports contract failures through the registry error channel.
See also
domain.calculations.registry._formula_runtimeSnapshot evaluator that calls these helpers while materialising
RegistrySnapshotoutputs.domain.calculations.registry._runtime_graphFormula graph walkers that discover the casilla, binding, relation, and parameter refs consumed before operation dispatch starts.
domain.calculations.registry.ValidatedRegistryAuthorityRegistry authority loaded by
read_parameter()for ad hoc parameter reads outside snapshot execution.
- exception UnresolvedFormulaDependencyError(dependency_ids)[source]¶
Bases:
RegistrySnapshotErrorRaised internally when a non-blocking source gap makes a formula unresolved.
Shared between
_formula_runtimeand its per-family op-evaluator siblings (e.g._formula_runtime_irnr) so a family module can signal a deferred dependency without importing back into the dispatcher module.- code: ClassVar[ErrorCode]¶
- class RegistryUnresolvedOutcomeReason(*values)[source]¶
Bases:
StrEnumClosed reason catalogue for typed formula outcomes with no Decimal value.
- M210_BASELINE_TIPO_DEFERRED¶
- M210_CONVENIO_RATE_MISSING¶
- exception UnresolvedFormulaOutcomeError(reason, *, context)[source]¶
Bases:
RegistrySnapshotErrorRaised internally when a formula emits a typed unresolved outcome.
- Parameters:
reason (RegistryUnresolvedOutcomeReason)
- Return type:
None
- code: ClassVar[ErrorCode]¶
- numeric_casilla_value(casilla_id, ctx)[source]¶
Read a resolved numeric casilla value from the evaluation context.
Generic accessor shared by the M210/IRNR, M131 módulos, and M303 módulos IVA formula-op families; each raises
UnresolvedFormulaDependencyErrorthe same way for a casilla deferred by a non-blocking source gap.- Return type:
Decimal
- Parameters:
casilla_id (CasillaId)
ctx (_EvalContext)
- evaluate_args_op(op, args)[source]¶
Evaluate a resolved formula operation over decimal operands.
Operation names mirror
FormulaExpressionopvalues consumed bydomain.calculations.registry._formula_runtime.calculate_registry_snapshot().
- resolve_bracket(parameter, base, date_context)[source]¶
Resolve a bracket-table
ParameterDefinitionfor a base amount.The parameter’s bracket date axis must be present in
date_contextso registry-authored validity windows select exactly one bracket row.
- resolve_parameter(parameter, date_context)[source]¶
Resolve one dated value from a
ParameterDefinition.Exactly one
DatedValuemust match the selected date axes for the parameter lookup to be deterministic.- Return type:
- Parameters:
parameter (ParameterDefinition)
- apply_rounding(value, rounding)[source]¶
Apply a registry rounding rule to a decimal formula result.
money-2usescore.money.round_to_cents();integeruses half-up quantization for registry-authored integer targets.
- reject_non_decimal(items, label)[source]¶
Reject non-decimal values before formula runtime consumption.
- validated_decimal_input_casilla_ids(inputs, *, revision)[source]¶
Canonicalise decimal input keys against a
ModeloRevision.Raw string keys become validated
CasillaIdvalues, thendomain.calculations.registry._casilla_membership.undeclared_casilla_ids()rejects inputs outside the revision’s declared casilla set.- Return type:
- Parameters:
inputs (Mapping)
revision (ModeloRevision)
- reject_non_string(values, label)[source]¶
Reject empty or non-string external values before registry validation.
- reject_unknown_external_values(items, known_ids, label)[source]¶
Reject external ids not declared by the current registry snapshot.
- read_parameter(modelo_id, revision_id, parameter_id, *, date_context, registry_root=None)[source]¶
Read a registry parameter through
ValidatedRegistryAuthority.The ad hoc public helper loads the same validated registry authority used by snapshot callers, narrows to the selected
ModeloRevision, and delegates the dated value lookup toresolve_parameter().