mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
57 lines
1.8 KiB
Python
57 lines
1.8 KiB
Python
from typing import List
|
|
from backend.Property import Property
|
|
from recommendations.Costs import Costs
|
|
|
|
|
|
class WindowsRecommendations:
|
|
|
|
def __init__(self, property_instance: Property, materials: List):
|
|
self.property = property_instance
|
|
self.costs = Costs(self.property)
|
|
|
|
self.recommendation = []
|
|
|
|
self.glazing_material = [
|
|
material for material in materials if material["type"] == "windows_glazing"
|
|
]
|
|
|
|
if len(self.glazing_material) != 1:
|
|
raise ValueError("There should only be one window glazing material")
|
|
self.glazing_material = self.glazing_material[0]
|
|
|
|
def recommend(self):
|
|
"""
|
|
This method will recommend the best possible glazing options for a property.
|
|
|
|
In order to do this, we need to estimate the number of windows that the home has. This information will be
|
|
stored in the property object, under property.number_of_windows
|
|
:return:
|
|
"""
|
|
|
|
number_of_windows = self.property.number_of_windows
|
|
|
|
if not number_of_windows:
|
|
raise ValueError("Number of windows not specified")
|
|
|
|
if self.property.windows["has_glazing"] & (self.property.windows["glazing_coverage"] == "full"):
|
|
return
|
|
|
|
# We then price the job based on the number of windows that there are
|
|
cost_result = self.costs.window_glazing(
|
|
number_of_windows=number_of_windows,
|
|
material=self.glazing_material,
|
|
)
|
|
|
|
description = None
|
|
|
|
self.recommendation = [
|
|
{
|
|
"parts": [],
|
|
"type": "window_glazing",
|
|
"description": description,
|
|
"starting_u_value": None,
|
|
"new_u_value": None,
|
|
"sap_points": None,
|
|
**cost_result
|
|
}
|
|
]
|