aeat.application.modelo._result_summary module

Headline result summary for a persisted calculation revision.

work calculate and work revision render every casilla a modelo declares — 2235 rows for Modelo 100. The figures an operator actually looks for (the result to pay or refund, the key computed totals) are buried in that flat table. This module distills a persisted CalculationRevision into a short, registry-grounded summary of the headline casillas, so the CLI can lead with it before the full table.

The headline casillas are taken from the modelo’s own registry metadata, never hand-picked. The revision’s parent WorkUnit selects the registry snapshot, whose VerificationExpectationDefinition entries use reconciliation_total_casilla_ids for result-to-pay / result-to-refund casillas and computed_casilla_ids for the modelo’s key computed outputs.

This is a presentation summary only. It does not derive the fichero Tipo de declaración result disposition, apply Modelo 303 refund elections, or decide cross-period carry-forward; that single determined fact belongs to aeat.application.modelo.resolve_modelo_result_disposition().

See also

aeat.application.modelo.resolve_modelo_result_disposition()

Determines the filed result disposition that export and carry-forward persistence read.

aeat.application.filing.summarise_calculation()

Draft-calculation summary surface for filing workflows; this module handles persisted modelo revisions instead.

class ResultSummaryRow(**data)[source]

Bases: BaseModel

One application row for a headline casilla in a calculation summary.

Rows are emitted only for casillas present in the source CalculationRevision values. result_ingresar and result_devolver identify registry-declared reconciliation totals; key_figure identifies a computed output retained for the CLI summary. label remains the official Spanish invariant; localized_labels carries registry-provided operator-facing display labels for other output languages. CLI JSON rendering serializes this model into ResultSummaryRowPayload rows with string decimal values.

Parameters:
casilla_id: CasillaId
label: str
localized_labels: dict[str, str]
value: Decimal
role: str

Why the casilla is a headline figure.

result_ingresar / result_devolver mark the registry-declared result-to-pay / result-to-refund total. key_figure marks a computed casilla the modelo’s verification expectation tracks.

class CalculationResultSummary(**data)[source]

Bases: BaseModel

Distilled headline figures for a persisted calculation revision.

The modelo, filing year, and typed Period come from the parent WorkUnit; rows are ResultSummaryRow values selected from that work unit’s registry snapshot. Text rendering uses the period’s bare registry token so the summary header does not duplicate the filing year.

Parameters:
modelo: str
filing_year: int
period: Period
rows: tuple[ResultSummaryRow, ...]
calculation_result_summary(revision, *, work_unit_resolver=<function get_work_unit>)[source]

Return the CalculationResultSummary for revision, if available.

revision is the persisted CalculationRevision attempt and provides casilla_values. The function resolves its parent WorkUnit, then reads the registry snapshot’s verification expectations for that work unit’s revision. Missing work-unit or snapshot lookup errors return None so callers can render only the full casilla table; unexpected errors are allowed to propagate.

For each VerificationExpectationDefinition, reconciliation_total_casilla_ids are considered first and produce result_ingresar or result_devolver rows. Remaining unique computed_casilla_ids produce key_figure rows. A result casilla is emitted once and skipped later if it also appears as a computed key figure.

Rows are emitted only when their casilla id exists in revision.casilla_values. Returns None when no candidate row survives.

Return type:

CalculationResultSummary | None

Parameters: