diff --git a/datatypes/epc/domain/mapper.py b/datatypes/epc/domain/mapper.py index f9f56143b..b9d93ecba 100644 --- a/datatypes/epc/domain/mapper.py +++ b/datatypes/epc/domain/mapper.py @@ -6093,6 +6093,11 @@ def _map_sap_heating( condensing=main.condensing, weather_compensator=main.weather_compensator, central_heating_pump_age_str=main.central_heating_pump_age, + # PCDB product id → the appliance's SEDBUK efficiency source + # (`gas_oil_boiler_record`); 0 means no product lodged (#1563). + main_heating_index_number=( + main.product_id if main.product_id > 0 else None + ), ) ], has_fixed_air_conditioning=ventilation.has_fixed_air_conditioning, diff --git a/datatypes/epc/domain/tests/test_from_site_notes.py b/datatypes/epc/domain/tests/test_from_site_notes.py index fa9d0fb1b..21de94ee7 100644 --- a/datatypes/epc/domain/tests/test_from_site_notes.py +++ b/datatypes/epc/domain/tests/test_from_site_notes.py @@ -314,6 +314,35 @@ class TestWaterHeatingCoding: ) +class TestMainHeatingEfficiencySource: + """`from_site_notes` must carry the surveyed PCDB `product_id` onto + `main_heating_index_number`, so the calculator reads the actual appliance's + SEDBUK efficiency (`gas_oil_boiler_record`) instead of a generic Table-4b + default. The site note lodges the boiler by PCDB id (`summer_efficiency` is + always 0), so the index IS the efficiency source (issue #1563). + """ + + def _survey(self, **main: object) -> PasHubRdSapSiteNotes: + data = load("pashub_rdsap_site_notes_example1.json") + data["heating_and_hot_water"]["main_heating"].update(main) + return from_dict(PasHubRdSapSiteNotes, data) + + def test_product_id_maps_to_index_number(self) -> None: + result = EpcPropertyDataMapper.from_site_notes(self._survey(product_id=18400)) + assert ( + result.sap_heating.main_heating_details[0].main_heating_index_number + == 18400 + ) + + def test_zero_product_id_leaves_index_none(self) -> None: + # No PCDB product lodged (e.g. selected by efficiency) → no index. + result = EpcPropertyDataMapper.from_site_notes(self._survey(product_id=0)) + assert ( + result.sap_heating.main_heating_details[0].main_heating_index_number + is None + ) + + class TestFromSiteNotesExample1: """ Fixture: pashub_rdsap_site_notes_example1.json @@ -666,6 +695,7 @@ class TestFromSiteNotesExample1: condensing=True, weather_compensator=False, central_heating_pump_age_str="Unknown", + main_heating_index_number=18400, # PCDB product id → efficiency source ) ], has_fixed_air_conditioning=False,