diff --git a/backend/Funding.py b/backend/Funding.py index ce712de4..31f89488 100644 --- a/backend/Funding.py +++ b/backend/Funding.py @@ -18,6 +18,11 @@ class Funding: Handles eligibility and funding calculations for ECO4 & GBIS (PRS + Social Housing). """ + SOLID_FUELS = [ + 'wood logs', 'manufactured smokeless fuel', 'house coal', 'smokeless coal', 'oil', 'dual fuel mineral wood', + 'anthracite', 'dual fuel appliance mineral and wood', "bulk wood pellets", "wood chips" + ] + def __init__( self, tenure: str, # 'Private' or 'Social' @@ -329,8 +334,7 @@ class Funding: return starting_str, ending_uvalue - @staticmethod - def _map_to_pre_main_heating(mainheating, main_fuel, mainheat_energy_eff): + def _map_to_pre_main_heating(self, mainheating, main_fuel, mainheat_energy_eff): # We check most likely primary heating system. Because mixed systems are hard to break up, we # check the larger, more prominent heating systems first and then the smaller ones. We aim # to cover the case where properties have heating systems like @@ -342,7 +346,7 @@ class Funding: if mainheating["has_boiler"] and (main_fuel["fuel_type"] == "lpg"): return 'Bottled LPG Boiler' if mainheating["has_boiler"] and ( - (main_fuel["fuel_type"] == "mains gas") or ( + (main_fuel["fuel_type"] in ["mains gas", "biogas"]) or ( (main_fuel["fuel_type"] == "unknown") and (mainheating["has_mains_gas"])) ): if mainheat_energy_eff in ["Good", "Very Good"]: @@ -374,12 +378,7 @@ class Funding: ): return 'Non Condensing LPG Boiler' - if mainheating["has_boiler"] and ( - main_fuel["fuel_type"] in [ - "dual fuel appliance mineral and wood", "manufactured smokeless fuel", "dual fuel mineral wood", - "smokeless coal" - ] - ) and (mainheat_energy_eff in ["Average", "Very Poor", "Poor"]): + if mainheating["has_boiler"] and (main_fuel["fuel_type"] in self.SOLID_FUELS): return 'Solid Fossil Boiler' if mainheating["has_ground_source_heat_pump"] or mainheating["has_water_source_heat_pump"]: @@ -408,17 +407,16 @@ class Funding: if mainheating["has_room_heaters"] and main_fuel["fuel_type"] == "lpg": return 'Bottled LPG Room Heaters' - if mainheating["has_room_heaters"] and main_fuel["fuel_type"] == "electricity": + if mainheating["has_room_heaters"] and ( + (main_fuel["fuel_type"] == "electricity") or mainheating["has_electric"] + ): return 'Electric Room Heaters' if mainheating["has_room_heaters"] and main_fuel["fuel_type"] == "mains gas": return 'Gas Room Heaters' if mainheating["has_room_heaters"] and ( - main_fuel["fuel_type"] in [ - "dual fuel appliance mineral and wood", "manufactured smokeless fuel", "dual fuel mineral wood", "oil", - 'smokeless coal', 'wood logs' - ] or mainheating["has_coal"] + main_fuel["fuel_type"] in self.SOLID_FUELS or mainheating["has_coal"] ): return 'Solid Fossil Room Heaters' @@ -435,10 +433,9 @@ class Funding: if mainheating["has_warm_air"] and main_fuel["fuel_type"] == "mains gas": if mainheat_energy_eff in ["Good", "Very Good"]: return 'Condensing Gas Boiler' - elif mainheat_energy_eff in ["Average", "Poor"]: + if mainheat_energy_eff in ["Average", "Poor"]: return 'Non Condensing Gas Boiler' - elif mainheat_energy_eff == "Very Poor": - return 'Gas Back Boiler to Radiators' + return 'Gas Back Boiler to Radiators' if mainheating["has_electricaire"]: # Based on current understanding, electricaire is an electric warm air storage heater, using @@ -456,8 +453,13 @@ class Funding: if mainheating["has_warm_air"] and main_fuel["fuel_type"] == "lpg": if mainheat_energy_eff in ["Good", "Very Good"]: return 'Condensing LPG Boiler' - else: # Average, Poor, Very Poor - return 'Non Condensing LPG Boiler' + return 'Non Condensing LPG Boiler' + + # Treat warm air oil as a direct acting oil boiler + if mainheating["has_warm_air"] and main_fuel["fuel_type"] == "lpg": + if mainheat_energy_eff in ["Good", "Very Good"]: + return 'Condensing Oil Boiler' + return 'Non Condensing Oil Boiler' raise ValueError("Invalid pre heating system") diff --git a/backend/tests/test_funding.py b/backend/tests/test_funding.py index 6c237308..60629383 100644 --- a/backend/tests/test_funding.py +++ b/backend/tests/test_funding.py @@ -1076,7 +1076,7 @@ for _, x in tqdm(epc_df.iterrows(), total=len(epc_df)): errored_epcs = epc_df[epc_df["LMK_KEY"].isin(errors)] unique_combs = errored_epcs[["MAINHEAT_ENERGY_EFF", "MAINHEAT_DESCRIPTION", "MAIN_FUEL"]].drop_duplicates() -i = 2 +i = 3 x = errored_epcs[ (errored_epcs["MAINHEAT_ENERGY_EFF"] == unique_combs["MAINHEAT_ENERGY_EFF"].values[i]) & (errored_epcs["MAINHEAT_DESCRIPTION"] == unique_combs["MAINHEAT_DESCRIPTION"].values[i]) &