diff --git a/domain/scenario_export/scenario_sheet.py b/domain/scenario_export/scenario_sheet.py index 33871d923..e38116679 100644 --- a/domain/scenario_export/scenario_sheet.py +++ b/domain/scenario_export/scenario_sheet.py @@ -53,6 +53,9 @@ _SAVINGS_COLUMNS: tuple[str, ...] = ( "energy_cost_savings", ) +# Package-level totals, trailing the savings roll-ups. +_TOTAL_COLUMNS: tuple[str, ...] = ("total_retrofit_cost",) + def _sum(values: Sequence[Optional[float]]) -> float: """Sum optional numbers, treating an absent contribution as zero.""" @@ -125,7 +128,9 @@ def shape_scenario_sheet( properties: Sequence[PropertyScenarioData], ) -> ExportSheet: """Shape one Scenario's Properties into a wide export sheet (ADR-0065).""" - columns: tuple[str, ...] = _ID_COLUMNS + MEASURE_COLUMNS + _SAVINGS_COLUMNS + columns: tuple[str, ...] = ( + _ID_COLUMNS + MEASURE_COLUMNS + _SAVINGS_COLUMNS + _TOTAL_COLUMNS + ) rows: list[dict[str, Any]] = [] for prop in properties: row: dict[str, Any] = { @@ -148,5 +153,6 @@ def shape_scenario_sheet( row["energy_cost_savings"] = _sum( [m.energy_cost_savings for m in prop.measures] ) + row["total_retrofit_cost"] = _sum([m.estimated_cost for m in prop.measures]) rows.append(row) return ExportSheet(columns=columns, rows=tuple(rows))