From 03b0aa6a5d231e67d7e1923851ca0c521d68f2ba Mon Sep 17 00:00:00 2001 From: natdeanlewissoftwire Date: Thu, 9 Mar 2023 09:16:04 +0000 Subject: [PATCH] feat: align with similar PR for 23/24 --- app/models/log.rb | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/app/models/log.rb b/app/models/log.rb index 5821b41b5..7d0900692 100644 --- a/app/models/log.rb +++ b/app/models/log.rb @@ -135,10 +135,33 @@ private process_postcode(ppostcode_full, "ppcodenk", "is_previous_la_inferred", "prevloc") end + LA_CHANGES = { + "E07000027" => "E06000063", # Barrow-in-Furness => Cumberland + "E07000030" => "E06000063", # Eden => Cumberland + "E07000031" => "E06000063", # South Lakeland => Cumberland + "E07000026" => "E06000064", # Allerdale => Westmorland and Furness + "E07000028" => "E06000064", # Carlisle => Westmorland and Furness + "E07000029" => "E06000064", # Copeland => Westmorland and Furness + "E07000163" => "E06000065", # Craven => North Yorkshire + "E07000164" => "E06000065", # Hambleton => North Yorkshire + "E07000165" => "E06000065", # Harrogate => North Yorkshire + "E07000166" => "E06000065", # Richmondshire => North Yorkshire + "E07000167" => "E06000065", # Ryedale => North Yorkshire + "E07000168" => "E06000065", # Scarborough => North Yorkshire + "E07000169" => "E06000065", # Selby => North Yorkshire + "E07000187" => "E06000066", # Mendip => Somerset + "E07000188" => "E06000066", # Sedgemoor => Somerset + "E07000246" => "E06000066", # Somerset West and Taunton => Somerset + "E07000189" => "E06000066", # South Somerset => Somerset + }.freeze + def get_inferred_la(postcode) result = PIO.lookup(postcode) - if result && !(form.start_date.year < 2023 && new_2023_admin_district_codes.include?(result[:location_code])) - result[:location_code] + location_code = result[:location_code] if result + if LA_CHANGES.value?(location_code) && form.start_date.year < 2023 + nil + else + location_code end end