From eef9fdc17120295f4c66bf541e800e1c65fbc4da Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Fri, 26 Jun 2026 11:25:45 +0000 Subject: [PATCH] fix(reporting): show scenario bars for EPC bands absent from the baseline MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The breakdown chart looped only over baseline bands (epcBands), which the query returns only for bands that have properties. So a band reached ONLY after the scenario — e.g. A/B when no property starts that high — had no row, and its scenario bar never rendered (portfolio 812: scenario yields 7 A + 2 B, baseline has none). Iterate a canonical A–G+Unknown order over baseline ∪ scenario instead, so post-scenario-only bands still appear. Co-Authored-By: Claude Opus 4.8 (1M context) --- .../(portfolio)/reporting/BreakdownChart.tsx | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/app/portfolio/[slug]/(portfolio)/reporting/BreakdownChart.tsx b/src/app/portfolio/[slug]/(portfolio)/reporting/BreakdownChart.tsx index 9b660ed0..976ecdec 100644 --- a/src/app/portfolio/[slug]/(portfolio)/reporting/BreakdownChart.tsx +++ b/src/app/portfolio/[slug]/(portfolio)/reporting/BreakdownChart.tsx @@ -51,15 +51,27 @@ export function BreakdownChart({ const rows: any[] = []; - for (const d of epcBands) { - const epc = d.epc ?? "Unknown"; + // The baseline query only returns bands that have properties, so a band + // reached ONLY after the scenario (e.g. A/B when nothing starts that high) + // is absent from epcBands — looping it alone drops those scenario bars. + // Iterate a canonical order over baseline ∪ scenario instead. + const baselineByBand = new Map( + epcBands.map((d) => [d.epc ?? "Unknown", d]), + ); + const BAND_ORDER = ["A", "B", "C", "D", "E", "F", "G", "Unknown"]; + const presentBands = BAND_ORDER.filter( + (b) => baselineByBand.has(b) || (scenarioEpcBands?.[b] ?? 0) > 0, + ); + + for (const epc of presentBands) { + const d = baselineByBand.get(epc); const scenarioValue = scenarioEpcBands?.[epc] ?? 0; // Baseline (stacked) rows.push({ label: `${epc}`, - [friendlyKeys.actual]: d.actual ?? 0, - [friendlyKeys.estimated]: d.estimated ?? 0, + [friendlyKeys.actual]: d?.actual ?? 0, + [friendlyKeys.estimated]: d?.estimated ?? 0, [friendlyKeys.scenario]: 0, });