mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-07-27 23:35:01 +00:00
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:
parent
df768d882e
commit
a6eaac5fe3
1 changed files with 7 additions and 1 deletions
|
|
@ -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))
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue