From 013070073c9431db2471c5851a342e8d8779f869 Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Wed, 24 Jan 2024 10:59:21 +0000 Subject: [PATCH] updated cleaning of construction age band to also clean the prepared epc --- etl/epc/Record.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/etl/epc/Record.py b/etl/epc/Record.py index f0bbcbfa..aac22618 100644 --- a/etl/epc/Record.py +++ b/etl/epc/Record.py @@ -618,9 +618,11 @@ class EPCRecord: if not self.prepared_epc: raise ValueError("EPC Recrod doesn not contain epc data") - self.construction_age_band = EPCDataProcessor.clean_construction_age_band( - self.prepared_epc["construction-age-band"]) - if self.construction_age_band in DATA_ANOMALY_MATCHES: + self.prepared_epc["construction-age-band"] = EPCDataProcessor.clean_construction_age_band( + self.prepared_epc["construction-age-band"] + ) + + if self.prepared_epc["construction-age-band"] in DATA_ANOMALY_MATCHES: if self.old_data: # Take the most recent max_datetime = max( @@ -630,15 +632,17 @@ class EPCRecord: most_recent = [old_record for old_record in self.old_data if old_record["lodgement-datetime"] == max_datetime] - self.construction_age_band = EPCDataProcessor.clean_construction_age_band( + self.prepared_epc["construction-age-band"] = EPCDataProcessor.clean_construction_age_band( most_recent[0]["construction-age-band"] ) + self.construction_age_band = self.prepared_epc["construction-age-band"] self.age_band = england_wales_age_band_lookup.get(self.construction_age_band) if (self.prepared_epc["transaction-type"] == "new dwelling") and (self.age_band is None): self.age_band = "L" self.construction_age_band = 'England and Wales: 2012 onwards' + self.prepared_epc["construction-age-band"] = self.construction_age_band if self.age_band is None: raise ValueError("age_band is missing")