diff --git a/app/models/log.rb b/app/models/log.rb index 52a197d97..0cb974d31 100644 --- a/app/models/log.rb +++ b/app/models/log.rb @@ -160,7 +160,7 @@ private location_code = result[:location_code] if result if LA_CHANGES.key?(location_code) && form.start_date.year >= 2023 LA_CHANGES[location_code] - else + elsif !(LA_CHANGES.value?(location_code) && form.start_date.year < 2023) location_code end end diff --git a/db/schema.rb b/db/schema.rb index eccfa98ca..3b26fde33 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -501,6 +501,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_03_08_101826) do t.integer "prevten" t.integer "mortgageused" t.integer "wchair" + t.integer "income2_value_check" t.integer "armedforcesspouse" t.datetime "hodate", precision: nil t.integer "hoday" @@ -525,14 +526,13 @@ ActiveRecord::Schema[7.0].define(version: 2023_03_08_101826) do t.integer "retirement_value_check" t.integer "hodate_check" t.integer "extrabor_value_check" - t.integer "grant_value_check" - t.integer "staircase_bought_value_check" t.integer "deposit_and_mortgage_value_check" t.integer "shared_ownership_deposit_value_check" + t.integer "grant_value_check" + t.integer "value_value_check" t.integer "old_persons_shared_ownership_value_check" - t.integer "income2_value_check" + t.integer "staircase_bought_value_check" t.integer "monthly_charges_value_check" - t.integer "value_value_check" t.integer "details_known_5" t.integer "details_known_6" t.integer "saledate_check" diff --git a/spec/models/sales_log_spec.rb b/spec/models/sales_log_spec.rb index d4814df14..afa8c451b 100644 --- a/spec/models/sales_log_spec.rb +++ b/spec/models/sales_log_spec.rb @@ -226,6 +226,37 @@ RSpec.describe SalesLog, type: :model do expect(record_from_db["la"]).to eq("E08000003") end + context "with 22/23 logs" do + let(:address_sales_log_22_23) do + described_class.create({ + owning_organisation:, + created_by: created_by_user, + ppcodenk: 1, + postcode_full: "CA10 1AA", + saledate: Time.zone.local(2022, 5, 2), + }) + end + + before do + WebMock.stub_request(:get, /api.postcodes.io\/postcodes\/CA101AA/) + .to_return(status: 200, body: '{"status":200,"result":{"admin_district":"Cumberland","codes":{"admin_district":"E06000063"}}}', headers: {}) + + Timecop.freeze(2023, 5, 1) + Singleton.__init__(FormHandler) + end + + after do + Timecop.unfreeze + Singleton.__init__(FormHandler) + end + + it "correctly sets la as nil" do + record_from_db = ActiveRecord::Base.connection.execute("select la from sales_logs where id=#{address_sales_log_22_23.id}").to_a[0] + expect(address_sales_log_22_23.la).to eq(nil) + expect(record_from_db["la"]).to eq(nil) + end + end + context "with 23/24 logs" do let(:address_sales_log_23_24) do described_class.create({