diff --git a/datatypes/epc/domain/mapper.py b/datatypes/epc/domain/mapper.py index 1f11895a..72bd667b 100644 --- a/datatypes/epc/domain/mapper.py +++ b/datatypes/epc/domain/mapper.py @@ -2946,6 +2946,17 @@ def _sap_17_1_building_part( perimeter_per_storey = exposed_area / total_height party_length_per_storey = party_area / total_height + # Guard: synthesise only when floor dims are absent AND we can confirm + # single-storey single-part. `is_flat` (sap_flat_details present) is the + # current signal — flats are always single-storey within the dwelling. + # Bungalows are equally single-storey but carry no equivalent structural + # field; `dwelling_type` string matching is the only handle, and has not + # been confirmed necessary (no bungalows with empty floor dims were found + # in the failing batch). An alternative worth considering: drop `is_flat` + # entirely and trigger on `not bp.sap_floor_dimensions and is_single_part` + # alone — if the cert lodged no dims at all, there is no per-storey data to + # misattribute regardless of dwelling type. Requires corpus evidence that + # multi-storey single-part certs never omit floor dims before widening. if not bp.sap_floor_dimensions and is_single_part and is_flat: floor_dimensions = [ SapFloorDimension(