diff --git a/backend/engine/engine.py b/backend/engine/engine.py index 3014f2b3..65393e20 100644 --- a/backend/engine/engine.py +++ b/backend/engine/engine.py @@ -134,7 +134,7 @@ def extract_portfolio_aggregation_data( lower_bound_valuation_uplift, upper_bound_valuation_uplift = 0, 0 agg_data.append({ - "pre_retrofit_epc": p.data["current-energy-rating"], + "pre_retrofit_epc": p.epc_record.current_energy_rating, "post_retrofit_epc": new_epc_bands[p.id], "pre_retrofit_co2": pre_retrofit_co2, "post_retrofit_co2": post_retrofit_co2, @@ -1145,7 +1145,7 @@ async def model_engine(body: PlanTriggerRequest): optimiser.solve() solution = optimiser.solution gain = optimiser.solution_gain - post_sap = int(p.data["current-energy-efficiency"]) + gain + post_sap = p.epc_record.current_energy_efficiency + gain pv_size = next( (m["array_size"] for m in solution if m["type"] == "solar_pv"), 0 @@ -1242,7 +1242,7 @@ async def model_engine(body: PlanTriggerRequest): # This will include everything, including already installed total_sap_points = sum([r["sap_points"] for r in default_recommendations]) - new_sap_points = float(p.data["current-energy-efficiency"]) + total_sap_points + new_sap_points = p.epc_record.current_energy_efficiency + total_sap_points new_epc = sap_to_epc(new_sap_points) # Already installed measures do not have a cost but we remove anyway total_cost = sum([r["total"] for r in default_recommendations if not r["already_installed"]]) diff --git a/backend/ml_models/Valuation.py b/backend/ml_models/Valuation.py index 17db0dae..64935dca 100644 --- a/backend/ml_models/Valuation.py +++ b/backend/ml_models/Valuation.py @@ -216,7 +216,7 @@ class PropertyValuation: cls.UPRN_VALUE_LOOKUP.get(property_instance.uprn) ) - current_epc = property_instance.data["current-energy-rating"] + current_epc = property_instance.epc_record.current_energy_rating if not current_value: # In this case, we return a % improvement rather than an absolute diff --git a/etl/epc/Record.py b/etl/epc/Record.py index 10968edc..ecbb89d2 100644 --- a/etl/epc/Record.py +++ b/etl/epc/Record.py @@ -186,7 +186,7 @@ class EPCRecord: heat_loss_corridor: Optional[str] = None unheated_corridor_length: Optional[float] = None - mains_gas_flag: Optional[str] = None + mains_gas_flag: Optional[bool] = None # ------------------------------------------------------------------ # BUILDING FABRIC DESCRIPTIONS