aeat.application.modelo._result_disposition_resolution module

Single determined-fact resolution of a modelo’s fichero result disposition.

The AEAT fichero “Tipo de declaración” encodes the result disposition of an autoliquidación (a ingresar / a compensar / a devolver / negativa). For Modelo 303 a negative result is, by default, a credit carried forward (compensación, C). The current accepted ADR treats inscription in the Registro de devolución mensual (REDEME) as the standing monthly-devolución disposition policy for eligible negative periods; a non-REDEME taxpayer may explicitly request devolución (D) only in the last filing period of the year.

This module is the ONE place that determination is made. The export header composer and the cross-period carry persistence both read the disposition from resolve_modelo_result_disposition(), so the fichero D the operator submits and the cross-period carry the next period reads can never disagree (a period requested as devolución is excluded from compensación carry - never both). It reuses the codified per-modelo result→code derivation (derive_result_disposition()) and the REDEME/last-period eligibility gate (refund_disposition_available()); it does not duplicate either.

Before resolving the result, the persisted CalculationRevision value map is checked through the parent WorkUnit against the law-determined registry ModeloRevision, so printed numbers, export refs, and ambiguous metadata tokens fail before they can influence the disposition.

Legal basis (Modelo 303 refund election): RD 1624/1992 (RIVA) art. 30 (Registro de devolución mensual); Ley 37/1992 (LIVA) art. 116 (the monthly-refund right).

See also

core.derive_result_disposition()

Diseño-grounded result-to-code derivation used before Modelo 303 refund election handling.

domain.iva.refund_disposition_available()

Law-determined REDEME/last-period eligibility gate layered on a carried Modelo 303 credit.

application.modelo.file_modelo_revision()

Filing transition that reads the same refund fact before persisting cross-period carry-forward observations.

DECLARATION_TYPE_FALLBACK: ResultDisposition

Provisional fallback “Tipo de declaración” disposition for a modelo that declares the header but has no codified, diseño-grounded result-disposition spec. INGRESO (“I”) is wrong for a credit/zero result, so a new modelo MUST be added to the spec rather than relying on it. Mirrors the export fallback constant — kept here because the resolver is the disposition authority.

resolve_modelo_result_disposition(*, work_unit, revision, workflow_profile, period, refund_election=RefundElection.COMPENSAR)[source]

Resolve the single fichero “Tipo de declaración” result disposition.

The boundary resolves a persisted CalculationRevision through its parent WorkUnit for a TaxpayerProfile, using the supplied Period to decide whether a Modelo 303 refund election is lawful. The work unit fixes the modelo, filing year, and registry revision against which the revision’s casilla_values are validated.

Computes the modelo’s base disposition from its final-result casilla via the codified derive_result_disposition(), then — for a Modelo 303 credit (C) — applies the refund election: the current accepted ADR treats a taxpayer inscribed in the Registro de devolución mensual (REDEME) as requesting devolución (D) for eligible negative periods under a standing monthly-devolución disposition policy; a non-REDEME taxpayer who explicitly elects DEVOLVER requests devolución for the negative last period of the year (Ley 37/1992 art. 116). The eligibility gate (refund_disposition_available()) confirms the refund is lawful for the period. Every other disposition is returned unchanged.

refund_election is the operator’s per-filing opt-in (default COMPENSAR, the non-regressive carry-forward). It is orthogonal to the standing REDEME inscription: the accepted ADR treats REDEME as the standing policy that resolves eligible negative periods to devolución regardless of this flag, while a non-REDEME taxpayer resolves to devolución only when both the period is eligible AND the operator elects DEVOLVER. An election of DEVOLVER for an ineligible period is refused — never silently carried, never silently requested as devolución.

Returns the one ResultDisposition both the export header composer and the cross-period carry persistence read, so the fichero disposition and the carry can never disagree.

Raises:

ModeloRefundElectionNotEligibleError – When refund_election is DEVOLVER but the period is not a lawful refund period for a non-REDEME taxpayer.

Return type:

ResultDisposition

Parameters:
revision_is_refund_disposition(*, work_unit, revision, workflow_profile, period, refund_election=RefundElection.COMPENSAR)[source]

Return whether the revision’s resolved disposition is a refund (devolución).

Resolves the supplied CalculationRevision for a TaxpayerProfile, with the same Period refund eligibility context used by export.

Convenience wrapper used by the cross-period carry path: a refunded Modelo 303 period generates zero compensación carry-forward. Reads the SAME resolved disposition the export emits via resolve_modelo_result_disposition(), threading the same refund_election so the carry and the fichero agree.

Return type:

bool

Parameters: