aeat.application.modelo._calculation_preparation module

Preparation gates for modelo calculation actions.

This module prepares calculation input channels against the registry ModeloRevision for a WorkUnit, resolves the law-determined RegistrySnapshot, applies the Modelo 303 IVA wallet gate, and runs ledger preflight through a TransactionCatalogueRepository before calculation proceeds.

See also

calculate_modelo_revision():

Consumes the prepared bundle before persisting a draft revision.

resolve_calculation_binding_channels():

Merges caller, backend, borrador, enum, and date binding channels.

_iva_wallet_gate:

Applies the persisted Modelo 303 IVA-wallet authority during preparation.

class PreparedCalculation(work_units, work_unit, snapshot, casilla_inputs, backend_casilla_inputs, period_date, channels)[source]

Bases: object

Validated calculation preflight bundle consumed by the action layer.

work_unit is the loaded WorkUnit; snapshot is the resolved RegistrySnapshot; channels is the merged ResolvedCalculationChannels set that the registry engine will consume. Casilla inputs have already been canonicalised and ledger, profile, required-binding, borrador, and IVA-wallet gates have already run.

Parameters:
work_units: WorkUnitCatalogue
work_unit: WorkUnit
snapshot: RegistrySnapshot
casilla_inputs: Mapping[TypeAliasType, Decimal]
backend_casilla_inputs: Mapping[TypeAliasType, Decimal] | None
period_date: date
channels: ResolvedCalculationChannels
prepare_calculation(*, work_unit_id, work_unit_repository, casilla_inputs, backend_casilla_inputs, ledger_preflight_transaction_repository, iva_compensation_decision, iva_compensation_decision_repository, binding_values, enum_binding_values, backend_binding_values, filing_period_date, borrador_snapshot_id, borrador_snapshot_repository, unresolved_relation_ids, unresolved_binding_ids)[source]

Prepare validated inputs, source channels, and gates for calculation.

The resolved registry ModeloRevision supplies binding and casilla requirements. ledger_preflight_transaction_repository may provide a TransactionCatalogueRepository for the ledger-tax readiness check. iva_compensation_decision_repository may provide the matching IvaWalletDecisionRepository for the Modelo 303 wallet authority, while Borrador100SnapshotRepository supplies the optional Modelo 100 borrador tier.

Return type:

PreparedCalculation

Returns:

A PreparedCalculation carrying the WorkUnit, RegistrySnapshot, validated inputs, period date, and ResolvedCalculationChannels.

Parameters: