diff --git a/recommendations/RoofRecommendations.py b/recommendations/RoofRecommendations.py index c37c4d85..fe027371 100644 --- a/recommendations/RoofRecommendations.py +++ b/recommendations/RoofRecommendations.py @@ -155,20 +155,24 @@ class RoofRecommendations: ) self.estimated_u_value = u_value - if (u_value <= self.BUILDING_REGULATIONS_PART_L_MAX_U_VALUE) and ( + if (u_value <= self.BUILDING_REGULATIONS_PART_L_MAX_U_VALUE) or ( "loft_insulation" not in measures ): # The Roof is already compliant return if (self.property.roof["is_pitched"] and "loft_insulation" in measures) or ( - self.property.roof["is_flat"] and "flat_roof_insulation" + self.property.roof["is_flat"] and "flat_roof_insulation" in measures ): insulation_thickness = 0 if "loft_insulation" not in measures else self.insulation_thickness self.recommend_roof_insulation(u_value, insulation_thickness, self.property.roof, phase) return - if self.property.roof["is_roof_room"] and ("room_roof_insulation" in measures): + # There are cases where the property might have a room roof as the second roof, but we have a recommendation for + # it, so we allow this override + if self.property.roof["is_roof_room"] and ("room_roof_insulation" in measures) or ( + "room_roof_insulation" in [x["type"] for x in self.property.non_invasive_recommendations] + ): self.recommend_room_roof_insulation(u_value, phase) return @@ -421,6 +425,10 @@ class RoofRecommendations: } ] + rir_non_invasive_recommendation = next( + (x for x in self.property.non_invasive_recommendations if x["type"] == "room_roof_insulation"), {} + ) + # lowest_selected_u_value = None recommendations = [] for material in roof_roof_insulation_materials: @@ -445,7 +453,13 @@ class RoofRecommendations: # if new_u_value <= self.BUILDING_REGULATIONS_PART_L_MAX_U_VALUE: # lowest_selected_u_value = update_lowest_selected_u_value(lowest_selected_u_value, new_u_value) - estimated_cost = cost_per_unit * self.property.insulation_floor_area + estimated_cost = ( + cost_per_unit * self.property.insulation_floor_area if + rir_non_invasive_recommendation.get("cost") is None else + rir_non_invasive_recommendation.get("cost") + ) + + sap_points = rir_non_invasive_recommendation.get("sap_points", None) # Could also be Roof room(s), ceiling insulated new_descriptin = "Pitched, insulated at rafters" @@ -483,14 +497,15 @@ class RoofRecommendations: "description": "Insulate room in roof at rafters and re-decorate", "starting_u_value": u_value, "new_u_value": None, - "sap_points": None, + "sap_points": sap_points, "simulation_config": simulation_config, "description_simulation": { "roof-description": new_descriptin, "roof-energy-eff": new_efficiency }, **cost_result, - "already_installed": already_installed + "already_installed": already_installed, + "survey": rir_non_invasive_recommendation.get("survey", None) } )