diff --git a/backend/Property.py b/backend/Property.py index 4c8bd5bc..d400d439 100644 --- a/backend/Property.py +++ b/backend/Property.py @@ -650,6 +650,17 @@ class Property(Definitions): self.data["floor-level"] not in self.DATA_ANOMALY_MATCHES else None ) + if self.floor_level is None: + + if self.data["property-type"] != "Flat": + return + + if self.floor["another_property_below"]: + self.floor_level = 1 + else: + self.floor_level = 0 + return + # We perform some extra checks, if the property is not on the ground floor, as we have found cases # where a property is marked as being on the first floor if self.floor_level > 0: diff --git a/backend/tests/test_property.py b/backend/tests/test_property.py index 9188f545..871c9291 100644 --- a/backend/tests/test_property.py +++ b/backend/tests/test_property.py @@ -423,3 +423,18 @@ class TestProperty: prop3.set_floor_level() assert prop3.floor_level == 2 + + # Example of a house + prop4 = Property(1, "AB12CD", "Test Address", mock_epc_client) + prop4.data = {'floor-level': '', 'property-type': 'House'} + prop4.floor = { + 'original_description': '(Another dwelling below)', 'clean_description': 'Solid, no insulation', + 'thermal_transmittance': None, 'thermal_transmittance_unit': None, 'is_assumed': False, + 'is_to_unheated_space': False, 'is_to_external_air': False, 'is_suspended': False, 'is_solid': False, + 'another_property_below': False, 'insulation_thickness': 'none', 'floor_thermal_transmittance': None, + 'floor_insulation_thickness': 'none' + } + + prop4.set_floor_level() + + assert prop4.floor_level is None