From 56fb33a64a16261f35f286adffc8268503fac24c Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Fri, 25 Oct 2024 18:39:55 +0100 Subject: [PATCH] added placeholder pricing sheet --- etl/customers/aiha/xml_extraction.py | 101 ++++++++++++++++++--------- 1 file changed, 68 insertions(+), 33 deletions(-) diff --git a/etl/customers/aiha/xml_extraction.py b/etl/customers/aiha/xml_extraction.py index 416065e7..563ed7ca 100644 --- a/etl/customers/aiha/xml_extraction.py +++ b/etl/customers/aiha/xml_extraction.py @@ -90,7 +90,7 @@ def main(): # - AIH001-09 - Is there definitely an immersion water heater? Is this definitely the case for the other units? # - AIH001-11 - The layout of this unit is confusing, is there roof access? # - AIH001-12 - Why was there not access to the cylinder? - # + # - AIH001-12 - Is the need to draught proofing due to the windows? recommended_measures = [ { @@ -111,7 +111,7 @@ def main(): }, { "measure": "Solar PV", - "description": "Solar PV system with various configurations", + "description": "4kWp Solar PV system", "config": [ { "size": "4kWp", @@ -131,13 +131,13 @@ def main(): }, { "measure": "Loft Insulation", - "description": "300mm of loft insulation", + "description": "300mm loft insulation", "sap_points": 8, "ending_sap": 61 }, { "measure": "TTZC", - "description": "Thermostatic Time Zone Control", + "description": "Smart Thermostat", "sap_points": 3, "ending_sap": 64 } @@ -157,16 +157,16 @@ def main(): }, { "measure": "TTZC", - "description": "Thermostatic Time Zone Control", + "description": "Smart Thermostat", "sap_points": 3, "ending_sap": 55 }, { "measure": "Solar PV", - "description": "Solar PV system with 4kW capacity, south-facing", + "description": "4kWp Solar PV system", "config": [ { - "size": "4kW", + "size": "4kWp", "orientation": "South", "elavation": 30, "overshading": "Modest", @@ -196,7 +196,7 @@ def main(): }, { "measure": "Solar PV", - "description": "Solar PV system with 4kW capacity, horizontal orientation", + "description": "4kWp Solar PV system", "config": [ { "size": "4kW", @@ -210,7 +210,7 @@ def main(): }, { "measure": "TTZC", - "description": "Thermostatic Time Zone Control", + "description": "Smart Thermostat", "sap_points": 3, "ending_sap": 73 } @@ -229,7 +229,7 @@ def main(): }, { "measure": "Solar PV", - "description": "Solar PV system with 2kW capacity, south-facing", + "description": "2kWp Solar PV system", "config": [ { "size": "2kW", @@ -255,7 +255,7 @@ def main(): "recommended_measures": [ { "measure": "Loft Insulation", - "description": "300mm of loft insulation", + "description": "300mm loft insulation", "sap_points": 2, "ending_sap": 58, }, @@ -273,7 +273,7 @@ def main(): }, { "measure": "Ventilation", - "description": "Ventilation improvement", + "description": "2x DMEV fans", "sap_points": 0, "ending_sap": 69, } @@ -291,19 +291,19 @@ def main(): }, { "measure": "Cavity Wall Insulation", - "description": "Cavity wall insulation for extensions", + "description": "CWI to rdSAP default standard", "sap_points": 1, "ending_sap": 53, }, { "measure": "Ventilation", - "description": "Ventilation improvement", + "description": "2x DMEV fans", "sap_points": 0, "ending_sap": 53, }, { "measure": "TTZC", - "description": "Thermostatic Time Zone Control", + "description": "Smart Thermostat", "sap_points": 3, "ending_sap": 56, } @@ -315,7 +315,7 @@ def main(): "recommended_measures": [ { "measure": "TTZC", - "description": "Thermostatic Time Zone Control", + "description": "Smart Thermostat", "sap_points": 4, "ending_sap": 63, }, @@ -345,13 +345,13 @@ def main(): }, { "measure": "Draught Proofing", - "description": "Draught proofing improvements", + "description": "Window draught proofing improvements", "sap_points": 1, "ending_sap": 49, }, { "measure": "Solar PV", - "description": "Solar PV system with 3.2kW capacity, east-facing", + "description": "3.2kWp Solar PV system", "config": [ { "size": "3.2W", @@ -383,37 +383,37 @@ def main(): "recommended_measures": [ { "measure": "Roof Insulation", - "description": "100mm+ insulation on all surfaces (ceiling u=0.16, walls u=0.3)", + "description": "100mm+ RIR insulation on all surfaces (ceiling u=0.16, walls u=0.3)", "sap_points": 6, "ending_sap": 59, }, { "measure": "Flat Roof Insulation", - "description": "Flat roof insulation", + "description": "100mm flat roof insulation", "sap_points": 2, "ending_sap": 61, }, { "measure": "Cavity Wall Insulation", - "description": "Cavity wall insulation", + "description": "CWI to rdSAP default standard", "sap_points": 6, "ending_sap": 67, }, { "measure": "Ventilation", - "description": "Ventilation improvement", + "description": "2x DMEV fans", "sap_points": 0, "ending_sap": 67, }, { "measure": "TTZC", - "description": "Thermostatic Time Zone Control", + "description": "Smart Thermostat", "sap_points": 2, "ending_sap": 69, }, { "measure": "Solar PV", - "description": "Solar PV system with 4kW capacity, flat roof installation", + "description": "4kWp Solar PV system", "config": [ { "size": "4kW", @@ -433,25 +433,25 @@ def main(): "recommended_measures": [ { "measure": "Cavity Wall Insulation", - "description": "Insulation for cavity walls", + "description": "CWI to rdSAP default standard", "sap_points": 5, "ending_sap": 68, }, { "measure": "Ventilation", - "description": "Ventilation improvement", + "description": "2x DMEV fans", "sap_points": 0, "ending_sap": 68, }, { "measure": "Loft Insulation", - "description": "Installation of loft insulation", + "description": "300mm loft insulation", "sap_points": 1, "ending_sap": 69, }, { "measure": "Solar PV", - "description": "Solar PV system with 10kW capacity", + "description": "3.2kWp Solar PV system", "sap_points": 10, "ending_sap": 79, } @@ -459,6 +459,33 @@ def main(): }, ] + descs = [] + for r in recommended_measures: + for m in r["recommended_measures"]: + descs.append(m["description"]) + descs = list(set(descs)) + + # TODO - need to add scaffolding + pricing_data = [ + {'item': '80mm cylinder insulation', 'unit_price': None, 'unit': 'unit'}, + {'item': '100mm internal wall insulation', 'unit_price': 244.8, 'unit': 'hlp_m2'}, + {'item': 'CWI to rdSAP default standard', 'unit_price': 14.21, 'unit': 'hlp_m2'}, + {'item': 'Window draught proofing improvements', 'unit_price': None, 'unit': 'unit'}, + {'item': '100mm flat roof insulation', 'unit_price': None, 'unit': 'floor_m2'}, + {'item': 'Switch to 24-hour tariff', 'unit_price': 0, 'unit': None}, + {'item': '3.2kWp Solar PV system', 'unit_price': 3686, 'unit': 'unit_needs_scaffolding'}, + {'item': 'Installation of double glazing', 'unit_price': None, 'unit': 'window'}, + {'item': 'Ecoforest ecoAIR EVI 4-20 20kW air source heat pump', 'unit_price': 21189, 'unit': 'unit'}, + {'item': '2kWp Solar PV system', 'unit_price': 3201, 'unit': 'unit_needs_scaffolding'}, + {'item': '100mm+ RIR insulation on all surfaces (ceiling u=0.16, walls u=0.3)', 'unit_price': 244.80, + 'unit': 'floor_m2'}, + {'item': '4kWp Solar PV system', 'unit_price': 4009, 'unit': 'unit_needs_scaffolding'}, + {'item': '300mm loft insulation', 'unit_price': 16.07, 'unit': 'floor_m2'}, + {'item': 'Smart Thermostat', 'unit_price': 1200, 'unit': 'unit'}, + {'item': '2x DMEV fans', 'unit_price': 1070, 'unit': 'unit'} + ] + pricing_data = pd.DataFrame(pricing_data) + # Step 1: Normalize the recommended_measures data into a DataFrame. normalized_measures = [] @@ -470,7 +497,8 @@ def main(): "survey_key": survey_key, "starting_sap": starting_sap, "measure": measure["measure"], - "description": measure.get("description", "") + "description": measure.get("description", ""), + "sap_points": measure.get("sap_points", 0) }) # Convert the normalized list into a DataFrame. @@ -485,16 +513,23 @@ def main(): fill_value=None ).reset_index() - # Step 3: Extract starting SAP for each survey key. + # Step 3: Calculate the total sap points for each survey. + total_sap_points = measures_df.groupby("survey_key")["sap_points"].sum().reset_index() + total_sap_points.columns = ["survey_key", "total_sap_points"] + + # Merge total sap points into the pivoted measures. + pivoted_measures = pd.merge(pivoted_measures, total_sap_points, on="survey_key", how="left") + + # Step 4: Extract starting SAP for each survey key. starting_sap_df = measures_df.drop_duplicates(subset=["survey_key"])[["survey_key", "starting_sap"]] # Merge starting SAP back onto pivoted measures. result_df = pd.merge(pivoted_measures, starting_sap_df, on="survey_key", how="left") - # Step 4: Calculate the ending SAP using the total sap points. - # Note: If you want to use total sap points, you'll need to update the total calculation accordingly. + # Step 5: Calculate the ending SAP. + result_df["ending_sap"] = result_df["starting_sap"] + result_df["total_sap_points"] - # Step 5: Merge the result with the measures_data to get the final DataFrame. + # Step 6: Merge the result with the measures_data to get the final DataFrame. final_measures = measures_data.merge( result_df, how="left", on="survey_key" )