From 23ff1e73a827416dd46550c9047369437a5db2c1 Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Mon, 13 Jul 2026 23:10:16 +0000 Subject: [PATCH] =?UTF-8?q?Guarantee=20every=20measure=20column=20on=20eve?= =?UTF-8?q?ry=20scenario=20sheet=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 | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/domain/scenario_export/scenario_sheet.py b/domain/scenario_export/scenario_sheet.py index 7a0ebfb68..3d9dfda7b 100644 --- a/domain/scenario_export/scenario_sheet.py +++ b/domain/scenario_export/scenario_sheet.py @@ -41,6 +41,9 @@ MEASURE_COLUMNS: tuple[str, ...] = ( "system_tune_up_zoned", ) +# Property identity columns, leading every sheet before the measure columns. +_ID_COLUMNS: tuple[str, ...] = ("property_id", "landlord_property_id") + @dataclass(frozen=True) class ExportMeasure: @@ -108,14 +111,19 @@ def shape_scenario_sheet( properties: Sequence[PropertyScenarioData], ) -> ExportSheet: """Shape one Scenario's Properties into a wide export sheet (ADR-0065).""" - columns: tuple[str, ...] = ("property_id", "landlord_property_id") + columns: tuple[str, ...] = _ID_COLUMNS + MEASURE_COLUMNS rows: list[dict[str, Any]] = [] for prop in properties: row: dict[str, Any] = { "property_id": prop.property_id, "landlord_property_id": prop.landlord_property_id, } + # Every measure column is present, blank unless this Property has it, so + # all scenario sheets share one contract (ADR-0065). + for column in MEASURE_COLUMNS: + row[column] = "" for measure in prop.measures: - row[measure.measure_type] = measure.estimated_cost + if measure.measure_type in MEASURE_COLUMNS: + row[measure.measure_type] = measure.estimated_cost rows.append(row) return ExportSheet(columns=columns, rows=tuple(rows))