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")