cadrumo.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 application.modelo.result_disposition_resolution.resolve_modelo_result_disposition().

See also

application.modelo.result_disposition_resolution.resolve_modelo_result_disposition()

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

Core types: RegistrySnapshot.

class ResultSummaryRole(*values)[source]

Bases: StrEnum

Closed vocabulary of why a 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.

RESULT_INGRESAR
RESULT_DEVOLVER
KEY_FIGURE
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 is resolved once for the active output language. CLI JSON rendering serializes this model into ResultSummaryRowPayload rows with string decimal values.

Parameters:

data (Any)

casilla_id: CasillaId
label: str
value: Decimal
role: ResultSummaryRole

Why the casilla is a headline figure. See ResultSummaryRole.

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:

data (Any)

modelo: str
filing_year: int
period: Period
rows: tuple[ResultSummaryRow, ...]
calculation_result_summary(revision, *, operation, work_unit=None, work_unit_resolver=None)[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: