From 0d1e49f1f336dd31910bdc250b6fc1bb3e4990c9 Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Tue, 21 May 2024 14:12:03 +0100 Subject: [PATCH] allow costing for flats ewi --- backend/app/plan/router.py | 5 ++++- recommendations/Costs.py | 4 +--- recommendations/Mds.py | 19 +++++++++++++------ recommendations/WallRecommendations.py | 1 - 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/backend/app/plan/router.py b/backend/app/plan/router.py index 7e0deae8..e11dded8 100644 --- a/backend/app/plan/router.py +++ b/backend/app/plan/router.py @@ -736,7 +736,10 @@ async def build_mds(body: PlanTriggerRequest): p.get_components(cleaned, photo_supply_lookup, floor_area_decile_thresholds) mds = Mds(property_instance=p, materials=materials) - mds.build() + property_representative_recommendations, errors = mds.build() + + if errors: + logger.info("Errors occurred during MDS build") except IntegrityError: diff --git a/recommendations/Costs.py b/recommendations/Costs.py index fd3c1692..03190727 100644 --- a/recommendations/Costs.py +++ b/recommendations/Costs.py @@ -626,12 +626,10 @@ class Costs: preliminaries_rate = self.EWI_SCAFFOLDING_PRELIMINARIES else: preliminaries_rate = self.EWI_NO_SCAFFOLDING_PRELIMINARIES - elif self.property.data["property-type"] == "Maisonette": + elif self.property.data["property-type"] in ["Maisonette", "Flat"]: preliminaries_rate = self.EWI_SCAFFOLDING_PRELIMINARIES elif self.property.data["property-type"] == "Bungalow": preliminaries_rate = self.EWI_NO_SCAFFOLDING_PRELIMINARIES - else: - raise ValueError("Unsupported property type - haven't handled flats") demolition_data = [x for x in non_insulation_materials if x["type"] == "ewi_wall_demolition"] preparation_data = [x for x in non_insulation_materials if x["type"] == "ewi_wall_preparation"] diff --git a/recommendations/Mds.py b/recommendations/Mds.py index d371f2ec..7453e5e9 100644 --- a/recommendations/Mds.py +++ b/recommendations/Mds.py @@ -59,6 +59,7 @@ class Mds: raise NotImplementedError("Not implemented measure in the property - implement me") mds_recommendations = [] + errors = [] # TODO: Could use a decarator to reduce the boilerplate code - insert_recommendation_id and then the append @@ -75,11 +76,15 @@ class Mds: mds_recommendations.append(recs) if "loft_insulation" in measure_config_list: - recs = self.roof_recommender.mds_loft_insulation(phase=0) - if not recs: - raise Exception("No recommendations for loft insulation") - recs = self.insert_recommendation_id(recs, measures, "loft_insulation") - mds_recommendations.append(recs) + # Check if the roof is suitable for loft insulation + if self.property_instance.roof['is_roof_room']: + errors.append("Roof is a room") + else: + recs = self.roof_recommender.mds_loft_insulation(phase=0) + if not recs: + raise Exception("No recommendations for loft insulation") + recs = self.insert_recommendation_id(recs, measures, "loft_insulation") + mds_recommendations.append(recs) if "internal_wall_insulation" in measure_config_list: raise Exception("check me out 4") @@ -104,7 +109,7 @@ class Mds: recs = self.heating_recommender.recommend_hhr_storage_heaters( phase=0, system_change=True, heating_controls_only=False, _return=True ) - recs = self.insert_recommendation_id(recs, measures) + recs = self.insert_recommendation_id(recs, measures, "electric_storage_heaters") mds_recommendations.append(recs) if "low_energy_lighting" in measure_config_list: @@ -156,6 +161,8 @@ class Mds: mds_recommendations, non_invasive_recommendations=[] ) + return property_representative_recommendations, errors + @staticmethod def insert_recommendation_id(recommendations, measures, measure_name): # Insert the recommendation identifier into this recommendation diff --git a/recommendations/WallRecommendations.py b/recommendations/WallRecommendations.py index 67fadd8e..71996e5c 100644 --- a/recommendations/WallRecommendations.py +++ b/recommendations/WallRecommendations.py @@ -123,7 +123,6 @@ class WallRecommendations(Definitions): def mds_recommend_ewi(self, phase=None): # Function specifically for external wall insulation, for usage in the mds report self.recommendations = [] - insulation_thickness = self.property.walls["insulation_thickness"] u_value = get_wall_u_value( clean_description=self.property.walls["clean_description"],