diff --git a/src/app/portfolio/[slug]/utils.ts b/src/app/portfolio/[slug]/utils.ts index c6947ccf..40e612a5 100644 --- a/src/app/portfolio/[slug]/utils.ts +++ b/src/app/portfolio/[slug]/utils.ts @@ -26,6 +26,8 @@ import { lodgementDateSql, isExpiredSql, mainfuelSql, + sapSql, + epcBandSql, } from "@/lib/services/epcSources"; import { FilterGroups, @@ -716,8 +718,11 @@ export async function getProperties( p.postcode AS postcode, p.status AS status, p.creation_status AS "creationStatus", - p.current_epc_rating AS "currentEpcRating", - p.current_sap_points AS "currentSapPoints", + -- Current EPC/SAP: new-approach properties have null headline columns on + -- the property row, so source from the lodged baseline. The "Expected EPC" + -- column is currentSapPoints + recommendation SAP, so this also fixes it. + ${epcBandSql} AS "currentEpcRating", + ${sapSql} AS "currentSapPoints", -- property_targets is no longer read (the "Expected EPC" column derives -- from currentSapPoints + recommendation SAP). Kept as NULL to preserve -- the PropertyWithRelations shape.