Total each Property's retrofit cost from its measure costs 🟩

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Khalim Conn-Kowlessar 2026-07-13 23:12:23 +00:00
parent df768d882e
commit a6eaac5fe3

View file

@ -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))