From ddebebee30ee1b786783fd560e29522ec05dd565 Mon Sep 17 00:00:00 2001 From: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com> Date: Tue, 14 Jan 2025 09:02:16 +0000 Subject: [PATCH] Remove irrelevant 2023 checks (#2895) * Remove irrelevant 2023 checks * Update/remove tests --- .../lettings_log_variables.rb | 2 +- .../derived_variables/sales_log_variables.rb | 2 +- app/models/form/question.rb | 2 +- .../bulk_upload_form/prepare_your_file.rb | 2 - app/models/lettings_log.rb | 4 +- app/models/sales_log.rb | 25 +--------- .../validations/financial_validations.rb | 2 +- .../validations/household_validations.rb | 2 +- .../sales/financial_validations.rb | 2 +- .../sales/household_validations.rb | 2 - .../forms/prepare_your_file_2023.html.erb | 46 ------------------- .../forms/prepare_your_file_2023.html.erb | 40 ---------------- .../bulk_upload_shared/guidance.html.erb | 21 ++------- spec/features/bulk_upload_sales_logs_spec.rb | 14 +++--- spec/models/sales_log_spec.rb | 8 ---- .../validations/financial_validations_spec.rb | 14 ------ ...lk_upload_lettings_logs_controller_spec.rb | 1 + .../bulk_upload_sales_logs_controller_spec.rb | 1 + 18 files changed, 20 insertions(+), 170 deletions(-) delete mode 100644 app/views/bulk_upload_lettings_logs/forms/prepare_your_file_2023.html.erb delete mode 100644 app/views/bulk_upload_sales_logs/forms/prepare_your_file_2023.html.erb diff --git a/app/models/derived_variables/lettings_log_variables.rb b/app/models/derived_variables/lettings_log_variables.rb index ced530b17..6d50bb5ff 100644 --- a/app/models/derived_variables/lettings_log_variables.rb +++ b/app/models/derived_variables/lettings_log_variables.rb @@ -346,7 +346,7 @@ private end def address_answered_without_uprn? - [address_line1, town_or_city].all?(&:present?) && uprn.nil? && form.start_date.year >= 2023 + [address_line1, town_or_city].all?(&:present?) && uprn.nil? end def get_lar diff --git a/app/models/derived_variables/sales_log_variables.rb b/app/models/derived_variables/sales_log_variables.rb index 6e12ec488..ef4997283 100644 --- a/app/models/derived_variables/sales_log_variables.rb +++ b/app/models/derived_variables/sales_log_variables.rb @@ -226,7 +226,7 @@ private end def address_answered_without_uprn? - [address_line1, town_or_city].all?(&:present?) && uprn.nil? && form.start_date.year >= 2023 + [address_line1, town_or_city].all?(&:present?) && uprn.nil? end def soctenant_from_prevten_values diff --git a/app/models/form/question.rb b/app/models/form/question.rb index 05eec89dd..a91187003 100644 --- a/app/models/form/question.rb +++ b/app/models/form/question.rb @@ -276,7 +276,7 @@ class Form::Question end def question_number_string(hidden: false) - if @question_number && !hidden && form.start_date.year >= 2023 + if @question_number && !hidden "Q#{@question_number}" end end diff --git a/app/models/forms/bulk_upload_form/prepare_your_file.rb b/app/models/forms/bulk_upload_form/prepare_your_file.rb index b89367d9f..911daa4fe 100644 --- a/app/models/forms/bulk_upload_form/prepare_your_file.rb +++ b/app/models/forms/bulk_upload_form/prepare_your_file.rb @@ -11,8 +11,6 @@ module Forms def view_path case year - when 2023 - "bulk_upload_#{log_type}_logs/forms/prepare_your_file_2023" when 2024 "bulk_upload_#{log_type}_logs/forms/prepare_your_file_2024" end diff --git a/app/models/lettings_log.rb b/app/models/lettings_log.rb index 67cafb75b..3ec0d6bf7 100644 --- a/app/models/lettings_log.rb +++ b/app/models/lettings_log.rb @@ -670,8 +670,7 @@ class LettingsLog < Log ["owning_organisation_id", "startdate", "tenancycode", - form.start_date.year < 2023 || uprn.blank? ? "postcode_full" : nil, - form.start_date.year >= 2023 && uprn.present? ? "uprn" : nil, + uprn.blank? ? "postcode_full" : "uprn", "scheme_id", "location_id", "age1", @@ -884,7 +883,6 @@ private def should_process_uprn_change? return unless uprn return unless startdate - return unless collection_start_year_for_date(startdate) >= 2023 uprn_changed? || startdate_changed? end diff --git a/app/models/sales_log.rb b/app/models/sales_log.rb index d03425ee4..f7604b11e 100644 --- a/app/models/sales_log.rb +++ b/app/models/sales_log.rb @@ -129,33 +129,12 @@ class SalesLog < Log def dynamically_not_required not_required = [] - not_required << "proplen" if proplen_optional? - not_required << "mortlen" if mortlen_optional? - not_required << "frombeds" if frombeds_optional? not_required << "deposit" if form.start_year_2024_or_later? && stairowned_100? not_required += %w[address_line2 county] not_required end - def proplen_optional? - return false unless collection_start_year - - collection_start_year < 2023 - end - - def mortlen_optional? - return false unless collection_start_year - - collection_start_year < 2023 - end - - def frombeds_optional? - return false unless collection_start_year - - collection_start_year < 2023 - end - def unresolved false end @@ -449,7 +428,6 @@ class SalesLog < Log def should_process_uprn_change? return unless uprn return unless saledate - return unless collection_start_year_for_date(saledate) >= 2023 uprn_changed? || saledate_changed? end @@ -514,8 +492,7 @@ class SalesLog < Log "age1", "sex1", "ecstat1", - form.start_date.year < 2023 || uprn.blank? ? "postcode_full" : nil, - form.start_date.year >= 2023 && uprn.present? ? "uprn" : nil].compact + uprn.blank? ? "postcode_full" : "uprn"].compact end def soctenant_is_inferred? diff --git a/app/models/validations/financial_validations.rb b/app/models/validations/financial_validations.rb index 73b389f4c..82b3fae01 100644 --- a/app/models/validations/financial_validations.rb +++ b/app/models/validations/financial_validations.rb @@ -25,7 +25,7 @@ module Validations::FinancialValidations end def validate_net_income(record) - if record.ecstat1 && record.hhmemb && record.weekly_net_income && record.startdate && record.form.start_date.year >= 2023 + if record.ecstat1 && record.hhmemb && record.weekly_net_income && record.startdate if record.weekly_net_income > record.applicable_income_range.hard_max frequency = record.form.get_question("incfreq", record).label_from_value(record.incfreq).downcase hard_max = format_as_currency(record.applicable_income_range.hard_max) diff --git a/app/models/validations/household_validations.rb b/app/models/validations/household_validations.rb index cf0ae009e..b4fa934dc 100644 --- a/app/models/validations/household_validations.rb +++ b/app/models/validations/household_validations.rb @@ -201,7 +201,7 @@ module Validations::HouseholdValidations def validate_layear_and_prevloc(record) return unless record.layear && record.la && record.prevloc && record.collection_start_year - if record.la == record.prevloc && record.layear == 1 && record.collection_start_year >= 2023 + if record.la == record.prevloc && record.layear == 1 record.errors.add :layear, :renewal_just_moved, message: I18n.t("validations.lettings.household.layear.same_la_just_moved_to_area") record.errors.add :la, :renewal_just_moved, message: I18n.t("validations.lettings.household.la.same_la_just_moved_to_area") record.errors.add :postcode_full, :renewal_just_moved, message: I18n.t("validations.lettings.household.postcode_full.same_la_just_moved_to_area") diff --git a/app/models/validations/sales/financial_validations.rb b/app/models/validations/sales/financial_validations.rb index 91d4c31b7..e5d8232f0 100644 --- a/app/models/validations/sales/financial_validations.rb +++ b/app/models/validations/sales/financial_validations.rb @@ -82,7 +82,7 @@ module Validations::Sales::FinancialValidations def validate_child_income(record) return unless record.income2 && record.ecstat2 - if record.income2.positive? && is_economic_status_child?(record.ecstat2) && record.form.start_date.year >= 2023 + if record.income2.positive? && is_economic_status_child?(record.ecstat2) record.errors.add :ecstat2, I18n.t("validations.sales.financial.ecstat2.child_has_income") record.errors.add :income2, I18n.t("validations.sales.financial.income2.child_has_income") end diff --git a/app/models/validations/sales/household_validations.rb b/app/models/validations/sales/household_validations.rb index 175474098..e5a66f935 100644 --- a/app/models/validations/sales/household_validations.rb +++ b/app/models/validations/sales/household_validations.rb @@ -13,8 +13,6 @@ module Validations::Sales::HouseholdValidations end def validate_buyers_living_in_property(record) - return unless record.form.start_date.year >= 2023 - if record.buyers_will_live_in? && record.buyer_one_will_not_live_in_property? && record.buyer_two_will_not_live_in_property? record.errors.add :buylivein, I18n.t("validations.sales.household.buylivein.buyers_will_live_in_property_values_inconsistent") record.errors.add :buy1livein, I18n.t("validations.sales.household.buy1livein.buyers_will_live_in_property_values_inconsistent") diff --git a/app/views/bulk_upload_lettings_logs/forms/prepare_your_file_2023.html.erb b/app/views/bulk_upload_lettings_logs/forms/prepare_your_file_2023.html.erb deleted file mode 100644 index f8549807b..000000000 --- a/app/views/bulk_upload_lettings_logs/forms/prepare_your_file_2023.html.erb +++ /dev/null @@ -1,46 +0,0 @@ -<% content_for :before_content do %> - <%= govuk_back_link href: @form.back_path %> -<% end %> - -
<%= govuk_link_to "Read the full guidance", bulk_upload_lettings_log_path(id: "guidance", form: { year: @form.year }, referrer: "prepare-your-file") %> before you start if you have not used bulk upload before.
- -Use one of these templates to upload logs for 2023/24:
-There are 7 or 8 rows of content in the templates. These rows are called the ‘headers’. They contain the CORE form questions and guidance about which questions are required and how to format your answers.
- -<%= govuk_link_to "Read the full guidance", bulk_upload_sales_log_path(id: "guidance", form: { year: @form.year }, referrer: "prepare-your-file") %> before you start if you have not used bulk upload before.
- -Use one of these templates to upload logs for 2023/24:
-There are 7 or 8 rows of content in the templates. These rows are called the ‘headers’. They contain the CORE form questions and guidance about which questions are required and how to format your answers.
- -For each collection year, we publish a bulk upload template and specification.
- <% if @form.year == 2023 %> -The bulk upload templates contain 7 or 8 rows of ‘headers’ with information about how to fill in the template, including:
- <% else %> -The bulk upload templates contain 8 rows of ‘headers’ with information about how to fill in the template, including:
- <% end %> +The bulk upload templates contain 8 rows of ‘headers’ with information about how to fill in the template, including:
<%= govuk_list ["the CORE form questions and their field numbers", "each field’s valid responses", "if/when certain fields can be left blank", "which fields are used to check for duplicate logs"], type: :bullet %>You can paste your data below the headers or copy the headers and insert them above the data in your file. The bulk upload fields start at column B. Leave column A blank.
Make sure that each column of data aligns with the corresponding question in the headers. We recommend ordering your data to match the headers, but you can also reorder the headers to match your data. When processing the file, we check what each column of data represents based on the headers above.
- <% if @form.year == 2023 %> -For 2023/24 uploads, there are 2 templates to choose from, a new template and a legacy template. They outline suggested ways of ordering your data.
-You must include the headers in your file when you upload, unless your data matches the exact order of the legacy template. If you choose to remove the headers, you must also remove the blank column A.
- -New template: In this template, the questions are in the same order as the 2023/24 paper form and web form. Use this template if your organisation is new to bulk upload or if your housing management system matches the new column ordering.
-<%= govuk_link_to "Download the lettings bulk upload template (2023 to 2024) – New question ordering", @form.lettings_template_path %>
-<%= govuk_link_to "Download the sales bulk upload template (2023 to 2024) – New question ordering", @form.sales_template_path %>
- -Legacy template: In this template, the questions are in the same order as the 2022/23 template, with new questions added on to the end. Use this template if you have not updated your system to match the new template yet.
- <% else %> -<%= govuk_link_to "Download the lettings bulk upload template (2024 to 2025)", @form.lettings_template_path %>
-<%= govuk_link_to "Download the sales bulk upload template (2024 to 2025)", @form.sales_template_path %>
- <% end %> +<%= govuk_link_to "Download the lettings bulk upload template (2024 to 2025)", @form.lettings_template_path %>
+<%= govuk_link_to "Download the sales bulk upload template (2024 to 2025)", @form.sales_template_path %>
<% end %> <%= accordion.with_section(heading_text: "Using the bulk upload specification") do %> diff --git a/spec/features/bulk_upload_sales_logs_spec.rb b/spec/features/bulk_upload_sales_logs_spec.rb index 1ff0d9fb0..1816b6720 100644 --- a/spec/features/bulk_upload_sales_logs_spec.rb +++ b/spec/features/bulk_upload_sales_logs_spec.rb @@ -22,7 +22,7 @@ RSpec.describe "Bulk upload sales log" do # rubocop:disable RSpec/AnyInstance context "when during crossover period" do before do - Timecop.freeze(2023, 5, 1) + Timecop.freeze(2024, 5, 1) end after do @@ -38,15 +38,15 @@ RSpec.describe "Bulk upload sales log" do click_button("Continue") expect(page).to have_content("You must select a collection period to upload for") - choose("2023 to 2024") + choose("2024 to 2025") click_button("Continue") click_link("Back") - expect(page.find_field("form-year-2023-field")).to be_checked + expect(page.find_field("form-year-2024-field")).to be_checked click_button("Continue") - expect(page).to have_content("Upload sales logs in bulk (2023 to 2024)") + expect(page).to have_content("Upload sales logs in bulk (2024 to 2025)") click_button("Continue") expect(page).to have_content("Upload your file") @@ -80,7 +80,7 @@ RSpec.describe "Bulk upload sales log" do expect(page).to have_content("Which year") click_button("Continue") click_button("Continue") - choose("2023 to 2024") + choose("2024 to 2025") click_button("Continue") click_button("Continue") @@ -96,7 +96,7 @@ RSpec.describe "Bulk upload sales log" do context "when not in crossover period" do before do - Timecop.freeze(2024, 2, 1) + Timecop.freeze(2025, 2, 1) end after do @@ -108,7 +108,7 @@ RSpec.describe "Bulk upload sales log" do expect(page).to have_link("Upload sales logs in bulk") click_link("Upload sales logs in bulk") - expect(page).to have_content("Upload sales logs in bulk (2023 to 2024)") + expect(page).to have_content("Upload sales logs in bulk (2024 to 2025)") click_button("Continue") expect(page).to have_content("Upload your file") diff --git a/spec/models/sales_log_spec.rb b/spec/models/sales_log_spec.rb index 20eb0b2a6..3e6d6405d 100644 --- a/spec/models/sales_log_spec.rb +++ b/spec/models/sales_log_spec.rb @@ -120,14 +120,6 @@ RSpec.describe SalesLog, type: :model do allow(Time).to receive(:now).and_return(Time.zone.local(2023, 5, 1)) end - it "is set to completed for a log with a saledate before 23/24" do - completed_sales_log.update!(proplen: nil, proplen_asked: 0, saledate: Time.zone.local(2022, 5, 1)) - expect(completed_sales_log.in_progress?).to be(false) - expect(completed_sales_log.not_started?).to be(false) - expect(completed_sales_log.completed?).to be(true) - expect(completed_sales_log.deleted?).to be(false) - end - it "is set to in_progress for a log with a saledate after 23/24" do completed_sales_log.update!(proplen: nil, proplen_asked: 0, saledate: Time.zone.local(2023, 5, 1)) expect(completed_sales_log.in_progress?).to be(true) diff --git a/spec/models/validations/financial_validations_spec.rb b/spec/models/validations/financial_validations_spec.rb index 282e050a2..7151c4c9d 100644 --- a/spec/models/validations/financial_validations_spec.rb +++ b/spec/models/validations/financial_validations_spec.rb @@ -338,20 +338,6 @@ RSpec.describe Validations::FinancialValidations do expect(record.errors["ecstat#{n}"]).to be_empty end end - - context "when the net income is lower than the hard min for their employment status for 22/23 collection" do - it "does not add an error" do - record.startdate = Time.zone.local(2022, 5, 1) - record.earnings = 50 - record.incfreq = 1 - record.hhmemb = 1 - record.ecstat1 = 1 - financial_validator.validate_net_income(record) - expect(record.errors["earnings"]).to be_empty - expect(record.errors["ecstat1"]).to be_empty - expect(record.errors["hhmemb"]).to be_empty - end - end end end diff --git a/spec/requests/bulk_upload_lettings_logs_controller_spec.rb b/spec/requests/bulk_upload_lettings_logs_controller_spec.rb index c9a22768d..abdea7079 100644 --- a/spec/requests/bulk_upload_lettings_logs_controller_spec.rb +++ b/spec/requests/bulk_upload_lettings_logs_controller_spec.rb @@ -112,6 +112,7 @@ RSpec.describe BulkUploadLettingsLogsController, type: :request do context "when requesting the previous year in a crossover period" do before do + allow(Time.zone).to receive(:now).and_return(Time.zone.now + 1.year) allow(FormHandler.instance).to receive(:lettings_in_crossover_period?).and_return(true) end diff --git a/spec/requests/bulk_upload_sales_logs_controller_spec.rb b/spec/requests/bulk_upload_sales_logs_controller_spec.rb index 4c20482be..a2d6e7ef4 100644 --- a/spec/requests/bulk_upload_sales_logs_controller_spec.rb +++ b/spec/requests/bulk_upload_sales_logs_controller_spec.rb @@ -112,6 +112,7 @@ RSpec.describe BulkUploadSalesLogsController, type: :request do context "when requesting the previous year in a crossover period" do before do + allow(Time.zone).to receive(:now).and_return(Time.zone.now + 1.year) allow(FormHandler.instance).to receive(:sales_in_crossover_period?).and_return(true) end