diff --git a/backend/Funding.py b/backend/Funding.py index d3283982..e52b1943 100644 --- a/backend/Funding.py +++ b/backend/Funding.py @@ -297,14 +297,28 @@ class Funding: """ Returns the closest starting U-value and appropriate ending U-value for solid wall insulation. - - If current_uvalue is closest to 0.45, assume the improvement target is 0.21. - - Otherwise, assume the target is 0.30. + - If the closest starting U-value is 0.45, assume an improvement to 0.21. + - Otherwise, assume improvement to 0.30. + - Special formatting rules: + - If closest is 0.45 → return "2" (string) + - If closest is 2.00 → return "2.0" + - Else: format with 2 decimal places """ possible_starting_u_values = [2.00, 1.70, 1.00, 0.60, 0.45] closest_starting = min(possible_starting_u_values, key=lambda x: abs(x - current_uvalue)) - ending_uvalue = 0.21 if closest_starting == 0.45 else 0.30 - return f"{closest_starting:.2f}", f"{ending_uvalue:.2f}" + # Determine the ending U-value + ending_uvalue = "0.21" if closest_starting == 0.45 else "0.3" + + # Format the starting U-value according to special rules + if closest_starting == 0.45: + starting_str = "2" + elif closest_starting == 2.00: + starting_str = "2.0" + else: + starting_str = f"{closest_starting:.2f}" + + return starting_str, ending_uvalue def calculate_partial_project_abs( self,