Browse Source

Remove irrelevant 2023 checks (#2895)

* Remove irrelevant 2023 checks

* Update/remove tests
pull/2887/head
kosiakkatrina 5 days ago committed by GitHub
parent
commit
ddebebee30
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      app/models/derived_variables/lettings_log_variables.rb
  2. 2
      app/models/derived_variables/sales_log_variables.rb
  3. 2
      app/models/form/question.rb
  4. 2
      app/models/forms/bulk_upload_form/prepare_your_file.rb
  5. 4
      app/models/lettings_log.rb
  6. 25
      app/models/sales_log.rb
  7. 2
      app/models/validations/financial_validations.rb
  8. 2
      app/models/validations/household_validations.rb
  9. 2
      app/models/validations/sales/financial_validations.rb
  10. 2
      app/models/validations/sales/household_validations.rb
  11. 46
      app/views/bulk_upload_lettings_logs/forms/prepare_your_file_2023.html.erb
  12. 40
      app/views/bulk_upload_sales_logs/forms/prepare_your_file_2023.html.erb
  13. 15
      app/views/bulk_upload_shared/guidance.html.erb
  14. 14
      spec/features/bulk_upload_sales_logs_spec.rb
  15. 8
      spec/models/sales_log_spec.rb
  16. 14
      spec/models/validations/financial_validations_spec.rb
  17. 1
      spec/requests/bulk_upload_lettings_logs_controller_spec.rb
  18. 1
      spec/requests/bulk_upload_sales_logs_controller_spec.rb

2
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

2
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

2
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

2
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

4
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

25
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?

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

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

2
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

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

46
app/views/bulk_upload_lettings_logs/forms/prepare_your_file_2023.html.erb

@ -1,46 +0,0 @@
<% content_for :before_content do %>
<%= govuk_back_link href: @form.back_path %>
<% end %>
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<%= form_with model: @form, scope: :form, url: bulk_upload_lettings_log_path(id: "prepare-your-file"), method: :patch do |f| %>
<%= f.hidden_field :year %>
<span class="govuk-caption-l">Upload lettings logs in bulk (<%= @form.year_combo %>)</span>
<h1 class="govuk-heading-l">Prepare your file</h1>
<p class="govuk-body govuk-!-margin-bottom-2"><%= 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.</p>
<h2 class="govuk-heading-s">Download template</h2>
<p class="govuk-body govuk-!-margin-bottom-2">Use one of these templates to upload logs for 2023/24:</p>
<ul class="govuk-list govuk-list--bullet">
<li>
<%= govuk_link_to "Download the new template", @form.template_path %>: In this template, the questions are in the same order as the 2023/24 paper form and web form.
</li>
</ul>
<p class="govuk-body govuk-!-margin-bottom-2">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.</p>
<h2 class="govuk-heading-s">Create your file</h2>
<ul class="govuk-list govuk-list--bullet">
<li>Fill in the template with data from your housing management system. Your data should go below the headers, with one row per log. Leave column A blank - the bulk upload fields start in column B.</li>
<li>Make sure each column of your data aligns with the matching headers above. You may need to reorder your data.</li>
<li>Use the <%= govuk_link_to "Lettings #{@form.year_combo} Bulk Upload Specification", @form.specification_path %> to check your data is in the correct format.</li>
<li><strong>Username field:</strong> To assign a log to someone else, enter the email address they use to log into CORE.</li>
<li>If you are using the new template, keep the headers. If you are using the legacy template, you can either keep or remove the headers. If you remove the headers, you should also remove the blank column A.</li>
</ul>
<%= govuk_inset_text(text: "You can upload both general needs and supported housing logs in the same file for 2023 to 2024 data.") %>
<h2 class="govuk-heading-s">Save your file</h2>
<ul class="govuk-list govuk-list--bullet">
<li>Save your file as a CSV.</li>
<li>Your file should now be ready to upload.</li>
</ul>
<%= f.govuk_submit class: "govuk-!-margin-top-7" %>
<% end %>
</div>
</div>

40
app/views/bulk_upload_sales_logs/forms/prepare_your_file_2023.html.erb

@ -1,40 +0,0 @@
<% content_for :before_content do %>
<%= govuk_back_link href: @form.back_path %>
<% end %>
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<%= form_with model: @form, scope: :form, url: bulk_upload_sales_log_path(id: "prepare-your-file"), method: :patch do |f| %>
<%= f.hidden_field :year %>
<span class="govuk-caption-l">Upload sales logs in bulk (<%= @form.year_combo %>)</span>
<h1 class="govuk-heading-l">Prepare your file</h1>
<p class="govuk-body govuk-!-margin-bottom-2"><%= 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.</p>
<h2 class="govuk-heading-s">Download template</h2>
<p class="govuk-body govuk-!-margin-bottom-2">Use one of these templates to upload logs for 2023/24:</p>
<ul class="govuk-list govuk-list--bullet">
<li><%= govuk_link_to "Download the new template", @form.template_path %>: In this template, the questions are in the same order as the 2023/24 paper form and web form.</li>
</ul>
<p class="govuk-body govuk-!-margin-bottom-2">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.</p>
<h2 class="govuk-heading-s">Create your file</h2>
<ul class="govuk-list govuk-list--bullet">
<li>Fill in the template with data from your housing management system. Your data should go below the headers, with one row per log. The bulk upload fields start at column B. Leave column A blank.</li>
<li>Make sure each column of your data aligns with the matching headers above. You may need to reorder your data.</li>
<li>Use the <%= govuk_link_to "Sales #{@form.year_combo} Bulk Upload Specification", @form.specification_path %> to check your data is in the correct format.</li>
<li><strong>Username field:</strong> To assign a log to someone else, enter the email address they use to log into CORE.</li>
<li>If you are using the new template, keep the headers. If you are using the legacy template, you can either keep or remove the headers. If you remove the headers, you should also remove the blank column A.</li>
</ul>
<h2 class="govuk-heading-s">Save your file</h2>
<ul class="govuk-list govuk-list--bullet">
<li>Save your file as a CSV.</li>
<li>Your file should now be ready to upload.</li>
</ul>
<%= f.govuk_submit %>
<% end %>
</div>
</div>

15
app/views/bulk_upload_shared/guidance.html.erb

@ -28,30 +28,15 @@
<%= accordion.with_section(heading_text: "Using the bulk upload template") do %>
<p class="govuk-body">For each collection year, we publish a bulk upload template and specification.</p>
<% if @form.year == 2023 %>
<p class="govuk-body">The bulk upload templates contain 7 or 8 rows of ‘headers’ with information about how to fill in the template, including:</p>
<% else %>
<p class="govuk-body">The bulk upload templates contain 8 rows of ‘headers’ with information about how to fill in the template, including:</p>
<% end %>
<%= 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 %>
<p class="govuk-body">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.</p>
<p class="govuk-body">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.</p>
<% if @form.year == 2023 %>
<p class="govuk-body">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.</p>
<p class="govuk-body">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.</p>
<p class="govuk-body"><strong>New template</strong>: 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.</p>
<p class="govuk-body"><%= govuk_link_to "Download the lettings bulk upload template (2023 to 2024) – New question ordering", @form.lettings_template_path %></p>
<p class="govuk-body"><%= govuk_link_to "Download the sales bulk upload template (2023 to 2024) – New question ordering", @form.sales_template_path %></p>
<p class="govuk-body"><strong>Legacy template</strong>: 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.</p>
<% else %>
<p class="govuk-body"><%= govuk_link_to "Download the lettings bulk upload template (2024 to 2025)", @form.lettings_template_path %></p>
<p class="govuk-body"><%= govuk_link_to "Download the sales bulk upload template (2024 to 2025)", @form.sales_template_path %></p>
<% end %>
<% end %>
<%= accordion.with_section(heading_text: "Using the bulk upload specification") do %>
<p class="govuk-body">The bulk upload specification contains the same information as the template headers, as well as more details about the accepted responses for each question. For multiple-choice questions, we use number or letter codes to represent each option, and the specification shows what answer each code represents.</p>

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

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

14
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

1
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

1
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

Loading…
Cancel
Save