moved year built

This commit is contained in:
Khalim Conn-Kowlessar 2023-06-23 16:06:12 +01:00
parent 9f36efb2a1
commit 4a89b1f409

View file

@ -37,6 +37,7 @@ class Property(BaseUtility):
self.data = data
self.full_sap_epc = None
self.in_conservation_area = None
self.year_built = None
if epc_client:
self.epc_client = epc_client
@ -145,14 +146,16 @@ class Property(BaseUtility):
"""
if self.full_sap_epc:
return pd.to_datetime(self.full_sap_epc["lodgement-date"]).year
self.year_built = pd.to_datetime(self.full_sap_epc["lodgement-date"]).year
return
if self.data["construction-age-band"] not in self.DATA_ANOMALY_MATCHES:
# Take the lower limit. If we're pessimistic about the age of the property, that at least means we have
# more options for recommendations if that age falls before the year that insulation in walls became
# common practice
band = [int(x) for x in re.findall(r'\b\d{4}\b', self.data["construction-age-band"])]
return band[0]
self.year_built = band[0]
return
# We don't know when the property was built
return None
self.year_built = None