From a6eaac5fe3b2bc9c4c24006ec5e02e55eaa482ae Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Mon, 13 Jul 2026 23:12:23 +0000 Subject: [PATCH] =?UTF-8?q?Total=20each=20Property's=20retrofit=20cost=20f?= =?UTF-8?q?rom=20its=20measure=20costs=20=F0=9F=9F=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.8 (1M context) --- domain/scenario_export/scenario_sheet.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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))