From a65ee5676f5188a9cbde7d2ad86907f8a190b504 Mon Sep 17 00:00:00 2001 From: Manny Dinssa <44172848+Dinssa@users.noreply.github.com> Date: Tue, 22 Oct 2024 14:14:53 +0100 Subject: [PATCH 01/30] CLDC-2399: Bulk upload table styling (#2714) --- .../bulk_upload_error_row_component.html.erb | 30 +++++++++---------- .../bulk_upload_error_row_component.rb | 13 ++++++++ app/frontend/styles/_bulk-uploads.scss | 5 ++++ 3 files changed, 33 insertions(+), 15 deletions(-) diff --git a/app/components/bulk_upload_error_row_component.html.erb b/app/components/bulk_upload_error_row_component.html.erb index 65e38613f..4bd303957 100644 --- a/app/components/bulk_upload_error_row_component.html.erb +++ b/app/components/bulk_upload_error_row_component.html.erb @@ -13,7 +13,7 @@ <% if critical_errors.any? %>

Critical errors

These errors must be fixed to complete your logs.

- <%= govuk_table do |table| %> + <%= govuk_table(html_attributes: { class: potential_errors.any? ? "" : "no-bottom-border" }) do |table| %> <%= table.with_head do |head| %> <% head.with_row do |row| %> <% row.with_cell(header: true, text: "Cell") %> @@ -39,7 +39,7 @@ <% if potential_errors.any? %>

Potential errors

The following groups of cells might have conflicting data. Check the answers and fix any incorrect data.

If the answers are correct, fix the critical errors and reupload the file. You'll need to confirm that the following data is correct when the file only contains potential errors.

- <%= govuk_table do |table| %> + <%= govuk_table(html_attributes: { class: "no-bottom-border" }) do |table| %> <%= table.with_head do |head| %> <% head.with_row do |row| %> <% row.with_cell(header: true, text: "Cell") %> @@ -49,24 +49,24 @@ <% end %> <% end %> - <%= table.with_body do |body| %> - <% potential_errors.group_by(&:error).each do |error_message, errors| %> - <% errors.each_with_index do |error, index| %> - <% row_class = "grouped-rows" %> - <% row_class += " first-row" if index.zero? %> - <% row_class += " last-row" if index == errors.size - 1 %> - <% body.with_row(html_attributes: { class: row_class }) do |row| %> - <% row.with_cell(text: error.cell) %> - <% row.with_cell(text: question_for_field(error.field), html_attributes: { class: "govuk-!-width-one-half" }) %> - <% if index == 0 %> - <% row.with_cell(text: error_message.html_safe, rowspan: errors.size, html_attributes: { class: "govuk-!-font-weight-bold govuk-!-width-one-half grouped-multirow-cell" }) %> - <% end %> - <% row.with_cell(text: error.field.humanize) %> + <%= table.with_body do |body| %> + <% potential_errors.group_by(&:error).each_with_index do |(error_message, errors), group_index| %> + <% total_groups = potential_errors.group_by(&:error).size %> + <% errors.each_with_index do |error, index| %> + <% row_class = row_classes(index, errors.size) %> + <% body.with_row(html_attributes: { class: row_class }) do |row| %> + <% row.with_cell(text: error.cell) %> + <% row.with_cell(text: question_for_field(error.field), html_attributes: { class: "govuk-!-width-one-half" }) %> + <% if index == 0 %> + <% cell_class = cell_classes(group_index, total_groups) %> + <% row.with_cell(text: error_message.html_safe, rowspan: errors.size, html_attributes: { class: cell_class }) %> <% end %> + <% row.with_cell(text: error.field.humanize) %> <% end %> <% end %> <% end %> <% end %> + <% end %> <% end %> diff --git a/app/components/bulk_upload_error_row_component.rb b/app/components/bulk_upload_error_row_component.rb index 887eef10c..1cb4de9d8 100644 --- a/app/components/bulk_upload_error_row_component.rb +++ b/app/components/bulk_upload_error_row_component.rb @@ -62,4 +62,17 @@ class BulkUploadErrorRowComponent < ViewComponent::Base def sales? bulk_upload.log_type == "sales" end + + def row_classes(index, errors_size) + row_class = "grouped-rows" + row_class += " first-row" if index.zero? + row_class += " last-row" if index == errors_size - 1 + row_class + end + + def cell_classes(group_index, total_groups) + cell_class = "govuk-!-font-weight-bold govuk-!-width-one-half" + cell_class += " grouped-multirow-cell" unless group_index == total_groups - 1 + cell_class + end end diff --git a/app/frontend/styles/_bulk-uploads.scss b/app/frontend/styles/_bulk-uploads.scss index eceae6565..65213ee82 100644 --- a/app/frontend/styles/_bulk-uploads.scss +++ b/app/frontend/styles/_bulk-uploads.scss @@ -12,6 +12,11 @@ border-bottom: 1px solid #b1b4b6; } +.no-bottom-border, +.no-bottom-border > tbody > tr:last-of-type td { + border-bottom: none; +} + .text-normal-break { white-space: normal; word-break: break-all; From 443a19f42d5fe5243982e9c385b153e9a326df42 Mon Sep 17 00:00:00 2001 From: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com> Date: Tue, 22 Oct 2024 16:08:44 +0100 Subject: [PATCH 02/30] Update household validations (#2708) --- .../sales/household_validations.rb | 48 +++++++++--------- app/models/validations/shared_validations.rb | 6 ++- .../bulk_upload/sales/year2024/row_parser.rb | 12 ++--- config/locales/en.yml | 11 ---- .../validations/sales/household.en.yml | 47 +++++++++++++++++ .../sales/household_validations_spec.rb | 50 +++++++++---------- 6 files changed, 107 insertions(+), 67 deletions(-) create mode 100644 config/locales/validations/sales/household.en.yml diff --git a/app/models/validations/sales/household_validations.rb b/app/models/validations/sales/household_validations.rb index e006374aa..fb1ea65c2 100644 --- a/app/models/validations/sales/household_validations.rb +++ b/app/models/validations/sales/household_validations.rb @@ -9,9 +9,9 @@ module Validations::Sales::HouseholdValidations 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.household.buylivein.buyers_will_live_in_property_values_inconsistent_setup") - record.errors.add :buy1livein, I18n.t("validations.household.buylivein.buyers_will_live_in_property_values_inconsistent") - record.errors.add :buy2livein, I18n.t("validations.household.buylivein.buyers_will_live_in_property_values_inconsistent") + 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") + record.errors.add :buy2livein, I18n.t("validations.sales.household.buy2livein.buyers_will_live_in_property_values_inconsistent") end end @@ -20,8 +20,8 @@ module Validations::Sales::HouseholdValidations return unless record.discounted_ownership_sale? && record.prevten if [3, 4, 5, 6, 7, 9, 0].include?(record.prevten) - record.errors.add :prevten, I18n.t("validations.household.prevten.invalid_for_discounted_sale") - record.errors.add :ownershipsch, I18n.t("validations.household.prevten.invalid_for_discounted_sale") + record.errors.add :prevten, I18n.t("validations.sales.household.prevten.prevten_invalid_for_discounted_sale") + record.errors.add :ownershipsch, I18n.t("validations.sales.household.ownershipsch.prevten_invalid_for_discounted_sale") end end @@ -34,11 +34,11 @@ module Validations::Sales::HouseholdValidations next unless age && relationship if age < 16 && !relationship_is_child_other_or_refused?(relationship) - record.errors.add "age#{person_num}", I18n.t("validations.household.age.child_under_16_relat_sales", person_num:) - record.errors.add "relat#{person_num}", I18n.t("validations.household.relat.child_under_16_sales", person_num:) + record.errors.add "age#{person_num}", I18n.t("validations.sales.household.age.child_under_16", person_num:) + record.errors.add "relat#{person_num}", I18n.t("validations.sales.household.relat.child_under_16", person_num:) elsif age >= 20 && person_is_child?(relationship) - record.errors.add "age#{person_num}", I18n.t("validations.household.age.child_over_20") - record.errors.add "relat#{person_num}", I18n.t("validations.household.relat.child_over_20") + record.errors.add "age#{person_num}", I18n.t("validations.sales.household.age.child_over_20") + record.errors.add "relat#{person_num}", I18n.t("validations.sales.household.relat.child_over_20") end end end @@ -58,16 +58,16 @@ module Validations::Sales::HouseholdValidations child = person_is_child?(relationship) if age_between_16_19 && !(student || economic_status_refused) && child - record.errors.add "ecstat#{person_num}", I18n.t("validations.household.ecstat.student_16_19.must_be_student") - record.errors.add "age#{person_num}", I18n.t("validations.household.age.student_16_19.cannot_be_16_19.child_not_student") - record.errors.add "relat#{person_num}", I18n.t("validations.household.relat.student_16_19.cannot_be_child.16_19_not_student") + record.errors.add "ecstat#{person_num}", I18n.t("validations.sales.household.ecstat.student_16_19.must_be_student") + record.errors.add "age#{person_num}", I18n.t("validations.sales.household.age.student_16_19.cannot_be_16_19.child_not_student") + record.errors.add "relat#{person_num}", I18n.t("validations.sales.household.relat.student_16_19.cannot_be_child.16_19_not_student") end next unless !age_between_16_19 && student && child - record.errors.add "age#{person_num}", I18n.t("validations.household.age.student_16_19.must_be_16_19") - record.errors.add "ecstat#{person_num}", I18n.t("validations.household.ecstat.student_16_19.cannot_be_student.child_not_16_19") - record.errors.add "relat#{person_num}", I18n.t("validations.household.relat.student_16_19.cannot_be_child.student_not_16_19") + record.errors.add "age#{person_num}", I18n.t("validations.sales.household.age.student_16_19.must_be_16_19") + record.errors.add "ecstat#{person_num}", I18n.t("validations.sales.household.ecstat.student_16_19.cannot_be_student.child_not_16_19") + record.errors.add "relat#{person_num}", I18n.t("validations.sales.household.relat.student_16_19.cannot_be_child.student_not_16_19") end end @@ -78,12 +78,12 @@ module Validations::Sales::HouseholdValidations next unless age && economic_status if age < 16 && !economic_status_is_child_other_or_refused?(economic_status) && !record.form.start_year_after_2024? - record.errors.add "ecstat#{person_num}", I18n.t("validations.household.ecstat.child_under_16", person_num:) - record.errors.add "age#{person_num}", I18n.t("validations.household.age.child_under_16_ecstat", person_num:) + record.errors.add "ecstat#{person_num}", I18n.t("validations.sales.household.ecstat.child_under_16", person_num:) + record.errors.add "age#{person_num}", I18n.t("validations.sales.household.age.child_under_16_ecstat", person_num:) end if person_is_economic_child?(economic_status) && age > 16 - record.errors.add "ecstat#{person_num}", I18n.t("validations.household.ecstat.child_over_16", person_num:) - record.errors.add "age#{person_num}", I18n.t("validations.household.age.child_over_16", person_num:) + record.errors.add "ecstat#{person_num}", I18n.t("validations.sales.household.ecstat.child_over_16", person_num:) + record.errors.add "age#{person_num}", I18n.t("validations.sales.household.age.child_over_16", person_num:) end end end @@ -99,17 +99,17 @@ module Validations::Sales::HouseholdValidations next unless person_age > buyer_1_age - 12 && person_is_child?(relationship) - record.errors.add "age1", I18n.t("validations.household.age.child_12_years_younger") - record.errors.add "age#{person_num}", I18n.t("validations.household.age.child_12_years_younger") - record.errors.add "relat#{person_num}", I18n.t("validations.household.age.child_12_years_younger") + record.errors.add "age1", I18n.t("validations.sales.household.age1.child_12_years_younger") + record.errors.add "age#{person_num}", I18n.t("validations.sales.household.age.child_12_years_younger") + record.errors.add "relat#{person_num}", I18n.t("validations.sales.household.relat.child_12_years_younger") end end def validate_buyer_not_child(record) return unless record.saledate && record.form.start_year_after_2024? - record.errors.add "ecstat1", I18n.t("validations.household.ecstat.buyer_cannot_be_child", buyer_index: "1") if person_is_economic_child?(record.ecstat1) - record.errors.add "ecstat2", I18n.t("validations.household.ecstat.buyer_cannot_be_child", buyer_index: "2") if person_is_economic_child?(record.ecstat2) && record.joint_purchase? + record.errors.add "ecstat1", I18n.t("validations.sales.household.ecstat1.buyer_cannot_be_child") if person_is_economic_child?(record.ecstat1) + record.errors.add "ecstat2", I18n.t("validations.sales.household.ecstat2.buyer_cannot_be_child") if person_is_economic_child?(record.ecstat2) && record.joint_purchase? end private diff --git a/app/models/validations/shared_validations.rb b/app/models/validations/shared_validations.rb index 217b2c170..a2ae916c1 100644 --- a/app/models/validations/shared_validations.rb +++ b/app/models/validations/shared_validations.rb @@ -131,7 +131,11 @@ module Validations::SharedValidations partner_numbers = (2..max_people).select { |n| person_is_partner?(record["relat#{n}"]) } if partner_numbers.count > 1 partner_numbers.each do |n| - record.errors.add "relat#{n}", I18n.t("validations.household.relat.one_partner") + if record.sales? + record.errors.add "relat#{n}", I18n.t("validations.sales.household.relat.one_partner") + else + record.errors.add "relat#{n}", I18n.t("validations.household.relat.one_partner") + end end end end diff --git a/app/services/bulk_upload/sales/year2024/row_parser.rb b/app/services/bulk_upload/sales/year2024/row_parser.rb index fbc99ba02..35984a045 100644 --- a/app/services/bulk_upload/sales/year2024/row_parser.rb +++ b/app/services/bulk_upload/sales/year2024/row_parser.rb @@ -1469,10 +1469,10 @@ private def validate_buyer1_economic_status if field_35 == 9 if field_31.present? && field_31.to_i >= 16 - errors.add(:field_35, I18n.t("validations.household.ecstat.buyer_cannot_be_over_16_and_child", buyer_index: "1")) - errors.add(:field_31, I18n.t("validations.household.ecstat.buyer_cannot_be_over_16_and_child", buyer_index: "1")) + errors.add(:field_35, I18n.t("validations.sales.household.ecstat.buyer_cannot_be_over_16_and_child", buyer_index: "1")) + errors.add(:field_31, I18n.t("validations.sales.household.ecstat.buyer_cannot_be_over_16_and_child", buyer_index: "1")) else - errors.add(:field_35, I18n.t("validations.household.ecstat.buyer_cannot_be_child", buyer_index: "1")) + errors.add(:field_35, I18n.t("validations.sales.household.ecstat1.buyer_cannot_be_child")) end end end @@ -1482,10 +1482,10 @@ private if field_42 == 9 if field_38.present? && field_38.to_i >= 16 - errors.add(:field_42, I18n.t("validations.household.ecstat.buyer_cannot_be_over_16_and_child", buyer_index: "2")) - errors.add(:field_38, I18n.t("validations.household.ecstat.buyer_cannot_be_over_16_and_child", buyer_index: "2")) + errors.add(:field_42, I18n.t("validations.sales.household.ecstat.buyer_cannot_be_over_16_and_child", buyer_index: "2")) + errors.add(:field_38, I18n.t("validations.sales.household.ecstat.buyer_cannot_be_over_16_and_child", buyer_index: "2")) else - errors.add(:field_42, I18n.t("validations.household.ecstat.buyer_cannot_be_child", buyer_index: "2")) + errors.add(:field_42, I18n.t("validations.sales.household.ecstat2.buyer_cannot_be_child")) end end end diff --git a/config/locales/en.yml b/config/locales/en.yml index b39183591..7cff7aae7 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -501,11 +501,8 @@ en: retired_female: "A female tenant who is retired must be 60 or over." retired_over_70: "Answer cannot be over 70 as person %{person_num} has economic status that is not ‘retired’." child_under_16_relat_lettings: "Answer cannot be under 16 as person %{person_num}'s relationship to the lead tenant is ‘partner’." - child_under_16_relat_sales: "Answer cannot be under 16 as person %{person_num}'s relationship to buyer 1 is ‘partner’." child_under_16_ecstat: "Answer cannot be under 16 as person %{person_num}’s working situation is not ‘child under 16’, ‘other’ or ‘prefers not to say’." child_over_16: "Answer cannot be over 16 as person’s %{person_num} working situation is ‘child under 16‘." - child_over_20: "Answer cannot be 20 or over as the relationship is ‘child’." - child_12_years_younger: "A child must be at least 12 years younger than their parent." not_student_16_19: "Answer cannot be between 16 and 19 as person %{person_num} is a child of the lead tenant but is not a full-time student." student_16_19: cannot_be_16_19: @@ -528,12 +525,8 @@ en: retired_female: "Answer cannot be ‘retired’ as the female tenant is under 60." not_child_16_19: cannot_be_student: "Person cannot be a student if they are aged 16-19 but are not a child." - buyer_cannot_be_child: "Buyer %{buyer_index} cannot have a working situation of child under 16." - buyer_cannot_be_over_16_and_child: "Buyer %{buyer_index}'s age cannot be 16 or over if their working situation is child under 16." relat: - child_under_16_sales: "Answer cannot be ‘partner’ as you told us person %{person_num}'s age is under 16." child_under_16_lettings: "Answer cannot be ‘partner’ as you told us person %{person_num}'s age is under 16." - child_over_20: "Answer cannot be ‘child’ if the person's age is 20 or over." one_partner: "Number of partners cannot be greater than 1." not_student_16_19: "Answer cannot be ‘child’ as you told us the person %{person_num} is between 16 and 19 and is not a full-time student." student_16_19: @@ -556,7 +549,6 @@ en: internal_transfer: "Answer cannot be %{prevten} as this tenancy is an internal transfer." la_general_needs: internal_transfer: "Answer cannot be a fixed-term or lifetime local authority general needs tenancy as it’s an internal transfer and a private registered provider is on the tenancy agreement." - invalid_for_discounted_sale: "Buyer 1’s previous tenure should be “local authority tenant” or “private registered provider or housing association tenant” for discounted sales." referral: secure_tenancy: "Answer must be internal transfer as this is a secure tenancy." rsnvac_non_temp: "Answer cannot be this source of referral as this is a re-let to tenant who occupied the same property as temporary accommodation." @@ -596,9 +588,6 @@ en: no_choices: "You cannot answer this question as you told us nobody in the household has a physical or mental health condition (or other illness) expected to last 12 months or more." postcode: discounted_ownership: "Last settled accommodation and discounted ownership property postcodes must match." - buylivein: - buyers_will_live_in_property_values_inconsistent_setup: "You have already told us that both buyer 1 and buyer 2 will not live in the property." - buyers_will_live_in_property_values_inconsistent: "You have already told us that the buyers will live in the property. Either buyer 1 or buyer 2 must live in the property." nationality: "Select a valid nationality." tenancy: diff --git a/config/locales/validations/sales/household.en.yml b/config/locales/validations/sales/household.en.yml new file mode 100644 index 000000000..c1f90971c --- /dev/null +++ b/config/locales/validations/sales/household.en.yml @@ -0,0 +1,47 @@ +en: + validations: + sales: + household: + buylivein: + buyers_will_live_in_property_values_inconsistent: "You have already told us that both buyer 1 and buyer 2 will not live in the property." + buy1livein: + buyers_will_live_in_property_values_inconsistent: "You have already told us that the buyers will live in the property. Either buyer 1 or buyer 2 must live in the property." + buy2livein: + buyers_will_live_in_property_values_inconsistent: "You have already told us that the buyers will live in the property. Either buyer 1 or buyer 2 must live in the property." + ownershipsch: + prevten_invalid_for_discounted_sale: "Buyer 1’s previous tenure should be “local authority tenant” or “private registered provider or housing association tenant” for discounted sales." + prevten: + prevten_invalid_for_discounted_sale: "Buyer 1’s previous tenure should be “local authority tenant” or “private registered provider or housing association tenant” for discounted sales." + age1: + child_12_years_younger: "A child must be at least 12 years younger than their parent." + ecstat1: + buyer_cannot_be_child: "Buyer 1 cannot have a working situation of child under 16." + ecstat2: + buyer_cannot_be_child: "Buyer 2 cannot have a working situation of child under 16." + age: + child_12_years_younger: "A child must be at least 12 years younger than their parent." + child_under_16: "Answer cannot be under 16 as person %{person_num}'s relationship to buyer 1 is ‘partner’." + child_under_16_ecstat: "Answer cannot be under 16 as person %{person_num}’s working situation is not ‘child under 16’, ‘other’ or ‘prefers not to say’." + child_over_16: "Answer cannot be over 16 as person’s %{person_num} working situation is ‘child under 16‘." + child_over_20: "Answer cannot be 20 or over as the relationship is ‘child’." + student_16_19: + cannot_be_16_19: + child_not_student: "Person cannot be aged 16-19 if they have relationship ‘child’ but are not a student." + must_be_16_19: "Person must be aged 16-19 if they are a student and have relationship ‘child’." + relat: + one_partner: "Number of partners cannot be greater than 1." + child_12_years_younger: "A child must be at least 12 years younger than their parent." + child_under_16: "Answer cannot be ‘partner’ as you told us person %{person_num}'s age is under 16." + child_over_20: "Answer cannot be ‘child’ if the person's age is 20 or over." + student_16_19: + cannot_be_child: + student_not_16_19: "Answer cannot be ‘child’ if the person is a student but not aged 16-19." + 16_19_not_student: "Answer cannot be ‘child’ if the person is aged 16-19 but not a student." + ecstat: + child_under_16: "Person %{person_num}’s working situation must be ‘child under 16’, ‘other’ or ‘prefers not to say’ as you told us they’re under 16." + child_over_16: "Answer cannot be ‘child under 16’ as you told us the person %{person_num} is older than 16." + student_16_19: + must_be_student: "Person must be a student if they are aged 16-19 and have relationship ‘child’." + cannot_be_student: + child_not_16_19: "Person cannot be a student if they are not aged 16-19 but have relationship ‘child’." + buyer_cannot_be_over_16_and_child: "Buyer %{buyer_index}'s age cannot be 16 or over if their working situation is child under 16." diff --git a/spec/models/validations/sales/household_validations_spec.rb b/spec/models/validations/sales/household_validations_spec.rb index 510681420..cffb42ab1 100644 --- a/spec/models/validations/sales/household_validations_spec.rb +++ b/spec/models/validations/sales/household_validations_spec.rb @@ -15,11 +15,11 @@ RSpec.describe Validations::Sales::HouseholdValidations do record.relat3 = "P" household_validator.validate_partner_count(record) expect(record.errors["relat2"]) - .to include(match I18n.t("validations.household.relat.one_partner")) + .to include(match I18n.t("validations.sales.household.relat.one_partner")) expect(record.errors["relat3"]) - .to include(match I18n.t("validations.household.relat.one_partner")) + .to include(match I18n.t("validations.sales.household.relat.one_partner")) expect(record.errors["relat4"]) - .not_to include(match I18n.t("validations.household.relat.one_partner")) + .not_to include(match I18n.t("validations.sales.household.relat.one_partner")) end it "expects that a tenant can have a partner" do @@ -47,9 +47,9 @@ RSpec.describe Validations::Sales::HouseholdValidations do record.relat2 = "P" household_validator.validate_person_age_matches_relationship(record) expect(record.errors["relat2"]) - .to include(match I18n.t("validations.household.relat.child_under_16_sales", person_num: 2)) + .to include(match I18n.t("validations.sales.household.relat.child_under_16", person_num: 2)) expect(record.errors["age2"]) - .to include(match I18n.t("validations.household.age.child_under_16_relat_sales", person_num: 2)) + .to include(match I18n.t("validations.sales.household.age.child_under_16", person_num: 2)) end end @@ -58,9 +58,9 @@ RSpec.describe Validations::Sales::HouseholdValidations do record.relat2 = "C" household_validator.validate_person_age_matches_relationship(record) expect(record.errors["relat2"]) - .to include(match I18n.t("validations.household.relat.child_over_20")) + .to include(match I18n.t("validations.sales.household.relat.child_over_20")) expect(record.errors["age2"]) - .to include(match I18n.t("validations.household.age.child_over_20")) + .to include(match I18n.t("validations.sales.household.age.child_over_20")) end end @@ -94,9 +94,9 @@ RSpec.describe Validations::Sales::HouseholdValidations do record.ecstat2 = 1 household_validator.validate_person_age_matches_economic_status(record) expect(record.errors["ecstat2"]) - .to include(match I18n.t("validations.household.ecstat.child_under_16", person_num: 2)) + .to include(match I18n.t("validations.sales.household.ecstat.child_under_16", person_num: 2)) expect(record.errors["age2"]) - .to include(match I18n.t("validations.household.age.child_under_16_ecstat", person_num: 2)) + .to include(match I18n.t("validations.sales.household.age.child_under_16_ecstat", person_num: 2)) end it "expects that person's economic status is Child" do @@ -112,9 +112,9 @@ RSpec.describe Validations::Sales::HouseholdValidations do record.ecstat2 = 9 household_validator.validate_person_age_matches_economic_status(record) expect(record.errors["ecstat2"]) - .to include(match I18n.t("validations.household.ecstat.child_over_16", person_num: 2)) + .to include(match I18n.t("validations.sales.household.ecstat.child_over_16", person_num: 2)) expect(record.errors["age2"]) - .to include(match I18n.t("validations.household.age.child_over_16", person_num: 2)) + .to include(match I18n.t("validations.sales.household.age.child_over_16", person_num: 2)) end end @@ -126,9 +126,9 @@ RSpec.describe Validations::Sales::HouseholdValidations do record.ecstat2 = 1 household_validator.validate_person_age_matches_economic_status(record) expect(record.errors["ecstat2"]) - .not_to include(match I18n.t("validations.household.ecstat.child_under_16", person_num: 2)) + .not_to include(match I18n.t("validations.sales.household.ecstat.child_under_16", person_num: 2)) expect(record.errors["age2"]) - .not_to include(match I18n.t("validations.household.age.child_under_16_ecstat", person_num: 2)) + .not_to include(match I18n.t("validations.sales.household.age.child_under_16_ecstat", person_num: 2)) end end end @@ -143,11 +143,11 @@ RSpec.describe Validations::Sales::HouseholdValidations do record.relat2 = "C" household_validator.validate_child_12_years_younger(record) expect(record.errors["age1"]) - .to include(match I18n.t("validations.household.age.child_12_years_younger", person_num: 2)) + .to include(match I18n.t("validations.sales.household.age.child_12_years_younger", person_num: 2)) expect(record.errors["age2"]) - .to include(match I18n.t("validations.household.age.child_12_years_younger", person_num: 2)) + .to include(match I18n.t("validations.sales.household.age.child_12_years_younger", person_num: 2)) expect(record.errors["relat2"]) - .to include(match I18n.t("validations.household.age.child_12_years_younger", person_num: 2)) + .to include(match I18n.t("validations.sales.household.age.child_12_years_younger", person_num: 2)) end it "expects the child is at least 12 years younger than buyer 1" do @@ -206,11 +206,11 @@ RSpec.describe Validations::Sales::HouseholdValidations do record.relat2 = "C" household_validator.validate_person_age_and_relationship_matches_economic_status(record) expect(record.errors["relat2"]) - .to include(match I18n.t("validations.household.relat.student_16_19.cannot_be_child.16_19_not_student")) + .to include(match I18n.t("validations.sales.household.relat.student_16_19.cannot_be_child.16_19_not_student")) expect(record.errors["age2"]) - .to include(match I18n.t("validations.household.age.student_16_19.cannot_be_16_19.child_not_student")) + .to include(match I18n.t("validations.sales.household.age.student_16_19.cannot_be_16_19.child_not_student")) expect(record.errors["ecstat2"]) - .to include(match I18n.t("validations.household.ecstat.student_16_19.must_be_student")) + .to include(match I18n.t("validations.sales.household.ecstat.student_16_19.must_be_student")) end it "adds errors for a person who is a child of the buyer and a student but not aged 16-19" do @@ -219,11 +219,11 @@ RSpec.describe Validations::Sales::HouseholdValidations do record.relat2 = "C" household_validator.validate_person_age_and_relationship_matches_economic_status(record) expect(record.errors["relat2"]) - .to include(match I18n.t("validations.household.relat.student_16_19.cannot_be_child.student_not_16_19")) + .to include(match I18n.t("validations.sales.household.relat.student_16_19.cannot_be_child.student_not_16_19")) expect(record.errors["age2"]) - .to include(match I18n.t("validations.household.age.student_16_19.must_be_16_19")) + .to include(match I18n.t("validations.sales.household.age.student_16_19.must_be_16_19")) expect(record.errors["ecstat2"]) - .to include(match I18n.t("validations.household.ecstat.student_16_19.cannot_be_student.child_not_16_19")) + .to include(match I18n.t("validations.sales.household.ecstat.student_16_19.cannot_be_student.child_not_16_19")) end end @@ -316,9 +316,9 @@ RSpec.describe Validations::Sales::HouseholdValidations do it "triggers a validation if buyer two will also not live in the property" do sales_log.buy2livein = 2 household_validator.validate_buyers_living_in_property(sales_log) - expect(sales_log.errors[:buylivein]).to include I18n.t("validations.household.buylivein.buyers_will_live_in_property_values_inconsistent_setup") - expect(sales_log.errors[:buy2livein]).to include I18n.t("validations.household.buylivein.buyers_will_live_in_property_values_inconsistent") - expect(sales_log.errors[:buy1livein]).to include I18n.t("validations.household.buylivein.buyers_will_live_in_property_values_inconsistent") + expect(sales_log.errors[:buylivein]).to include I18n.t("validations.sales.household.buylivein.buyers_will_live_in_property_values_inconsistent") + expect(sales_log.errors[:buy2livein]).to include I18n.t("validations.sales.household.buy2livein.buyers_will_live_in_property_values_inconsistent") + expect(sales_log.errors[:buy1livein]).to include I18n.t("validations.sales.household.buy1livein.buyers_will_live_in_property_values_inconsistent") end end end From 9bd3389c846243bf9ba1bb81334661f2c5ff53ba Mon Sep 17 00:00:00 2001 From: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com> Date: Tue, 22 Oct 2024 16:27:51 +0100 Subject: [PATCH 03/30] CLDC-3655 Extract property information validations (#2700) * Extract property information validations * Refactor possesive variable from errors --- app/models/form/sales/questions/uprn.rb | 2 +- app/models/form/sales/questions/uprn_known.rb | 2 +- .../validations/sales/property_validations.rb | 15 ++++++----- config/locales/en.yml | 6 ----- .../sales/property_information.en.yml | 27 +++++++++++++++++++ 5 files changed, 37 insertions(+), 15 deletions(-) create mode 100644 config/locales/validations/sales/property_information.en.yml diff --git a/app/models/form/sales/questions/uprn.rb b/app/models/form/sales/questions/uprn.rb index 75a41a0ec..94aaccb43 100644 --- a/app/models/form/sales/questions/uprn.rb +++ b/app/models/form/sales/questions/uprn.rb @@ -16,7 +16,7 @@ class Form::Sales::Questions::Uprn < ::Form::Question end def unanswered_error_message - I18n.t("validations.property.uprn.invalid") + I18n.t("validations.sales.property_information.uprn.invalid") end def get_extra_check_answer_value(log) diff --git a/app/models/form/sales/questions/uprn_known.rb b/app/models/form/sales/questions/uprn_known.rb index 44ce03cad..fdd0c9e9a 100644 --- a/app/models/form/sales/questions/uprn_known.rb +++ b/app/models/form/sales/questions/uprn_known.rb @@ -31,7 +31,7 @@ class Form::Sales::Questions::UprnKnown < ::Form::Question }.freeze def unanswered_error_message - I18n.t("validations.property.uprn_known.invalid") + I18n.t("validations.sales.property_information.uprn_known.invalid") end QUESTION_NUMBER_FROM_YEAR = { 2023 => 14, 2024 => 15 }.freeze diff --git a/app/models/validations/sales/property_validations.rb b/app/models/validations/sales/property_validations.rb index 50818c422..59d616c9a 100644 --- a/app/models/validations/sales/property_validations.rb +++ b/app/models/validations/sales/property_validations.rb @@ -4,10 +4,11 @@ module Validations::Sales::PropertyValidations return unless record.ppostcode_full.present? && record.postcode_full.present? if record.discounted_ownership_sale? && record.ppostcode_full != record.postcode_full - record.errors.add :postcode_full, I18n.t("validations.property.postcode.must_match_previous", buyer_possessive: record.joint_purchase? ? "Buyers’" : "Buyer’s") - record.errors.add :ppostcode_full, I18n.t("validations.property.postcode.must_match_previous", buyer_possessive: record.joint_purchase? ? "Buyers’" : "Buyer’s") - record.errors.add :ownershipsch, I18n.t("validations.property.postcode.must_match_previous", buyer_possessive: record.joint_purchase? ? "Buyers’" : "Buyer’s") - record.errors.add :uprn, I18n.t("validations.property.postcode.must_match_previous", buyer_possessive: record.joint_purchase? ? "Buyers’" : "Buyer’s") + joint_purchase_id = record.joint_purchase? ? "joint_purchase" : "not_joint_purchase" + record.errors.add :postcode_full, I18n.t("validations.sales.property_information.postcode_full.postcode_must_match_previous.#{joint_purchase_id}") + record.errors.add :ppostcode_full, I18n.t("validations.sales.property_information.ppostcode_full.postcode_must_match_previous.#{joint_purchase_id}") + record.errors.add :ownershipsch, I18n.t("validations.sales.property_information.ownershipsch.postcode_must_match_previous.#{joint_purchase_id}") + record.errors.add :uprn, I18n.t("validations.sales.property_information.uprn.postcode_must_match_previous.#{joint_purchase_id}") end end @@ -15,8 +16,8 @@ module Validations::Sales::PropertyValidations return unless record.proptype.present? && record.beds.present? if record.is_bedsit? && record.beds > 1 - record.errors.add :proptype, I18n.t("validations.property.proptype.bedsits_have_max_one_bedroom") - record.errors.add :beds, I18n.t("validations.property.beds.bedsits_have_max_one_bedroom") + record.errors.add :proptype, I18n.t("validations.sales.property_information.proptype.bedsits_have_max_one_bedroom") + record.errors.add :beds, I18n.t("validations.sales.property_information.beds.bedsits_have_max_one_bedroom") end end @@ -25,6 +26,6 @@ module Validations::Sales::PropertyValidations return if record.uprn.match?(/^[0-9]{1,12}$/) - record.errors.add :uprn, I18n.t("validations.property.uprn.invalid") + record.errors.add :uprn, I18n.t("validations.sales.property_information.uprn.invalid") end end diff --git a/config/locales/en.yml b/config/locales/en.yml index 7cff7aae7..ff73bfdcb 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -382,12 +382,6 @@ en: one_bedroom_bedsit: "A bedsit can only have one bedroom." one_seven_bedroom_shared: "A shared house must have 1 to 7 bedrooms." one_three_bedroom_single_tenant_shared: "A shared house with fewer than two tenants must have 1 to 3 bedrooms." - beds: - bedsits_have_max_one_bedroom: "Number of bedrooms must be 1 if the property is a bedsit." - proptype: - bedsits_have_max_one_bedroom: "Answer cannot be 'Bedsit' if the property has 2 or more bedrooms." - postcode: - must_match_previous: "%{buyer_possessive} last accommodation and discounted ownership postcodes must match." financial: tshortfall: diff --git a/config/locales/validations/sales/property_information.en.yml b/config/locales/validations/sales/property_information.en.yml new file mode 100644 index 000000000..e69f90edf --- /dev/null +++ b/config/locales/validations/sales/property_information.en.yml @@ -0,0 +1,27 @@ +en: + validations: + sales: + property_information: + postcode_full: + postcode_must_match_previous: + joint_purchase: "Buyers’ last accommodation and discounted ownership postcodes must match." + not_joint_purchase: "Buyer’s last accommodation and discounted ownership postcodes must match." + ppostcode_full: + postcode_must_match_previous: + joint_purchase: "Buyers’ last accommodation and discounted ownership postcodes must match." + not_joint_purchase: "Buyer’s last accommodation and discounted ownership postcodes must match." + ownershipsch: + postcode_must_match_previous: + joint_purchase: "Buyers’ last accommodation and discounted ownership postcodes must match." + not_joint_purchase: "Buyer’s last accommodation and discounted ownership postcodes must match." + uprn: + postcode_must_match_previous: + joint_purchase: "Buyers’ last accommodation and discounted ownership postcodes must match." + not_joint_purchase: "Buyer’s last accommodation and discounted ownership postcodes must match." + invalid: "UPRN must be 12 digits or less." + beds: + bedsits_have_max_one_bedroom: "Number of bedrooms must be 1 if the property is a bedsit." + proptype: + bedsits_have_max_one_bedroom: "Answer cannot be 'Bedsit' if the property has 2 or more bedrooms." + uprn_known: + invalid: "You must answer UPRN known?" From e71b2aeb9f687c9ac41d2b3e5993d5867a6f4690 Mon Sep 17 00:00:00 2001 From: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com> Date: Wed, 23 Oct 2024 10:21:41 +0100 Subject: [PATCH 04/30] CLDC-3638 Allow adding custom resources (#2690) * Stub some collection resource requests * Rebase changes * Add upload new resource page * Allow adding custom collection resources * Display and validate additional resources * Allow downloading additional collection resources * Allow updating additional resources * Display additional resources on the homepage * Add delete link to additional resources * Update hint text * Update tests * Allow unauthenticated users to donwload additional collection resources * Add some changes to copy and styling * Add content type to the files * Validate short display name at the same time as file --- .../collection_resources_controller.rb | 122 +++++-- app/controllers/start_controller.rb | 2 + app/helpers/collection_resources_helper.rb | 2 +- app/models/collection_resource.rb | 31 +- app/services/collection_resources_service.rb | 3 +- .../mandatory_collection_resources_service.rb | 1 + app/services/storage/local_disk_service.rb | 2 +- app/services/storage/s3_service.rb | 21 +- .../_collection_resource_summary_list.erb | 19 +- app/views/collection_resources/edit.html.erb | 21 +- app/views/collection_resources/index.html.erb | 4 +- app/views/collection_resources/new.html.erb | 36 ++ .../layouts/_collection_resources.html.erb | 4 +- config/locales/en.yml | 7 +- config/routes.rb | 8 +- spec/factories/collection_resource.rb | 10 + spec/features/collection_resources_spec.rb | 73 ++++ .../collection_resources_helper_spec.rb | 12 +- .../collection_resources_controller_spec.rb | 342 +++++++++++++++++- spec/requests/start_controller_spec.rb | 2 + .../collection_resources_service_spec.rb | 2 +- 21 files changed, 668 insertions(+), 56 deletions(-) create mode 100644 app/views/collection_resources/new.html.erb diff --git a/app/controllers/collection_resources_controller.rb b/app/controllers/collection_resources_controller.rb index ed080c749..5203ceea1 100644 --- a/app/controllers/collection_resources_controller.rb +++ b/app/controllers/collection_resources_controller.rb @@ -1,13 +1,15 @@ class CollectionResourcesController < ApplicationController include CollectionResourcesHelper - before_action :authenticate_user!, except: %i[download_mandatory_collection_resource] + before_action :authenticate_user!, except: %i[download_mandatory_collection_resource download_additional_collection_resource] def index render_not_found unless current_user.support? @mandatory_lettings_collection_resources_per_year = MandatoryCollectionResourcesService.generate_resources("lettings", editable_collection_resource_years) @mandatory_sales_collection_resources_per_year = MandatoryCollectionResourcesService.generate_resources("sales", editable_collection_resource_years) + @additional_lettings_collection_resources_per_year = CollectionResource.where(log_type: "lettings", mandatory: false).group_by(&:year) + @additional_sales_collection_resources_per_year = CollectionResource.where(log_type: "sales", mandatory: false).group_by(&:year) end def download_mandatory_collection_resource @@ -23,7 +25,16 @@ class CollectionResourcesController < ApplicationController download_resource(resource.download_filename) end - def edit + def download_additional_collection_resource + resource = CollectionResource.find_by(id: params[:collection_resource_id]) + + return render_not_found unless resource + return render_not_found unless resource_for_year_can_be_downloaded?(resource.year) + + download_resource(resource.download_filename) + end + + def edit_mandatory_collection_resource return render_not_found unless current_user.support? year = params[:year].to_i @@ -39,7 +50,18 @@ class CollectionResourcesController < ApplicationController render "collection_resources/edit" end - def update + def edit_additional_collection_resource + return render_not_found unless current_user.support? + + @collection_resource = CollectionResource.find_by(id: params[:collection_resource_id]) + + return render_not_found unless @collection_resource + return render_not_found unless resource_for_year_can_be_updated?(@collection_resource.year) + + render "collection_resources/edit" + end + + def update_mandatory_collection_resource return render_not_found unless current_user.support? year = resource_params[:year].to_i @@ -52,7 +74,8 @@ class CollectionResourcesController < ApplicationController @collection_resource = MandatoryCollectionResourcesService.generate_resource(log_type, year, resource_type) render_not_found unless @collection_resource - validate_file(file) + @collection_resource.file = file + @collection_resource.validate_attached_file return render "collection_resources/edit" if @collection_resource.errors.any? @@ -68,6 +91,36 @@ class CollectionResourcesController < ApplicationController redirect_to collection_resources_path end + def update_additional_collection_resource + return render_not_found unless current_user.support? + + @collection_resource = CollectionResource.find_by(id: params[:collection_resource_id]) + + return render_not_found unless @collection_resource + return render_not_found unless resource_for_year_can_be_updated?(@collection_resource.year) + + @collection_resource.file = resource_params[:file] + @collection_resource.validate_attached_file + @collection_resource.validate_short_display_name + return render "collection_resources/edit" if @collection_resource.errors.any? + + @collection_resource.short_display_name = resource_params[:short_display_name] + @collection_resource.download_filename = @collection_resource.file&.original_filename + @collection_resource.display_name = "#{@collection_resource.log_type} #{@collection_resource.short_display_name} (#{text_year_range_format(@collection_resource.year)})" + if @collection_resource.save + begin + CollectionResourcesService.new.upload_collection_resource(@collection_resource.download_filename, @collection_resource.file) + flash[:notice] = "The #{@collection_resource.log_type} #{text_year_range_format(@collection_resource.year)} #{@collection_resource.short_display_name.downcase} has been updated." + redirect_to collection_resources_path + rescue StandardError + @collection_resource.errors.add(:file, :error_uploading) + render "collection_resources/edit" + end + else + render "collection_resources/edit" + end + end + def confirm_mandatory_collection_resources_release return render_not_found unless current_user.support? @@ -91,10 +144,50 @@ class CollectionResourcesController < ApplicationController redirect_to collection_resources_path end + def new + return render_not_found unless current_user.support? + + year = params[:year].to_i + log_type = params[:log_type] + + return render_not_found unless editable_collection_resource_years.include?(year) + + @collection_resource = CollectionResource.new(year:, log_type:) + end + + def create + return render_not_found unless current_user.support? && editable_collection_resource_years.include?(resource_params[:year].to_i) + + @collection_resource = CollectionResource.new(resource_params) + @collection_resource.download_filename ||= @collection_resource.file&.original_filename + @collection_resource.display_name = "#{@collection_resource.log_type} #{@collection_resource.short_display_name} (#{text_year_range_format(@collection_resource.year)})" + + @collection_resource.validate_attached_file + @collection_resource.validate_short_display_name + return render "collection_resources/new" if @collection_resource.errors.any? + + if @collection_resource.save + begin + CollectionResourcesService.new.upload_collection_resource(@collection_resource.download_filename, @collection_resource.file) + flash[:notice] = if displayed_collection_resource_years.include?(@collection_resource.year) + "The #{@collection_resource.log_type} #{text_year_range_format(@collection_resource.year)} #{@collection_resource.short_display_name} is now available to users." + else + "The #{@collection_resource.log_type} #{text_year_range_format(@collection_resource.year)} #{@collection_resource.short_display_name} has been uploaded." + end + redirect_to collection_resources_path + rescue StandardError + @collection_resource.errors.add(:file, :error_uploading) + render "collection_resources/new" + end + else + render "collection_resources/new" + end + end + private def resource_params - params.require(:collection_resource).permit(:year, :log_type, :resource_type, :file) + params.require(:collection_resource).permit(:year, :log_type, :resource_type, :file, :mandatory, :short_display_name) end def download_resource(filename) @@ -113,23 +206,4 @@ private def resource_for_year_can_be_updated?(year) editable_collection_resource_years.include?(year) end - - def validate_file(file) - return @collection_resource.errors.add(:file, :blank) unless file - return @collection_resource.errors.add(:file, :above_100_mb) if file.size > 100.megabytes - - argv = %W[file --brief --mime-type -- #{file.path}] - output = `#{argv.shelljoin}` - - case @collection_resource.resource_type - when "paper_form" - unless output.match?(/application\/pdf/) - @collection_resource.errors.add(:file, :must_be_pdf) - end - when "bulk_upload_template", "bulk_upload_specification" - unless output.match?(/application\/vnd\.ms-excel|application\/vnd\.openxmlformats-officedocument\.spreadsheetml\.sheet/) - @collection_resource.errors.add(:file, :must_be_xlsx, resource: @collection_resource.short_display_name.downcase) - end - end - end end diff --git a/app/controllers/start_controller.rb b/app/controllers/start_controller.rb index 5bd49df3f..b65da4d44 100644 --- a/app/controllers/start_controller.rb +++ b/app/controllers/start_controller.rb @@ -4,6 +4,8 @@ class StartController < ApplicationController def index @mandatory_lettings_collection_resources_per_year = MandatoryCollectionResourcesService.generate_resources("lettings", displayed_collection_resource_years) @mandatory_sales_collection_resources_per_year = MandatoryCollectionResourcesService.generate_resources("sales", displayed_collection_resource_years) + @additional_lettings_collection_resources_per_year = CollectionResource.where(log_type: "lettings", mandatory: false, year: displayed_collection_resource_years).group_by(&:year) + @additional_sales_collection_resources_per_year = CollectionResource.where(log_type: "sales", mandatory: false, year: displayed_collection_resource_years).group_by(&:year) if current_user @homepage_presenter = HomepagePresenter.new(current_user) render "home/index" diff --git a/app/helpers/collection_resources_helper.rb b/app/helpers/collection_resources_helper.rb index 9deb13887..1a5887744 100644 --- a/app/helpers/collection_resources_helper.rb +++ b/app/helpers/collection_resources_helper.rb @@ -49,7 +49,7 @@ module CollectionResourcesHelper def document_list_component_items(resources) resources.map do |resource| { - name: "Download the #{resource.display_name}", + name: "Download the #{resource.display_name.downcase}", href: resource.download_path, metadata: file_type_size_and_pages(resource.download_filename), } diff --git a/app/models/collection_resource.rb b/app/models/collection_resource.rb index 81665ccf6..cc217b8cd 100644 --- a/app/models/collection_resource.rb +++ b/app/models/collection_resource.rb @@ -3,7 +3,36 @@ class CollectionResource < ApplicationRecord attr_accessor :file + validates :short_display_name, presence: true + def download_path - download_mandatory_collection_resource_path(log_type:, year:, resource_type:) + if mandatory + download_mandatory_collection_resource_path(log_type:, year:, resource_type:) + else + collection_resource_download_path(self) + end + end + + def validate_attached_file + return errors.add(:file, :blank) unless file + return errors.add(:file, :above_100_mb) if file.size > 100.megabytes + + argv = %W[file --brief --mime-type -- #{file.path}] + output = `#{argv.shelljoin}` + + case resource_type + when "paper_form" + unless output.match?(/application\/pdf/) + errors.add(:file, :must_be_pdf) + end + when "bulk_upload_template", "bulk_upload_specification" + unless output.match?(/application\/vnd\.ms-excel|application\/vnd\.openxmlformats-officedocument\.spreadsheetml\.sheet/) + errors.add(:file, :must_be_xlsx, resource: short_display_name.downcase) + end + end + end + + def validate_short_display_name + errors.add(:short_display_name, :blank) if short_display_name.blank? end end diff --git a/app/services/collection_resources_service.rb b/app/services/collection_resources_service.rb index 81ab08254..82247f7a0 100644 --- a/app/services/collection_resources_service.rb +++ b/app/services/collection_resources_service.rb @@ -24,6 +24,7 @@ class CollectionResourcesService end def upload_collection_resource(filename, file) - @storage_service.write_file(filename, file) + content_type = MiniMime.lookup_by_filename(filename)&.content_type + @storage_service.write_file(filename, file, content_type:) end end diff --git a/app/services/mandatory_collection_resources_service.rb b/app/services/mandatory_collection_resources_service.rb index 8b34153e9..397e4b5d0 100644 --- a/app/services/mandatory_collection_resources_service.rb +++ b/app/services/mandatory_collection_resources_service.rb @@ -27,6 +27,7 @@ class MandatoryCollectionResourcesService year:, log_type:, download_filename: download_filename(resource_type, year, log_type), + mandatory: true, ) end diff --git a/app/services/storage/local_disk_service.rb b/app/services/storage/local_disk_service.rb index bb5825340..ad3cc9608 100644 --- a/app/services/storage/local_disk_service.rb +++ b/app/services/storage/local_disk_service.rb @@ -19,7 +19,7 @@ module Storage File.open(path, "r") end - def write_file(filename, data) + def write_file(filename, data, _content_type: nil) path = Rails.root.join("tmp/storage", filename) FileUtils.mkdir_p(path.dirname) diff --git a/app/services/storage/s3_service.rb b/app/services/storage/s3_service.rb index 88199c0a0..2e8daa719 100644 --- a/app/services/storage/s3_service.rb +++ b/app/services/storage/s3_service.rb @@ -36,12 +36,21 @@ module Storage .body.read end - def write_file(file_name, data) - @client.put_object( - body: data, - bucket: @configuration.bucket_name, - key: file_name, - ) + def write_file(file_name, data, content_type: nil) + if content_type.nil? + @client.put_object( + body: data, + bucket: @configuration.bucket_name, + key: file_name, + ) + else + @client.put_object( + body: data, + bucket: @configuration.bucket_name, + key: file_name, + content_type:, + ) + end end def get_file_metadata(file_name) diff --git a/app/views/collection_resources/_collection_resource_summary_list.erb b/app/views/collection_resources/_collection_resource_summary_list.erb index 8ef588fd5..0e630f0aa 100644 --- a/app/views/collection_resources/_collection_resource_summary_list.erb +++ b/app/views/collection_resources/_collection_resource_summary_list.erb @@ -23,9 +23,26 @@ <% end %> <% end %> <% end %> + <% additional_resources&.each do |resource| %> + <% summary_list.with_row do |row| %> + <% row.with_key { resource.short_display_name } %> + <% row.with_value do %> + <%= render DocumentListComponent.new(items: document_list_edit_component_items([resource]), label: "") %> + <% end %> + <% row.with_action( + text: "Change", + href: collection_resource_edit_path(resource), + ) %> + <% row.with_action( + text: "Delete", + href: "/", + classes: "app-!-colour-red" + ) %> + <% end %> + <% end %> <% end %>
- <%= govuk_link_to "Add new #{mandatory_resources.first.log_type} #{text_year_range_format(mandatory_resources.first.year)} resource", href: "/" %> + <%= govuk_link_to "Add new #{mandatory_resources.first.log_type} #{text_year_range_format(mandatory_resources.first.year)} resource", href: new_collection_resource_path(year: mandatory_resources.first.year, log_type: mandatory_resources.first.log_type) %>

diff --git a/app/views/collection_resources/edit.html.erb b/app/views/collection_resources/edit.html.erb index e5b2a6d33..6100256c8 100644 --- a/app/views/collection_resources/edit.html.erb +++ b/app/views/collection_resources/edit.html.erb @@ -5,7 +5,7 @@
<% resource_exists = file_exists_on_s3?(@collection_resource.download_filename) %> - <%= form_with model: @collection_resource, url: update_mandatory_collection_resource_path, method: :patch do |f| %> + <%= form_with model: @collection_resource, url: @collection_resource.mandatory ? update_mandatory_collection_resource_path : collection_resource_update_path(@collection_resource), method: :patch do |f| %> <%= f.hidden_field :year %> <%= f.hidden_field :log_type %> <%= f.hidden_field :resource_type %> @@ -13,7 +13,7 @@ <%= f.govuk_error_summary %> <%= "#{@collection_resource.log_type.humanize} #{text_year_range_format(@collection_resource.year)}" %> -

<%= resource_exists ? "Change" : "Upload" %> the <%= @collection_resource.resource_type.humanize.downcase %>

+

<%= resource_exists ? "Change" : "Upload" %> the <%= @collection_resource.short_display_name.downcase %>

This file will be available for all users to download. @@ -21,9 +21,22 @@ <%= f.govuk_file_field :file, label: { text: "Upload file", size: "m" } %> + <% if resource_exists %> +

Current file: <%= govuk_link_to @collection_resource.download_filename, href: @collection_resource.download_path %>

+ <% end %> - <%= f.govuk_submit resource_exists ? "Save changes" : "Upload" %> - <%= govuk_button_link_to "Cancel", collection_resources_path, secondary: true %> + <% unless @collection_resource.mandatory %> + <%= f.govuk_text_field :short_display_name, + label: { text: "Resource type", size: "m" }, + hint: { text: safe_join(["This will be used in the download link on the homepage. Do not include the log type or collection year.", + content_tag(:br), + "For example, if you enter “bulk upload change log”, the download link will say “Download the #{@collection_resource.log_type} bulk upload change log (#{text_year_range_format(@collection_resource.year)})”."]) } %> + <% end %> + +
+ <%= f.govuk_submit resource_exists ? "Save changes" : "Upload" %> + <%= govuk_button_link_to "Cancel", collection_resources_path, secondary: true %> +
<% end %>
diff --git a/app/views/collection_resources/index.html.erb b/app/views/collection_resources/index.html.erb index f6785eb46..207a63991 100644 --- a/app/views/collection_resources/index.html.erb +++ b/app/views/collection_resources/index.html.erb @@ -18,12 +18,12 @@

Lettings <%= text_year_range_format(year) %>

- <%= render partial: "collection_resource_summary_list", locals: { mandatory_resources: } %> + <%= render partial: "collection_resource_summary_list", locals: { mandatory_resources:, additional_resources: @additional_lettings_collection_resources_per_year[year] } %> <% end %> <% @mandatory_sales_collection_resources_per_year.each do |year, mandatory_resources| %>

Sales <%= text_year_range_format(year) %>

- <%= render partial: "collection_resource_summary_list", locals: { mandatory_resources: } %> + <%= render partial: "collection_resource_summary_list", locals: { mandatory_resources:, additional_resources: @additional_sales_collection_resources_per_year[year] } %> <% end %> diff --git a/app/views/collection_resources/new.html.erb b/app/views/collection_resources/new.html.erb new file mode 100644 index 000000000..f66c56b94 --- /dev/null +++ b/app/views/collection_resources/new.html.erb @@ -0,0 +1,36 @@ +<% content_for :before_content do %> + <%= govuk_back_link href: collection_resources_path %> +<% end %> + +
+
+ <%= form_with model: @collection_resource, url: collection_resources_path, method: :post do |f| %> + <%= f.hidden_field :year %> + <%= f.hidden_field :log_type %> + <%= f.hidden_field :mandatory, value: false %> + + <%= f.govuk_error_summary %> + + <%= "#{@collection_resource.log_type.humanize} #{text_year_range_format(@collection_resource.year)}" %> +

Add a new collection resource

+ +

+ This file will be available for all users to download. +

+ + <%= f.govuk_file_field :file, + label: { text: "Upload file", size: "m" } %> + + <%= f.govuk_text_field :short_display_name, + label: { text: "Resource type", size: "m" }, + hint: { text: safe_join(["This will be used in the download link on the homepage. Do not include the log type or collection year.", + content_tag(:br), + "For example, if you enter “bulk upload change log”, the download link will say “Download the #{@collection_resource.log_type} bulk upload change log (#{text_year_range_format(@collection_resource.year)})”."]) } %> + +
+ <%= f.govuk_submit "Add resource" %> + <%= govuk_button_link_to "Cancel", collection_resources_path, secondary: true %> +
+ <% end %> +
+
diff --git a/app/views/layouts/_collection_resources.html.erb b/app/views/layouts/_collection_resources.html.erb index 935f1806c..07648e5c0 100644 --- a/app/views/layouts/_collection_resources.html.erb +++ b/app/views/layouts/_collection_resources.html.erb @@ -12,12 +12,12 @@ <%= govuk_tabs(title: "Collection resources", classes: %w[app-tab__small-headers]) do |c| %> <% @mandatory_lettings_collection_resources_per_year.each do |year, resources| %> <% c.with_tab(label: "Lettings #{year_range_format(year)}") do %> - <%= render DocumentListComponent.new(items: document_list_component_items(resources), label: "Lettings #{text_year_range_format(year)}") %> + <%= render DocumentListComponent.new(items: document_list_component_items(resources.concat(@additional_lettings_collection_resources_per_year[year] || [])), label: "Lettings #{text_year_range_format(year)}") %> <% end %> <% end %> <% @mandatory_sales_collection_resources_per_year.each do |year, resources| %> <% c.with_tab(label: "Sales #{year_range_format(year)}") do %> - <%= render DocumentListComponent.new(items: document_list_component_items(resources), label: "Sales #{text_year_range_format(year)}") %> + <%= render DocumentListComponent.new(items: document_list_component_items(resources.concat(@additional_sales_collection_resources_per_year[year] || [])), label: "Sales #{text_year_range_format(year)}") %> <% end %> <% end %> <% end %> diff --git a/config/locales/en.yml b/config/locales/en.yml index ff73bfdcb..d490fd8ae 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -122,7 +122,7 @@ en: file: error_uploading: There was an error uploading this file. blank: Select which file to upload. - above_100_mb: The file is above 100MB. + above_100_mb: File must be 100MB or less. must_be_pdf: The paper form must be a PDF. must_be_xlsx: The %{resource} must be a Microsoft Excel file. @@ -212,9 +212,12 @@ en: file: error_uploading: There was an error uploading this file. blank: Select which file to upload. - above_100_mb: The file is above 100MB. + above_100_mb: File must be 100MB or less. must_be_pdf: The paper form must be a PDF. must_be_xlsx: The %{resource} must be a Microsoft Excel file. + short_display_name: + blank: "You must answer resource type." + notification: logs_deleted: one: "%{count} log has been deleted." diff --git a/config/routes.rb b/config/routes.rb index db4b2a8a2..cbac4894a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -42,13 +42,15 @@ Rails.application.routes.draw do get "collection-resources", to: "collection_resources#index" get "/collection-resources/:log_type/:year/:resource_type/download", to: "collection_resources#download_mandatory_collection_resource", as: :download_mandatory_collection_resource - get "/collection-resources/:log_type/:year/:resource_type/edit", to: "collection_resources#edit", as: :edit_mandatory_collection_resource - patch "/collection-resources", to: "collection_resources#update", as: :update_mandatory_collection_resource + get "/collection-resources/:log_type/:year/:resource_type/edit", to: "collection_resources#edit_mandatory_collection_resource", as: :edit_mandatory_collection_resource + patch "/collection-resources", to: "collection_resources#update_mandatory_collection_resource", as: :update_mandatory_collection_resource get "/collection-resources/:year/release", to: "collection_resources#confirm_mandatory_collection_resources_release", as: :confirm_mandatory_collection_resources_release patch "/collection-resources/:year/release", to: "collection_resources#release_mandatory_collection_resources", as: :release_mandatory_collection_resources resources :collection_resources, path: "/collection-resources" do - get "/download", to: "collection_resources#download_additional_collection_resource" # when we get to adding them + get "/download", to: "collection_resources#download_additional_collection_resource" + get "/edit", to: "collection_resources#edit_additional_collection_resource" + patch "/update", to: "collection_resources#update_additional_collection_resource" end get "clear-filters", to: "sessions#clear_filters" diff --git a/spec/factories/collection_resource.rb b/spec/factories/collection_resource.rb index c352b70a9..0282e33e3 100644 --- a/spec/factories/collection_resource.rb +++ b/spec/factories/collection_resource.rb @@ -6,5 +6,15 @@ FactoryBot.define do year { 2024 } log_type { "lettings" } download_filename { "24_25_lettings_paper_form.pdf" } + mandatory { true } + trait(:additional) do + resource_type { nil } + display_name { "lettings additional resource (2024 to 2025)" } + short_display_name { "additional resource" } + year { 2024 } + log_type { "lettings" } + download_filename { "additional.pdf" } + mandatory { false } + end end end diff --git a/spec/features/collection_resources_spec.rb b/spec/features/collection_resources_spec.rb index 643f3537e..ad9a370b6 100644 --- a/spec/features/collection_resources_spec.rb +++ b/spec/features/collection_resources_spec.rb @@ -5,6 +5,9 @@ RSpec.describe "Collection resources" do let(:collection_resources_service) { instance_double(CollectionResourcesService, file_exists_on_s3?: true) } before do + # rubocop:disable RSpec/AnyInstance + allow_any_instance_of(CollectionResourcesHelper).to receive(:editable_collection_resource_years).and_return([2024, 2025]) + # rubocop:enable RSpec/AnyInstance allow(CollectionResourcesService).to receive(:new).and_return(collection_resources_service) allow(collection_resources_service).to receive(:upload_collection_resource) allow(collection_resources_service).to receive(:get_file_metadata).and_return({ "content_type" => "application/pdf", "content_length" => 1000 }) @@ -165,4 +168,74 @@ RSpec.describe "Collection resources" do expect(page).to have_content("There was an error uploading this file.") end end + + context "when uploading an additional resource" do + it "allows valid files" do + expect(CollectionResource.count).to eq(0) + + visit(new_collection_resource_path(year: 2025, log_type: "sales")) + fill_in("collection_resource[short_display_name]", with: "some file") + attach_file "file", file_fixture("pdf_file.pdf") + + click_button("Add resource") + expect(collection_resources_service).to have_received(:upload_collection_resource).with("pdf_file.pdf", anything) + expect(CollectionResource.count).to eq(1) + expect(CollectionResource.first.year).to eq(2025) + expect(CollectionResource.first.log_type).to eq("sales") + expect(CollectionResource.first.resource_type).to be_nil + expect(CollectionResource.first.mandatory).to be_falsey + expect(CollectionResource.first.released_to_user).to be_nil + expect(CollectionResource.first.display_name).to eq("sales some file (2025 to 2026)") + expect(CollectionResource.first.short_display_name).to eq("some file") + expect(page).to have_content("The sales 2025 to 2026 some file has been uploaded.") + end + + it "validates file is attached" do + visit(new_collection_resource_path(year: 2025, log_type: "sales")) + + fill_in("collection_resource[short_display_name]", with: "some file") + click_button("Add resource") + expect(page).to have_content("Select which file to upload.") + end + + it "validates resource type is given" do + visit(new_collection_resource_path(year: 2025, log_type: "sales")) + + attach_file "file", file_fixture("pdf_file.pdf") + click_button("Add resource") + expect(page).to have_content("You must answer resource type.") + end + end + + context "when updating an additional resource" do + let!(:collection_resource) { create(:collection_resource, :additional, year: 2025, log_type: "sales") } + + it "only allows valid files" do + expect(CollectionResource.count).to eq(1) + + visit(collection_resource_edit_path(collection_resource)) + fill_in("collection_resource[short_display_name]", with: "some updated file") + attach_file "file", file_fixture("pdf_file.pdf") + + click_button("Save changes") + expect(collection_resources_service).to have_received(:upload_collection_resource).with("pdf_file.pdf", anything) + expect(CollectionResource.count).to eq(1) + expect(CollectionResource.first.year).to eq(2025) + expect(CollectionResource.first.log_type).to eq("sales") + expect(CollectionResource.first.resource_type).to be_nil + expect(CollectionResource.first.mandatory).to be_falsey + expect(CollectionResource.first.released_to_user).to be_nil + expect(CollectionResource.first.display_name).to eq("sales some updated file (2025 to 2026)") + expect(CollectionResource.first.short_display_name).to eq("some updated file") + expect(page).to have_content("The sales 2025 to 2026 some updated file has been updated.") + end + + it "validates file is attached" do + visit(collection_resource_edit_path(collection_resource)) + + fill_in("collection_resource[short_display_name]", with: "some file") + click_button("Save changes") + expect(page).to have_content("Select which file to upload.") + end + end end diff --git a/spec/helpers/collection_resources_helper_spec.rb b/spec/helpers/collection_resources_helper_spec.rb index 859d14cd1..9fc77a4c9 100644 --- a/spec/helpers/collection_resources_helper_spec.rb +++ b/spec/helpers/collection_resources_helper_spec.rb @@ -94,9 +94,9 @@ RSpec.describe CollectionResourcesHelper do context "and next year resources were manually released" do before do - CollectionResource.create!(year: 2025, resource_type: "paper_form", display_name: "lettings log for tenants (2025 to 2026)", download_filename: "file.pdf", mandatory: true, released_to_user: true) - CollectionResource.create!(year: 2025, resource_type: "bulk_upload_template", display_name: "bulk upload template (2025 to 2026)", download_filename: "file.xlsx", mandatory: true, released_to_user: true) - CollectionResource.create!(year: 2025, resource_type: "bulk_upload_specification", display_name: "sales log for tenants (2025 to 2026)", download_filename: "file.xlsx", mandatory: true, released_to_user: true) + create(:collection_resource, year: 2025, resource_type: "paper_form", display_name: "lettings log for tenants (2025 to 2026)", download_filename: "file.pdf", mandatory: true, released_to_user: true) + create(:collection_resource, year: 2025, resource_type: "bulk_upload_template", display_name: "bulk upload template (2025 to 2026)", download_filename: "file.xlsx", mandatory: true, released_to_user: true) + create(:collection_resource, year: 2025, resource_type: "bulk_upload_specification", display_name: "sales log for tenants (2025 to 2026)", download_filename: "file.xlsx", mandatory: true, released_to_user: true) end it "reutrns current and next years" do @@ -199,9 +199,9 @@ RSpec.describe CollectionResourcesHelper do context "and the resources have been manually released" do before do - CollectionResource.create!(year: 2025, resource_type: "paper_form", display_name: "lettings log for tenants (2025 to 2026)", download_filename: "file.pdf", mandatory: true, released_to_user: true) - CollectionResource.create!(year: 2025, resource_type: "bulk_upload_template", display_name: "bulk upload template (2025 to 2026)", download_filename: "file.xlsx", mandatory: true, released_to_user: true) - CollectionResource.create!(year: 2025, resource_type: "bulk_upload_specification", display_name: "sales log for tenants (2025 to 2026)", download_filename: "file.xlsx", mandatory: true, released_to_user: true) + create(:collection_resource, year: 2025, resource_type: "paper_form", display_name: "lettings log for tenants (2025 to 2026)", download_filename: "file.pdf", mandatory: true, released_to_user: true) + create(:collection_resource, year: 2025, resource_type: "bulk_upload_template", display_name: "bulk upload template (2025 to 2026)", download_filename: "file.xlsx", mandatory: true, released_to_user: true) + create(:collection_resource, year: 2025, resource_type: "bulk_upload_specification", display_name: "sales log for tenants (2025 to 2026)", download_filename: "file.xlsx", mandatory: true, released_to_user: true) end it "returns false" do diff --git a/spec/requests/collection_resources_controller_spec.rb b/spec/requests/collection_resources_controller_spec.rb index 7c9bb0f05..a6d88f911 100644 --- a/spec/requests/collection_resources_controller_spec.rb +++ b/spec/requests/collection_resources_controller_spec.rb @@ -62,7 +62,7 @@ RSpec.describe CollectionResourcesController, type: :request do expect(page).to have_content("Sales 2025 to 2026") end - it "displays mandatory filed" do + it "displays mandatory files" do get collection_resources_path expect(page).to have_content("Paper form") @@ -70,6 +70,15 @@ RSpec.describe CollectionResourcesController, type: :request do expect(page).to have_content("Bulk upload specification") end + it "allows uploading new resources" do + get collection_resources_path + + expect(page).to have_link("Add new sales 2024 to 2025 resource", href: new_collection_resource_path(year: 2024, log_type: "sales")) + expect(page).to have_link("Add new lettings 2024 to 2025 resource", href: new_collection_resource_path(year: 2024, log_type: "lettings")) + expect(page).to have_link("Add new sales 2025 to 2026 resource", href: new_collection_resource_path(year: 2025, log_type: "sales")) + expect(page).to have_link("Add new lettings 2025 to 2026 resource", href: new_collection_resource_path(year: 2025, log_type: "lettings")) + end + context "when files are on S3" do before do allow(storage_service).to receive(:file_exists?).and_return(true) @@ -113,6 +122,16 @@ RSpec.describe CollectionResourcesController, type: :request do expect(page).to have_content("The 2025 to 2026 collection resources are not yet available to users.") expect(page).to have_link("Release the 2025 to 2026 collection resources to users", href: confirm_mandatory_collection_resources_release_path(year: 2025)) end + + context "when there are additional resources" do + let!(:collection_resource) { create(:collection_resource, :additional, year: 2025, short_display_name: "additional resource", download_filename: "additional.pdf") } + + it "displays change links for additional resources" do + get collection_resources_path + + expect(page).to have_link("Change", href: collection_resource_edit_path(collection_resource)) + end + end end context "when files are not on S3" do @@ -147,6 +166,26 @@ RSpec.describe CollectionResourcesController, type: :request do expect(page).to have_content("Once you have uploaded all the required 2025 to 2026 collection resources, you will be able to release them to users.") end end + + context "when there are additional resources" do + let!(:collection_resource) { create(:collection_resource, :additional, year: 2025, short_display_name: "additional resource", download_filename: "additional.pdf") } + + before do + # rubocop:disable RSpec/AnyInstance + allow_any_instance_of(CollectionResourcesHelper).to receive(:editable_collection_resource_years).and_return([2025]) + # rubocop:enable RSpec/AnyInstance + create(:collection_resource, :additional, year: 2026, short_display_name: "additional resource 2") + end + + it "displays additional resources for editable years" do + get collection_resources_path + + expect(page).to have_content("additional resource") + expect(page).not_to have_content("additional resource 2") + expect(page).to have_link("additional.pdf", href: collection_resource_download_path(collection_resource)) + expect(page).to have_link("Delete") + end + end end end @@ -473,4 +512,305 @@ RSpec.describe CollectionResourcesController, type: :request do end end end + + describe "GET #new_collection_resource" do + context "when user is not signed in" do + it "redirects to the sign in page" do + get new_collection_resource_path(year: 2025, log_type: "sales") + expect(response).to redirect_to(new_user_session_path) + end + end + + context "when user is signed in as a data coordinator" do + let(:user) { create(:user, :data_coordinator) } + + before do + sign_in user + end + + it "returns page not found" do + get new_collection_resource_path(year: 2025, log_type: "sales") + expect(response).to have_http_status(:not_found) + end + end + + context "when user is signed in as a data provider" do + let(:user) { create(:user, :data_provider) } + + before do + sign_in user + end + + it "returns page not found" do + get new_collection_resource_path(year: 2025, log_type: "sales") + expect(response).to have_http_status(:not_found) + end + end + + context "when user is signed in as a support user" do + let(:user) { create(:user, :support) } + + before do + # rubocop:disable RSpec/AnyInstance + allow_any_instance_of(CollectionResourcesHelper).to receive(:editable_collection_resource_years).and_return([2025, 2026]) + # rubocop:enable RSpec/AnyInstance + allow(user).to receive(:need_two_factor_authentication?).and_return(false) + sign_in user + end + + it "displays new collection resource page content" do + get new_collection_resource_path(year: 2025, log_type: "sales") + + expect(page).to have_content("Sales 2025 to 2026") + expect(page).to have_content("Add a new collection resource") + expect(page).to have_content("Upload file") + expect(page).to have_button("Add resource") + expect(page).to have_link("Back", href: collection_resources_path) + expect(page).to have_link("Cancel", href: collection_resources_path) + end + end + end + + describe "POST #collection_resources" do + let(:some_file) { File.open(file_fixture("blank_bulk_upload_sales.csv")) } + let(:params) { { collection_resource: { year: 2025, log_type: "sales", file: some_file, display_name: "some file" } } } + + context "when user is not signed in" do + it "redirects to the sign in page" do + post collection_resources_path, params: params + expect(response).to redirect_to(new_user_session_path) + end + end + + context "when user is signed in as a data coordinator" do + let(:user) { create(:user, :data_coordinator) } + + before do + sign_in user + end + + it "returns page not found" do + post collection_resources_path, params: params + expect(response).to have_http_status(:not_found) + end + end + + context "when user is signed in as a data provider" do + let(:user) { create(:user, :data_provider) } + + before do + sign_in user + end + + it "returns page not found" do + post collection_resources_path, params: params + expect(response).to have_http_status(:not_found) + end + end + end + + describe "GET #download_additional_collection_resource" do + let(:collection_resource) { create(:collection_resource, :additional, year: 2025, short_display_name: "additional resource") } + + before do + # rubocop:disable RSpec/AnyInstance + allow_any_instance_of(CollectionResourcesHelper).to receive(:editable_collection_resource_years).and_return([2025, 2026]) + allow_any_instance_of(CollectionResourcesHelper).to receive(:displayed_collection_resource_years).and_return([2025]) + # rubocop:enable RSpec/AnyInstance + end + + context "when the user is not signed in" do + context "when the file exists on S3" do + before do + allow(storage_service).to receive(:get_file).and_return("file") + get collection_resource_download_path(collection_resource) + end + + it "downloads the file" do + expect(response.body).to eq("file") + end + end + end + + context "when user is signed in as a data coordinator" do + let(:user) { create(:user, :data_coordinator) } + + context "when the file exists on S3" do + before do + sign_in user + allow(storage_service).to receive(:get_file).and_return("file") + get collection_resource_download_path(collection_resource) + end + + it "downloads the file" do + expect(response.body).to eq("file") + end + end + + context "when the file does not exist on S3" do + before do + sign_in user + allow(storage_service).to receive(:get_file).and_return(nil) + get collection_resource_download_path(collection_resource) + end + + it "returns page not found" do + expect(response).to have_http_status(:not_found) + end + end + + context "when resource id is invalid" do + before do + sign_in user + allow(storage_service).to receive(:get_file).and_return(nil) + get collection_resource_download_path(collection_resource_id: "invalid") + end + + it "returns page not found" do + expect(response).to have_http_status(:not_found) + end + end + + context "when year not in displayed_collection_resource_years" do + let(:collection_resource) { create(:collection_resource, :additional, year: 2026, short_display_name: "additional resource") } + + before do + sign_in user + get collection_resource_download_path(collection_resource) + end + + it "returns page not found" do + expect(response).to have_http_status(:not_found) + end + end + end + + context "when user is signed in as a support user" do + let(:collection_resource) { create(:collection_resource, :additional, year: 2026, short_display_name: "additional resource") } + let(:user) { create(:user, :support) } + + context "when year is in editable_collection_resource_years but not in displayed_collection_resource_years" do + before do + allow(user).to receive(:need_two_factor_authentication?).and_return(false) + sign_in user + allow(storage_service).to receive(:get_file).and_return("file") + get collection_resource_download_path(collection_resource) + end + + it "downloads the file" do + expect(response.status).to eq(200) + expect(response.body).to eq("file") + end + end + end + end + + describe "GET #edit_additional_collection_resource" do + let(:collection_resource) { create(:collection_resource, :additional, year: 2025, log_type: "sales", short_display_name: "additional resource", download_filename: "additional.pdf") } + + context "when user is not signed in" do + it "redirects to the sign in page" do + get collection_resource_edit_path(collection_resource) + expect(response).to redirect_to(new_user_session_path) + end + end + + context "when user is signed in as a data coordinator" do + let(:user) { create(:user, :data_coordinator) } + + before do + sign_in user + end + + it "returns page not found" do + get collection_resource_edit_path(collection_resource) + expect(response).to have_http_status(:not_found) + end + end + + context "when user is signed in as a data provider" do + let(:user) { create(:user, :data_provider) } + + before do + sign_in user + end + + it "returns page not found" do + get collection_resource_edit_path(collection_resource) + expect(response).to have_http_status(:not_found) + end + end + + context "when user is signed in as a support user" do + let(:user) { create(:user, :support) } + + before do + allow(Time.zone).to receive(:today).and_return(Time.zone.local(2025, 1, 8)) + allow(user).to receive(:need_two_factor_authentication?).and_return(false) + sign_in user + end + + context "and the file exists on S3" do + before do + allow(storage_service).to receive(:file_exists?).and_return(true) + end + + it "displays update collection resources page content" do + get collection_resource_edit_path(collection_resource) + + expect(page).to have_content("Sales 2025 to 2026") + expect(page).to have_content("Change the additional resource") + expect(page).to have_content("This file will be available for all users to download.") + expect(page).to have_content("Upload file") + expect(page).to have_button("Save changes") + expect(page).to have_link("Back", href: collection_resources_path) + expect(page).to have_link("Cancel", href: collection_resources_path) + end + end + end + end + + describe "PATCH #update_additional_collection_resource" do + let(:some_file) { File.open(file_fixture("blank_bulk_upload_sales.csv")) } + let(:params) { { collection_resource: { short_display_name: "short name", file: some_file } } } + let(:collection_resource_service) { instance_double(CollectionResourcesService) } + let(:collection_resource) { create(:collection_resource, :additional, year: 2025, log_type: "sales", short_display_name: "additional resource", download_filename: "additional.pdf") } + + before do + allow(CollectionResourcesService).to receive(:new).and_return(collection_resource_service) + end + + context "when user is not signed in" do + it "redirects to the sign in page" do + patch collection_resource_update_path(collection_resource), params: params + expect(response).to redirect_to(new_user_session_path) + end + end + + context "when user is signed in as a data coordinator" do + let(:user) { create(:user, :data_coordinator) } + + before do + sign_in user + end + + it "returns page not found" do + patch collection_resource_update_path(collection_resource), params: params + expect(response).to have_http_status(:not_found) + end + end + + context "when user is signed in as a data provider" do + let(:user) { create(:user, :data_provider) } + + before do + sign_in user + end + + it "returns page not found" do + patch collection_resource_update_path(collection_resource), params: params + expect(response).to have_http_status(:not_found) + end + end + end end diff --git a/spec/requests/start_controller_spec.rb b/spec/requests/start_controller_spec.rb index db884d09f..b3846809c 100644 --- a/spec/requests/start_controller_spec.rb +++ b/spec/requests/start_controller_spec.rb @@ -324,6 +324,7 @@ RSpec.describe StartController, type: :request do context "and 2023 collection window is open for editing" do before do + create(:collection_resource, :additional, year: 2023, log_type: "sales", display_name: "sales additional resource (2023 to 2024)") allow(Time).to receive(:now).and_return(Time.zone.local(2024, 4, 1)) end @@ -337,6 +338,7 @@ RSpec.describe StartController, type: :request do expect(page).to have_content("Sales 23/24") expect(page).to have_content("Sales 2024 to 2025") expect(page).to have_content("Sales 2023 to 2024") + expect(page).to have_content("Download the sales additional resource (2023 to 2024)") end end diff --git a/spec/services/collection_resources_service_spec.rb b/spec/services/collection_resources_service_spec.rb index 3786b70c9..602e36c38 100644 --- a/spec/services/collection_resources_service_spec.rb +++ b/spec/services/collection_resources_service_spec.rb @@ -12,7 +12,7 @@ describe CollectionResourcesService do end it "calls write_file on S3 service" do - expect(storage_service).to receive(:write_file).with("2025_26_lettings_paper_form.pdf", some_file) + expect(storage_service).to receive(:write_file).with("2025_26_lettings_paper_form.pdf", some_file, content_type: "application/pdf") service.upload_collection_resource("2025_26_lettings_paper_form.pdf", some_file) end end From c45d370f732e792f52f86d528feafdbbde86dea4 Mon Sep 17 00:00:00 2001 From: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com> Date: Wed, 23 Oct 2024 12:52:05 +0100 Subject: [PATCH 05/30] CLDC-3649 Delete custom resource (#2693) * Stub some collection resource requests * Rebase changes * Add delete confirmation page * Allow deleting resources * lint * Return unauthorised status * Fix delete path from delete confirmation page * Change the ordering for collection resources * Do not create header for empty label * Add margin between sections --- .../document_list_component.html.erb | 4 +- .../collection_resources_controller.rb | 43 +++- app/controllers/start_controller.rb | 4 +- app/frontend/styles/_document-list.scss | 1 - app/models/collection_resource.rb | 7 + app/services/collection_resources_service.rb | 4 + app/services/storage/local_disk_service.rb | 6 + app/services/storage/s3_service.rb | 4 + app/services/storage/storage_service.rb | 8 + .../_collection_resource_summary_list.erb | 6 +- .../delete_confirmation.html.erb | 31 +++ app/views/collection_resources/index.html.erb | 9 +- config/routes.rb | 2 + db/migrate/20241011112158_add_discarded_at.rb | 5 + db/schema.rb | 3 +- .../collection_resources_controller_spec.rb | 191 ++++++++++++++---- 16 files changed, 270 insertions(+), 58 deletions(-) create mode 100644 app/views/collection_resources/delete_confirmation.html.erb create mode 100644 db/migrate/20241011112158_add_discarded_at.rb diff --git a/app/components/document_list_component.html.erb b/app/components/document_list_component.html.erb index 32b2d1562..f2587f10f 100644 --- a/app/components/document_list_component.html.erb +++ b/app/components/document_list_component.html.erb @@ -1,4 +1,6 @@ -

<%= label %>

+<% unless label.blank? %> +

<%= label %>

+<% end %>
<% items.each do |item| %>
diff --git a/app/controllers/collection_resources_controller.rb b/app/controllers/collection_resources_controller.rb index 5203ceea1..06988c88c 100644 --- a/app/controllers/collection_resources_controller.rb +++ b/app/controllers/collection_resources_controller.rb @@ -8,8 +8,8 @@ class CollectionResourcesController < ApplicationController @mandatory_lettings_collection_resources_per_year = MandatoryCollectionResourcesService.generate_resources("lettings", editable_collection_resource_years) @mandatory_sales_collection_resources_per_year = MandatoryCollectionResourcesService.generate_resources("sales", editable_collection_resource_years) - @additional_lettings_collection_resources_per_year = CollectionResource.where(log_type: "lettings", mandatory: false).group_by(&:year) - @additional_sales_collection_resources_per_year = CollectionResource.where(log_type: "sales", mandatory: false).group_by(&:year) + @additional_lettings_collection_resources_per_year = CollectionResource.visible.where(log_type: "lettings", mandatory: false).group_by(&:year) + @additional_sales_collection_resources_per_year = CollectionResource.visible.where(log_type: "sales", mandatory: false).group_by(&:year) end def download_mandatory_collection_resource @@ -35,7 +35,7 @@ class CollectionResourcesController < ApplicationController end def edit_mandatory_collection_resource - return render_not_found unless current_user.support? + return render_not_authorized unless current_user.support? year = params[:year].to_i resource_type = params[:resource_type] @@ -51,7 +51,7 @@ class CollectionResourcesController < ApplicationController end def edit_additional_collection_resource - return render_not_found unless current_user.support? + return render_not_authorized unless current_user.support? @collection_resource = CollectionResource.find_by(id: params[:collection_resource_id]) @@ -62,7 +62,7 @@ class CollectionResourcesController < ApplicationController end def update_mandatory_collection_resource - return render_not_found unless current_user.support? + return render_not_authorized unless current_user.support? year = resource_params[:year].to_i resource_type = resource_params[:resource_type] @@ -92,7 +92,7 @@ class CollectionResourcesController < ApplicationController end def update_additional_collection_resource - return render_not_found unless current_user.support? + return render_not_authorized unless current_user.support? @collection_resource = CollectionResource.find_by(id: params[:collection_resource_id]) @@ -122,7 +122,7 @@ class CollectionResourcesController < ApplicationController end def confirm_mandatory_collection_resources_release - return render_not_found unless current_user.support? + return render_not_authorized unless current_user.support? @year = params[:year].to_i @@ -132,7 +132,7 @@ class CollectionResourcesController < ApplicationController end def release_mandatory_collection_resources - return render_not_found unless current_user.support? + return render_not_authorized unless current_user.support? year = params[:year].to_i @@ -145,7 +145,7 @@ class CollectionResourcesController < ApplicationController end def new - return render_not_found unless current_user.support? + return render_not_authorized unless current_user.support? year = params[:year].to_i log_type = params[:log_type] @@ -156,7 +156,7 @@ class CollectionResourcesController < ApplicationController end def create - return render_not_found unless current_user.support? && editable_collection_resource_years.include?(resource_params[:year].to_i) + return render_not_authorized unless current_user.support? && editable_collection_resource_years.include?(resource_params[:year].to_i) @collection_resource = CollectionResource.new(resource_params) @collection_resource.download_filename ||= @collection_resource.file&.original_filename @@ -184,6 +184,29 @@ class CollectionResourcesController < ApplicationController end end + def delete_confirmation + return render_not_authorized unless current_user.support? + + @collection_resource = CollectionResource.find_by(id: params[:collection_resource_id]) + + return render_not_found unless @collection_resource + + render "collection_resources/delete_confirmation" + end + + def delete + return render_not_authorized unless current_user.support? + + @collection_resource = CollectionResource.find_by(id: params[:collection_resource_id]) + + return render_not_found unless @collection_resource + + @collection_resource.discard! + + flash[:notice] = "The #{@collection_resource.log_type} #{text_year_range_format(@collection_resource.year)} #{@collection_resource.short_display_name.downcase} has been deleted." + redirect_to collection_resources_path + end + private def resource_params diff --git a/app/controllers/start_controller.rb b/app/controllers/start_controller.rb index b65da4d44..d6df81c39 100644 --- a/app/controllers/start_controller.rb +++ b/app/controllers/start_controller.rb @@ -4,8 +4,8 @@ class StartController < ApplicationController def index @mandatory_lettings_collection_resources_per_year = MandatoryCollectionResourcesService.generate_resources("lettings", displayed_collection_resource_years) @mandatory_sales_collection_resources_per_year = MandatoryCollectionResourcesService.generate_resources("sales", displayed_collection_resource_years) - @additional_lettings_collection_resources_per_year = CollectionResource.where(log_type: "lettings", mandatory: false, year: displayed_collection_resource_years).group_by(&:year) - @additional_sales_collection_resources_per_year = CollectionResource.where(log_type: "sales", mandatory: false, year: displayed_collection_resource_years).group_by(&:year) + @additional_lettings_collection_resources_per_year = CollectionResource.visible.where(log_type: "lettings", mandatory: false, year: displayed_collection_resource_years).group_by(&:year) + @additional_sales_collection_resources_per_year = CollectionResource.visible.where(log_type: "sales", mandatory: false, year: displayed_collection_resource_years).group_by(&:year) if current_user @homepage_presenter = HomepagePresenter.new(current_user) render "home/index" diff --git a/app/frontend/styles/_document-list.scss b/app/frontend/styles/_document-list.scss index e8cef0625..a1f812551 100644 --- a/app/frontend/styles/_document-list.scss +++ b/app/frontend/styles/_document-list.scss @@ -1,5 +1,4 @@ .app-document-list { - margin-top: govuk-spacing(3); margin-bottom: govuk-spacing(6); } diff --git a/app/models/collection_resource.rb b/app/models/collection_resource.rb index cc217b8cd..fc5808cec 100644 --- a/app/models/collection_resource.rb +++ b/app/models/collection_resource.rb @@ -1,8 +1,10 @@ class CollectionResource < ApplicationRecord include Rails.application.routes.url_helpers + has_paper_trail attr_accessor :file + scope :visible, -> { where(discarded_at: nil) } validates :short_display_name, presence: true def download_path @@ -35,4 +37,9 @@ class CollectionResource < ApplicationRecord def validate_short_display_name errors.add(:short_display_name, :blank) if short_display_name.blank? end + + def discard! + CollectionResourcesService.new.delete_collection_resource(download_filename) + update!(discarded_at: Time.zone.now) + end end diff --git a/app/services/collection_resources_service.rb b/app/services/collection_resources_service.rb index 82247f7a0..f6762116a 100644 --- a/app/services/collection_resources_service.rb +++ b/app/services/collection_resources_service.rb @@ -27,4 +27,8 @@ class CollectionResourcesService content_type = MiniMime.lookup_by_filename(filename)&.content_type @storage_service.write_file(filename, file, content_type:) end + + def delete_collection_resource(filename) + @storage_service.delete_file(filename) + end end diff --git a/app/services/storage/local_disk_service.rb b/app/services/storage/local_disk_service.rb index ad3cc9608..228f0339e 100644 --- a/app/services/storage/local_disk_service.rb +++ b/app/services/storage/local_disk_service.rb @@ -43,5 +43,11 @@ module Storage File.exist?(path) end + + def delete_file(filename) + path = Rails.root.join("tmp/storage", filename) + + File.delete(path) + end end end diff --git a/app/services/storage/s3_service.rb b/app/services/storage/s3_service.rb index 2e8daa719..a6eef7d49 100644 --- a/app/services/storage/s3_service.rb +++ b/app/services/storage/s3_service.rb @@ -64,6 +64,10 @@ module Storage false end + def delete_file(file_name) + @client.delete_object(bucket: @configuration.bucket_name, key: file_name) + end + private def create_configuration diff --git a/app/services/storage/storage_service.rb b/app/services/storage/storage_service.rb index afb3d4a58..37d4cc0fd 100644 --- a/app/services/storage/storage_service.rb +++ b/app/services/storage/storage_service.rb @@ -15,5 +15,13 @@ module Storage def write_file(_file_name, _data) raise NotImplementedError end + + def get_file(_file_name, _data) + raise NotImplementedError + end + + def delete_file(_file_name, _data) + raise NotImplementedError + end end end diff --git a/app/views/collection_resources/_collection_resource_summary_list.erb b/app/views/collection_resources/_collection_resource_summary_list.erb index 0e630f0aa..581bb6303 100644 --- a/app/views/collection_resources/_collection_resource_summary_list.erb +++ b/app/views/collection_resources/_collection_resource_summary_list.erb @@ -35,15 +35,15 @@ ) %> <% row.with_action( text: "Delete", - href: "/", + href: collection_resource_delete_confirmation_path(resource), classes: "app-!-colour-red" ) %> <% end %> <% end %> <% end %> -
+
<%= govuk_link_to "Add new #{mandatory_resources.first.log_type} #{text_year_range_format(mandatory_resources.first.year)} resource", href: new_collection_resource_path(year: mandatory_resources.first.year, log_type: mandatory_resources.first.log_type) %>
-
+
diff --git a/app/views/collection_resources/delete_confirmation.html.erb b/app/views/collection_resources/delete_confirmation.html.erb new file mode 100644 index 000000000..9f861bc19 --- /dev/null +++ b/app/views/collection_resources/delete_confirmation.html.erb @@ -0,0 +1,31 @@ +<% content_for :before_content do %> + <% content_for :title, "Are you sure you want to delete the #{@collection_resource.short_display_name.downcase}?" %> + <%= govuk_back_link href: collection_resources_path %> +<% end %> + +
+
+ <%= "#{@collection_resource.log_type.humanize} #{text_year_range_format(@collection_resource.year)}" %> +

+ <%= content_for(:title) %> +

+

+ This file will no longer be available for users to download. +

+ + <%= govuk_warning_text(text: "You will not be able to undo this action.") %> + +
+ <%= govuk_button_to( + "Delete resource", + collection_resource_delete_path(@collection_resource), + method: :delete, + ) %> + <%= govuk_button_link_to( + "Cancel", + collection_resources_path, + secondary: true, + ) %> +
+
+
diff --git a/app/views/collection_resources/index.html.erb b/app/views/collection_resources/index.html.erb index 207a63991..ee5574f80 100644 --- a/app/views/collection_resources/index.html.erb +++ b/app/views/collection_resources/index.html.erb @@ -14,16 +14,13 @@ <% end %>

<%= title %>

-<% @mandatory_lettings_collection_resources_per_year.each do |year, mandatory_resources| %> +<% editable_collection_resource_years.each do |year| %>

Lettings <%= text_year_range_format(year) %>

- <%= render partial: "collection_resource_summary_list", locals: { mandatory_resources:, additional_resources: @additional_lettings_collection_resources_per_year[year] } %> -<% end %> - -<% @mandatory_sales_collection_resources_per_year.each do |year, mandatory_resources| %> + <%= render partial: "collection_resource_summary_list", locals: { mandatory_resources: @mandatory_lettings_collection_resources_per_year[year], additional_resources: @additional_lettings_collection_resources_per_year[year] } %>

Sales <%= text_year_range_format(year) %>

- <%= render partial: "collection_resource_summary_list", locals: { mandatory_resources:, additional_resources: @additional_sales_collection_resources_per_year[year] } %> + <%= render partial: "collection_resource_summary_list", locals: { mandatory_resources: @mandatory_sales_collection_resources_per_year[year], additional_resources: @additional_sales_collection_resources_per_year[year] } %> <% end %> diff --git a/config/routes.rb b/config/routes.rb index cbac4894a..6ac7b3f34 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -51,6 +51,8 @@ Rails.application.routes.draw do get "/download", to: "collection_resources#download_additional_collection_resource" get "/edit", to: "collection_resources#edit_additional_collection_resource" patch "/update", to: "collection_resources#update_additional_collection_resource" + get "/delete-confirmation", to: "collection_resources#delete_confirmation" + delete "/delete", to: "collection_resources#delete" end get "clear-filters", to: "sessions#clear_filters" diff --git a/db/migrate/20241011112158_add_discarded_at.rb b/db/migrate/20241011112158_add_discarded_at.rb new file mode 100644 index 000000000..d910b8797 --- /dev/null +++ b/db/migrate/20241011112158_add_discarded_at.rb @@ -0,0 +1,5 @@ +class AddDiscardedAt < ActiveRecord::Migration[7.0] + def change + add_column :collection_resources, :discarded_at, :datetime + end +end diff --git a/db/schema.rb b/db/schema.rb index 1f5cca5ca..84bf048af 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2024_10_08_100119) do +ActiveRecord::Schema[7.0].define(version: 2024_10_11_112158) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -61,6 +61,7 @@ ActiveRecord::Schema[7.0].define(version: 2024_10_08_100119) do t.boolean "released_to_user" t.datetime "created_at", null: false t.datetime "updated_at", null: false + t.datetime "discarded_at" end create_table "csv_variable_definitions", force: :cascade do |t| diff --git a/spec/requests/collection_resources_controller_spec.rb b/spec/requests/collection_resources_controller_spec.rb index a6d88f911..eb6f56aed 100644 --- a/spec/requests/collection_resources_controller_spec.rb +++ b/spec/requests/collection_resources_controller_spec.rb @@ -2,7 +2,7 @@ require "rails_helper" RSpec.describe CollectionResourcesController, type: :request do let(:page) { Capybara::Node::Simple.new(response.body) } - let(:storage_service) { instance_double(Storage::S3Service, get_file_metadata: nil) } + let(:storage_service) { instance_double(Storage::S3Service, get_file_metadata: nil, delete_file: nil) } before do allow(Storage::S3Service).to receive(:new).and_return(storage_service) @@ -183,7 +183,7 @@ RSpec.describe CollectionResourcesController, type: :request do expect(page).to have_content("additional resource") expect(page).not_to have_content("additional resource 2") expect(page).to have_link("additional.pdf", href: collection_resource_download_path(collection_resource)) - expect(page).to have_link("Delete") + expect(page).to have_link("Delete", href: collection_resource_delete_confirmation_path(collection_resource)) end end end @@ -277,9 +277,9 @@ RSpec.describe CollectionResourcesController, type: :request do sign_in user end - it "returns page not found" do + it "returns page not authorised" do get edit_mandatory_collection_resource_path(year: 2024, log_type: "sales", resource_type: "bulk_upload_template") - expect(response).to have_http_status(:not_found) + expect(response).to have_http_status(:unauthorized) end end @@ -290,9 +290,9 @@ RSpec.describe CollectionResourcesController, type: :request do sign_in user end - it "returns page not found" do + it "returns page not authorised" do get edit_mandatory_collection_resource_path(year: 2024, log_type: "sales", resource_type: "bulk_upload_template") - expect(response).to have_http_status(:not_found) + expect(response).to have_http_status(:unauthorized) end end @@ -366,9 +366,9 @@ RSpec.describe CollectionResourcesController, type: :request do sign_in user end - it "returns page not found" do + it "returns page not authorised" do patch update_mandatory_collection_resource_path, params: params - expect(response).to have_http_status(:not_found) + expect(response).to have_http_status(:unauthorized) end end @@ -379,9 +379,9 @@ RSpec.describe CollectionResourcesController, type: :request do sign_in user end - it "returns page not found" do + it "returns page not authorised" do patch update_mandatory_collection_resource_path, params: params - expect(response).to have_http_status(:not_found) + expect(response).to have_http_status(:unauthorized) end end end @@ -401,9 +401,9 @@ RSpec.describe CollectionResourcesController, type: :request do sign_in user end - it "returns page not found" do + it "returns page not authorised" do get confirm_mandatory_collection_resources_release_path(year: 2025) - expect(response).to have_http_status(:not_found) + expect(response).to have_http_status(:unauthorized) end end @@ -414,9 +414,9 @@ RSpec.describe CollectionResourcesController, type: :request do sign_in user end - it "returns page not found" do + it "returns page not authorised" do get confirm_mandatory_collection_resources_release_path(year: 2025) - expect(response).to have_http_status(:not_found) + expect(response).to have_http_status(:unauthorized) end end @@ -466,9 +466,9 @@ RSpec.describe CollectionResourcesController, type: :request do sign_in user end - it "returns page not found" do + it "returns page not authorised" do patch release_mandatory_collection_resources_path(year: 2024) - expect(response).to have_http_status(:not_found) + expect(response).to have_http_status(:unauthorized) end end @@ -479,9 +479,9 @@ RSpec.describe CollectionResourcesController, type: :request do sign_in user end - it "returns page not found" do + it "returns page not authorised" do patch release_mandatory_collection_resources_path(year: 2024) - expect(response).to have_http_status(:not_found) + expect(response).to have_http_status(:unauthorized) end end @@ -528,9 +528,9 @@ RSpec.describe CollectionResourcesController, type: :request do sign_in user end - it "returns page not found" do + it "returns page not authorised" do get new_collection_resource_path(year: 2025, log_type: "sales") - expect(response).to have_http_status(:not_found) + expect(response).to have_http_status(:unauthorized) end end @@ -541,9 +541,9 @@ RSpec.describe CollectionResourcesController, type: :request do sign_in user end - it "returns page not found" do + it "returns page not authorised" do get new_collection_resource_path(year: 2025, log_type: "sales") - expect(response).to have_http_status(:not_found) + expect(response).to have_http_status(:unauthorized) end end @@ -589,9 +589,9 @@ RSpec.describe CollectionResourcesController, type: :request do sign_in user end - it "returns page not found" do + it "returns page not authorised" do post collection_resources_path, params: params - expect(response).to have_http_status(:not_found) + expect(response).to have_http_status(:unauthorized) end end @@ -602,9 +602,9 @@ RSpec.describe CollectionResourcesController, type: :request do sign_in user end - it "returns page not found" do + it "returns page not authorised" do post collection_resources_path, params: params - expect(response).to have_http_status(:not_found) + expect(response).to have_http_status(:unauthorized) end end end @@ -722,9 +722,9 @@ RSpec.describe CollectionResourcesController, type: :request do sign_in user end - it "returns page not found" do + it "returns page not authorised" do get collection_resource_edit_path(collection_resource) - expect(response).to have_http_status(:not_found) + expect(response).to have_http_status(:unauthorized) end end @@ -735,9 +735,9 @@ RSpec.describe CollectionResourcesController, type: :request do sign_in user end - it "returns page not found" do + it "returns page not authorised" do get collection_resource_edit_path(collection_resource) - expect(response).to have_http_status(:not_found) + expect(response).to have_http_status(:unauthorized) end end @@ -794,9 +794,9 @@ RSpec.describe CollectionResourcesController, type: :request do sign_in user end - it "returns page not found" do + it "returns page not authorised" do patch collection_resource_update_path(collection_resource), params: params - expect(response).to have_http_status(:not_found) + expect(response).to have_http_status(:unauthorized) end end @@ -807,9 +807,132 @@ RSpec.describe CollectionResourcesController, type: :request do sign_in user end - it "returns page not found" do + it "returns page not authorised" do patch collection_resource_update_path(collection_resource), params: params - expect(response).to have_http_status(:not_found) + expect(response).to have_http_status(:unauthorized) + end + end + end + + describe "GET #collection_resource_delete_confirmation" do + let(:collection_resource) { create(:collection_resource, :additional, year: 2025, log_type: "sales", short_display_name: "additional resource", download_filename: "additional.pdf") } + + context "when user is not signed in" do + it "redirects to the sign in page" do + get collection_resource_delete_confirmation_path(collection_resource) + expect(response).to redirect_to(new_user_session_path) + end + end + + context "when user is signed in as a data coordinator" do + let(:user) { create(:user, :data_coordinator) } + + before do + sign_in user + end + + it "returns page not authorised" do + get collection_resource_delete_confirmation_path(collection_resource) + expect(response).to have_http_status(:unauthorized) + end + end + + context "when user is signed in as a data provider" do + let(:user) { create(:user, :data_provider) } + + before do + sign_in user + end + + it "returns page not authorised" do + get collection_resource_delete_confirmation_path(collection_resource) + expect(response).to have_http_status(:unauthorized) + end + end + + context "when user is signed in as a support user" do + let(:user) { create(:user, :support) } + + before do + allow(Time.zone).to receive(:today).and_return(Time.zone.local(2025, 1, 8)) + allow(user).to receive(:need_two_factor_authentication?).and_return(false) + sign_in user + end + + context "and the file exists on S3" do + it "displays delete confirmation page content" do + get collection_resource_delete_confirmation_path(collection_resource) + + expect(page).to have_content("Sales 2025 to 2026") + expect(page).to have_content("Are you sure you want to delete the additional resource?") + expect(page).to have_content("This file will no longer be available for users to download.") + expect(page).to have_content("You will not be able to undo this action.") + expect(page).to have_button("Delete resource") + expect(page).to have_link("Back", href: collection_resources_path) + expect(page).to have_link("Cancel", href: collection_resources_path) + end + end + end + end + + describe "DELETE #collection_resource_delete" do + let!(:collection_resource) { create(:collection_resource, :additional, year: 2025, log_type: "sales", short_display_name: "additional resource", download_filename: "additional.pdf") } + + context "when user is not signed in" do + it "redirects to the sign in page" do + delete collection_resource_delete_path(collection_resource) + expect(response).to redirect_to(new_user_session_path) + end + end + + context "when user is signed in as a data coordinator" do + let(:user) { create(:user, :data_coordinator) } + + before do + sign_in user + end + + it "returns page not authorised" do + delete collection_resource_delete_path(collection_resource) + expect(response).to have_http_status(:unauthorized) + end + end + + context "when user is signed in as a data provider" do + let(:user) { create(:user, :data_provider) } + + before do + sign_in user + end + + it "returns page not authorised" do + delete collection_resource_delete_path(collection_resource) + expect(response).to have_http_status(:unauthorized) + end + end + + context "when user is signed in as a support user" do + let(:user) { create(:user, :support) } + + before do + allow(storage_service).to receive(:file_exists?).and_return(true) + allow(Time.zone).to receive(:today).and_return(Time.zone.local(2025, 1, 8)) + allow(user).to receive(:need_two_factor_authentication?).and_return(false) + sign_in user + end + + context "and the file exists on S3" do + it "displays delete confirmation page content" do + expect(CollectionResource.visible.count).to eq(1) + delete collection_resource_delete_path(collection_resource) + + expect(CollectionResource.count).to eq(1) + expect(CollectionResource.visible.count).to eq(0) + expect(response).to redirect_to(collection_resources_path) + expect(storage_service).to have_received(:delete_file).with(collection_resource.download_filename) + follow_redirect! + expect(page).to have_content("The sales 2025 to 2026 additional resource has been deleted.") + end end end end From 64caf018e0f0464ba1b77738df4c906ea10f5af0 Mon Sep 17 00:00:00 2001 From: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com> Date: Wed, 23 Oct 2024 13:27:23 +0100 Subject: [PATCH 06/30] CLDC-2413 Allow 4 digit year format for bulk uploads (#2715) * Allow 4 digit years for start date/sale date * Update other dates --- .../lettings/year2023/csv_parser.rb | 6 ++-- .../lettings/year2023/row_parser.rb | 25 ++++++-------- .../lettings/year2024/csv_parser.rb | 6 ++-- .../lettings/year2024/row_parser.rb | 25 ++++++-------- .../bulk_upload/sales/year2023/csv_parser.rb | 6 ++-- .../bulk_upload/sales/year2023/row_parser.rb | 13 ++++--- .../bulk_upload/sales/year2024/csv_parser.rb | 6 ++-- .../bulk_upload/sales/year2024/row_parser.rb | 13 ++++--- config/locales/en.yml | 4 +-- .../lettings/year2023/row_parser_spec.rb | 34 ++++++++++++++++--- .../lettings/year2024/row_parser_spec.rb | 34 ++++++++++++++++--- .../sales/year2023/row_parser_spec.rb | 19 ++++++++--- .../sales/year2024/row_parser_spec.rb | 20 ++++++++--- 13 files changed, 144 insertions(+), 67 deletions(-) diff --git a/app/services/bulk_upload/lettings/year2023/csv_parser.rb b/app/services/bulk_upload/lettings/year2023/csv_parser.rb index 64e27108f..96be2256d 100644 --- a/app/services/bulk_upload/lettings/year2023/csv_parser.rb +++ b/app/services/bulk_upload/lettings/year2023/csv_parser.rb @@ -109,9 +109,11 @@ private def first_record_start_date if with_headers? - Date.new(row_parsers.first.field_9.to_i + 2000, row_parsers.first.field_8.to_i, row_parsers.first.field_7.to_i) + year = row_parsers.first.field_9.to_s.strip.length.between?(1, 2) ? row_parsers.first.field_9.to_i + 2000 : row_parsers.first.field_9.to_i + Date.new(year, row_parsers.first.field_8.to_i, row_parsers.first.field_7.to_i) else - Date.new(rows.first[97].to_i + 2000, rows.first[96].to_i, rows.first[95].to_i) + year = rows.first[97].to_s.strip.length.between?(1, 2) ? rows.first[97].to_i + 2000 : rows.first[97].to_i + Date.new(year, rows.first[96].to_i, rows.first[95].to_i) end end end diff --git a/app/services/bulk_upload/lettings/year2023/row_parser.rb b/app/services/bulk_upload/lettings/year2023/row_parser.rb index 8c435ad24..59cf7ea34 100644 --- a/app/services/bulk_upload/lettings/year2023/row_parser.rb +++ b/app/services/bulk_upload/lettings/year2023/row_parser.rb @@ -323,8 +323,8 @@ class BulkUpload::Lettings::Year2023::RowParser category: :setup, }, format: { - with: /\A\d{2}\z/, - message: I18n.t("validations.setup.startdate.year_not_two_digits"), + with: /\A(\d{2}|\d{4})\z/, + message: I18n.t("validations.setup.startdate.year_not_two_or_four_digits"), category: :setup, unless: -> { field_9.blank? }, }, @@ -618,14 +618,6 @@ private end end - def start_date - return if field_7.blank? || field_8.blank? || field_9.blank? - - Date.parse("20#{field_9.to_s.rjust(2, '0')}-#{field_8}-#{field_7}") - rescue StandardError - nil - end - def validate_no_and_dont_know_disabled_needs_conjunction if field_87 == 1 && field_88 == 1 errors.add(:field_87, I18n.t("validations.household.housingneeds.no_and_dont_know_disabled_needs_conjunction")) @@ -736,9 +728,9 @@ private end def validate_relevant_collection_window - return if start_date.blank? || bulk_upload.form.blank? + return if startdate.blank? || bulk_upload.form.blank? - unless bulk_upload.form.valid_start_date_for_form?(start_date) + unless bulk_upload.form.valid_start_date_for_form?(startdate) errors.add(:field_7, I18n.t("validations.date.outside_collection_window", year_combo: bulk_upload.year_combo, start_year: bulk_upload.year, end_year: bulk_upload.end_year), category: :setup) errors.add(:field_8, I18n.t("validations.date.outside_collection_window", year_combo: bulk_upload.year_combo, start_year: bulk_upload.year, end_year: bulk_upload.end_year), category: :setup) errors.add(:field_9, I18n.t("validations.date.outside_collection_window", year_combo: bulk_upload.year_combo, start_year: bulk_upload.year, end_year: bulk_upload.end_year), category: :setup) @@ -1388,7 +1380,8 @@ private end def startdate - Date.new(field_9 + 2000, field_8, field_7) if field_9.present? && field_8.present? && field_7.present? + year = field_9.to_s.strip.length.between?(1, 2) ? field_9 + 2000 : field_9 + Date.new(year, field_8, field_7) if field_9.present? && field_8.present? && field_7.present? rescue Date::Error Date.new end @@ -1584,13 +1577,15 @@ private end def mrcdate - Date.new(field_38 + 2000, field_37, field_36) if field_38.present? && field_37.present? && field_36.present? + year = field_38.to_s.strip.length.between?(1, 2) ? field_38 + 2000 : field_38 + Date.new(year, field_37, field_36) if field_38.present? && field_37.present? && field_36.present? rescue Date::Error Date.new end def voiddate - Date.new(field_35 + 2000, field_34, field_33) if field_35.present? && field_34.present? && field_33.present? + year = field_35.to_s.strip.length.between?(1, 2) ? field_35 + 2000 : field_35 + Date.new(year, field_34, field_33) if field_35.present? && field_34.present? && field_33.present? rescue Date::Error Date.new end diff --git a/app/services/bulk_upload/lettings/year2024/csv_parser.rb b/app/services/bulk_upload/lettings/year2024/csv_parser.rb index d8d430755..22caeab02 100644 --- a/app/services/bulk_upload/lettings/year2024/csv_parser.rb +++ b/app/services/bulk_upload/lettings/year2024/csv_parser.rb @@ -112,9 +112,11 @@ private def first_record_start_date if with_headers? - Date.new(row_parsers.first.field_10.to_i + 2000, row_parsers.first.field_9.to_i, row_parsers.first.field_8.to_i) + year = row_parsers.first.field_10.to_s.strip.length.between?(1, 2) ? row_parsers.first.field_10.to_i + 2000 : row_parsers.first.field_10.to_i + Date.new(year, row_parsers.first.field_9.to_i, row_parsers.first.field_8.to_i) else - Date.new(rows.first[9].to_i + 2000, rows.first[8].to_i, rows.first[7].to_i) + year = rows.first[9].to_s.strip.length.between?(1, 2) ? rows.first[9].to_i + 2000 : rows.first[9].to_i + Date.new(year, rows.first[8].to_i, rows.first[7].to_i) end end end diff --git a/app/services/bulk_upload/lettings/year2024/row_parser.rb b/app/services/bulk_upload/lettings/year2024/row_parser.rb index a7eb96c61..312a5472a 100644 --- a/app/services/bulk_upload/lettings/year2024/row_parser.rb +++ b/app/services/bulk_upload/lettings/year2024/row_parser.rb @@ -324,8 +324,8 @@ class BulkUpload::Lettings::Year2024::RowParser category: :setup, }, format: { - with: /\A\d{2}\z/, - message: I18n.t("validations.setup.startdate.year_not_two_digits"), + with: /\A(\d{2}|\d{4})\z/, + message: I18n.t("validations.setup.startdate.year_not_two_or_four_digits"), category: :setup, unless: -> { field_10.blank? }, }, @@ -686,14 +686,6 @@ private end end - def start_date - return if field_8.blank? || field_9.blank? || field_10.blank? - - Date.parse("20#{field_10.to_s.rjust(2, '0')}-#{field_9}-#{field_8}") - rescue StandardError - nil - end - def validate_no_and_dont_know_disabled_needs_conjunction if field_83 == 1 && field_84 == 1 errors.add(:field_83, I18n.t("validations.household.housingneeds.no_and_dont_know_disabled_needs_conjunction")) @@ -790,9 +782,9 @@ private end def validate_relevant_collection_window - return if start_date.blank? || bulk_upload.form.blank? + return if startdate.blank? || bulk_upload.form.blank? - unless bulk_upload.form.valid_start_date_for_form?(start_date) + unless bulk_upload.form.valid_start_date_for_form?(startdate) errors.add(:field_8, I18n.t("validations.date.outside_collection_window", year_combo: bulk_upload.year_combo, start_year: bulk_upload.year, end_year: bulk_upload.end_year), category: :setup) errors.add(:field_9, I18n.t("validations.date.outside_collection_window", year_combo: bulk_upload.year_combo, start_year: bulk_upload.year, end_year: bulk_upload.end_year), category: :setup) errors.add(:field_10, I18n.t("validations.date.outside_collection_window", year_combo: bulk_upload.year_combo, start_year: bulk_upload.year, end_year: bulk_upload.end_year), category: :setup) @@ -1394,7 +1386,8 @@ private end def startdate - Date.new(field_10 + 2000, field_9, field_8) if field_10.present? && field_9.present? && field_8.present? + year = field_10.to_s.strip.length.between?(1, 2) ? field_10 + 2000 : field_10 + Date.new(year, field_9, field_8) if field_10.present? && field_9.present? && field_8.present? rescue Date::Error Date.new end @@ -1599,13 +1592,15 @@ private end def mrcdate - Date.new(field_35 + 2000, field_34, field_33) if field_35.present? && field_34.present? && field_33.present? + year = field_35.to_s.strip.length.between?(1, 2) ? field_35 + 2000 : field_35 + Date.new(year, field_34, field_33) if field_35.present? && field_34.present? && field_33.present? rescue Date::Error Date.new end def voiddate - Date.new(field_32 + 2000, field_31, field_30) if field_32.present? && field_31.present? && field_30.present? + year = field_32.to_s.strip.length.between?(1, 2) ? field_32 + 2000 : field_32 + Date.new(year, field_31, field_30) if field_32.present? && field_31.present? && field_30.present? rescue Date::Error Date.new end diff --git a/app/services/bulk_upload/sales/year2023/csv_parser.rb b/app/services/bulk_upload/sales/year2023/csv_parser.rb index ec7346f92..85d455d01 100644 --- a/app/services/bulk_upload/sales/year2023/csv_parser.rb +++ b/app/services/bulk_upload/sales/year2023/csv_parser.rb @@ -111,9 +111,11 @@ private def first_record_start_date if with_headers? - Date.new(row_parsers.first.field_5.to_i + 2000, row_parsers.first.field_4.to_i, row_parsers.first.field_3.to_i) + year = row_parsers.first.field_5.to_s.strip.length.between?(1, 2) ? row_parsers.first.field_5.to_i + 2000 : row_parsers.first.field_5.to_i + Date.new(year, row_parsers.first.field_4.to_i, row_parsers.first.field_3.to_i) else - Date.new(rows.first[3].to_i + 2000, rows.first[2].to_i, rows.first[1].to_i) + year = rows.first[3].to_s.strip.length.between?(1, 2) ? rows.first[3].to_i + 2000 : rows.first[3].to_i + Date.new(year, rows.first[2].to_i, rows.first[1].to_i) end end end diff --git a/app/services/bulk_upload/sales/year2023/row_parser.rb b/app/services/bulk_upload/sales/year2023/row_parser.rb index 6a18512aa..d87c94dce 100644 --- a/app/services/bulk_upload/sales/year2023/row_parser.rb +++ b/app/services/bulk_upload/sales/year2023/row_parser.rb @@ -328,8 +328,8 @@ class BulkUpload::Sales::Year2023::RowParser category: :setup, }, format: { - with: /\A\d{2}\z/, - message: I18n.t("validations.setup.saledate.year_not_two_digits"), + with: /\A(\d{2}|\d{4})\z/, + message: I18n.t("validations.setup.saledate.year_not_two_or_four_digits"), category: :setup, if: proc { field_5.present? }, }, on: :after_log @@ -954,19 +954,22 @@ private end def saledate - Date.new(field_5 + 2000, field_4, field_3) if field_5.present? && field_4.present? && field_3.present? + year = field_5.to_s.strip.length.between?(1, 2) ? field_5 + 2000 : field_5 + Date.new(year, field_4, field_3) if field_5.present? && field_4.present? && field_3.present? rescue Date::Error Date.new end def hodate - Date.new(field_97 + 2000, field_96, field_95) if field_97.present? && field_96.present? && field_95.present? + year = field_97.to_s.strip.length.between?(1, 2) ? field_97 + 2000 : field_97 + Date.new(year, field_96, field_95) if field_97.present? && field_96.present? && field_95.present? rescue Date::Error Date.new end def exdate - Date.new(field_94 + 2000, field_93, field_92) if field_94.present? && field_93.present? && field_92.present? + year = field_94.to_s.strip.length.between?(1, 2) ? field_94 + 2000 : field_94 + Date.new(year, field_93, field_92) if field_94.present? && field_93.present? && field_92.present? rescue Date::Error Date.new end diff --git a/app/services/bulk_upload/sales/year2024/csv_parser.rb b/app/services/bulk_upload/sales/year2024/csv_parser.rb index 9ba99c19b..4a3cb7ac9 100644 --- a/app/services/bulk_upload/sales/year2024/csv_parser.rb +++ b/app/services/bulk_upload/sales/year2024/csv_parser.rb @@ -114,9 +114,11 @@ private def first_record_start_date if with_headers? - Date.new(row_parsers.first.field_6.to_i + 2000, row_parsers.first.field_5.to_i, row_parsers.first.field_4.to_i) + year = row_parsers.first.field_6.to_s.strip.length.between?(1, 2) ? row_parsers.first.field_6.to_i + 2000 : row_parsers.first.field_6.to_i + Date.new(year, row_parsers.first.field_5.to_i, row_parsers.first.field_4.to_i) else - Date.new(rows.first[5].to_i + 2000, rows.first[4].to_i, rows.first[3].to_i) + year = rows.first[5].to_s.strip.length.between?(1, 2) ? rows.first[5].to_i + 2000 : rows.first[5].to_i + Date.new(year, rows.first[4].to_i, rows.first[3].to_i) end end end diff --git a/app/services/bulk_upload/sales/year2024/row_parser.rb b/app/services/bulk_upload/sales/year2024/row_parser.rb index 35984a045..7b72eef5c 100644 --- a/app/services/bulk_upload/sales/year2024/row_parser.rb +++ b/app/services/bulk_upload/sales/year2024/row_parser.rb @@ -320,8 +320,8 @@ class BulkUpload::Sales::Year2024::RowParser category: :setup, }, format: { - with: /\A\d{2}\z/, - message: I18n.t("validations.setup.saledate.year_not_two_digits"), + with: /\A(\d{2}|\d{4})\z/, + message: I18n.t("validations.setup.saledate.year_not_two_or_four_digits"), category: :setup, if: proc { field_6.present? }, }, on: :after_log @@ -994,19 +994,22 @@ private end def saledate - Date.new(field_6 + 2000, field_5, field_4) if field_6.present? && field_5.present? && field_4.present? + year = field_6.to_s.strip.length.between?(1, 2) ? field_6 + 2000 : field_6 + Date.new(year, field_5, field_4) if field_6.present? && field_5.present? && field_4.present? rescue Date::Error Date.new end def hodate - Date.new(field_96 + 2000, field_95, field_94) if field_96.present? && field_95.present? && field_94.present? + year = field_96.to_s.strip.length.between?(1, 2) ? field_96 + 2000 : field_96 + Date.new(year, field_95, field_94) if field_96.present? && field_95.present? && field_94.present? rescue Date::Error Date.new end def exdate - Date.new(field_93 + 2000, field_92, field_91) if field_93.present? && field_92.present? && field_91.present? + year = field_93.to_s.strip.length.between?(1, 2) ? field_93 + 2000 : field_93 + Date.new(year, field_92, field_91) if field_93.present? && field_92.present? && field_91.present? rescue Date::Error Date.new end diff --git a/config/locales/en.yml b/config/locales/en.yml index d490fd8ae..faced2c11 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -284,7 +284,7 @@ en: intermediate_rent_product_name: blank: "Enter name of other intermediate rent product." saledate: - year_not_two_digits: "Sale completion year must be 2 digits." + year_not_two_or_four_digits: "Sale completion year must be 2 or 4 digits." type: percentage_bought_must_be_at_least_threshold: "The minimum increase in equity while staircasing is %{threshold}% for this shared ownership type." @@ -297,7 +297,7 @@ en: before_scheme_end_date: "The tenancy start date must be before the end date for this supported housing scheme." after_void_date: "Enter a tenancy start date that is after the void date." after_major_repair_date: "Enter a tenancy start date that is after the major repair date." - year_not_two_digits: "Tenancy start year must be 2 digits." + year_not_two_or_four_digits: "Tenancy start year must be 2 or 4 digits." ten_years_after_void_date: "Enter a tenancy start date that is no more than 10 years after the void date." ten_years_after_mrc_date: "Enter a tenancy start date that is no more than 10 years after the major repairs completion date." invalid_merged_organisations_start_date: diff --git a/spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb b/spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb index 6d3feffa9..314db674d 100644 --- a/spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb +++ b/spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb @@ -1476,11 +1476,21 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do end context "when field_9 is 4 digits instead of 2" do - let(:attributes) { { bulk_upload:, field_9: "2022" } } + let(:attributes) { setup_section_params.merge({ bulk_upload:, field_9: "2023", field_8: "12", field_7: "1" }) } + + it "correctly sets the date" do + parser.valid? + expect(parser.errors[:field_9]).to be_empty + expect(parser.log.startdate).to eq(Date.new(2023, 12, 1)) + end + end + + context "when field_9 is not 4 or 2 digits" do + let(:attributes) { { bulk_upload:, field_9: "202" } } it "returns an error" do parser.valid? - expect(parser.errors[:field_9]).to include("Tenancy start year must be 2 digits.") + expect(parser.errors[:field_9]).to include("Tenancy start year must be 2 or 4 digits.") end end @@ -2546,6 +2556,14 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do end end + context "when valid (4 digit year)" do + let(:attributes) { { bulk_upload:, field_36: "13", field_37: "12", field_38: "2022" } } + + it "sets value given" do + expect(parser.log.mrcdate).to eq(Date.new(2022, 12, 13)) + end + end + context "when invalid" do let(:attributes) { { bulk_upload:, field_36: "13", field_37: "13", field_38: "22" } } @@ -2582,6 +2600,14 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do end end + context "when valid (4 digit year)" do + let(:attributes) { { bulk_upload:, field_33: "13", field_34: "12", field_35: "2022" } } + + it "sets value given" do + expect(parser.log.voiddate).to eq(Date.new(2022, 12, 13)) + end + end + context "when invalid" do let(:attributes) { { bulk_upload:, field_33: "13", field_34: "13", field_35: "22" } } @@ -2824,12 +2850,12 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do end end - describe "#start_date" do + describe "#startdate" do context "when year of 9 is passed to represent 2009" do let(:attributes) { { bulk_upload:, field_7: "1", field_8: "1", field_9: "9" } } it "uses the year 2009" do - expect(parser.send(:start_date)).to eql(Date.new(2009, 1, 1)) + expect(parser.send(:startdate)).to eql(Date.new(2009, 1, 1)) end end end diff --git a/spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb b/spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb index 2e4c82635..d82effa0b 100644 --- a/spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb +++ b/spec/services/bulk_upload/lettings/year2024/row_parser_spec.rb @@ -1303,11 +1303,21 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do end context "when field_10 is 4 digits instead of 2" do - let(:attributes) { { bulk_upload:, field_10: "2023" } } + let(:attributes) { setup_section_params.merge({ bulk_upload:, field_10: "2024", field_9: "4", field_8: "5" }) } + + it "correctly sets the date" do + parser.valid? + expect(parser.errors[:field_10]).to be_empty + expect(parser.log.startdate).to eq(Time.zone.local(2024, 4, 5)) + end + end + + context "when field_10 is not 4 or 2 digits" do + let(:attributes) { { bulk_upload:, field_10: "204" } } it "returns an error" do parser.valid? - expect(parser.errors[:field_10]).to include("Tenancy start year must be 2 digits.") + expect(parser.errors[:field_10]).to include("Tenancy start year must be 2 or 4 digits.") end end @@ -2659,6 +2669,14 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do end end + context "when valid (4 digit year)" do + let(:attributes) { { bulk_upload:, field_33: "13", field_34: "12", field_35: "2022" } } + + it "sets value given" do + expect(parser.log.mrcdate).to eq(Date.new(2022, 12, 13)) + end + end + context "when invalid" do let(:attributes) { { bulk_upload:, field_33: "13", field_34: "13", field_35: "22" } } @@ -2695,6 +2713,14 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do end end + context "when valid (4 digit year)" do + let(:attributes) { { bulk_upload:, field_30: "13", field_31: "12", field_32: "2022" } } + + it "sets value given" do + expect(parser.log.voiddate).to eq(Date.new(2022, 12, 13)) + end + end + context "when invalid" do let(:attributes) { { bulk_upload:, field_30: "13", field_31: "13", field_32: "22" } } @@ -2945,12 +2971,12 @@ RSpec.describe BulkUpload::Lettings::Year2024::RowParser do end end - describe "#start_date" do + describe "#startdate" do context "when year of 9 is passed to represent 2009" do let(:attributes) { { bulk_upload:, field_8: "1", field_9: "1", field_10: "9" } } it "uses the year 2009" do - expect(parser.send(:start_date)).to eql(Date.new(2009, 1, 1)) + expect(parser.send(:startdate)).to eql(Date.new(2009, 1, 1)) end end end diff --git a/spec/services/bulk_upload/sales/year2023/row_parser_spec.rb b/spec/services/bulk_upload/sales/year2023/row_parser_spec.rb index d5b6aa718..824754b25 100644 --- a/spec/services/bulk_upload/sales/year2023/row_parser_spec.rb +++ b/spec/services/bulk_upload/sales/year2023/row_parser_spec.rb @@ -88,10 +88,10 @@ RSpec.describe BulkUpload::Sales::Year2023::RowParser do field_90: "1", field_92: "30", field_93: "3", - field_94: "22", + field_94: "2022", field_95: "24", field_96: "3", - field_97: "22", + field_97: "2022", field_98: "3", field_99: "1", field_100: "1", @@ -594,10 +594,21 @@ RSpec.describe BulkUpload::Sales::Year2023::RowParser do end context "when field 5 is 4 digits instead of 2" do - let(:attributes) { setup_section_params.merge({ bulk_upload:, field_5: "2022" }) } + let(:attributes) { setup_section_params.merge({ bulk_upload:, field_5: "2023", field_4: "4", field_3: "3" }) } + + it "correctly sets the date" do + parser.valid? + expect(parser.errors.where(:field_5, category: :setup)).to be_empty + expect(parser.log.saledate).to eq(Time.zone.local(2023, 4, 3)) + end + end + + context "when field 5 is not 2 or 4 digits" do + let(:attributes) { setup_section_params.merge({ bulk_upload:, field_5: "202" }) } it "returns a setup error" do - expect(parser.errors.where(:field_5, category: :setup).map(&:message)).to include("Sale completion year must be 2 digits.") + parser.valid? + expect(parser.errors.where(:field_5, category: :setup).map(&:message)).to include("Sale completion year must be 2 or 4 digits.") end end diff --git a/spec/services/bulk_upload/sales/year2024/row_parser_spec.rb b/spec/services/bulk_upload/sales/year2024/row_parser_spec.rb index 3c4e71247..96914fc44 100644 --- a/spec/services/bulk_upload/sales/year2024/row_parser_spec.rb +++ b/spec/services/bulk_upload/sales/year2024/row_parser_spec.rb @@ -95,10 +95,10 @@ RSpec.describe BulkUpload::Sales::Year2024::RowParser do field_89: "1", field_91: "30", field_92: "3", - field_93: "22", + field_93: "2022", field_94: "24", field_95: "3", - field_96: "22", + field_96: "2022", field_97: "3", field_98: "1", field_99: "1", @@ -721,12 +721,22 @@ RSpec.describe BulkUpload::Sales::Year2024::RowParser do end end - context "when field 5 is 4 digits instead of 2" do - let(:attributes) { setup_section_params.merge({ bulk_upload:, field_6: "2023" }) } + context "when field 6 is 4 digits instead of 2" do + let(:attributes) { setup_section_params.merge({ bulk_upload:, field_6: "2024" }) } + + it "correctly sets the date" do + parser.valid? + expect(parser.errors.where(:field_6, category: :setup)).to be_empty + expect(parser.log.saledate).to eq(Time.zone.local(2024, 5, 1)) + end + end + + context "when field 5 is not 2 or 4 digits" do + let(:attributes) { setup_section_params.merge({ bulk_upload:, field_6: "202" }) } it "returns a setup error" do parser.valid? - expect(parser.errors.where(:field_6, category: :setup).map(&:message)).to include("Sale completion year must be 2 digits.") + expect(parser.errors.where(:field_6, category: :setup).map(&:message)).to include("Sale completion year must be 2 or 4 digits.") end end From 0799ff7a36bd89c995a9e93230736b69a9bb8391 Mon Sep 17 00:00:00 2001 From: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com> Date: Fri, 25 Oct 2024 08:20:07 +0100 Subject: [PATCH 07/30] CLDC-3658 Extract household needs copy (#2718) * Extract household needs subsection copy * Extract housing needs soft validations copy * Add new lines at the end of some files --- .../sales/pages/household_wheelchair_check.rb | 4 +-- .../form/sales/questions/armed_forces.rb | 3 -- .../sales/questions/armed_forces_spouse.rb | 2 -- .../sales/questions/buyer_still_serving.rb | 2 -- .../sales/questions/household_disability.rb | 3 -- .../sales/questions/household_wheelchair.rb | 2 -- .../questions/household_wheelchair_check.rb | 3 +- config/locales/en.yml | 2 -- .../forms/2023/sales/household_needs.en.yml | 34 +++++++++++++++++++ .../forms/2023/sales/soft_validations.en.yml | 6 ++++ .../forms/2024/sales/household_needs.en.yml | 34 +++++++++++++++++++ .../forms/2024/sales/soft_validations.en.yml | 6 ++++ .../pages/household_wheelchair_check_spec.rb | 3 +- .../sales/subsections/household_needs_spec.rb | 3 +- 14 files changed, 87 insertions(+), 20 deletions(-) create mode 100644 config/locales/forms/2023/sales/household_needs.en.yml create mode 100644 config/locales/forms/2024/sales/household_needs.en.yml diff --git a/app/models/form/sales/pages/household_wheelchair_check.rb b/app/models/form/sales/pages/household_wheelchair_check.rb index 72b78cc2b..8cd2821be 100644 --- a/app/models/form/sales/pages/household_wheelchair_check.rb +++ b/app/models/form/sales/pages/household_wheelchair_check.rb @@ -6,8 +6,8 @@ class Form::Sales::Pages::HouseholdWheelchairCheck < ::Form::Page "wheelchair_when_not_disabled?" => true, }, ] - @informative_text = {} - @title_text = { "translation" => "soft_validations.wheelchair.title_text" } + @copy_key = "sales.soft_validations.wheel_value_check" + @title_text = { "translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text" } end def questions diff --git a/app/models/form/sales/questions/armed_forces.rb b/app/models/form/sales/questions/armed_forces.rb index 0d655a733..7bd14d7b1 100644 --- a/app/models/form/sales/questions/armed_forces.rb +++ b/app/models/form/sales/questions/armed_forces.rb @@ -2,10 +2,7 @@ class Form::Sales::Questions::ArmedForces < ::Form::Question def initialize(id, hsh, page) super @id = "hhregres" - @check_answer_label = "Have any of the buyers ever served as a regular in the UK armed forces?" - @header = "Have any of the buyers ever served as a regular in the UK armed forces?" @type = "radio" - @hint_text = "A regular is somebody who has served in the Royal Navy, the Royal Marines, the Royal Airforce or Army full time and does not include reserve forces" @answer_options = ANSWER_OPTIONS @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end diff --git a/app/models/form/sales/questions/armed_forces_spouse.rb b/app/models/form/sales/questions/armed_forces_spouse.rb index 949b5d612..02be7c5e3 100644 --- a/app/models/form/sales/questions/armed_forces_spouse.rb +++ b/app/models/form/sales/questions/armed_forces_spouse.rb @@ -2,8 +2,6 @@ class Form::Sales::Questions::ArmedForcesSpouse < ::Form::Question def initialize(id, hsh, page) super @id = "armedforcesspouse" - @check_answer_label = "Are any of the buyers a spouse or civil partner of a UK armed forces regular who died in service within the last 2 years?" - @header = "Are any of the buyers a spouse or civil partner of a UK armed forces regular who died in service within the last 2 years?" @type = "radio" @answer_options = ANSWER_OPTIONS @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] diff --git a/app/models/form/sales/questions/buyer_still_serving.rb b/app/models/form/sales/questions/buyer_still_serving.rb index 602a0804d..04c1c2307 100644 --- a/app/models/form/sales/questions/buyer_still_serving.rb +++ b/app/models/form/sales/questions/buyer_still_serving.rb @@ -2,8 +2,6 @@ class Form::Sales::Questions::BuyerStillServing < ::Form::Question def initialize(id, hsh, page) super @id = "hhregresstill" - @check_answer_label = "Are they still serving in the UK armed forces?" - @header = "Is the buyer still serving in the UK armed forces?" @type = "radio" @answer_options = ANSWER_OPTIONS @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] diff --git a/app/models/form/sales/questions/household_disability.rb b/app/models/form/sales/questions/household_disability.rb index 43773dcf3..3dac19bb6 100644 --- a/app/models/form/sales/questions/household_disability.rb +++ b/app/models/form/sales/questions/household_disability.rb @@ -2,11 +2,8 @@ class Form::Sales::Questions::HouseholdDisability < ::Form::Question def initialize(id, hsh, page) super @id = "disabled" - @header = "Does anyone in the household consider themselves to have a disability?" - @check_answer_label = "Does anyone in the household have a disability?" @type = "radio" @answer_options = ANSWER_OPTIONS - @hint_text = "This includes any long-term health condition that has an impact on the person's day-to-day life" @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end diff --git a/app/models/form/sales/questions/household_wheelchair.rb b/app/models/form/sales/questions/household_wheelchair.rb index 4b5316b29..4c46bd55d 100644 --- a/app/models/form/sales/questions/household_wheelchair.rb +++ b/app/models/form/sales/questions/household_wheelchair.rb @@ -2,10 +2,8 @@ class Form::Sales::Questions::HouseholdWheelchair < ::Form::Question def initialize(id, hsh, page) super @id = "wheel" - @header = "Does anyone in the household use a wheelchair?" @type = "radio" @answer_options = ANSWER_OPTIONS - @hint_text = "This can be inside or outside the home" @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end diff --git a/app/models/form/sales/questions/household_wheelchair_check.rb b/app/models/form/sales/questions/household_wheelchair_check.rb index 50498b099..a37e80203 100644 --- a/app/models/form/sales/questions/household_wheelchair_check.rb +++ b/app/models/form/sales/questions/household_wheelchair_check.rb @@ -2,8 +2,7 @@ class Form::Sales::Questions::HouseholdWheelchairCheck < ::Form::Question def initialize(id, hsh, page) super @id = "wheel_value_check" - @check_answer_label = "Does anyone in the household use a wheelchair?" - @header = "You told us that someone in the household uses a wheelchair." + @copy_key = "sales.soft_validations.wheel_value_check" @type = "interruption_screen" @answer_options = { "0" => { "value" => "Yes" }, diff --git a/config/locales/en.yml b/config/locales/en.yml index faced2c11..53154eab2 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -754,8 +754,6 @@ Make sure these answers are correct." grant: title_text: "You told us that the grant amount is %{grant}." hint_text: "Loans, grants and subsidies are usually between £9,000 and £16,000." - wheelchair: - title_text: "You told us that someone in the household uses a wheelchair." referral: title_text: "Are you sure?" hint_text: "This is a general needs log, and this referral type is for supported housing." diff --git a/config/locales/forms/2023/sales/household_needs.en.yml b/config/locales/forms/2023/sales/household_needs.en.yml new file mode 100644 index 000000000..f4a13e47a --- /dev/null +++ b/config/locales/forms/2023/sales/household_needs.en.yml @@ -0,0 +1,34 @@ +en: + forms: + 2023: + sales: + household_needs: + hhregres: + page_header: "" + check_answer_label: "Have any of the buyers ever served as a regular in the UK armed forces?" + hint_text: "A regular is somebody who has served in the Royal Navy, the Royal Marines, the Royal Airforce or Army full time and does not include reserve forces" + question_text: "Have any of the buyers ever served as a regular in the UK armed forces?" + + hhregresstill: + page_header: "" + check_answer_label: "Are they still serving in the UK armed forces?" + hint_text: "" + question_text: "Is the buyer still serving in the UK armed forces?" + + armedforcesspouse: + page_header: "" + check_answer_label: "Are any of the buyers a spouse or civil partner of a UK armed forces regular who died in service within the last 2 years?" + hint_text: "" + question_text: "Are any of the buyers a spouse or civil partner of a UK armed forces regular who died in service within the last 2 years?" + + disabled: + page_header: "" + check_answer_label: "Does anyone in the household have a disability?" + hint_text: "This includes any long-term health condition that has an impact on the person's day-to-day life" + question_text: "Does anyone in the household consider themselves to have a disability?" + + wheel: + page_header: "" + check_answer_label: "Does anyone in the household use a wheelchair?" + hint_text: "This can be inside or outside the home" + question_text: "Does anyone in the household use a wheelchair?" diff --git a/config/locales/forms/2023/sales/soft_validations.en.yml b/config/locales/forms/2023/sales/soft_validations.en.yml index de5138208..a0912555a 100644 --- a/config/locales/forms/2023/sales/soft_validations.en.yml +++ b/config/locales/forms/2023/sales/soft_validations.en.yml @@ -58,3 +58,9 @@ en: not_joint_purchase: title_text: "You told us the buyer’s deposit was %{deposit} and their savings were %{savings}." informative_text: "The deposit amount is higher than we would expect for the amount of savings they have." + wheel_value_check: + page_header: "" + check_answer_label: "Does anyone in the household use a wheelchair?" + hint_text: "" + question_text: "You told us that someone in the household uses a wheelchair." + title_text: "You told us that someone in the household uses a wheelchair." diff --git a/config/locales/forms/2024/sales/household_needs.en.yml b/config/locales/forms/2024/sales/household_needs.en.yml new file mode 100644 index 000000000..290543a34 --- /dev/null +++ b/config/locales/forms/2024/sales/household_needs.en.yml @@ -0,0 +1,34 @@ +en: + forms: + 2024: + sales: + household_needs: + hhregres: + page_header: "" + check_answer_label: "Have any of the buyers ever served as a regular in the UK armed forces?" + hint_text: "A regular is somebody who has served in the Royal Navy, the Royal Marines, the Royal Airforce or Army full time and does not include reserve forces" + question_text: "Have any of the buyers ever served as a regular in the UK armed forces?" + + hhregresstill: + page_header: "" + check_answer_label: "Are they still serving in the UK armed forces?" + hint_text: "" + question_text: "Is the buyer still serving in the UK armed forces?" + + armedforcesspouse: + page_header: "" + check_answer_label: "Are any of the buyers a spouse or civil partner of a UK armed forces regular who died in service within the last 2 years?" + hint_text: "" + question_text: "Are any of the buyers a spouse or civil partner of a UK armed forces regular who died in service within the last 2 years?" + + disabled: + page_header: "" + check_answer_label: "Does anyone in the household have a disability?" + hint_text: "This includes any long-term health condition that has an impact on the person's day-to-day life" + question_text: "Does anyone in the household consider themselves to have a disability?" + + wheel: + page_header: "" + check_answer_label: "Does anyone in the household use a wheelchair?" + hint_text: "This can be inside or outside the home" + question_text: "Does anyone in the household use a wheelchair?" diff --git a/config/locales/forms/2024/sales/soft_validations.en.yml b/config/locales/forms/2024/sales/soft_validations.en.yml index 853d21ad2..2c7ac6e3e 100644 --- a/config/locales/forms/2024/sales/soft_validations.en.yml +++ b/config/locales/forms/2024/sales/soft_validations.en.yml @@ -58,3 +58,9 @@ en: not_joint_purchase: title_text: "You told us the buyer’s deposit was %{deposit} and their savings were %{savings}." informative_text: "The deposit amount is higher than we would expect for the amount of savings they have." + wheel_value_check: + page_header: "" + check_answer_label: "Does anyone in the household use a wheelchair?" + hint_text: "" + question_text: "You told us that someone in the household uses a wheelchair." + title_text: "You told us that someone in the household uses a wheelchair." diff --git a/spec/models/form/sales/pages/household_wheelchair_check_spec.rb b/spec/models/form/sales/pages/household_wheelchair_check_spec.rb index f0789b54c..68e269cbf 100644 --- a/spec/models/form/sales/pages/household_wheelchair_check_spec.rb +++ b/spec/models/form/sales/pages/household_wheelchair_check_spec.rb @@ -5,7 +5,8 @@ RSpec.describe Form::Sales::Pages::HouseholdWheelchairCheck, type: :model do let(:page_id) { "buyer_1_income_mortgage_value_check" } let(:page_definition) { nil } - let(:subsection) { instance_double(Form::Subsection) } + let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) } + let(:subsection) { instance_double(Form::Subsection, form:) } it "has correct subsection" do expect(page.subsection).to eq(subsection) diff --git a/spec/models/form/sales/subsections/household_needs_spec.rb b/spec/models/form/sales/subsections/household_needs_spec.rb index d65f5513e..cd4ff67fa 100644 --- a/spec/models/form/sales/subsections/household_needs_spec.rb +++ b/spec/models/form/sales/subsections/household_needs_spec.rb @@ -5,7 +5,8 @@ RSpec.describe Form::Sales::Subsections::HouseholdNeeds, type: :model do let(:subsection_id) { nil } let(:subsection_definition) { nil } - let(:section) { instance_double(Form::Sales::Sections::Household) } + let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) } + let(:section) { instance_double(Form::Sales::Sections::Household, form:) } it "has correct section" do expect(household_characteristics.section).to eq(section) From 72d83bcd44ac37384ed99c5fb9c00b17a3923b41 Mon Sep 17 00:00:00 2001 From: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com> Date: Fri, 25 Oct 2024 13:15:45 +0100 Subject: [PATCH 08/30] Fix role updates (#2727) * Allow some providers to update role on staging * Refactor --- app/controllers/users_controller.rb | 17 ++++++++++------- app/models/user.rb | 6 +++++- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index b7c323ca1..f27bfc2b3 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -257,13 +257,7 @@ private def user_params if @user == current_user - if current_user.data_coordinator? - params.require(:user).permit(:email, :phone, :phone_extension, :name, :password, :password_confirmation, :role, :is_dpo, :is_key_contact, :initial_confirmation_sent) - elsif current_user.support? - params.require(:user).permit(:email, :phone, :phone_extension, :name, :password, :password_confirmation, :role, :is_dpo, :is_key_contact, :initial_confirmation_sent, :organisation_id) - else - params.require(:user).permit(:email, :phone, :phone_extension, :name, :password, :password_confirmation, :initial_confirmation_sent) - end + current_user_params elsif current_user.data_coordinator? params.require(:user).permit(:email, :phone, :phone_extension, :name, :role, :is_dpo, :is_key_contact, :active, :initial_confirmation_sent) elsif current_user.support? @@ -271,6 +265,15 @@ private end end + def current_user_params + base_params = %i[email phone phone_extension name password password_confirmation initial_confirmation_sent] + return params.require(:user).permit(*(base_params + %i[role is_dpo is_key_contact])) if current_user.data_coordinator? + return params.require(:user).permit(*(base_params + %i[role is_dpo is_key_contact organisation_id])) if current_user.support? + return params.require(:user).permit(*(base_params + [:role])) if Rails.env.staging? && current_user.in_staging_role_update_email_allowlist? + + params.require(:user).permit(*base_params) + end + def user_params_without_org user_params.except(:organisation_id) end diff --git a/app/models/user.rb b/app/models/user.rb index 0d3bc4846..75b5a366b 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -212,7 +212,7 @@ class User < ApplicationRecord end def assignable_roles - if Rails.env.staging? && Rails.application.credentials[:staging_role_update_email_allowlist].include?(email.split("@").last.downcase) + if Rails.env.staging? && in_staging_role_update_email_allowlist? return ROLES end @@ -222,6 +222,10 @@ class User < ApplicationRecord ROLES.except(:support) end + def in_staging_role_update_email_allowlist? + Rails.application.credentials[:staging_role_update_email_allowlist].include?(email.split("@").last.downcase) + end + def logs_filters(specific_org: false) if (support? && !specific_org) || organisation.has_managing_agents? || organisation.has_stock_owners? %w[years status needstypes assigned_to user owning_organisation managing_organisation bulk_upload_id user_text_search owning_organisation_text_search managing_organisation_text_search] From be52a7b7b49c79cb60e682464062a7050f74e55d Mon Sep 17 00:00:00 2001 From: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com> Date: Fri, 25 Oct 2024 15:17:19 +0100 Subject: [PATCH 09/30] CLDC-2639 Display correct back to logs button (#2721) * Display correct back to logs button * Add bulk_upload_filter_applied for sales * Update view tests --- app/controllers/lettings_logs_controller.rb | 2 +- app/controllers/sales_logs_controller.rb | 2 +- app/helpers/log_actions_helper.rb | 8 +++--- app/services/storage/local_disk_service.rb | 4 ++- app/views/logs/edit.html.erb | 2 +- .../requests/lettings_logs_controller_spec.rb | 25 ++++++++++++++++++ spec/views/logs/edit.html.erb_spec.rb | 26 ++++++++++--------- 7 files changed, 49 insertions(+), 20 deletions(-) diff --git a/app/controllers/lettings_logs_controller.rb b/app/controllers/lettings_logs_controller.rb index 0194946d4..cc3c731d5 100644 --- a/app/controllers/lettings_logs_controller.rb +++ b/app/controllers/lettings_logs_controller.rb @@ -65,7 +65,7 @@ class LettingsLogsController < LogsController elsif @log.collection_closed_for_editing? redirect_to review_lettings_log_path(@log) else - render("logs/edit", locals: { current_user: }) + render("logs/edit", locals: { current_user:, bulk_upload_filter_applied: session_filters["bulk_upload_id"].present? }) end end diff --git a/app/controllers/sales_logs_controller.rb b/app/controllers/sales_logs_controller.rb index d1bbe3bc2..af9879896 100644 --- a/app/controllers/sales_logs_controller.rb +++ b/app/controllers/sales_logs_controller.rb @@ -39,7 +39,7 @@ class SalesLogsController < LogsController if @log.collection_closed_for_editing? redirect_to review_sales_log_path(@log, sales_log: true) else - render "logs/edit", locals: { current_user: } + render "logs/edit", locals: { current_user:, bulk_upload_filter_applied: session_filters["bulk_upload_id"].present? } end end diff --git a/app/helpers/log_actions_helper.rb b/app/helpers/log_actions_helper.rb index 8a018445e..3f2737cdd 100644 --- a/app/helpers/log_actions_helper.rb +++ b/app/helpers/log_actions_helper.rb @@ -2,8 +2,8 @@ module LogActionsHelper include GovukLinkHelper include GovukVisuallyHiddenHelper - def edit_actions_for_log(log) - back = back_button_for(log) + def edit_actions_for_log(log, bulk_upload_filter_applied) + back = back_button_for(log, bulk_upload_filter_applied) delete = delete_button_for_log(log) return if back.nil? && delete.nil? @@ -15,9 +15,9 @@ module LogActionsHelper private - def back_button_for(log) + def back_button_for(log, bulk_upload_filter_applied) if log.completed? - if log.creation_method_bulk_upload? && log.bulk_upload.present? + if log.creation_method_bulk_upload? && log.bulk_upload.present? && bulk_upload_filter_applied if log.lettings? govuk_button_link_to "Back to uploaded logs", resume_bulk_upload_lettings_result_path(log.bulk_upload) else diff --git a/app/services/storage/local_disk_service.rb b/app/services/storage/local_disk_service.rb index 228f0339e..8e69e2516 100644 --- a/app/services/storage/local_disk_service.rb +++ b/app/services/storage/local_disk_service.rb @@ -19,7 +19,9 @@ module Storage File.open(path, "r") end - def write_file(filename, data, _content_type: nil) + # rubocop:disable Lint/UnusedMethodArgument + def write_file(filename, data, content_type: nil) + # rubocop:enable Lint/UnusedMethodArgument path = Rails.root.join("tmp/storage", filename) FileUtils.mkdir_p(path.dirname) diff --git a/app/views/logs/edit.html.erb b/app/views/logs/edit.html.erb index 68bf78e87..3859ca6db 100644 --- a/app/views/logs/edit.html.erb +++ b/app/views/logs/edit.html.erb @@ -38,6 +38,6 @@ <%= render "tasklist" %> - <%= edit_actions_for_log(@log) %> + <%= edit_actions_for_log(@log, bulk_upload_filter_applied) %> diff --git a/spec/requests/lettings_logs_controller_spec.rb b/spec/requests/lettings_logs_controller_spec.rb index 79a184336..3443a70ca 100644 --- a/spec/requests/lettings_logs_controller_spec.rb +++ b/spec/requests/lettings_logs_controller_spec.rb @@ -1158,6 +1158,31 @@ RSpec.describe LettingsLogsController, type: :request do expect(page).to have_link("review and make changes to this log", href: "/lettings-logs/#{lettings_log.id}/review") end end + + context "with bulk_upload_id filter" do + let(:bulk_upload) { create(:bulk_upload, :lettings, user:) } + let(:lettings_log) { create(:lettings_log, :completed, age1: nil, bulk_upload:, assigned_to: user, creation_method: "bulk upload") } + + before do + lettings_log.status = "completed" + lettings_log.skip_update_status = true + lettings_log.save!(validate: false) + end + + context "with bulk_upload_id filter in session" do + it "displays back to uploaded logs link" do + get "/lettings-logs/#{lettings_log.id}?bulk_upload_id[]=#{bulk_upload.id}" + expect(page).to have_link("Back to uploaded logs") + end + end + + context "without bulk_upload_id filter in session" do + it "does not display back to uploaded logs link" do + get "/lettings-logs/#{lettings_log.id}" + expect(page).not_to have_link("Back to uploaded logs") + end + end + end end context "with lettings logs from a closed collection period before the previous collection" do diff --git a/spec/views/logs/edit.html.erb_spec.rb b/spec/views/logs/edit.html.erb_spec.rb index 9ecb1e5c8..b2dde0f3d 100644 --- a/spec/views/logs/edit.html.erb_spec.rb +++ b/spec/views/logs/edit.html.erb_spec.rb @@ -1,11 +1,13 @@ require "rails_helper" RSpec.describe "logs/edit.html.erb" do + let(:current_user) { create(:user, :support) } + before do Timecop.freeze(Time.zone.local(2024, 3, 1)) Singleton.__init__(FormHandler) assign(:log, log) - sign_in create(:user, :support) + sign_in current_user end after do @@ -17,7 +19,7 @@ RSpec.describe "logs/edit.html.erb" do let(:log) { create(:lettings_log, :in_progress) } it "there is no link back to log type root" do - render + render template: "logs/edit", locals: { current_user:, bulk_upload_filter_applied: false } fragment = Capybara::Node::Simple.new(rendered) @@ -25,7 +27,7 @@ RSpec.describe "logs/edit.html.erb" do end it "has link 'Delete log'" do - render + render template: "logs/edit", locals: { current_user:, bulk_upload_filter_applied: false } fragment = Capybara::Node::Simple.new(rendered) @@ -38,7 +40,7 @@ RSpec.describe "logs/edit.html.erb" do let(:log) { create(:lettings_log, :completed) } it "has link 'Back to lettings logs'" do - render + render template: "logs/edit", locals: { current_user:, bulk_upload_filter_applied: false } fragment = Capybara::Node::Simple.new(rendered) @@ -46,7 +48,7 @@ RSpec.describe "logs/edit.html.erb" do end it "has link 'Delete log'" do - render + render template: "logs/edit", locals: { current_user:, bulk_upload_filter_applied: false } fragment = Capybara::Node::Simple.new(rendered) @@ -58,7 +60,7 @@ RSpec.describe "logs/edit.html.erb" do let(:log) { create(:sales_log, :completed) } it "has link 'Back to sales logs'" do - render + render template: "logs/edit", locals: { current_user:, bulk_upload_filter_applied: false } fragment = Capybara::Node::Simple.new(rendered) @@ -66,7 +68,7 @@ RSpec.describe "logs/edit.html.erb" do end it "has link 'Delete log'" do - render + render template: "logs/edit", locals: { current_user:, bulk_upload_filter_applied: false } fragment = Capybara::Node::Simple.new(rendered) @@ -79,7 +81,7 @@ RSpec.describe "logs/edit.html.erb" do let(:log) { create(:lettings_log, :completed, bulk_upload:, creation_method: "bulk upload") } it "has link 'Back to uploaded logs'" do - render + render template: "logs/edit", locals: { current_user:, bulk_upload_filter_applied: true } fragment = Capybara::Node::Simple.new(rendered) @@ -87,7 +89,7 @@ RSpec.describe "logs/edit.html.erb" do end it "has link 'Delete log'" do - render + render template: "logs/edit", locals: { current_user:, bulk_upload_filter_applied: true } fragment = Capybara::Node::Simple.new(rendered) @@ -99,7 +101,7 @@ RSpec.describe "logs/edit.html.erb" do let(:log) { create(:lettings_log, :completed, bulk_upload: nil, creation_method: "bulk upload") } it "does not have link 'Back to uploaded logs'" do - render + render template: "logs/edit", locals: { current_user:, bulk_upload_filter_applied: false } fragment = Capybara::Node::Simple.new(rendered) @@ -112,7 +114,7 @@ RSpec.describe "logs/edit.html.erb" do let(:log) { create(:sales_log, :completed, bulk_upload:, creation_method: "bulk upload") } it "has link 'Back to uploaded logs'" do - render + render template: "logs/edit", locals: { current_user:, bulk_upload_filter_applied: true } fragment = Capybara::Node::Simple.new(rendered) @@ -120,7 +122,7 @@ RSpec.describe "logs/edit.html.erb" do end it "has link 'Delete log'" do - render + render template: "logs/edit", locals: { current_user:, bulk_upload_filter_applied: true } fragment = Capybara::Node::Simple.new(rendered) From 469211ce6513276aa8630a4c4dd93ba720741cd8 Mon Sep 17 00:00:00 2001 From: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com> Date: Mon, 28 Oct 2024 10:11:41 +0000 Subject: [PATCH 10/30] CLDC-3661 Update year format (#2713) * Update year combo format * lint * Update tests and validations * update model tests * Update bu list year format * Update test --- .../bulk_upload_summary_component.html.erb | 2 +- app/helpers/filters_helper.rb | 2 +- app/helpers/review_helper.rb | 2 +- app/helpers/tasklist_helper.rb | 2 +- app/models/bulk_upload.rb | 2 +- .../bulk_upload_lettings/checking_file.rb | 2 +- .../forms/bulk_upload_lettings/needstype.rb | 2 +- .../bulk_upload_lettings/prepare_your_file.rb | 2 +- .../bulk_upload_lettings/upload_your_file.rb | 2 +- app/models/forms/bulk_upload_lettings/year.rb | 2 +- .../forms/bulk_upload_sales/checking_file.rb | 2 +- .../bulk_upload_sales/prepare_your_file.rb | 2 +- .../bulk_upload_sales/upload_your_file.rb | 2 +- app/models/forms/bulk_upload_sales/year.rb | 2 +- .../validations/sales/setup_validations.rb | 10 +++---- app/models/validations/setup_validations.rb | 10 +++---- .../forms/prepare_your_file_2023.html.erb | 2 +- .../forms/prepare_your_file_2024.html.erb | 2 +- .../show.html.erb | 2 +- .../summary.html.erb | 2 +- .../chosen.html.erb | 2 +- .../completed.html.erb | 2 +- .../confirm.html.erb | 2 +- .../deletion_report.html.erb | 2 +- .../fix_choice.html.erb | 2 +- .../chosen.html.erb | 2 +- .../confirm.html.erb | 2 +- .../confirm_soft_errors.html.erb | 2 +- .../bulk_upload_sales_results/show.html.erb | 2 +- .../summary.html.erb | 2 +- .../bulk_upload_sales_resume/chosen.html.erb | 2 +- .../completed.html.erb | 2 +- .../bulk_upload_sales_resume/confirm.html.erb | 2 +- .../deletion_report.html.erb | 2 +- .../fix_choice.html.erb | 2 +- .../chosen.html.erb | 2 +- .../confirm.html.erb | 2 +- .../confirm_soft_errors.html.erb | 2 +- config/locales/en.yml | 4 +-- config/locales/validations/sales/setup.en.yml | 4 +-- .../bulk_upload_summary_component_spec.rb | 2 +- .../bulk_upload_lettings_logs_spec.rb | 11 ++++--- spec/features/bulk_upload_sales_logs_spec.rb | 6 ++-- spec/features/sales_log_spec.rb | 2 +- spec/helpers/filters_helper_spec.rb | 12 ++++---- spec/helpers/tasklist_helper_spec.rb | 8 ++--- spec/models/bulk_upload_spec.rb | 4 +-- .../forms/bulk_upload_lettings/year_spec.rb | 6 ++-- .../forms/bulk_upload_sales/year_spec.rb | 6 ++-- .../sales/setup_validations_spec.rb | 16 +++++----- .../validations/setup_validations_spec.rb | 30 +++++++++---------- ...upload_lettings_results_controller_spec.rb | 4 +-- ..._upload_lettings_resume_controller_spec.rb | 8 ++--- ..._soft_validations_check_controller_spec.rb | 2 +- ...lk_upload_sales_results_controller_spec.rb | 2 +- ...ulk_upload_sales_resume_controller_spec.rb | 8 ++--- ..._soft_validations_check_controller_spec.rb | 2 +- .../requests/lettings_logs_controller_spec.rb | 2 +- spec/requests/sales_logs_controller_spec.rb | 2 +- 59 files changed, 116 insertions(+), 117 deletions(-) diff --git a/app/components/bulk_upload_summary_component.html.erb b/app/components/bulk_upload_summary_component.html.erb index abbff4493..a7ac57da3 100644 --- a/app/components/bulk_upload_summary_component.html.erb +++ b/app/components/bulk_upload_summary_component.html.erb @@ -4,7 +4,7 @@

<%= bulk_upload.filename %> - +

diff --git a/app/helpers/filters_helper.rb b/app/helpers/filters_helper.rb index e43614d45..35fea17e9 100644 --- a/app/helpers/filters_helper.rb +++ b/app/helpers/filters_helper.rb @@ -287,7 +287,7 @@ private end def year_combo(year) - "#{year}/#{year - 2000 + 1}" + "#{year} to #{year + 1}" end def formatted_years_filter(session_filters) diff --git a/app/helpers/review_helper.rb b/app/helpers/review_helper.rb index 87fb691eb..bf1d70d64 100644 --- a/app/helpers/review_helper.rb +++ b/app/helpers/review_helper.rb @@ -6,7 +6,7 @@ module ReviewHelper "You can review and make changes to this log until #{log.form.submission_deadline.to_formatted_s(:govuk_date)}.".html_safe else start_year = log.startdate ? collection_start_year_for_date(log.startdate) : log.form.start_date.year - "This log is from the #{start_year}/#{start_year + 1} collection window, which is now closed." + "This log is from the #{start_year} to #{start_year + 1} collection window, which is now closed." end end diff --git a/app/helpers/tasklist_helper.rb b/app/helpers/tasklist_helper.rb index bdc71b4ab..2caef019a 100644 --- a/app/helpers/tasklist_helper.rb +++ b/app/helpers/tasklist_helper.rb @@ -55,7 +55,7 @@ module TasklistHelper else start_year = log.startdate ? collection_start_year_for_date(log.startdate) : log.form.start_date.year - "This log is from the #{start_year}/#{start_year + 1} collection window, which is now closed." + "This log is from the #{start_year} to #{start_year + 1} collection window, which is now closed." end end diff --git a/app/models/bulk_upload.rb b/app/models/bulk_upload.rb index ad76c2192..93f661225 100644 --- a/app/models/bulk_upload.rb +++ b/app/models/bulk_upload.rb @@ -59,7 +59,7 @@ class BulkUpload < ApplicationRecord end def year_combo - "#{year}/#{year - 2000 + 1}" + "#{year} to #{year + 1}" end def end_year diff --git a/app/models/forms/bulk_upload_lettings/checking_file.rb b/app/models/forms/bulk_upload_lettings/checking_file.rb index 3b43cb269..2ce12df46 100644 --- a/app/models/forms/bulk_upload_lettings/checking_file.rb +++ b/app/models/forms/bulk_upload_lettings/checking_file.rb @@ -21,7 +21,7 @@ module Forms end def year_combo - "#{year}/#{year + 1 - 2000}" + "#{year} to #{year + 1}" end def save! diff --git a/app/models/forms/bulk_upload_lettings/needstype.rb b/app/models/forms/bulk_upload_lettings/needstype.rb index 32ed0acf3..b15c05b52 100644 --- a/app/models/forms/bulk_upload_lettings/needstype.rb +++ b/app/models/forms/bulk_upload_lettings/needstype.rb @@ -28,7 +28,7 @@ module Forms end def year_combo - "#{year}/#{year + 1 - 2000}" + "#{year} to #{year + 1}" end def save! diff --git a/app/models/forms/bulk_upload_lettings/prepare_your_file.rb b/app/models/forms/bulk_upload_lettings/prepare_your_file.rb index b66c1649f..d0a577ee1 100644 --- a/app/models/forms/bulk_upload_lettings/prepare_your_file.rb +++ b/app/models/forms/bulk_upload_lettings/prepare_your_file.rb @@ -41,7 +41,7 @@ module Forms end def year_combo - "#{year}/#{year + 1 - 2000}" + "#{year} to #{year + 1}" end def save! diff --git a/app/models/forms/bulk_upload_lettings/upload_your_file.rb b/app/models/forms/bulk_upload_lettings/upload_your_file.rb index 954c6e6e6..82b5c75d5 100644 --- a/app/models/forms/bulk_upload_lettings/upload_your_file.rb +++ b/app/models/forms/bulk_upload_lettings/upload_your_file.rb @@ -25,7 +25,7 @@ module Forms end def year_combo - "#{year}/#{year + 1 - 2000}" + "#{year} to #{year + 1}" end def next_path diff --git a/app/models/forms/bulk_upload_lettings/year.rb b/app/models/forms/bulk_upload_lettings/year.rb index 396b91a79..ca2e9c144 100644 --- a/app/models/forms/bulk_upload_lettings/year.rb +++ b/app/models/forms/bulk_upload_lettings/year.rb @@ -16,7 +16,7 @@ module Forms def options possible_years.map do |year| - OpenStruct.new(id: year, name: "#{year}/#{year + 1}") + OpenStruct.new(id: year, name: "#{year} to #{year + 1}") end end diff --git a/app/models/forms/bulk_upload_sales/checking_file.rb b/app/models/forms/bulk_upload_sales/checking_file.rb index 243d64070..4e512b29b 100644 --- a/app/models/forms/bulk_upload_sales/checking_file.rb +++ b/app/models/forms/bulk_upload_sales/checking_file.rb @@ -21,7 +21,7 @@ module Forms end def year_combo - "#{year}/#{year + 1 - 2000}" + "#{year} to #{year + 1}" end def save! diff --git a/app/models/forms/bulk_upload_sales/prepare_your_file.rb b/app/models/forms/bulk_upload_sales/prepare_your_file.rb index 6bac024cc..aaca752a2 100644 --- a/app/models/forms/bulk_upload_sales/prepare_your_file.rb +++ b/app/models/forms/bulk_upload_sales/prepare_your_file.rb @@ -40,7 +40,7 @@ module Forms end def year_combo - "#{year}/#{year + 1 - 2000}" + "#{year} to #{year + 1}" end def save! diff --git a/app/models/forms/bulk_upload_sales/upload_your_file.rb b/app/models/forms/bulk_upload_sales/upload_your_file.rb index 5a0114caf..83ce04e10 100644 --- a/app/models/forms/bulk_upload_sales/upload_your_file.rb +++ b/app/models/forms/bulk_upload_sales/upload_your_file.rb @@ -24,7 +24,7 @@ module Forms end def year_combo - "#{year}/#{year + 1 - 2000}" + "#{year} to #{year + 1}" end def next_path diff --git a/app/models/forms/bulk_upload_sales/year.rb b/app/models/forms/bulk_upload_sales/year.rb index 1de8dec04..ecf74c636 100644 --- a/app/models/forms/bulk_upload_sales/year.rb +++ b/app/models/forms/bulk_upload_sales/year.rb @@ -16,7 +16,7 @@ module Forms def options possible_years.map do |year| - OpenStruct.new(id: year, name: "#{year}/#{year + 1}") + OpenStruct.new(id: year, name: "#{year} to #{year + 1}") end end diff --git a/app/models/validations/sales/setup_validations.rb b/app/models/validations/sales/setup_validations.rb index a28777a17..6fdc2f1a3 100644 --- a/app/models/validations/sales/setup_validations.rb +++ b/app/models/validations/sales/setup_validations.rb @@ -80,18 +80,18 @@ private if FormHandler.instance.sales_in_crossover_period? I18n.t( "validations.sales.setup.saledate.must_be_within.previous_and_current_collection_year", - previous_start_year_short: previous_collection_start_date.strftime("%y"), - previous_end_year_short: previous_collection_end_date.strftime("%y"), + previous_start_year_short: previous_collection_start_date.strftime("%Y"), + previous_end_year_short: previous_collection_end_date.strftime("%Y"), previous_start_year_long: previous_collection_start_date.strftime("#{previous_collection_start_date.day.ordinalize} %B %Y"), - current_end_year_short: current_collection_end_date.strftime("%y"), + current_end_year_short: current_collection_end_date.strftime("%Y"), current_end_year_long: current_collection_end_date.strftime("#{current_collection_end_date.day.ordinalize} %B %Y"), ) else I18n.t( "validations.sales.setup.saledate.must_be_within.current_collection_year", - current_start_year_short: current_collection_start_date.strftime("%y"), + current_start_year_short: current_collection_start_date.strftime("%Y"), current_start_year_long: current_collection_start_date.strftime("#{current_collection_start_date.day.ordinalize} %B %Y"), - current_end_year_short: current_collection_end_date.strftime("%y"), + current_end_year_short: current_collection_end_date.strftime("%Y"), current_end_year_long: current_collection_end_date.strftime("#{current_collection_end_date.day.ordinalize} %B %Y"), ) end diff --git a/app/models/validations/setup_validations.rb b/app/models/validations/setup_validations.rb index 528126ab7..913cc9c96 100644 --- a/app/models/validations/setup_validations.rb +++ b/app/models/validations/setup_validations.rb @@ -130,17 +130,17 @@ private if FormHandler.instance.lettings_in_crossover_period? I18n.t( "validations.setup.startdate.previous_and_current_collection_year", - previous_start_year_short: previous_collection_start_date.strftime("%y"), - previous_end_year_short: previous_collection_end_date.strftime("%y"), + previous_start_year_short: previous_collection_start_date.strftime("%Y"), + previous_end_year_short: previous_collection_end_date.strftime("%Y"), previous_start_year_long: previous_collection_start_date.strftime("#{previous_collection_start_date.day.ordinalize} %B %Y"), - current_end_year_short: current_collection_end_date.strftime("%y"), + current_end_year_short: current_collection_end_date.strftime("%Y"), current_end_year_long:, ) else I18n.t( "validations.setup.startdate.current_collection_year", - current_start_year_short: current_collection_start_date.strftime("%y"), - current_end_year_short: current_collection_end_date.strftime("%y"), + current_start_year_short: current_collection_start_date.strftime("%Y"), + current_end_year_short: current_collection_end_date.strftime("%Y"), current_start_year_long: current_collection_start_date.strftime("#{current_collection_start_date.day.ordinalize} %B %Y"), current_end_year_long:, ) 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 index a07092278..f8549807b 100644 --- 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 @@ -31,7 +31,7 @@
  • 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.
  • - <%= govuk_inset_text(text: "You can upload both general needs and supported housing logs in the same file for 2023/24 data.") %> + <%= govuk_inset_text(text: "You can upload both general needs and supported housing logs in the same file for 2023 to 2024 data.") %>

    Save your file

    diff --git a/app/views/bulk_upload_lettings_logs/forms/prepare_your_file_2024.html.erb b/app/views/bulk_upload_lettings_logs/forms/prepare_your_file_2024.html.erb index 7657396f1..0e91061c3 100644 --- a/app/views/bulk_upload_lettings_logs/forms/prepare_your_file_2024.html.erb +++ b/app/views/bulk_upload_lettings_logs/forms/prepare_your_file_2024.html.erb @@ -27,7 +27,7 @@
  • If you have reordered the headers, keep the headers in the file.
  • - <%= govuk_inset_text(text: "You can upload both general needs and supported housing logs in the same file for 2024/25 data.") %> + <%= govuk_inset_text(text: "You can upload both general needs and supported housing logs in the same file for 2024 to 2025 data.") %>

    Save your file

    diff --git a/app/views/bulk_upload_lettings_results/show.html.erb b/app/views/bulk_upload_lettings_results/show.html.erb index fd49c8f3e..b1f9eb6f6 100644 --- a/app/views/bulk_upload_lettings_results/show.html.erb +++ b/app/views/bulk_upload_lettings_results/show.html.erb @@ -6,7 +6,7 @@
    - Bulk upload for lettings (<%= @bulk_upload.year_combo %>) + Upload lettings logs in bulk (<%= @bulk_upload.year_combo %>)

    We found <%= pluralize(@bulk_upload.bulk_upload_errors.count, "error") %> in your file

    diff --git a/app/views/bulk_upload_lettings_results/summary.html.erb b/app/views/bulk_upload_lettings_results/summary.html.erb index 2e4fa91fc..2f565ed59 100644 --- a/app/views/bulk_upload_lettings_results/summary.html.erb +++ b/app/views/bulk_upload_lettings_results/summary.html.erb @@ -2,7 +2,7 @@
    - Bulk upload for lettings (<%= @bulk_upload.year_combo %>) + Upload lettings logs in bulk (<%= @bulk_upload.year_combo %>)

    Fix <%= pluralize(@bulk_upload.bulk_upload_errors.count, "error") %> and upload file again

    diff --git a/app/views/bulk_upload_lettings_resume/chosen.html.erb b/app/views/bulk_upload_lettings_resume/chosen.html.erb index 47ed9bbfd..a50af7524 100644 --- a/app/views/bulk_upload_lettings_resume/chosen.html.erb +++ b/app/views/bulk_upload_lettings_resume/chosen.html.erb @@ -4,7 +4,7 @@

    - Bulk upload for lettings (<%= @bulk_upload.year_combo %>) + Upload lettings logs in bulk (<%= @bulk_upload.year_combo %>)

    You need to fix logs from your bulk upload

    You have chosen to create logs from your recent bulk upload. To view and complete these logs, return to the list of lettings logs.

    diff --git a/app/views/bulk_upload_lettings_resume/completed.html.erb b/app/views/bulk_upload_lettings_resume/completed.html.erb index 0487d1921..59f58b710 100644 --- a/app/views/bulk_upload_lettings_resume/completed.html.erb +++ b/app/views/bulk_upload_lettings_resume/completed.html.erb @@ -4,7 +4,7 @@
    - Bulk upload for lettings (<%= @bulk_upload.year_combo %>) + Upload lettings logs in bulk (<%= @bulk_upload.year_combo %>)

    These logs are complete

    You have created logs from your bulk upload, and the logs are complete. Return to lettings logs to view them.

    diff --git a/app/views/bulk_upload_lettings_resume/confirm.html.erb b/app/views/bulk_upload_lettings_resume/confirm.html.erb index 368f16f60..bb15c7101 100644 --- a/app/views/bulk_upload_lettings_resume/confirm.html.erb +++ b/app/views/bulk_upload_lettings_resume/confirm.html.erb @@ -4,7 +4,7 @@
    - Bulk upload for lettings (<%= @bulk_upload.year_combo %>) + Upload lettings logs in bulk (<%= @bulk_upload.year_combo %>)

    Are you sure you want to upload all logs from this bulk upload?

    diff --git a/app/views/bulk_upload_lettings_resume/deletion_report.html.erb b/app/views/bulk_upload_lettings_resume/deletion_report.html.erb index 881f9026c..a13979dfd 100644 --- a/app/views/bulk_upload_lettings_resume/deletion_report.html.erb +++ b/app/views/bulk_upload_lettings_resume/deletion_report.html.erb @@ -4,7 +4,7 @@

    - Bulk upload for lettings (<%= @bulk_upload.year_combo %>) + Upload lettings logs in bulk (<%= @bulk_upload.year_combo %>)

    <%= answers_to_be_deleted_title_text(@bulk_upload) %>

    The following cells contain data this is incorrect.

    diff --git a/app/views/bulk_upload_lettings_resume/fix_choice.html.erb b/app/views/bulk_upload_lettings_resume/fix_choice.html.erb index 87aff25ae..383cdbfa1 100644 --- a/app/views/bulk_upload_lettings_resume/fix_choice.html.erb +++ b/app/views/bulk_upload_lettings_resume/fix_choice.html.erb @@ -3,7 +3,7 @@ <%= form_with model: @form, scope: :form, url: page_bulk_upload_lettings_resume_path(@bulk_upload, page: "fix-choice"), method: :patch do |f| %> <%= f.govuk_error_summary %> - Bulk upload for lettings (<%= @bulk_upload.year_combo %>) + Upload lettings logs in bulk (<%= @bulk_upload.year_combo %>)

    How would you like to fix the errors?

    diff --git a/app/views/bulk_upload_lettings_soft_validations_check/chosen.html.erb b/app/views/bulk_upload_lettings_soft_validations_check/chosen.html.erb index 0487d1921..59f58b710 100644 --- a/app/views/bulk_upload_lettings_soft_validations_check/chosen.html.erb +++ b/app/views/bulk_upload_lettings_soft_validations_check/chosen.html.erb @@ -4,7 +4,7 @@
    - Bulk upload for lettings (<%= @bulk_upload.year_combo %>) + Upload lettings logs in bulk (<%= @bulk_upload.year_combo %>)

    These logs are complete

    You have created logs from your bulk upload, and the logs are complete. Return to lettings logs to view them.

    diff --git a/app/views/bulk_upload_lettings_soft_validations_check/confirm.html.erb b/app/views/bulk_upload_lettings_soft_validations_check/confirm.html.erb index fcb039eac..90f5a00b3 100644 --- a/app/views/bulk_upload_lettings_soft_validations_check/confirm.html.erb +++ b/app/views/bulk_upload_lettings_soft_validations_check/confirm.html.erb @@ -4,7 +4,7 @@
    - Bulk upload for lettings (<%= @bulk_upload.year_combo %>) + Upload lettings logs in bulk (<%= @bulk_upload.year_combo %>)

    You have chosen to upload all logs from this bulk upload.

    <%= logs_and_soft_validations_warning(@bulk_upload) %>

    diff --git a/app/views/bulk_upload_lettings_soft_validations_check/confirm_soft_errors.html.erb b/app/views/bulk_upload_lettings_soft_validations_check/confirm_soft_errors.html.erb index 087557b3f..8a2a9d371 100644 --- a/app/views/bulk_upload_lettings_soft_validations_check/confirm_soft_errors.html.erb +++ b/app/views/bulk_upload_lettings_soft_validations_check/confirm_soft_errors.html.erb @@ -3,7 +3,7 @@
    <%= f.govuk_error_summary %> - Bulk upload for lettings (<%= @bulk_upload.year_combo %>) + Upload lettings logs in bulk (<%= @bulk_upload.year_combo %>)

    Check these <%= pluralize(@bulk_upload.bulk_upload_errors.count, "answer") %>

    Some data from your bulk upload might not be right. Check your file for any errors in the fields below.

    diff --git a/app/views/bulk_upload_sales_results/show.html.erb b/app/views/bulk_upload_sales_results/show.html.erb index 6d0863617..24b09ce6a 100644 --- a/app/views/bulk_upload_sales_results/show.html.erb +++ b/app/views/bulk_upload_sales_results/show.html.erb @@ -6,7 +6,7 @@
    - Bulk Upload for sales (<%= @bulk_upload.year_combo %>) + Upload sales logs in bulk (<%= @bulk_upload.year_combo %>)

    We found <%= pluralize(@bulk_upload.bulk_upload_errors.count, "error") %> in your file

    diff --git a/app/views/bulk_upload_sales_results/summary.html.erb b/app/views/bulk_upload_sales_results/summary.html.erb index 171cbf77f..2ae2a915b 100644 --- a/app/views/bulk_upload_sales_results/summary.html.erb +++ b/app/views/bulk_upload_sales_results/summary.html.erb @@ -2,7 +2,7 @@
    - Bulk upload for sales (<%= @bulk_upload.year_combo %>) + Upload sales logs in bulk (<%= @bulk_upload.year_combo %>)

    Fix <%= pluralize(@bulk_upload.bulk_upload_errors.count, "error") %> and upload file again

    diff --git a/app/views/bulk_upload_sales_resume/chosen.html.erb b/app/views/bulk_upload_sales_resume/chosen.html.erb index 0d381e6a6..1f88a76b5 100644 --- a/app/views/bulk_upload_sales_resume/chosen.html.erb +++ b/app/views/bulk_upload_sales_resume/chosen.html.erb @@ -4,7 +4,7 @@

    - Bulk upload for sales (<%= @bulk_upload.year_combo %>) + Upload sales logs in bulk (<%= @bulk_upload.year_combo %>)

    You need to fix logs from your bulk upload

    You have chosen to create logs from your recent bulk upload. To view and complete these logs, return to the list of sales logs.

    diff --git a/app/views/bulk_upload_sales_resume/completed.html.erb b/app/views/bulk_upload_sales_resume/completed.html.erb index 9fcc656ad..737f56385 100644 --- a/app/views/bulk_upload_sales_resume/completed.html.erb +++ b/app/views/bulk_upload_sales_resume/completed.html.erb @@ -4,7 +4,7 @@
    - Bulk upload for sales (<%= @bulk_upload.year_combo %>) + Upload sales logs in bulk (<%= @bulk_upload.year_combo %>)

    These logs are complete

    You have created logs from your bulk upload, and the logs are complete. Return to sales logs to view them.

    diff --git a/app/views/bulk_upload_sales_resume/confirm.html.erb b/app/views/bulk_upload_sales_resume/confirm.html.erb index 3d02e025a..b47619053 100644 --- a/app/views/bulk_upload_sales_resume/confirm.html.erb +++ b/app/views/bulk_upload_sales_resume/confirm.html.erb @@ -4,7 +4,7 @@
    - Bulk upload for sales (<%= @bulk_upload.year_combo %>) + Upload sales logs in bulk (<%= @bulk_upload.year_combo %>)

    Are you sure you want to upload all logs from this bulk upload?

    diff --git a/app/views/bulk_upload_sales_resume/deletion_report.html.erb b/app/views/bulk_upload_sales_resume/deletion_report.html.erb index 299cff4f4..bcc044439 100644 --- a/app/views/bulk_upload_sales_resume/deletion_report.html.erb +++ b/app/views/bulk_upload_sales_resume/deletion_report.html.erb @@ -4,7 +4,7 @@

    - Bulk upload for sales (<%= @bulk_upload.year_combo %>) + Upload sales logs in bulk (<%= @bulk_upload.year_combo %>)

    <%= answers_to_be_deleted_title_text(@bulk_upload) %>

    The following cells contain data this is incorrect.

    diff --git a/app/views/bulk_upload_sales_resume/fix_choice.html.erb b/app/views/bulk_upload_sales_resume/fix_choice.html.erb index 5fcc1d5ea..946426d0c 100644 --- a/app/views/bulk_upload_sales_resume/fix_choice.html.erb +++ b/app/views/bulk_upload_sales_resume/fix_choice.html.erb @@ -3,7 +3,7 @@ <%= form_with model: @form, scope: :form, url: page_bulk_upload_sales_resume_path(@bulk_upload, page: "fix-choice"), method: :patch do |f| %> <%= f.govuk_error_summary %> - Bulk upload for sales (<%= @bulk_upload.year_combo %>) + Upload sales logs in bulk (<%= @bulk_upload.year_combo %>)

    How would you like to fix the errors?

    diff --git a/app/views/bulk_upload_sales_soft_validations_check/chosen.html.erb b/app/views/bulk_upload_sales_soft_validations_check/chosen.html.erb index 9fcc656ad..737f56385 100644 --- a/app/views/bulk_upload_sales_soft_validations_check/chosen.html.erb +++ b/app/views/bulk_upload_sales_soft_validations_check/chosen.html.erb @@ -4,7 +4,7 @@
    - Bulk upload for sales (<%= @bulk_upload.year_combo %>) + Upload sales logs in bulk (<%= @bulk_upload.year_combo %>)

    These logs are complete

    You have created logs from your bulk upload, and the logs are complete. Return to sales logs to view them.

    diff --git a/app/views/bulk_upload_sales_soft_validations_check/confirm.html.erb b/app/views/bulk_upload_sales_soft_validations_check/confirm.html.erb index ca9f7fd4f..2b4a6e981 100644 --- a/app/views/bulk_upload_sales_soft_validations_check/confirm.html.erb +++ b/app/views/bulk_upload_sales_soft_validations_check/confirm.html.erb @@ -4,7 +4,7 @@
    - Bulk upload for sales (<%= @bulk_upload.year_combo %>) + Upload sales logs in bulk (<%= @bulk_upload.year_combo %>)

    You have chosen to upload all logs from this bulk upload.

    <%= logs_and_soft_validations_warning(@bulk_upload) %>

    diff --git a/app/views/bulk_upload_sales_soft_validations_check/confirm_soft_errors.html.erb b/app/views/bulk_upload_sales_soft_validations_check/confirm_soft_errors.html.erb index 4a2765ab4..0bf5553b3 100644 --- a/app/views/bulk_upload_sales_soft_validations_check/confirm_soft_errors.html.erb +++ b/app/views/bulk_upload_sales_soft_validations_check/confirm_soft_errors.html.erb @@ -3,7 +3,7 @@
    <%= f.govuk_error_summary %> - Bulk upload for sales (<%= @bulk_upload.year_combo %>) + Upload sales logs in bulk (<%= @bulk_upload.year_combo %>)

    Check these <%= pluralize(@bulk_upload.bulk_upload_errors.count, "answer") %>

    Some data from your bulk upload might not be right. Check your file for any errors in the fields below.

    diff --git a/config/locales/en.yml b/config/locales/en.yml index 53154eab2..afa157034 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -290,9 +290,9 @@ en: startdate: current_collection_year: - "Enter a date within the %{current_start_year_short}/%{current_end_year_short} collection year, which is between %{current_start_year_long} and %{current_end_year_long}." + "Enter a date within the %{current_start_year_short} to %{current_end_year_short} collection year, which is between %{current_start_year_long} and %{current_end_year_long}." previous_and_current_collection_year: - "Enter a date within the %{previous_start_year_short}/%{previous_end_year_short} or %{previous_end_year_short}/%{current_end_year_short} collection years, which is between %{previous_start_year_long} and %{current_end_year_long}." + "Enter a date within the %{previous_start_year_short} to %{previous_end_year_short} or %{previous_end_year_short} to %{current_end_year_short} collection years, which is between %{previous_start_year_long} and %{current_end_year_long}." later_than_14_days_after: "The tenancy start date must not be later than 14 days from today’s date." before_scheme_end_date: "The tenancy start date must be before the end date for this supported housing scheme." after_void_date: "Enter a tenancy start date that is after the void date." diff --git a/config/locales/validations/sales/setup.en.yml b/config/locales/validations/sales/setup.en.yml index 2741464b0..9dd13b525 100644 --- a/config/locales/validations/sales/setup.en.yml +++ b/config/locales/validations/sales/setup.en.yml @@ -7,9 +7,9 @@ en: next_two_weeks: "Sale completion date must not be later than 14 days from today’s date." must_be_within: current_collection_year: - "Enter a date within the %{current_start_year_short}/%{current_end_year_short} collection year, which is between %{current_start_year_long} and %{current_end_year_long}." + "Enter a date within the %{current_start_year_short} to %{current_end_year_short} collection year, which is between %{current_start_year_long} and %{current_end_year_long}." previous_and_current_collection_year: - "Enter a date within the %{previous_start_year_short}/%{previous_end_year_short} or %{previous_end_year_short}/%{current_end_year_short} collection years, which is between %{previous_start_year_long} and %{current_end_year_long}." + "Enter a date within the %{previous_start_year_short} to %{previous_end_year_short} or %{previous_end_year_short} to %{current_end_year_short} collection years, which is between %{previous_start_year_long} and %{current_end_year_long}." invalid: merged_organisations: "Enter a date when the owning organisation was active. %{owning_organisation} became inactive on %{merge_date} and was replaced by %{absorbing_organisation}." diff --git a/spec/components/bulk_upload_summary_component_spec.rb b/spec/components/bulk_upload_summary_component_spec.rb index 9c0c68731..544befcb3 100644 --- a/spec/components/bulk_upload_summary_component_spec.rb +++ b/spec/components/bulk_upload_summary_component_spec.rb @@ -12,7 +12,7 @@ RSpec.describe BulkUploadSummaryComponent, type: :component do it "shows the collection year" do result = render_inline(described_class.new(bulk_upload:)) - expect(result).to have_content("2024/2025") + expect(result).to have_content("2024 to 2025") end it "includes a download file link" do diff --git a/spec/features/bulk_upload_lettings_logs_spec.rb b/spec/features/bulk_upload_lettings_logs_spec.rb index 5d48d9ee0..315e1461e 100644 --- a/spec/features/bulk_upload_lettings_logs_spec.rb +++ b/spec/features/bulk_upload_lettings_logs_spec.rb @@ -5,8 +5,7 @@ RSpec.describe "Bulk upload lettings log" do let(:user) { create(:user) } let(:current_year) { current_collection_start_year } - let(:current_formatted_year) { "#{current_year}/#{current_year + 1}" } - let(:current_formatted_short_year) { "#{current_year}/#{current_year - 2000 + 1}" } + let(:current_formatted_year) { "#{current_year} to #{current_year + 1}" } let(:stub_file_upload) do vcap_services = { "aws-s3-bucket" => {} } @@ -47,12 +46,12 @@ RSpec.describe "Bulk upload lettings log" do expect(page.find_field("form-year-#{current_year}-field")).to be_checked click_button("Continue") - expect(page).to have_content("Upload lettings logs in bulk (#{current_formatted_short_year})") + expect(page).to have_content("Upload lettings logs in bulk (#{current_formatted_year})") click_button("Continue") expect(page).not_to have_content("What is the needs type?") - expect(page).to have_content("Upload lettings logs in bulk (#{current_formatted_short_year})") + expect(page).to have_content("Upload lettings logs in bulk (#{current_formatted_year})") expect(page).to have_content("Upload your file") click_button("Upload") @@ -88,7 +87,7 @@ RSpec.describe "Bulk upload lettings log" do expect(page).to have_link("Upload lettings logs in bulk") click_link("Upload lettings logs in bulk") - expect(page).to have_content("Upload lettings logs in bulk (#{current_formatted_short_year})") + expect(page).to have_content("Upload lettings logs in bulk (#{current_formatted_year})") click_button("Continue") expect(page).to have_content("Upload your file") @@ -107,7 +106,7 @@ RSpec.describe "Bulk upload lettings log" do expect(page).to have_content("Prepare your file") click_button("Continue") - expect(page).to have_content("Upload lettings logs in bulk (#{current_formatted_short_year})") + expect(page).to have_content("Upload lettings logs in bulk (#{current_formatted_year})") expect(page).to have_content("Upload your file") click_button("Upload") diff --git a/spec/features/bulk_upload_sales_logs_spec.rb b/spec/features/bulk_upload_sales_logs_spec.rb index e47273cdc..b7098999d 100644 --- a/spec/features/bulk_upload_sales_logs_spec.rb +++ b/spec/features/bulk_upload_sales_logs_spec.rb @@ -38,7 +38,7 @@ 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/2024") + choose("2023 to 2024") click_button("Continue") click_link("Back") @@ -46,7 +46,7 @@ RSpec.describe "Bulk upload sales log" do expect(page.find_field("form-year-2023-field")).to be_checked click_button("Continue") - expect(page).to have_content("Upload sales logs in bulk (2023/24)") + expect(page).to have_content("Upload sales logs in bulk (2023 to 2024)") click_button("Continue") expect(page).to have_content("Upload your file") @@ -88,7 +88,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/24)") + expect(page).to have_content("Upload sales logs in bulk (2023 to 2024)") click_button("Continue") expect(page).to have_content("Upload your file") diff --git a/spec/features/sales_log_spec.rb b/spec/features/sales_log_spec.rb index 8e4ffba42..ceff00f94 100644 --- a/spec/features/sales_log_spec.rb +++ b/spec/features/sales_log_spec.rb @@ -191,7 +191,7 @@ RSpec.describe "Sales Log Features" do context "when one year filter is selected" do before do - check("2024") + check("2024 to 2025") click_button("Apply filters") end diff --git a/spec/helpers/filters_helper_spec.rb b/spec/helpers/filters_helper_spec.rb index 58c82f0c9..b709a16ac 100644 --- a/spec/helpers/filters_helper_spec.rb +++ b/spec/helpers/filters_helper_spec.rb @@ -491,7 +491,7 @@ RSpec.describe FiltersHelper do it "has the correct options" do expect(collection_year_options).to eq( { - "2023" => "2023/24", "2022" => "2022/23", "2021" => "2021/22" + "2023" => "2023 to 2024", "2022" => "2022 to 2023", "2021" => "2021 to 2022" }, ) end @@ -505,7 +505,7 @@ RSpec.describe FiltersHelper do it "has the correct options" do expect(collection_year_options).to eq( { - "2023" => "2023/24", "2022" => "2022/23" + "2023" => "2023 to 2024", "2022" => "2022 to 2023" }, ) end @@ -520,7 +520,7 @@ RSpec.describe FiltersHelper do it "has the correct options" do expect(collection_year_options).to eq( { - "2024" => "2024/25", "2023" => "2023/24", "2022" => "2022/23" + "2024" => "2024 to 2025", "2023" => "2023 to 2024", "2022" => "2022 to 2023" }, ) end @@ -541,7 +541,7 @@ RSpec.describe FiltersHelper do it "has the correct options" do expect(collection_year_radio_options).to eq( { - "2023" => { label: "2023/24" }, "2022" => { label: "2022/23" }, "2021" => { label: "2021/22" } + "2023" => { label: "2023 to 2024" }, "2022" => { label: "2022 to 2023" }, "2021" => { label: "2021 to 2022" } }, ) end @@ -555,7 +555,7 @@ RSpec.describe FiltersHelper do it "has the correct options" do expect(collection_year_radio_options).to eq( { - "2023" => { label: "2023/24" }, "2022" => { label: "2022/23" } + "2023" => { label: "2023 to 2024" }, "2022" => { label: "2022 to 2023" } }, ) end @@ -570,7 +570,7 @@ RSpec.describe FiltersHelper do it "has the correct options" do expect(collection_year_radio_options).to eq( { - "2024" => { label: "2024/25" }, "2023" => { label: "2023/24" }, "2022" => { label: "2022/23" } + "2024" => { label: "2024 to 2025" }, "2023" => { label: "2023 to 2024" }, "2022" => { label: "2022 to 2023" } }, ) end diff --git a/spec/helpers/tasklist_helper_spec.rb b/spec/helpers/tasklist_helper_spec.rb index 5d3bd4f91..c5e1bd784 100644 --- a/spec/helpers/tasklist_helper_spec.rb +++ b/spec/helpers/tasklist_helper_spec.rb @@ -143,7 +143,7 @@ RSpec.describe TasklistHelper do end it "returns relevant text" do - expect(review_log_text(sales_log)).to eq("This log is from the 2022/2023 collection window, which is now closed.") + expect(review_log_text(sales_log)).to eq("This log is from the 2022 to 2023 collection window, which is now closed.") end end @@ -156,7 +156,7 @@ RSpec.describe TasklistHelper do end it "returns relevant text" do - expect(review_log_text(sales_log)).to eq("This log is from the 2021/2022 collection window, which is now closed.") + expect(review_log_text(sales_log)).to eq("This log is from the 2021 to 2022 collection window, which is now closed.") end end end @@ -186,7 +186,7 @@ RSpec.describe TasklistHelper do end it "returns relevant text" do - expect(review_log_text(lettings_log)).to eq("This log is from the 2022/2023 collection window, which is now closed.") + expect(review_log_text(lettings_log)).to eq("This log is from the 2022 to 2023 collection window, which is now closed.") end end @@ -199,7 +199,7 @@ RSpec.describe TasklistHelper do end it "returns relevant text" do - expect(review_log_text(lettings_log)).to eq("This log is from the 2021/2022 collection window, which is now closed.") + expect(review_log_text(lettings_log)).to eq("This log is from the 2021 to 2022 collection window, which is now closed.") end end end diff --git a/spec/models/bulk_upload_spec.rb b/spec/models/bulk_upload_spec.rb index af2547d7a..db475709a 100644 --- a/spec/models/bulk_upload_spec.rb +++ b/spec/models/bulk_upload_spec.rb @@ -39,8 +39,8 @@ RSpec.describe BulkUpload, type: :model do describe "year_combo" do [ - { year: 2023, expected_value: "2023/24" }, - { year: 2024, expected_value: "2024/25" }, + { year: 2023, expected_value: "2023 to 2024" }, + { year: 2024, expected_value: "2024 to 2025" }, ].each do |test_case| context "when the bulk upload year is #{test_case[:year]}" do let(:bulk_upload) { build(:bulk_upload, year: test_case[:year]) } diff --git a/spec/models/forms/bulk_upload_lettings/year_spec.rb b/spec/models/forms/bulk_upload_lettings/year_spec.rb index 70d6af4bf..c4429b98b 100644 --- a/spec/models/forms/bulk_upload_lettings/year_spec.rb +++ b/spec/models/forms/bulk_upload_lettings/year_spec.rb @@ -17,7 +17,7 @@ RSpec.describe Forms::BulkUploadLettings::Year do it "returns current and previous years" do expect(form.options.map(&:id)).to eql([2024, 2023]) - expect(form.options.map(&:name)).to eql(%w[2024/2025 2023/2024]) + expect(form.options.map(&:name)).to eql(["2024 to 2025", "2023 to 2024"]) end end @@ -28,7 +28,7 @@ RSpec.describe Forms::BulkUploadLettings::Year do it "returns the current year" do expect(form.options.map(&:id)).to eql([2024]) - expect(form.options.map(&:name)).to eql(%w[2024/2025]) + expect(form.options.map(&:name)).to eql(["2024 to 2025"]) end end @@ -40,7 +40,7 @@ RSpec.describe Forms::BulkUploadLettings::Year do it "returns current and next years" do expect(form.options.map(&:id)).to eql([2024, 2025]) - expect(form.options.map(&:name)).to eql(%w[2024/2025 2025/2026]) + expect(form.options.map(&:name)).to eql(["2024 to 2025", "2025 to 2026"]) end end end diff --git a/spec/models/forms/bulk_upload_sales/year_spec.rb b/spec/models/forms/bulk_upload_sales/year_spec.rb index 2cfa8babc..b1b22bb8d 100644 --- a/spec/models/forms/bulk_upload_sales/year_spec.rb +++ b/spec/models/forms/bulk_upload_sales/year_spec.rb @@ -17,7 +17,7 @@ RSpec.describe Forms::BulkUploadSales::Year do it "returns current and previous years" do expect(form.options.map(&:id)).to eql([2024, 2023]) - expect(form.options.map(&:name)).to eql(%w[2024/2025 2023/2024]) + expect(form.options.map(&:name)).to eql(["2024 to 2025", "2023 to 2024"]) end end @@ -28,7 +28,7 @@ RSpec.describe Forms::BulkUploadSales::Year do it "returns the current year" do expect(form.options.map(&:id)).to eql([2024]) - expect(form.options.map(&:name)).to eql(%w[2024/2025]) + expect(form.options.map(&:name)).to eql(["2024 to 2025"]) end end @@ -44,7 +44,7 @@ RSpec.describe Forms::BulkUploadSales::Year do it "returns current and next years" do expect(form.options.map(&:id)).to eql([2024, 2025]) - expect(form.options.map(&:name)).to eql(%w[2024/2025 2025/2026]) + expect(form.options.map(&:name)).to eql(["2024 to 2025", "2025 to 2026"]) end end end diff --git a/spec/models/validations/sales/setup_validations_spec.rb b/spec/models/validations/sales/setup_validations_spec.rb index 797b0c22c..659cde23f 100644 --- a/spec/models/validations/sales/setup_validations_spec.rb +++ b/spec/models/validations/sales/setup_validations_spec.rb @@ -37,7 +37,7 @@ RSpec.describe Validations::Sales::SetupValidations do it "adds error" do setup_validator.validate_saledate_collection_year(record) - expect(record.errors[:saledate]).to include(/Enter a date within the \d{2}\/\d{2} collection year, which is between 1st April \d{4} and 31st March \d{4}/) + expect(record.errors[:saledate]).to include(/Enter a date within the \d{4} to \d{4} collection year, which is between 1st April \d{4} and 31st March \d{4}/) end end @@ -47,7 +47,7 @@ RSpec.describe Validations::Sales::SetupValidations do it "adds error" do setup_validator.validate_saledate_collection_year(record) - expect(record.errors[:saledate]).to include(/Enter a date within the \d{2}\/\d{2} collection year, which is between 1st April \d{4} and 31st March \d{4}/) + expect(record.errors[:saledate]).to include(/Enter a date within the \d{4} to \d{4} collection year, which is between 1st April \d{4} and 31st March \d{4}/) end end end @@ -91,7 +91,7 @@ RSpec.describe Validations::Sales::SetupValidations do it "adds error" do setup_validator.validate_saledate_collection_year(record) - expect(record.errors[:saledate]).to include("Enter a date within the 23/24 or 24/25 collection years, which is between 1st April 2023 and 31st March 2025.") + expect(record.errors[:saledate]).to include("Enter a date within the 2023 to 2024 or 2024 to 2025 collection years, which is between 1st April 2023 and 31st March 2025.") end end @@ -105,7 +105,7 @@ RSpec.describe Validations::Sales::SetupValidations do it "adds error" do setup_validator.validate_saledate_collection_year(record) - expect(record.errors[:saledate]).to include("Enter a date within the 23/24 or 24/25 collection years, which is between 1st April 2023 and 31st March 2025.") + expect(record.errors[:saledate]).to include("Enter a date within the 2023 to 2024 or 2024 to 2025 collection years, which is between 1st April 2023 and 31st March 2025.") end end @@ -119,7 +119,7 @@ RSpec.describe Validations::Sales::SetupValidations do it "cannot create new logs for the archived collection year" do record.saledate = Time.zone.local(2023, 1, 1) setup_validator.validate_saledate_collection_year(record) - expect(record.errors["saledate"]).to include(match "Enter a date within the 23/24 or 24/25 collection years, which is between 1st April 2023 and 31st March 2025.") + expect(record.errors["saledate"]).to include(match "Enter a date within the 2023 to 2024 or 2024 to 2025 collection years, which is between 1st April 2023 and 31st March 2025.") end it "can edit already created logs for the previous collection year" do @@ -127,7 +127,7 @@ RSpec.describe Validations::Sales::SetupValidations do record.save!(validate: false) record.saledate = Time.zone.local(2024, 1, 1) setup_validator.validate_saledate_collection_year(record) - expect(record.errors["saledate"]).not_to include(match "Enter a date within the 24/25 collection year, which is between 1st April 2024 and 31st March 2025.") + expect(record.errors["saledate"]).not_to include(match "Enter a date within the 2024 to 2025 collection year, which is between 1st April 2024 and 31st March 2025.") end end @@ -142,7 +142,7 @@ RSpec.describe Validations::Sales::SetupValidations do record.update!(saledate: nil) record.saledate = Time.zone.local(2023, 1, 1) setup_validator.validate_saledate_collection_year(record) - expect(record.errors["saledate"]).to include(match "Enter a date within the 23/24 or 24/25 collection years, which is between 1st April 2023 and 31st March 2025.") + expect(record.errors["saledate"]).to include(match "Enter a date within the 2023 to 2024 or 2024 to 2025 collection years, which is between 1st April 2023 and 31st March 2025.") end it "cannot edit already created logs for the archived collection year" do @@ -150,7 +150,7 @@ RSpec.describe Validations::Sales::SetupValidations do record.save!(validate: false) record.saledate = Time.zone.local(2023, 1, 1) setup_validator.validate_saledate_collection_year(record) - expect(record.errors["saledate"]).to include(match "Enter a date within the 23/24 or 24/25 collection years, which is between 1st April 2023 and 31st March 2025.") + expect(record.errors["saledate"]).to include(match "Enter a date within the 2023 to 2024 or 2024 to 2025 collection years, which is between 1st April 2023 and 31st March 2025.") end end end diff --git a/spec/models/validations/setup_validations_spec.rb b/spec/models/validations/setup_validations_spec.rb index f39b71328..f1e306a89 100644 --- a/spec/models/validations/setup_validations_spec.rb +++ b/spec/models/validations/setup_validations_spec.rb @@ -7,7 +7,7 @@ RSpec.describe Validations::SetupValidations do let(:record) { build(:lettings_log) } describe "tenancy start date" do - context "when in 22/23 collection" do + context "when in 2022 to 2023 collection" do context "when in the crossover period" do before do allow(Time).to receive(:now).and_return(Time.zone.local(2022, 4, 1)) @@ -18,14 +18,14 @@ RSpec.describe Validations::SetupValidations do record.startdate = Time.zone.local(2021, 1, 1) setup_validator.validate_startdate_setup(record) setup_validator.validate_merged_organisations_start_date(record) - expect(record.errors["startdate"]).to include(match "Enter a date within the 21/22 or 22/23 collection years, which is between 1st April 2021 and 31st March 2023") + expect(record.errors["startdate"]).to include(match "Enter a date within the 2021 to 2022 or 2022 to 2023 collection years, which is between 1st April 2021 and 31st March 2023") end it "cannot be after the second collection window end date" do record.startdate = Time.zone.local(2023, 7, 1, 6) setup_validator.validate_startdate_setup(record) setup_validator.validate_merged_organisations_start_date(record) - expect(record.errors["startdate"]).to include(match "Enter a date within the 21/22 or 22/23 collection years, which is between 1st April 2021 and 31st March 2023") + expect(record.errors["startdate"]).to include(match "Enter a date within the 2021 to 2022 or 2022 to 2023 collection years, which is between 1st April 2021 and 31st March 2023") end end @@ -39,19 +39,19 @@ RSpec.describe Validations::SetupValidations do record.startdate = Time.zone.local(2022, 1, 1) setup_validator.validate_startdate_setup(record) setup_validator.validate_merged_organisations_start_date(record) - expect(record.errors["startdate"]).to include(match "Enter a date within the 22/23 collection year, which is between 1st April 2022 and 31st March 2023") + expect(record.errors["startdate"]).to include(match "Enter a date within the 2022 to 2023 collection year, which is between 1st April 2022 and 31st March 2023") end it "cannot be after the second collection window end date" do record.startdate = Time.zone.local(2023, 7, 1, 6) setup_validator.validate_startdate_setup(record) setup_validator.validate_merged_organisations_start_date(record) - expect(record.errors["startdate"]).to include(match "Enter a date within the 22/23 collection year, which is between 1st April 2022 and 31st March 2023") + expect(record.errors["startdate"]).to include(match "Enter a date within the 2022 to 2023 collection year, which is between 1st April 2022 and 31st March 2023") end end end - context "when in 23/24 collection" do + context "when in 2023 to 2024 collection" do context "when in the crossover period" do before do allow(Time).to receive(:now).and_return(Time.zone.local(2023, 4, 1)) @@ -62,14 +62,14 @@ RSpec.describe Validations::SetupValidations do record.startdate = Time.zone.local(2022, 1, 1) setup_validator.validate_startdate_setup(record) setup_validator.validate_merged_organisations_start_date(record) - expect(record.errors["startdate"]).to include(match "Enter a date within the 22/23 or 23/24 collection years, which is between 1st April 2022 and 31st March 2024") + expect(record.errors["startdate"]).to include(match "Enter a date within the 2022 to 2023 or 2023 to 2024 collection years, which is between 1st April 2022 and 31st March 2024") end it "cannot be after the second collection window end date" do record.startdate = Time.zone.local(2024, 7, 1, 6) setup_validator.validate_startdate_setup(record) setup_validator.validate_merged_organisations_start_date(record) - expect(record.errors["startdate"]).to include(match "Enter a date within the 22/23 or 23/24 collection years, which is between 1st April 2022 and 31st March 2024") + expect(record.errors["startdate"]).to include(match "Enter a date within the 2022 to 2023 or 2023 to 2024 collection years, which is between 1st April 2022 and 31st March 2024") end end @@ -83,14 +83,14 @@ RSpec.describe Validations::SetupValidations do record.startdate = Time.zone.local(2023, 1, 1) setup_validator.validate_startdate_setup(record) setup_validator.validate_merged_organisations_start_date(record) - expect(record.errors["startdate"]).to include(match "Enter a date within the 23/24 collection year, which is between 1st April 2023 and 31st March 2024") + expect(record.errors["startdate"]).to include(match "Enter a date within the 2023 to 2024 collection year, which is between 1st April 2023 and 31st March 2024") end it "cannot be after the second collection window end date" do record.startdate = Time.zone.local(2024, 7, 1, 6) setup_validator.validate_startdate_setup(record) setup_validator.validate_merged_organisations_start_date(record) - expect(record.errors["startdate"]).to include(match "Enter a date within the 23/24 collection year, which is between 1st April 2023 and 31st March 2024") + expect(record.errors["startdate"]).to include(match "Enter a date within the 2023 to 2024 collection year, which is between 1st April 2023 and 31st March 2024") end end @@ -104,7 +104,7 @@ RSpec.describe Validations::SetupValidations do record.startdate = Time.zone.local(2023, 1, 1) setup_validator.validate_startdate_setup(record) setup_validator.validate_merged_organisations_start_date(record) - expect(record.errors["startdate"]).to include(match "Enter a date within the 23/24 collection year, which is between 1st April 2023 and 31st March 2024") + expect(record.errors["startdate"]).to include(match "Enter a date within the 2023 to 2024 collection year, which is between 1st April 2023 and 31st March 2024") end xit "can edit already created logs for the previous collection year" do @@ -113,7 +113,7 @@ RSpec.describe Validations::SetupValidations do record.startdate = Time.zone.local(2023, 1, 1) setup_validator.validate_startdate_setup(record) setup_validator.validate_merged_organisations_start_date(record) - expect(record.errors["startdate"]).not_to include(match "Enter a date within the 23/24 collection year, which is between 1st April 2023 and 31st March 2024") + expect(record.errors["startdate"]).not_to include(match "Enter a date within the 2023 to 2024 collection year, which is between 1st April 2023 and 31st March 2024") end end @@ -127,7 +127,7 @@ RSpec.describe Validations::SetupValidations do record.startdate = Time.zone.local(2023, 1, 1) setup_validator.validate_startdate_setup(record) setup_validator.validate_merged_organisations_start_date(record) - expect(record.errors["startdate"]).to include(match "Enter a date within the 23/24 collection year, which is between 1st April 2023 and 31st March 2024") + expect(record.errors["startdate"]).to include(match "Enter a date within the 2023 to 2024 collection year, which is between 1st April 2023 and 31st March 2024") end it "cannot edit already created logs for the previous collection year" do @@ -136,7 +136,7 @@ RSpec.describe Validations::SetupValidations do record.startdate = Time.zone.local(2023, 1, 1) setup_validator.validate_startdate_setup(record) setup_validator.validate_merged_organisations_start_date(record) - expect(record.errors["startdate"]).to include(match "Enter a date within the 23/24 collection year, which is between 1st April 2023 and 31st March 2024") + expect(record.errors["startdate"]).to include(match "Enter a date within the 2023 to 2024 collection year, which is between 1st April 2023 and 31st March 2024") end end end @@ -157,7 +157,7 @@ RSpec.describe Validations::SetupValidations do record.startdate = Time.zone.local(2024, 4, 1) setup_validator.validate_startdate_setup(record) expect(record.errors["startdate"].length).to be >= 2 - expect(record.errors["startdate"][0]).to eq("Enter a date within the 23/24 collection year, which is between 1st April 2023 and 31st March 2024.") + expect(record.errors["startdate"][0]).to eq("Enter a date within the 2023 to 2024 collection year, which is between 1st April 2023 and 31st March 2024.") expect(record.errors["startdate"][1]).to eq(I18n.t("validations.setup.startdate.later_than_14_days_after")) end end diff --git a/spec/requests/bulk_upload_lettings_results_controller_spec.rb b/spec/requests/bulk_upload_lettings_results_controller_spec.rb index dc78c9d78..afbd84df9 100644 --- a/spec/requests/bulk_upload_lettings_results_controller_spec.rb +++ b/spec/requests/bulk_upload_lettings_results_controller_spec.rb @@ -16,7 +16,7 @@ RSpec.describe BulkUploadLettingsResultsController, type: :request do get "/lettings-logs/bulk-upload-results/#{bulk_upload.id}/summary" expect(response).to be_successful - expect(response.body).to include("Bulk upload for lettings (#{bulk_upload.year_combo})") + expect(response.body).to include("Upload lettings logs in bulk (#{bulk_upload.year_combo})") end it "renders the bulk upload filename" do @@ -90,7 +90,7 @@ RSpec.describe BulkUploadLettingsResultsController, type: :request do get "/lettings-logs/bulk-upload-results/#{bulk_upload.id}" expect(response).to be_successful - expect(response.body).to include("Bulk upload for lettings (#{bulk_upload.year_combo})") + expect(response.body).to include("Upload lettings logs in bulk (#{bulk_upload.year_combo})") end it "renders correct number of errors" do diff --git a/spec/requests/bulk_upload_lettings_resume_controller_spec.rb b/spec/requests/bulk_upload_lettings_resume_controller_spec.rb index f6ac9bb4a..8e3c0b0e0 100644 --- a/spec/requests/bulk_upload_lettings_resume_controller_spec.rb +++ b/spec/requests/bulk_upload_lettings_resume_controller_spec.rb @@ -60,7 +60,7 @@ RSpec.describe BulkUploadLettingsResumeController, type: :request do expect(response).to be_successful - expect(response.body).to include("Bulk upload for lettings") + expect(response.body).to include("Upload lettings logs in bulk") expect(response.body).to include(bulk_upload.year_combo) expect(response.body).to include("View the error report") expect(response.body).to include("How would you like to fix the errors?") @@ -120,7 +120,7 @@ RSpec.describe BulkUploadLettingsResumeController, type: :request do expect(response).to be_successful - expect(response.body).to include("Bulk upload for lettings") + expect(response.body).to include("Upload lettings logs in bulk") expect(response.body).to include("Cancel") end end @@ -218,7 +218,7 @@ RSpec.describe BulkUploadLettingsResumeController, type: :request do expect(response).to be_successful - expect(response.body).to include("Bulk upload for lettings") + expect(response.body).to include("Upload lettings logs in bulk") expect(response.body).to include(bulk_upload.year_combo) expect(response.body).to include("These 2 answers will be deleted if you upload the log") expect(response.body).to include(bulk_upload.filename) @@ -260,7 +260,7 @@ RSpec.describe BulkUploadLettingsResumeController, type: :request do expect(response).to be_successful - expect(response.body).to include("Bulk upload for lettings") + expect(response.body).to include("Upload lettings logs in bulk") expect(response.body).to include(bulk_upload.year_combo) expect(response.body).to include("These 2 answers will be deleted if you upload the log") expect(response.body).to include(bulk_upload.filename) diff --git a/spec/requests/bulk_upload_lettings_soft_validations_check_controller_spec.rb b/spec/requests/bulk_upload_lettings_soft_validations_check_controller_spec.rb index e7fc9ed46..315235e0e 100644 --- a/spec/requests/bulk_upload_lettings_soft_validations_check_controller_spec.rb +++ b/spec/requests/bulk_upload_lettings_soft_validations_check_controller_spec.rb @@ -14,7 +14,7 @@ RSpec.describe BulkUploadLettingsSoftValidationsCheckController, type: :request it "shows the soft validation errors with confirmation question" do get "/lettings-logs/bulk-upload-soft-validations-check/#{bulk_upload.id}/confirm-soft-errors" - expect(response.body).to include("Bulk upload for lettings") + expect(response.body).to include("Upload lettings logs in bulk") expect(response.body).to include(bulk_upload.year_combo) expect(response.body).to include("Check these 2 answers") expect(response.body).to include(bulk_upload.filename) diff --git a/spec/requests/bulk_upload_sales_results_controller_spec.rb b/spec/requests/bulk_upload_sales_results_controller_spec.rb index 1bd171dec..b7bb7a10c 100644 --- a/spec/requests/bulk_upload_sales_results_controller_spec.rb +++ b/spec/requests/bulk_upload_sales_results_controller_spec.rb @@ -52,7 +52,7 @@ RSpec.describe BulkUploadSalesResultsController, type: :request do get "/sales-logs/bulk-upload-results/#{bulk_upload.id}" expect(response).to be_successful - expect(response.body).to include("Bulk Upload for sales (#{bulk_upload.year_combo})") + expect(response.body).to include("Upload sales logs in bulk (#{bulk_upload.year_combo})") end it "renders correct number of errors" do diff --git a/spec/requests/bulk_upload_sales_resume_controller_spec.rb b/spec/requests/bulk_upload_sales_resume_controller_spec.rb index 9c0efded8..c6622afcb 100644 --- a/spec/requests/bulk_upload_sales_resume_controller_spec.rb +++ b/spec/requests/bulk_upload_sales_resume_controller_spec.rb @@ -60,7 +60,7 @@ RSpec.describe BulkUploadSalesResumeController, type: :request do expect(response).to be_successful - expect(response.body).to include("Bulk upload for sales") + expect(response.body).to include("Upload sales logs in bulk") expect(response.body).to include(bulk_upload.year_combo) expect(response.body).to include("View the error report") expect(response.body).to include("How would you like to fix the errors?") @@ -120,7 +120,7 @@ RSpec.describe BulkUploadSalesResumeController, type: :request do expect(response).to be_successful - expect(response.body).to include("Bulk upload for sales") + expect(response.body).to include("Upload sales logs in bulk") expect(response.body).to include("Cancel") end end @@ -218,7 +218,7 @@ RSpec.describe BulkUploadSalesResumeController, type: :request do expect(response).to be_successful - expect(response.body).to include("Bulk upload for sales") + expect(response.body).to include("Upload sales logs in bulk") expect(response.body).to include(bulk_upload.year_combo) expect(response.body).to include("These 2 answers will be deleted if you upload the log") expect(response.body).to include(bulk_upload.filename) @@ -260,7 +260,7 @@ RSpec.describe BulkUploadSalesResumeController, type: :request do expect(response).to be_successful - expect(response.body).to include("Bulk upload for sales") + expect(response.body).to include("Upload sales logs in bulk") expect(response.body).to include(bulk_upload.year_combo) expect(response.body).to include("These 2 answers will be deleted if you upload the log") expect(response.body).to include(bulk_upload.filename) diff --git a/spec/requests/bulk_upload_sales_soft_validations_check_controller_spec.rb b/spec/requests/bulk_upload_sales_soft_validations_check_controller_spec.rb index f22ca0aa2..90e44a4f7 100644 --- a/spec/requests/bulk_upload_sales_soft_validations_check_controller_spec.rb +++ b/spec/requests/bulk_upload_sales_soft_validations_check_controller_spec.rb @@ -14,7 +14,7 @@ RSpec.describe BulkUploadSalesSoftValidationsCheckController, type: :request do it "shows the soft validation errors with confirmation question" do get "/sales-logs/bulk-upload-soft-validations-check/#{bulk_upload.id}/confirm-soft-errors" - expect(response.body).to include("Bulk upload for sales") + expect(response.body).to include("Upload sales logs in bulk") expect(response.body).to include(bulk_upload.year_combo) expect(response.body).to include("Check these 2 answers") expect(response.body).to include(bulk_upload.filename) diff --git a/spec/requests/lettings_logs_controller_spec.rb b/spec/requests/lettings_logs_controller_spec.rb index 3443a70ca..6af9f3f12 100644 --- a/spec/requests/lettings_logs_controller_spec.rb +++ b/spec/requests/lettings_logs_controller_spec.rb @@ -1202,7 +1202,7 @@ RSpec.describe LettingsLogsController, type: :request do it "displays a closed collection window message for previous collection year logs" do follow_redirect! - expect(page).to have_content(/This log is from the \d{4}\/\d{4} collection window, which is now closed\./) + expect(page).to have_content(/This log is from the \d{4} to \d{4} collection window, which is now closed\./) end end diff --git a/spec/requests/sales_logs_controller_spec.rb b/spec/requests/sales_logs_controller_spec.rb index 607349a68..4c6ca3cc1 100644 --- a/spec/requests/sales_logs_controller_spec.rb +++ b/spec/requests/sales_logs_controller_spec.rb @@ -954,7 +954,7 @@ RSpec.describe SalesLogsController, type: :request do expect(completed_sales_log.form.new_logs_end_date).to eq(Time.zone.local(2022, 12, 31)) expect(completed_sales_log.status).to eq("completed") follow_redirect! - expect(page).to have_content("This log is from the 2021/2022 collection window, which is now closed.") + expect(page).to have_content("This log is from the 2021 to 2022 collection window, which is now closed.") end end end From a39405346203e0d65bf49fe311689a6bfa8e03af Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 29 Oct 2024 09:26:54 +0000 Subject: [PATCH 11/30] Bump rexml from 3.3.6 to 3.3.9 in /docs (#2733) Bumps [rexml](https://github.com/ruby/rexml) from 3.3.6 to 3.3.9. - [Release notes](https://github.com/ruby/rexml/releases) - [Changelog](https://github.com/ruby/rexml/blob/master/NEWS.md) - [Commits](https://github.com/ruby/rexml/compare/v3.3.6...v3.3.9) --- updated-dependencies: - dependency-name: rexml dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- docs/Gemfile.lock | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/docs/Gemfile.lock b/docs/Gemfile.lock index 8270007c8..f8962318e 100644 --- a/docs/Gemfile.lock +++ b/docs/Gemfile.lock @@ -226,8 +226,7 @@ GEM rb-fsevent (0.11.2) rb-inotify (0.10.1) ffi (~> 1.0) - rexml (3.3.6) - strscan + rexml (3.3.9) rouge (3.26.0) ruby2_keywords (0.0.5) rubyzip (2.3.2) @@ -242,7 +241,6 @@ GEM faraday (>= 0.17.3, < 3) simpleidn (0.2.1) unf (~> 0.1.4) - strscan (3.1.0) terminal-table (1.8.0) unicode-display_width (~> 1.1, >= 1.1.1) typhoeus (1.4.0) From 5865c307b40cfb4b8c0d9c38290eb12f1cdc695d Mon Sep 17 00:00:00 2001 From: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com> Date: Tue, 29 Oct 2024 11:03:02 +0000 Subject: [PATCH 12/30] Update rexml (#2734) --- Gemfile.lock | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index cc9e57d24..1a98463b5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -377,8 +377,7 @@ GEM responders (3.1.1) actionpack (>= 5.2) railties (>= 5.2) - rexml (3.3.6) - strscan + rexml (3.3.9) roo (2.10.1) nokogiri (~> 1) rubyzip (>= 1.3.0, < 3.0.0) @@ -463,7 +462,6 @@ GEM smart_properties (1.17.0) stimulus-rails (1.3.3) railties (>= 6.0.0) - strscan (3.1.0) thor (1.3.2) thread_safe (0.3.6) timecop (0.9.8) From 1ffc4403422607b4a5e9ceae8230f92ae008f738 Mon Sep 17 00:00:00 2001 From: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com> Date: Tue, 29 Oct 2024 12:20:31 +0000 Subject: [PATCH 13/30] CLDC-3656 Extract household characteristics question and page copy to translation files (#2702) * Extract question and page copy to translation files * Refactor 2 question pages * Readd removed answer options * Fix missing/wrong age mappings * Update some pages/questions * Update tests * CLDC-3656 Extract household characteristics soft validations (#2707) * Extract retirement confirmation questions * Extract old persons shared ownership confirmation questions * Extract income confirmation questions * Extract buyer live-in value check page and question copy to translation files * Extract student not a child confirmation questions and page copy to translation files * Extract partner under 16 value check page and question copy to translation files * Extract partner under 16 value check page and question copy to translation files * Update some missing/wrong keys * Update some keys on 2023 * Update BU tests --- app/models/form/sales/pages/age1.rb | 1 + app/models/form/sales/pages/age2.rb | 1 + .../pages/buyer1_ethnic_background_arab.rb | 1 + .../pages/buyer1_ethnic_background_asian.rb | 1 + .../pages/buyer1_ethnic_background_black.rb | 1 + .../pages/buyer1_ethnic_background_mixed.rb | 1 + .../pages/buyer1_ethnic_background_white.rb | 1 + .../pages/buyer2_ethnic_background_arab.rb | 1 + .../pages/buyer2_ethnic_background_asian.rb | 1 + .../pages/buyer2_ethnic_background_black.rb | 1 + .../pages/buyer2_ethnic_background_mixed.rb | 1 + .../pages/buyer2_ethnic_background_white.rb | 1 + .../pages/buyer2_relationship_to_buyer1.rb | 1 + .../sales/pages/buyer2_working_situation.rb | 1 + .../form/sales/pages/buyer_interview.rb | 2 +- .../sales/pages/buyer_live_in_value_check.rb | 5 +- .../form/sales/pages/gender_identity2.rb | 1 + .../pages/multiple_partners_value_check.rb | 8 +- .../sales/pages/not_retired_value_check.rb | 6 +- ...ld_persons_shared_ownership_value_check.rb | 5 +- .../pages/partner_under_16_value_check.rb | 8 +- app/models/form/sales/pages/person_age.rb | 1 + .../sales/pages/person_gender_identity.rb | 1 + .../pages/person_relationship_to_buyer_1.rb | 1 + .../person_student_not_child_value_check.rb | 5 +- .../sales/pages/person_working_situation.rb | 1 + app/models/form/sales/pages/privacy_notice.rb | 2 +- .../sales/pages/retirement_value_check.rb | 8 +- app/models/form/sales/questions/age1.rb | 3 +- app/models/form/sales/questions/age2.rb | 3 +- .../form/sales/questions/buyer1_age_known.rb | 4 +- .../buyer1_ethnic_background_arab.rb | 4 +- .../buyer1_ethnic_background_asian.rb | 4 +- .../buyer1_ethnic_background_black.rb | 4 +- .../buyer1_ethnic_background_mixed.rb | 4 +- .../buyer1_ethnic_background_white.rb | 4 +- .../sales/questions/buyer1_ethnic_group.rb | 3 - .../questions/buyer1_live_in_property.rb | 3 - .../sales/questions/buyer1_nationality.rb | 3 - .../questions/buyer1_working_situation.rb | 3 - .../form/sales/questions/buyer2_age_known.rb | 3 +- .../buyer2_ethnic_background_arab.rb | 3 +- .../buyer2_ethnic_background_asian.rb | 3 +- .../buyer2_ethnic_background_black.rb | 3 +- .../buyer2_ethnic_background_mixed.rb | 3 +- .../buyer2_ethnic_background_white.rb | 3 +- .../sales/questions/buyer2_ethnic_group.rb | 2 - .../questions/buyer2_live_in_property.rb | 2 - .../sales/questions/buyer2_nationality.rb | 2 - .../buyer2_relationship_to_buyer1.rb | 3 +- .../questions/buyer2_working_situation.rb | 3 +- .../form/sales/questions/buyer_interview.rb | 2 +- .../questions/buyer_live_in_value_check.rb | 3 +- .../form/sales/questions/gender_identity1.rb | 10 - .../form/sales/questions/gender_identity2.rb | 9 +- .../multiple_partners_value_check.rb | 3 +- .../form/sales/questions/nationality_all.rb | 2 - .../sales/questions/nationality_all_group.rb | 3 - .../questions/not_retired_value_check.rb | 3 +- .../questions/number_of_others_in_property.rb | 14 +- ...ld_persons_shared_ownership_value_check.rb | 3 +- .../questions/partner_under_16_value_check.rb | 3 +- app/models/form/sales/questions/person_age.rb | 9 +- .../form/sales/questions/person_age_known.rb | 3 +- .../sales/questions/person_gender_identity.rb | 9 +- .../form/sales/questions/person_known.rb | 2 - .../person_relationship_to_buyer_1.rb | 3 +- .../person_student_not_child_value_check.rb | 3 +- .../questions/person_working_situation.rb | 3 +- .../form/sales/questions/privacy_notice.rb | 2 +- .../sales/questions/retirement_value_check.rb | 3 +- config/locales/en.yml | 17 - .../sales/household_characteristics.en.yml | 357 ++++++++++++++++++ .../forms/2023/sales/soft_validations.en.yml | 66 +++- .../sales/household_characteristics.en.yml | 345 +++++++++++++++++ .../forms/2024/sales/soft_validations.en.yml | 66 +++- .../form/sales/pages/buyer_interview_spec.rb | 43 ++- .../pages/buyer_live_in_value_check_spec.rb | 7 +- .../multiple_partners_value_check_spec.rb | 11 +- ...rsons_shared_ownership_value_check_spec.rb | 9 +- .../pages/partner_under16_value_check_spec.rb | 27 +- ...rson_student_not_child_value_check_spec.rb | 7 +- .../form/sales/pages/privacy_notice_spec.rb | 37 +- .../pages/retirement_value_check_spec.rb | 27 +- .../sales/questions/buyer_interview_spec.rb | 37 +- .../sales/questions/privacy_notice_spec.rb | 36 +- .../sales/year2023/row_parser_spec.rb | 4 +- .../sales/year2024/row_parser_spec.rb | 4 +- 88 files changed, 1080 insertions(+), 252 deletions(-) create mode 100644 config/locales/forms/2023/sales/household_characteristics.en.yml create mode 100644 config/locales/forms/2024/sales/household_characteristics.en.yml diff --git a/app/models/form/sales/pages/age1.rb b/app/models/form/sales/pages/age1.rb index caa0948ee..12fc8c4d2 100644 --- a/app/models/form/sales/pages/age1.rb +++ b/app/models/form/sales/pages/age1.rb @@ -2,6 +2,7 @@ class Form::Sales::Pages::Age1 < ::Form::Page def initialize(id, hsh, subsection) super @id = "buyer_1_age" + @copy_key = "sales.household_characteristics.age1" @depends_on = [ { "buyer_has_seen_privacy_notice?" => true, diff --git a/app/models/form/sales/pages/age2.rb b/app/models/form/sales/pages/age2.rb index ee3bbc487..fb8d3953a 100644 --- a/app/models/form/sales/pages/age2.rb +++ b/app/models/form/sales/pages/age2.rb @@ -2,6 +2,7 @@ class Form::Sales::Pages::Age2 < ::Form::Page def initialize(id, hsh, subsection) super @id = "buyer_2_age" + @copy_key = "sales.household_characteristics.age2.buyer" @depends_on = [ { "joint_purchase?" => true, diff --git a/app/models/form/sales/pages/buyer1_ethnic_background_arab.rb b/app/models/form/sales/pages/buyer1_ethnic_background_arab.rb index e0e74e129..ff603e1d6 100644 --- a/app/models/form/sales/pages/buyer1_ethnic_background_arab.rb +++ b/app/models/form/sales/pages/buyer1_ethnic_background_arab.rb @@ -2,6 +2,7 @@ class Form::Sales::Pages::Buyer1EthnicBackgroundArab < ::Form::Page def initialize(id, hsh, subsection) super @id = "buyer_1_ethnic_background_arab" + @copy_key = "sales.household_characteristics.ethnic.ethnic_background_arab" @depends_on = [{ "ethnic_group" => 4, }] diff --git a/app/models/form/sales/pages/buyer1_ethnic_background_asian.rb b/app/models/form/sales/pages/buyer1_ethnic_background_asian.rb index 599a48f91..5b865cd9b 100644 --- a/app/models/form/sales/pages/buyer1_ethnic_background_asian.rb +++ b/app/models/form/sales/pages/buyer1_ethnic_background_asian.rb @@ -2,6 +2,7 @@ class Form::Sales::Pages::Buyer1EthnicBackgroundAsian < ::Form::Page def initialize(id, hsh, subsection) super @id = "buyer_1_ethnic_background_asian" + @copy_key = "sales.household_characteristics.ethnic.ethnic_background_asian" @depends_on = [{ "ethnic_group" => 2, }] diff --git a/app/models/form/sales/pages/buyer1_ethnic_background_black.rb b/app/models/form/sales/pages/buyer1_ethnic_background_black.rb index 73e17d912..a54c4c54d 100644 --- a/app/models/form/sales/pages/buyer1_ethnic_background_black.rb +++ b/app/models/form/sales/pages/buyer1_ethnic_background_black.rb @@ -2,6 +2,7 @@ class Form::Sales::Pages::Buyer1EthnicBackgroundBlack < ::Form::Page def initialize(id, hsh, subsection) super @id = "buyer_1_ethnic_background_black" + @copy_key = "sales.household_characteristics.ethnic.ethnic_background_black" @depends_on = [{ "ethnic_group" => 3, }] diff --git a/app/models/form/sales/pages/buyer1_ethnic_background_mixed.rb b/app/models/form/sales/pages/buyer1_ethnic_background_mixed.rb index 13fea19a7..2b498e68f 100644 --- a/app/models/form/sales/pages/buyer1_ethnic_background_mixed.rb +++ b/app/models/form/sales/pages/buyer1_ethnic_background_mixed.rb @@ -2,6 +2,7 @@ class Form::Sales::Pages::Buyer1EthnicBackgroundMixed < ::Form::Page def initialize(id, hsh, subsection) super @id = "buyer_1_ethnic_background_mixed" + @copy_key = "sales.household_characteristics.ethnic.ethnic_background_mixed" @depends_on = [{ "ethnic_group" => 1, }] diff --git a/app/models/form/sales/pages/buyer1_ethnic_background_white.rb b/app/models/form/sales/pages/buyer1_ethnic_background_white.rb index 2e4bd3097..4553d5d36 100644 --- a/app/models/form/sales/pages/buyer1_ethnic_background_white.rb +++ b/app/models/form/sales/pages/buyer1_ethnic_background_white.rb @@ -2,6 +2,7 @@ class Form::Sales::Pages::Buyer1EthnicBackgroundWhite < ::Form::Page def initialize(id, hsh, subsection) super @id = "buyer_1_ethnic_background_white" + @copy_key = "sales.household_characteristics.ethnic.ethnic_background_white" @depends_on = [{ "ethnic_group" => 0, }] diff --git a/app/models/form/sales/pages/buyer2_ethnic_background_arab.rb b/app/models/form/sales/pages/buyer2_ethnic_background_arab.rb index 593e43ebc..370e07dcd 100644 --- a/app/models/form/sales/pages/buyer2_ethnic_background_arab.rb +++ b/app/models/form/sales/pages/buyer2_ethnic_background_arab.rb @@ -2,6 +2,7 @@ class Form::Sales::Pages::Buyer2EthnicBackgroundArab < ::Form::Page def initialize(id, hsh, subsection) super @id = "buyer_2_ethnic_background_arab" + @copy_key = "sales.household_characteristics.ethnicbuy2.ethnic_background_arab" @depends_on = [{ "ethnic_group2" => 4, }] diff --git a/app/models/form/sales/pages/buyer2_ethnic_background_asian.rb b/app/models/form/sales/pages/buyer2_ethnic_background_asian.rb index 98a36476e..0c9f47627 100644 --- a/app/models/form/sales/pages/buyer2_ethnic_background_asian.rb +++ b/app/models/form/sales/pages/buyer2_ethnic_background_asian.rb @@ -2,6 +2,7 @@ class Form::Sales::Pages::Buyer2EthnicBackgroundAsian < ::Form::Page def initialize(id, hsh, subsection) super @id = "buyer_2_ethnic_background_asian" + @copy_key = "sales.household_characteristics.ethnicbuy2.ethnic_background_asian" @depends_on = [{ "ethnic_group2" => 2, }] diff --git a/app/models/form/sales/pages/buyer2_ethnic_background_black.rb b/app/models/form/sales/pages/buyer2_ethnic_background_black.rb index a772f46ac..2178d42ce 100644 --- a/app/models/form/sales/pages/buyer2_ethnic_background_black.rb +++ b/app/models/form/sales/pages/buyer2_ethnic_background_black.rb @@ -2,6 +2,7 @@ class Form::Sales::Pages::Buyer2EthnicBackgroundBlack < ::Form::Page def initialize(id, hsh, subsection) super @id = "buyer_2_ethnic_background_black" + @copy_key = "sales.household_characteristics.ethnicbuy2.ethnic_background_black" @depends_on = [{ "ethnic_group2" => 3, }] diff --git a/app/models/form/sales/pages/buyer2_ethnic_background_mixed.rb b/app/models/form/sales/pages/buyer2_ethnic_background_mixed.rb index f02165dfc..9a8710396 100644 --- a/app/models/form/sales/pages/buyer2_ethnic_background_mixed.rb +++ b/app/models/form/sales/pages/buyer2_ethnic_background_mixed.rb @@ -2,6 +2,7 @@ class Form::Sales::Pages::Buyer2EthnicBackgroundMixed < ::Form::Page def initialize(id, hsh, subsection) super @id = "buyer_2_ethnic_background_mixed" + @copy_key = "sales.household_characteristics.ethnicbuy2.ethnic_background_black" @depends_on = [{ "ethnic_group2" => 1, }] diff --git a/app/models/form/sales/pages/buyer2_ethnic_background_white.rb b/app/models/form/sales/pages/buyer2_ethnic_background_white.rb index 2013c8682..d81f20d4f 100644 --- a/app/models/form/sales/pages/buyer2_ethnic_background_white.rb +++ b/app/models/form/sales/pages/buyer2_ethnic_background_white.rb @@ -2,6 +2,7 @@ class Form::Sales::Pages::Buyer2EthnicBackgroundWhite < ::Form::Page def initialize(id, hsh, subsection) super @id = "buyer_2_ethnic_background_white" + @copy_key = "sales.household_characteristics.ethnicbuy2.ethnic_background_white" @depends_on = [{ "ethnic_group2" => 0, }] diff --git a/app/models/form/sales/pages/buyer2_relationship_to_buyer1.rb b/app/models/form/sales/pages/buyer2_relationship_to_buyer1.rb index 0791769d8..a9d3550f0 100644 --- a/app/models/form/sales/pages/buyer2_relationship_to_buyer1.rb +++ b/app/models/form/sales/pages/buyer2_relationship_to_buyer1.rb @@ -2,6 +2,7 @@ class Form::Sales::Pages::Buyer2RelationshipToBuyer1 < ::Form::Page def initialize(id, hsh, subsection) super @id = "buyer_2_relationship_to_buyer_1" + @copy_key = "sales.household_characteristics.relat2.buyer" @depends_on = [ { "joint_purchase?" => true, diff --git a/app/models/form/sales/pages/buyer2_working_situation.rb b/app/models/form/sales/pages/buyer2_working_situation.rb index 1ff7bbecc..4e73c09cf 100644 --- a/app/models/form/sales/pages/buyer2_working_situation.rb +++ b/app/models/form/sales/pages/buyer2_working_situation.rb @@ -2,6 +2,7 @@ class Form::Sales::Pages::Buyer2WorkingSituation < ::Form::Page def initialize(id, hsh, subsection) super @id = "buyer_2_working_situation" + @copy_key = "sales.household_characteristics.ecstat2.buyer" @depends_on = [ { "joint_purchase?" => true, diff --git a/app/models/form/sales/pages/buyer_interview.rb b/app/models/form/sales/pages/buyer_interview.rb index d042db288..c6a43690b 100644 --- a/app/models/form/sales/pages/buyer_interview.rb +++ b/app/models/form/sales/pages/buyer_interview.rb @@ -2,7 +2,7 @@ class Form::Sales::Pages::BuyerInterview < ::Form::Page def initialize(id, hsh, subsection, joint_purchase:) super(id, hsh, subsection) @joint_purchase = joint_purchase - @copy_key = "sales.setup.noint.#{joint_purchase ? 'joint_purchase' : 'not_joint_purchase'}" + @copy_key = "sales.#{subsection.id}.noint.#{joint_purchase ? 'joint_purchase' : 'not_joint_purchase'}" end def questions diff --git a/app/models/form/sales/pages/buyer_live_in_value_check.rb b/app/models/form/sales/pages/buyer_live_in_value_check.rb index 99080ae77..bb08ba7f4 100644 --- a/app/models/form/sales/pages/buyer_live_in_value_check.rb +++ b/app/models/form/sales/pages/buyer_live_in_value_check.rb @@ -6,12 +6,13 @@ class Form::Sales::Pages::BuyerLiveInValueCheck < Form::Sales::Pages::Person "buyer#{person_index}_livein_wrong_for_ownership_type?" => true, }, ] + @copy_key = "sales.soft_validations.buyer_livein_value_check.buyer#{person_index}" @title_text = { - "translation" => "soft_validations.buyer#{person_index}_livein_wrong_for_ownership_type.title_text", + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text", "arguments" => [{ "key" => "ownership_scheme", "label" => false, "i18n_template" => "ownership_scheme" }], } @informative_text = { - "translation" => "soft_validations.buyer#{person_index}_livein_wrong_for_ownership_type.hint_text", + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text", "arguments" => [{ "key" => "ownership_scheme", "label" => false, "i18n_template" => "ownership_scheme" }], } end diff --git a/app/models/form/sales/pages/gender_identity2.rb b/app/models/form/sales/pages/gender_identity2.rb index 94e585795..dc38847e4 100644 --- a/app/models/form/sales/pages/gender_identity2.rb +++ b/app/models/form/sales/pages/gender_identity2.rb @@ -2,6 +2,7 @@ class Form::Sales::Pages::GenderIdentity2 < ::Form::Page def initialize(id, hsh, subsection) super @id = "buyer_2_gender_identity" + @copy_key = "sales.household_characteristics.sex2.buyer" @depends_on = [ { "joint_purchase?" => true, diff --git a/app/models/form/sales/pages/multiple_partners_value_check.rb b/app/models/form/sales/pages/multiple_partners_value_check.rb index db409f148..37ab02ca4 100644 --- a/app/models/form/sales/pages/multiple_partners_value_check.rb +++ b/app/models/form/sales/pages/multiple_partners_value_check.rb @@ -6,12 +6,16 @@ class Form::Sales::Pages::MultiplePartnersValueCheck < Form::Sales::Pages::Perso "multiple_partners?" => true, }, ] + @copy_key = "sales.soft_validations.multiple_partners_value_check" @person_index = person_index @title_text = { - "translation" => "soft_validations.multiple_partners_sales.title", + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text", + "arguments" => [], + } + @informative_text = { + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text", "arguments" => [], } - @informative_text = {} end def questions diff --git a/app/models/form/sales/pages/not_retired_value_check.rb b/app/models/form/sales/pages/not_retired_value_check.rb index 193aa6e7d..cf480cb59 100644 --- a/app/models/form/sales/pages/not_retired_value_check.rb +++ b/app/models/form/sales/pages/not_retired_value_check.rb @@ -7,11 +7,13 @@ class Form::Sales::Pages::NotRetiredValueCheck < Form::Sales::Pages::Person }, ] @person_index = person_index + @copy_key = "sales.soft_validations.retirement_value_check.max" @title_text = { - "translation" => "soft_validations.retirement.max.title", + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text", } @informative_text = { - "translation" => "soft_validations.retirement.max.hint_text", + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text", + "arguments" => [], } end diff --git a/app/models/form/sales/pages/old_persons_shared_ownership_value_check.rb b/app/models/form/sales/pages/old_persons_shared_ownership_value_check.rb index 0254804f0..7ac7b7cad 100644 --- a/app/models/form/sales/pages/old_persons_shared_ownership_value_check.rb +++ b/app/models/form/sales/pages/old_persons_shared_ownership_value_check.rb @@ -1,12 +1,13 @@ class Form::Sales::Pages::OldPersonsSharedOwnershipValueCheck < ::Form::Page def initialize(id, hsh, subsection, joint_purchase:) super(id, hsh, subsection) + @copy_key = "sales.soft_validations.old_persons_shared_ownership_value_check" @title_text = { - "translation" => "soft_validations.old_persons_shared_ownership.title_text.#{joint_purchase ? 'two' : 'one'}", + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text.#{joint_purchase ? 'joint_purchase' : 'not_joint_purchase'}", "arguments" => [], } @informative_text = { - "translation" => "soft_validations.old_persons_shared_ownership.hint_text", + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text", "arguments" => [], } @joint_purchase = joint_purchase diff --git a/app/models/form/sales/pages/partner_under_16_value_check.rb b/app/models/form/sales/pages/partner_under_16_value_check.rb index 5113e1677..f6b3622f1 100644 --- a/app/models/form/sales/pages/partner_under_16_value_check.rb +++ b/app/models/form/sales/pages/partner_under_16_value_check.rb @@ -6,9 +6,10 @@ class Form::Sales::Pages::PartnerUnder16ValueCheck < Form::Sales::Pages::Person "person_#{person_index}_partner_under_16?" => true, }, ] + @copy_key = "sales.soft_validations.partner_under_16_value_check" @person_index = person_index @title_text = { - "translation" => "soft_validations.partner_under_16_sales.title", + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text", "arguments" => [ { "key" => "age#{person_index}", @@ -17,7 +18,10 @@ class Form::Sales::Pages::PartnerUnder16ValueCheck < Form::Sales::Pages::Person }, ], } - @informative_text = {} + @informative_text = { + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text", + "arguments" => [], + } end def questions diff --git a/app/models/form/sales/pages/person_age.rb b/app/models/form/sales/pages/person_age.rb index 82e958aca..af7daa606 100644 --- a/app/models/form/sales/pages/person_age.rb +++ b/app/models/form/sales/pages/person_age.rb @@ -1,6 +1,7 @@ class Form::Sales::Pages::PersonAge < Form::Sales::Pages::Person def initialize(id, hsh, subsection, person_index:) super + @copy_key = person_index == 2 ? "sales.household_characteristics.age2.person" : "sales.household_characteristics.age#{person_index}" @depends_on = [{ "details_known_#{person_index}" => 1 }] end diff --git a/app/models/form/sales/pages/person_gender_identity.rb b/app/models/form/sales/pages/person_gender_identity.rb index 7cc080fa4..f4673d1db 100644 --- a/app/models/form/sales/pages/person_gender_identity.rb +++ b/app/models/form/sales/pages/person_gender_identity.rb @@ -1,6 +1,7 @@ class Form::Sales::Pages::PersonGenderIdentity < Form::Sales::Pages::Person def initialize(id, hsh, subsection, person_index:) super + @copy_key = "sales.household_characteristics.sex2.person" if person_index == 2 @depends_on = [ { "details_known_#{person_index}" => 1 }, ] diff --git a/app/models/form/sales/pages/person_relationship_to_buyer_1.rb b/app/models/form/sales/pages/person_relationship_to_buyer_1.rb index 3967d57ea..8f09e50b6 100644 --- a/app/models/form/sales/pages/person_relationship_to_buyer_1.rb +++ b/app/models/form/sales/pages/person_relationship_to_buyer_1.rb @@ -1,6 +1,7 @@ class Form::Sales::Pages::PersonRelationshipToBuyer1 < ::Form::Sales::Pages::Person def initialize(id, hsh, subsection, person_index:) super + @copy_key = "sales.household_characteristics.relat2.person" if person_index == 2 @depends_on = [ { "details_known_#{person_index}" => 1 }, ] diff --git a/app/models/form/sales/pages/person_student_not_child_value_check.rb b/app/models/form/sales/pages/person_student_not_child_value_check.rb index a798c8e16..33448298c 100644 --- a/app/models/form/sales/pages/person_student_not_child_value_check.rb +++ b/app/models/form/sales/pages/person_student_not_child_value_check.rb @@ -6,11 +6,12 @@ class Form::Sales::Pages::PersonStudentNotChildValueCheck < Form::Sales::Pages:: "person_#{person_index}_student_not_child?" => true, }, ] + @copy_key = "sales.soft_validations.student_not_child_value_check" @person_index = person_index @title_text = { - "translation" => "soft_validations.student_not_child.title_text", + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text", } - @informative_text = {} + @informative_text = { "translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text", "arguments" => [] } end def questions diff --git a/app/models/form/sales/pages/person_working_situation.rb b/app/models/form/sales/pages/person_working_situation.rb index 488141ccf..5237d2827 100644 --- a/app/models/form/sales/pages/person_working_situation.rb +++ b/app/models/form/sales/pages/person_working_situation.rb @@ -1,6 +1,7 @@ class Form::Sales::Pages::PersonWorkingSituation < Form::Sales::Pages::Person def initialize(id, hsh, subsection, person_index:) super + @copy_key = "sales.household_characteristics.ecstat2.person" if person_index == 2 @depends_on = [ { "details_known_#{person_index}" => 1, diff --git a/app/models/form/sales/pages/privacy_notice.rb b/app/models/form/sales/pages/privacy_notice.rb index cf6a7bbbc..40c441d3e 100644 --- a/app/models/form/sales/pages/privacy_notice.rb +++ b/app/models/form/sales/pages/privacy_notice.rb @@ -1,7 +1,7 @@ class Form::Sales::Pages::PrivacyNotice < ::Form::Page def initialize(id, hsh, subsection, joint_purchase:) super(id, hsh, subsection) - @copy_key = "sales.setup.privacynotice.#{joint_purchase ? 'joint_purchase' : 'not_joint_purchase'}" + @copy_key = "sales.#{subsection.id}.privacynotice.#{joint_purchase ? 'joint_purchase' : 'not_joint_purchase'}" @joint_purchase = joint_purchase end diff --git a/app/models/form/sales/pages/retirement_value_check.rb b/app/models/form/sales/pages/retirement_value_check.rb index 9e5dbb87f..0f3e45559 100644 --- a/app/models/form/sales/pages/retirement_value_check.rb +++ b/app/models/form/sales/pages/retirement_value_check.rb @@ -7,8 +7,9 @@ class Form::Sales::Pages::RetirementValueCheck < Form::Sales::Pages::Person }, ] @person_index = person_index + @copy_key = "sales.soft_validations.retirement_value_check.min" @title_text = { - "translation" => "soft_validations.retirement.min.title", + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text", "arguments" => [ { "key" => "age#{person_index}", @@ -17,7 +18,10 @@ class Form::Sales::Pages::RetirementValueCheck < Form::Sales::Pages::Person }, ], } - @informative_text = {} + @informative_text = { + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text", + "arguments" => [], + } end def questions diff --git a/app/models/form/sales/questions/age1.rb b/app/models/form/sales/questions/age1.rb index 65a969c08..4722d0208 100644 --- a/app/models/form/sales/questions/age1.rb +++ b/app/models/form/sales/questions/age1.rb @@ -2,10 +2,9 @@ class Form::Sales::Questions::Age1 < ::Form::Question def initialize(id, hsh, page) super @id = "age1" - @check_answer_label = "Buyer 1’s age" - @header = "Age" @type = "numeric" @width = 2 + @copy_key = "sales.household_characteristics.age1.age1" @inferred_check_answers_value = [ { "condition" => { "age1_known" => 1 }, diff --git a/app/models/form/sales/questions/age2.rb b/app/models/form/sales/questions/age2.rb index 82deecbed..29d955291 100644 --- a/app/models/form/sales/questions/age2.rb +++ b/app/models/form/sales/questions/age2.rb @@ -2,8 +2,7 @@ class Form::Sales::Questions::Age2 < ::Form::Question def initialize(id, hsh, page) super @id = "age2" - @check_answer_label = "Buyer 2’s age" - @header = "Age" + @copy_key = "sales.household_characteristics.age2.buyer.age2" @type = "numeric" @width = 2 @inferred_check_answers_value = [{ diff --git a/app/models/form/sales/questions/buyer1_age_known.rb b/app/models/form/sales/questions/buyer1_age_known.rb index 2e38871eb..9f6da83ad 100644 --- a/app/models/form/sales/questions/buyer1_age_known.rb +++ b/app/models/form/sales/questions/buyer1_age_known.rb @@ -2,11 +2,9 @@ class Form::Sales::Questions::Buyer1AgeKnown < ::Form::Question def initialize(id, hsh, page) super @id = "age1_known" - @check_answer_label = "Buyer 1’s age" - @header = "Do you know buyer 1’s age?" @type = "radio" + @copy_key = "sales.household_characteristics.age1.age1_known" @answer_options = ANSWER_OPTIONS - @hint_text = "Buyer 1 is the person in the household who does the most paid work. If it’s a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest." @conditional_for = { "age1" => [0], } diff --git a/app/models/form/sales/questions/buyer1_ethnic_background_arab.rb b/app/models/form/sales/questions/buyer1_ethnic_background_arab.rb index fbaca62ca..12a4bd842 100644 --- a/app/models/form/sales/questions/buyer1_ethnic_background_arab.rb +++ b/app/models/form/sales/questions/buyer1_ethnic_background_arab.rb @@ -2,11 +2,9 @@ class Form::Sales::Questions::Buyer1EthnicBackgroundArab < ::Form::Question def initialize(id, hsh, page) super @id = "ethnic" - @check_answer_label = "Buyer 1’s ethnic background" - @header = "Which of the following best describes buyer 1’s Arab background?" + @copy_key = "sales.household_characteristics.ethnic.ethnic_background_arab" @type = "radio" @answer_options = ANSWER_OPTIONS - @hint_text = form.start_year_after_2024? ? "" : "Buyer 1 is the person in the household who does the most paid work. If it’s a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest." @check_answers_card_number = 1 @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end diff --git a/app/models/form/sales/questions/buyer1_ethnic_background_asian.rb b/app/models/form/sales/questions/buyer1_ethnic_background_asian.rb index 64cffb507..1b982e39c 100644 --- a/app/models/form/sales/questions/buyer1_ethnic_background_asian.rb +++ b/app/models/form/sales/questions/buyer1_ethnic_background_asian.rb @@ -2,11 +2,9 @@ class Form::Sales::Questions::Buyer1EthnicBackgroundAsian < ::Form::Question def initialize(id, hsh, page) super @id = "ethnic" - @check_answer_label = "Buyer 1’s ethnic background" - @header = "Which of the following best describes buyer 1’s Asian or Asian British background?" + @copy_key = "sales.household_characteristics.ethnic.ethnic_background_asian" @type = "radio" @answer_options = ANSWER_OPTIONS - @hint_text = form.start_year_after_2024? ? "" : "Buyer 1 is the person in the household who does the most paid work. If it’s a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest." @check_answers_card_number = 1 @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end diff --git a/app/models/form/sales/questions/buyer1_ethnic_background_black.rb b/app/models/form/sales/questions/buyer1_ethnic_background_black.rb index 41d951d71..fac93e0eb 100644 --- a/app/models/form/sales/questions/buyer1_ethnic_background_black.rb +++ b/app/models/form/sales/questions/buyer1_ethnic_background_black.rb @@ -2,11 +2,9 @@ class Form::Sales::Questions::Buyer1EthnicBackgroundBlack < ::Form::Question def initialize(id, hsh, page) super @id = "ethnic" - @check_answer_label = "Buyer 1’s ethnic background" - @header = "Which of the following best describes buyer 1’s Black, African, Caribbean or Black British background?" + @copy_key = "sales.household_characteristics.ethnic.ethnic_background_black" @type = "radio" @answer_options = ANSWER_OPTIONS - @hint_text = form.start_year_after_2024? ? "" : "Buyer 1 is the person in the household who does the most paid work. If it’s a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest." @check_answers_card_number = 1 @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end diff --git a/app/models/form/sales/questions/buyer1_ethnic_background_mixed.rb b/app/models/form/sales/questions/buyer1_ethnic_background_mixed.rb index 42506b70e..342490da3 100644 --- a/app/models/form/sales/questions/buyer1_ethnic_background_mixed.rb +++ b/app/models/form/sales/questions/buyer1_ethnic_background_mixed.rb @@ -2,11 +2,9 @@ class Form::Sales::Questions::Buyer1EthnicBackgroundMixed < ::Form::Question def initialize(id, hsh, page) super @id = "ethnic" - @check_answer_label = "Buyer 1’s ethnic background" - @header = "Which of the following best describes buyer 1’s Mixed or Multiple ethnic groups background?" + @copy_key = "sales.household_characteristics.ethnic.ethnic_background_mixed" @type = "radio" @answer_options = ANSWER_OPTIONS - @hint_text = form.start_year_after_2024? ? "" : "Buyer 1 is the person in the household who does the most paid work. If it’s a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest." @check_answers_card_number = 1 @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end diff --git a/app/models/form/sales/questions/buyer1_ethnic_background_white.rb b/app/models/form/sales/questions/buyer1_ethnic_background_white.rb index 6c8017fbf..2bbe4939f 100644 --- a/app/models/form/sales/questions/buyer1_ethnic_background_white.rb +++ b/app/models/form/sales/questions/buyer1_ethnic_background_white.rb @@ -2,10 +2,8 @@ class Form::Sales::Questions::Buyer1EthnicBackgroundWhite < ::Form::Question def initialize(id, hsh, page) super @id = "ethnic" - @check_answer_label = "Buyer 1’s ethnic background" - @header = "Which of the following best describes buyer 1’s White background?" + @copy_key = "sales.household_characteristics.ethnic.ethnic_background_white" @type = "radio" - @hint_text = form.start_year_after_2024? ? "" : "Buyer 1 is the person in the household who does the most paid work. If it’s a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest." @check_answers_card_number = 1 @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end diff --git a/app/models/form/sales/questions/buyer1_ethnic_group.rb b/app/models/form/sales/questions/buyer1_ethnic_group.rb index a3eec2474..9e67164cc 100644 --- a/app/models/form/sales/questions/buyer1_ethnic_group.rb +++ b/app/models/form/sales/questions/buyer1_ethnic_group.rb @@ -2,11 +2,8 @@ class Form::Sales::Questions::Buyer1EthnicGroup < ::Form::Question def initialize(id, hsh, page) super @id = "ethnic_group" - @check_answer_label = "Buyer 1’s ethnic group" - @header = "What is buyer 1’s ethnic group?" @type = "radio" @answer_options = ANSWER_OPTIONS - @hint_text = form.start_year_after_2024? ? "" : "Buyer 1 is the person in the household who does the most paid work. If it’s a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest." @check_answers_card_number = 1 @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end diff --git a/app/models/form/sales/questions/buyer1_live_in_property.rb b/app/models/form/sales/questions/buyer1_live_in_property.rb index 83dff6437..835cbe4a3 100644 --- a/app/models/form/sales/questions/buyer1_live_in_property.rb +++ b/app/models/form/sales/questions/buyer1_live_in_property.rb @@ -2,11 +2,8 @@ class Form::Sales::Questions::Buyer1LiveInProperty < ::Form::Question def initialize(id, hsh, page) super @id = "buy1livein" - @check_answer_label = "Will buyer 1 live in the property?" - @header = "Will buyer 1 live in the property?" @type = "radio" @answer_options = ANSWER_OPTIONS - @hint_text = form.start_year_after_2024? ? "" : "Buyer 1 is the person in the household who does the most paid work. If it’s a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest." @check_answers_card_number = 1 @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end diff --git a/app/models/form/sales/questions/buyer1_nationality.rb b/app/models/form/sales/questions/buyer1_nationality.rb index b0bedfbb4..9cd5f3eed 100644 --- a/app/models/form/sales/questions/buyer1_nationality.rb +++ b/app/models/form/sales/questions/buyer1_nationality.rb @@ -2,10 +2,7 @@ class Form::Sales::Questions::Buyer1Nationality < ::Form::Question def initialize(id, hsh, page) super @id = "national" - @check_answer_label = "Buyer 1’s nationality" - @header = "What is buyer 1’s nationality?" @type = "radio" - @hint_text = "Buyer 1 is the person in the household who does the most paid work. If it’s a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest." @answer_options = ANSWER_OPTIONS @check_answers_card_number = 1 @inferred_check_answers_value = [{ diff --git a/app/models/form/sales/questions/buyer1_working_situation.rb b/app/models/form/sales/questions/buyer1_working_situation.rb index 376367624..b00db033f 100644 --- a/app/models/form/sales/questions/buyer1_working_situation.rb +++ b/app/models/form/sales/questions/buyer1_working_situation.rb @@ -2,11 +2,8 @@ class Form::Sales::Questions::Buyer1WorkingSituation < ::Form::Question def initialize(id, hsh, page) super @id = "ecstat1" - @check_answer_label = "Buyer 1's working situation" - @header = "Which of these best describes buyer 1's working situation?" @type = "radio" @answer_options = ANSWER_OPTIONS - @hint_text = form.start_year_after_2024? ? "" : "Buyer 1 is the person in the household who does the most paid work. If it’s a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest." @check_answers_card_number = 1 @inferred_check_answers_value = [{ "condition" => { diff --git a/app/models/form/sales/questions/buyer2_age_known.rb b/app/models/form/sales/questions/buyer2_age_known.rb index 7123d3e5e..ecd6c91f0 100644 --- a/app/models/form/sales/questions/buyer2_age_known.rb +++ b/app/models/form/sales/questions/buyer2_age_known.rb @@ -2,8 +2,7 @@ class Form::Sales::Questions::Buyer2AgeKnown < ::Form::Question def initialize(id, hsh, page) super @id = "age2_known" - @check_answer_label = "Buyer 2’s age" - @header = "Do you know buyer 2’s age?" + @copy_key = "sales.household_characteristics.age2.buyer.age2_known" @type = "radio" @answer_options = ANSWER_OPTIONS @conditional_for = { diff --git a/app/models/form/sales/questions/buyer2_ethnic_background_arab.rb b/app/models/form/sales/questions/buyer2_ethnic_background_arab.rb index 5debc0257..e69ad5a9e 100644 --- a/app/models/form/sales/questions/buyer2_ethnic_background_arab.rb +++ b/app/models/form/sales/questions/buyer2_ethnic_background_arab.rb @@ -2,8 +2,7 @@ class Form::Sales::Questions::Buyer2EthnicBackgroundArab < ::Form::Question def initialize(id, hsh, page) super @id = "ethnicbuy2" - @check_answer_label = "Buyer 2’s ethnic background" - @header = "Which of the following best describes buyer 2’s Arab background?" + @copy_key = "sales.household_characteristics.ethnicbuy2.ethnic_background_arab" @type = "radio" @answer_options = ANSWER_OPTIONS @check_answers_card_number = 2 diff --git a/app/models/form/sales/questions/buyer2_ethnic_background_asian.rb b/app/models/form/sales/questions/buyer2_ethnic_background_asian.rb index eee32a4b2..8c31fc723 100644 --- a/app/models/form/sales/questions/buyer2_ethnic_background_asian.rb +++ b/app/models/form/sales/questions/buyer2_ethnic_background_asian.rb @@ -2,8 +2,7 @@ class Form::Sales::Questions::Buyer2EthnicBackgroundAsian < ::Form::Question def initialize(id, hsh, page) super @id = "ethnicbuy2" - @check_answer_label = "Buyer 2’s ethnic background" - @header = "Which of the following best describes buyer 2’s Asian or Asian British background?" + @copy_key = "sales.household_characteristics.ethnicbuy2.ethnic_background_asian" @type = "radio" @answer_options = ANSWER_OPTIONS @check_answers_card_number = 2 diff --git a/app/models/form/sales/questions/buyer2_ethnic_background_black.rb b/app/models/form/sales/questions/buyer2_ethnic_background_black.rb index 4fffd67ca..f44119251 100644 --- a/app/models/form/sales/questions/buyer2_ethnic_background_black.rb +++ b/app/models/form/sales/questions/buyer2_ethnic_background_black.rb @@ -2,8 +2,7 @@ class Form::Sales::Questions::Buyer2EthnicBackgroundBlack < ::Form::Question def initialize(id, hsh, page) super @id = "ethnicbuy2" - @check_answer_label = "Buyer 2’s ethnic background" - @header = "Which of the following best describes buyer 2’s Black, African, Caribbean or Black British background?" + @copy_key = "sales.household_characteristics.ethnicbuy2.ethnic_background_black" @type = "radio" @answer_options = ANSWER_OPTIONS @check_answers_card_number = 2 diff --git a/app/models/form/sales/questions/buyer2_ethnic_background_mixed.rb b/app/models/form/sales/questions/buyer2_ethnic_background_mixed.rb index d66e2e2aa..013ad100b 100644 --- a/app/models/form/sales/questions/buyer2_ethnic_background_mixed.rb +++ b/app/models/form/sales/questions/buyer2_ethnic_background_mixed.rb @@ -2,8 +2,7 @@ class Form::Sales::Questions::Buyer2EthnicBackgroundMixed < ::Form::Question def initialize(id, hsh, page) super @id = "ethnicbuy2" - @check_answer_label = "Buyer 2’s ethnic background" - @header = "Which of the following best describes buyer 2’s Mixed or Multiple ethnic groups background?" + @copy_key = "sales.household_characteristics.ethnicbuy2.ethnic_background_mixed" @type = "radio" @answer_options = ANSWER_OPTIONS @check_answers_card_number = 2 diff --git a/app/models/form/sales/questions/buyer2_ethnic_background_white.rb b/app/models/form/sales/questions/buyer2_ethnic_background_white.rb index 8af5b8641..232e0f99e 100644 --- a/app/models/form/sales/questions/buyer2_ethnic_background_white.rb +++ b/app/models/form/sales/questions/buyer2_ethnic_background_white.rb @@ -2,8 +2,7 @@ class Form::Sales::Questions::Buyer2EthnicBackgroundWhite < ::Form::Question def initialize(id, hsh, page) super @id = "ethnicbuy2" - @check_answer_label = "Buyer 2’s ethnic background" - @header = "Which of the following best describes buyer 2’s White background?" + @copy_key = "sales.household_characteristics.ethnicbuy2.ethnic_background_white" @type = "radio" @check_answers_card_number = 2 @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] diff --git a/app/models/form/sales/questions/buyer2_ethnic_group.rb b/app/models/form/sales/questions/buyer2_ethnic_group.rb index 16b5d7cd0..4613b9963 100644 --- a/app/models/form/sales/questions/buyer2_ethnic_group.rb +++ b/app/models/form/sales/questions/buyer2_ethnic_group.rb @@ -2,8 +2,6 @@ class Form::Sales::Questions::Buyer2EthnicGroup < ::Form::Question def initialize(id, hsh, page) super @id = "ethnic_group2" - @check_answer_label = "Buyer 2’s ethnic group" - @header = "What is buyer 2’s ethnic group?" @type = "radio" @answer_options = ANSWER_OPTIONS @check_answers_card_number = 2 diff --git a/app/models/form/sales/questions/buyer2_live_in_property.rb b/app/models/form/sales/questions/buyer2_live_in_property.rb index 93f5c3870..4d6aad8ba 100644 --- a/app/models/form/sales/questions/buyer2_live_in_property.rb +++ b/app/models/form/sales/questions/buyer2_live_in_property.rb @@ -2,8 +2,6 @@ class Form::Sales::Questions::Buyer2LiveInProperty < ::Form::Question def initialize(id, hsh, page) super @id = "buy2livein" - @check_answer_label = "Will buyer 2 live in the property?" - @header = "Will buyer 2 live in the property?" @type = "radio" @answer_options = ANSWER_OPTIONS @check_answers_card_number = 2 diff --git a/app/models/form/sales/questions/buyer2_nationality.rb b/app/models/form/sales/questions/buyer2_nationality.rb index 62f269e4a..c7e92d294 100644 --- a/app/models/form/sales/questions/buyer2_nationality.rb +++ b/app/models/form/sales/questions/buyer2_nationality.rb @@ -2,8 +2,6 @@ class Form::Sales::Questions::Buyer2Nationality < ::Form::Question def initialize(id, hsh, page) super @id = "nationalbuy2" - @check_answer_label = "Buyer 2’s nationality" - @header = "What is buyer 2’s nationality?" @type = "radio" @answer_options = ANSWER_OPTIONS @check_answers_card_number = 2 diff --git a/app/models/form/sales/questions/buyer2_relationship_to_buyer1.rb b/app/models/form/sales/questions/buyer2_relationship_to_buyer1.rb index f8acf75aa..3f0fc299c 100644 --- a/app/models/form/sales/questions/buyer2_relationship_to_buyer1.rb +++ b/app/models/form/sales/questions/buyer2_relationship_to_buyer1.rb @@ -2,8 +2,7 @@ class Form::Sales::Questions::Buyer2RelationshipToBuyer1 < ::Form::Question def initialize(id, hsh, page) super @id = "relat2" - @check_answer_label = "Buyer 2's relationship to buyer 1" - @header = "What is buyer 2's relationship to buyer 1?" + @copy_key = "sales.household_characteristics.relat2.buyer" @type = "radio" @answer_options = answer_options @check_answers_card_number = 2 diff --git a/app/models/form/sales/questions/buyer2_working_situation.rb b/app/models/form/sales/questions/buyer2_working_situation.rb index 54fcb5931..5356cb8e8 100644 --- a/app/models/form/sales/questions/buyer2_working_situation.rb +++ b/app/models/form/sales/questions/buyer2_working_situation.rb @@ -2,8 +2,7 @@ class Form::Sales::Questions::Buyer2WorkingSituation < ::Form::Question def initialize(id, hsh, page) super @id = "ecstat2" - @check_answer_label = "Buyer 2's working situation" - @header = "Which of these best describes buyer 2's working situation?" + @copy_key = "sales.household_characteristics.ecstat2.buyer" @type = "radio" @answer_options = ANSWER_OPTIONS @check_answers_card_number = 2 diff --git a/app/models/form/sales/questions/buyer_interview.rb b/app/models/form/sales/questions/buyer_interview.rb index 8b434d11c..b49b57807 100644 --- a/app/models/form/sales/questions/buyer_interview.rb +++ b/app/models/form/sales/questions/buyer_interview.rb @@ -2,7 +2,7 @@ class Form::Sales::Questions::BuyerInterview < ::Form::Question def initialize(id, hsh, page, joint_purchase:) super(id, hsh, page) @id = "noint" - @copy_key = "sales.setup.noint.#{joint_purchase ? 'joint_purchase' : 'not_joint_purchase'}" + @copy_key = "sales.#{subsection.id}.noint.#{joint_purchase ? 'joint_purchase' : 'not_joint_purchase'}" @type = "radio" @answer_options = ANSWER_OPTIONS @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] diff --git a/app/models/form/sales/questions/buyer_live_in_value_check.rb b/app/models/form/sales/questions/buyer_live_in_value_check.rb index a4209c38c..1526e1e6e 100644 --- a/app/models/form/sales/questions/buyer_live_in_value_check.rb +++ b/app/models/form/sales/questions/buyer_live_in_value_check.rb @@ -2,7 +2,7 @@ class Form::Sales::Questions::BuyerLiveInValueCheck < ::Form::Question def initialize(id, hsh, page, person_index:) super(id, hsh, page) @id = "buyer_livein_value_check" - @check_answer_label = "Buyer live in confirmation" + @copy_key = "sales.soft_validations.buyer_livein_value_check.buyer#{person_index}" @type = "interruption_screen" @answer_options = { "0" => { "value" => "Yes" }, @@ -19,6 +19,5 @@ class Form::Sales::Questions::BuyerLiveInValueCheck < ::Form::Question ], } @check_answers_card_number = person_index - @header = "Are you sure this is correct?" end end diff --git a/app/models/form/sales/questions/gender_identity1.rb b/app/models/form/sales/questions/gender_identity1.rb index e59ba355b..c82af4b91 100644 --- a/app/models/form/sales/questions/gender_identity1.rb +++ b/app/models/form/sales/questions/gender_identity1.rb @@ -2,8 +2,6 @@ class Form::Sales::Questions::GenderIdentity1 < ::Form::Question def initialize(id, hsh, page) super @id = "sex1" - @check_answer_label = "Buyer 1’s gender identity" - @header = "Which of these best describes buyer 1’s gender identity?" @type = "radio" @answer_options = ANSWER_OPTIONS @check_answers_card_number = 1 @@ -17,13 +15,5 @@ class Form::Sales::Questions::GenderIdentity1 < ::Form::Question "R" => { "value" => "Prefers not to say" }, }.freeze - def hint_text - if form.start_year_after_2024? - "This should be however they personally choose to identify from the options below. This may or may not be the same as their biological sex or the sex they were assigned at birth." - else - "Buyer 1 is the person in the household who does the most paid work. If it’s a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest." - end - end - QUESTION_NUMBER_FROM_YEAR = { 2023 => 21, 2024 => 23 }.freeze end diff --git a/app/models/form/sales/questions/gender_identity2.rb b/app/models/form/sales/questions/gender_identity2.rb index 110de6c3a..50545a796 100644 --- a/app/models/form/sales/questions/gender_identity2.rb +++ b/app/models/form/sales/questions/gender_identity2.rb @@ -2,9 +2,8 @@ class Form::Sales::Questions::GenderIdentity2 < ::Form::Question def initialize(id, hsh, page) super @id = "sex2" - @check_answer_label = "Buyer 2’s gender identity" - @header = "Which of these best describes buyer 2’s gender identity?" @type = "radio" + @copy_key = "sales.household_characteristics.sex2.buyer" @answer_options = ANSWER_OPTIONS @check_answers_card_number = 2 @inferred_check_answers_value = [{ @@ -23,11 +22,5 @@ class Form::Sales::Questions::GenderIdentity2 < ::Form::Question "R" => { "value" => "Buyer prefers not to say" }, }.freeze - def hint_text - return unless form.start_year_after_2024? - - "This should be however they personally choose to identify from the options below. This may or may not be the same as their biological sex or the sex they were assigned at birth." - end - QUESTION_NUMBER_FROM_YEAR = { 2023 => 29, 2024 => 31 }.freeze end diff --git a/app/models/form/sales/questions/multiple_partners_value_check.rb b/app/models/form/sales/questions/multiple_partners_value_check.rb index ce99438d0..06e3af3b3 100644 --- a/app/models/form/sales/questions/multiple_partners_value_check.rb +++ b/app/models/form/sales/questions/multiple_partners_value_check.rb @@ -2,7 +2,7 @@ class Form::Sales::Questions::MultiplePartnersValueCheck < ::Form::Question def initialize(id, hsh, page, person_index:) super(id, hsh, page) @id = "multiple_partners_value_check" - @check_answer_label = "Multiple partners confirmation" + @copy_key = "sales.soft_validations.multiple_partners_value_check" @type = "interruption_screen" @answer_options = { "0" => { "value" => "Yes" }, @@ -19,6 +19,5 @@ class Form::Sales::Questions::MultiplePartnersValueCheck < ::Form::Question ], } @check_answers_card_number = person_index - @header = "Are you sure this is correct?" end end diff --git a/app/models/form/sales/questions/nationality_all.rb b/app/models/form/sales/questions/nationality_all.rb index 68ef122bf..6dd3c19df 100644 --- a/app/models/form/sales/questions/nationality_all.rb +++ b/app/models/form/sales/questions/nationality_all.rb @@ -1,8 +1,6 @@ class Form::Sales::Questions::NationalityAll < ::Form::Question def initialize(id, hsh, page, buyer_index) super(id, hsh, page) - @check_answer_label = "Buyer #{buyer_index}’s nationality" - @header = "Enter a nationality" @type = "select" @answer_options = GlobalConstants::COUNTRIES_ANSWER_OPTIONS @check_answers_card_number = buyer_index diff --git a/app/models/form/sales/questions/nationality_all_group.rb b/app/models/form/sales/questions/nationality_all_group.rb index 86dcabc88..afbc5bf19 100644 --- a/app/models/form/sales/questions/nationality_all_group.rb +++ b/app/models/form/sales/questions/nationality_all_group.rb @@ -1,10 +1,7 @@ class Form::Sales::Questions::NationalityAllGroup < ::Form::Question def initialize(id, hsh, page, buyer_index) super(id, hsh, page) - @check_answer_label = "Buyer #{buyer_index}’s nationality" - @header = "What is buyer #{buyer_index}’s nationality?" @type = "radio" - @hint_text = "If buyer #{buyer_index} is a dual national of the United Kingdom and another country, enter United Kingdom. If they are a dual national of two other countries, the buyer should decide which country to enter." @answer_options = ANSWER_OPTIONS @check_answers_card_number = buyer_index @conditional_for = buyer_index == 1 ? { "nationality_all" => [12] } : { "nationality_all_buyer2" => [12] } diff --git a/app/models/form/sales/questions/not_retired_value_check.rb b/app/models/form/sales/questions/not_retired_value_check.rb index 58c95c1bb..86b85f294 100644 --- a/app/models/form/sales/questions/not_retired_value_check.rb +++ b/app/models/form/sales/questions/not_retired_value_check.rb @@ -2,7 +2,7 @@ class Form::Sales::Questions::NotRetiredValueCheck < ::Form::Question def initialize(id, hsh, page, person_index:) super(id, hsh, page) @id = "retirement_value_check" - @check_answer_label = "Retirement confirmation" + @copy_key = "sales.soft_validations.retirement_value_check.max" @type = "interruption_screen" @answer_options = { "0" => { "value" => "Yes" }, @@ -19,6 +19,5 @@ class Form::Sales::Questions::NotRetiredValueCheck < ::Form::Question ], } @check_answers_card_number = person_index - @header = "Are you sure this person isn't retired?" end end diff --git a/app/models/form/sales/questions/number_of_others_in_property.rb b/app/models/form/sales/questions/number_of_others_in_property.rb index fd498cebe..c10047da5 100644 --- a/app/models/form/sales/questions/number_of_others_in_property.rb +++ b/app/models/form/sales/questions/number_of_others_in_property.rb @@ -2,10 +2,8 @@ class Form::Sales::Questions::NumberOfOthersInProperty < ::Form::Question def initialize(id, hsh, page, joint_purchase:) super(id, hsh, page) @id = "hholdcount" - @check_answer_label = "Number of other people living in the property" - @header = "Besides the #{'buyer'.pluralize(joint_purchase ? 2 : 1)}, how many other people live or will live in the property?" + @copy_key = joint_purchase ? "sales.household_characteristics.hholdcount.joint_purchase" : "sales.household_characteristics.hholdcount.not_joint_purchase" @type = "numeric" - @hint_text = hint(joint_purchase) @width = 2 @min = 0 @max = 15 @@ -13,15 +11,5 @@ class Form::Sales::Questions::NumberOfOthersInProperty < ::Form::Question @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end -private - - def hint(joint_purchase) - if joint_purchase - "You can provide details for a maximum of 4 other people for a joint purchase." - else - "You can provide details for a maximum of 5 other people if there is only one buyer." - end - end - QUESTION_NUMBER_FROM_YEAR = { 2023 => 35, 2024 => 37 }.freeze end diff --git a/app/models/form/sales/questions/old_persons_shared_ownership_value_check.rb b/app/models/form/sales/questions/old_persons_shared_ownership_value_check.rb index c869dd3be..601e02ac2 100644 --- a/app/models/form/sales/questions/old_persons_shared_ownership_value_check.rb +++ b/app/models/form/sales/questions/old_persons_shared_ownership_value_check.rb @@ -2,8 +2,7 @@ class Form::Sales::Questions::OldPersonsSharedOwnershipValueCheck < ::Form::Ques def initialize(id, hsh, page) super @id = "old_persons_shared_ownership_value_check" - @check_answer_label = "Shared ownership confirmation" - @header = "Are you sure this is correct?" + @copy_key = "sales.soft_validations.old_persons_shared_ownership_value_check" @type = "interruption_screen" @answer_options = { "0" => { "value" => "Yes" }, diff --git a/app/models/form/sales/questions/partner_under_16_value_check.rb b/app/models/form/sales/questions/partner_under_16_value_check.rb index 4c147b7e5..cca2386fd 100644 --- a/app/models/form/sales/questions/partner_under_16_value_check.rb +++ b/app/models/form/sales/questions/partner_under_16_value_check.rb @@ -2,7 +2,7 @@ class Form::Sales::Questions::PartnerUnder16ValueCheck < ::Form::Question def initialize(id, hsh, page, person_index:) super(id, hsh, page) @id = "partner_under_16_value_check" - @check_answer_label = "Partner under 16 confirmation" + @copy_key = "sales.soft_validations.partner_under_16_value_check" @type = "interruption_screen" @answer_options = { "0" => { "value" => "Yes" }, @@ -19,6 +19,5 @@ class Form::Sales::Questions::PartnerUnder16ValueCheck < ::Form::Question ], } @check_answers_card_number = person_index - @header = "Are you sure this is correct?" end end diff --git a/app/models/form/sales/questions/person_age.rb b/app/models/form/sales/questions/person_age.rb index 9f3d9378f..1638f6103 100644 --- a/app/models/form/sales/questions/person_age.rb +++ b/app/models/form/sales/questions/person_age.rb @@ -1,9 +1,8 @@ class Form::Sales::Questions::PersonAge < ::Form::Question def initialize(id, hsh, page, person_index:) super(id, hsh, page) - @check_answer_label = "Person #{person_index}’s age" - @header = "Age" @type = "numeric" + @copy_key = person_index == 2 ? "sales.household_characteristics.age2.person.age2" : "sales.household_characteristics.age#{person_index}.age#{person_index}" @width = 3 @inferred_check_answers_value = [{ "condition" => { "age#{person_index}_known" => 1 }, @@ -27,10 +26,4 @@ class Form::Sales::Questions::PersonAge < ::Form::Question base_question_number + (4 * @person_index) end - - def hint_text - if form.start_year_after_2024? - "Answer 1 for children aged under 1 year old" - end - end end diff --git a/app/models/form/sales/questions/person_age_known.rb b/app/models/form/sales/questions/person_age_known.rb index b53724e67..ede210c80 100644 --- a/app/models/form/sales/questions/person_age_known.rb +++ b/app/models/form/sales/questions/person_age_known.rb @@ -1,10 +1,9 @@ class Form::Sales::Questions::PersonAgeKnown < ::Form::Question def initialize(id, hsh, page, person_index:) super(id, hsh, page) - @check_answer_label = "Person #{person_index}’s age known?" - @header = "Do you know person #{person_index}’s age?" @type = "radio" @answer_options = ANSWER_OPTIONS + @copy_key = person_index == 2 ? "sales.household_characteristics.age2.person.age2_known" : "sales.household_characteristics.age#{person_index}.age#{person_index}_known" @conditional_for = { "age#{person_index}" => [0], } diff --git a/app/models/form/sales/questions/person_gender_identity.rb b/app/models/form/sales/questions/person_gender_identity.rb index 8b1a0ff2b..44cf15a85 100644 --- a/app/models/form/sales/questions/person_gender_identity.rb +++ b/app/models/form/sales/questions/person_gender_identity.rb @@ -1,9 +1,8 @@ class Form::Sales::Questions::PersonGenderIdentity < ::Form::Question def initialize(id, hsh, page, person_index:) super(id, hsh, page) - @check_answer_label = "Person #{person_index}’s gender identity" - @header = "Which of these best describes Person #{person_index}’s gender identity?" @type = "radio" + @copy_key = "sales.household_characteristics.sex2.person" if person_index == 2 @answer_options = ANSWER_OPTIONS @check_answers_card_number = person_index @inferred_check_answers_value = [{ @@ -23,12 +22,6 @@ class Form::Sales::Questions::PersonGenderIdentity < ::Form::Question "R" => { "value" => "Person prefers not to say" }, }.freeze - def hint_text - return unless form.start_year_after_2024? - - "This should be however they personally choose to identify from the options below. This may or may not be the same as their biological sex or the sex they were assigned at birth." - end - def question_number base_question_number = case form.start_date.year when 2023 diff --git a/app/models/form/sales/questions/person_known.rb b/app/models/form/sales/questions/person_known.rb index d0de89044..e8a7122f8 100644 --- a/app/models/form/sales/questions/person_known.rb +++ b/app/models/form/sales/questions/person_known.rb @@ -1,8 +1,6 @@ class Form::Sales::Questions::PersonKnown < ::Form::Question def initialize(id, hsh, page, person_index:) super(id, hsh, page) - @check_answer_label = "Details known for person #{person_index}?" - @header = "Do you know the details for person #{person_index}?" @type = "radio" @answer_options = ANSWER_OPTIONS @check_answers_card_number = person_index diff --git a/app/models/form/sales/questions/person_relationship_to_buyer_1.rb b/app/models/form/sales/questions/person_relationship_to_buyer_1.rb index 3fe33cef0..af3f2a78b 100644 --- a/app/models/form/sales/questions/person_relationship_to_buyer_1.rb +++ b/app/models/form/sales/questions/person_relationship_to_buyer_1.rb @@ -1,9 +1,8 @@ class Form::Sales::Questions::PersonRelationshipToBuyer1 < ::Form::Question def initialize(id, hsh, page, person_index:) super(id, hsh, page) - @check_answer_label = "Person #{person_index}’s relationship to Buyer 1" - @header = "What is Person #{person_index}’s relationship to Buyer 1?" @type = "radio" + @copy_key = "sales.household_characteristics.relat2.person" if person_index == 2 @answer_options = answer_options @check_answers_card_number = person_index @inferred_check_answers_value = [{ diff --git a/app/models/form/sales/questions/person_student_not_child_value_check.rb b/app/models/form/sales/questions/person_student_not_child_value_check.rb index fba35d05b..c2ff55688 100644 --- a/app/models/form/sales/questions/person_student_not_child_value_check.rb +++ b/app/models/form/sales/questions/person_student_not_child_value_check.rb @@ -2,7 +2,7 @@ class Form::Sales::Questions::PersonStudentNotChildValueCheck < ::Form::Question def initialize(id, hsh, page, person_index:) super(id, hsh, page) @id = "student_not_child_value_check" - @check_answer_label = "Student not a child confirmation" + @copy_key = "sales.soft_validations.student_not_child_value_check" @type = "interruption_screen" @answer_options = { "0" => { "value" => "Yes" }, @@ -19,6 +19,5 @@ class Form::Sales::Questions::PersonStudentNotChildValueCheck < ::Form::Question ], } @check_answers_card_number = person_index - @header = "Are you sure this person is not a child?" end end diff --git a/app/models/form/sales/questions/person_working_situation.rb b/app/models/form/sales/questions/person_working_situation.rb index fd5506170..488a77092 100644 --- a/app/models/form/sales/questions/person_working_situation.rb +++ b/app/models/form/sales/questions/person_working_situation.rb @@ -1,9 +1,8 @@ class Form::Sales::Questions::PersonWorkingSituation < ::Form::Question def initialize(id, hsh, page, person_index:) super(id, hsh, page) - @check_answer_label = "Person #{person_index}’s working situation" - @header = "Which of these best describes Person #{person_index}’s working situation?" @type = "radio" + @copy_key = "sales.household_characteristics.ecstat2.person" if person_index == 2 @check_answers_card_number = person_index @inferred_check_answers_value = [{ "condition" => { diff --git a/app/models/form/sales/questions/privacy_notice.rb b/app/models/form/sales/questions/privacy_notice.rb index a9e737f0e..95921737f 100644 --- a/app/models/form/sales/questions/privacy_notice.rb +++ b/app/models/form/sales/questions/privacy_notice.rb @@ -2,7 +2,7 @@ class Form::Sales::Questions::PrivacyNotice < ::Form::Question def initialize(id, hsh, page, joint_purchase:) super(id, hsh, page) @id = "privacynotice" - @copy_key = "sales.setup.privacynotice.#{joint_purchase ? 'joint_purchase' : 'not_joint_purchase'}" + @copy_key = "sales.#{subsection.id}.privacynotice.#{joint_purchase ? 'joint_purchase' : 'not_joint_purchase'}" @type = "checkbox" @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] @joint_purchase = joint_purchase diff --git a/app/models/form/sales/questions/retirement_value_check.rb b/app/models/form/sales/questions/retirement_value_check.rb index 56573490e..6b8b10898 100644 --- a/app/models/form/sales/questions/retirement_value_check.rb +++ b/app/models/form/sales/questions/retirement_value_check.rb @@ -2,7 +2,7 @@ class Form::Sales::Questions::RetirementValueCheck < ::Form::Question def initialize(id, hsh, page, person_index:) super(id, hsh, page) @id = "retirement_value_check" - @check_answer_label = "Retirement confirmation" + @copy_key = "sales.soft_validations.retirement_value_check.min" @type = "interruption_screen" @answer_options = { "0" => { "value" => "Yes" }, @@ -19,6 +19,5 @@ class Form::Sales::Questions::RetirementValueCheck < ::Form::Question ], } @check_answers_card_number = person_index - @header = "Are you sure this person is retired?" end end diff --git a/config/locales/en.yml b/config/locales/en.yml index afa157034..5412c8b2b 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -724,30 +724,17 @@ Make sure these answers are correct." hint_text: "This is higher than we would expect." shared_ownership_deposit: title_text: "You told us that the %{mortgage_deposit_and_discount_error_fields} add up to %{mortgage_deposit_and_discount_total}." - old_persons_shared_ownership: - title_text: - one: "You told us the buyer is using the Older Persons Shared Ownership scheme." - two: "You told us the buyers are using the Older Persons Shared Ownership scheme." - hint_text: "At least one buyer must be aged 65 years and over to use this scheme." staircase_bought_seems_high: title_text: "You told us that %{percentage}% was bought in this staircasing transaction." hint_text: "Most staircasing transactions are less than 50%" monthly_charges_over_soft_max: title_text: "You told us that the monthly charges were %{mscharge}." hint_text: "This is higher than we would expect." - student_not_child: - title_text: "You told us this person is a student aged between 16 and 19." discounted_sale_value: title_text: "Mortgage, deposit, and grant total must equal %{value_with_discount}." informative_text: "Your given mortgage, deposit and grant total is %{mortgage_deposit_and_grant_total}." care_home_charges: title_text: "Care home charges should be provided if this is a care home accommodation." - buyer1_livein_wrong_for_ownership_type: - title_text: "You told us that buyer 1 will not live in the property." - hint_text: " For %{ownership_scheme} types, the buyer usually lives in the property." - buyer2_livein_wrong_for_ownership_type: - title_text: "You told us that buyer 2 will not live in the property." - hint_text: " For %{ownership_scheme} types, the buyer usually lives in the property." percentage_discount_value: title_text: "You told us that the percentage discount is %{discount}." hint_text: "This is higher than we would expect." @@ -783,12 +770,8 @@ Make sure these answers are correct." informative_text: "We could not find an address that matches your search. You can search again or continue to enter the address manually." partner_under_16_lettings: title: "You told us this person is aged %{age} years and has 'Partner' relationship to the lead tenant." - partner_under_16_sales: - title: "You told us this person is aged %{age} years and has 'Partner' relationship to buyer 1." multiple_partners_lettings: title: "You told us there are more than 1 persons with 'Partner' relationship to the lead tenant." - multiple_partners_sales: - title: "You told us there are more than 1 persons with 'Partner' relationship to buyer 1." devise: two_factor_authentication: diff --git a/config/locales/forms/2023/sales/household_characteristics.en.yml b/config/locales/forms/2023/sales/household_characteristics.en.yml new file mode 100644 index 000000000..a49a817dc --- /dev/null +++ b/config/locales/forms/2023/sales/household_characteristics.en.yml @@ -0,0 +1,357 @@ +en: + forms: + 2023: + sales: + household_characteristics: + noint: + joint_purchase: + page_header: "" + check_answer_label: "Buyers interviewed in person?" + hint_text: "You should still try to answer all questions even if the buyers weren’t interviewed in person" + question_text: "Were the buyers interviewed for any of the answers you will provide on this log?" + not_joint_purchase: + page_header: "" + check_answer_label: "Buyer interviewed in person?" + hint_text: "You should still try to answer all questions even if the buyer wasn’t interviewed in person" + question_text: "Was the buyer interviewed for any of the answers you will provide on this log?" + + privacynotice: + joint_purchase: + page_header: "" + check_answer_label: "Buyers have seen the privacy notice?" + hint_text: "" + question_text: "Declaration" + not_joint_purchase: + page_header: "" + check_answer_label: "Buyer has seen the privacy notice?" + hint_text: "" + question_text: "Declaration" + + age1: + page_header: "" + age1_known: + check_answer_label: "Buyer 1’s age" + hint_text: "Buyer 1 is the person in the household who does the most paid work. If it’s a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest." + question_text: "Do you know buyer 1’s age?" + age1: + check_answer_label: "Buyer 1’s age" + hint_text: "" + question_text: "Age" + + sex1: + page_header: "" + check_answer_label: "Buyer 1’s gender identity" + hint_text: "Buyer 1 is the person in the household who does the most paid work. If it’s a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest." + question_text: "Which of these best describes buyer 1’s gender identity?" + + ethnic_group: + page_header: "" + check_answer_label: "Buyer 1’s ethnic group" + hint_text: "Buyer 1 is the person in the household who does the most paid work. If it’s a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest." + question_text: "What is buyer 1’s ethnic group?" + + ethnic: + ethnic_background_black: + page_header: "" + check_answer_label: "Buyer 1’s ethnic background" + hint_text: "Buyer 1 is the person in the household who does the most paid work. If it’s a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest." + question_text: "Which of the following best describes buyer 1’s Black, African, Caribbean or Black British background?" + ethnic_background_asian: + page_header: "" + check_answer_label: "Buyer 1’s ethnic background" + hint_text: "Buyer 1 is the person in the household who does the most paid work. If it’s a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest." + question_text: "Which of the following best describes buyer 1’s Asian or Asian British background?" + ethnic_background_arab: + page_header: "" + check_answer_label: "Buyer 1’s ethnic background" + hint_text: "Buyer 1 is the person in the household who does the most paid work. If it’s a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest." + question_text: "Which of the following best describes buyer 1’s Arab background?" + ethnic_background_mixed: + page_header: "" + check_answer_label: "Buyer 1’s ethnic background" + hint_text: "Buyer 1 is the person in the household who does the most paid work. If it’s a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest." + question_text: "Which of the following best describes buyer 1’s Mixed or Multiple ethnic groups background?" + ethnic_background_white: + page_header: "" + check_answer_label: "Buyer 1’s ethnic background" + hint_text: "Buyer 1 is the person in the household who does the most paid work. If it’s a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest." + question_text: "Which of the following best describes buyer 1’s White background?" + + national: + page_header: "" + check_answer_label: "Buyer 1’s nationality" + hint_text: "Buyer 1 is the person in the household who does the most paid work. If it’s a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest." + question_text: "What is buyer 1’s nationality?" + + ecstat1: + page_header: "" + check_answer_label: "Buyer 1's working situation" + hint_text: "Buyer 1 is the person in the household who does the most paid work. If it’s a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest." + question_text: "Which of these best describes buyer 1's working situation?" + + buy1livein: + page_header: "" + check_answer_label: "Will buyer 1 live in the property?" + hint_text: "Buyer 1 is the person in the household who does the most paid work. If it’s a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest." + question_text: "Will buyer 1 live in the property?" + + relat2: + buyer: + page_header: "" + check_answer_label: "Buyer 2's relationship to buyer 1" + hint_text: "" + question_text: "What is buyer 2's relationship to buyer 1?" + person: + page_header: "" + check_answer_label: "Person 2’s relationship to Buyer 1" + hint_text: "" + question_text: "What is Person 2’s relationship to Buyer 1?" + + age2: + buyer: + page_header: "" + age2_known: + check_answer_label: "Buyer 2’s age" + hint_text: "" + question_text: "Do you know buyer 2’s age?" + age2: + check_answer_label: "Buyer 2’s age" + hint_text: "" + question_text: "Age" + person: + page_header: "" + age2_known: + check_answer_label: "Person 2’s age known?" + hint_text: "" + question_text: "Do you know person 2’s age?" + age: + check_answer_label: "Person 2’s age" + hint_text: "" + question_text: "Age" + + sex2: + buyer: + page_header: "" + check_answer_label: "Buyer 2’s gender identity" + hint_text: "" + question_text: "Which of these best describes buyer 2’s gender identity?" + person: + page_header: "" + check_answer_label: "Person 2’s gender identity" + hint_text: "" + question_text: "Which of these best describes Person 2’s gender identity?" + + ethnic_group2: + page_header: "" + check_answer_label: "Buyer 2’s ethnic group" + hint_text: "" + question_text: "What is buyer 2’s ethnic group?" + + ethnicbuy2: + ethnic_background_black: + page_header: "" + check_answer_label: "Buyer 2’s ethnic background" + hint_text: "" + question_text: "Which of the following best describes buyer 2’s Black, African, Caribbean or Black British background?" + ethnic_background_asian: + page_header: "" + check_answer_label: "Buyer 2’s ethnic background" + hint_text: "" + question_text: "Which of the following best describes buyer 2’s Asian or Asian British background?" + ethnic_background_arab: + page_header: "" + check_answer_label: "Buyer 2’s ethnic background" + hint_text: "" + question_text: "Which of the following best describes buyer 2’s Arab background?" + ethnic_background_mixed: + page_header: "" + check_answer_label: "Buyer 2’s ethnic background" + hint_text: "" + question_text: "Which of the following best describes buyer 2’s Mixed or Multiple ethnic groups background?" + ethnic_background_white: + page_header: "" + check_answer_label: "Buyer 2’s ethnic background" + hint_text: "" + question_text: "Which of the following best describes buyer 2’s White background?" + + nationalbuy2: + page_header: "" + check_answer_label: "Buyer 2’s nationality" + hint_text: "" + question_text: "What is buyer 2’s nationality?" + + ecstat2: + buyer: + page_header: "" + check_answer_label: "Buyer 2's working situation" + hint_text: "" + question_text: "Which of these best describes buyer 2's working situation?" + person: + page_header: "" + check_answer_label: "Person 2’s working situation" + hint_text: "" + question_text: "Which of these best describes Person 2’s working situation?" + + buy2livein: + page_header: "" + check_answer_label: "Will buyer 2 live in the property?" + hint_text: "" + question_text: "Will buyer 2 live in the property?" + + hholdcount: + joint_purchase: + page_header: "" + check_answer_label: "Number of other people living in the property" + hint_text: "You can provide details for a maximum of 4 other people for a joint purchase." + question_text: "Besides the buyers, how many other people live or will live in the property?" + not_joint_purchase: + page_header: "" + check_answer_label: "Number of other people living in the property" + hint_text: "You can provide details for a maximum of 5 other people if there is only one buyer." + question_text: "Besides the buyer, how many other people live or will live in the property?" + + details_known_2: + page_header: "" + check_answer_label: "Details known for person 2?" + hint_text: "" + question_text: "Do you know the details for person 2?" + + details_known_3: + page_header: "" + check_answer_label: "Details known for person 3?" + hint_text: "" + question_text: "Do you know the details for person 3?" + + relat3: + page_header: "" + check_answer_label: "Person 3’s relationship to Buyer 1" + hint_text: "" + question_text: "What is Person 3’s relationship to Buyer 1?" + + age3: + page_header: "" + age3_known: + check_answer_label: "Person 3’s age known?" + hint_text: "" + question_text: "Do you know person 3’s age?" + age3: + check_answer_label: "Person 3’s age" + hint_text: "" + question_text: "Age" + + sex3: + page_header: "" + check_answer_label: "Person 3’s gender identity" + hint_text: "" + question_text: "Which of these best describes Person 3’s gender identity?" + + ecstat3: + page_header: "" + check_answer_label: "Person 3’s working situation" + hint_text: "" + question_text: "Which of these best describes Person 3’s working situation?" + + details_known_4: + page_header: "" + check_answer_label: "Details known for person 4?" + hint_text: "" + question_text: "Do you know the details for person 4?" + + relat4: + page_header: "" + check_answer_label: "Person 4’s relationship to Buyer 1" + hint_text: "" + question_text: "What is Person 4’s relationship to Buyer 1?" + + age4: + page_header: "" + age4_known: + check_answer_label: "Person 4’s age known?" + hint_text: "" + question_text: "Do you know person 4’s age?" + age4: + check_answer_label: "Person 4’s age" + hint_text: "" + question_text: "Age" + + sex4: + page_header: "" + check_answer_label: "Person 4’s gender identity" + hint_text: "" + question_text: "Which of these best describes Person 4’s gender identity?" + + ecstat4: + page_header: "" + check_answer_label: "Person 4’s working situation" + hint_text: "" + question_text: "Which of these best describes Person 4’s working situation?" + + details_known_5: + page_header: "" + check_answer_label: "Details known for person 5?" + hint_text: "" + question_text: "Do you know the details for person 5?" + + relat5: + page_header: "" + check_answer_label: "Person 5’s relationship to Buyer 1" + hint_text: "" + question_text: "What is Person 5’s relationship to Buyer 1?" + + age5: + page_header: "" + age5_known: + check_answer_label: "Person 5’s age known?" + hint_text: "" + question_text: "Do you know person 5’s age?" + age5: + check_answer_label: "Person 5’s age" + hint_text: "" + question_text: "Age" + + sex5: + page_header: "" + check_answer_label: "Person 5’s gender identity" + hint_text: "" + question_text: "Which of these best describes Person 5’s gender identity?" + + ecstat5: + page_header: "" + check_answer_label: "Person 5’s working situation" + hint_text: "" + question_text: "Which of these best describes Person 5’s working situation?" + + details_known_6: + page_header: "" + check_answer_label: "Details known for person 6?" + hint_text: "" + question_text: "Do you know the details for person 6?" + + relat6: + page_header: "" + check_answer_label: "Person 6’s relationship to Buyer 1" + hint_text: "" + question_text: "What is Person 6’s relationship to Buyer 1?" + + age6: + page_header: "" + age6_known: + check_answer_label: "Person 6’s age known?" + hint_text: "" + question_text: "Do you know person 6’s age?" + age6: + check_answer_label: "Person 6’s age" + hint_text: "" + question_text: "Age" + + sex6: + page_header: "" + check_answer_label: "Person 6’s gender identity" + hint_text: "" + question_text: "Which of these best describes Person 6’s gender identity?" + + ecstat6: + page_header: "" + check_answer_label: "Person 6’s working situation" + hint_text: "" + question_text: "Which of these best describes Person 6’s working situation?" diff --git a/config/locales/forms/2023/sales/soft_validations.en.yml b/config/locales/forms/2023/sales/soft_validations.en.yml index a0912555a..3467b9432 100644 --- a/config/locales/forms/2023/sales/soft_validations.en.yml +++ b/config/locales/forms/2023/sales/soft_validations.en.yml @@ -3,25 +3,51 @@ en: 2023: sales: soft_validations: - income1_value_check: + retirement_value_check: + max: + page_header: "" + check_answer_label: "Retirement confirmation" + hint_text: "" + question_text: "Are you sure this person isn't retired?" + title_text: "You told us this person is over 66 and not retired." + informative_text: "The minimum expected retirement age in England is 66." + min: + page_header: "" + check_answer_label: "Retirement confirmation" + hint_text: "" + question_text: "Are you sure this person is retired?" + title_text: "You told us this person is aged %{age} years and retired." + informative_text: "The minimum expected retirement age in England is 66." + old_persons_shared_ownership_value_check: page_header: "" + check_answer_label: "Shared ownership confirmation" + hint_text: "" + question_text: "Are you sure this is correct?" + title_text: + joint_purchase: "You told us the buyers are using the Older Persons Shared Ownership scheme." + not_joint_purchase: "You told us the buyer is using the Older Persons Shared Ownership scheme." + informative_text: "At least one buyer must be aged 65 years and over to use this scheme." + income1_value_check: check_answer_label: "Buyer 1 income confirmation" hint_text: "" question_text: "Are you sure this is correct?" min: + page_header: "" title_text: "You told us income was %{income}." informative_text: "This is less than we would expect for someone in this working situation." max: + page_header: "" title_text: "You told us the income of buyer 1 is %{income}. This seems high. Are you sure this is correct?" income2_value_check: - page_header: "" check_answer_label: "Buyer 2 income confirmation" hint_text: "" question_text: "Are you sure this is correct?" min: + page_header: "" title_text: "You told us income was %{income}." informative_text: "This is less than we would expect for someone in this working situation." max: + page_header: "" title_text: "You told us the income of buyer 2 is %{income}. This seems high. Are you sure this is correct?" combined_income_value_check: page_header: "" @@ -64,3 +90,39 @@ en: hint_text: "" question_text: "You told us that someone in the household uses a wheelchair." title_text: "You told us that someone in the household uses a wheelchair." + buyer_livein_value_check: + buyer1: + page_header: "" + check_answer_label: "Buyer live in confirmation" + hint_text: "" + question_text: "Are you sure this is correct?" + title_text: "You told us that buyer 1 will not live in the property." + informative_text: "For %{ownership_scheme} types, the buyer usually lives in the property." + buyer2: + page_header: "" + check_answer_label: "Buyer live in confirmation" + hint_text: "" + question_text: "Are you sure this is correct?" + title_text: "You told us that buyer 2 will not live in the property." + informative_text: "For %{ownership_scheme} types, the buyer usually lives in the property." + student_not_child_value_check: + page_header: "" + check_answer_label: "Student not a child confirmation" + hint_text: "" + question_text: "Are you sure this person is not a child?" + title_text: "You told us this person is a student aged between 16 and 19." + informative_text: "Are you sure this person is not a child?" + partner_under_16_value_check: + page_header: "" + check_answer_label: "Partner under 16 confirmation" + hint_text: "" + question_text: "Are you sure this is correct?" + title_text: "You told us this person is aged %{age} years and has 'Partner' relationship to buyer 1." + informative_text: "Are you sure this is correct?" + multiple_partners_value_check: + page_header: "" + check_answer_label: "Multiple partners confirmation" + hint_text: "" + question_text: "Are you sure this is correct?" + title_text: "You told us there are more than 1 persons with 'Partner' relationship to buyer 1." + informative_text: "Are you sure this is correct?" diff --git a/config/locales/forms/2024/sales/household_characteristics.en.yml b/config/locales/forms/2024/sales/household_characteristics.en.yml new file mode 100644 index 000000000..22f9427e8 --- /dev/null +++ b/config/locales/forms/2024/sales/household_characteristics.en.yml @@ -0,0 +1,345 @@ +en: + forms: + 2024: + sales: + household_characteristics: + age1: + page_header: "" + age1_known: + check_answer_label: "Buyer 1’s age" + hint_text: "Buyer 1 is the person in the household who does the most paid work. If it’s a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest." + question_text: "Do you know buyer 1’s age?" + age1: + check_answer_label: "Buyer 1’s age" + hint_text: "" + question_text: "Age" + + sex1: + page_header: "" + check_answer_label: "Buyer 1’s gender identity" + hint_text: "This should be however they personally choose to identify from the options below. This may or may not be the same as their biological sex or the sex they were assigned at birth." + question_text: "Which of these best describes buyer 1’s gender identity?" + + ethnic_group: + page_header: "" + check_answer_label: "Buyer 1’s ethnic group" + hint_text: "" + question_text: "What is buyer 1’s ethnic group?" + + ethnic: + ethnic_background_black: + page_header: "" + check_answer_label: "Buyer 1’s ethnic background" + hint_text: "" + question_text: "Which of the following best describes buyer 1’s Black, African, Caribbean or Black British background?" + ethnic_background_asian: + page_header: "" + check_answer_label: "Buyer 1’s ethnic background" + hint_text: "" + question_text: "Which of the following best describes buyer 1’s Asian or Asian British background?" + ethnic_background_arab: + page_header: "" + check_answer_label: "Buyer 1’s ethnic background" + hint_text: "" + question_text: "Which of the following best describes buyer 1’s Arab background?" + ethnic_background_mixed: + page_header: "" + check_answer_label: "Buyer 1’s ethnic background" + hint_text: "" + question_text: "Which of the following best describes buyer 1’s Mixed or Multiple ethnic groups background?" + ethnic_background_white: + page_header: "" + check_answer_label: "Buyer 1’s ethnic background" + hint_text: "" + question_text: "Which of the following best describes buyer 1’s White background?" + + nationality_all_group: + page_header: "" + check_answer_label: "Buyer 1’s nationality" + hint_text: "If buyer 1 is a dual national of the United Kingdom and another country, enter United Kingdom. If they are a dual national of two other countries, the buyer should decide which country to enter." + question_text: "What is buyer 1’s nationality?" + + nationality_all: + page_header: "" + check_answer_label: "Buyer 1’s nationality" + hint_text: "" + question_text: "Enter a nationality" + + ecstat1: + page_header: "" + check_answer_label: "Buyer 1's working situation" + hint_text: "" + question_text: "Which of these best describes buyer 1's working situation?" + + buy1livein: + page_header: "" + check_answer_label: "Will buyer 1 live in the property?" + hint_text: "" + question_text: "Will buyer 1 live in the property?" + + relat2: + buyer: + page_header: "" + check_answer_label: "Buyer 2's relationship to buyer 1" + hint_text: "" + question_text: "What is buyer 2's relationship to buyer 1?" + person: + page_header: "" + check_answer_label: "Person 2’s relationship to Buyer 1" + hint_text: "" + question_text: "What is Person 2’s relationship to Buyer 1?" + + age2: + buyer: + page_header: "" + age2_known: + check_answer_label: "Buyer 2’s age" + hint_text: "" + question_text: "Do you know buyer 2’s age?" + age2: + check_answer_label: "Buyer 2’s age" + hint_text: "" + question_text: "Age" + person: + page_header: "" + age2_known: + check_answer_label: "Person 2’s age known?" + hint_text: "" + question_text: "Do you know person 2’s age?" + age2: + check_answer_label: "Person 2’s age" + hint_text: "" + question_text: "Age" + + sex2: + buyer: + page_header: "" + check_answer_label: "Buyer 2’s gender identity" + hint_text: "This should be however they personally choose to identify from the options below. This may or may not be the same as their biological sex or the sex they were assigned at birth." + question_text: "Which of these best describes buyer 2’s gender identity?" + person: + page_header: "" + check_answer_label: "Person 2’s gender identity" + hint_text: "This should be however they personally choose to identify from the options below. This may or may not be the same as their biological sex or the sex they were assigned at birth." + question_text: "Which of these best describes Person 2’s gender identity?" + + ethnic_group2: + page_header: "" + check_answer_label: "Buyer 2’s ethnic group" + hint_text: "" + question_text: "What is buyer 2’s ethnic group?" + + ethnicbuy2: + ethnic_background_black: + page_header: "" + check_answer_label: "Buyer 2’s ethnic background" + hint_text: "" + question_text: "Which of the following best describes buyer 2’s Black, African, Caribbean or Black British background?" + ethnic_background_asian: + page_header: "" + check_answer_label: "Buyer 2’s ethnic background" + hint_text: "" + question_text: "Which of the following best describes buyer 2’s Asian or Asian British background?" + ethnic_background_arab: + page_header: "" + check_answer_label: "Buyer 2’s ethnic background" + hint_text: "" + question_text: "Which of the following best describes buyer 2’s Arab background?" + ethnic_background_mixed: + page_header: "" + check_answer_label: "Buyer 2’s ethnic background" + hint_text: "" + question_text: "Which of the following best describes buyer 2’s Mixed or Multiple ethnic groups background?" + ethnic_background_white: + page_header: "" + check_answer_label: "Buyer 2’s ethnic background" + hint_text: "" + question_text: "Which of the following best describes buyer 2’s White background?" + + nationality_all_buyer2_group: + page_header: "" + check_answer_label: "Buyer 2’s nationality" + hint_text: "If buyer 1 is a dual national of the United Kingdom and another country, enter United Kingdom. If they are a dual national of two other countries, the buyer should decide which country to enter." + question_text: "What is buyer 2’s nationality?" + + nationality_all_buyer2: + page_header: "" + check_answer_label: "Buyer 2’s nationality" + hint_text: "" + question_text: "Enter a nationality" + + ecstat2: + buyer: + page_header: "" + check_answer_label: "Buyer 2's working situation" + hint_text: "" + question_text: "Which of these best describes buyer 2's working situation?" + person: + page_header: "" + check_answer_label: "Person 2’s working situation" + hint_text: "" + question_text: "Which of these best describes Person 2’s working situation?" + + buy2livein: + page_header: "" + check_answer_label: "Will buyer 2 live in the property?" + hint_text: "" + question_text: "Will buyer 2 live in the property?" + + hholdcount: + joint_purchase: + page_header: "" + check_answer_label: "Number of other people living in the property" + hint_text: "You can provide details for a maximum of 4 other people for a joint purchase." + question_text: "Besides the buyers, how many other people live or will live in the property?" + not_joint_purchase: + page_header: "" + check_answer_label: "Number of other people living in the property" + hint_text: "You can provide details for a maximum of 5 other people if there is only one buyer." + question_text: "Besides the buyer, how many other people live or will live in the property?" + + details_known_2: + page_header: "" + check_answer_label: "Details known for person 2?" + hint_text: "" + question_text: "Do you know the details for person 2?" + + details_known_3: + page_header: "" + check_answer_label: "Details known for person 3?" + hint_text: "" + question_text: "Do you know the details for person 3?" + + relat3: + page_header: "" + check_answer_label: "Person 3’s relationship to Buyer 1" + hint_text: "" + question_text: "What is Person 3’s relationship to Buyer 1?" + + age3: + page_header: "" + age3_known: + check_answer_label: "Person 3’s age known?" + hint_text: "" + question_text: "Do you know person 3’s age?" + age3: + check_answer_label: "Person 3’s age" + hint_text: "" + question_text: "Age" + + sex3: + page_header: "" + check_answer_label: "Person 3’s gender identity" + hint_text: "This should be however they personally choose to identify from the options below. This may or may not be the same as their biological sex or the sex they were assigned at birth." + question_text: "Which of these best describes Person 3’s gender identity?" + + ecstat3: + page_header: "" + check_answer_label: "Person 3’s working situation" + hint_text: "" + question_text: "Which of these best describes Person 3’s working situation?" + + details_known_4: + page_header: "" + check_answer_label: "Details known for person 4?" + hint_text: "" + question_text: "Do you know the details for person 4?" + + relat4: + page_header: "" + check_answer_label: "Person 4’s relationship to Buyer 1" + hint_text: "" + question_text: "What is Person 4’s relationship to Buyer 1?" + + age4: + page_header: "" + age4_known: + check_answer_label: "Person 4’s age known?" + hint_text: "" + question_text: "Do you know person 4’s age?" + age4: + check_answer_label: "Person 4’s age" + hint_text: "" + question_text: "Age" + + sex4: + page_header: "" + check_answer_label: "Person 4’s gender identity" + hint_text: "This should be however they personally choose to identify from the options below. This may or may not be the same as their biological sex or the sex they were assigned at birth." + question_text: "Which of these best describes Person 4’s gender identity?" + + ecstat4: + page_header: "" + check_answer_label: "Person 4’s working situation" + hint_text: "" + question_text: "Which of these best describes Person 4’s working situation?" + + details_known_5: + page_header: "" + check_answer_label: "Details known for person 5?" + hint_text: "" + question_text: "Do you know the details for person 5?" + + relat5: + page_header: "" + check_answer_label: "Person 5’s relationship to Buyer 1" + hint_text: "" + question_text: "What is Person 5’s relationship to Buyer 1?" + + age5: + page_header: "" + age5_known: + check_answer_label: "Person 5’s age known?" + hint_text: "" + question_text: "Do you know person 5’s age?" + age5: + check_answer_label: "Person 5’s age" + hint_text: "" + question_text: "Age" + + sex5: + page_header: "" + check_answer_label: "Person 5’s gender identity" + hint_text: "This should be however they personally choose to identify from the options below. This may or may not be the same as their biological sex or the sex they were assigned at birth." + question_text: "Which of these best describes Person 5’s gender identity?" + + ecstat5: + page_header: "" + check_answer_label: "Person 5’s working situation" + hint_text: "" + question_text: "Which of these best describes Person 5’s working situation?" + + details_known_6: + page_header: "" + check_answer_label: "Details known for person 6?" + hint_text: "" + question_text: "Do you know the details for person 6?" + + relat6: + page_header: "" + check_answer_label: "Person 6’s relationship to Buyer 1" + hint_text: "" + question_text: "What is Person 6’s relationship to Buyer 1?" + + age6: + page_header: "" + age6_known: + check_answer_label: "Person 6’s age known?" + hint_text: "" + question_text: "Do you know person 6’s age?" + age6: + check_answer_label: "Person 6’s age" + hint_text: "" + question_text: "Age" + + sex6: + page_header: "" + check_answer_label: "Person 6’s gender identity" + hint_text: "This should be however they personally choose to identify from the options below. This may or may not be the same as their biological sex or the sex they were assigned at birth." + question_text: "Which of these best describes Person 6’s gender identity?" + + ecstat6: + page_header: "" + check_answer_label: "Person 6’s working situation" + hint_text: "" + question_text: "Which of these best describes Person 6’s working situation?" diff --git a/config/locales/forms/2024/sales/soft_validations.en.yml b/config/locales/forms/2024/sales/soft_validations.en.yml index 2c7ac6e3e..39af6cb38 100644 --- a/config/locales/forms/2024/sales/soft_validations.en.yml +++ b/config/locales/forms/2024/sales/soft_validations.en.yml @@ -3,25 +3,51 @@ en: 2024: sales: soft_validations: - income1_value_check: + retirement_value_check: + max: + page_header: "" + check_answer_label: "Retirement confirmation" + hint_text: "" + question_text: "Are you sure this person isn't retired?" + title_text: "You told us this person is over 66 and not retired." + informative_text: "The minimum expected retirement age in England is 66." + min: + page_header: "" + check_answer_label: "Retirement confirmation" + hint_text: "" + question_text: "Are you sure this person is retired?" + title_text: "You told us this person is aged %{age} years and retired." + informative_text: "The minimum expected retirement age in England is 66." + old_persons_shared_ownership_value_check: page_header: "" + check_answer_label: "Shared ownership confirmation" + hint_text: "" + question_text: "Are you sure this is correct?" + title_text: + joint_purchase: "You told us the buyers are using the Older Persons Shared Ownership scheme." + not_joint_purchase: "You told us the buyer is using the Older Persons Shared Ownership scheme." + informative_text: "At least one buyer must be aged 65 years and over to use this scheme." + income1_value_check: check_answer_label: "Buyer 1 income confirmation" hint_text: "" question_text: "Are you sure this is correct?" min: + page_header: "" title_text: "You told us income was %{income}." informative_text: "This is less than we would expect for someone in this working situation." max: + page_header: "" title_text: "You told us the income of buyer 1 is %{income}. This seems high. Are you sure this is correct?" income2_value_check: - page_header: "" check_answer_label: "Buyer 2 income confirmation" hint_text: "" question_text: "Are you sure this is correct?" min: + page_header: "" title_text: "You told us income was %{income}." informative_text: "This is less than we would expect for someone in this working situation." max: + page_header: "" title_text: "You told us the income of buyer 2 is %{income}. This seems high. Are you sure this is correct?" combined_income_value_check: page_header: "" @@ -64,3 +90,39 @@ en: hint_text: "" question_text: "You told us that someone in the household uses a wheelchair." title_text: "You told us that someone in the household uses a wheelchair." + buyer_livein_value_check: + buyer1: + page_header: "" + check_answer_label: "Buyer live in confirmation" + hint_text: "" + question_text: "Are you sure this is correct?" + title_text: "You told us that buyer 1 will not live in the property." + informative_text: "For %{ownership_scheme} types, the buyer usually lives in the property." + buyer2: + page_header: "" + check_answer_label: "Buyer live in confirmation" + hint_text: "" + question_text: "Are you sure this is correct?" + title_text: "You told us that buyer 2 will not live in the property." + informative_text: "For %{ownership_scheme} types, the buyer usually lives in the property." + student_not_child_value_check: + page_header: "" + check_answer_label: "Student not a child confirmation" + hint_text: "" + question_text: "Are you sure this person is not a child?" + title_text: "You told us this person is a student aged between 16 and 19." + informative_text: "Are you sure this person is not a child?" + partner_under_16_value_check: + page_header: "" + check_answer_label: "Partner under 16 confirmation" + hint_text: "" + question_text: "Are you sure this is correct?" + title_text: "You told us this person is aged %{age} years and has 'Partner' relationship to buyer 1." + informative_text: "Are you sure this is correct?" + multiple_partners_value_check: + page_header: "" + check_answer_label: "Multiple partners confirmation" + hint_text: "" + question_text: "Are you sure this is correct?" + title_text: "You told us there are more than 1 persons with 'Partner' relationship to buyer 1." + informative_text: "Are you sure this is correct?" diff --git a/spec/models/form/sales/pages/buyer_interview_spec.rb b/spec/models/form/sales/pages/buyer_interview_spec.rb index ce72974e9..24704526d 100644 --- a/spec/models/form/sales/pages/buyer_interview_spec.rb +++ b/spec/models/form/sales/pages/buyer_interview_spec.rb @@ -5,7 +5,8 @@ RSpec.describe Form::Sales::Pages::BuyerInterview, type: :model do let(:page_id) { "buyer_interview" } let(:page_definition) { nil } - let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1))) } + let(:form) { instance_double(Form, start_date: Time.zone.local(2023, 4, 1), start_year_after_2024?: false) } + let(:subsection) { instance_double(Form::Subsection, form:, id: "setup") } it "has correct subsection" do expect(page.subsection).to eq(subsection) @@ -23,19 +24,43 @@ RSpec.describe Form::Sales::Pages::BuyerInterview, type: :model do expect(page.description).to be_nil end - context "when there are joint buyers" do - subject(:page) { described_class.new(page_id, page_definition, subsection, joint_purchase: true) } + context "when form is before 2024" do + let(:subsection) { instance_double(Form::Subsection, form:, id: "household_characteristics") } - it "has the expected copy_key" do - expect(page.copy_key).to eq("sales.setup.noint.joint_purchase") + context "when there are joint buyers" do + subject(:page) { described_class.new(page_id, page_definition, subsection, joint_purchase: true) } + + it "has the expected copy_key" do + expect(page.copy_key).to eq("sales.household_characteristics.noint.joint_purchase") + end + end + + context "when there is a single buyer" do + subject(:page) { described_class.new(page_id, page_definition, subsection, joint_purchase: false) } + + it "has the expected copy_key" do + expect(page.copy_key).to eq("sales.household_characteristics.noint.not_joint_purchase") + end end end - context "when there is a single buyer" do - subject(:page) { described_class.new(page_id, page_definition, subsection, joint_purchase: false) } + context "when form is after 2024" do + let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1), start_year_after_2024?: true) } + + context "when there are joint buyers" do + subject(:page) { described_class.new(page_id, page_definition, subsection, joint_purchase: true) } + + it "has the expected copy_key" do + expect(page.copy_key).to eq("sales.setup.noint.joint_purchase") + end + end + + context "when there is a single buyer" do + subject(:page) { described_class.new(page_id, page_definition, subsection, joint_purchase: false) } - it "has the expected copy_key" do - expect(page.copy_key).to eq("sales.setup.noint.not_joint_purchase") + it "has the expected copy_key" do + expect(page.copy_key).to eq("sales.setup.noint.not_joint_purchase") + end end end end diff --git a/spec/models/form/sales/pages/buyer_live_in_value_check_spec.rb b/spec/models/form/sales/pages/buyer_live_in_value_check_spec.rb index 4bce29312..72234b6d5 100644 --- a/spec/models/form/sales/pages/buyer_live_in_value_check_spec.rb +++ b/spec/models/form/sales/pages/buyer_live_in_value_check_spec.rb @@ -6,7 +6,8 @@ RSpec.describe Form::Sales::Pages::BuyerLiveInValueCheck, type: :model do let(:page_id) { "buyer_1_live_in_value_check" } let(:page_definition) { nil } let(:person_index) { 1 } - let(:subsection) { instance_double(Form::Subsection) } + let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) } + let(:subsection) { instance_double(Form::Subsection, form:) } it "has correct subsection" do expect(page.subsection).to eq(subsection) @@ -34,7 +35,7 @@ RSpec.describe Form::Sales::Pages::BuyerLiveInValueCheck, type: :model do it "has the correct title_text" do expect(page.title_text).to eq({ - "translation" => "soft_validations.buyer1_livein_wrong_for_ownership_type.title_text", + "translation" => "forms.2024.sales.soft_validations.buyer_livein_value_check.buyer1.title_text", "arguments" => [{ "key" => "ownership_scheme", "label" => false, "i18n_template" => "ownership_scheme" }], }) end @@ -56,7 +57,7 @@ RSpec.describe Form::Sales::Pages::BuyerLiveInValueCheck, type: :model do it "has the correct title_text" do expect(page.title_text).to eq({ - "translation" => "soft_validations.buyer2_livein_wrong_for_ownership_type.title_text", + "translation" => "forms.2024.sales.soft_validations.buyer_livein_value_check.buyer2.title_text", "arguments" => [{ "key" => "ownership_scheme", "label" => false, "i18n_template" => "ownership_scheme" }], }) end diff --git a/spec/models/form/sales/pages/multiple_partners_value_check_spec.rb b/spec/models/form/sales/pages/multiple_partners_value_check_spec.rb index 890a24e6a..e3ee322a5 100644 --- a/spec/models/form/sales/pages/multiple_partners_value_check_spec.rb +++ b/spec/models/form/sales/pages/multiple_partners_value_check_spec.rb @@ -4,7 +4,8 @@ RSpec.describe Form::Sales::Pages::MultiplePartnersValueCheck, type: :model do subject(:page) { described_class.new(page_id, page_definition, subsection, person_index:) } let(:page_definition) { nil } - let(:subsection) { instance_double(Form::Subsection) } + let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) } + let(:subsection) { instance_double(Form::Subsection, form:) } let(:person_index) { 1 } let(:page_id) { "multiple_partners_value_check" } @@ -39,13 +40,13 @@ RSpec.describe Form::Sales::Pages::MultiplePartnersValueCheck, type: :model do it "has correct title_text" do expect(page.title_text).to eq({ - "translation" => "soft_validations.multiple_partners_sales.title", + "translation" => "forms.2024.sales.soft_validations.multiple_partners_value_check.title_text", "arguments" => [], }) end it "has correct informative_text" do - expect(page.informative_text).to eq({}) + expect(page.informative_text).to eq({ "arguments" => [], "translation" => "forms.2024.sales.soft_validations.multiple_partners_value_check.informative_text" }) end it "has correct interruption_screen_question_ids" do @@ -71,13 +72,13 @@ RSpec.describe Form::Sales::Pages::MultiplePartnersValueCheck, type: :model do it "has correct title_text" do expect(page.title_text).to eq({ - "translation" => "soft_validations.multiple_partners_sales.title", + "translation" => "forms.2024.sales.soft_validations.multiple_partners_value_check.title_text", "arguments" => [], }) end it "has correct informative_text" do - expect(page.informative_text).to eq({}) + expect(page.informative_text).to eq({ "arguments" => [], "translation" => "forms.2024.sales.soft_validations.multiple_partners_value_check.informative_text" }) end it "has correct interruption_screen_question_ids" do diff --git a/spec/models/form/sales/pages/old_persons_shared_ownership_value_check_spec.rb b/spec/models/form/sales/pages/old_persons_shared_ownership_value_check_spec.rb index 8bc20cef7..19292db35 100644 --- a/spec/models/form/sales/pages/old_persons_shared_ownership_value_check_spec.rb +++ b/spec/models/form/sales/pages/old_persons_shared_ownership_value_check_spec.rb @@ -5,7 +5,8 @@ RSpec.describe Form::Sales::Pages::OldPersonsSharedOwnershipValueCheck, type: :m let(:page_id) { "old_persons_shared_ownership_value_check" } let(:page_definition) { nil } - let(:subsection) { instance_double(Form::Subsection) } + let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) } + let(:subsection) { instance_double(Form::Subsection, form:) } it "has correct subsection" do expect(page.subsection).to eq(subsection) @@ -34,13 +35,13 @@ RSpec.describe Form::Sales::Pages::OldPersonsSharedOwnershipValueCheck, type: :m it "has the correct title_text" do expect(page.title_text).to eq({ - "translation" => "soft_validations.old_persons_shared_ownership.title_text.one", + "translation" => "forms.2024.sales.soft_validations.old_persons_shared_ownership_value_check.title_text.not_joint_purchase", "arguments" => [], }) end it "has the correct informative_text" do - expect(page.informative_text).to eq({ "arguments" => [], "translation" => "soft_validations.old_persons_shared_ownership.hint_text" }) + expect(page.informative_text).to eq({ "arguments" => [], "translation" => "forms.2024.sales.soft_validations.old_persons_shared_ownership_value_check.informative_text" }) end it "has the correct interruption_screen_question_ids" do @@ -52,7 +53,7 @@ RSpec.describe Form::Sales::Pages::OldPersonsSharedOwnershipValueCheck, type: :m it "has the correct title_text" do expect(page.title_text).to eq({ - "translation" => "soft_validations.old_persons_shared_ownership.title_text.two", + "translation" => "forms.2024.sales.soft_validations.old_persons_shared_ownership_value_check.title_text.joint_purchase", "arguments" => [], }) end diff --git a/spec/models/form/sales/pages/partner_under16_value_check_spec.rb b/spec/models/form/sales/pages/partner_under16_value_check_spec.rb index fe11bdc86..5785ab900 100644 --- a/spec/models/form/sales/pages/partner_under16_value_check_spec.rb +++ b/spec/models/form/sales/pages/partner_under16_value_check_spec.rb @@ -4,7 +4,8 @@ RSpec.describe Form::Sales::Pages::PartnerUnder16ValueCheck, type: :model do subject(:page) { described_class.new(page_id, page_definition, subsection, person_index:) } let(:page_definition) { nil } - let(:subsection) { instance_double(Form::Subsection) } + let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) } + let(:subsection) { instance_double(Form::Subsection, form:) } let(:person_index) { 1 } let(:page_id) { "partner_under_16_value_check" } @@ -39,7 +40,7 @@ RSpec.describe Form::Sales::Pages::PartnerUnder16ValueCheck, type: :model do it "has correct title_text" do expect(page.title_text).to eq({ - "translation" => "soft_validations.partner_under_16_sales.title", + "translation" => "forms.2024.sales.soft_validations.partner_under_16_value_check.title_text", "arguments" => [ { "key" => "age1", @@ -51,7 +52,7 @@ RSpec.describe Form::Sales::Pages::PartnerUnder16ValueCheck, type: :model do end it "has correct informative_text" do - expect(page.informative_text).to eq({}) + expect(page.informative_text).to eq({ "arguments" => [], "translation" => "forms.2024.sales.soft_validations.partner_under_16_value_check.informative_text" }) end it "has correct interruption_screen_question_ids" do @@ -77,7 +78,7 @@ RSpec.describe Form::Sales::Pages::PartnerUnder16ValueCheck, type: :model do it "has correct title_text" do expect(page.title_text).to eq({ - "translation" => "soft_validations.partner_under_16_sales.title", + "translation" => "forms.2024.sales.soft_validations.partner_under_16_value_check.title_text", "arguments" => [ { "key" => "age2", @@ -89,7 +90,7 @@ RSpec.describe Form::Sales::Pages::PartnerUnder16ValueCheck, type: :model do end it "has correct informative_text" do - expect(page.informative_text).to eq({}) + expect(page.informative_text).to eq({ "arguments" => [], "translation" => "forms.2024.sales.soft_validations.partner_under_16_value_check.informative_text" }) end it "has correct interruption_screen_question_ids" do @@ -115,7 +116,7 @@ RSpec.describe Form::Sales::Pages::PartnerUnder16ValueCheck, type: :model do it "has correct title_text" do expect(page.title_text).to eq({ - "translation" => "soft_validations.partner_under_16_sales.title", + "translation" => "forms.2024.sales.soft_validations.partner_under_16_value_check.title_text", "arguments" => [ { "key" => "age3", @@ -127,7 +128,7 @@ RSpec.describe Form::Sales::Pages::PartnerUnder16ValueCheck, type: :model do end it "has correct informative_text" do - expect(page.informative_text).to eq({}) + expect(page.informative_text).to eq({ "arguments" => [], "translation" => "forms.2024.sales.soft_validations.partner_under_16_value_check.informative_text" }) end it "has correct interruption_screen_question_ids" do @@ -153,7 +154,7 @@ RSpec.describe Form::Sales::Pages::PartnerUnder16ValueCheck, type: :model do it "has correct title_text" do expect(page.title_text).to eq({ - "translation" => "soft_validations.partner_under_16_sales.title", + "translation" => "forms.2024.sales.soft_validations.partner_under_16_value_check.title_text", "arguments" => [ { "key" => "age4", @@ -165,7 +166,7 @@ RSpec.describe Form::Sales::Pages::PartnerUnder16ValueCheck, type: :model do end it "has correct informative_text" do - expect(page.informative_text).to eq({}) + expect(page.informative_text).to eq({ "arguments" => [], "translation" => "forms.2024.sales.soft_validations.partner_under_16_value_check.informative_text" }) end it "has correct interruption_screen_question_ids" do @@ -191,7 +192,7 @@ RSpec.describe Form::Sales::Pages::PartnerUnder16ValueCheck, type: :model do it "has correct title_text" do expect(page.title_text).to eq({ - "translation" => "soft_validations.partner_under_16_sales.title", + "translation" => "forms.2024.sales.soft_validations.partner_under_16_value_check.title_text", "arguments" => [ { "key" => "age5", @@ -203,7 +204,7 @@ RSpec.describe Form::Sales::Pages::PartnerUnder16ValueCheck, type: :model do end it "has correct informative_text" do - expect(page.informative_text).to eq({}) + expect(page.informative_text).to eq({ "arguments" => [], "translation" => "forms.2024.sales.soft_validations.partner_under_16_value_check.informative_text" }) end it "has correct interruption_screen_question_ids" do @@ -229,7 +230,7 @@ RSpec.describe Form::Sales::Pages::PartnerUnder16ValueCheck, type: :model do it "has correct title_text" do expect(page.title_text).to eq({ - "translation" => "soft_validations.partner_under_16_sales.title", + "translation" => "forms.2024.sales.soft_validations.partner_under_16_value_check.title_text", "arguments" => [ { "key" => "age6", @@ -241,7 +242,7 @@ RSpec.describe Form::Sales::Pages::PartnerUnder16ValueCheck, type: :model do end it "has correct informative_text" do - expect(page.informative_text).to eq({}) + expect(page.informative_text).to eq({ "arguments" => [], "translation" => "forms.2024.sales.soft_validations.partner_under_16_value_check.informative_text" }) end it "has correct interruption_screen_question_ids" do diff --git a/spec/models/form/sales/pages/person_student_not_child_value_check_spec.rb b/spec/models/form/sales/pages/person_student_not_child_value_check_spec.rb index 9185f9f1c..43ba0af49 100644 --- a/spec/models/form/sales/pages/person_student_not_child_value_check_spec.rb +++ b/spec/models/form/sales/pages/person_student_not_child_value_check_spec.rb @@ -4,7 +4,8 @@ RSpec.describe Form::Sales::Pages::PersonStudentNotChildValueCheck, type: :model subject(:page) { described_class.new(page_id, page_definition, subsection, person_index:) } let(:page_definition) { nil } - let(:subsection) { instance_double(Form::Subsection) } + let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) } + let(:subsection) { instance_double(Form::Subsection, form:) } let(:person_index) { 2 } let(:page_id) { "person_2_student_not_child_value_check" } @@ -23,12 +24,12 @@ RSpec.describe Form::Sales::Pages::PersonStudentNotChildValueCheck, type: :model it "has correct title_text" do expect(page.title_text).to eq({ - "translation" => "soft_validations.student_not_child.title_text", + "translation" => "forms.2024.sales.soft_validations.student_not_child_value_check.title_text", }) end it "has correct informative_text" do - expect(page.informative_text).to eq({}) + expect(page.informative_text).to eq({ "arguments" => [], "translation" => "forms.2024.sales.soft_validations.student_not_child_value_check.informative_text" }) end it "has correct questions" do diff --git a/spec/models/form/sales/pages/privacy_notice_spec.rb b/spec/models/form/sales/pages/privacy_notice_spec.rb index 1d146f0af..7510e60d9 100644 --- a/spec/models/form/sales/pages/privacy_notice_spec.rb +++ b/spec/models/form/sales/pages/privacy_notice_spec.rb @@ -5,12 +5,11 @@ RSpec.describe Form::Sales::Pages::PrivacyNotice, type: :model do let(:page_id) { "privacy_notice" } let(:page_definition) { nil } - let(:subsection) { instance_double(Form::Subsection) } - let(:form) { instance_double(Form, start_date: Time.zone.local(2023, 4, 1)) } + let(:subsection) { instance_double(Form::Subsection, id: "setup") } + let(:form) { instance_double(Form, start_date: Time.zone.local(2023, 4, 1), start_year_after_2024?: false) } before do allow(subsection).to receive(:form).and_return(form) - allow(form).to receive(:start_year_after_2024?) end it "has correct subsection" do @@ -32,8 +31,20 @@ RSpec.describe Form::Sales::Pages::PrivacyNotice, type: :model do context "when there are joint buyers" do subject(:page) { described_class.new(page_id, page_definition, subsection, joint_purchase: true) } - it "has the expected copy_key" do - expect(page.copy_key).to eq("sales.setup.privacynotice.joint_purchase") + context "when the form start year is before 2024" do + let(:subsection) { instance_double(Form::Subsection, id: "household_characteristics") } + + it "has the expected copy_key" do + expect(page.copy_key).to eq("sales.household_characteristics.privacynotice.joint_purchase") + end + end + + context "when the form start year is after 2024" do + let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1), start_year_after_2024?: true) } + + it "has the expected copy_key" do + expect(page.copy_key).to eq("sales.setup.privacynotice.joint_purchase") + end end it "has correct depends_on" do @@ -44,8 +55,20 @@ RSpec.describe Form::Sales::Pages::PrivacyNotice, type: :model do context "when there is a single buyer" do subject(:page) { described_class.new(page_id, page_definition, subsection, joint_purchase: false) } - it "has the expected copy_key" do - expect(page.copy_key).to eq("sales.setup.privacynotice.not_joint_purchase") + context "when the form start year is before 2024" do + let(:subsection) { instance_double(Form::Subsection, id: "household_characteristics") } + + it "has the expected copy_key" do + expect(page.copy_key).to eq("sales.household_characteristics.privacynotice.not_joint_purchase") + end + end + + context "when the form start year is after 2024" do + let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1), start_year_after_2024?: true) } + + it "has the expected copy_key" do + expect(page.copy_key).to eq("sales.setup.privacynotice.not_joint_purchase") + end end it "has correct depends_on" do diff --git a/spec/models/form/sales/pages/retirement_value_check_spec.rb b/spec/models/form/sales/pages/retirement_value_check_spec.rb index 6df7a379b..e316250b5 100644 --- a/spec/models/form/sales/pages/retirement_value_check_spec.rb +++ b/spec/models/form/sales/pages/retirement_value_check_spec.rb @@ -4,7 +4,8 @@ RSpec.describe Form::Sales::Pages::RetirementValueCheck, type: :model do subject(:page) { described_class.new(page_id, page_definition, subsection, person_index:) } let(:page_definition) { nil } - let(:subsection) { instance_double(Form::Subsection) } + let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) } + let(:subsection) { instance_double(Form::Subsection, form:) } let(:person_index) { 1 } let(:page_id) { "person_1_retirement_value_check" } @@ -39,7 +40,7 @@ RSpec.describe Form::Sales::Pages::RetirementValueCheck, type: :model do it "has correct title_text" do expect(page.title_text).to eq({ - "translation" => "soft_validations.retirement.min.title", + "translation" => "forms.2024.sales.soft_validations.retirement_value_check.min.title_text", "arguments" => [ { "key" => "age1", @@ -51,7 +52,7 @@ RSpec.describe Form::Sales::Pages::RetirementValueCheck, type: :model do end it "has correct informative_text" do - expect(page.informative_text).to eq({}) + expect(page.informative_text).to eq({ "arguments" => [], "translation" => "forms.2024.sales.soft_validations.retirement_value_check.min.informative_text" }) end it "has correct interruption_screen_question_ids" do @@ -77,7 +78,7 @@ RSpec.describe Form::Sales::Pages::RetirementValueCheck, type: :model do it "has correct title_text" do expect(page.title_text).to eq({ - "translation" => "soft_validations.retirement.min.title", + "translation" => "forms.2024.sales.soft_validations.retirement_value_check.min.title_text", "arguments" => [ { "key" => "age2", @@ -89,7 +90,7 @@ RSpec.describe Form::Sales::Pages::RetirementValueCheck, type: :model do end it "has correct informative_text" do - expect(page.informative_text).to eq({}) + expect(page.informative_text).to eq({ "arguments" => [], "translation" => "forms.2024.sales.soft_validations.retirement_value_check.min.informative_text" }) end it "has correct interruption_screen_question_ids" do @@ -115,7 +116,7 @@ RSpec.describe Form::Sales::Pages::RetirementValueCheck, type: :model do it "has correct title_text" do expect(page.title_text).to eq({ - "translation" => "soft_validations.retirement.min.title", + "translation" => "forms.2024.sales.soft_validations.retirement_value_check.min.title_text", "arguments" => [ { "key" => "age3", @@ -127,7 +128,7 @@ RSpec.describe Form::Sales::Pages::RetirementValueCheck, type: :model do end it "has correct informative_text" do - expect(page.informative_text).to eq({}) + expect(page.informative_text).to eq({ "arguments" => [], "translation" => "forms.2024.sales.soft_validations.retirement_value_check.min.informative_text" }) end it "has correct interruption_screen_question_ids" do @@ -153,7 +154,7 @@ RSpec.describe Form::Sales::Pages::RetirementValueCheck, type: :model do it "has correct title_text" do expect(page.title_text).to eq({ - "translation" => "soft_validations.retirement.min.title", + "translation" => "forms.2024.sales.soft_validations.retirement_value_check.min.title_text", "arguments" => [ { "key" => "age4", @@ -165,7 +166,7 @@ RSpec.describe Form::Sales::Pages::RetirementValueCheck, type: :model do end it "has correct informative_text" do - expect(page.informative_text).to eq({}) + expect(page.informative_text).to eq({ "arguments" => [], "translation" => "forms.2024.sales.soft_validations.retirement_value_check.min.informative_text" }) end it "has correct interruption_screen_question_ids" do @@ -191,7 +192,7 @@ RSpec.describe Form::Sales::Pages::RetirementValueCheck, type: :model do it "has correct title_text" do expect(page.title_text).to eq({ - "translation" => "soft_validations.retirement.min.title", + "translation" => "forms.2024.sales.soft_validations.retirement_value_check.min.title_text", "arguments" => [ { "key" => "age5", @@ -203,7 +204,7 @@ RSpec.describe Form::Sales::Pages::RetirementValueCheck, type: :model do end it "has correct informative_text" do - expect(page.informative_text).to eq({}) + expect(page.informative_text).to eq({ "arguments" => [], "translation" => "forms.2024.sales.soft_validations.retirement_value_check.min.informative_text" }) end it "has correct interruption_screen_question_ids" do @@ -229,7 +230,7 @@ RSpec.describe Form::Sales::Pages::RetirementValueCheck, type: :model do it "has correct title_text" do expect(page.title_text).to eq({ - "translation" => "soft_validations.retirement.min.title", + "translation" => "forms.2024.sales.soft_validations.retirement_value_check.min.title_text", "arguments" => [ { "key" => "age6", @@ -241,7 +242,7 @@ RSpec.describe Form::Sales::Pages::RetirementValueCheck, type: :model do end it "has correct informative_text" do - expect(page.informative_text).to eq({}) + expect(page.informative_text).to eq({ "arguments" => [], "translation" => "forms.2024.sales.soft_validations.retirement_value_check.min.informative_text" }) end it "has correct interruption_screen_question_ids" do diff --git a/spec/models/form/sales/questions/buyer_interview_spec.rb b/spec/models/form/sales/questions/buyer_interview_spec.rb index 3370a84f5..e2b39c50f 100644 --- a/spec/models/form/sales/questions/buyer_interview_spec.rb +++ b/spec/models/form/sales/questions/buyer_interview_spec.rb @@ -5,7 +5,8 @@ RSpec.describe Form::Sales::Questions::BuyerInterview, type: :model do let(:question_id) { nil } let(:question_definition) { nil } - let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1)))) } + let(:form) { instance_double(Form, start_date: Time.zone.local(2023, 4, 1), start_year_after_2024?: true) } + let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form:, id: "setup")) } it "has correct page" do expect(question.page).to eq(page) @@ -33,16 +34,42 @@ RSpec.describe Form::Sales::Questions::BuyerInterview, type: :model do context "when there are joint buyers" do subject(:question) { described_class.new(question_id, question_definition, page, joint_purchase: true) } - it "has the expected copy_key" do - expect(question.copy_key).to eq("sales.setup.noint.joint_purchase") + context "when the form start year is before 2024" do + let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form:, id: "household_characteristics")) } + let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 3, 1), start_year_after_2024?: false) } + + it "has the expected copy_key" do + expect(question.copy_key).to eq("sales.household_characteristics.noint.joint_purchase") + end + end + + context "when the form start year is after 2024" do + let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1), start_year_after_2024?: true) } + + it "has the expected copy_key" do + expect(question.copy_key).to eq("sales.setup.noint.joint_purchase") + end end end context "when there is a single buyer" do subject(:question) { described_class.new(question_id, question_definition, page, joint_purchase: false) } - it "has the expected copy_key" do - expect(question.copy_key).to eq("sales.setup.noint.not_joint_purchase") + context "when the form start year is before 2024" do + let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form:, id: "household_characteristics")) } + let(:form) { instance_double(Form, start_date: Time.zone.local(2023, 4, 1), start_year_after_2024?: false) } + + it "has the expected copy_key" do + expect(question.copy_key).to eq("sales.household_characteristics.noint.not_joint_purchase") + end + end + + context "when the form start year is after 2024" do + let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1), start_year_after_2024?: true) } + + it "has the expected copy_key" do + expect(question.copy_key).to eq("sales.setup.noint.not_joint_purchase") + end end end end diff --git a/spec/models/form/sales/questions/privacy_notice_spec.rb b/spec/models/form/sales/questions/privacy_notice_spec.rb index 11589049d..48de6056f 100644 --- a/spec/models/form/sales/questions/privacy_notice_spec.rb +++ b/spec/models/form/sales/questions/privacy_notice_spec.rb @@ -6,7 +6,7 @@ RSpec.describe Form::Sales::Questions::PrivacyNotice, type: :model do let(:question_id) { nil } let(:question_definition) { nil } let(:page) { instance_double(Form::Page) } - let(:subsection) { instance_double(Form::Subsection) } + let(:subsection) { instance_double(Form::Subsection, id: "setup") } let(:form) { instance_double(Form, start_date: Time.zone.local(2023, 4, 1)) } before do @@ -31,23 +31,9 @@ RSpec.describe Form::Sales::Questions::PrivacyNotice, type: :model do expect(question.derived?(nil)).to be false end - context "when there are joint buyers" do - subject(:question) { described_class.new(question_id, question_definition, page, joint_purchase: true) } - - it "has the expected copy_key" do - expect(question.copy_key).to eq("sales.setup.privacynotice.joint_purchase") - end - end - - context "when there is a single buyer" do - subject(:question) { described_class.new(question_id, question_definition, page, joint_purchase: false) } - - it "has the expected copy_key" do - expect(question.copy_key).to eq("sales.setup.privacynotice.not_joint_purchase") - end - end - context "when the form year is before 2024" do + let(:subsection) { instance_double(Form::Subsection, id: "household_characteristics") } + before do allow(form).to receive(:start_year_after_2024?).and_return(false) end @@ -66,6 +52,10 @@ RSpec.describe Form::Sales::Questions::PrivacyNotice, type: :model do it "returns correct unanswered_error_message" do expect(question.unanswered_error_message).to eq("You must show the MHCLG privacy notice to the buyer before you can submit this log.") end + + it "has the expected copy_key" do + expect(question.copy_key).to eq("sales.household_characteristics.privacynotice.not_joint_purchase") + end end context "and there are joint buyers" do @@ -84,6 +74,10 @@ RSpec.describe Form::Sales::Questions::PrivacyNotice, type: :model do it "returns correct unanswered_error_message" do expect(question.unanswered_error_message).to eq("You must show the MHCLG privacy notice to the buyers before you can submit this log.") end + + it "has the expected copy_key" do + expect(question.copy_key).to eq("sales.household_characteristics.privacynotice.joint_purchase") + end end end @@ -106,6 +100,10 @@ RSpec.describe Form::Sales::Questions::PrivacyNotice, type: :model do it "returns correct unanswered_error_message" do expect(question.unanswered_error_message).to eq("You must show or give the buyer access to the MHCLG privacy notice before you can submit this log.") end + + it "has the expected copy_key" do + expect(question.copy_key).to eq("sales.setup.privacynotice.not_joint_purchase") + end end context "and there are joint buyers" do @@ -124,6 +122,10 @@ RSpec.describe Form::Sales::Questions::PrivacyNotice, type: :model do it "returns correct unanswered_error_message" do expect(question.unanswered_error_message).to eq("You must show or give the buyers access to the MHCLG privacy notice before you can submit this log.") end + + it "has the expected copy_key" do + expect(question.copy_key).to eq("sales.setup.privacynotice.joint_purchase") + end end end end diff --git a/spec/services/bulk_upload/sales/year2023/row_parser_spec.rb b/spec/services/bulk_upload/sales/year2023/row_parser_spec.rb index 824754b25..70bd923e6 100644 --- a/spec/services/bulk_upload/sales/year2023/row_parser_spec.rb +++ b/spec/services/bulk_upload/sales/year2023/row_parser_spec.rb @@ -1029,8 +1029,8 @@ RSpec.describe BulkUpload::Sales::Year2023::RowParser do end it "populates with correct error message" do - expect(parser.errors.where(:field_30, category: :soft_validation).first.message).to eql("You told us this person is aged 22 years and retired.") - expect(parser.errors.where(:field_30, category: :soft_validation).first.message).to eql("You told us this person is aged 22 years and retired.") + expect(parser.errors.where(:field_30, category: :soft_validation).first.message).to eql("You told us this person is aged 22 years and retired. The minimum expected retirement age in England is 66.") + expect(parser.errors.where(:field_30, category: :soft_validation).first.message).to eql("You told us this person is aged 22 years and retired. The minimum expected retirement age in England is 66.") end end diff --git a/spec/services/bulk_upload/sales/year2024/row_parser_spec.rb b/spec/services/bulk_upload/sales/year2024/row_parser_spec.rb index 96914fc44..d1d4aeb53 100644 --- a/spec/services/bulk_upload/sales/year2024/row_parser_spec.rb +++ b/spec/services/bulk_upload/sales/year2024/row_parser_spec.rb @@ -1486,8 +1486,8 @@ RSpec.describe BulkUpload::Sales::Year2024::RowParser do it "populates with correct error message" do parser.valid? - expect(parser.errors.where(:field_31, category: :soft_validation).first.message).to eql("You told us this person is aged 22 years and retired.") - expect(parser.errors.where(:field_35, category: :soft_validation).first.message).to eql("You told us this person is aged 22 years and retired.") + expect(parser.errors.where(:field_31, category: :soft_validation).first.message).to eql("You told us this person is aged 22 years and retired. The minimum expected retirement age in England is 66.") + expect(parser.errors.where(:field_35, category: :soft_validation).first.message).to eql("You told us this person is aged 22 years and retired. The minimum expected retirement age in England is 66.") end end end From 247b7f212f0b8d4b81dee7238e7501f90f85d2b3 Mon Sep 17 00:00:00 2001 From: Manny Dinssa <44172848+Dinssa@users.noreply.github.com> Date: Tue, 29 Oct 2024 13:03:09 +0000 Subject: [PATCH 14/30] CLDC-3679: Copy changes lettings setup questions (#2723) --- app/models/form/lettings/pages/declaration.rb | 1 - app/models/form/lettings/pages/location.rb | 2 +- .../form/lettings/pages/location_search.rb | 2 +- app/models/form/lettings/pages/rent_type.rb | 2 +- app/models/form/lettings/pages/scheme.rb | 1 - .../form/lettings/questions/created_by_id.rb | 2 - .../lettings/questions/irproduct_other.rb | 3 +- .../form/lettings/questions/location_id.rb | 11 +-- .../lettings/questions/location_id_search.rb | 12 +-- .../questions/managing_organisation.rb | 2 - .../form/lettings/questions/needs_type.rb | 3 - .../lettings/questions/property_reference.rb | 3 - app/models/form/lettings/questions/renewal.rb | 19 ---- .../form/lettings/questions/rent_type.rb | 3 +- .../form/lettings/questions/scheme_id.rb | 11 --- .../form/lettings/questions/stock_owner.rb | 2 - .../lettings/questions/tenancy_start_date.rb | 2 - .../form/lettings/questions/tenant_code.rb | 3 - .../locales/forms/2023/lettings/setup.en.yml | 81 +++++++++++++++++ .../locales/forms/2024/lettings/setup.en.yml | 87 +++++++++++++++++++ .../check_answers_page_lettings_logs_spec.rb | 2 - spec/features/lettings_log_spec.rb | 2 +- spec/requests/form_controller_spec.rb | 7 +- .../requests/lettings_logs_controller_spec.rb | 2 +- 24 files changed, 183 insertions(+), 82 deletions(-) create mode 100644 config/locales/forms/2023/lettings/setup.en.yml create mode 100644 config/locales/forms/2024/lettings/setup.en.yml diff --git a/app/models/form/lettings/pages/declaration.rb b/app/models/form/lettings/pages/declaration.rb index 89561817d..647e2ccee 100644 --- a/app/models/form/lettings/pages/declaration.rb +++ b/app/models/form/lettings/pages/declaration.rb @@ -2,7 +2,6 @@ class Form::Lettings::Pages::Declaration < ::Form::Page def initialize(id, hsh, subsection) super @id = "declaration" - @header = "Ministry of Housing, Communities and Local Government privacy notice" end def questions diff --git a/app/models/form/lettings/pages/location.rb b/app/models/form/lettings/pages/location.rb index ba357dc1b..b35a38f7c 100644 --- a/app/models/form/lettings/pages/location.rb +++ b/app/models/form/lettings/pages/location.rb @@ -8,7 +8,7 @@ class Form::Lettings::Pages::Location < ::Form::Page "scheme_has_large_number_of_locations?" => false, }, ] - @header = "Location" + @copy_key = "lettings.setup.location_id.less_than_twenty" @next_unresolved_page_id = :check_answers end diff --git a/app/models/form/lettings/pages/location_search.rb b/app/models/form/lettings/pages/location_search.rb index f27fae281..e77346fce 100644 --- a/app/models/form/lettings/pages/location_search.rb +++ b/app/models/form/lettings/pages/location_search.rb @@ -8,7 +8,7 @@ class Form::Lettings::Pages::LocationSearch < ::Form::Page "scheme_has_large_number_of_locations?" => true, }, ] - @header = "Location" + @copy_key = "lettings.setup.location_id.twenty_or_more" @next_unresolved_page_id = :check_answers end diff --git a/app/models/form/lettings/pages/rent_type.rb b/app/models/form/lettings/pages/rent_type.rb index b3e52d0e2..8353b0338 100644 --- a/app/models/form/lettings/pages/rent_type.rb +++ b/app/models/form/lettings/pages/rent_type.rb @@ -2,7 +2,7 @@ class Form::Lettings::Pages::RentType < ::Form::Page def initialize(_id, hsh, subsection) super("rent_type", hsh, subsection) @derived = true - @header = "Rent Type" + @copy_key = "lettings.setup.rent_type" end def questions diff --git a/app/models/form/lettings/pages/scheme.rb b/app/models/form/lettings/pages/scheme.rb index 06bb6eb9c..9ac87a756 100644 --- a/app/models/form/lettings/pages/scheme.rb +++ b/app/models/form/lettings/pages/scheme.rb @@ -6,7 +6,6 @@ class Form::Lettings::Pages::Scheme < ::Form::Page "needstype" => 2, }, ] - @header = "Scheme" @next_unresolved_page_id = "location" end diff --git a/app/models/form/lettings/questions/created_by_id.rb b/app/models/form/lettings/questions/created_by_id.rb index 1f260960f..ea6375152 100644 --- a/app/models/form/lettings/questions/created_by_id.rb +++ b/app/models/form/lettings/questions/created_by_id.rb @@ -4,8 +4,6 @@ class Form::Lettings::Questions::CreatedById < ::Form::Question def initialize(id, hsh, page) super @id = "assigned_to_id" - @check_answer_label = "Log owner" - @header = "Which user are you creating this log for?" @derived = true @type = "select" end diff --git a/app/models/form/lettings/questions/irproduct_other.rb b/app/models/form/lettings/questions/irproduct_other.rb index d0df0bec8..b004d5dc2 100644 --- a/app/models/form/lettings/questions/irproduct_other.rb +++ b/app/models/form/lettings/questions/irproduct_other.rb @@ -2,8 +2,7 @@ class Form::Lettings::Questions::IrproductOther < ::Form::Question def initialize(id, hsh, page) super @id = "irproduct_other" - @check_answer_label = "Product name" - @header = "Name of rent product" + @copy_key = "lettings.setup.rent_type.irproduct_other" @type = "text" @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] if form.start_date.present? end diff --git a/app/models/form/lettings/questions/location_id.rb b/app/models/form/lettings/questions/location_id.rb index 59101592f..5bc316476 100644 --- a/app/models/form/lettings/questions/location_id.rb +++ b/app/models/form/lettings/questions/location_id.rb @@ -2,8 +2,7 @@ class Form::Lettings::Questions::LocationId < ::Form::Question def initialize(id, hsh, page) super @id = "location_id" - @check_answer_label = "Location" - @header = header_text + @copy_key = "lettings.setup.location_id.less_than_twenty" @type = "radio" @answer_options = answer_options @inferred_answers = { @@ -56,13 +55,5 @@ private false end - def header_text - if form.start_date && form.start_date.year >= 2023 - "Which location is this letting for?" - else - "Which location is this log for?" - end - end - QUESTION_NUMBER_FROM_YEAR = { 2023 => 10, 2024 => 5 }.freeze end diff --git a/app/models/form/lettings/questions/location_id_search.rb b/app/models/form/lettings/questions/location_id_search.rb index d085572e4..ecba28c38 100644 --- a/app/models/form/lettings/questions/location_id_search.rb +++ b/app/models/form/lettings/questions/location_id_search.rb @@ -2,10 +2,8 @@ class Form::Lettings::Questions::LocationIdSearch < ::Form::Question def initialize(id, hsh, page) super @id = "location_id" - @check_answer_label = "Location" - @header = header_text - @hint_text = '
    This scheme has 20 or more locations.
    Enter postcode or address.' @type = "select" + @copy_key = "lettings.setup.location_id.twenty_or_more" @answer_options = answer_options @inferred_answers = { "location.name": { @@ -52,13 +50,5 @@ private false end - def header_text - if form.start_date && form.start_date.year >= 2023 - "Which location is this letting for?" - else - "Which location is this log for?" - end - end - QUESTION_NUMBER_FROM_YEAR = { 2023 => 10, 2024 => 5 }.freeze end diff --git a/app/models/form/lettings/questions/managing_organisation.rb b/app/models/form/lettings/questions/managing_organisation.rb index 81847876e..e415837fe 100644 --- a/app/models/form/lettings/questions/managing_organisation.rb +++ b/app/models/form/lettings/questions/managing_organisation.rb @@ -2,8 +2,6 @@ class Form::Lettings::Questions::ManagingOrganisation < ::Form::Question def initialize(id, hsh, page) super @id = "managing_organisation_id" - @check_answer_label = "Managing agent" - @header = "Which organisation manages this letting?" @derived = true @type = "select" @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] if form.start_date.present? diff --git a/app/models/form/lettings/questions/needs_type.rb b/app/models/form/lettings/questions/needs_type.rb index 158626843..4a0aff67b 100644 --- a/app/models/form/lettings/questions/needs_type.rb +++ b/app/models/form/lettings/questions/needs_type.rb @@ -2,9 +2,6 @@ class Form::Lettings::Questions::NeedsType < ::Form::Question def initialize(id, hsh, page) super @id = "needstype" - @check_answer_label = "Needs type" - @header = "What is the needs type?" - @hint_text = "General needs housing includes both self-contained and shared housing without support or specific adaptations. Supported housing can include direct access hostels, group homes, residential care and nursing homes." @type = "radio" @answer_options = ANSWER_OPTIONS @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] if form.start_date.present? diff --git a/app/models/form/lettings/questions/property_reference.rb b/app/models/form/lettings/questions/property_reference.rb index f7d80829c..d4587ffe8 100644 --- a/app/models/form/lettings/questions/property_reference.rb +++ b/app/models/form/lettings/questions/property_reference.rb @@ -2,9 +2,6 @@ class Form::Lettings::Questions::PropertyReference < ::Form::Question def initialize(id, hsh, page) super @id = "propcode" - @check_answer_label = "Property reference" - @header = "What is the property reference?" - @hint_text = "This is how you usually refer to this property on your own systems." @type = "text" @width = 10 @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] if form.start_date.present? diff --git a/app/models/form/lettings/questions/renewal.rb b/app/models/form/lettings/questions/renewal.rb index 2a32d1f16..e78d98247 100644 --- a/app/models/form/lettings/questions/renewal.rb +++ b/app/models/form/lettings/questions/renewal.rb @@ -2,11 +2,8 @@ class Form::Lettings::Questions::Renewal < ::Form::Question def initialize(id, hsh, page) super @id = "renewal" - @check_answer_label = "Property renewal" - @header = header_text @type = "radio" @answer_options = ANSWER_OPTIONS - @hint_text = hint_text @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] if form.start_date.present? end @@ -16,21 +13,5 @@ class Form::Lettings::Questions::Renewal < ::Form::Question } .freeze - def header_text - if form.start_year_after_2024? - "Is this letting a renewal of social housing to the same tenant in the same property?" - else - "Is this letting a renewal?" - end - end - - def hint_text - if form.start_year_after_2024? - "If the property was previously being used as temporary accommodation, then answer 'no'" - else - "A renewal is a letting to the same tenant in the same property. If the property was previously being used as temporary accommodation, then answer 'no'" - end - end - QUESTION_NUMBER_FROM_YEAR = { 2023 => 4, 2024 => 6 }.freeze end diff --git a/app/models/form/lettings/questions/rent_type.rb b/app/models/form/lettings/questions/rent_type.rb index 7454cd752..818ead98a 100644 --- a/app/models/form/lettings/questions/rent_type.rb +++ b/app/models/form/lettings/questions/rent_type.rb @@ -2,8 +2,7 @@ class Form::Lettings::Questions::RentType < ::Form::Question def initialize(id, hsh, page) super @id = "rent_type" - @check_answer_label = "Rent type" - @header = "What is the rent type?" + @copy_key = "lettings.setup.rent_type.rent_type" @type = "radio" @top_guidance_partial = form.start_year_after_2024? ? "rent_type_definitions_2024" : "rent_type_definitions" @answer_options = form.start_year_after_2024? ? ANSWER_OPTIONS_2024 : ANSWER_OPTIONS diff --git a/app/models/form/lettings/questions/scheme_id.rb b/app/models/form/lettings/questions/scheme_id.rb index d5c58df61..862ef3130 100644 --- a/app/models/form/lettings/questions/scheme_id.rb +++ b/app/models/form/lettings/questions/scheme_id.rb @@ -1,8 +1,6 @@ class Form::Lettings::Questions::SchemeId < ::Form::Question def initialize(_id, hsh, page) super("scheme_id", hsh, page) - @check_answer_label = "Scheme name" - @header = "What scheme is this log for?" @type = "select" @answer_options = answer_options @top_guidance_partial = "finding_scheme" @@ -48,15 +46,6 @@ class Form::Lettings::Questions::SchemeId < ::Form::Question lettings_log.form.get_question("postcode_full", nil).label_from_value(lettings_log.postcode_full) unless lettings_log.scheme_has_multiple_locations? end - def hint_text - if form.start_year_after_2024? - "Enter postcode or scheme name.

    - A supported housing scheme provides shared or self-contained housing for a particular client group, for example younger or vulnerable people." - else - "Enter postcode or scheme name" - end - end - private def supported_housing_selected?(lettings_log) diff --git a/app/models/form/lettings/questions/stock_owner.rb b/app/models/form/lettings/questions/stock_owner.rb index daa042004..6fc418b62 100644 --- a/app/models/form/lettings/questions/stock_owner.rb +++ b/app/models/form/lettings/questions/stock_owner.rb @@ -2,8 +2,6 @@ class Form::Lettings::Questions::StockOwner < ::Form::Question def initialize(id, hsh, page) super @id = "owning_organisation_id" - @check_answer_label = "Stock owner" - @header = "Which organisation owns this property?" @derived = true @type = "select" @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] if form.start_date.present? diff --git a/app/models/form/lettings/questions/tenancy_start_date.rb b/app/models/form/lettings/questions/tenancy_start_date.rb index c7dc73627..cf1b556e7 100644 --- a/app/models/form/lettings/questions/tenancy_start_date.rb +++ b/app/models/form/lettings/questions/tenancy_start_date.rb @@ -2,8 +2,6 @@ class Form::Lettings::Questions::TenancyStartDate < ::Form::Question def initialize(id, hsh, page) super @id = "startdate" - @check_answer_label = "Tenancy start date" - @header = "What is the tenancy start date?" @type = "date" @unresolved_hint_text = "Some scheme details have changed, and now this log needs updating. Check that the tenancy start date is correct." @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] if form.start_date.present? diff --git a/app/models/form/lettings/questions/tenant_code.rb b/app/models/form/lettings/questions/tenant_code.rb index 30b51525a..7b7be3cac 100644 --- a/app/models/form/lettings/questions/tenant_code.rb +++ b/app/models/form/lettings/questions/tenant_code.rb @@ -2,9 +2,6 @@ class Form::Lettings::Questions::TenantCode < ::Form::Question def initialize(id, hsh, page) super @id = "tenancycode" - @check_answer_label = "Tenant code" - @header = "What is the tenant code?" - @hint_text = "This is how you usually refer to this tenancy on your own systems." @type = "text" @width = 10 @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] if form.start_date.present? diff --git a/config/locales/forms/2023/lettings/setup.en.yml b/config/locales/forms/2023/lettings/setup.en.yml new file mode 100644 index 000000000..5df98796a --- /dev/null +++ b/config/locales/forms/2023/lettings/setup.en.yml @@ -0,0 +1,81 @@ +en: + forms: + 2023: + lettings: + setup: + owning_organisation_id: + page_header: "" + check_answer_label: "Stock owner" + hint_text: "" + question_text: "Which organisation owns this property?" + + managing_organisation_id: + page_header: "" + check_answer_label: "Managing agent" + hint_text: "" + question_text: "Which organisation manages this letting?" + + assigned_to_id: + page_header: "" + check_answer_label: "Log owner" + hint_text: "" + question_text: "Which user are you creating this log for?" + + needstype: + page_header: "" + check_answer_label: "Needs type" + hint_text: "General needs housing includes both self-contained and shared housing without support or specific adaptations. Supported housing can include direct access hostels, group homes, residential care and nursing homes." + question_text: "What is the needs type?" + + scheme_id: + page_header: "Scheme" + check_answer_label: "Scheme name" + hint_text: "Enter postcode or scheme name" + question_text: "What scheme is this log for?" + + location_id: + less_than_twenty: + page_header: "Location" + check_answer_label: "Location" + hint_text: "" + question_text: "Which location is this letting for?" + twenty_or_more: + page_header: "Location" + check_answer_label: "Location" + hint_text: '
    This scheme has 20 or more locations.
    Enter postcode or address.' + question_text: "Which location is this letting for?" + + renewal: + page_header: "" + check_answer_label: "Property renewal" + hint_text: "A renewal is a letting to the same tenant in the same property. If the property was previously being used as temporary accommodation, then answer 'no'." + question_text: "Is this letting a renewal?" + + startdate: + page_header: "" + check_answer_label: "Tenancy start date" + hint_text: "" + question_text: "What is the tenancy start date?" + + rent_type: + page_header: "Rent Type" + rent_type: + check_answer_label: "Rent type" + hint_text: "" + question_text: "What is the rent type?" + irproduct_other: + check_answer_label: "Product name" + hint_text: "" + question_text: "Name of rent product" + + tenancycode: + page_header: "" + check_answer_label: "Tenant code" + hint_text: "This is how you usually refer to this tenancy on your own systems." + question_text: "What is the tenant code?" + + propcode: + page_header: "" + check_answer_label: "Property reference" + hint_text: "This is how you usually refer to this property on your own systems." + question_text: "What is the property reference?" diff --git a/config/locales/forms/2024/lettings/setup.en.yml b/config/locales/forms/2024/lettings/setup.en.yml new file mode 100644 index 000000000..5a18fe719 --- /dev/null +++ b/config/locales/forms/2024/lettings/setup.en.yml @@ -0,0 +1,87 @@ +en: + forms: + 2024: + lettings: + setup: + owning_organisation_id: + page_header: "" + check_answer_label: "Stock owner" + hint_text: "" + question_text: "Which organisation owns this property?" + + managing_organisation_id: + page_header: "" + check_answer_label: "Managing agent" + hint_text: "" + question_text: "Which organisation manages this letting?" + + assigned_to_id: + page_header: "" + check_answer_label: "Log owner" + hint_text: "" + question_text: "Which user are you creating this log for?" + + needstype: + page_header: "" + check_answer_label: "Needs type" + hint_text: "General needs housing includes both self-contained and shared housing without support or specific adaptations. Supported housing can include direct access hostels, group homes, residential care and nursing homes." + question_text: "What is the needs type?" + + scheme_id: + page_header: "Scheme" + check_answer_label: "Scheme name" + hint_text: "Enter postcode or scheme name.

    A supported housing scheme provides shared or self-contained housing for a particular client group, for example younger or vulnerable people." + question_text: "What scheme is this log for?" + + location_id: + less_than_twenty: + page_header: "Location" + check_answer_label: "Location" + hint_text: "" + question_text: "Which location is this letting for?" + twenty_or_more: + page_header: "Location" + check_answer_label: "Location" + hint_text: '
    This scheme has 20 or more locations.
    Enter postcode or address.' + question_text: "Which location is this letting for?" + + renewal: + page_header: "" + check_answer_label: "Property renewal" + hint_text: "If the property was previously being used as temporary accommodation, then answer 'no'." + question_text: "Is this letting a renewal of social housing to the same tenant in the same property?" + + startdate: + page_header: "" + check_answer_label: "Tenancy start date" + hint_text: "" + question_text: "What is the tenancy start date?" + + rent_type: + page_header: "Rent Type" + rent_type: + check_answer_label: "Rent type" + hint_text: "" + question_text: "What is the rent type?" + irproduct_other: + check_answer_label: "Product name" + hint_text: "" + question_text: "Name of rent product" + + tenancycode: + page_header: "" + check_answer_label: "Tenant code" + hint_text: "This is how you usually refer to this tenancy on your own systems." + question_text: "What is the tenant code?" + + propcode: + page_header: "" + check_answer_label: "Property reference" + hint_text: "This is how you usually refer to this property on your own systems." + question_text: "What is the property reference?" + + declaration: + page_header: "Ministry of Housing, Communities and Local Government privacy notice" + check_answer_label: "Tenant has seen the privacy notice" + hint_text: "" + question_text: "Declaration" diff --git a/spec/features/form/check_answers_page_lettings_logs_spec.rb b/spec/features/form/check_answers_page_lettings_logs_spec.rb index d435f8b7a..bbbeccbe6 100644 --- a/spec/features/form/check_answers_page_lettings_logs_spec.rb +++ b/spec/features/form/check_answers_page_lettings_logs_spec.rb @@ -167,14 +167,12 @@ RSpec.describe "Lettings Log Check Answers Page" do it "displays inferred postcode with the location id" do lettings_log.update!(location:) visit("/lettings-logs/#{id}/setup/check-answers") - expect(page).to have_content("Location") expect(page).to have_content(location.name) end it "displays inferred postcode with the location_admin_district" do lettings_log.update!(location:) visit("/lettings-logs/#{id}/setup/check-answers") - expect(page).to have_content("Location") expect(page).to have_content(location.location_admin_district) end end diff --git a/spec/features/lettings_log_spec.rb b/spec/features/lettings_log_spec.rb index 218850992..092ab2b40 100644 --- a/spec/features/lettings_log_spec.rb +++ b/spec/features/lettings_log_spec.rb @@ -243,7 +243,7 @@ RSpec.describe "Lettings Log Features" do context "when completing the setup lettings log section", :aggregate_failure do before do - Timecop.freeze(Time.zone.local(2023, 3, 3)) + Timecop.freeze(Time.zone.local(2023, 4, 3)) Singleton.__init__(FormHandler) end diff --git a/spec/requests/form_controller_spec.rb b/spec/requests/form_controller_spec.rb index 80157e992..94f6595c7 100644 --- a/spec/requests/form_controller_spec.rb +++ b/spec/requests/form_controller_spec.rb @@ -735,14 +735,19 @@ RSpec.describe FormController, type: :request do end before do + Timecop.freeze(Time.zone.local(2023, 12, 1)) organisation.stock_owners << stock_owner organisation.managing_agents << managing_organisation organisation.managing_agents << managing_organisation_too organisation.reload - lettings_log.update!(owning_organisation: stock_owner, assigned_to: user, managing_organisation: organisation) + lettings_log.update!(owning_organisation: stock_owner, assigned_to: user, managing_organisation: organisation, startdate: Time.zone.local(2023, 5, 1)) lettings_log.reload end + after do + Timecop.unfreeze + end + it "re-renders the same page with errors if validation fails" do post "/lettings-logs/#{lettings_log.id}/managing-organisation", params: params expect(page).to have_content("There is a problem") diff --git a/spec/requests/lettings_logs_controller_spec.rb b/spec/requests/lettings_logs_controller_spec.rb index 6af9f3f12..308b90c1e 100644 --- a/spec/requests/lettings_logs_controller_spec.rb +++ b/spec/requests/lettings_logs_controller_spec.rb @@ -1538,7 +1538,7 @@ RSpec.describe LettingsLogsController, type: :request do end context "when viewing a specific log affected by deactivated location" do - let!(:affected_lettings_log) { FactoryBot.create(:lettings_log, unresolved: true, assigned_to: user, needstype: 2) } + let!(:affected_lettings_log) { FactoryBot.create(:lettings_log, unresolved: true, assigned_to: user, needstype: 2, startdate: Time.zone.local(2024, 4, 1)) } let(:headers) { { "Accept" => "text/html" } } before do From 9763013ac176a398db9b484ccf133bc580da1938 Mon Sep 17 00:00:00 2001 From: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com> Date: Tue, 29 Oct 2024 13:59:03 +0000 Subject: [PATCH 15/30] Extract sale information validations into a separate translations file (#2699) --- .../sales/sale_information_validations.rb | 80 +++++------ config/locales/en.yml | 43 ------ .../validations/sales/sale_information.en.yml | 125 ++++++++++++++++++ .../sale_information_validations_spec.rb | 8 +- 4 files changed, 169 insertions(+), 87 deletions(-) create mode 100644 config/locales/validations/sales/sale_information.en.yml diff --git a/app/models/validations/sales/sale_information_validations.rb b/app/models/validations/sales/sale_information_validations.rb index c5febb693..700867e66 100644 --- a/app/models/validations/sales/sale_information_validations.rb +++ b/app/models/validations/sales/sale_information_validations.rb @@ -8,13 +8,13 @@ module Validations::Sales::SaleInformationValidations return if record.saledate.blank? if record.hodate > record.saledate - record.errors.add :hodate, I18n.t("validations.sale_information.hodate.must_be_before_saledate") - record.errors.add :saledate, I18n.t("validations.sale_information.saledate.must_be_after_hodate") + record.errors.add :hodate, I18n.t("validations.sales.sale_information.hodate.must_be_before_saledate") + record.errors.add :saledate, I18n.t("validations.sales.sale_information.saledate.must_be_after_hodate") end if record.saledate - record.hodate >= 3.years && record.form.start_year_after_2024? - record.errors.add :hodate, I18n.t("validations.sale_information.hodate.must_be_less_than_3_years_from_saledate") - record.errors.add :saledate, I18n.t("validations.sale_information.saledate.must_be_less_than_3_years_from_hodate") + record.errors.add :hodate, I18n.t("validations.sales.sale_information.hodate.must_be_less_than_3_years_from_saledate") + record.errors.add :saledate, I18n.t("validations.sales.sale_information.saledate.must_be_less_than_3_years_from_hodate") end end @@ -22,13 +22,13 @@ module Validations::Sales::SaleInformationValidations return unless record.exdate && record.saledate if record.exdate > record.saledate - record.errors.add :exdate, I18n.t("validations.sale_information.exdate.must_be_before_saledate") - record.errors.add :saledate, I18n.t("validations.sale_information.saledate.must_be_after_exdate") + record.errors.add :exdate, I18n.t("validations.sales.sale_information.exdate.must_be_before_saledate") + record.errors.add :saledate, I18n.t("validations.sales.sale_information.saledate.must_be_after_exdate") end if record.saledate - record.exdate >= 1.year - record.errors.add :exdate, I18n.t("validations.sale_information.exdate.must_be_less_than_1_year_from_saledate") - record.errors.add :saledate, I18n.t("validations.sale_information.saledate.must_be_less_than_1_year_from_exdate") + record.errors.add :exdate, I18n.t("validations.sales.sale_information.exdate.must_be_less_than_1_year_from_saledate") + record.errors.add :saledate, I18n.t("validations.sales.sale_information.saledate.must_be_less_than_1_year_from_exdate") end end @@ -36,8 +36,8 @@ module Validations::Sales::SaleInformationValidations return unless record.fromprop && record.frombeds if record.frombeds != 1 && record.fromprop == 2 - record.errors.add :frombeds, I18n.t("validations.sale_information.previous_property_type.property_type_bedsit") - record.errors.add :fromprop, I18n.t("validations.sale_information.previous_property_type.property_type_bedsit") + record.errors.add :frombeds, I18n.t("validations.sales.sale_information.frombeds.previous_property_type_bedsit") + record.errors.add :fromprop, I18n.t("validations.sales.sale_information.fromprop.previous_property_type_bedsit") end end @@ -54,7 +54,7 @@ module Validations::Sales::SaleInformationValidations deposit_and_grant_sentence = record.grant.present? ? ", cash deposit (#{record.field_formatted_as_currency('deposit')}), and grant (#{record.field_formatted_as_currency('grant')})" : " and cash deposit (#{record.field_formatted_as_currency('deposit')})" discount_sentence = record.discount.present? ? " (#{record.field_formatted_as_currency('value')}) subtracted by the sum of the full purchase price (#{record.field_formatted_as_currency('value')}) multiplied by the percentage discount (#{record.discount}%)" : "" %i[mortgageused mortgage value deposit ownershipsch discount grant].each do |field| - record.errors.add field, I18n.t("validations.sale_information.discounted_ownership_value", + record.errors.add field, I18n.t("validations.sales.sale_information.#{field}.discounted_ownership_value", mortgage: record.mortgage&.positive? ? " (#{record.field_formatted_as_currency('mortgage')})" : "", deposit_and_grant_sentence:, mortgage_deposit_and_grant_total: record.field_formatted_as_currency("mortgage_deposit_and_grant_total"), @@ -72,13 +72,13 @@ module Validations::Sales::SaleInformationValidations if over_tolerance?(record.mortgage_and_deposit_total, record.value, 1) %i[mortgageused mortgage value deposit].each do |field| - record.errors.add field, I18n.t("validations.sale_information.outright_sale_value", + record.errors.add field, I18n.t("validations.sales.sale_information.#{field}.outright_sale_value", mortgage_and_deposit_total: record.field_formatted_as_currency("mortgage_and_deposit_total"), mortgage: record.mortgage&.positive? ? " (#{record.field_formatted_as_currency('mortgage')})" : "", deposit: record.field_formatted_as_currency("deposit"), value: record.field_formatted_as_currency("value")).html_safe end - record.errors.add :ownershipsch, :skip_bu_error, message: I18n.t("validations.sale_information.outright_sale_value", + record.errors.add :ownershipsch, :skip_bu_error, message: I18n.t("validations.sales.sale_information.ownershipsch.outright_sale_value", mortgage_and_deposit_total: record.field_formatted_as_currency("mortgage_and_deposit_total"), mortgage: record.mortgage&.positive? ? " (#{record.field_formatted_as_currency('mortgage')})" : "", deposit: record.field_formatted_as_currency("deposit"), @@ -90,8 +90,8 @@ module Validations::Sales::SaleInformationValidations return unless record.mrent && record.ownershipsch && record.type if record.shared_ownership_scheme? && !record.old_persons_shared_ownership? && record.mrent > 9999 - record.errors.add :mrent, I18n.t("validations.sale_information.monthly_rent.higher_than_expected") - record.errors.add :type, I18n.t("validations.sale_information.monthly_rent.higher_than_expected") + record.errors.add :mrent, I18n.t("validations.sales.sale_information.mrent.monthly_rent_higher_than_expected") + record.errors.add :type, I18n.t("validations.sales.sale_information.type.monthly_rent_higher_than_expected") end end @@ -100,7 +100,7 @@ module Validations::Sales::SaleInformationValidations return unless record.grant && (record.type == 8 || record.type == 21) unless record.grant.between?(9_000, 16_000) - record.errors.add :grant, I18n.t("validations.sale_information.grant.out_of_range") + record.errors.add :grant, I18n.t("validations.sales.sale_information.grant.out_of_range") end end @@ -118,8 +118,8 @@ module Validations::Sales::SaleInformationValidations end if max_stairbought && record.stairbought > max_stairbought - record.errors.add :stairbought, I18n.t("validations.sale_information.stairbought.over_max", max_stairbought:, type: record.form.get_question("type", record).answer_label(record)) - record.errors.add :type, I18n.t("validations.sale_information.stairbought.over_max", max_stairbought:, type: record.form.get_question("type", record).answer_label(record)) + record.errors.add :stairbought, I18n.t("validations.sales.sale_information.stairbought.stairbought_over_max", max_stairbought:, type: record.form.get_question("type", record).answer_label(record)) + record.errors.add :type, I18n.t("validations.sales.sale_information.type.stairbought_over_max", max_stairbought:, type: record.form.get_question("type", record).answer_label(record)) end end @@ -129,11 +129,11 @@ module Validations::Sales::SaleInformationValidations if record.london_property? && record.discount_value > 136_400 %i[discount value la postcode_full uprn].each do |field| - record.errors.add field, I18n.t("validations.sale_information.value.over_discounted_london_max", discount_value: record.field_formatted_as_currency("discount_value")) + record.errors.add field, I18n.t("validations.sales.sale_information.#{field}.value_over_discounted_london_max", discount_value: record.field_formatted_as_currency("discount_value")) end elsif record.property_not_in_london? && record.discount_value > 102_400 %i[discount value la postcode_full uprn].each do |field| - record.errors.add field, I18n.t("validations.sale_information.value.over_discounted_max", discount_value: record.field_formatted_as_currency("discount_value")) + record.errors.add field, I18n.t("validations.sales.sale_information.#{field}.value_over_discounted_max", discount_value: record.field_formatted_as_currency("discount_value")) end end end @@ -170,7 +170,7 @@ module Validations::Sales::SaleInformationValidations if over_tolerance?(record.mortgage_deposit_and_discount_total, record.expected_shared_ownership_deposit_value, 1) %i[mortgage value deposit cashdis equity].each do |field| - record.errors.add field, I18n.t("validations.sale_information.non_staircasing_mortgage.mortgage_used_socialhomebuy", + record.errors.add field, I18n.t("validations.sales.sale_information.#{field}.non_staircasing_mortgage.mortgage_used_socialhomebuy", mortgage: record.field_formatted_as_currency("mortgage"), value: record.field_formatted_as_currency("value"), deposit: record.field_formatted_as_currency("deposit"), @@ -179,7 +179,7 @@ module Validations::Sales::SaleInformationValidations mortgage_deposit_and_discount_total: record.field_formatted_as_currency("mortgage_deposit_and_discount_total"), expected_shared_ownership_deposit_value: record.field_formatted_as_currency("expected_shared_ownership_deposit_value")).html_safe end - record.errors.add :type, :skip_bu_error, message: I18n.t("validations.sale_information.non_staircasing_mortgage.mortgage_used_socialhomebuy", + record.errors.add :type, :skip_bu_error, message: I18n.t("validations.sales.sale_information.type.non_staircasing_mortgage.mortgage_used_socialhomebuy", mortgage: record.field_formatted_as_currency("mortgage"), value: record.field_formatted_as_currency("value"), deposit: record.field_formatted_as_currency("deposit"), @@ -191,7 +191,7 @@ module Validations::Sales::SaleInformationValidations elsif record.mortgage_not_used? if over_tolerance?(record.deposit_and_discount_total, record.expected_shared_ownership_deposit_value, 1) %i[mortgageused value deposit cashdis equity].each do |field| - record.errors.add field, I18n.t("validations.sale_information.non_staircasing_mortgage.mortgage_not_used_socialhomebuy", + record.errors.add field, I18n.t("validations.sales.sale_information.#{field}.non_staircasing_mortgage.mortgage_not_used_socialhomebuy", deposit_and_discount_total: record.field_formatted_as_currency("deposit_and_discount_total"), expected_shared_ownership_deposit_value: record.field_formatted_as_currency("expected_shared_ownership_deposit_value"), value: record.field_formatted_as_currency("value"), @@ -199,7 +199,7 @@ module Validations::Sales::SaleInformationValidations cashdis: record.field_formatted_as_currency("cashdis"), equity: "#{record.equity}%").html_safe end - record.errors.add :type, :skip_bu_error, message: I18n.t("validations.sale_information.non_staircasing_mortgage.mortgage_not_used_socialhomebuy", + record.errors.add :type, :skip_bu_error, message: I18n.t("validations.sales.sale_information.type.non_staircasing_mortgage.mortgage_not_used_socialhomebuy", deposit_and_discount_total: record.field_formatted_as_currency("deposit_and_discount_total"), expected_shared_ownership_deposit_value: record.field_formatted_as_currency("expected_shared_ownership_deposit_value"), value: record.field_formatted_as_currency("value"), @@ -216,7 +216,7 @@ module Validations::Sales::SaleInformationValidations if over_tolerance?(record.mortgage_and_deposit_total, record.expected_shared_ownership_deposit_value, 1) %i[mortgage value deposit equity].each do |field| - record.errors.add field, I18n.t("validations.sale_information.non_staircasing_mortgage.mortgage_used", + record.errors.add field, I18n.t("validations.sales.sale_information.#{field}.non_staircasing_mortgage.mortgage_used", mortgage: record.field_formatted_as_currency("mortgage"), deposit: record.field_formatted_as_currency("deposit"), value: record.field_formatted_as_currency("value"), @@ -224,7 +224,7 @@ module Validations::Sales::SaleInformationValidations mortgage_and_deposit_total: record.field_formatted_as_currency("mortgage_and_deposit_total"), expected_shared_ownership_deposit_value: record.field_formatted_as_currency("expected_shared_ownership_deposit_value")).html_safe end - record.errors.add :type, :skip_bu_error, message: I18n.t("validations.sale_information.non_staircasing_mortgage.mortgage_used", + record.errors.add :type, :skip_bu_error, message: I18n.t("validations.sales.sale_information.type.non_staircasing_mortgage.mortgage_used", mortgage: record.field_formatted_as_currency("mortgage"), deposit: record.field_formatted_as_currency("deposit"), value: record.field_formatted_as_currency("value"), @@ -235,12 +235,12 @@ module Validations::Sales::SaleInformationValidations elsif record.mortgage_not_used? if over_tolerance?(record.deposit, record.expected_shared_ownership_deposit_value, 1) %i[mortgageused value deposit equity].each do |field| - record.errors.add field, I18n.t("validations.sale_information.non_staircasing_mortgage.mortgage_not_used", + record.errors.add field, I18n.t("validations.sales.sale_information.#{field}.non_staircasing_mortgage.mortgage_not_used", deposit: record.field_formatted_as_currency("deposit"), value: record.field_formatted_as_currency("value"), expected_shared_ownership_deposit_value: record.field_formatted_as_currency("expected_shared_ownership_deposit_value")).html_safe end - record.errors.add :type, :skip_bu_error, message: I18n.t("validations.sale_information.non_staircasing_mortgage.mortgage_not_used", + record.errors.add :type, :skip_bu_error, message: I18n.t("validations.sales.sale_information.type.non_staircasing_mortgage.mortgage_not_used", deposit: record.field_formatted_as_currency("deposit"), value: record.field_formatted_as_currency("value"), expected_shared_ownership_deposit_value: record.field_formatted_as_currency("expected_shared_ownership_deposit_value")).html_safe @@ -256,7 +256,7 @@ module Validations::Sales::SaleInformationValidations if over_tolerance?(record.mortgage_deposit_and_discount_total, record.stairbought_part_of_value, 1) %i[mortgage value deposit cashdis stairbought].each do |field| - record.errors.add field, I18n.t("validations.sale_information.staircasing_mortgage.mortgage_used_socialhomebuy", + record.errors.add field, I18n.t("validations.sales.sale_information.#{field}.staircasing_mortgage.mortgage_used_socialhomebuy", mortgage_deposit_and_discount_total: record.field_formatted_as_currency("mortgage_deposit_and_discount_total"), stairbought_part_of_value: record.field_formatted_as_currency("stairbought_part_of_value"), mortgage: record.field_formatted_as_currency("mortgage"), @@ -265,7 +265,7 @@ module Validations::Sales::SaleInformationValidations cashdis: record.field_formatted_as_currency("cashdis"), stairbought: "#{record.stairbought}%").html_safe end - record.errors.add :type, :skip_bu_error, message: I18n.t("validations.sale_information.staircasing_mortgage.mortgage_used_socialhomebuy", + record.errors.add :type, :skip_bu_error, message: I18n.t("validations.sales.sale_information.type.staircasing_mortgage.mortgage_used_socialhomebuy", mortgage_deposit_and_discount_total: record.field_formatted_as_currency("mortgage_deposit_and_discount_total"), stairbought_part_of_value: record.field_formatted_as_currency("stairbought_part_of_value"), mortgage: record.field_formatted_as_currency("mortgage"), @@ -276,7 +276,7 @@ module Validations::Sales::SaleInformationValidations end elsif over_tolerance?(record.deposit_and_discount_total, record.stairbought_part_of_value, 1) %i[mortgageused value deposit cashdis stairbought].each do |field| - record.errors.add field, I18n.t("validations.sale_information.staircasing_mortgage.mortgage_not_used_socialhomebuy", + record.errors.add field, I18n.t("validations.sales.sale_information.#{field}.staircasing_mortgage.mortgage_not_used_socialhomebuy", deposit_and_discount_total: record.field_formatted_as_currency("deposit_and_discount_total"), stairbought_part_of_value: record.field_formatted_as_currency("stairbought_part_of_value"), value: record.field_formatted_as_currency("value"), @@ -284,7 +284,7 @@ module Validations::Sales::SaleInformationValidations cashdis: record.field_formatted_as_currency("cashdis"), stairbought: "#{record.stairbought}%").html_safe end - record.errors.add :type, :skip_bu_error, message: I18n.t("validations.sale_information.staircasing_mortgage.mortgage_not_used_socialhomebuy", + record.errors.add :type, :skip_bu_error, message: I18n.t("validations.sales.sale_information.type.staircasing_mortgage.mortgage_not_used_socialhomebuy", deposit_and_discount_total: record.field_formatted_as_currency("deposit_and_discount_total"), stairbought_part_of_value: record.field_formatted_as_currency("stairbought_part_of_value"), value: record.field_formatted_as_currency("value"), @@ -300,14 +300,14 @@ module Validations::Sales::SaleInformationValidations if over_tolerance?(record.mortgage_and_deposit_total, record.stairbought_part_of_value, 1) %i[mortgage value deposit stairbought].each do |field| - record.errors.add field, I18n.t("validations.sale_information.staircasing_mortgage.mortgage_used", + record.errors.add field, I18n.t("validations.sales.sale_information.#{field}.staircasing_mortgage.mortgage_used", mortgage: record.field_formatted_as_currency("mortgage"), deposit: record.field_formatted_as_currency("deposit"), mortgage_and_deposit_total: record.field_formatted_as_currency("mortgage_and_deposit_total"), value: record.field_formatted_as_currency("value"), stairbought_part_of_value: record.field_formatted_as_currency("stairbought_part_of_value")).html_safe end - record.errors.add :type, :skip_bu_error, message: I18n.t("validations.sale_information.staircasing_mortgage.mortgage_used", + record.errors.add :type, :skip_bu_error, message: I18n.t("validations.sales.sale_information.type.staircasing_mortgage.mortgage_used", mortgage: record.field_formatted_as_currency("mortgage"), deposit: record.field_formatted_as_currency("deposit"), mortgage_and_deposit_total: record.field_formatted_as_currency("mortgage_and_deposit_total"), @@ -316,12 +316,12 @@ module Validations::Sales::SaleInformationValidations end elsif over_tolerance?(record.deposit, record.stairbought_part_of_value, 1) %i[mortgageused value deposit stairbought].each do |field| - record.errors.add field, I18n.t("validations.sale_information.staircasing_mortgage.mortgage_not_used", + record.errors.add field, I18n.t("validations.sales.sale_information.#{field}.staircasing_mortgage.mortgage_not_used", deposit: record.field_formatted_as_currency("deposit"), value: record.field_formatted_as_currency("value"), stairbought_part_of_value: record.field_formatted_as_currency("stairbought_part_of_value")).html_safe end - record.errors.add :type, :skip_bu_error, message: I18n.t("validations.sale_information.staircasing_mortgage.mortgage_not_used", + record.errors.add :type, :skip_bu_error, message: I18n.t("validations.sales.sale_information.type.staircasing_mortgage.mortgage_not_used", deposit: record.field_formatted_as_currency("deposit"), value: record.field_formatted_as_currency("value"), stairbought_part_of_value: record.field_formatted_as_currency("stairbought_part_of_value")).html_safe @@ -336,15 +336,15 @@ module Validations::Sales::SaleInformationValidations end if record.outright_sale? && record.saledate && !record.form.start_year_after_2024? record.errors.add :mortgageused, I18n.t("validations.invalid_option", question: "was a mortgage used for the purchase of this property?") - record.errors.add :saledate, I18n.t("validations.financial.mortgage_used.year") + record.errors.add :saledate, I18n.t("validations.sales.sale_information.saledate.mortgage_used_year") end if record.shared_ownership_scheme? && record.is_not_staircasing? record.errors.add :mortgageused, I18n.t("validations.invalid_option", question: "was a mortgage used for the purchase of this property?") - record.errors.add :staircase, I18n.t("validations.financial.mortgage_used.staircasing") + record.errors.add :staircase, I18n.t("validations.sales.sale_information.staircase.mortgage_used_value") end if record.stairowned && !record.stairowned_100? - record.errors.add :stairowned, I18n.t("validations.sale_information.stairowned.mortgageused_dont_know") - record.errors.add :mortgageused, I18n.t("validations.sale_information.stairowned.mortgageused_dont_know") + record.errors.add :stairowned, I18n.t("validations.sales.sale_information.stairowned.mortgageused_dont_know") + record.errors.add :mortgageused, I18n.t("validations.sales.sale_information.mortgageused.mortgageused_dont_know") end end diff --git a/config/locales/en.yml b/config/locales/en.yml index 5412c8b2b..7ed8f42e8 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -476,9 +476,6 @@ en: over_max: "The maximum initial equity stake is %{max_equity}%." over_stairowned_minus_stairbought: "The initial equity stake is %{equity}% and the percentage owned in total minus the percentage bought is %{staircase_difference}%. In a staircasing transaction, the equity stake purchased cannot be larger than the percentage the %{buyer_owns} minus the percentage bought." mortgage: "Mortgage value cannot be £0 if a mortgage was used for the purchase of this property." - mortgage_used: - year: "You must answer either ‘yes’ or ‘no’ to the question ‘was a mortgage used’ for the selected year." - staircasing: "You must answer either ‘yes’ or ‘no’ to the question ‘was a mortgage used’ for staircasing transactions." shared_ownership_deposit: "The %{mortgage_deposit_and_discount_error_fields} added together is %{mortgage_deposit_and_discount_total}. The value times the equity percentage is %{value_times_equity}. These figures should be the same." household: @@ -637,46 +634,6 @@ en: before_deactivation: "This location was deactivated on %{date}. The reactivation date must be on or after deactivation date." deactivation: during_deactivated_period: "The location is already deactivated during this date, please enter a different date." - sale_information: - proplen: - social_homebuy: "Social HomeBuy buyers should not have lived here before." - rent_to_buy: "Rent to Buy buyers should not have lived here before." - hodate: - must_be_before_saledate: "Practical completion or handover date must be before sale completion date." - must_be_less_than_3_years_from_saledate: "Practical completion or handover date must be less than 3 years before sale completion date." - exdate: - must_be_before_saledate: "Contract exchange date must be before sale completion date." - must_be_less_than_1_year_from_saledate: "Contract exchange date must be less than 1 year before sale completion date." - saledate: - must_be_after_exdate: "Sale completion date must be after contract exchange date." - must_be_less_than_1_year_from_exdate: "Sale completion date must be less than 1 year after contract exchange date." - must_be_less_than_3_years_from_hodate: "Sale completion date must be less than 3 years after practical completion or handover date." - must_be_after_hodate: "Sale completion date must be after practical completion or handover date." - previous_property_type: - property_type_bedsit: "A bedsit cannot have more than 1 bedroom." - discounted_ownership_value: "The mortgage%{mortgage}%{deposit_and_grant_sentence} added together is %{mortgage_deposit_and_grant_total}.

    The full purchase price%{discount_sentence} is %{value_with_discount}.

    These two amounts should be the same." - outright_sale_value: "The mortgage%{mortgage} and cash deposit (%{deposit}) when added together is %{mortgage_and_deposit_total}.

    The full purchase price is %{value}.

    These two amounts should be the same." - monthly_rent: - higher_than_expected: "Basic monthly rent must be between £0.00 and £9,999.00." - grant: - out_of_range: "Loan, grants or subsidies must be between £9,000 and £16,000." - stairbought: - over_max: "The percentage bought in this staircasing transaction cannot be higher than %{max_stairbought}% for %{type} sales." - value: - over_discounted_london_max: "The percentage discount multiplied by the purchase price is %{discount_value}. This figure should not be more than £136,400 for properties in London." - over_discounted_max: "The percentage discount multiplied by the purchase price is %{discount_value}. This figure should not be more than £102,400 for properties outside of London." - non_staircasing_mortgage: - mortgage_used: "The mortgage (%{mortgage}) and cash deposit (%{deposit}) added together is %{mortgage_and_deposit_total}.

    The full purchase price (%{value}) multiplied by the percentage equity stake purchased (%{equity}) is %{expected_shared_ownership_deposit_value}.

    These two amounts should be the same." - mortgage_not_used: "The cash deposit is %{deposit}.

    The full purchase price (%{value}) multiplied by the percentage bought is %{expected_shared_ownership_deposit_value}.

    These two amounts should be the same." - mortgage_used_socialhomebuy: "The mortgage amount (%{mortgage}), cash deposit (%{deposit}), and cash discount (%{cashdis}) added together is %{mortgage_deposit_and_discount_total}.

    The full purchase price (%{value}) multiplied by the percentage equity stake purchased (%{equity}) is %{expected_shared_ownership_deposit_value}.

    These two amounts should be the same." - mortgage_not_used_socialhomebuy: "The cash deposit (%{deposit}) and cash discount (%{cashdis}) added together is %{deposit_and_discount_total}.

    The full purchase price (%{value}) multiplied by the percentage bought (%{equity}) is %{expected_shared_ownership_deposit_value}.

    These two amounts should be the same." - staircasing_mortgage: - mortgage_used: "The mortgage (%{mortgage}) and cash deposit (%{deposit}) added together is %{mortgage_and_deposit_total}.

    The full purchase price (%{value}) multiplied by the percentage bought is %{stairbought_part_of_value}.

    These two amounts should be the same." - mortgage_not_used: "The cash deposit is %{deposit}.

    The full purchase price (%{value}) multiplied by the percentage bought is %{stairbought_part_of_value}.

    These two amounts should be the same." - mortgage_used_socialhomebuy: "The mortgage amount (%{mortgage}), cash deposit (%{deposit}), and cash discount (%{cashdis}) added together is %{mortgage_deposit_and_discount_total}.

    The full purchase price (%{value}) multiplied by the percentage bought (%{stairbought}) is %{stairbought_part_of_value}.

    These two amounts should be the same." - mortgage_not_used_socialhomebuy: "The cash deposit (%{deposit}) and cash discount (%{cashdis}) added together is %{deposit_and_discount_total}.

    The full purchase price (%{value}) multiplied by the percentage bought (%{stairbought}) is %{stairbought_part_of_value}.

    These two amounts should be the same." - stairowned: - mortgageused_dont_know: "The percentage owned has to be 100% if the mortgage used is 'Don’t know'" merge_request: organisation_part_of_another_merge: "This organisation is part of another merge - select a different one." organisation_not_selected: "Select an organisation from the search list." diff --git a/config/locales/validations/sales/sale_information.en.yml b/config/locales/validations/sales/sale_information.en.yml new file mode 100644 index 000000000..20aca17d2 --- /dev/null +++ b/config/locales/validations/sales/sale_information.en.yml @@ -0,0 +1,125 @@ +en: + validations: + sales: + sale_information: + ownershipsch: + discounted_ownership_value: "The mortgage%{mortgage}%{deposit_and_grant_sentence} added together is %{mortgage_deposit_and_grant_total}.

    The full purchase price%{discount_sentence} is %{value_with_discount}.

    These two amounts should be the same." + outright_sale_value: "The mortgage%{mortgage} and cash deposit (%{deposit}) when added together is %{mortgage_and_deposit_total}.

    The full purchase price is %{value}.

    These two amounts should be the same." + hodate: + must_be_before_saledate: "Practical completion or handover date must be before sale completion date." + must_be_less_than_3_years_from_saledate: "Practical completion or handover date must be less than 3 years before sale completion date." + saledate: + must_be_after_hodate: "Sale completion date must be after practical completion or handover date." + must_be_less_than_3_years_from_hodate: "Sale completion date must be less than 3 years after practical completion or handover date." + must_be_after_exdate: "Sale completion date must be after contract exchange date." + must_be_less_than_1_year_from_exdate: "Sale completion date must be less than 1 year after contract exchange date." + mortgage_used_year: "You must answer either ‘yes’ or ‘no’ to the question ‘was a mortgage used’ for the selected year." + exdate: + must_be_before_saledate: "Contract exchange date must be before sale completion date." + must_be_less_than_1_year_from_saledate: "Contract exchange date must be less than 1 year before sale completion date." + fromprop: + previous_property_type_bedsit: "A bedsit cannot have more than 1 bedroom." + frombeds: + previous_property_type_bedsit: "A bedsit cannot have more than 1 bedroom." + mortgageused: + discounted_ownership_value: "The mortgage%{mortgage}%{deposit_and_grant_sentence} added together is %{mortgage_deposit_and_grant_total}.

    The full purchase price%{discount_sentence} is %{value_with_discount}.

    These two amounts should be the same." + outright_sale_value: "The mortgage%{mortgage} and cash deposit (%{deposit}) when added together is %{mortgage_and_deposit_total}.

    The full purchase price is %{value}.

    These two amounts should be the same." + mortgageused_dont_know: "The percentage owned has to be 100% if the mortgage used is 'Don’t know'" + non_staircasing_mortgage: + mortgage_not_used: "The cash deposit is %{deposit}.

    The full purchase price (%{value}) multiplied by the percentage bought is %{expected_shared_ownership_deposit_value}.

    These two amounts should be the same." + mortgage_not_used_socialhomebuy: "The cash deposit (%{deposit}) and cash discount (%{cashdis}) added together is %{deposit_and_discount_total}.

    The full purchase price (%{value}) multiplied by the percentage bought (%{equity}) is %{expected_shared_ownership_deposit_value}.

    These two amounts should be the same." + staircasing_mortgage: + mortgage_not_used: "The cash deposit is %{deposit}.

    The full purchase price (%{value}) multiplied by the percentage bought is %{stairbought_part_of_value}.

    These two amounts should be the same." + mortgage_not_used_socialhomebuy: "The cash deposit (%{deposit}) and cash discount (%{cashdis}) added together is %{deposit_and_discount_total}.

    The full purchase price (%{value}) multiplied by the percentage bought (%{stairbought}) is %{stairbought_part_of_value}.

    These two amounts should be the same." + mortgage: + discounted_ownership_value: "The mortgage%{mortgage}%{deposit_and_grant_sentence} added together is %{mortgage_deposit_and_grant_total}.

    The full purchase price%{discount_sentence} is %{value_with_discount}.

    These two amounts should be the same." + outright_sale_value: "The mortgage%{mortgage} and cash deposit (%{deposit}) when added together is %{mortgage_and_deposit_total}.

    The full purchase price is %{value}.

    These two amounts should be the same." + non_staircasing_mortgage: + mortgage_used: "The mortgage (%{mortgage}) and cash deposit (%{deposit}) added together is %{mortgage_and_deposit_total}.

    The full purchase price (%{value}) multiplied by the percentage equity stake purchased (%{equity}) is %{expected_shared_ownership_deposit_value}.

    These two amounts should be the same." + mortgage_used_socialhomebuy: "The mortgage amount (%{mortgage}), cash deposit (%{deposit}), and cash discount (%{cashdis}) added together is %{mortgage_deposit_and_discount_total}.

    The full purchase price (%{value}) multiplied by the percentage equity stake purchased (%{equity}) is %{expected_shared_ownership_deposit_value}.

    These two amounts should be the same." + staircasing_mortgage: + mortgage_used: "The mortgage (%{mortgage}) and cash deposit (%{deposit}) added together is %{mortgage_and_deposit_total}.

    The full purchase price (%{value}) multiplied by the percentage bought is %{stairbought_part_of_value}.

    These two amounts should be the same." + mortgage_used_socialhomebuy: "The mortgage amount (%{mortgage}), cash deposit (%{deposit}), and cash discount (%{cashdis}) added together is %{mortgage_deposit_and_discount_total}.

    The full purchase price (%{value}) multiplied by the percentage bought (%{stairbought}) is %{stairbought_part_of_value}.

    These two amounts should be the same." + value: + discounted_ownership_value: "The mortgage%{mortgage}%{deposit_and_grant_sentence} added together is %{mortgage_deposit_and_grant_total}.

    The full purchase price%{discount_sentence} is %{value_with_discount}.

    These two amounts should be the same." + outright_sale_value: "The mortgage%{mortgage} and cash deposit (%{deposit}) when added together is %{mortgage_and_deposit_total}.

    The full purchase price is %{value}.

    These two amounts should be the same." + value_over_discounted_london_max: "The percentage discount multiplied by the purchase price is %{discount_value}. This figure should not be more than £136,400 for properties in London." + value_over_discounted_max: "The percentage discount multiplied by the purchase price is %{discount_value}. This figure should not be more than £102,400 for properties outside of London." + non_staircasing_mortgage: + mortgage_used: "The mortgage (%{mortgage}) and cash deposit (%{deposit}) added together is %{mortgage_and_deposit_total}.

    The full purchase price (%{value}) multiplied by the percentage equity stake purchased (%{equity}) is %{expected_shared_ownership_deposit_value}.

    These two amounts should be the same." + mortgage_not_used: "The cash deposit is %{deposit}.

    The full purchase price (%{value}) multiplied by the percentage bought is %{expected_shared_ownership_deposit_value}.

    These two amounts should be the same." + mortgage_used_socialhomebuy: "The mortgage amount (%{mortgage}), cash deposit (%{deposit}), and cash discount (%{cashdis}) added together is %{mortgage_deposit_and_discount_total}.

    The full purchase price (%{value}) multiplied by the percentage equity stake purchased (%{equity}) is %{expected_shared_ownership_deposit_value}.

    These two amounts should be the same." + mortgage_not_used_socialhomebuy: "The cash deposit (%{deposit}) and cash discount (%{cashdis}) added together is %{deposit_and_discount_total}.

    The full purchase price (%{value}) multiplied by the percentage bought (%{equity}) is %{expected_shared_ownership_deposit_value}.

    These two amounts should be the same." + staircasing_mortgage: + mortgage_used: "The mortgage (%{mortgage}) and cash deposit (%{deposit}) added together is %{mortgage_and_deposit_total}.

    The full purchase price (%{value}) multiplied by the percentage bought is %{stairbought_part_of_value}.

    These two amounts should be the same." + mortgage_not_used: "The cash deposit is %{deposit}.

    The full purchase price (%{value}) multiplied by the percentage bought is %{stairbought_part_of_value}.

    These two amounts should be the same." + mortgage_used_socialhomebuy: "The mortgage amount (%{mortgage}), cash deposit (%{deposit}), and cash discount (%{cashdis}) added together is %{mortgage_deposit_and_discount_total}.

    The full purchase price (%{value}) multiplied by the percentage bought (%{stairbought}) is %{stairbought_part_of_value}.

    These two amounts should be the same." + mortgage_not_used_socialhomebuy: "The cash deposit (%{deposit}) and cash discount (%{cashdis}) added together is %{deposit_and_discount_total}.

    The full purchase price (%{value}) multiplied by the percentage bought (%{stairbought}) is %{stairbought_part_of_value}.

    These two amounts should be the same." + deposit: + discounted_ownership_value: "The mortgage%{mortgage}%{deposit_and_grant_sentence} added together is %{mortgage_deposit_and_grant_total}.

    The full purchase price%{discount_sentence} is %{value_with_discount}.

    These two amounts should be the same." + outright_sale_value: "The mortgage%{mortgage} and cash deposit (%{deposit}) when added together is %{mortgage_and_deposit_total}.

    The full purchase price is %{value}.

    These two amounts should be the same." + non_staircasing_mortgage: + mortgage_used: "The mortgage (%{mortgage}) and cash deposit (%{deposit}) added together is %{mortgage_and_deposit_total}.

    The full purchase price (%{value}) multiplied by the percentage equity stake purchased (%{equity}) is %{expected_shared_ownership_deposit_value}.

    These two amounts should be the same." + mortgage_not_used: "The cash deposit is %{deposit}.

    The full purchase price (%{value}) multiplied by the percentage bought is %{expected_shared_ownership_deposit_value}.

    These two amounts should be the same." + mortgage_used_socialhomebuy: "The mortgage amount (%{mortgage}), cash deposit (%{deposit}), and cash discount (%{cashdis}) added together is %{mortgage_deposit_and_discount_total}.

    The full purchase price (%{value}) multiplied by the percentage equity stake purchased (%{equity}) is %{expected_shared_ownership_deposit_value}.

    These two amounts should be the same." + mortgage_not_used_socialhomebuy: "The cash deposit (%{deposit}) and cash discount (%{cashdis}) added together is %{deposit_and_discount_total}.

    The full purchase price (%{value}) multiplied by the percentage bought (%{equity}) is %{expected_shared_ownership_deposit_value}.

    These two amounts should be the same." + staircasing_mortgage: + mortgage_used: "The mortgage (%{mortgage}) and cash deposit (%{deposit}) added together is %{mortgage_and_deposit_total}.

    The full purchase price (%{value}) multiplied by the percentage bought is %{stairbought_part_of_value}.

    These two amounts should be the same." + mortgage_not_used: "The cash deposit is %{deposit}.

    The full purchase price (%{value}) multiplied by the percentage bought is %{stairbought_part_of_value}.

    These two amounts should be the same." + mortgage_used_socialhomebuy: "The mortgage amount (%{mortgage}), cash deposit (%{deposit}), and cash discount (%{cashdis}) added together is %{mortgage_deposit_and_discount_total}.

    The full purchase price (%{value}) multiplied by the percentage bought (%{stairbought}) is %{stairbought_part_of_value}.

    These two amounts should be the same." + mortgage_not_used_socialhomebuy: "The cash deposit (%{deposit}) and cash discount (%{cashdis}) added together is %{deposit_and_discount_total}.

    The full purchase price (%{value}) multiplied by the percentage bought (%{stairbought}) is %{stairbought_part_of_value}.

    These two amounts should be the same." + cashdis: + non_staircasing_mortgage: + mortgage_used_socialhomebuy: "The mortgage amount (%{mortgage}), cash deposit (%{deposit}), and cash discount (%{cashdis}) added together is %{mortgage_deposit_and_discount_total}.

    The full purchase price (%{value}) multiplied by the percentage equity stake purchased (%{equity}) is %{expected_shared_ownership_deposit_value}.

    These two amounts should be the same." + mortgage_not_used_socialhomebuy: "The cash deposit (%{deposit}) and cash discount (%{cashdis}) added together is %{deposit_and_discount_total}.

    The full purchase price (%{value}) multiplied by the percentage bought (%{equity}) is %{expected_shared_ownership_deposit_value}.

    These two amounts should be the same." + staircasing_mortgage: + mortgage_used_socialhomebuy: "The mortgage amount (%{mortgage}), cash deposit (%{deposit}), and cash discount (%{cashdis}) added together is %{mortgage_deposit_and_discount_total}.

    The full purchase price (%{value}) multiplied by the percentage bought (%{stairbought}) is %{stairbought_part_of_value}.

    These two amounts should be the same." + mortgage_not_used_socialhomebuy: "The cash deposit (%{deposit}) and cash discount (%{cashdis}) added together is %{deposit_and_discount_total}.

    The full purchase price (%{value}) multiplied by the percentage bought (%{stairbought}) is %{stairbought_part_of_value}.

    These two amounts should be the same." + equity: + non_staircasing_mortgage: + mortgage_used: "The mortgage (%{mortgage}) and cash deposit (%{deposit}) added together is %{mortgage_and_deposit_total}.

    The full purchase price (%{value}) multiplied by the percentage equity stake purchased (%{equity}) is %{expected_shared_ownership_deposit_value}.

    These two amounts should be the same." + mortgage_not_used: "The cash deposit is %{deposit}.

    The full purchase price (%{value}) multiplied by the percentage bought is %{expected_shared_ownership_deposit_value}.

    These two amounts should be the same." + mortgage_used_socialhomebuy: "The mortgage amount (%{mortgage}), cash deposit (%{deposit}), and cash discount (%{cashdis}) added together is %{mortgage_deposit_and_discount_total}.

    The full purchase price (%{value}) multiplied by the percentage equity stake purchased (%{equity}) is %{expected_shared_ownership_deposit_value}.

    These two amounts should be the same." + mortgage_not_used_socialhomebuy: "The cash deposit (%{deposit}) and cash discount (%{cashdis}) added together is %{deposit_and_discount_total}.

    The full purchase price (%{value}) multiplied by the percentage bought (%{equity}) is %{expected_shared_ownership_deposit_value}.

    These two amounts should be the same." + discount: + discounted_ownership_value: "The mortgage%{mortgage}%{deposit_and_grant_sentence} added together is %{mortgage_deposit_and_grant_total}.

    The full purchase price%{discount_sentence} is %{value_with_discount}.

    These two amounts should be the same." + value_over_discounted_london_max: "The percentage discount multiplied by the purchase price is %{discount_value}. This figure should not be more than £136,400 for properties in London." + value_over_discounted_max: "The percentage discount multiplied by the purchase price is %{discount_value}. This figure should not be more than £102,400 for properties outside of London." + grant: + discounted_ownership_value: "The mortgage%{mortgage}%{deposit_and_grant_sentence} added together is %{mortgage_deposit_and_grant_total}.

    The full purchase price%{discount_sentence} is %{value_with_discount}.

    These two amounts should be the same." + out_of_range: "Loan, grants or subsidies must be between £9,000 and £16,000." + mrent: + monthly_rent_higher_than_expected: "Basic monthly rent must be between £0.00 and £9,999.00." + type: + monthly_rent_higher_than_expected: "Basic monthly rent must be between £0.00 and £9,999.00." + stairbought_over_max: "The percentage bought in this staircasing transaction cannot be higher than %{max_stairbought}% for %{type} sales." + non_staircasing_mortgage: + mortgage_used: "The mortgage (%{mortgage}) and cash deposit (%{deposit}) added together is %{mortgage_and_deposit_total}.

    The full purchase price (%{value}) multiplied by the percentage equity stake purchased (%{equity}) is %{expected_shared_ownership_deposit_value}.

    These two amounts should be the same." + mortgage_not_used: "The cash deposit is %{deposit}.

    The full purchase price (%{value}) multiplied by the percentage bought is %{expected_shared_ownership_deposit_value}.

    These two amounts should be the same." + mortgage_used_socialhomebuy: "The mortgage amount (%{mortgage}), cash deposit (%{deposit}), and cash discount (%{cashdis}) added together is %{mortgage_deposit_and_discount_total}.

    The full purchase price (%{value}) multiplied by the percentage equity stake purchased (%{equity}) is %{expected_shared_ownership_deposit_value}.

    These two amounts should be the same." + mortgage_not_used_socialhomebuy: "The cash deposit (%{deposit}) and cash discount (%{cashdis}) added together is %{deposit_and_discount_total}.

    The full purchase price (%{value}) multiplied by the percentage bought (%{equity}) is %{expected_shared_ownership_deposit_value}.

    These two amounts should be the same." + staircasing_mortgage: + mortgage_used: "The mortgage (%{mortgage}) and cash deposit (%{deposit}) added together is %{mortgage_and_deposit_total}.

    The full purchase price (%{value}) multiplied by the percentage bought is %{stairbought_part_of_value}.

    These two amounts should be the same." + mortgage_not_used: "The cash deposit is %{deposit}.

    The full purchase price (%{value}) multiplied by the percentage bought is %{stairbought_part_of_value}.

    These two amounts should be the same." + mortgage_used_socialhomebuy: "The mortgage amount (%{mortgage}), cash deposit (%{deposit}), and cash discount (%{cashdis}) added together is %{mortgage_deposit_and_discount_total}.

    The full purchase price (%{value}) multiplied by the percentage bought (%{stairbought}) is %{stairbought_part_of_value}.

    These two amounts should be the same." + mortgage_not_used_socialhomebuy: "The cash deposit (%{deposit}) and cash discount (%{cashdis}) added together is %{deposit_and_discount_total}.

    The full purchase price (%{value}) multiplied by the percentage bought (%{stairbought}) is %{stairbought_part_of_value}.

    These two amounts should be the same." + stairbought: + stairbought_over_max: "The percentage bought in this staircasing transaction cannot be higher than %{max_stairbought}% for %{type} sales." + staircasing_mortgage: + mortgage_used: "The mortgage (%{mortgage}) and cash deposit (%{deposit}) added together is %{mortgage_and_deposit_total}.

    The full purchase price (%{value}) multiplied by the percentage bought is %{stairbought_part_of_value}.

    These two amounts should be the same." + mortgage_not_used: "The cash deposit is %{deposit}.

    The full purchase price (%{value}) multiplied by the percentage bought is %{stairbought_part_of_value}.

    These two amounts should be the same." + mortgage_used_socialhomebuy: "The mortgage amount (%{mortgage}), cash deposit (%{deposit}), and cash discount (%{cashdis}) added together is %{mortgage_deposit_and_discount_total}.

    The full purchase price (%{value}) multiplied by the percentage bought (%{stairbought}) is %{stairbought_part_of_value}.

    These two amounts should be the same." + mortgage_not_used_socialhomebuy: "The cash deposit (%{deposit}) and cash discount (%{cashdis}) added together is %{deposit_and_discount_total}.

    The full purchase price (%{value}) multiplied by the percentage bought (%{stairbought}) is %{stairbought_part_of_value}.

    These two amounts should be the same." + stairowned: + mortgageused_dont_know: "The percentage owned has to be 100% if the mortgage used is 'Don’t know'" + staircase: + mortgage_used_value: "You must answer either ‘yes’ or ‘no’ to the question ‘was a mortgage used’ for staircasing transactions." + la: + value_over_discounted_london_max: "The percentage discount multiplied by the purchase price is %{discount_value}. This figure should not be more than £136,400 for properties in London." + value_over_discounted_max: "The percentage discount multiplied by the purchase price is %{discount_value}. This figure should not be more than £102,400 for properties outside of London." + uprn: + value_over_discounted_london_max: "The percentage discount multiplied by the purchase price is %{discount_value}. This figure should not be more than £136,400 for properties in London." + value_over_discounted_max: "The percentage discount multiplied by the purchase price is %{discount_value}. This figure should not be more than £102,400 for properties outside of London." + postcode_full: + value_over_discounted_london_max: "The percentage discount multiplied by the purchase price is %{discount_value}. This figure should not be more than £136,400 for properties in London." + value_over_discounted_max: "The percentage discount multiplied by the purchase price is %{discount_value}. This figure should not be more than £102,400 for properties outside of London." diff --git a/spec/models/validations/sales/sale_information_validations_spec.rb b/spec/models/validations/sales/sale_information_validations_spec.rb index 945d1b25b..1f20163d3 100644 --- a/spec/models/validations/sales/sale_information_validations_spec.rb +++ b/spec/models/validations/sales/sale_information_validations_spec.rb @@ -197,8 +197,8 @@ RSpec.describe Validations::Sales::SaleInformationValidations do it "does add an error if it's a bedsit" do sale_information_validator.validate_previous_property_unit_type(record) - expect(record.errors["fromprop"]).to include(I18n.t("validations.sale_information.previous_property_type.property_type_bedsit")) - expect(record.errors["frombeds"]).to include(I18n.t("validations.sale_information.previous_property_type.property_type_bedsit")) + expect(record.errors["fromprop"]).to include(I18n.t("validations.sales.sale_information.fromprop.previous_property_type_bedsit")) + expect(record.errors["frombeds"]).to include(I18n.t("validations.sales.sale_information.frombeds.previous_property_type_bedsit")) end end end @@ -648,8 +648,8 @@ RSpec.describe Validations::Sales::SaleInformationValidations do it "adds an error" do sale_information_validator.validate_basic_monthly_rent(record) - expect(record.errors[:mrent]).to include(I18n.t("validations.sale_information.monthly_rent.higher_than_expected")) - expect(record.errors[:type]).to include(I18n.t("validations.sale_information.monthly_rent.higher_than_expected")) + expect(record.errors[:mrent]).to include(I18n.t("validations.sales.sale_information.mrent.monthly_rent_higher_than_expected")) + expect(record.errors[:type]).to include(I18n.t("validations.sales.sale_information.type.monthly_rent_higher_than_expected")) end end end From 83877dae69f491451a2910ac5728896eae4a79f0 Mon Sep 17 00:00:00 2001 From: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com> Date: Tue, 29 Oct 2024 14:13:16 +0000 Subject: [PATCH 16/30] Extract lettings household needs copy (#2729) --- .../lettings/pages/type_of_access_needs.rb | 2 +- .../form/lettings/questions/armedforces.rb | 3 - .../lettings/questions/condition_effects.rb | 3 - .../form/lettings/questions/housingneeds.rb | 3 - .../lettings/questions/housingneeds_other.rb | 4 +- .../lettings/questions/housingneeds_type.rb | 4 +- app/models/form/lettings/questions/illness.rb | 3 - app/models/form/lettings/questions/leftreg.rb | 3 - .../form/lettings/questions/preg_occ.rb | 3 - .../form/lettings/questions/reservist.rb | 3 - .../lettings/subsections/household_needs.rb | 1 + .../2023/lettings/household_needs.en.yml | 58 +++++++++++++++++++ .../2024/lettings/household_needs.en.yml | 58 +++++++++++++++++++ 13 files changed, 120 insertions(+), 28 deletions(-) create mode 100644 config/locales/forms/2023/lettings/household_needs.en.yml create mode 100644 config/locales/forms/2024/lettings/household_needs.en.yml diff --git a/app/models/form/lettings/pages/type_of_access_needs.rb b/app/models/form/lettings/pages/type_of_access_needs.rb index 670e2ef89..25b4fe187 100644 --- a/app/models/form/lettings/pages/type_of_access_needs.rb +++ b/app/models/form/lettings/pages/type_of_access_needs.rb @@ -2,7 +2,7 @@ class Form::Lettings::Pages::TypeOfAccessNeeds < ::Form::Page def initialize(id, hsh, subsection) super @id = "type_of_access_needs" - @header = "Disabled access needs" + @copy_key = "lettings.household_needs.housingneeds_type" @depends_on = [{ "housingneeds" => 1 }] end diff --git a/app/models/form/lettings/questions/armedforces.rb b/app/models/form/lettings/questions/armedforces.rb index d7f8e44f2..25dbeff86 100644 --- a/app/models/form/lettings/questions/armedforces.rb +++ b/app/models/form/lettings/questions/armedforces.rb @@ -2,11 +2,8 @@ class Form::Lettings::Questions::Armedforces < ::Form::Question def initialize(id, hsh, page) super @id = "armedforces" - @check_answer_label = "Household links to UK armed forces" - @header = "Does anybody in the household have any links to the UK armed forces?" @type = "radio" @check_answers_card_number = 0 - @hint_text = "This excludes national service.

    If there are several people in the household with links to the UK armed forces, you should answer for the regular. If there’s no regular, answer for the reserve. If there’s no reserve, answer for the spouse or civil partner." @answer_options = ANSWER_OPTIONS @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end diff --git a/app/models/form/lettings/questions/condition_effects.rb b/app/models/form/lettings/questions/condition_effects.rb index de5c188f0..1821f6e98 100644 --- a/app/models/form/lettings/questions/condition_effects.rb +++ b/app/models/form/lettings/questions/condition_effects.rb @@ -2,11 +2,8 @@ class Form::Lettings::Questions::ConditionEffects < ::Form::Question def initialize(id, hsh, page) super @id = "condition_effects" - @check_answer_label = "How is person affected by condition or illness" - @header = "How is the person affected by their condition or illness?" @type = "checkbox" @check_answers_card_number = 0 - @hint_text = "Select all that apply." @answer_options = ANSWER_OPTIONS @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end diff --git a/app/models/form/lettings/questions/housingneeds.rb b/app/models/form/lettings/questions/housingneeds.rb index 3d3369d68..03c80d5cb 100644 --- a/app/models/form/lettings/questions/housingneeds.rb +++ b/app/models/form/lettings/questions/housingneeds.rb @@ -2,11 +2,8 @@ class Form::Lettings::Questions::Housingneeds < ::Form::Question def initialize(id, hsh, page) super @id = "housingneeds" - @check_answer_label = "Anybody with disabled access needs" - @header = "Does anybody in the household have any disabled access needs?" @type = "radio" @check_answers_card_number = 0 - @hint_text = "" @answer_options = ANSWER_OPTIONS @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end diff --git a/app/models/form/lettings/questions/housingneeds_other.rb b/app/models/form/lettings/questions/housingneeds_other.rb index e8fa2c0f9..75834d3bb 100644 --- a/app/models/form/lettings/questions/housingneeds_other.rb +++ b/app/models/form/lettings/questions/housingneeds_other.rb @@ -2,11 +2,9 @@ class Form::Lettings::Questions::HousingneedsOther < ::Form::Question def initialize(id, hsh, page) super @id = "housingneeds_other" - @check_answer_label = "Other disabled access needs" - @header = "Do they have any other disabled access needs?" + @copy_key = "lettings.household_needs.housingneeds_type.housingneeds_other" @type = "radio" @check_answers_card_number = 0 - @hint_text = "" @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end diff --git a/app/models/form/lettings/questions/housingneeds_type.rb b/app/models/form/lettings/questions/housingneeds_type.rb index a3de7223d..50b9c3742 100644 --- a/app/models/form/lettings/questions/housingneeds_type.rb +++ b/app/models/form/lettings/questions/housingneeds_type.rb @@ -2,11 +2,9 @@ class Form::Lettings::Questions::HousingneedsType < ::Form::Question def initialize(id, hsh, page) super @id = "housingneeds_type" - @check_answer_label = "Disabled access needs" - @header = "What type of access needs do they have?" + @copy_key = "lettings.household_needs.housingneeds_type.housingneeds_type" @type = "radio" @check_answers_card_number = 0 - @hint_text = "" @answer_options = ANSWER_OPTIONS @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end diff --git a/app/models/form/lettings/questions/illness.rb b/app/models/form/lettings/questions/illness.rb index 20b76bec4..f92a7a04a 100644 --- a/app/models/form/lettings/questions/illness.rb +++ b/app/models/form/lettings/questions/illness.rb @@ -2,11 +2,8 @@ class Form::Lettings::Questions::Illness < ::Form::Question def initialize(id, hsh, page) super @id = "illness" - @check_answer_label = "Anybody in household with physical or mental health condition" - @header = "Does anybody in the household have a physical or mental health condition (or other illness) expected to last 12 months or more?" @type = "radio" @check_answers_card_number = 0 - @hint_text = "" @answer_options = ANSWER_OPTIONS @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end diff --git a/app/models/form/lettings/questions/leftreg.rb b/app/models/form/lettings/questions/leftreg.rb index 3868d5ce7..9b90566cf 100644 --- a/app/models/form/lettings/questions/leftreg.rb +++ b/app/models/form/lettings/questions/leftreg.rb @@ -2,11 +2,8 @@ class Form::Lettings::Questions::Leftreg < ::Form::Question def initialize(id, hsh, page) super @id = "leftreg" - @check_answer_label = "Person still serving in UK armed forces" - @header = "Is the person still serving in the UK armed forces?" @type = "radio" @check_answers_card_number = 0 - @hint_text = "" @answer_options = ANSWER_OPTIONS @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end diff --git a/app/models/form/lettings/questions/preg_occ.rb b/app/models/form/lettings/questions/preg_occ.rb index a733fc806..1ad1bd1f5 100644 --- a/app/models/form/lettings/questions/preg_occ.rb +++ b/app/models/form/lettings/questions/preg_occ.rb @@ -2,11 +2,8 @@ class Form::Lettings::Questions::PregOcc < ::Form::Question def initialize(id, hsh, page) super @id = "preg_occ" - @check_answer_label = "Anybody in household pregnant" - @header = "Is anybody in the household pregnant?" @type = "radio" @check_answers_card_number = 0 - @hint_text = "" @answer_options = ANSWER_OPTIONS @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end diff --git a/app/models/form/lettings/questions/reservist.rb b/app/models/form/lettings/questions/reservist.rb index d411f96e7..023f1655d 100644 --- a/app/models/form/lettings/questions/reservist.rb +++ b/app/models/form/lettings/questions/reservist.rb @@ -2,11 +2,8 @@ class Form::Lettings::Questions::Reservist < ::Form::Question def initialize(id, hsh, page) super @id = "reservist" - @check_answer_label = "Person seriously injured or ill as result of serving in UK armed forces" - @header = "Was the person seriously injured or ill as a result of serving in the UK armed forces?" @type = "radio" @check_answers_card_number = 0 - @hint_text = "" @answer_options = ANSWER_OPTIONS @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end diff --git a/app/models/form/lettings/subsections/household_needs.rb b/app/models/form/lettings/subsections/household_needs.rb index 2f6900f4f..3bfbbb336 100644 --- a/app/models/form/lettings/subsections/household_needs.rb +++ b/app/models/form/lettings/subsections/household_needs.rb @@ -2,6 +2,7 @@ class Form::Lettings::Subsections::HouseholdNeeds < ::Form::Subsection def initialize(id, hsh, section) super @id = "household_needs" + @copy_key = "lettings.household_needs.housingneeds_type" @label = "Household needs" @depends_on = [{ "non_location_setup_questions_completed?" => true }] end diff --git a/config/locales/forms/2023/lettings/household_needs.en.yml b/config/locales/forms/2023/lettings/household_needs.en.yml new file mode 100644 index 000000000..1e1a2823e --- /dev/null +++ b/config/locales/forms/2023/lettings/household_needs.en.yml @@ -0,0 +1,58 @@ +en: + forms: + 2023: + lettings: + household_needs: + armedforces: + page_header: "" + check_answer_label: "Household links to UK armed forces" + hint_text: "This excludes national service.

    If there are several people in the household with links to the UK armed forces, you should answer for the regular. If there’s no regular, answer for the reserve. If there’s no reserve, answer for the spouse or civil partner." + question_text: "Does anybody in the household have any links to the UK armed forces?" + + leftreg: + page_header: "" + check_answer_label: "Person still serving in UK armed forces" + hint_text: "" + question_text: "Is the person still serving in the UK armed forces?" + + reservist: + page_header: "" + check_answer_label: "Person seriously injured or ill as result of serving in UK armed forces" + hint_text: "" + question_text: "Was the person seriously injured or ill as a result of serving in the UK armed forces?" + + preg_occ: + page_header: "" + check_answer_label: "Anybody in household pregnant" + hint_text: "" + question_text: "Is anybody in the household pregnant?" + + housingneeds: + page_header: "" + check_answer_label: "Anybody with disabled access needs" + hint_text: "" + question_text: "Does anybody in the household have any disabled access needs?" + + housingneeds_type: + page_header: "Disabled access needs" + housingneeds_type: + check_answer_label: "Disabled access needs" + hint_text: "" + question_text: "What type of access needs do they have?" + housingneeds_other: + check_answer_label: "Other disabled access needs" + hint_text: "" + question_text: "Do they have any other disabled access needs?" + + illness: + page_header: "" + check_answer_label: "Anybody in household with physical or mental health condition" + hint_text: "" + question_text: "Does anybody in the household have a physical or mental health condition (or other illness) expected to last 12 months or more?" + + condition_effects: + page_header: "" + check_answer_label: "How is person affected by condition or illness" + hint_text: "Select all that apply." + question_text: "How is the person affected by their condition or illness?" + \ No newline at end of file diff --git a/config/locales/forms/2024/lettings/household_needs.en.yml b/config/locales/forms/2024/lettings/household_needs.en.yml new file mode 100644 index 000000000..d934be355 --- /dev/null +++ b/config/locales/forms/2024/lettings/household_needs.en.yml @@ -0,0 +1,58 @@ +en: + forms: + 2024: + lettings: + household_needs: + armedforces: + page_header: "" + check_answer_label: "Household links to UK armed forces" + hint_text: "This excludes national service.

    If there are several people in the household with links to the UK armed forces, you should answer for the regular. If there’s no regular, answer for the reserve. If there’s no reserve, answer for the spouse or civil partner." + question_text: "Does anybody in the household have any links to the UK armed forces?" + + leftreg: + page_header: "" + check_answer_label: "Person still serving in UK armed forces" + hint_text: "" + question_text: "Is the person still serving in the UK armed forces?" + + reservist: + page_header: "" + check_answer_label: "Person seriously injured or ill as result of serving in UK armed forces" + hint_text: "" + question_text: "Was the person seriously injured or ill as a result of serving in the UK armed forces?" + + preg_occ: + page_header: "" + check_answer_label: "Anybody in household pregnant" + hint_text: "" + question_text: "Is anybody in the household pregnant?" + + housingneeds: + page_header: "" + check_answer_label: "Anybody with disabled access needs" + hint_text: "" + question_text: "Does anybody in the household have any disabled access needs?" + + housingneeds_type: + page_header: "Disabled access needs" + housingneeds_type: + check_answer_label: "Disabled access needs" + hint_text: "" + question_text: "What type of access needs do they have?" + housingneeds_other: + check_answer_label: "Other disabled access needs" + hint_text: "" + question_text: "Do they have any other disabled access needs?" + + illness: + page_header: "" + check_answer_label: "Anybody in household with physical or mental health condition" + hint_text: "" + question_text: "Does anybody in the household have a physical or mental health condition (or other illness) expected to last 12 months or more?" + + condition_effects: + page_header: "" + check_answer_label: "How is person affected by condition or illness" + hint_text: "Select all that apply." + question_text: "How is the person affected by their condition or illness?" + \ No newline at end of file From af430ef3735597fff96cb1e3b764415c55dae9a9 Mon Sep 17 00:00:00 2001 From: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com> Date: Tue, 29 Oct 2024 15:09:55 +0000 Subject: [PATCH 17/30] Update flaky test (#2736) --- spec/requests/locations_controller_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/requests/locations_controller_spec.rb b/spec/requests/locations_controller_spec.rb index b42176967..a7d7684f0 100644 --- a/spec/requests/locations_controller_spec.rb +++ b/spec/requests/locations_controller_spec.rb @@ -180,7 +180,7 @@ RSpec.describe LocationsController, type: :request do context "when signed in as a data coordinator user" do let(:user) { create(:user, :data_coordinator) } - let(:scheme) { create(:scheme, owning_organisation: user.organisation) } + let(:scheme) { create(:scheme, owning_organisation: user.organisation, service_name: "Some name") } let!(:locations) { create_list(:location, 3, scheme:, startdate: Time.zone.local(2022, 4, 1)) } before do @@ -288,7 +288,7 @@ RSpec.describe LocationsController, type: :request do it "has search in the title" do expected_title = CGI.escapeHTML("#{scheme.service_name} (1 location matching ‘#{search_param}’) - Submit social housing lettings and sales data (CORE) - GOV.UK") - expect(page).to have_title(expected_title) + expect(page.title).to eq(expected_title) end end From ff3f789acc96cfa636cd7c46ba16a12272ed4f50 Mon Sep 17 00:00:00 2001 From: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com> Date: Wed, 30 Oct 2024 10:54:45 +0000 Subject: [PATCH 18/30] CLDC-3681 Extract lettings household characteristics copy (#2728) * Extract lettings household characteristics copy * Update cya labels for age known * Update missing keys and copy --- .../form/lettings/pages/lead_tenant_age.rb | 1 + .../lead_tenant_ethnic_background_arab.rb | 1 + .../lead_tenant_ethnic_background_asian.rb | 1 + .../lead_tenant_ethnic_background_black.rb | 1 + .../lead_tenant_ethnic_background_mixed.rb | 1 + .../lead_tenant_ethnic_background_white.rb | 1 + .../lettings/pages/lead_tenant_nationality.rb | 1 + app/models/form/lettings/pages/person_age.rb | 9 +- .../form/lettings/pages/person_known.rb | 1 - app/models/form/lettings/questions/age.rb | 8 +- app/models/form/lettings/questions/age1.rb | 3 +- .../form/lettings/questions/age1_known.rb | 11 +- .../form/lettings/questions/age_known.rb | 4 +- .../form/lettings/questions/declaration.rb | 2 - .../form/lettings/questions/details_known.rb | 3 - .../form/lettings/questions/ethnic_arab.rb | 4 +- .../form/lettings/questions/ethnic_asian.rb | 4 +- .../form/lettings/questions/ethnic_black.rb | 4 +- .../form/lettings/questions/ethnic_group.rb | 3 - .../form/lettings/questions/ethnic_mixed.rb | 4 +- .../form/lettings/questions/ethnic_white.rb | 4 +- .../lettings/questions/gender_identity1.rb | 10 - app/models/form/lettings/questions/hhmemb.rb | 3 - .../form/lettings/questions/nationality.rb | 3 - .../lettings/questions/nationality_all.rb | 3 +- .../questions/nationality_all_group.rb | 4 +- .../questions/person_gender_identity.rb | 10 - .../lettings/questions/person_relationship.rb | 3 - .../questions/person_working_situation.rb | 3 - .../lettings/questions/working_situation1.rb | 3 - .../subsections/household_characteristics.rb | 7 - .../lettings/household_characteristics.en.yml | 323 ++++++++++++++++++ .../lettings/household_characteristics.en.yml | 322 +++++++++++++++++ .../form/lettings/pages/person_age_spec.rb | 35 +- .../form/lettings/questions/age_spec.rb | 3 +- .../household_characteristics_spec.rb | 42 +-- 36 files changed, 692 insertions(+), 153 deletions(-) create mode 100644 config/locales/forms/2023/lettings/household_characteristics.en.yml create mode 100644 config/locales/forms/2024/sales/lettings/household_characteristics.en.yml diff --git a/app/models/form/lettings/pages/lead_tenant_age.rb b/app/models/form/lettings/pages/lead_tenant_age.rb index 640d23142..3058d8a77 100644 --- a/app/models/form/lettings/pages/lead_tenant_age.rb +++ b/app/models/form/lettings/pages/lead_tenant_age.rb @@ -2,6 +2,7 @@ class Form::Lettings::Pages::LeadTenantAge < ::Form::Page def initialize(id, hsh, subsection) super @id = "lead_tenant_age" + @copy_key = "lettings.household_characteristics.age1" @depends_on = [{ "declaration" => 1 }] end diff --git a/app/models/form/lettings/pages/lead_tenant_ethnic_background_arab.rb b/app/models/form/lettings/pages/lead_tenant_ethnic_background_arab.rb index 89d73fd34..fe038aa78 100644 --- a/app/models/form/lettings/pages/lead_tenant_ethnic_background_arab.rb +++ b/app/models/form/lettings/pages/lead_tenant_ethnic_background_arab.rb @@ -2,6 +2,7 @@ class Form::Lettings::Pages::LeadTenantEthnicBackgroundArab < ::Form::Page def initialize(id, hsh, subsection) super @id = "lead_tenant_ethnic_background_arab" + @copy_key = "lettings.household_characteristics.ethnic.ethnic_background_arab" @depends_on = [{ "ethnic_group" => 4 }] end diff --git a/app/models/form/lettings/pages/lead_tenant_ethnic_background_asian.rb b/app/models/form/lettings/pages/lead_tenant_ethnic_background_asian.rb index d55ce9837..9f01300d1 100644 --- a/app/models/form/lettings/pages/lead_tenant_ethnic_background_asian.rb +++ b/app/models/form/lettings/pages/lead_tenant_ethnic_background_asian.rb @@ -2,6 +2,7 @@ class Form::Lettings::Pages::LeadTenantEthnicBackgroundAsian < ::Form::Page def initialize(id, hsh, subsection) super @id = "lead_tenant_ethnic_background_asian" + @copy_key = "lettings.household_characteristics.ethnic.ethnic_background_asian" @depends_on = [{ "ethnic_group" => 2 }] end diff --git a/app/models/form/lettings/pages/lead_tenant_ethnic_background_black.rb b/app/models/form/lettings/pages/lead_tenant_ethnic_background_black.rb index 7ce2ef9c4..68bcffb1c 100644 --- a/app/models/form/lettings/pages/lead_tenant_ethnic_background_black.rb +++ b/app/models/form/lettings/pages/lead_tenant_ethnic_background_black.rb @@ -2,6 +2,7 @@ class Form::Lettings::Pages::LeadTenantEthnicBackgroundBlack < ::Form::Page def initialize(id, hsh, subsection) super @id = "lead_tenant_ethnic_background_black" + @copy_key = "lettings.household_characteristics.ethnic.ethnic_background_black" @depends_on = [{ "ethnic_group" => 3 }] end diff --git a/app/models/form/lettings/pages/lead_tenant_ethnic_background_mixed.rb b/app/models/form/lettings/pages/lead_tenant_ethnic_background_mixed.rb index a4c225083..fd1e52c11 100644 --- a/app/models/form/lettings/pages/lead_tenant_ethnic_background_mixed.rb +++ b/app/models/form/lettings/pages/lead_tenant_ethnic_background_mixed.rb @@ -2,6 +2,7 @@ class Form::Lettings::Pages::LeadTenantEthnicBackgroundMixed < ::Form::Page def initialize(id, hsh, subsection) super @id = "lead_tenant_ethnic_background_mixed" + @copy_key = "lettings.household_characteristics.ethnic.ethnic_background_mixed" @depends_on = [{ "ethnic_group" => 1 }] end diff --git a/app/models/form/lettings/pages/lead_tenant_ethnic_background_white.rb b/app/models/form/lettings/pages/lead_tenant_ethnic_background_white.rb index 994e6e159..e457c39fe 100644 --- a/app/models/form/lettings/pages/lead_tenant_ethnic_background_white.rb +++ b/app/models/form/lettings/pages/lead_tenant_ethnic_background_white.rb @@ -2,6 +2,7 @@ class Form::Lettings::Pages::LeadTenantEthnicBackgroundWhite < ::Form::Page def initialize(id, hsh, subsection) super @id = "lead_tenant_ethnic_background_white" + @copy_key = "lettings.household_characteristics.ethnic.ethnic_background_white" @depends_on = [{ "ethnic_group" => 0 }] end diff --git a/app/models/form/lettings/pages/lead_tenant_nationality.rb b/app/models/form/lettings/pages/lead_tenant_nationality.rb index 9fc78644f..d4845f8f9 100644 --- a/app/models/form/lettings/pages/lead_tenant_nationality.rb +++ b/app/models/form/lettings/pages/lead_tenant_nationality.rb @@ -2,6 +2,7 @@ class Form::Lettings::Pages::LeadTenantNationality < ::Form::Page def initialize(id, hsh, subsection) super @id = "lead_tenant_nationality" + @copy_key = "lettings.household_characteristics.#{form.start_year_after_2024? ? 'nationality_all' : 'national'}" @depends_on = [{ "declaration" => 1 }] end diff --git a/app/models/form/lettings/pages/person_age.rb b/app/models/form/lettings/pages/person_age.rb index bbb5da01e..3e6a73e14 100644 --- a/app/models/form/lettings/pages/person_age.rb +++ b/app/models/form/lettings/pages/person_age.rb @@ -1,13 +1,12 @@ class Form::Lettings::Pages::PersonAge < ::Form::Page - def initialize(id, hsh, subsection, person_index:, person_type: "non_child") + def initialize(id, hsh, subsection, person_index:) super(id, hsh, subsection) - @id = "person_#{person_index}_age_#{person_type}" + @id = "person_#{person_index}_age" + @copy_key = "lettings.household_characteristics.age#{person_index}" @person_index = person_index - @person_type = person_type @depends_on = [ { "details_known_#{person_index}" => 0, - "person_#{person_index}_child_relation?" => (person_type == "child"), }, ] end @@ -15,7 +14,7 @@ class Form::Lettings::Pages::PersonAge < ::Form::Page def questions @questions ||= [ Form::Lettings::Questions::AgeKnown.new(nil, nil, self, person_index: @person_index), - Form::Lettings::Questions::Age.new(nil, nil, self, person_index: @person_index, person_type: @person_type), + Form::Lettings::Questions::Age.new(nil, nil, self, person_index: @person_index), ] end end diff --git a/app/models/form/lettings/pages/person_known.rb b/app/models/form/lettings/pages/person_known.rb index b864ab708..6e699926d 100644 --- a/app/models/form/lettings/pages/person_known.rb +++ b/app/models/form/lettings/pages/person_known.rb @@ -2,7 +2,6 @@ class Form::Lettings::Pages::PersonKnown < ::Form::Page def initialize(id, hsh, subsection, person_index:) super(id, hsh, subsection) @id = "person_#{person_index}_known" - @header = "You’ve given us the details for #{person_index - 1} person in the household" @depends_on = (person_index..8).map { |index| { "hhmemb" => index } } @person_index = person_index end diff --git a/app/models/form/lettings/questions/age.rb b/app/models/form/lettings/questions/age.rb index 0a457203c..b861cb39f 100644 --- a/app/models/form/lettings/questions/age.rb +++ b/app/models/form/lettings/questions/age.rb @@ -1,9 +1,8 @@ class Form::Lettings::Questions::Age < ::Form::Question - def initialize(id, hsh, page, person_index:, person_type:) + def initialize(id, hsh, page, person_index:) super(id, hsh, page) @id = "age#{person_index}" - @check_answer_label = "Person #{person_index}’s age" - @header = "Age" + @copy_key = "lettings.household_characteristics.age#{person_index}.age#{person_index}" @type = "numeric" @width = 2 @inferred_check_answers_value = [{ "condition" => { "age#{person_index}_known" => 1 }, "value" => "Not known" }] @@ -13,7 +12,6 @@ class Form::Lettings::Questions::Age < ::Form::Question @step = 1 @person_index = person_index @question_number = question_number - @person_type = person_type @hint_text = hint_text end @@ -31,8 +29,6 @@ class Form::Lettings::Questions::Age < ::Form::Question def hint_text if form.start_year_after_2024? "Answer 1 for children aged under 1 year old" - elsif @person_type == "child" - "For a child under 1, enter 1" end end end diff --git a/app/models/form/lettings/questions/age1.rb b/app/models/form/lettings/questions/age1.rb index 922345e65..72d89096c 100644 --- a/app/models/form/lettings/questions/age1.rb +++ b/app/models/form/lettings/questions/age1.rb @@ -2,8 +2,7 @@ class Form::Lettings::Questions::Age1 < ::Form::Question def initialize(id, hsh, page) super @id = "age1" - @check_answer_label = "Lead tenant’s age" - @header = "Age" + @copy_key = "lettings.household_characteristics.age1.age1" @type = "numeric" @width = 2 @inferred_check_answers_value = [{ "condition" => { "age1_known" => 1 }, "value" => "Not known" }] diff --git a/app/models/form/lettings/questions/age1_known.rb b/app/models/form/lettings/questions/age1_known.rb index 27c185de4..e54d7993b 100644 --- a/app/models/form/lettings/questions/age1_known.rb +++ b/app/models/form/lettings/questions/age1_known.rb @@ -2,8 +2,7 @@ class Form::Lettings::Questions::Age1Known < ::Form::Question def initialize(id, hsh, page) super @id = "age1_known" - @check_answer_label = "" - @header = "Do you know the lead tenant’s age?" + @copy_key = "lettings.household_characteristics.age1.age1_known" @type = "radio" @check_answers_card_number = 1 @answer_options = ANSWER_OPTIONS @@ -14,13 +13,5 @@ class Form::Lettings::Questions::Age1Known < ::Form::Question ANSWER_OPTIONS = { "0" => { "value" => "Yes" }, "1" => { "value" => "No" } }.freeze - def hint_text - if form.start_year_after_2024? - "The ’lead’ or ’main’ tenant is the person in the household who does the most paid work. If several people do the same amount of paid work, the lead tenant is whoever is the oldest." - else - "The ’lead’ or ’main’ tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest." - end - end - QUESTION_NUMBER_FROM_YEAR = { 2023 => 32, 2024 => 31 }.freeze end diff --git a/app/models/form/lettings/questions/age_known.rb b/app/models/form/lettings/questions/age_known.rb index 10ae7dad5..2f5d7ce0b 100644 --- a/app/models/form/lettings/questions/age_known.rb +++ b/app/models/form/lettings/questions/age_known.rb @@ -2,11 +2,9 @@ class Form::Lettings::Questions::AgeKnown < ::Form::Question def initialize(id, hsh, page, person_index:) super(id, hsh, page) @id = "age#{person_index}_known" - @check_answer_label = "" - @header = "Do you know person #{person_index}’s age?" + @copy_key = "lettings.household_characteristics.age#{person_index}.age#{person_index}_known" @type = "radio" @check_answers_card_number = person_index - @hint_text = "" @answer_options = ANSWER_OPTIONS @conditional_for = { "age#{person_index}" => [0] } @hidden_in_check_answers = { diff --git a/app/models/form/lettings/questions/declaration.rb b/app/models/form/lettings/questions/declaration.rb index 5d3f6d76b..c88c7cf3c 100644 --- a/app/models/form/lettings/questions/declaration.rb +++ b/app/models/form/lettings/questions/declaration.rb @@ -2,8 +2,6 @@ class Form::Lettings::Questions::Declaration < ::Form::Question def initialize(id, hsh, page) super @id = "declaration" - @check_answer_label = "Tenant has seen the privacy notice" - @header = "Declaration" @type = "checkbox" @check_answers_card_number = 0 unless form.start_year_after_2024? @top_guidance_partial = form.start_year_after_2024? ? "privacy_notice_tenant_2024" : "privacy_notice_tenant" diff --git a/app/models/form/lettings/questions/details_known.rb b/app/models/form/lettings/questions/details_known.rb index f2850b65e..fda7a2eb7 100644 --- a/app/models/form/lettings/questions/details_known.rb +++ b/app/models/form/lettings/questions/details_known.rb @@ -2,11 +2,8 @@ class Form::Lettings::Questions::DetailsKnown < ::Form::Question def initialize(id, hsh, page, person_index:) super(id, hsh, page) @id = "details_known_#{person_index}" - @check_answer_label = "Details known for person #{person_index}" - @header = "Do you know details for person #{person_index}?" @type = "radio" @check_answers_card_number = person_index - @hint_text = "You must provide details for everyone in the household if you know them." @answer_options = ANSWER_OPTIONS end diff --git a/app/models/form/lettings/questions/ethnic_arab.rb b/app/models/form/lettings/questions/ethnic_arab.rb index 380de645f..d642c1a1b 100644 --- a/app/models/form/lettings/questions/ethnic_arab.rb +++ b/app/models/form/lettings/questions/ethnic_arab.rb @@ -2,11 +2,9 @@ class Form::Lettings::Questions::EthnicArab < ::Form::Question def initialize(id, hsh, page) super @id = "ethnic" - @check_answer_label = "Lead tenant’s ethnic background" - @header = "Which of the following best describes the lead tenant’s Arab background?" + @copy_key = "lettings.household_characteristics.ethnic.ethnic_background_arab" @type = "radio" @check_answers_card_number = 1 - @hint_text = form.start_year_after_2024? ? "" : "The lead tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest." @answer_options = ANSWER_OPTIONS @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end diff --git a/app/models/form/lettings/questions/ethnic_asian.rb b/app/models/form/lettings/questions/ethnic_asian.rb index 33002533b..7fb309bba 100644 --- a/app/models/form/lettings/questions/ethnic_asian.rb +++ b/app/models/form/lettings/questions/ethnic_asian.rb @@ -2,11 +2,9 @@ class Form::Lettings::Questions::EthnicAsian < ::Form::Question def initialize(id, hsh, page) super @id = "ethnic" - @check_answer_label = "Lead tenant’s ethnic background" - @header = "Which of the following best describes the lead tenant’s Asian or Asian British background?" + @copy_key = "lettings.household_characteristics.ethnic.ethnic_background_asian" @type = "radio" @check_answers_card_number = 1 - @hint_text = form.start_year_after_2024? ? "" : "The lead tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest." @answer_options = ANSWER_OPTIONS @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end diff --git a/app/models/form/lettings/questions/ethnic_black.rb b/app/models/form/lettings/questions/ethnic_black.rb index 16a886eb3..e3a88259e 100644 --- a/app/models/form/lettings/questions/ethnic_black.rb +++ b/app/models/form/lettings/questions/ethnic_black.rb @@ -2,11 +2,9 @@ class Form::Lettings::Questions::EthnicBlack < ::Form::Question def initialize(id, hsh, page) super @id = "ethnic" - @check_answer_label = "Lead tenant’s ethnic background" - @header = "Which of the following best describes the lead tenant’s Black, African, Caribbean or Black British background?" + @copy_key = "lettings.household_characteristics.ethnic.ethnic_background_black" @type = "radio" @check_answers_card_number = 1 - @hint_text = form.start_year_after_2024? ? "" : "The lead tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest." @answer_options = ANSWER_OPTIONS @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end diff --git a/app/models/form/lettings/questions/ethnic_group.rb b/app/models/form/lettings/questions/ethnic_group.rb index c3093d48e..16bdfc4ba 100644 --- a/app/models/form/lettings/questions/ethnic_group.rb +++ b/app/models/form/lettings/questions/ethnic_group.rb @@ -2,11 +2,8 @@ class Form::Lettings::Questions::EthnicGroup < ::Form::Question def initialize(id, hsh, page) super @id = "ethnic_group" - @check_answer_label = "Lead tenant’s ethnic group" - @header = "What is the lead tenant’s ethnic group?" @type = "radio" @check_answers_card_number = 1 - @hint_text = form.start_year_after_2024? ? "" : "The lead tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest." @answer_options = ANSWER_OPTIONS @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end diff --git a/app/models/form/lettings/questions/ethnic_mixed.rb b/app/models/form/lettings/questions/ethnic_mixed.rb index cd7d7a4bb..14d1f213b 100644 --- a/app/models/form/lettings/questions/ethnic_mixed.rb +++ b/app/models/form/lettings/questions/ethnic_mixed.rb @@ -2,11 +2,9 @@ class Form::Lettings::Questions::EthnicMixed < ::Form::Question def initialize(id, hsh, page) super @id = "ethnic" - @check_answer_label = "Lead tenant’s ethnic background" - @header = "Which of the following best describes the lead tenant’s Mixed or Multiple ethnic groups background?" + @copy_key = "lettings.household_characteristics.ethnic.ethnic_background_mixed" @type = "radio" @check_answers_card_number = 1 - @hint_text = form.start_year_after_2024? ? "" : "The lead tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest." @answer_options = ANSWER_OPTIONS @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end diff --git a/app/models/form/lettings/questions/ethnic_white.rb b/app/models/form/lettings/questions/ethnic_white.rb index 9c042b576..40b99bc9f 100644 --- a/app/models/form/lettings/questions/ethnic_white.rb +++ b/app/models/form/lettings/questions/ethnic_white.rb @@ -2,11 +2,9 @@ class Form::Lettings::Questions::EthnicWhite < ::Form::Question def initialize(id, hsh, page) super @id = "ethnic" - @check_answer_label = "Lead tenant’s ethnic background" - @header = "Which of the following best describes the lead tenant’s White background?" + @copy_key = "lettings.household_characteristics.ethnic.ethnic_background_white" @type = "radio" @check_answers_card_number = 1 - @hint_text = form.start_year_after_2024? ? "" : "The lead tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest." @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end diff --git a/app/models/form/lettings/questions/gender_identity1.rb b/app/models/form/lettings/questions/gender_identity1.rb index eefe20e15..411bcd3d0 100644 --- a/app/models/form/lettings/questions/gender_identity1.rb +++ b/app/models/form/lettings/questions/gender_identity1.rb @@ -2,8 +2,6 @@ class Form::Lettings::Questions::GenderIdentity1 < ::Form::Question def initialize(id, hsh, page) super @id = "sex1" - @check_answer_label = "Lead tenant’s gender identity" - @header = "Which of these best describes the lead tenant’s gender identity?" @type = "radio" @check_answers_card_number = 1 @answer_options = ANSWER_OPTIONS @@ -18,13 +16,5 @@ class Form::Lettings::Questions::GenderIdentity1 < ::Form::Question "R" => { "value" => "Tenant prefers not to say" }, }.freeze - def hint_text - if form.start_year_after_2024? - "This should be however they personally choose to identify from the options below. This may or may not be the same as their biological sex or the sex they were assigned at birth." - else - "The lead tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest." - end - end - QUESTION_NUMBER_FROM_YEAR = { 2023 => 33, 2024 => 32 }.freeze end diff --git a/app/models/form/lettings/questions/hhmemb.rb b/app/models/form/lettings/questions/hhmemb.rb index bd874d544..61fad98ef 100644 --- a/app/models/form/lettings/questions/hhmemb.rb +++ b/app/models/form/lettings/questions/hhmemb.rb @@ -2,14 +2,11 @@ class Form::Lettings::Questions::Hhmemb < ::Form::Question def initialize(id, hsh, page) super @id = "hhmemb" - @check_answer_label = "Number of household members" - @header = "How many people live in the household for this letting?" @type = "numeric" @width = 2 @check_answers_card_number = 0 @max = 8 @min = 1 - @hint_text = "You can provide details for a maximum of 8 people." @step = 1 @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end diff --git a/app/models/form/lettings/questions/nationality.rb b/app/models/form/lettings/questions/nationality.rb index 51cbec936..8c4a700c1 100644 --- a/app/models/form/lettings/questions/nationality.rb +++ b/app/models/form/lettings/questions/nationality.rb @@ -2,11 +2,8 @@ class Form::Lettings::Questions::Nationality < ::Form::Question def initialize(id, hsh, page) super @id = "national" - @check_answer_label = "Lead tenant’s nationality" - @header = "What is the nationality of the lead tenant?" @type = "radio" @check_answers_card_number = 1 - @hint_text = "The lead tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest." @answer_options = ANSWER_OPTIONS @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end diff --git a/app/models/form/lettings/questions/nationality_all.rb b/app/models/form/lettings/questions/nationality_all.rb index a8324595f..8a0e3d1d9 100644 --- a/app/models/form/lettings/questions/nationality_all.rb +++ b/app/models/form/lettings/questions/nationality_all.rb @@ -2,8 +2,7 @@ class Form::Lettings::Questions::NationalityAll < ::Form::Question def initialize(id, hsh, page) super @id = "nationality_all" - @check_answer_label = "Lead tenant’s nationality" - @header = "Enter a nationality" + @copy_key = "lettings.household_characteristics.nationality_all.nationality_all" @type = "select" @check_answers_card_number = 1 @answer_options = GlobalConstants::COUNTRIES_ANSWER_OPTIONS diff --git a/app/models/form/lettings/questions/nationality_all_group.rb b/app/models/form/lettings/questions/nationality_all_group.rb index 53534851b..559b1c9a0 100644 --- a/app/models/form/lettings/questions/nationality_all_group.rb +++ b/app/models/form/lettings/questions/nationality_all_group.rb @@ -2,11 +2,9 @@ class Form::Lettings::Questions::NationalityAllGroup < ::Form::Question def initialize(id, hsh, page) super @id = "nationality_all_group" - @check_answer_label = "Lead tenant’s nationality" - @header = "What is the nationality of the lead tenant?" + @copy_key = "lettings.household_characteristics.nationality_all.nationality_all_group" @type = "radio" @check_answers_card_number = 1 - @hint_text = "If the lead tenant is a dual national of the United Kingdom and another country, enter United Kingdom. If they are a dual national of two other countries, the tenant should decide which country to enter." @answer_options = ANSWER_OPTIONS @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] @conditional_for = { "nationality_all" => [12] } diff --git a/app/models/form/lettings/questions/person_gender_identity.rb b/app/models/form/lettings/questions/person_gender_identity.rb index 21244938d..0d76d23e3 100644 --- a/app/models/form/lettings/questions/person_gender_identity.rb +++ b/app/models/form/lettings/questions/person_gender_identity.rb @@ -2,8 +2,6 @@ class Form::Lettings::Questions::PersonGenderIdentity < ::Form::Question def initialize(id, hsh, page, person_index:) super(id, hsh, page) @id = "sex#{person_index}" - @check_answer_label = "Person #{person_index}’s gender identity" - @header = "Which of these best describes person #{person_index}’s gender identity?" @type = "radio" @check_answers_card_number = person_index @answer_options = ANSWER_OPTIONS @@ -19,14 +17,6 @@ class Form::Lettings::Questions::PersonGenderIdentity < ::Form::Question "R" => { "value" => "Person prefers not to say" }, }.freeze - def hint_text - if form.start_year_after_2024? - "This should be however they personally choose to identify from the options below. This may or may not be the same as their biological sex or the sex they were assigned at birth." - else - "" - end - end - def question_number base_question_number = case form.start_date.year when 2023 diff --git a/app/models/form/lettings/questions/person_relationship.rb b/app/models/form/lettings/questions/person_relationship.rb index c20ec9f2c..ec7a78969 100644 --- a/app/models/form/lettings/questions/person_relationship.rb +++ b/app/models/form/lettings/questions/person_relationship.rb @@ -2,11 +2,8 @@ class Form::Lettings::Questions::PersonRelationship < ::Form::Question def initialize(id, hsh, page, person_index:) super(id, hsh, page) @id = "relat#{person_index}" - @check_answer_label = "Person #{person_index}’s relationship to the lead tenant" - @header = "What is person #{person_index}’s relationship to the lead tenant?" @type = "radio" @check_answers_card_number = person_index - @hint_text = "" @answer_options = answer_options @person_index = person_index @question_number = question_number diff --git a/app/models/form/lettings/questions/person_working_situation.rb b/app/models/form/lettings/questions/person_working_situation.rb index 3d223a943..cc4644f48 100644 --- a/app/models/form/lettings/questions/person_working_situation.rb +++ b/app/models/form/lettings/questions/person_working_situation.rb @@ -2,11 +2,8 @@ class Form::Lettings::Questions::PersonWorkingSituation < ::Form::Question def initialize(id, hsh, page, person_index:) super(id, hsh, page) @id = "ecstat#{person_index}" - @check_answer_label = "Person #{person_index}’s working situation" - @header = "Which of these best describes person #{person_index}’s working situation?" @type = "radio" @check_answers_card_number = person_index - @hint_text = "" @person_index = person_index @question_number = question_number @answer_options = answer_options diff --git a/app/models/form/lettings/questions/working_situation1.rb b/app/models/form/lettings/questions/working_situation1.rb index b2facdf01..dbaf4fc7a 100644 --- a/app/models/form/lettings/questions/working_situation1.rb +++ b/app/models/form/lettings/questions/working_situation1.rb @@ -2,11 +2,8 @@ class Form::Lettings::Questions::WorkingSituation1 < ::Form::Question def initialize(id, hsh, page) super @id = "ecstat1" - @check_answer_label = "Lead tenant’s working situation" - @header = "Which of these best describes the lead tenant’s working situation?" @type = "radio" @check_answers_card_number = 1 - @hint_text = form.start_year_after_2024? ? "" : "The lead tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest." @answer_options = ANSWER_OPTIONS @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end diff --git a/app/models/form/lettings/subsections/household_characteristics.rb b/app/models/form/lettings/subsections/household_characteristics.rb index b74cc3792..e95cdf19c 100644 --- a/app/models/form/lettings/subsections/household_characteristics.rb +++ b/app/models/form/lettings/subsections/household_characteristics.rb @@ -35,7 +35,6 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection Form::Lettings::Pages::PersonRelationshipToLead.new(nil, nil, self, person_index: 2), (Form::Lettings::Pages::PartnerUnder16ValueCheck.new("relationship_2_partner_under_16_value_check", nil, self, person_index: 2) if form.start_year_after_2024?), (Form::Lettings::Pages::MultiplePartnersValueCheck.new("relationship_2_multiple_partners_value_check", nil, self, person_index: 2) if form.start_year_after_2024?), - Form::Lettings::Pages::PersonAge.new(nil, nil, self, person_index: 2, person_type: "child"), Form::Lettings::Pages::PersonAge.new(nil, nil, self, person_index: 2), Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonAgeValueCheck.new(nil, nil, self, person_index: 2), @@ -56,7 +55,6 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection Form::Lettings::Pages::PersonRelationshipToLead.new(nil, nil, self, person_index: 3), (Form::Lettings::Pages::PartnerUnder16ValueCheck.new("relationship_3_partner_under_16_value_check", nil, self, person_index: 3) if form.start_year_after_2024?), (Form::Lettings::Pages::MultiplePartnersValueCheck.new("relationship_3_multiple_partners_value_check", nil, self, person_index: 3) if form.start_year_after_2024?), - Form::Lettings::Pages::PersonAge.new(nil, nil, self, person_index: 3, person_type: "child"), Form::Lettings::Pages::PersonAge.new(nil, nil, self, person_index: 3), Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonAgeValueCheck.new(nil, nil, self, person_index: 3), @@ -77,7 +75,6 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection Form::Lettings::Pages::PersonRelationshipToLead.new(nil, nil, self, person_index: 4), (Form::Lettings::Pages::PartnerUnder16ValueCheck.new("relationship_4_partner_under_16_value_check", nil, self, person_index: 4) if form.start_year_after_2024?), (Form::Lettings::Pages::MultiplePartnersValueCheck.new("relationship_4_multiple_partners_value_check", nil, self, person_index: 4) if form.start_year_after_2024?), - Form::Lettings::Pages::PersonAge.new(nil, nil, self, person_index: 4, person_type: "child"), Form::Lettings::Pages::PersonAge.new(nil, nil, self, person_index: 4), Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonAgeValueCheck.new(nil, nil, self, person_index: 4), @@ -98,7 +95,6 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection Form::Lettings::Pages::PersonRelationshipToLead.new(nil, nil, self, person_index: 5), (Form::Lettings::Pages::PartnerUnder16ValueCheck.new("relationship_5_partner_under_16_value_check", nil, self, person_index: 5) if form.start_year_after_2024?), (Form::Lettings::Pages::MultiplePartnersValueCheck.new("relationship_5_multiple_partners_value_check", nil, self, person_index: 5) if form.start_year_after_2024?), - Form::Lettings::Pages::PersonAge.new(nil, nil, self, person_index: 5, person_type: "child"), Form::Lettings::Pages::PersonAge.new(nil, nil, self, person_index: 5), Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonAgeValueCheck.new(nil, nil, self, person_index: 5), @@ -119,7 +115,6 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection Form::Lettings::Pages::PersonRelationshipToLead.new(nil, nil, self, person_index: 6), (Form::Lettings::Pages::PartnerUnder16ValueCheck.new("relationship_6_partner_under_16_value_check", nil, self, person_index: 6) if form.start_year_after_2024?), (Form::Lettings::Pages::MultiplePartnersValueCheck.new("relationship_6_multiple_partners_value_check", nil, self, person_index: 6) if form.start_year_after_2024?), - Form::Lettings::Pages::PersonAge.new(nil, nil, self, person_index: 6, person_type: "child"), Form::Lettings::Pages::PersonAge.new(nil, nil, self, person_index: 6), Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonAgeValueCheck.new(nil, nil, self, person_index: 6), @@ -140,7 +135,6 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection Form::Lettings::Pages::PersonRelationshipToLead.new(nil, nil, self, person_index: 7), (Form::Lettings::Pages::PartnerUnder16ValueCheck.new("relationship_7_partner_under_16_value_check", nil, self, person_index: 7) if form.start_year_after_2024?), (Form::Lettings::Pages::MultiplePartnersValueCheck.new("relationship_7_multiple_partners_value_check", nil, self, person_index: 7) if form.start_year_after_2024?), - Form::Lettings::Pages::PersonAge.new(nil, nil, self, person_index: 7, person_type: "child"), Form::Lettings::Pages::PersonAge.new(nil, nil, self, person_index: 7), Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonAgeValueCheck.new(nil, nil, self, person_index: 7), @@ -161,7 +155,6 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection Form::Lettings::Pages::PersonRelationshipToLead.new(nil, nil, self, person_index: 8), (Form::Lettings::Pages::PartnerUnder16ValueCheck.new("relationship_8_partner_under_16_value_check", nil, self, person_index: 8) if form.start_year_after_2024?), (Form::Lettings::Pages::MultiplePartnersValueCheck.new("relationship_8_multiple_partners_value_check", nil, self, person_index: 8) if form.start_year_after_2024?), - Form::Lettings::Pages::PersonAge.new(nil, nil, self, person_index: 8, person_type: "child"), Form::Lettings::Pages::PersonAge.new(nil, nil, self, person_index: 8), Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonAgeValueCheck.new(nil, nil, self, person_index: 8), diff --git a/config/locales/forms/2023/lettings/household_characteristics.en.yml b/config/locales/forms/2023/lettings/household_characteristics.en.yml new file mode 100644 index 000000000..1f175adbc --- /dev/null +++ b/config/locales/forms/2023/lettings/household_characteristics.en.yml @@ -0,0 +1,323 @@ +en: + forms: + 2023: + lettings: + household_characteristics: + declaration: + page_header: "Ministry of Housing, Communities and Local Government privacy notice" + check_answer_label: "Tenant has seen the privacy notice" + hint_text: "" + question_text: "Declaration" + + hhmemb: + page_header: "" + check_answer_label: "Number of household members" + hint_text: "You can provide details for a maximum of 8 people." + question_text: "How many people live in the household for this letting?" + + age1: + page_header: "" + age1_known: + check_answer_label: "" + hint_text: "The ’lead’ or ’main’ tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest." + question_text: "Do you know the lead tenant’s age?" + age1: + check_answer_label: "Lead tenant’s age" + hint_text: "" + question_text: "Age" + + sex1: + page_header: "" + check_answer_label: "Lead tenant’s gender identity" + hint_text: "The lead tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest." + question_text: "Which of these best describes the lead tenant’s gender identity?" + + ethnic_group: + page_header: "" + check_answer_label: "Lead tenant’s ethnic group" + hint_text: "The lead tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest." + question_text: "What is the lead tenant’s ethnic group?" + + ethnic: + ethnic_background_black: + page_header: "" + check_answer_label: "Lead tenant’s ethnic background" + hint_text: "The lead tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest." + question_text: "Which of the following best describes lead tenant’s Black, African, Caribbean or Black British background?" + ethnic_background_asian: + page_header: "" + check_answer_label: "Lead tenant’s ethnic background" + hint_text: "The lead tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest." + question_text: "Which of the following best describes lead tenant’s Asian or Asian British background?" + ethnic_background_arab: + page_header: "" + check_answer_label: "Lead tenant’s ethnic background" + hint_text: "The lead tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest." + question_text: "Which of the following best describes the lead tenant’s Arab background?" + ethnic_background_mixed: + page_header: "" + check_answer_label: "Lead tenant’s ethnic background" + hint_text: "The lead tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest." + question_text: "Which of the following best describes lead tenant’s Mixed or Multiple ethnic groups background?" + ethnic_background_white: + page_header: "" + check_answer_label: "Lead tenant’s ethnic background" + hint_text: "The lead tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest." + question_text: "Which of the following best describes lead tenant’s White background?" + + national: + page_header: "" + check_answer_label: "Lead tenant’s nationality" + hint_text: "The lead tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest." + question_text: "What is the nationality of the lead tenant?" + + ecstat1: + page_header: "" + check_answer_label: "Lead tenant’s working situation" + hint_text: "The lead tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest." + question_text: "Which of these best describes the lead tenant’s working situation?" + + details_known_2: + page_header: "You’ve given us the details for 1 person in the household" + check_answer_label: "Details known for person 2" + hint_text: "You must provide details for everyone in the household if you know them." + question_text: "Do you know details for person 2?" + + relat2: + page_header: "" + check_answer_label: "Person 2’s relationship to the lead tenant" + hint_text: "" + question_text: "What is person 2’s relationship to the lead tenant?" + + age2: + page_header: "" + age2_known: + check_answer_label: "" + hint_text: "" + question_text: "Do you know person 2’s age?" + age2: + check_answer_label: "Person 2’s age" + hint_text: "" + question_text: "Age" + + sex2: + page_header: "" + check_answer_label: "Person 2’s gender identity" + hint_text: "" + question_text: "Which of these best describes person 2’s gender identity?" + + ecstat2: + page_header: "" + check_answer_label: "Person 2’s working situation" + hint_text: "" + question_text: "Which of these best describes person 2’s working situation?" + + details_known_3: + page_header: "You’ve given us the details for 2 people in the household" + check_answer_label: "Details known for person 3" + hint_text: "You must provide details for everyone in the household if you know them." + question_text: "Do you know details for person 3?" + + relat3: + page_header: "" + check_answer_label: "Person 3’s relationship to the lead tenant" + hint_text: "" + question_text: "What is person 3’s relationship to the lead tenant?" + + age3: + page_header: "" + age3_known: + check_answer_label: "" + hint_text: "" + question_text: "Do you know person 3’s age?" + age3: + check_answer_label: "Person 3’s age" + hint_text: "" + question_text: "Age" + + sex3: + page_header: "" + check_answer_label: "Person 3’s gender identity" + hint_text: "" + question_text: "Which of these best describes person 3’s gender identity?" + + ecstat3: + page_header: "" + check_answer_label: "Person 3’s working situation" + hint_text: "" + question_text: "Which of these best describes person 3’s working situation?" + + details_known_4: + page_header: "You’ve given us the details for 3 people in the household" + check_answer_label: "Details known for person 4" + hint_text: "You must provide details for everyone in the household if you know them." + question_text: "Do you know details for person 4?" + + relat4: + page_header: "" + check_answer_label: "Person 4’s relationship to the lead tenant" + hint_text: "" + question_text: "What is person 4’s relationship to the lead tenant?" + + age4: + page_header: "" + age4_known: + check_answer_label: "" + hint_text: "" + question_text: "Do you know person 4’s age?" + age4: + check_answer_label: "Person 4’s age" + hint_text: "" + question_text: "Age" + + sex4: + page_header: "" + check_answer_label: "Person 4’s gender identity" + hint_text: "" + question_text: "Which of these best describes person 4’s gender identity?" + + ecstat4: + page_header: "" + check_answer_label: "Person 4’s working situation" + hint_text: "" + question_text: "Which of these best describes person 4’s working situation?" + + details_known_5: + page_header: "You’ve given us the details for 4 people in the household" + check_answer_label: "Details known for person 5" + hint_text: "You must provide details for everyone in the household if you know them." + question_text: "Do you know details for person 5?" + + relat5: + page_header: "" + check_answer_label: "Person 5’s relationship to the lead tenant" + hint_text: "" + question_text: "What is person 5’s relationship to the lead tenant?" + + age5: + page_header: "" + age5_known: + check_answer_label: "" + hint_text: "" + question_text: "Do you know person 5’s age?" + age5: + check_answer_label: "Person 5’s age" + hint_text: "" + question_text: "Age" + + sex5: + page_header: "" + check_answer_label: "Person 5’s gender identity" + hint_text: "" + question_text: "Which of these best describes person 5’s gender identity?" + + ecstat5: + page_header: "" + check_answer_label: "Person 5’s working situation" + hint_text: "" + question_text: "Which of these best describes person 5’s working situation?" + + details_known_6: + page_header: "You’ve given us the details for 5 people in the household" + check_answer_label: "Details known for person 6" + hint_text: "You must provide details for everyone in the household if you know them." + question_text: "Do you know details for person 6?" + + relat6: + page_header: "" + check_answer_label: "Person 6’s relationship to the lead tenant" + hint_text: "" + question_text: "What is person 6’s relationship to the lead tenant?" + + age6: + page_header: "" + age6_known: + check_answer_label: "" + hint_text: "" + question_text: "Do you know person 6’s age?" + age6: + check_answer_label: "Person 6’s age" + hint_text: "" + question_text: "Age" + + sex6: + page_header: "" + check_answer_label: "Person 6’s gender identity" + hint_text: "" + question_text: "Which of these best describes person 6’s gender identity?" + + ecstat6: + page_header: "" + check_answer_label: "Person 6’s working situation" + hint_text: "" + question_text: "Which of these best describes person 6’s working situation?" + + details_known_7: + page_header: "You’ve given us the details for 6 people in the household" + check_answer_label: "Details known for person 7" + hint_text: "You must provide details for everyone in the household if you know them." + question_text: "Do you know details for person 7?" + + relat7: + page_header: "" + check_answer_label: "Person 7’s relationship to the lead tenant" + hint_text: "" + question_text: "What is person 7’s relationship to the lead tenant?" + + age7: + page_header: "" + age7_known: + check_answer_label: "" + hint_text: "" + question_text: "Do you know person 7’s age?" + age7: + check_answer_label: "Person 7’s age" + hint_text: "" + question_text: "Age" + + sex7: + page_header: "" + check_answer_label: "Person 7’s gender identity" + hint_text: "" + question_text: "Which of these best describes person 7’s gender identity?" + + ecstat7: + page_header: "" + check_answer_label: "Person 7’s working situation" + hint_text: "" + question_text: "Which of these best describes person 7’s working situation?" + + details_known_8: + page_header: "You’ve given us the details for 7 people in the household" + check_answer_label: "Details known for person 8" + hint_text: "You must provide details for everyone in the household if you know them." + question_text: "Do you know details for person 8?" + + relat8: + page_header: "" + check_answer_label: "Person 8’s relationship to the lead tenant" + hint_text: "" + question_text: "What is person 8’s relationship to the lead tenant?" + + age8: + page_header: "" + age8_known: + check_answer_label: "" + hint_text: "" + question_text: "Do you know person 8’s age?" + age8: + check_answer_label: "Person 8’s age" + hint_text: "" + question_text: "Age" + + sex8: + page_header: "" + check_answer_label: "Person 8’s gender identity" + hint_text: "" + question_text: "Which of these best describes person 8’s gender identity?" + + ecstat8: + page_header: "" + check_answer_label: "Person 8’s working situation" + hint_text: "" + question_text: "Which of these best describes person 8’s working situation?" \ No newline at end of file diff --git a/config/locales/forms/2024/sales/lettings/household_characteristics.en.yml b/config/locales/forms/2024/sales/lettings/household_characteristics.en.yml new file mode 100644 index 000000000..04a311f06 --- /dev/null +++ b/config/locales/forms/2024/sales/lettings/household_characteristics.en.yml @@ -0,0 +1,322 @@ +en: + forms: + 2024: + lettings: + household_characteristics: + hhmemb: + page_header: "" + check_answer_label: "Number of household members" + hint_text: "You can provide details for a maximum of 8 people." + question_text: "How many people live in the household for this letting?" + + age1: + page_header: "" + age1_known: + check_answer_label: "" + hint_text: "The ’lead’ or ’main’ tenant is the person in the household who does the most paid work. If several people do the same amount of paid work, the lead tenant is whoever is the oldest." + question_text: "Do you know the lead tenant’s age?" + age1: + check_answer_label: "Lead tenant’s age" + hint_text: "" + question_text: "Age" + + sex1: + page_header: "" + check_answer_label: "Lead tenant’s gender identity" + hint_text: "This should be however they personally choose to identify from the options below. This may or may not be the same as their biological sex or the sex they were assigned at birth." + question_text: "Which of these best describes the lead tenant’s gender identity?" + + ethnic_group: + page_header: "" + check_answer_label: "Lead tenant’s ethnic group" + hint_text: "" + question_text: "What is the lead tenant’s ethnic group?" + + ethnic: + ethnic_background_black: + page_header: "" + check_answer_label: "Lead tenant’s ethnic background" + hint_text: "" + question_text: "Which of the following best describes lead tenant’s Black, African, Caribbean or Black British background?" + ethnic_background_asian: + page_header: "" + check_answer_label: "Lead tenant’s ethnic background" + hint_text: "" + question_text: "Which of the following best describes lead tenant’s Asian or Asian British background?" + ethnic_background_arab: + page_header: "" + check_answer_label: "Lead tenant’s ethnic background" + hint_text: "" + question_text: "Which of the following best describes the lead tenant’s Arab background?" + ethnic_background_mixed: + page_header: "" + check_answer_label: "Lead tenant’s ethnic background" + hint_text: "" + question_text: "Which of the following best describes lead tenant’s Mixed or Multiple ethnic groups background?" + ethnic_background_white: + page_header: "" + check_answer_label: "Lead tenant’s ethnic background" + hint_text: "" + question_text: "Which of the following best describes lead tenant’s White background?" + + nationality_all: + page_header: "" + nationality_all: + check_answer_label: "Lead tenant’s nationality" + hint_text: "" + question_text: "Enter a nationality" + nationality_all_group: + check_answer_label: "Lead tenant’s nationality" + hint_text: "If the lead tenant is a dual national of the United Kingdom and another country, enter United Kingdom. If they are a dual national of two other countries, the tenant should decide which country to enter." + question_text: "What is the nationality of the lead tenant?" + + ecstat1: + page_header: "" + check_answer_label: "Lead tenant’s working situation" + hint_text: "" + question_text: "Which of these best describes the lead tenant’s working situation?" + + details_known_2: + page_header: "You’ve given us the details for 1 person in the household" + check_answer_label: "Details known for person 2" + hint_text: "You must provide details for everyone in the household if you know them." + question_text: "Do you know details for person 2?" + + relat2: + page_header: "" + check_answer_label: "Person 2’s relationship to the lead tenant" + hint_text: "" + question_text: "What is person 2’s relationship to the lead tenant?" + + age2: + page_header: "" + age2_known: + check_answer_label: "" + hint_text: "" + question_text: "Do you know person 2’s age?" + age2: + check_answer_label: "Person 2’s age" + hint_text: "Answer 1 for children aged under 1 year old" + question_text: "Age" + + sex2: + page_header: "" + check_answer_label: "Person 2’s gender identity" + hint_text: "This should be however they personally choose to identify from the options below. This may or may not be the same as their biological sex or the sex they were assigned at birth." + question_text: "Which of these best describes person 2’s gender identity?" + + ecstat2: + page_header: "" + check_answer_label: "Person 2’s working situation" + hint_text: "" + question_text: "Which of these best describes person 2’s working situation?" + + details_known_3: + page_header: "You’ve given us the details for 2 people in the household" + check_answer_label: "Details known for person 3" + hint_text: "You must provide details for everyone in the household if you know them." + question_text: "Do you know details for person 3?" + + relat3: + page_header: "" + check_answer_label: "Person 3’s relationship to the lead tenant" + hint_text: "" + question_text: "What is person 3’s relationship to the lead tenant?" + + age3: + page_header: "" + age3_known: + check_answer_label: "" + hint_text: "" + question_text: "Do you know person 3’s age?" + age3: + check_answer_label: "Person 3’s age" + hint_text: "Answer 1 for children aged under 1 year old" + question_text: "Age" + + sex3: + page_header: "" + check_answer_label: "Person 3’s gender identity" + hint_text: "This should be however they personally choose to identify from the options below. This may or may not be the same as their biological sex or the sex they were assigned at birth." + question_text: "Which of these best describes person 3’s gender identity?" + + ecstat3: + page_header: "" + check_answer_label: "Person 3’s working situation" + hint_text: "" + question_text: "Which of these best describes person 3’s working situation?" + + details_known_4: + page_header: "You’ve given us the details for 3 people in the household" + check_answer_label: "Details known for person 4" + hint_text: "You must provide details for everyone in the household if you know them." + question_text: "Do you know details for person 4?" + + relat4: + page_header: "" + check_answer_label: "Person 4’s relationship to the lead tenant" + hint_text: "" + question_text: "What is person 4’s relationship to the lead tenant?" + + age4: + page_header: "" + age4_known: + check_answer_label: "" + hint_text: "" + question_text: "Do you know person 4’s age?" + age4: + check_answer_label: "Person 4’s age" + hint_text: "Answer 1 for children aged under 1 year old" + question_text: "Age" + + sex4: + page_header: "" + check_answer_label: "Person 4’s gender identity" + hint_text: "This should be however they personally choose to identify from the options below. This may or may not be the same as their biological sex or the sex they were assigned at birth." + question_text: "Which of these best describes person 4’s gender identity?" + + ecstat4: + page_header: "" + check_answer_label: "Person 4’s working situation" + hint_text: "" + question_text: "Which of these best describes person 4’s working situation?" + + details_known_5: + page_header: "You’ve given us the details for 4 people in the household" + check_answer_label: "Details known for person 5" + hint_text: "You must provide details for everyone in the household if you know them." + question_text: "Do you know details for person 5?" + + relat5: + page_header: "" + check_answer_label: "Person 5’s relationship to the lead tenant" + hint_text: "" + question_text: "What is person 5’s relationship to the lead tenant?" + + age5: + page_header: "" + age5_known: + check_answer_label: "" + hint_text: "" + question_text: "Do you know person 5’s age?" + age5: + check_answer_label: "Person 5’s age" + hint_text: "Answer 1 for children aged under 1 year old" + question_text: "Age" + + sex5: + page_header: "" + check_answer_label: "Person 5’s gender identity" + hint_text: "This should be however they personally choose to identify from the options below. This may or may not be the same as their biological sex or the sex they were assigned at birth." + question_text: "Which of these best describes person 5’s gender identity?" + + ecstat5: + page_header: "" + check_answer_label: "Person 5’s working situation" + hint_text: "" + question_text: "Which of these best describes person 5’s working situation?" + + details_known_6: + page_header: "You’ve given us the details for 5 people in the household" + check_answer_label: "Details known for person 6" + hint_text: "You must provide details for everyone in the household if you know them." + question_text: "Do you know details for person 6?" + + relat6: + page_header: "" + check_answer_label: "Person 6’s relationship to the lead tenant" + hint_text: "" + question_text: "What is person 6’s relationship to the lead tenant?" + + age6: + page_header: "" + age6_known: + check_answer_label: "" + hint_text: "" + question_text: "Do you know person 6’s age?" + age6: + check_answer_label: "Person 6’s age" + hint_text: "Answer 1 for children aged under 1 year old" + question_text: "Age" + + sex6: + page_header: "" + check_answer_label: "Person 6’s gender identity" + hint_text: "This should be however they personally choose to identify from the options below. This may or may not be the same as their biological sex or the sex they were assigned at birth." + question_text: "Which of these best describes person 6’s gender identity?" + + ecstat6: + page_header: "" + check_answer_label: "Person 6’s working situation" + hint_text: "" + question_text: "Which of these best describes person 6’s working situation?" + + details_known_7: + page_header: "You’ve given us the details for 6 people in the household" + check_answer_label: "Details known for person 7" + hint_text: "You must provide details for everyone in the household if you know them." + question_text: "Do you know details for person 7?" + + relat7: + page_header: "" + check_answer_label: "Person 7’s relationship to the lead tenant" + hint_text: "" + question_text: "What is person 7’s relationship to the lead tenant?" + + age7: + page_header: "" + age7_known: + check_answer_label: "" + hint_text: "" + question_text: "Do you know person 7’s age?" + age7: + check_answer_label: "Person 7’s age" + hint_text: "Answer 1 for children aged under 1 year old" + question_text: "Age" + + sex7: + page_header: "" + check_answer_label: "Person 7’s gender identity" + hint_text: "This should be however they personally choose to identify from the options below. This may or may not be the same as their biological sex or the sex they were assigned at birth." + question_text: "Which of these best describes person 7’s gender identity?" + + ecstat7: + page_header: "" + check_answer_label: "Person 7’s working situation" + hint_text: "" + question_text: "Which of these best describes person 7’s working situation?" + + details_known_8: + page_header: "You’ve given us the details for 7 people in the household" + check_answer_label: "Details known for person 8" + hint_text: "You must provide details for everyone in the household if you know them." + question_text: "Do you know details for person 8?" + + relat8: + page_header: "" + check_answer_label: "Person 8’s relationship to the lead tenant" + hint_text: "" + question_text: "What is person 8’s relationship to the lead tenant?" + + age8: + page_header: "" + age8_known: + check_answer_label: "" + hint_text: "" + question_text: "Do you know person 8’s age?" + age8: + check_answer_label: "Person 8’s age" + hint_text: "Answer 1 for children aged under 1 year old" + question_text: "Age" + + sex8: + page_header: "" + check_answer_label: "Person 8’s gender identity" + hint_text: "This should be however they personally choose to identify from the options below. This may or may not be the same as their biological sex or the sex they were assigned at birth." + question_text: "Which of these best describes person 8’s gender identity?" + + ecstat8: + page_header: "" + check_answer_label: "Person 8’s working situation" + hint_text: "" + question_text: "Which of these best describes person 8’s working situation?" \ No newline at end of file diff --git a/spec/models/form/lettings/pages/person_age_spec.rb b/spec/models/form/lettings/pages/person_age_spec.rb index c9a57c138..dfcc82406 100644 --- a/spec/models/form/lettings/pages/person_age_spec.rb +++ b/spec/models/form/lettings/pages/person_age_spec.rb @@ -1,12 +1,11 @@ require "rails_helper" RSpec.describe Form::Lettings::Pages::PersonAge, type: :model do - subject(:page) { described_class.new(nil, page_definition, subsection, person_index:, person_type:) } + subject(:page) { described_class.new(nil, page_definition, subsection, person_index:) } let(:page_definition) { nil } let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2024, 4, 1), start_year_after_2024?: false)) } let(:person_index) { 2 } - let(:person_type) { "non_child" } it "has correct subsection" do expect(page.subsection).to eq(subsection) @@ -21,30 +20,14 @@ RSpec.describe Form::Lettings::Pages::PersonAge, type: :model do expect(page.questions.map(&:id)).to eq(%w[age2_known age2]) end - context "when child" do - let(:person_type) { "child" } - - it "has the correct id" do - expect(page.id).to eq("person_2_age_child") - end - - it "has correct depends_on" do - expect(page.depends_on).to eq( - [{ "details_known_2" => 0, "person_2_child_relation?" => true }], - ) - end + it "has the correct id" do + expect(page.id).to eq("person_2_age") end - context "when not child" do - it "has the correct id" do - expect(page.id).to eq("person_2_age_non_child") - end - - it "has correct depends_on" do - expect(page.depends_on).to eq( - [{ "details_known_2" => 0, "person_2_child_relation?" => false }], - ) - end + it "has correct depends_on" do + expect(page.depends_on).to eq( + [{ "details_known_2" => 0 }], + ) end end @@ -56,12 +39,12 @@ RSpec.describe Form::Lettings::Pages::PersonAge, type: :model do end it "has the correct id" do - expect(page.id).to eq("person_3_age_non_child") + expect(page.id).to eq("person_3_age") end it "has correct depends_on" do expect(page.depends_on).to eq( - [{ "details_known_3" => 0, "person_3_child_relation?" => false }], + [{ "details_known_3" => 0 }], ) end end diff --git a/spec/models/form/lettings/questions/age_spec.rb b/spec/models/form/lettings/questions/age_spec.rb index 4ec1ee985..e456007f7 100644 --- a/spec/models/form/lettings/questions/age_spec.rb +++ b/spec/models/form/lettings/questions/age_spec.rb @@ -1,12 +1,11 @@ require "rails_helper" RSpec.describe Form::Lettings::Questions::Age, type: :model do - subject(:question) { described_class.new(nil, question_definition, page, person_index:, person_type:) } + subject(:question) { described_class.new(nil, question_definition, page, person_index:) } let(:question_definition) { nil } let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 4), start_year_after_2024?: false))) } let(:person_index) { 2 } - let(:person_type) { "non_child" } it "has correct page" do expect(question.page).to eq(page) diff --git a/spec/models/form/lettings/subsections/household_characteristics_spec.rb b/spec/models/form/lettings/subsections/household_characteristics_spec.rb index c71ee165c..e199f55d3 100644 --- a/spec/models/form/lettings/subsections/household_characteristics_spec.rb +++ b/spec/models/form/lettings/subsections/household_characteristics_spec.rb @@ -49,8 +49,7 @@ RSpec.describe Form::Lettings::Subsections::HouseholdCharacteristics, type: :mod working_situation_lead_tenant_over_retirement_value_check person_2_known person_2_relationship_to_lead - person_2_age_child - person_2_age_non_child + person_2_age no_females_pregnant_household_person_2_age_value_check females_in_soft_age_range_in_pregnant_household_person_2_age_value_check age_2_under_retirement_value_check @@ -64,8 +63,7 @@ RSpec.describe Form::Lettings::Subsections::HouseholdCharacteristics, type: :mod working_situation_2_over_retirement_value_check person_3_known person_3_relationship_to_lead - person_3_age_child - person_3_age_non_child + person_3_age no_females_pregnant_household_person_3_age_value_check females_in_soft_age_range_in_pregnant_household_person_3_age_value_check age_3_under_retirement_value_check @@ -79,8 +77,7 @@ RSpec.describe Form::Lettings::Subsections::HouseholdCharacteristics, type: :mod working_situation_3_over_retirement_value_check person_4_known person_4_relationship_to_lead - person_4_age_child - person_4_age_non_child + person_4_age no_females_pregnant_household_person_4_age_value_check females_in_soft_age_range_in_pregnant_household_person_4_age_value_check age_4_under_retirement_value_check @@ -94,8 +91,7 @@ RSpec.describe Form::Lettings::Subsections::HouseholdCharacteristics, type: :mod working_situation_4_over_retirement_value_check person_5_known person_5_relationship_to_lead - person_5_age_child - person_5_age_non_child + person_5_age no_females_pregnant_household_person_5_age_value_check females_in_soft_age_range_in_pregnant_household_person_5_age_value_check age_5_under_retirement_value_check @@ -109,8 +105,7 @@ RSpec.describe Form::Lettings::Subsections::HouseholdCharacteristics, type: :mod working_situation_5_over_retirement_value_check person_6_known person_6_relationship_to_lead - person_6_age_child - person_6_age_non_child + person_6_age no_females_pregnant_household_person_6_age_value_check females_in_soft_age_range_in_pregnant_household_person_6_age_value_check age_6_under_retirement_value_check @@ -124,8 +119,7 @@ RSpec.describe Form::Lettings::Subsections::HouseholdCharacteristics, type: :mod working_situation_6_over_retirement_value_check person_7_known person_7_relationship_to_lead - person_7_age_child - person_7_age_non_child + person_7_age no_females_pregnant_household_person_7_age_value_check females_in_soft_age_range_in_pregnant_household_person_7_age_value_check age_7_under_retirement_value_check @@ -139,8 +133,7 @@ RSpec.describe Form::Lettings::Subsections::HouseholdCharacteristics, type: :mod working_situation_7_over_retirement_value_check person_8_known person_8_relationship_to_lead - person_8_age_child - person_8_age_non_child + person_8_age no_females_pregnant_household_person_8_age_value_check females_in_soft_age_range_in_pregnant_household_person_8_age_value_check age_8_under_retirement_value_check @@ -191,8 +184,7 @@ RSpec.describe Form::Lettings::Subsections::HouseholdCharacteristics, type: :mod person_2_relationship_to_lead relationship_2_partner_under_16_value_check relationship_2_multiple_partners_value_check - person_2_age_child - person_2_age_non_child + person_2_age no_females_pregnant_household_person_2_age_value_check females_in_soft_age_range_in_pregnant_household_person_2_age_value_check age_2_under_retirement_value_check @@ -209,8 +201,7 @@ RSpec.describe Form::Lettings::Subsections::HouseholdCharacteristics, type: :mod person_3_relationship_to_lead relationship_3_partner_under_16_value_check relationship_3_multiple_partners_value_check - person_3_age_child - person_3_age_non_child + person_3_age no_females_pregnant_household_person_3_age_value_check females_in_soft_age_range_in_pregnant_household_person_3_age_value_check age_3_under_retirement_value_check @@ -227,8 +218,7 @@ RSpec.describe Form::Lettings::Subsections::HouseholdCharacteristics, type: :mod person_4_relationship_to_lead relationship_4_partner_under_16_value_check relationship_4_multiple_partners_value_check - person_4_age_child - person_4_age_non_child + person_4_age no_females_pregnant_household_person_4_age_value_check females_in_soft_age_range_in_pregnant_household_person_4_age_value_check age_4_under_retirement_value_check @@ -245,8 +235,7 @@ RSpec.describe Form::Lettings::Subsections::HouseholdCharacteristics, type: :mod person_5_relationship_to_lead relationship_5_partner_under_16_value_check relationship_5_multiple_partners_value_check - person_5_age_child - person_5_age_non_child + person_5_age no_females_pregnant_household_person_5_age_value_check females_in_soft_age_range_in_pregnant_household_person_5_age_value_check age_5_under_retirement_value_check @@ -263,8 +252,7 @@ RSpec.describe Form::Lettings::Subsections::HouseholdCharacteristics, type: :mod person_6_relationship_to_lead relationship_6_partner_under_16_value_check relationship_6_multiple_partners_value_check - person_6_age_child - person_6_age_non_child + person_6_age no_females_pregnant_household_person_6_age_value_check females_in_soft_age_range_in_pregnant_household_person_6_age_value_check age_6_under_retirement_value_check @@ -281,8 +269,7 @@ RSpec.describe Form::Lettings::Subsections::HouseholdCharacteristics, type: :mod person_7_relationship_to_lead relationship_7_partner_under_16_value_check relationship_7_multiple_partners_value_check - person_7_age_child - person_7_age_non_child + person_7_age no_females_pregnant_household_person_7_age_value_check females_in_soft_age_range_in_pregnant_household_person_7_age_value_check age_7_under_retirement_value_check @@ -299,8 +286,7 @@ RSpec.describe Form::Lettings::Subsections::HouseholdCharacteristics, type: :mod person_8_relationship_to_lead relationship_8_partner_under_16_value_check relationship_8_multiple_partners_value_check - person_8_age_child - person_8_age_non_child + person_8_age no_females_pregnant_household_person_8_age_value_check females_in_soft_age_range_in_pregnant_household_person_8_age_value_check age_8_under_retirement_value_check From 3424cbc550ab9b82d98144a16bd9a688a13e6545 Mon Sep 17 00:00:00 2001 From: Rachael Booth Date: Wed, 30 Oct 2024 11:45:26 +0000 Subject: [PATCH 19/30] CLDC-3366: Use single page for rent soft validation (#2724) * CLDC-3366: Use single page for rent soft validation * Fix tests --- .../lettings/pages/max_rent_value_check.rb | 24 ----------- .../lettings/pages/min_rent_value_check.rb | 24 ----------- .../form/lettings/pages/rent_value_check.rb | 35 ++++++++++++++++ .../questions/max_rent_value_check.rb | 15 ------- ...ent_value_check.rb => rent_value_check.rb} | 4 +- .../subsections/income_and_benefits.rb | 3 +- .../subsections/property_information.rb | 6 +-- app/models/validations/soft_validations.rb | 8 ++++ .../pages/max_rent_value_check_spec.rb | 33 --------------- .../pages/min_rent_value_check_spec.rb | 42 ------------------- .../questions/max_rent_value_check_spec.rb | 32 -------------- .../questions/min_rent_value_check_spec.rb | 32 -------------- .../subsections/income_and_benefits_spec.rb | 3 +- .../subsections/property_information_spec.rb | 42 ++----------------- spec/services/documentation_generator_spec.rb | 4 +- 15 files changed, 55 insertions(+), 252 deletions(-) delete mode 100644 app/models/form/lettings/pages/max_rent_value_check.rb delete mode 100644 app/models/form/lettings/pages/min_rent_value_check.rb create mode 100644 app/models/form/lettings/pages/rent_value_check.rb delete mode 100644 app/models/form/lettings/questions/max_rent_value_check.rb rename app/models/form/lettings/questions/{min_rent_value_check.rb => rent_value_check.rb} (77%) delete mode 100644 spec/models/form/lettings/pages/max_rent_value_check_spec.rb delete mode 100644 spec/models/form/lettings/pages/min_rent_value_check_spec.rb delete mode 100644 spec/models/form/lettings/questions/max_rent_value_check_spec.rb delete mode 100644 spec/models/form/lettings/questions/min_rent_value_check_spec.rb diff --git a/app/models/form/lettings/pages/max_rent_value_check.rb b/app/models/form/lettings/pages/max_rent_value_check.rb deleted file mode 100644 index f3280420b..000000000 --- a/app/models/form/lettings/pages/max_rent_value_check.rb +++ /dev/null @@ -1,24 +0,0 @@ -class Form::Lettings::Pages::MaxRentValueCheck < ::Form::Page - def initialize(id, hsh, subsection, check_answers_card_number: nil) - super(id, hsh, subsection) - @depends_on = [{ "rent_in_soft_max_range?" => true }] - @title_text = { - "translation" => "soft_validations.rent.outside_range_title", - "arguments" => [{ - "key" => "brent", - "label" => true, - "i18n_template" => "brent", - }], - } - @informative_text = I18n.t("soft_validations.rent.informative_text", higher_or_lower: "higher") - @check_answers_card_number = check_answers_card_number - end - - def questions - @questions ||= [Form::Lettings::Questions::MaxRentValueCheck.new(nil, nil, self, check_answers_card_number: @check_answers_card_number)] - end - - def interruption_screen_question_ids - %w[brent period startdate uprn postcode_full la beds rent_type needstype] - end -end diff --git a/app/models/form/lettings/pages/min_rent_value_check.rb b/app/models/form/lettings/pages/min_rent_value_check.rb deleted file mode 100644 index ee26b4d7e..000000000 --- a/app/models/form/lettings/pages/min_rent_value_check.rb +++ /dev/null @@ -1,24 +0,0 @@ -class Form::Lettings::Pages::MinRentValueCheck < ::Form::Page - def initialize(id, hsh, subsection, check_answers_card_number: nil) - super(id, hsh, subsection) - @depends_on = [{ "rent_in_soft_min_range?" => true }] - @title_text = { - "translation" => "soft_validations.rent.outside_range_title", - "arguments" => [{ - "key" => "brent", - "label" => true, - "i18n_template" => "brent", - }], - } - @informative_text = I18n.t("soft_validations.rent.informative_text", higher_or_lower: "lower") - @check_answers_card_number = check_answers_card_number - end - - def questions - @questions ||= [Form::Lettings::Questions::MinRentValueCheck.new(nil, nil, self, check_answers_card_number: @check_answers_card_number)] - end - - def interruption_screen_question_ids - %w[brent period startdate uprn postcode_full la beds rent_type needstype] - end -end diff --git a/app/models/form/lettings/pages/rent_value_check.rb b/app/models/form/lettings/pages/rent_value_check.rb new file mode 100644 index 000000000..a80dc7339 --- /dev/null +++ b/app/models/form/lettings/pages/rent_value_check.rb @@ -0,0 +1,35 @@ +class Form::Lettings::Pages::RentValueCheck < ::Form::Page + def initialize(id, hsh, subsection, check_answers_card_number: nil) + super(id, hsh, subsection) + @depends_on = [{ "rent_soft_validation_triggered?" => true }] + @title_text = { + "translation" => "soft_validations.rent.outside_range_title", + "arguments" => [ + { + "key" => "brent", + "label" => true, + "i18n_template" => "brent", + }, + ], + } + @informative_text = { + "translation" => "soft_validations.rent.informative_text", + "arguments" => [ + { + "key" => "rent_soft_validation_higher_or_lower_text", + "label" => false, + "i18n_template" => "higher_or_lower", + }, + ], + } + @check_answers_card_number = check_answers_card_number + end + + def questions + @questions ||= [Form::Lettings::Questions::RentValueCheck.new(nil, nil, self, check_answers_card_number: @check_answers_card_number)] + end + + def interruption_screen_question_ids + %w[brent period startdate uprn postcode_full la beds rent_type needstype] + end +end diff --git a/app/models/form/lettings/questions/max_rent_value_check.rb b/app/models/form/lettings/questions/max_rent_value_check.rb deleted file mode 100644 index 6936e9e36..000000000 --- a/app/models/form/lettings/questions/max_rent_value_check.rb +++ /dev/null @@ -1,15 +0,0 @@ -class Form::Lettings::Questions::MaxRentValueCheck < ::Form::Question - def initialize(id, hsh, page, check_answers_card_number:) - super(id, hsh, page) - @id = "rent_value_check" - @check_answer_label = "Total rent confirmation" - @header = "Are you sure this is correct?" - @type = "interruption_screen" - @hint_text = I18n.t("soft_validations.rent.hint_text", higher_or_lower: "higher") - @check_answers_card_number = check_answers_card_number - @answer_options = ANSWER_OPTIONS - @hidden_in_check_answers = { "depends_on" => [{ "rent_value_check" => 0 }, { "rent_value_check" => 1 }] } - end - - ANSWER_OPTIONS = { "0" => { "value" => "Yes" }, "1" => { "value" => "No" } }.freeze -end diff --git a/app/models/form/lettings/questions/min_rent_value_check.rb b/app/models/form/lettings/questions/rent_value_check.rb similarity index 77% rename from app/models/form/lettings/questions/min_rent_value_check.rb rename to app/models/form/lettings/questions/rent_value_check.rb index ad4111c61..688499259 100644 --- a/app/models/form/lettings/questions/min_rent_value_check.rb +++ b/app/models/form/lettings/questions/rent_value_check.rb @@ -1,11 +1,11 @@ -class Form::Lettings::Questions::MinRentValueCheck < ::Form::Question +class Form::Lettings::Questions::RentValueCheck < ::Form::Question def initialize(id, hsh, page, check_answers_card_number:) super(id, hsh, page) @id = "rent_value_check" @check_answer_label = "Total rent confirmation" @header = "Are you sure this is correct?" @type = "interruption_screen" - @hint_text = I18n.t("soft_validations.rent.hint_text", higher_or_lower: "lower") + @hint_text = I18n.t("soft_validations.rent.hint_text") @check_answers_card_number = check_answers_card_number @answer_options = ANSWER_OPTIONS @hidden_in_check_answers = { "depends_on" => [{ "rent_value_check" => 0 }, { "rent_value_check" => 1 }] } diff --git a/app/models/form/lettings/subsections/income_and_benefits.rb b/app/models/form/lettings/subsections/income_and_benefits.rb index 1404ebf04..2be2fb9a5 100644 --- a/app/models/form/lettings/subsections/income_and_benefits.rb +++ b/app/models/form/lettings/subsections/income_and_benefits.rb @@ -24,8 +24,7 @@ class Form::Lettings::Subsections::IncomeAndBenefits < ::Form::Subsection Form::Lettings::Pages::RentBiWeekly.new(nil, nil, self), Form::Lettings::Pages::Rent4Weekly.new(nil, nil, self), Form::Lettings::Pages::RentMonthly.new(nil, nil, self), - Form::Lettings::Pages::MinRentValueCheck.new("brent_min_rent_value_check", nil, self, check_answers_card_number: 0), - Form::Lettings::Pages::MaxRentValueCheck.new("brent_max_rent_value_check", nil, self, check_answers_card_number: 0), + Form::Lettings::Pages::RentValueCheck.new("brent_rent_value_check", nil, self, check_answers_card_number: 0), Form::Lettings::Pages::SchargeValueCheck.new(nil, nil, self), Form::Lettings::Pages::PschargeValueCheck.new(nil, nil, self), Form::Lettings::Pages::SupchargValueCheck.new(nil, nil, self), diff --git a/app/models/form/lettings/subsections/property_information.rb b/app/models/form/lettings/subsections/property_information.rb index 67a22c7f5..3068faf92 100644 --- a/app/models/form/lettings/subsections/property_information.rb +++ b/app/models/form/lettings/subsections/property_information.rb @@ -10,8 +10,7 @@ class Form::Lettings::Subsections::PropertyInformation < ::Form::Subsection @pages ||= [ uprn_questions, Form::Lettings::Pages::PropertyLocalAuthority.new(nil, nil, self), - Form::Lettings::Pages::MinRentValueCheck.new("local_authority_min_rent_value_check", nil, self, check_answers_card_number: nil), - Form::Lettings::Pages::MaxRentValueCheck.new("local_authority_max_rent_value_check", nil, self, check_answers_card_number: nil), + Form::Lettings::Pages::RentValueCheck.new("local_authority_rent_value_check", nil, self, check_answers_card_number: nil), Form::Lettings::Pages::FirstTimePropertyLetAsSocialHousing.new(nil, nil, self), Form::Lettings::Pages::PropertyLetType.new(nil, nil, self), Form::Lettings::Pages::PropertyVacancyReasonNotFirstLet.new(nil, nil, self), @@ -21,8 +20,7 @@ class Form::Lettings::Subsections::PropertyInformation < ::Form::Subsection Form::Lettings::Pages::PropertyBuildingType.new(nil, nil, self), Form::Lettings::Pages::PropertyWheelchairAccessible.new(nil, nil, self), Form::Lettings::Pages::PropertyNumberOfBedrooms.new(nil, nil, self), - Form::Lettings::Pages::MinRentValueCheck.new("beds_min_rent_value_check", nil, self, check_answers_card_number: 0), - Form::Lettings::Pages::MaxRentValueCheck.new("beds_max_rent_value_check", nil, self, check_answers_card_number: 0), + Form::Lettings::Pages::RentValueCheck.new("beds_rent_value_check", nil, self, check_answers_card_number: 0), Form::Lettings::Pages::VoidDate.new(nil, nil, self), Form::Lettings::Pages::VoidDateValueCheck.new(nil, nil, self), Form::Lettings::Pages::PropertyMajorRepairs.new(nil, nil, self), diff --git a/app/models/validations/soft_validations.rb b/app/models/validations/soft_validations.rb index 41309cef0..0b76f792b 100644 --- a/app/models/validations/soft_validations.rb +++ b/app/models/validations/soft_validations.rb @@ -27,6 +27,14 @@ module Validations::SoftValidations weekly_net_income.between?(applicable_income_range.hard_min, applicable_income_range.soft_min) end + def rent_soft_validation_triggered? + rent_in_soft_min_range? || rent_in_soft_max_range? + end + + def rent_soft_validation_higher_or_lower_text + rent_in_soft_min_range? ? "lower" : "higher" + end + def rent_in_soft_min_range? return unless brent && weekly_value(brent) && startdate diff --git a/spec/models/form/lettings/pages/max_rent_value_check_spec.rb b/spec/models/form/lettings/pages/max_rent_value_check_spec.rb deleted file mode 100644 index 273272d8b..000000000 --- a/spec/models/form/lettings/pages/max_rent_value_check_spec.rb +++ /dev/null @@ -1,33 +0,0 @@ -require "rails_helper" - -RSpec.describe Form::Lettings::Pages::MaxRentValueCheck, type: :model do - subject(:page) { described_class.new(page_id, page_definition, subsection) } - - let(:page_id) { "max_rent_value_check" } - let(:page_definition) { nil } - let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2024, 4, 1))) } - - it "has correct subsection" do - expect(page.subsection).to eq(subsection) - end - - it "has correct questions" do - expect(page.questions.map(&:id)).to eq(%w[rent_value_check]) - end - - it "has the correct id" do - expect(page.id).to eq("max_rent_value_check") - end - - it "has correct depends_on" do - expect(page.depends_on).to eq([{ "rent_in_soft_max_range?" => true }]) - end - - it "has the correct title_text" do - expect(page.title_text).to eq({ "arguments" => [{ "i18n_template" => "brent", "key" => "brent", "label" => true }], "translation" => "soft_validations.rent.outside_range_title" }) - end - - it "has the correct interruption_screen_question_ids" do - expect(page.interruption_screen_question_ids).to eq(%w[brent period startdate uprn postcode_full la beds rent_type needstype]) - end -end diff --git a/spec/models/form/lettings/pages/min_rent_value_check_spec.rb b/spec/models/form/lettings/pages/min_rent_value_check_spec.rb deleted file mode 100644 index 950f2f43f..000000000 --- a/spec/models/form/lettings/pages/min_rent_value_check_spec.rb +++ /dev/null @@ -1,42 +0,0 @@ -require "rails_helper" - -RSpec.describe Form::Lettings::Pages::MinRentValueCheck, type: :model do - subject(:page) { described_class.new(page_id, page_definition, subsection) } - - let(:page_id) { "min_rent_value_check" } - let(:page_definition) { nil } - let(:subsection) { instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2024, 4, 1))) } - - it "has correct subsection" do - expect(page.subsection).to eq(subsection) - end - - it "has the correct description" do - expect(page.description).to be nil - end - - it "has correct questions" do - expect(page.questions.map(&:id)).to eq(%w[rent_value_check]) - end - - it "has the correct id" do - expect(page.id).to eq("min_rent_value_check") - end - - it "has correct depends_on" do - expect(page.depends_on).to eq( - [{ "rent_in_soft_min_range?" => true }], - ) - end - - it "has the correct title_text" do - expect(page.title_text).to eq({ - "translation" => "soft_validations.rent.outside_range_title", - "arguments" => [{ "i18n_template" => "brent", "key" => "brent", "label" => true }], - }) - end - - it "has the correct interruption_screen_question_ids" do - expect(page.interruption_screen_question_ids).to eq(%w[brent period startdate uprn postcode_full la beds rent_type needstype]) - end -end diff --git a/spec/models/form/lettings/questions/max_rent_value_check_spec.rb b/spec/models/form/lettings/questions/max_rent_value_check_spec.rb deleted file mode 100644 index 6fa0784e4..000000000 --- a/spec/models/form/lettings/questions/max_rent_value_check_spec.rb +++ /dev/null @@ -1,32 +0,0 @@ -require "rails_helper" - -RSpec.describe Form::Lettings::Questions::MaxRentValueCheck, type: :model do - subject(:question) { described_class.new(nil, question_definition, page, check_answers_card_number:) } - - let(:question_definition) { nil } - let(:check_answers_card_number) { nil } - let(:page) { instance_double(Form::Page) } - - it "has correct page" do - expect(question.page).to eq(page) - end - - it "has the correct id" do - expect(question.id).to eq("rent_value_check") - end - - it "has the correct type" do - expect(question.type).to eq("interruption_screen") - end - - it "has the correct answer_options" do - expect(question.answer_options).to eq({ - "0" => { "value" => "Yes" }, - "1" => { "value" => "No" }, - }) - end - - it "has the correct hidden_in_check_answers" do - expect(question.hidden_in_check_answers).to eq({ "depends_on" => [{ "rent_value_check" => 0 }, { "rent_value_check" => 1 }] }) - end -end diff --git a/spec/models/form/lettings/questions/min_rent_value_check_spec.rb b/spec/models/form/lettings/questions/min_rent_value_check_spec.rb deleted file mode 100644 index c3d8a16bc..000000000 --- a/spec/models/form/lettings/questions/min_rent_value_check_spec.rb +++ /dev/null @@ -1,32 +0,0 @@ -require "rails_helper" - -RSpec.describe Form::Lettings::Questions::MinRentValueCheck, type: :model do - subject(:question) { described_class.new(nil, question_definition, page, check_answers_card_number:) } - - let(:question_definition) { nil } - let(:check_answers_card_number) { nil } - let(:page) { instance_double(Form::Page) } - - it "has correct page" do - expect(question.page).to eq(page) - end - - it "has the correct id" do - expect(question.id).to eq("rent_value_check") - end - - it "has the correct type" do - expect(question.type).to eq("interruption_screen") - end - - it "has the correct answer_options" do - expect(question.answer_options).to eq({ - "0" => { "value" => "Yes" }, - "1" => { "value" => "No" }, - }) - end - - it "has the correct hidden_in_check_answers" do - expect(question.hidden_in_check_answers).to eq({ "depends_on" => [{ "rent_value_check" => 0 }, { "rent_value_check" => 1 }] }) - end -end diff --git a/spec/models/form/lettings/subsections/income_and_benefits_spec.rb b/spec/models/form/lettings/subsections/income_and_benefits_spec.rb index c260ff56d..4c92faaf6 100644 --- a/spec/models/form/lettings/subsections/income_and_benefits_spec.rb +++ b/spec/models/form/lettings/subsections/income_and_benefits_spec.rb @@ -30,8 +30,7 @@ RSpec.describe Form::Lettings::Subsections::IncomeAndBenefits, type: :model do rent_bi_weekly rent_4_weekly rent_monthly - brent_min_rent_value_check - brent_max_rent_value_check + brent_rent_value_check scharge_value_check pscharge_value_check supcharg_value_check diff --git a/spec/models/form/lettings/subsections/property_information_spec.rb b/spec/models/form/lettings/subsections/property_information_spec.rb index 7d406d1a7..d333ff669 100644 --- a/spec/models/form/lettings/subsections/property_information_spec.rb +++ b/spec/models/form/lettings/subsections/property_information_spec.rb @@ -17,36 +17,6 @@ RSpec.describe Form::Lettings::Subsections::PropertyInformation, type: :model do allow(form).to receive(:start_year_after_2024?).and_return(false) end - context "when 2022" do - let(:start_date) { Time.utc(2022, 2, 8) } - - it "has correct pages" do - expect(property_information.pages.compact.map(&:id)).to eq( - %w[ - property_postcode - property_local_authority - local_authority_min_rent_value_check - local_authority_max_rent_value_check - first_time_property_let_as_social_housing - property_let_type - property_vacancy_reason_not_first_let - property_vacancy_reason_first_let - property_number_of_times_relet - property_unit_type - property_building_type - property_wheelchair_accessible - property_number_of_bedrooms - beds_min_rent_value_check - beds_max_rent_value_check - void_date - void_date_value_check - property_major_repairs - property_major_repairs_value_check - ], - ) - end - end - context "when 2023" do let(:start_date) { Time.utc(2023, 2, 8) } @@ -57,8 +27,7 @@ RSpec.describe Form::Lettings::Subsections::PropertyInformation, type: :model do uprn_confirmation address property_local_authority - local_authority_min_rent_value_check - local_authority_max_rent_value_check + local_authority_rent_value_check first_time_property_let_as_social_housing property_let_type property_vacancy_reason_not_first_let @@ -68,8 +37,7 @@ RSpec.describe Form::Lettings::Subsections::PropertyInformation, type: :model do property_building_type property_wheelchair_accessible property_number_of_bedrooms - beds_min_rent_value_check - beds_max_rent_value_check + beds_rent_value_check void_date void_date_value_check property_major_repairs @@ -96,8 +64,7 @@ RSpec.describe Form::Lettings::Subsections::PropertyInformation, type: :model do uprn_selection address property_local_authority - local_authority_min_rent_value_check - local_authority_max_rent_value_check + local_authority_rent_value_check first_time_property_let_as_social_housing property_let_type property_vacancy_reason_not_first_let @@ -106,8 +73,7 @@ RSpec.describe Form::Lettings::Subsections::PropertyInformation, type: :model do property_building_type property_wheelchair_accessible property_number_of_bedrooms - beds_min_rent_value_check - beds_max_rent_value_check + beds_rent_value_check void_date void_date_value_check property_major_repairs diff --git a/spec/services/documentation_generator_spec.rb b/spec/services/documentation_generator_spec.rb index 47bc813f7..6f4714d01 100644 --- a/spec/services/documentation_generator_spec.rb +++ b/spec/services/documentation_generator_spec.rb @@ -89,7 +89,7 @@ describe DocumentationGenerator do end describe ":describe_soft_validations" do - let(:all_validation_methods) { ["rent_in_soft_min_range?"] } + let(:all_validation_methods) { ["rent_soft_validation_triggered?"] } let(:response) do { "choices" => [{ "message" => { "tool_calls" => [{ "function" => { "arguments" => "{\n \"description\": \"Validates the format.\",\n \"validation_type\": \"format\",\n \"other_validated_models\": \"User\"}" } }] } }] } @@ -100,7 +100,7 @@ describe DocumentationGenerator do it "creates new validation documentation records" do expect { described_class.new.describe_soft_validations(client, all_validation_methods, all_helper_methods, log_type) }.to change(LogValidation, :count) - expect(LogValidation.where(validation_name: "rent_in_soft_min_range?").count).to be_positive + expect(LogValidation.where(validation_name: "rent_soft_validation_triggered?").count).to be_positive any_validation = LogValidation.first expect(any_validation.description).to eq("Validates the format.") expect(any_validation.field).not_to be_empty From a00489b7d78ce7ac39e613050b8e576d9c826a14 Mon Sep 17 00:00:00 2001 From: Rachael Booth Date: Wed, 30 Oct 2024 12:18:51 +0000 Subject: [PATCH 20/30] CLDC-3659: Pull sales household situation questions copy into translation file (#2701) * CLDC-3659: Pull sales household situation questions copy into translation file * Fix header->question_text --- .../form/sales/pages/last_accommodation.rb | 1 + .../form/sales/pages/last_accommodation_la.rb | 1 + .../sales/questions/buyer1_previous_tenure.rb | 2 - .../form/sales/questions/buyer2_living_in.rb | 3 -- .../sales/questions/buyers_organisations.rb | 7 --- .../form/sales/questions/previous_la_known.rb | 4 +- .../form/sales/questions/previous_postcode.rb | 3 +- .../questions/previous_postcode_known.rb | 4 +- .../sales/questions/previous_tenure_buyer2.rb | 3 -- app/models/form/sales/questions/prevloc.rb | 3 +- .../2023/sales/household_situation.en.yml | 50 +++++++++++++++++++ .../2024/sales/household_situation.en.yml | 50 +++++++++++++++++++ 12 files changed, 106 insertions(+), 25 deletions(-) create mode 100644 config/locales/forms/2023/sales/household_situation.en.yml create mode 100644 config/locales/forms/2024/sales/household_situation.en.yml diff --git a/app/models/form/sales/pages/last_accommodation.rb b/app/models/form/sales/pages/last_accommodation.rb index 457da99b1..f9d167028 100644 --- a/app/models/form/sales/pages/last_accommodation.rb +++ b/app/models/form/sales/pages/last_accommodation.rb @@ -2,6 +2,7 @@ class Form::Sales::Pages::LastAccommodation < ::Form::Page def initialize(id, hsh, subsection) super @id = "last_accommodation" + @copy_key = "sales.household_situation.last_accommodation" end def questions diff --git a/app/models/form/sales/pages/last_accommodation_la.rb b/app/models/form/sales/pages/last_accommodation_la.rb index 1c126a28d..9cae326bf 100644 --- a/app/models/form/sales/pages/last_accommodation_la.rb +++ b/app/models/form/sales/pages/last_accommodation_la.rb @@ -2,6 +2,7 @@ class Form::Sales::Pages::LastAccommodationLa < ::Form::Page def initialize(id, hsh, subsection) super @id = "last_accommodation_la" + @copy_key = "sales.household_situation.last_accommodation_la" @depends_on = [{ "is_previous_la_inferred" => false, }] diff --git a/app/models/form/sales/questions/buyer1_previous_tenure.rb b/app/models/form/sales/questions/buyer1_previous_tenure.rb index 4f560f10d..aea90af30 100644 --- a/app/models/form/sales/questions/buyer1_previous_tenure.rb +++ b/app/models/form/sales/questions/buyer1_previous_tenure.rb @@ -2,8 +2,6 @@ class Form::Sales::Questions::Buyer1PreviousTenure < ::Form::Question def initialize(id, hsh, page) super @id = "prevten" - @check_answer_label = "Buyer 1’s previous tenure" - @header = "What was buyer 1’s previous tenure?" @type = "radio" @answer_options = answer_options @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] diff --git a/app/models/form/sales/questions/buyer2_living_in.rb b/app/models/form/sales/questions/buyer2_living_in.rb index 83b1712fe..0939d119f 100644 --- a/app/models/form/sales/questions/buyer2_living_in.rb +++ b/app/models/form/sales/questions/buyer2_living_in.rb @@ -2,10 +2,7 @@ class Form::Sales::Questions::Buyer2LivingIn < ::Form::Question def initialize(id, hsh, page) super @id = "buy2living" - @check_answer_label = "Buyer 2 living at the same address" - @header = "At the time of purchase, was buyer 2 living at the same address as buyer 1?" @type = "radio" - @hint_text = "" @answer_options = ANSWER_OPTIONS @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end diff --git a/app/models/form/sales/questions/buyers_organisations.rb b/app/models/form/sales/questions/buyers_organisations.rb index 714f7a2e3..727a65ad0 100644 --- a/app/models/form/sales/questions/buyers_organisations.rb +++ b/app/models/form/sales/questions/buyers_organisations.rb @@ -2,10 +2,7 @@ class Form::Sales::Questions::BuyersOrganisations < ::Form::Question def initialize(id, hsh, page) super @id = "buyers_organisations" - @check_answer_label = "Organisations buyers were registered with" - @header = "What organisations were the buyers registered with?" @type = "checkbox" - @hint_text = "Select all that apply. This question is optional. If no options are applicable, leave the options blank, and select save and continue." @answer_options = ANSWER_OPTIONS @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end @@ -27,9 +24,5 @@ class Form::Sales::Questions::BuyersOrganisations < ::Form::Question } end - def unanswered_error_message - "At least one option must be selected of these four" - end - QUESTION_NUMBER_FROM_YEAR = { 2023 => 59, 2024 => 61 }.freeze end diff --git a/app/models/form/sales/questions/previous_la_known.rb b/app/models/form/sales/questions/previous_la_known.rb index 7a31fbd74..a54a98d11 100644 --- a/app/models/form/sales/questions/previous_la_known.rb +++ b/app/models/form/sales/questions/previous_la_known.rb @@ -2,11 +2,9 @@ class Form::Sales::Questions::PreviousLaKnown < ::Form::Question def initialize(id, hsh, page) super @id = "previous_la_known" - @check_answer_label = "Local authority of buyer 1’s last settled accommodation" - @header = "Do you know the local authority of buyer 1’s last settled accommodation?" + @copy_key = "sales.household_situation.last_accommodation_la.previous_la_known" @type = "radio" @answer_options = ANSWER_OPTIONS - @hint_text = "This is also known as the household’s 'last settled home'" @hidden_in_check_answers = { "depends_on" => [ { diff --git a/app/models/form/sales/questions/previous_postcode.rb b/app/models/form/sales/questions/previous_postcode.rb index a0a4fe725..32b4e153e 100644 --- a/app/models/form/sales/questions/previous_postcode.rb +++ b/app/models/form/sales/questions/previous_postcode.rb @@ -2,8 +2,7 @@ class Form::Sales::Questions::PreviousPostcode < ::Form::Question def initialize(id, hsh, page) super @id = "ppostcode_full" - @check_answer_label = "Postcode of buyer 1’s last settled accommodation" - @header = "Postcode" + @copy_key = "sales.household_situation.last_accommodation.ppostcode_full" @type = "text" @width = 5 @inferred_check_answers_value = [{ diff --git a/app/models/form/sales/questions/previous_postcode_known.rb b/app/models/form/sales/questions/previous_postcode_known.rb index d9df53f6c..c2156b887 100644 --- a/app/models/form/sales/questions/previous_postcode_known.rb +++ b/app/models/form/sales/questions/previous_postcode_known.rb @@ -2,14 +2,12 @@ class Form::Sales::Questions::PreviousPostcodeKnown < ::Form::Question def initialize(id, hsh, page) super @id = "ppcodenk" - @check_answer_label = "Buyer 1’s last settled accommodation" - @header = "Do you know the postcode of buyer 1’s last settled accommodation?" + @copy_key = "sales.household_situation.last_accommodation.ppcodenk" @type = "radio" @answer_options = ANSWER_OPTIONS @conditional_for = { "ppostcode_full" => [0], } - @hint_text = "This is also known as the household’s 'last settled home'" @hidden_in_check_answers = { "depends_on" => [ { diff --git a/app/models/form/sales/questions/previous_tenure_buyer2.rb b/app/models/form/sales/questions/previous_tenure_buyer2.rb index 2873b8dc5..db606e254 100644 --- a/app/models/form/sales/questions/previous_tenure_buyer2.rb +++ b/app/models/form/sales/questions/previous_tenure_buyer2.rb @@ -2,10 +2,7 @@ class Form::Sales::Questions::PreviousTenureBuyer2 < ::Form::Question def initialize(id, hsh, page) super @id = "prevtenbuy2" - @check_answer_label = "Buyer 2’s previous tenure" - @header = "What was buyer 2’s previous tenure?" @type = "radio" - @hint_text = "" @answer_options = ANSWER_OPTIONS @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end diff --git a/app/models/form/sales/questions/prevloc.rb b/app/models/form/sales/questions/prevloc.rb index b8c46f427..5deb48877 100644 --- a/app/models/form/sales/questions/prevloc.rb +++ b/app/models/form/sales/questions/prevloc.rb @@ -2,8 +2,7 @@ class Form::Sales::Questions::Prevloc < ::Form::Question def initialize(id, hsh, page) super @id = "prevloc" - @check_answer_label = "Local authority of buyer 1’s last settled accommodation" - @header = "Select a local authority" + @copy_key = "sales.household_situation.last_accommodation_la.prevloc" @type = "select" @inferred_check_answers_value = [{ "condition" => { diff --git a/config/locales/forms/2023/sales/household_situation.en.yml b/config/locales/forms/2023/sales/household_situation.en.yml new file mode 100644 index 000000000..e22777a28 --- /dev/null +++ b/config/locales/forms/2023/sales/household_situation.en.yml @@ -0,0 +1,50 @@ +en: + forms: + 2023: + sales: + household_situation: + prevten: + page_header: "" + check_answer_label: "Buyer 1’s previous tenure" + hint_text: "" + question_text: "What was buyer 1’s previous tenure?" + + last_accommodation: + page_header: "" + ppcodenk: + check_answer_label: "Buyer 1’s last settled accommodation" + hint_text: "This is also known as the household’s 'last settled home'" + question_text: "Do you know the postcode of buyer 1’s last settled accommodation?" + ppostcode_full: + check_answer_label: "Postcode of buyer 1’s last settled accommodation" + hint_text: "" + question_text: "Postcode" + + last_accommodation_la: + page_header: "" + previous_la_known: + check_answer_label: "Local authority of buyer 1’s last settled accommodation" + hint_text: "This is also known as the household’s 'last settled home'" + question_text: "Do you know the local authority of buyer 1’s last settled accommodation?" + prevloc: + check_answer_label: "Local authority of buyer 1’s last settled accommodation" + hint_text: "" + question_text: "Select a local authority" + + buyers_organisations: + page_header: "" + check_answer_label: "Organisations buyers were registered with" + hint_text: "Select all that apply. This question is optional. If no options are applicable, leave the options blank, and select save and continue." + question_text: "What organisations were the buyers registered with?" + + buy2living: + page_header: "" + check_answer_label: "Buyer 2 living at the same address" + hint_text: "" + header: "At the time of purchase, was buyer 2 living at the same address as buyer 1?" + + prevtenbuy2: + page_header: "" + check_answer_label: "Buyer 2’s previous tenure" + hint_text: "" + question_text: "What was buyer 2’s previous tenure?" diff --git a/config/locales/forms/2024/sales/household_situation.en.yml b/config/locales/forms/2024/sales/household_situation.en.yml new file mode 100644 index 000000000..1ab6d540e --- /dev/null +++ b/config/locales/forms/2024/sales/household_situation.en.yml @@ -0,0 +1,50 @@ +en: + forms: + 2024: + sales: + household_situation: + prevten: + page_header: "" + check_answer_label: "Buyer 1’s previous tenure" + hint_text: "" + question_text: "What was buyer 1’s previous tenure?" + + last_accommodation: + page_header: "" + ppcodenk: + check_answer_label: "Buyer 1’s last settled accommodation" + hint_text: "This is also known as the household’s 'last settled home'" + question_text: "Do you know the postcode of buyer 1’s last settled accommodation?" + ppostcode_full: + check_answer_label: "Postcode of buyer 1’s last settled accommodation" + hint_text: "" + question_text: "Postcode" + + last_accommodation_la: + page_header: "" + previous_la_known: + check_answer_label: "Local authority of buyer 1’s last settled accommodation" + hint_text: "This is also known as the household’s 'last settled home'" + question_text: "Do you know the local authority of buyer 1’s last settled accommodation?" + prevloc: + check_answer_label: "Local authority of buyer 1’s last settled accommodation" + hint_text: "" + question_text: "Select a local authority" + + buyers_organisations: + page_header: "" + check_answer_label: "Organisations buyers were registered with" + hint_text: "Select all that apply. This question is optional. If no options are applicable, leave the options blank, and select save and continue." + question_text: "What organisations were the buyers registered with?" + + buy2living: + page_header: "" + check_answer_label: "Buyer 2 living at the same address" + hint_text: "" + question_text: "At the time of purchase, was buyer 2 living at the same address as buyer 1?" + + prevtenbuy2: + page_header: "" + check_answer_label: "Buyer 2’s previous tenure" + hint_text: "" + question_text: "What was buyer 2’s previous tenure?" From f2f44329f36a03507179a3cf714236d1c0b6d990 Mon Sep 17 00:00:00 2001 From: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com> Date: Wed, 30 Oct 2024 13:19:54 +0000 Subject: [PATCH 21/30] CLDC-3684 Extract lettings tenancy information copy (#2731) * Extract lettings tenancy information copy * Fix flaky merged schemes test --- .../lettings/pages/starter_tenancy_type.rb | 1 + .../form/lettings/pages/tenancy_length.rb | 1 + .../pages/tenancy_length_affordable_rent.rb | 1 + .../pages/tenancy_length_intermediate_rent.rb | 1 + .../lettings/pages/tenancy_length_periodic.rb | 1 + .../form/lettings/pages/tenancy_type.rb | 1 + app/models/form/lettings/questions/joint.rb | 3 - .../form/lettings/questions/sheltered.rb | 3 - .../questions/starter_tenancy_type.rb | 4 +- .../form/lettings/questions/startertenancy.rb | 11 ---- .../form/lettings/questions/tenancy_length.rb | 4 +- .../tenancy_length_affordable_rent.rb | 11 +--- .../tenancy_length_intermediate_rent.rb | 11 +--- .../questions/tenancy_length_periodic.rb | 4 +- .../form/lettings/questions/tenancy_other.rb | 4 +- .../form/lettings/questions/tenancy_type.rb | 4 +- .../2023/lettings/tenancy_information.en.yml | 66 +++++++++++++++++++ .../2024/lettings/tenancy_information.en.yml | 66 +++++++++++++++++++ .../questions/starter_tenancy_type_spec.rb | 2 +- .../tenancy_length_affordable_rent_spec.rb | 2 +- .../tenancy_length_intermediate_rent_spec.rb | 2 +- .../questions/tenancy_length_periodic_spec.rb | 2 +- .../lettings/questions/tenancy_length_spec.rb | 2 +- .../lettings/questions/tenancy_other_spec.rb | 2 +- .../lettings/questions/tenancy_type_spec.rb | 2 +- .../merge/merge_organisations_service_spec.rb | 6 +- 26 files changed, 155 insertions(+), 62 deletions(-) create mode 100644 config/locales/forms/2023/lettings/tenancy_information.en.yml create mode 100644 config/locales/forms/2024/lettings/tenancy_information.en.yml diff --git a/app/models/form/lettings/pages/starter_tenancy_type.rb b/app/models/form/lettings/pages/starter_tenancy_type.rb index fe147bc77..462d4fb37 100644 --- a/app/models/form/lettings/pages/starter_tenancy_type.rb +++ b/app/models/form/lettings/pages/starter_tenancy_type.rb @@ -2,6 +2,7 @@ class Form::Lettings::Pages::StarterTenancyType < ::Form::Page def initialize(id, hsh, subsection) super @id = "starter_tenancy_type" + @copy_key = "lettings.tenancy_information.tenancy.starter_tenancy_type" @depends_on = [{ "starter_tenancy?" => true }] end diff --git a/app/models/form/lettings/pages/tenancy_length.rb b/app/models/form/lettings/pages/tenancy_length.rb index 006cd8e42..b855133bf 100644 --- a/app/models/form/lettings/pages/tenancy_length.rb +++ b/app/models/form/lettings/pages/tenancy_length.rb @@ -2,6 +2,7 @@ class Form::Lettings::Pages::TenancyLength < ::Form::Page def initialize(id, hsh, subsection) super @id = "tenancy_length" + @copy_key = "lettings.tenancy_information.tenancylength.tenancy_length" @depends_on = [{ "tenancy_type_fixed_term?" => true, "needstype" => 2 }] end diff --git a/app/models/form/lettings/pages/tenancy_length_affordable_rent.rb b/app/models/form/lettings/pages/tenancy_length_affordable_rent.rb index aa88d81f9..cb292823a 100644 --- a/app/models/form/lettings/pages/tenancy_length_affordable_rent.rb +++ b/app/models/form/lettings/pages/tenancy_length_affordable_rent.rb @@ -2,6 +2,7 @@ class Form::Lettings::Pages::TenancyLengthAffordableRent < ::Form::Page def initialize(id, hsh, subsection) super @id = "tenancy_length_affordable_rent" + @copy_key = "lettings.tenancy_information.tenancylength.tenancy_length_affordable_rent" @depends_on = [{ "tenancy_type_fixed_term?" => true, "affordable_or_social_rent?" => true, "needstype" => 1 }] end diff --git a/app/models/form/lettings/pages/tenancy_length_intermediate_rent.rb b/app/models/form/lettings/pages/tenancy_length_intermediate_rent.rb index 070d0abe1..a693a6f3d 100644 --- a/app/models/form/lettings/pages/tenancy_length_intermediate_rent.rb +++ b/app/models/form/lettings/pages/tenancy_length_intermediate_rent.rb @@ -2,6 +2,7 @@ class Form::Lettings::Pages::TenancyLengthIntermediateRent < ::Form::Page def initialize(id, hsh, subsection) super @id = "tenancy_length_intermediate_rent" + @copy_key = "lettings.tenancy_information.tenancylength.tenancy_length_intermediate_rent" @depends_on = [{ "tenancy_type_fixed_term?" => true, "affordable_or_social_rent?" => false, "needstype" => 1 }] end diff --git a/app/models/form/lettings/pages/tenancy_length_periodic.rb b/app/models/form/lettings/pages/tenancy_length_periodic.rb index 9ea6553af..82972e796 100644 --- a/app/models/form/lettings/pages/tenancy_length_periodic.rb +++ b/app/models/form/lettings/pages/tenancy_length_periodic.rb @@ -2,6 +2,7 @@ class Form::Lettings::Pages::TenancyLengthPeriodic < ::Form::Page def initialize(id, hsh, subsection) super @id = "tenancy_length_periodic" + @copy_key = "lettings.tenancy_information.tenancylength.tenancy_length_periodic" @depends_on = [{ "tenancy_type_periodic?" => true }] end diff --git a/app/models/form/lettings/pages/tenancy_type.rb b/app/models/form/lettings/pages/tenancy_type.rb index c15f6f27a..2d7eceb5f 100644 --- a/app/models/form/lettings/pages/tenancy_type.rb +++ b/app/models/form/lettings/pages/tenancy_type.rb @@ -2,6 +2,7 @@ class Form::Lettings::Pages::TenancyType < ::Form::Page def initialize(id, hsh, subsection) super @id = "tenancy_type" + @copy_key = "lettings.tenancy_information.tenancy.tenancy_type" @depends_on = [{ "starter_tenancy?" => false }] end diff --git a/app/models/form/lettings/questions/joint.rb b/app/models/form/lettings/questions/joint.rb index 5f3379c5d..e28a0085c 100644 --- a/app/models/form/lettings/questions/joint.rb +++ b/app/models/form/lettings/questions/joint.rb @@ -2,11 +2,8 @@ class Form::Lettings::Questions::Joint < ::Form::Question def initialize(id, hsh, page) super @id = "joint" - @check_answer_label = "Is this a joint tenancy?" - @header = "Is this a joint tenancy?" @type = "radio" @check_answers_card_number = 0 - @hint_text = form.start_year_after_2024? ? "This is where two or more people are named on the tenancy agreement" : "" @answer_options = ANSWER_OPTIONS @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end diff --git a/app/models/form/lettings/questions/sheltered.rb b/app/models/form/lettings/questions/sheltered.rb index 7b78a9b30..7b80bb5bf 100644 --- a/app/models/form/lettings/questions/sheltered.rb +++ b/app/models/form/lettings/questions/sheltered.rb @@ -2,11 +2,8 @@ class Form::Lettings::Questions::Sheltered < ::Form::Question def initialize(id, hsh, page) super @id = "sheltered" - @check_answer_label = "Is this letting in sheltered accommodation?" - @header = "Is this letting in sheltered accommodation?" @type = "radio" @check_answers_card_number = 0 - @hint_text = "Sheltered housing and special retirement housing are for tenants with low-level care and support needs. This typically provides some limited support to enable independent living, such as alarm-based assistance or a scheme manager.

    Extra care housing is for tenants with medium to high care and support needs, often with 24 hour access to support staff provided by an agency registered with the Care Quality Commission." @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end diff --git a/app/models/form/lettings/questions/starter_tenancy_type.rb b/app/models/form/lettings/questions/starter_tenancy_type.rb index 9157c8e18..85d4a14ff 100644 --- a/app/models/form/lettings/questions/starter_tenancy_type.rb +++ b/app/models/form/lettings/questions/starter_tenancy_type.rb @@ -2,11 +2,9 @@ class Form::Lettings::Questions::StarterTenancyType < ::Form::Question def initialize(id, hsh, page) super @id = "tenancy" - @check_answer_label = form.start_year_after_2024? ? "Type of main tenancy after the starter or introductory period has ended" : "Type of main tenancy after the starter period has ended" - @header = form.start_year_after_2024? ? "What is the type of tenancy after the starter or introductory period has ended?" : "What is the type of tenancy after the starter period has ended?" + @copy_key = "lettings.tenancy_information.tenancy.#{page.id}.tenancy" @type = "radio" @check_answers_card_number = 0 - @hint_text = form.start_year_after_2024? ? "" : "This is also known as an ‘introductory period’." @conditional_for = { "tenancyother" => [3] } @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end diff --git a/app/models/form/lettings/questions/startertenancy.rb b/app/models/form/lettings/questions/startertenancy.rb index 0e461a25e..44b592cd6 100644 --- a/app/models/form/lettings/questions/startertenancy.rb +++ b/app/models/form/lettings/questions/startertenancy.rb @@ -2,8 +2,6 @@ class Form::Lettings::Questions::Startertenancy < ::Form::Question def initialize(id, hsh, page) super @id = "startertenancy" - @check_answer_label = "Is this a starter or introductory tenancy?" - @header = "Is this a starter tenancy?" @type = "radio" @check_answers_card_number = 0 @answer_options = ANSWER_OPTIONS @@ -12,14 +10,5 @@ class Form::Lettings::Questions::Startertenancy < ::Form::Question ANSWER_OPTIONS = { "1" => { "value" => "Yes" }, "2" => { "value" => "No" } }.freeze - def hint_text - if form.start_year_after_2024? - "If the tenancy has an ‘introductory period’ answer ‘yes’.

    - You should submit a CORE log at the beginning of the starter tenancy or introductory period, with the best information you have at the time. You do not need to submit a log when a tenant later rolls onto the main tenancy." - else - "This is also known as an ‘introductory period’." - end - end - QUESTION_NUMBER_FROM_YEAR = { 2023 => 26 }.freeze end diff --git a/app/models/form/lettings/questions/tenancy_length.rb b/app/models/form/lettings/questions/tenancy_length.rb index b94d41af5..1bf868377 100644 --- a/app/models/form/lettings/questions/tenancy_length.rb +++ b/app/models/form/lettings/questions/tenancy_length.rb @@ -2,14 +2,12 @@ class Form::Lettings::Questions::TenancyLength < ::Form::Question def initialize(id, hsh, page) super @id = "tenancylength" - @check_answer_label = "Length of fixed-term tenancy" - @header = "What is the length of the fixed-term tenancy to the nearest year?" + @copy_key = "lettings.tenancy_information.tenancylength.#{page.id}" @type = "numeric" @width = 2 @check_answers_card_number = 0 @max = 150 @min = 0 - @hint_text = "Do not include the starter or introductory period." @step = 1 @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end diff --git a/app/models/form/lettings/questions/tenancy_length_affordable_rent.rb b/app/models/form/lettings/questions/tenancy_length_affordable_rent.rb index bea745ae1..8e79924aa 100644 --- a/app/models/form/lettings/questions/tenancy_length_affordable_rent.rb +++ b/app/models/form/lettings/questions/tenancy_length_affordable_rent.rb @@ -2,8 +2,7 @@ class Form::Lettings::Questions::TenancyLengthAffordableRent < ::Form::Question def initialize(id, hsh, page) super @id = "tenancylength" - @check_answer_label = "Length of fixed-term tenancy" - @header = "What is the length of the fixed-term tenancy to the nearest year?" + @copy_key = "lettings.tenancy_information.tenancylength.#{page.id}" @type = "numeric" @width = 2 @check_answers_card_number = 0 @@ -13,13 +12,5 @@ class Form::Lettings::Questions::TenancyLengthAffordableRent < ::Form::Question @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end - def hint_text - if form.start_year_after_2024? - "Do not include the starter or introductory period.
    The minimum period is 2 years for social or affordable rent general needs logs. You do not need to submit CORE logs for these types of tenancies if they are shorter than 2 years." - else - "Do not include the starter or introductory period.
    The minimum period is 2 years for social or affordable rent general needs logs and you do not need a log for shorter tenancies." - end - end - QUESTION_NUMBER_FROM_YEAR = { 2023 => 28 }.freeze end diff --git a/app/models/form/lettings/questions/tenancy_length_intermediate_rent.rb b/app/models/form/lettings/questions/tenancy_length_intermediate_rent.rb index 835efd429..1bf3bd7cc 100644 --- a/app/models/form/lettings/questions/tenancy_length_intermediate_rent.rb +++ b/app/models/form/lettings/questions/tenancy_length_intermediate_rent.rb @@ -2,8 +2,7 @@ class Form::Lettings::Questions::TenancyLengthIntermediateRent < ::Form::Questio def initialize(id, hsh, page) super @id = "tenancylength" - @check_answer_label = "Length of fixed-term tenancy" - @header = "What is the length of the fixed-term tenancy to the nearest year?" + @copy_key = "lettings.tenancy_information.tenancylength.#{page.id}" @type = "numeric" @width = 2 @check_answers_card_number = 0 @@ -13,13 +12,5 @@ class Form::Lettings::Questions::TenancyLengthIntermediateRent < ::Form::Questio @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end - def hint_text - if form.start_year_after_2024? - "Do not include the starter or introductory period.
    The minimum period is 1 year for intermediate rent general needs logs. You do not need to submit CORE logs for these types of tenancies if they are shorter than 1 year." - else - "Do not include the starter or introductory period.
    The minimum period is 1 year for intermediate rent general needs logs and you do not need a log for shorter tenancies." - end - end - QUESTION_NUMBER_FROM_YEAR = { 2023 => 28 }.freeze end diff --git a/app/models/form/lettings/questions/tenancy_length_periodic.rb b/app/models/form/lettings/questions/tenancy_length_periodic.rb index 113435dd6..c65f41399 100644 --- a/app/models/form/lettings/questions/tenancy_length_periodic.rb +++ b/app/models/form/lettings/questions/tenancy_length_periodic.rb @@ -2,8 +2,7 @@ class Form::Lettings::Questions::TenancyLengthPeriodic < ::Form::Question def initialize(id, hsh, page) super @id = "tenancylength" - @check_answer_label = "Length of periodic tenancy" - @header = "What is the length of the periodic tenancy to the nearest year?" + @copy_key = "lettings.tenancy_information.tenancylength.#{page.id}" @type = "numeric" @width = 2 @check_answers_card_number = 0 @@ -11,7 +10,6 @@ class Form::Lettings::Questions::TenancyLengthPeriodic < ::Form::Question @min = 0 @step = 1 @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] - @hint_text = "As this is a periodic tenancy, this question is optional. If you do not have the information available click save and continue" end QUESTION_NUMBER_FROM_YEAR = { 2023 => 28 }.freeze diff --git a/app/models/form/lettings/questions/tenancy_other.rb b/app/models/form/lettings/questions/tenancy_other.rb index 21e932250..3fb3469ee 100644 --- a/app/models/form/lettings/questions/tenancy_other.rb +++ b/app/models/form/lettings/questions/tenancy_other.rb @@ -2,11 +2,9 @@ class Form::Lettings::Questions::TenancyOther < ::Form::Question def initialize(id, hsh, page) super @id = "tenancyother" - @check_answer_label = "" - @header = "Please state the tenancy type" + @copy_key = "lettings.tenancy_information.tenancy.#{page.id}.tenancyother" @type = "text" @check_answers_card_number = 0 - @hint_text = "" @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end diff --git a/app/models/form/lettings/questions/tenancy_type.rb b/app/models/form/lettings/questions/tenancy_type.rb index b4ed6aca4..9a83b44cb 100644 --- a/app/models/form/lettings/questions/tenancy_type.rb +++ b/app/models/form/lettings/questions/tenancy_type.rb @@ -2,11 +2,9 @@ class Form::Lettings::Questions::TenancyType < ::Form::Question def initialize(id, hsh, page) super @id = "tenancy" - @check_answer_label = "Type of main tenancy" - @header = "What is the type of tenancy?" + @copy_key = "lettings.tenancy_information.tenancy.#{page.id}.tenancy" @type = "radio" @check_answers_card_number = 0 - @hint_text = "" @conditional_for = { "tenancyother" => [3] } @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end diff --git a/config/locales/forms/2023/lettings/tenancy_information.en.yml b/config/locales/forms/2023/lettings/tenancy_information.en.yml new file mode 100644 index 000000000..e9331d4dc --- /dev/null +++ b/config/locales/forms/2023/lettings/tenancy_information.en.yml @@ -0,0 +1,66 @@ +en: + forms: + 2023: + lettings: + tenancy_information: + joint: + page_header: "" + check_answer_label: "Is this a joint tenancy?" + hint_text: "" + question_text: "Is this a joint tenancy?" + + startertenancy: + page_header: "" + check_answer_label: "Is this a starter or introductory tenancy?" + hint_text: "This is also known as an ‘introductory period’." + question_text: "Is this a starter tenancy?" + + tenancy: + tenancy_type: + page_header: "" + tenancy: + check_answer_label: "Type of main tenancy" + hint_text: "" + question_text: "What is the type of tenancy?" + tenancyother: + check_answer_label: "" + hint_text: "" + question_text: "Please state the tenancy type" + starter_tenancy_type: + page_header: "" + tenancy: + check_answer_label: "Type of main tenancy after the starter period has ended" + hint_text: "This is also known as an ‘introductory period’." + question_text: "What is the type of tenancy after the starter period has ended?" + tenancyother: + check_answer_label: "" + hint_text: "" + question_text: "Please state the tenancy type" + + tenancylength: + tenancy_length: + page_header: "" + check_answer_label: "Length of fixed-term tenancy" + hint_text: "Do not include the starter or introductory period." + question_text: "What is the length of the fixed-term tenancy to the nearest year?" + tenancy_length_affordable_rent: + page_header: "" + check_answer_label: "Length of fixed-term tenancy" + hint_text: "Do not include the starter or introductory period.
    The minimum period is 2 years for social or affordable rent general needs logs and you do not need a log for shorter tenancies." + question_text: "What is the length of the fixed-term tenancy to the nearest year?" + tenancy_length_intermediate_rent: + page_header: "" + check_answer_label: "Length of fixed-term tenancy" + hint_text: "Do not include the starter or introductory period.
    The minimum period is 1 year for intermediate rent general needs logs and you do not need a log for shorter tenancies." + question_text: "What is the length of the fixed-term tenancy to the nearest year?" + tenancy_length_periodic: + page_header: "" + check_answer_label: "Length of periodic tenancy" + hint_text: "As this is a periodic tenancy, this question is optional. If you do not have the information available click save and continue" + question_text: "What is the length of the periodic tenancy to the nearest year?" + + sheltered: + page_header: "" + check_answer_label: "Is this letting in sheltered accommodation?" + hint_text: "Sheltered housing and special retirement housing are for tenants with low-level care and support needs. This typically provides some limited support to enable independent living, such as alarm-based assistance or a scheme manager.

    Extra care housing is for tenants with medium to high care and support needs, often with 24 hour access to support staff provided by an agency registered with the Care Quality Commission." + question_text: "Is this letting in sheltered accommodation?" diff --git a/config/locales/forms/2024/lettings/tenancy_information.en.yml b/config/locales/forms/2024/lettings/tenancy_information.en.yml new file mode 100644 index 000000000..bee380e7c --- /dev/null +++ b/config/locales/forms/2024/lettings/tenancy_information.en.yml @@ -0,0 +1,66 @@ +en: + forms: + 2024: + lettings: + tenancy_information: + joint: + page_header: "" + check_answer_label: "Is this a joint tenancy?" + hint_text: "This is where two or more people are named on the tenancy agreement" + question_text: "Is this a joint tenancy?" + + startertenancy: + page_header: "" + check_answer_label: "Is this a starter or introductory tenancy?" + hint_text: "If the tenancy has an ‘introductory period’ answer ‘yes’.

    You should submit a CORE log at the beginning of the starter tenancy or introductory period, with the best information you have at the time. You do not need to submit a log when a tenant later rolls onto the main tenancy." + question_text: "Is this a starter tenancy?" + + tenancy: + tenancy_type: + page_header: "" + tenancy: + check_answer_label: "Type of main tenancy" + hint_text: "" + question_text: "What is the type of tenancy?" + tenancyother: + check_answer_label: "" + hint_text: "" + question_text: "Please state the tenancy type" + starter_tenancy_type: + page_header: "" + tenancy: + check_answer_label: "Type of main tenancy after the starter or introductory period has ended" + hint_text: "" + question_text: "What is the type of tenancy after the starter or introductory period has ended?" + tenancyother: + check_answer_label: "" + hint_text: "" + question_text: "Please state the tenancy type" + + tenancylength: + tenancy_length: + page_header: "" + check_answer_label: "Length of fixed-term tenancy" + hint_text: "Do not include the starter or introductory period." + question_text: "What is the length of the fixed-term tenancy to the nearest year?" + tenancy_length_affordable_rent: + page_header: "" + check_answer_label: "Length of fixed-term tenancy" + hint_text: "Do not include the starter or introductory period.
    The minimum period is 2 years for social or affordable rent general needs logs. You do not need to submit CORE logs for these types of tenancies if they are shorter than 2 years." + question_text: "What is the length of the fixed-term tenancy to the nearest year?" + tenancy_length_intermediate_rent: + page_header: "" + check_answer_label: "Length of fixed-term tenancy" + hint_text: "Do not include the starter or introductory period.
    The minimum period is 1 year for intermediate rent general needs logs. You do not need to submit CORE logs for these types of tenancies if they are shorter than 1 year." + question_text: "What is the length of the fixed-term tenancy to the nearest year?" + tenancy_length_periodic: + page_header: "" + check_answer_label: "Length of periodic tenancy" + hint_text: "As this is a periodic tenancy, this question is optional. If you do not have the information available click save and continue" + question_text: "What is the length of the periodic tenancy to the nearest year?" + + sheltered: + page_header: "" + check_answer_label: "Is this letting in sheltered accommodation?" + hint_text: "Sheltered housing and special retirement housing are for tenants with low-level care and support needs. This typically provides some limited support to enable independent living, such as alarm-based assistance or a scheme manager.

    Extra care housing is for tenants with medium to high care and support needs, often with 24 hour access to support staff provided by an agency registered with the Care Quality Commission." + question_text: "Is this letting in sheltered accommodation?" diff --git a/spec/models/form/lettings/questions/starter_tenancy_type_spec.rb b/spec/models/form/lettings/questions/starter_tenancy_type_spec.rb index 66ea2b355..d3022dfcf 100644 --- a/spec/models/form/lettings/questions/starter_tenancy_type_spec.rb +++ b/spec/models/form/lettings/questions/starter_tenancy_type_spec.rb @@ -5,7 +5,7 @@ RSpec.describe Form::Lettings::Questions::StarterTenancyType, type: :model do let(:question_id) { nil } let(:question_definition) { nil } - let(:page) { instance_double(Form::Page) } + let(:page) { instance_double(Form::Page, id: "starter_tenancy_type") } let(:subsection) { instance_double(Form::Subsection) } let(:form) { instance_double(Form, start_date: Time.zone.local(2023, 4, 1)) } diff --git a/spec/models/form/lettings/questions/tenancy_length_affordable_rent_spec.rb b/spec/models/form/lettings/questions/tenancy_length_affordable_rent_spec.rb index fb334f909..4bab9187a 100644 --- a/spec/models/form/lettings/questions/tenancy_length_affordable_rent_spec.rb +++ b/spec/models/form/lettings/questions/tenancy_length_affordable_rent_spec.rb @@ -5,7 +5,7 @@ RSpec.describe Form::Lettings::Questions::TenancyLengthAffordableRent, type: :mo let(:question_id) { nil } let(:question_definition) { nil } - let(:page) { instance_double(Form::Page) } + let(:page) { instance_double(Form::Page, id: "affordable_tenancy_length") } let(:subsection) { instance_double(Form::Subsection) } let(:form) { instance_double(Form, start_date: Time.zone.local(2023, 4, 1)) } diff --git a/spec/models/form/lettings/questions/tenancy_length_intermediate_rent_spec.rb b/spec/models/form/lettings/questions/tenancy_length_intermediate_rent_spec.rb index 0c0923bf8..a3f9c80e2 100644 --- a/spec/models/form/lettings/questions/tenancy_length_intermediate_rent_spec.rb +++ b/spec/models/form/lettings/questions/tenancy_length_intermediate_rent_spec.rb @@ -5,7 +5,7 @@ RSpec.describe Form::Lettings::Questions::TenancyLengthIntermediateRent, type: : let(:question_id) { nil } let(:question_definition) { nil } - let(:page) { instance_double(Form::Page) } + let(:page) { instance_double(Form::Page, id: "intermediate_tenancy_length") } let(:subsection) { instance_double(Form::Subsection) } let(:form) { instance_double(Form, start_date: Time.zone.local(2023, 4, 1)) } diff --git a/spec/models/form/lettings/questions/tenancy_length_periodic_spec.rb b/spec/models/form/lettings/questions/tenancy_length_periodic_spec.rb index 3a0fae171..449677736 100644 --- a/spec/models/form/lettings/questions/tenancy_length_periodic_spec.rb +++ b/spec/models/form/lettings/questions/tenancy_length_periodic_spec.rb @@ -5,7 +5,7 @@ RSpec.describe Form::Lettings::Questions::TenancyLengthPeriodic, type: :model do let(:question_id) { nil } let(:question_definition) { nil } - let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1)))) } + let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1))), id: "periodic_tenancy_length") } it "has correct page" do expect(question.page).to eq(page) diff --git a/spec/models/form/lettings/questions/tenancy_length_spec.rb b/spec/models/form/lettings/questions/tenancy_length_spec.rb index 2d87d0923..cc7bf9f9f 100644 --- a/spec/models/form/lettings/questions/tenancy_length_spec.rb +++ b/spec/models/form/lettings/questions/tenancy_length_spec.rb @@ -3,7 +3,7 @@ require "rails_helper" RSpec.describe Form::Lettings::Questions::TenancyLength, type: :model do subject(:question) { described_class.new(nil, nil, page) } - let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1)))) } + let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1))), id: "tenancy_length") } it "has correct page" do expect(question.page).to eq(page) diff --git a/spec/models/form/lettings/questions/tenancy_other_spec.rb b/spec/models/form/lettings/questions/tenancy_other_spec.rb index ce8aec5db..a6a2962dc 100644 --- a/spec/models/form/lettings/questions/tenancy_other_spec.rb +++ b/spec/models/form/lettings/questions/tenancy_other_spec.rb @@ -3,7 +3,7 @@ require "rails_helper" RSpec.describe Form::Lettings::Questions::TenancyOther, type: :model do subject(:question) { described_class.new(nil, nil, page) } - let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1)))) } + let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 1))), id: "tenancy_type") } it "has correct page" do expect(question.page).to eq(page) diff --git a/spec/models/form/lettings/questions/tenancy_type_spec.rb b/spec/models/form/lettings/questions/tenancy_type_spec.rb index 13998094a..08818d3ea 100644 --- a/spec/models/form/lettings/questions/tenancy_type_spec.rb +++ b/spec/models/form/lettings/questions/tenancy_type_spec.rb @@ -3,7 +3,7 @@ require "rails_helper" RSpec.describe Form::Lettings::Questions::TenancyType, type: :model do subject(:question) { described_class.new(nil, nil, page) } - let(:page) { instance_double(Form::Page) } + let(:page) { instance_double(Form::Page, id: "tenancy_type") } let(:subsection) { instance_double(Form::Subsection) } let(:form) { instance_double(Form, start_date: Time.zone.local(2023, 4, 1)) } diff --git a/spec/services/merge/merge_organisations_service_spec.rb b/spec/services/merge/merge_organisations_service_spec.rb index 6eea8635f..7163a142f 100644 --- a/spec/services/merge/merge_organisations_service_spec.rb +++ b/spec/services/merge/merge_organisations_service_spec.rb @@ -1317,9 +1317,9 @@ RSpec.describe Merge::MergeOrganisationsService do merging_organisation.reload expect(new_absorbing_organisation.owned_lettings_logs.count).to eq(2) expect(new_absorbing_organisation.managed_lettings_logs.count).to eq(1) - expect(new_absorbing_organisation.owned_lettings_logs.find(owned_lettings_log.id).scheme).to eq(new_absorbing_organisation.owned_schemes.first) - expect(new_absorbing_organisation.owned_lettings_logs.find(owned_lettings_log.id).location).to eq(new_absorbing_organisation.owned_schemes.first.locations.first) - expect(new_absorbing_organisation.owned_lettings_logs.find(owned_lettings_log_no_location.id).scheme).to eq(new_absorbing_organisation.owned_schemes.first) + expect(new_absorbing_organisation.owned_lettings_logs.find(owned_lettings_log.id).scheme).to eq(new_absorbing_organisation.owned_schemes.find_by(service_name: scheme.service_name)) + expect(new_absorbing_organisation.owned_lettings_logs.find(owned_lettings_log.id).location).to eq(new_absorbing_organisation.owned_schemes.find_by(service_name: scheme.service_name).locations.first) + expect(new_absorbing_organisation.owned_lettings_logs.find(owned_lettings_log_no_location.id).scheme).to eq(new_absorbing_organisation.owned_schemes.find_by(service_name: scheme.service_name)) expect(new_absorbing_organisation.owned_lettings_logs.find(owned_lettings_log_no_location.id).location).to eq(nil) end From b6f3a24db735e1453a1c1842952cc1ea66f3e8e0 Mon Sep 17 00:00:00 2001 From: Manny Dinssa <44172848+Dinssa@users.noreply.github.com> Date: Wed, 30 Oct 2024 15:25:33 +0000 Subject: [PATCH 22/30] Update links from dluhcdigital to mhclgdigital (#2717) --- app/constants/global_constants.rb | 2 +- app/helpers/merge_requests_helper.rb | 2 +- app/views/content/accessibility_statement.md | 4 ++-- .../data_protection_confirmation_banner_component_spec.rb | 4 ++-- spec/mailers/csv_download_mailer_spec.rb | 4 ++-- spec/requests/organisations_controller_spec.rb | 2 +- spec/views/merge_requests/show.html.erb_spec.rb | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/constants/global_constants.rb b/app/constants/global_constants.rb index f42af5253..4066fb1d4 100644 --- a/app/constants/global_constants.rb +++ b/app/constants/global_constants.rb @@ -1,5 +1,5 @@ module GlobalConstants - HELPDESK_URL = "https://dluhcdigital.atlassian.net/servicedesk/customer/portal/6/group/11".freeze + HELPDESK_URL = "https://mhclgdigital.atlassian.net/servicedesk/customer/portal/6/group/11".freeze COUNTRIES_ANSWER_OPTIONS = { "" => "Select an option", diff --git a/app/helpers/merge_requests_helper.rb b/app/helpers/merge_requests_helper.rb index a342ca808..6283ef42e 100644 --- a/app/helpers/merge_requests_helper.rb +++ b/app/helpers/merge_requests_helper.rb @@ -9,7 +9,7 @@ module MergeRequestsHelper def request_details(merge_request) [ { label: "Requester", value: display_value_or_placeholder(merge_request.requester&.name) }, - { label: "Helpdesk ticket", value: merge_request.helpdesk_ticket.present? ? link_to("#{merge_request.helpdesk_ticket} (opens in a new tab)", "https://dluhcdigital.atlassian.net/browse/#{merge_request.helpdesk_ticket}", target: "_blank", rel: "noopener noreferrer") : display_value_or_placeholder(nil), action: merge_request_action(merge_request, "helpdesk_ticket") }, + { label: "Helpdesk ticket", value: merge_request.helpdesk_ticket.present? ? link_to("#{merge_request.helpdesk_ticket} (opens in a new tab)", "https://mhclgdigital.atlassian.net/browse/#{merge_request.helpdesk_ticket}", target: "_blank", rel: "noopener noreferrer") : display_value_or_placeholder(nil), action: merge_request_action(merge_request, "helpdesk_ticket") }, { label: "Status", value: status_tag(merge_request.status) }, ] end diff --git a/app/views/content/accessibility_statement.md b/app/views/content/accessibility_statement.md index a49bd999c..1d861fdcf 100644 --- a/app/views/content/accessibility_statement.md +++ b/app/views/content/accessibility_statement.md @@ -32,11 +32,11 @@ If you need information on this website in a different format like accessible PD We’ll consider your request and get back to you in 2 working days. -You can also [contact us through the helpdesk](https://dluhcdigital.atlassian.net/servicedesk/customer/portal/6/group/11). +You can also [contact us through the helpdesk](https://mhclgdigital.atlassian.net/servicedesk/customer/portal/6/group/11). ### Reporting accessibility problems with this website -We’re always looking to improve the accessibility of this website. If you find any problems not listed on this page or think we’re not meeting accessibility requirements, [contact the helpdesk](https://dluhcdigital.atlassian.net/servicedesk/customer/portal/6/group/11). +We’re always looking to improve the accessibility of this website. If you find any problems not listed on this page or think we’re not meeting accessibility requirements, [contact the helpdesk](https://mhclgdigital.atlassian.net/servicedesk/customer/portal/6/group/11). ### Enforcement procedure diff --git a/spec/components/data_protection_confirmation_banner_component_spec.rb b/spec/components/data_protection_confirmation_banner_component_spec.rb index 608628093..fb687f25c 100644 --- a/spec/components/data_protection_confirmation_banner_component_spec.rb +++ b/spec/components/data_protection_confirmation_banner_component_spec.rb @@ -27,7 +27,7 @@ RSpec.describe DataProtectionConfirmationBannerComponent, type: :component do expect(component.display_banner?).to eq(true) expect(render).to have_link( "Contact helpdesk to assign a data protection officer", - href: "https://dluhcdigital.atlassian.net/servicedesk/customer/portal/6/group/11", + href: "https://mhclgdigital.atlassian.net/servicedesk/customer/portal/6/group/11", ) expect(render).to have_selector("p", text: "To create logs your organisation must state a data protection officer. They must sign the Data Sharing Agreement.") end @@ -131,7 +131,7 @@ RSpec.describe DataProtectionConfirmationBannerComponent, type: :component do expect(component.display_banner?).to eq(true) expect(render).to have_link( "Contact helpdesk to assign a data protection officer", - href: "https://dluhcdigital.atlassian.net/servicedesk/customer/portal/6/group/11", + href: "https://mhclgdigital.atlassian.net/servicedesk/customer/portal/6/group/11", ) expect(render).to have_selector("p", text: "To create logs your organisation must state a data protection officer. They must sign the Data Sharing Agreement.") end diff --git a/spec/mailers/csv_download_mailer_spec.rb b/spec/mailers/csv_download_mailer_spec.rb index 704d71e1e..138a0e4ce 100644 --- a/spec/mailers/csv_download_mailer_spec.rb +++ b/spec/mailers/csv_download_mailer_spec.rb @@ -42,7 +42,7 @@ RSpec.describe CsvDownloadMailer do ## Missing town or city The town or city in some logs is missing. This data is required in the new version of CORE.\n", how_to_fix: "You need to:\n -- download [this spreadsheet for lettings logs](#{link}). This link will expire in one week. To request another link, [contact the CORE helpdesk](https://dluhcdigital.atlassian.net/servicedesk/customer/portal/6/group/11). +- download [this spreadsheet for lettings logs](#{link}). This link will expire in one week. To request another link, [contact the CORE helpdesk](https://mhclgdigital.atlassian.net/servicedesk/customer/portal/6/group/11). - fill in the missing address data - check that the existing address data is correct\n", duration: "20 minutes", @@ -70,7 +70,7 @@ In some of your logs, the UPRN is the same as the purchaser code, but these are If a log has the correct UPRN, leave the UPRN unchanged. If the UPRN is incorrect, clear the value and provide the full address instead. Alternatively, you can change the UPRN on the CORE system.\n", how_to_fix: "You need to:\n -- download [this spreadsheet for sales logs](#{link}). This link will expire in one week. To request another link, [contact the CORE helpdesk](https://dluhcdigital.atlassian.net/servicedesk/customer/portal/6/group/11). +- download [this spreadsheet for sales logs](#{link}). This link will expire in one week. To request another link, [contact the CORE helpdesk](https://mhclgdigital.atlassian.net/servicedesk/customer/portal/6/group/11). - check that the address data is correct - correct any address errors\n", duration: "20 minutes", diff --git a/spec/requests/organisations_controller_spec.rb b/spec/requests/organisations_controller_spec.rb index 223cc9e00..5a300c56c 100644 --- a/spec/requests/organisations_controller_spec.rb +++ b/spec/requests/organisations_controller_spec.rb @@ -497,7 +497,7 @@ RSpec.describe OrganisationsController, type: :request do it "displays a link to merge organisations" do expect(page).to have_content("To report a merge or update your organisation details, ") - expect(page).to have_link("contact the helpdesk", href: "https://dluhcdigital.atlassian.net/servicedesk/customer/portal/6/group/11") + expect(page).to have_link("contact the helpdesk", href: "https://mhclgdigital.atlassian.net/servicedesk/customer/portal/6/group/11") end it "does not display merge history if there is none" do diff --git a/spec/views/merge_requests/show.html.erb_spec.rb b/spec/views/merge_requests/show.html.erb_spec.rb index d03239d2a..c1dd47bfd 100644 --- a/spec/views/merge_requests/show.html.erb_spec.rb +++ b/spec/views/merge_requests/show.html.erb_spec.rb @@ -30,7 +30,7 @@ RSpec.describe "merge_requests/show.html.erb", type: :view do it "displays the helpdesk ticket details" do expect(rendered).to have_selector("dt", text: "Helpdesk ticket") if merge_request.helpdesk_ticket.present? - expect(rendered).to have_link(merge_request.helpdesk_ticket, href: "https://dluhcdigital.atlassian.net/browse/#{merge_request.helpdesk_ticket}") + expect(rendered).to have_link(merge_request.helpdesk_ticket, href: "https://mhclgdigital.atlassian.net/browse/#{merge_request.helpdesk_ticket}") else expect(rendered).to have_selector("dd", text: "You didn't answer this question") end From 3804a64b2e1f15fd0c3e6208bab4d4392a9fb0b4 Mon Sep 17 00:00:00 2001 From: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com> Date: Wed, 30 Oct 2024 15:45:14 +0000 Subject: [PATCH 23/30] Open links in new tab (#2722) --- app/views/organisations/duplicate_schemes.html.erb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/views/organisations/duplicate_schemes.html.erb b/app/views/organisations/duplicate_schemes.html.erb index 427cf427c..79f7d435f 100644 --- a/app/views/organisations/duplicate_schemes.html.erb +++ b/app/views/organisations/duplicate_schemes.html.erb @@ -56,6 +56,8 @@ <% end %> +

    The links below open in a new tab.

    + <%= govuk_table do |table| %> <%= table.with_head do |head| %> <% head.with_row do |row| %> @@ -69,7 +71,7 @@
      <% duplicate_set.each do |scheme| %>
    1. - <%= govuk_link_to scheme.service_name, scheme %> + <%= govuk_link_to scheme.service_name, scheme, target: "#" %>
    2. <% end %>
    @@ -93,6 +95,8 @@ <% end %> +

    The links below open in a new tab.

    + <%= govuk_table do |table| %> <%= table.with_head do |head| %> <% head.with_row do |row| %> @@ -107,13 +111,13 @@
      <% duplicate_set[:locations].each do |location| %>
    1. - <%= govuk_link_to location.name, scheme_location_path(location) %> + <%= govuk_link_to location.name, scheme_location_path(location), target: "#" %>
    2. <% end %>
    <% end %> <% row.with_cell do %> - <%= govuk_link_to duplicate_set[:scheme].service_name, duplicate_set[:scheme] %> + <%= govuk_link_to duplicate_set[:scheme].service_name, duplicate_set[:scheme], target: "#" %> <% end %> <% end %> <% end %> From f9922c1ba4cd20509b5362a527c182b6197013a1 Mon Sep 17 00:00:00 2001 From: Manny Dinssa <44172848+Dinssa@users.noreply.github.com> Date: Wed, 30 Oct 2024 16:25:20 +0000 Subject: [PATCH 24/30] CLDC-3654: Copy changes - Sales property information questions (#2694) --- app/helpers/formatting_helper.rb | 3 +- .../form/lettings/pages/property_postcode.rb | 14 --- .../form/lettings/questions/postcode_full.rb | 15 --- .../form/lettings/questions/postcode_known.rb | 17 ---- .../subsections/property_information.rb | 6 +- .../sales/pages/about_price_value_check.rb | 5 +- app/models/form/sales/pages/address.rb | 2 +- .../form/sales/pages/address_fallback.rb | 2 +- .../form/sales/pages/address_matcher.rb | 2 +- .../pages/monthly_charges_value_check.rb | 5 +- .../form/sales/pages/no_address_found.rb | 5 +- .../pages/percentage_discount_value_check.rb | 7 +- app/models/form/sales/pages/postcode.rb | 13 --- .../sales/pages/property_local_authority.rb | 9 +- app/models/form/sales/pages/uprn.rb | 1 + .../form/sales/pages/uprn_confirmation.rb | 1 - app/models/form/sales/pages/uprn_selection.rb | 1 - .../questions/about_price_value_check.rb | 3 +- .../form/sales/questions/address_line1.rb | 3 +- .../address_line1_for_address_matcher.rb | 3 +- .../form/sales/questions/address_line2.rb | 2 +- app/models/form/sales/questions/county.rb | 3 +- .../questions/monthly_charges_value_check.rb | 3 +- .../form/sales/questions/no_address_found.rb | 2 +- .../percentage_discount_value_check.rb | 3 +- app/models/form/sales/questions/postcode.rb | 22 ----- .../questions/postcode_for_address_matcher.rb | 2 +- .../questions/postcode_for_full_address.rb | 3 +- .../form/sales/questions/postcode_known.rb | 29 ------ .../sales/questions/property_building_type.rb | 3 +- .../questions/property_local_authority.rb | 2 - .../property_local_authority_known.rb | 26 ------ .../questions/property_number_of_bedrooms.rb | 4 +- .../sales/questions/property_unit_type.rb | 3 +- .../property_wheelchair_accessible.rb | 4 +- .../form/sales/questions/town_or_city.rb | 3 +- app/models/form/sales/questions/uprn.rb | 3 +- .../form/sales/questions/uprn_confirmation.rb | 2 - app/models/form/sales/questions/uprn_known.rb | 6 +- .../form/sales/questions/uprn_selection.rb | 2 - .../sales/subsections/property_information.rb | 12 --- config/locales/en.yml | 14 +-- .../2023/sales/property_information.en.yml | 74 +++++++++++++++ .../forms/2023/sales/soft_validations.en.yml | 33 ++++++- .../2024/sales/property_information.en.yml | 91 +++++++++++++++++++ .../forms/2024/sales/soft_validations.en.yml | 41 ++++++++- .../pages/about_price_value_check_spec.rb | 7 +- .../pages/monthly_charges_value_check_spec.rb | 7 +- .../form/sales/pages/no_address_found_spec.rb | 7 +- .../percentage_discount_value_check_spec.rb | 7 +- spec/models/form/sales/pages/postcode_spec.rb | 29 ------ .../pages/property_local_authority_spec.rb | 13 --- .../sales/questions/postcode_known_spec.rb | 47 ---------- .../form/sales/questions/postcode_spec.rb | 46 ---------- .../sales/questions/uprn_confirmation_spec.rb | 6 +- .../form/sales/questions/uprn_known_spec.rb | 4 +- .../subsections/property_information_spec.rb | 24 ----- 57 files changed, 298 insertions(+), 408 deletions(-) delete mode 100644 app/models/form/lettings/pages/property_postcode.rb delete mode 100644 app/models/form/lettings/questions/postcode_full.rb delete mode 100644 app/models/form/lettings/questions/postcode_known.rb delete mode 100644 app/models/form/sales/pages/postcode.rb delete mode 100644 app/models/form/sales/questions/postcode.rb delete mode 100644 app/models/form/sales/questions/postcode_known.rb delete mode 100644 app/models/form/sales/questions/property_local_authority_known.rb create mode 100644 config/locales/forms/2023/sales/property_information.en.yml create mode 100644 config/locales/forms/2024/sales/property_information.en.yml delete mode 100644 spec/models/form/sales/pages/postcode_spec.rb delete mode 100644 spec/models/form/sales/questions/postcode_known_spec.rb delete mode 100644 spec/models/form/sales/questions/postcode_spec.rb diff --git a/app/helpers/formatting_helper.rb b/app/helpers/formatting_helper.rb index 0675d42ba..ffa8b05e9 100644 --- a/app/helpers/formatting_helper.rb +++ b/app/helpers/formatting_helper.rb @@ -2,7 +2,8 @@ module FormattingHelper def format_ending(text) return text if text.blank? - modified_text = lowercase_first_letter(text) + first_word = text.split.first + modified_text = first_word == first_word.upcase ? text : lowercase_first_letter(text) ensure_sentence_ending(modified_text) end diff --git a/app/models/form/lettings/pages/property_postcode.rb b/app/models/form/lettings/pages/property_postcode.rb deleted file mode 100644 index a40d4140f..000000000 --- a/app/models/form/lettings/pages/property_postcode.rb +++ /dev/null @@ -1,14 +0,0 @@ -class Form::Lettings::Pages::PropertyPostcode < ::Form::Page - def initialize(id, hsh, subsection) - super - @id = "property_postcode" - @depends_on = [{ "is_general_needs?" => true }] - end - - def questions - @questions ||= [ - Form::Lettings::Questions::PostcodeKnown.new(nil, nil, self), - Form::Lettings::Questions::PostcodeFull.new(nil, nil, self), - ] - end -end diff --git a/app/models/form/lettings/questions/postcode_full.rb b/app/models/form/lettings/questions/postcode_full.rb deleted file mode 100644 index fc7d7691b..000000000 --- a/app/models/form/lettings/questions/postcode_full.rb +++ /dev/null @@ -1,15 +0,0 @@ -class Form::Lettings::Questions::PostcodeFull < ::Form::Question - def initialize(id, hsh, page) - super - @id = "postcode_full" - @check_answer_label = "Postcode" - @header = "What is the property’s postcode?" - @type = "text" - @width = 5 - @inferred_check_answers_value = [{ "condition" => { "postcode_known" => 0 }, "value" => "Not known" }] - @check_answers_card_number = 0 - @hint_text = "" - @inferred_answers = { "la" => { "is_la_inferred" => true } } - @disable_clearing_if_not_routed_or_dynamic_answer_options = true - end -end diff --git a/app/models/form/lettings/questions/postcode_known.rb b/app/models/form/lettings/questions/postcode_known.rb deleted file mode 100644 index ea9adb06b..000000000 --- a/app/models/form/lettings/questions/postcode_known.rb +++ /dev/null @@ -1,17 +0,0 @@ -class Form::Lettings::Questions::PostcodeKnown < ::Form::Question - def initialize(id, hsh, page) - super - @id = "postcode_known" - @check_answer_label = "Do you know the property postcode?" - @header = "Do you know the property’s postcode?" - @type = "radio" - @check_answers_card_number = 0 - @hint_text = "" - @answer_options = ANSWER_OPTIONS - @disable_clearing_if_not_routed_or_dynamic_answer_options = true - @conditional_for = { "postcode_full" => [1] } - @hidden_in_check_answers = { "depends_on" => [{ "postcode_known" => 0 }, { "postcode_known" => 1 }] } - end - - ANSWER_OPTIONS = { "1" => { "value" => "Yes" }, "0" => { "value" => "No" } }.freeze -end diff --git a/app/models/form/lettings/subsections/property_information.rb b/app/models/form/lettings/subsections/property_information.rb index 3068faf92..7b9aead2d 100644 --- a/app/models/form/lettings/subsections/property_information.rb +++ b/app/models/form/lettings/subsections/property_information.rb @@ -38,16 +38,12 @@ class Form::Lettings::Subsections::PropertyInformation < ::Form::Subsection Form::Lettings::Pages::UprnSelection.new(nil, nil, self), Form::Lettings::Pages::AddressFallback.new(nil, nil, self), ] - elsif form.start_date.year == 2023 + else [ Form::Lettings::Pages::Uprn.new(nil, nil, self), Form::Lettings::Pages::UprnConfirmation.new(nil, nil, self), Form::Lettings::Pages::Address.new(nil, nil, self), ] - else - [ - Form::Lettings::Pages::PropertyPostcode.new(nil, nil, self), - ] end end diff --git a/app/models/form/sales/pages/about_price_value_check.rb b/app/models/form/sales/pages/about_price_value_check.rb index 8b5cb45ab..41ae283dc 100644 --- a/app/models/form/sales/pages/about_price_value_check.rb +++ b/app/models/form/sales/pages/about_price_value_check.rb @@ -6,8 +6,9 @@ class Form::Sales::Pages::AboutPriceValueCheck < ::Form::Page "purchase_price_out_of_soft_range?" => true, }, ] + @copy_key = "sales.soft_validations.value_value_check" @title_text = { - "translation" => "soft_validations.purchase_price.title_text", + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text", "arguments" => [ { "key" => "value", @@ -17,7 +18,7 @@ class Form::Sales::Pages::AboutPriceValueCheck < ::Form::Page ], } @informative_text = { - "translation" => "soft_validations.purchase_price.hint_text", + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text", "arguments" => [ { "key" => "field_formatted_as_currency", diff --git a/app/models/form/sales/pages/address.rb b/app/models/form/sales/pages/address.rb index 6bd74f8b7..be0ed9eae 100644 --- a/app/models/form/sales/pages/address.rb +++ b/app/models/form/sales/pages/address.rb @@ -2,7 +2,7 @@ class Form::Sales::Pages::Address < ::Form::Page def initialize(id, hsh, subsection) super @id = "address" - @header = "Q#{QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]} - What is the property's address?" + @copy_key = "sales.property_information.address" @depends_on = [ { "uprn_known" => nil }, { "uprn_known" => 0 }, diff --git a/app/models/form/sales/pages/address_fallback.rb b/app/models/form/sales/pages/address_fallback.rb index 3a69dabba..1f0a3f1e8 100644 --- a/app/models/form/sales/pages/address_fallback.rb +++ b/app/models/form/sales/pages/address_fallback.rb @@ -2,7 +2,7 @@ class Form::Sales::Pages::AddressFallback < ::Form::Page def initialize(id, hsh, subsection) super @id = "address" - @header = "Q12 - What is the property's address?" + @copy_key = "sales.property_information.address" @depends_on = [ { "uprn_known" => nil, "uprn_selection" => "uprn_not_listed" }, { "uprn_known" => 0, "uprn_selection" => "uprn_not_listed" }, diff --git a/app/models/form/sales/pages/address_matcher.rb b/app/models/form/sales/pages/address_matcher.rb index 5d2a38767..23b8c5c86 100644 --- a/app/models/form/sales/pages/address_matcher.rb +++ b/app/models/form/sales/pages/address_matcher.rb @@ -2,7 +2,7 @@ class Form::Sales::Pages::AddressMatcher < ::Form::Page def initialize(id, hsh, subsection) super @id = "address_matcher" - @header = "Find an address" + @copy_key = "sales.property_information.address_matcher" @depends_on = [ { "uprn_known" => nil }, { "uprn_known" => 0 }, diff --git a/app/models/form/sales/pages/monthly_charges_value_check.rb b/app/models/form/sales/pages/monthly_charges_value_check.rb index 662a048bb..f6aef088c 100644 --- a/app/models/form/sales/pages/monthly_charges_value_check.rb +++ b/app/models/form/sales/pages/monthly_charges_value_check.rb @@ -6,8 +6,9 @@ class Form::Sales::Pages::MonthlyChargesValueCheck < ::Form::Page "monthly_charges_over_soft_max?" => true, }, ] + @copy_key = "sales.soft_validations.monthly_charges_value_check" @title_text = { - "translation" => "soft_validations.monthly_charges_over_soft_max.title_text", + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text", "arguments" => [ { "key" => "field_formatted_as_currency", @@ -17,7 +18,7 @@ class Form::Sales::Pages::MonthlyChargesValueCheck < ::Form::Page ], } @informative_text = { - "translation" => "soft_validations.monthly_charges_over_soft_max.hint_text", + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text", "arguments" => [], } end diff --git a/app/models/form/sales/pages/no_address_found.rb b/app/models/form/sales/pages/no_address_found.rb index 6e3b04f40..ae2663896 100644 --- a/app/models/form/sales/pages/no_address_found.rb +++ b/app/models/form/sales/pages/no_address_found.rb @@ -3,12 +3,13 @@ class Form::Sales::Pages::NoAddressFound < ::Form::Page super @id = "no_address_found" @type = "interruption_screen" + @copy_key = "sales.soft_validations.address_search_value_check" @title_text = { - "translation" => "soft_validations.no_address_found.title_text", + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text", "arguments" => [], } @informative_text = { - "translation" => "soft_validations.no_address_found.informative_text", + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text", "arguments" => [], } @depends_on = [ diff --git a/app/models/form/sales/pages/percentage_discount_value_check.rb b/app/models/form/sales/pages/percentage_discount_value_check.rb index 37ff4eea4..aa8c20d75 100644 --- a/app/models/form/sales/pages/percentage_discount_value_check.rb +++ b/app/models/form/sales/pages/percentage_discount_value_check.rb @@ -1,15 +1,16 @@ class Form::Sales::Pages::PercentageDiscountValueCheck < ::Form::Page def initialize(id, hsh, subsection) super + @depends_on = [{ "percentage_discount_invalid?" => true }] + @copy_key = "sales.soft_validations.percentage_discount_value_check" @title_text = { - "translation" => "soft_validations.percentage_discount_value.title_text", + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text", "arguments" => [{ "key" => "discount", "label" => true, "i18n_template" => "discount" }], } @informative_text = { - "translation" => "soft_validations.percentage_discount_value.hint_text", + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text", "arguments" => [], } - @depends_on = [{ "percentage_discount_invalid?" => true }] end def questions diff --git a/app/models/form/sales/pages/postcode.rb b/app/models/form/sales/pages/postcode.rb deleted file mode 100644 index c40a18845..000000000 --- a/app/models/form/sales/pages/postcode.rb +++ /dev/null @@ -1,13 +0,0 @@ -class Form::Sales::Pages::Postcode < ::Form::Page - def initialize(id, hsh, subsection) - super - @id = "property_postcode" - end - - def questions - @questions ||= [ - Form::Sales::Questions::PostcodeKnown.new(nil, nil, self), - Form::Sales::Questions::Postcode.new(nil, nil, self), - ] - end -end diff --git a/app/models/form/sales/pages/property_local_authority.rb b/app/models/form/sales/pages/property_local_authority.rb index e0289839d..649a445f9 100644 --- a/app/models/form/sales/pages/property_local_authority.rb +++ b/app/models/form/sales/pages/property_local_authority.rb @@ -10,14 +10,7 @@ class Form::Sales::Pages::PropertyLocalAuthority < ::Form::Page def questions @questions ||= [ - la_known_question, Form::Sales::Questions::PropertyLocalAuthority.new(nil, nil, self), - ].compact - end - - def la_known_question - if form.start_date.year < 2023 - Form::Sales::Questions::PropertyLocalAuthorityKnown.new(nil, nil, self) - end + ] end end diff --git a/app/models/form/sales/pages/uprn.rb b/app/models/form/sales/pages/uprn.rb index d4c7e4d77..fce51e543 100644 --- a/app/models/form/sales/pages/uprn.rb +++ b/app/models/form/sales/pages/uprn.rb @@ -2,6 +2,7 @@ class Form::Sales::Pages::Uprn < ::Form::Page def initialize(id, hsh, subsection) super @id = "uprn" + @copy_key = "sales.property_information.uprn" end def questions diff --git a/app/models/form/sales/pages/uprn_confirmation.rb b/app/models/form/sales/pages/uprn_confirmation.rb index d553972a3..9cc2ccf94 100644 --- a/app/models/form/sales/pages/uprn_confirmation.rb +++ b/app/models/form/sales/pages/uprn_confirmation.rb @@ -2,7 +2,6 @@ class Form::Sales::Pages::UprnConfirmation < ::Form::Page def initialize(id, hsh, subsection) super @id = "uprn_confirmation" - @header = "We found an address that might be this property" end def questions diff --git a/app/models/form/sales/pages/uprn_selection.rb b/app/models/form/sales/pages/uprn_selection.rb index 94f35540f..6dc5bb2bc 100644 --- a/app/models/form/sales/pages/uprn_selection.rb +++ b/app/models/form/sales/pages/uprn_selection.rb @@ -2,7 +2,6 @@ class Form::Sales::Pages::UprnSelection < ::Form::Page def initialize(id, hsh, subsection) super @id = "uprn_selection" - @header = "We found some addresses that might be this property" @depends_on = [ { "uprn_known" => nil, "address_options_present?" => true }, { "uprn_known" => 0, "address_options_present?" => true }, diff --git a/app/models/form/sales/questions/about_price_value_check.rb b/app/models/form/sales/questions/about_price_value_check.rb index 2b51cd7fb..52f7b156f 100644 --- a/app/models/form/sales/questions/about_price_value_check.rb +++ b/app/models/form/sales/questions/about_price_value_check.rb @@ -2,8 +2,7 @@ class Form::Sales::Questions::AboutPriceValueCheck < ::Form::Question def initialize(id, hsh, page) super @id = "value_value_check" - @check_answer_label = "Purchase price confirmation" - @header = "Are you sure?" + @copy_key = "sales.soft_validations.value_value_check" @type = "interruption_screen" @answer_options = { "0" => { "value" => "Yes" }, diff --git a/app/models/form/sales/questions/address_line1.rb b/app/models/form/sales/questions/address_line1.rb index f72aaea96..f7a4c7c2d 100644 --- a/app/models/form/sales/questions/address_line1.rb +++ b/app/models/form/sales/questions/address_line1.rb @@ -2,11 +2,10 @@ class Form::Sales::Questions::AddressLine1 < ::Form::Question def initialize(id, hsh, page) super @id = "address_line1" - @header = "Address line 1" + @copy_key = "sales.property_information.address.address_line1" @error_label = "Address line 1" @type = "text" @plain_label = true - @check_answer_label = "Address lines 1 and 2" @disable_clearing_if_not_routed_or_dynamic_answer_options = true @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] @hide_question_number_on_page = true diff --git a/app/models/form/sales/questions/address_line1_for_address_matcher.rb b/app/models/form/sales/questions/address_line1_for_address_matcher.rb index fd1211b69..cfc086f7b 100644 --- a/app/models/form/sales/questions/address_line1_for_address_matcher.rb +++ b/app/models/form/sales/questions/address_line1_for_address_matcher.rb @@ -2,11 +2,10 @@ class Form::Sales::Questions::AddressLine1ForAddressMatcher < ::Form::Question def initialize(id, hsh, page) super @id = "address_line1_input" - @header = "Address line 1" + @copy_key = "sales.property_information.address_matcher.address_line1_input" @error_label = "Address line 1" @type = "text" @plain_label = true - @check_answer_label = "Find address" @disable_clearing_if_not_routed_or_dynamic_answer_options = true @hide_question_number_on_page = true end diff --git a/app/models/form/sales/questions/address_line2.rb b/app/models/form/sales/questions/address_line2.rb index 94396a2af..521d1dc58 100644 --- a/app/models/form/sales/questions/address_line2.rb +++ b/app/models/form/sales/questions/address_line2.rb @@ -2,7 +2,7 @@ class Form::Sales::Questions::AddressLine2 < ::Form::Question def initialize(id, hsh, page) super @id = "address_line2" - @header = "Address line 2 (optional)" + @copy_key = "sales.property_information.address.address_line2" @type = "text" @plain_label = true @disable_clearing_if_not_routed_or_dynamic_answer_options = true diff --git a/app/models/form/sales/questions/county.rb b/app/models/form/sales/questions/county.rb index d95d90e73..8f92a5480 100644 --- a/app/models/form/sales/questions/county.rb +++ b/app/models/form/sales/questions/county.rb @@ -2,10 +2,9 @@ class Form::Sales::Questions::County < ::Form::Question def initialize(id, hsh, page) super @id = "county" - @header = "County (optional)" + @copy_key = "sales.property_information.address.county" @type = "text" @plain_label = true - @check_answer_label = "County" @disable_clearing_if_not_routed_or_dynamic_answer_options = true @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] @hide_question_number_on_page = true diff --git a/app/models/form/sales/questions/monthly_charges_value_check.rb b/app/models/form/sales/questions/monthly_charges_value_check.rb index 90fcf4545..615238cda 100644 --- a/app/models/form/sales/questions/monthly_charges_value_check.rb +++ b/app/models/form/sales/questions/monthly_charges_value_check.rb @@ -2,8 +2,7 @@ class Form::Sales::Questions::MonthlyChargesValueCheck < ::Form::Question def initialize(id, hsh, page) super @id = "monthly_charges_value_check" - @check_answer_label = "Monthly charges confirmation" - @header = "Are you sure this is correct?" + @copy_key = "sales.soft_validations.monthly_charges_value_check" @type = "interruption_screen" @answer_options = { "0" => { "value" => "Yes" }, diff --git a/app/models/form/sales/questions/no_address_found.rb b/app/models/form/sales/questions/no_address_found.rb index 0db041111..06d92b594 100644 --- a/app/models/form/sales/questions/no_address_found.rb +++ b/app/models/form/sales/questions/no_address_found.rb @@ -2,7 +2,7 @@ class Form::Sales::Questions::NoAddressFound < ::Form::Question def initialize(id, hsh, page) super @id = "address_search_value_check" - @header = "No address found" + @copy_key = "sales.soft_validations.address_search_value_check" @type = "interruption_screen" @hidden_in_check_answers = true end diff --git a/app/models/form/sales/questions/percentage_discount_value_check.rb b/app/models/form/sales/questions/percentage_discount_value_check.rb index 9ac5547b4..5a1e7a045 100644 --- a/app/models/form/sales/questions/percentage_discount_value_check.rb +++ b/app/models/form/sales/questions/percentage_discount_value_check.rb @@ -2,8 +2,7 @@ class Form::Sales::Questions::PercentageDiscountValueCheck < ::Form::Question def initialize(id, hsh, page) super @id = "percentage_discount_value_check" - @check_answer_label = "Percentage discount confirmation" - @header = "Are you sure this is correct?" + @copy_key = "sales.soft_validations.percentage_discount_value_check" @type = "interruption_screen" @answer_options = { "0" => { "value" => "Yes" }, diff --git a/app/models/form/sales/questions/postcode.rb b/app/models/form/sales/questions/postcode.rb deleted file mode 100644 index 55e33199a..000000000 --- a/app/models/form/sales/questions/postcode.rb +++ /dev/null @@ -1,22 +0,0 @@ -class Form::Sales::Questions::Postcode < ::Form::Question - def initialize(id, hsh, page) - super - @id = "postcode_full" - @check_answer_label = "Property’s postcode" - @header = "Postcode" - @type = "text" - @width = 5 - @inferred_check_answers_value = [{ - "condition" => { - "pcodenk" => 1, - }, - "value" => "Not known", - }] - @inferred_answers = { - "la" => { - "is_la_inferred" => true, - }, - } - @disable_clearing_if_not_routed_or_dynamic_answer_options = true - end -end diff --git a/app/models/form/sales/questions/postcode_for_address_matcher.rb b/app/models/form/sales/questions/postcode_for_address_matcher.rb index 421cdc4fc..945bdc2ad 100644 --- a/app/models/form/sales/questions/postcode_for_address_matcher.rb +++ b/app/models/form/sales/questions/postcode_for_address_matcher.rb @@ -2,7 +2,7 @@ class Form::Sales::Questions::PostcodeForAddressMatcher < ::Form::Question def initialize(id, hsh, page) super @id = "postcode_full_input" - @header = "Postcode" + @copy_key = "sales.property_information.address_matcher.postcode_full_input" @type = "text" @width = 5 @plain_label = true diff --git a/app/models/form/sales/questions/postcode_for_full_address.rb b/app/models/form/sales/questions/postcode_for_full_address.rb index 74c235ab7..34fbea00b 100644 --- a/app/models/form/sales/questions/postcode_for_full_address.rb +++ b/app/models/form/sales/questions/postcode_for_full_address.rb @@ -2,7 +2,7 @@ class Form::Sales::Questions::PostcodeForFullAddress < ::Form::Question def initialize(id, hsh, page) super @id = "postcode_full" - @header = "Postcode" + @copy_key = "sales.property_information.address.postcode_full" @type = "text" @width = 5 @inferred_check_answers_value = [{ @@ -17,7 +17,6 @@ class Form::Sales::Questions::PostcodeForFullAddress < ::Form::Question }, } @plain_label = true - @check_answer_label = "Postcode" @disable_clearing_if_not_routed_or_dynamic_answer_options = true @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] @hide_question_number_on_page = true diff --git a/app/models/form/sales/questions/postcode_known.rb b/app/models/form/sales/questions/postcode_known.rb deleted file mode 100644 index 10a3e2765..000000000 --- a/app/models/form/sales/questions/postcode_known.rb +++ /dev/null @@ -1,29 +0,0 @@ -class Form::Sales::Questions::PostcodeKnown < ::Form::Question - def initialize(id, hsh, page) - super - @id = "pcodenk" - @check_answer_label = "Property’s postcode" - @header = "Do you know the property’s postcode?" - @type = "radio" - @answer_options = ANSWER_OPTIONS - @conditional_for = { - "postcode_full" => [0], - } - @hidden_in_check_answers = { - "depends_on" => [ - { - "pcodenk" => 0, - }, - { - "pcodenk" => 1, - }, - ], - } - @disable_clearing_if_not_routed_or_dynamic_answer_options = true - end - - ANSWER_OPTIONS = { - "0" => { "value" => "Yes" }, - "1" => { "value" => "No" }, - }.freeze -end diff --git a/app/models/form/sales/questions/property_building_type.rb b/app/models/form/sales/questions/property_building_type.rb index f8f7e3905..42b65a57a 100644 --- a/app/models/form/sales/questions/property_building_type.rb +++ b/app/models/form/sales/questions/property_building_type.rb @@ -2,8 +2,7 @@ class Form::Sales::Questions::PropertyBuildingType < ::Form::Question def initialize(id, hsh, page) super @id = "builtype" - @check_answer_label = "Type of building" - @header = "What type of building is the property?" + @copy_key = "sales.property_information.builtype" @type = "radio" @answer_options = ANSWER_OPTIONS @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] diff --git a/app/models/form/sales/questions/property_local_authority.rb b/app/models/form/sales/questions/property_local_authority.rb index 2a8d3cc69..053ee8fde 100644 --- a/app/models/form/sales/questions/property_local_authority.rb +++ b/app/models/form/sales/questions/property_local_authority.rb @@ -2,8 +2,6 @@ class Form::Sales::Questions::PropertyLocalAuthority < ::Form::Question def initialize(id, hsh, page) super @id = "la" - @check_answer_label = "Local authority" - @header = "What is the property’s local authority?" @type = "select" @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] @disable_clearing_if_not_routed_or_dynamic_answer_options = true diff --git a/app/models/form/sales/questions/property_local_authority_known.rb b/app/models/form/sales/questions/property_local_authority_known.rb deleted file mode 100644 index b18486c6a..000000000 --- a/app/models/form/sales/questions/property_local_authority_known.rb +++ /dev/null @@ -1,26 +0,0 @@ -class Form::Sales::Questions::PropertyLocalAuthorityKnown < ::Form::Question - def initialize(id, hsh, page) - super - @id = "la_known" - @check_answer_label = "Local authority known" - @header = "Do you know the property’s local authority?" - @type = "radio" - @answer_options = ANSWER_OPTIONS - @conditional_for = { "la" => [1] } - @hidden_in_check_answers = { - "depends_on" => [ - { - "la_known" => 1, - }, - ], - } - @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] - end - - ANSWER_OPTIONS = { - "1" => { "value" => "Yes" }, - "0" => { "value" => "No" }, - }.freeze - - QUESTION_NUMBER_FROM_YEAR = { 2023 => 16, 2024 => 17 }.freeze -end diff --git a/app/models/form/sales/questions/property_number_of_bedrooms.rb b/app/models/form/sales/questions/property_number_of_bedrooms.rb index b8462b6fa..c394fe334 100644 --- a/app/models/form/sales/questions/property_number_of_bedrooms.rb +++ b/app/models/form/sales/questions/property_number_of_bedrooms.rb @@ -2,9 +2,7 @@ class Form::Sales::Questions::PropertyNumberOfBedrooms < ::Form::Question def initialize(id, hsh, page) super @id = "beds" - @check_answer_label = "Number of bedrooms" - @header = "How many bedrooms does the property have?" - @hint_text = "A bedsit has 1 bedroom" + @copy_key = "sales.property_information.beds" @type = "numeric" @width = 2 @min = 1 diff --git a/app/models/form/sales/questions/property_unit_type.rb b/app/models/form/sales/questions/property_unit_type.rb index 1622473ec..45e935941 100644 --- a/app/models/form/sales/questions/property_unit_type.rb +++ b/app/models/form/sales/questions/property_unit_type.rb @@ -2,8 +2,7 @@ class Form::Sales::Questions::PropertyUnitType < ::Form::Question def initialize(id, hsh, page) super @id = "proptype" - @check_answer_label = "Type of unit" - @header = "What type of unit is the property?" + @copy_key = "sales.property_information.proptype" @type = "radio" @answer_options = ANSWER_OPTIONS @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] diff --git a/app/models/form/sales/questions/property_wheelchair_accessible.rb b/app/models/form/sales/questions/property_wheelchair_accessible.rb index 1569725c5..fd79bda9e 100644 --- a/app/models/form/sales/questions/property_wheelchair_accessible.rb +++ b/app/models/form/sales/questions/property_wheelchair_accessible.rb @@ -2,12 +2,10 @@ class Form::Sales::Questions::PropertyWheelchairAccessible < ::Form::Question def initialize(id, hsh, page) super @id = "wchair" - @check_answer_label = "Property built or adapted to wheelchair-user standards" - @header = "Is the property built or adapted to wheelchair-user standards?" + @copy_key = "sales.property_information.wchair" @type = "radio" @answer_options = ANSWER_OPTIONS @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] - @hint_text = form.start_year_after_2024? ? "This is whether someone who uses a wheelchair is able to make full use of all of the property’s rooms and facilities, including use of both inside and outside space, and entering and exiting the property." : nil end ANSWER_OPTIONS = { diff --git a/app/models/form/sales/questions/town_or_city.rb b/app/models/form/sales/questions/town_or_city.rb index 18f6298f3..9536c024f 100644 --- a/app/models/form/sales/questions/town_or_city.rb +++ b/app/models/form/sales/questions/town_or_city.rb @@ -2,10 +2,9 @@ class Form::Sales::Questions::TownOrCity < ::Form::Question def initialize(id, hsh, page) super @id = "town_or_city" - @header = "Town or city" + @copy_key = "sales.property_information.address.town_or_city" @type = "text" @plain_label = true - @check_answer_label = "Town or city" @disable_clearing_if_not_routed_or_dynamic_answer_options = true @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] @hide_question_number_on_page = true diff --git a/app/models/form/sales/questions/uprn.rb b/app/models/form/sales/questions/uprn.rb index 94aaccb43..ea0df85ab 100644 --- a/app/models/form/sales/questions/uprn.rb +++ b/app/models/form/sales/questions/uprn.rb @@ -2,8 +2,7 @@ class Form::Sales::Questions::Uprn < ::Form::Question def initialize(id, hsh, page) super @id = "uprn" - @check_answer_label = "UPRN" - @header = "What is the property's UPRN?" + @copy_key = "sales.property_information.uprn.uprn" @type = "text" @width = 10 @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] diff --git a/app/models/form/sales/questions/uprn_confirmation.rb b/app/models/form/sales/questions/uprn_confirmation.rb index 6954a6ea5..94c1afa36 100644 --- a/app/models/form/sales/questions/uprn_confirmation.rb +++ b/app/models/form/sales/questions/uprn_confirmation.rb @@ -2,9 +2,7 @@ class Form::Sales::Questions::UprnConfirmation < ::Form::Question def initialize(id, hsh, page) super @id = "uprn_confirmed" - @header = "Is this the property address?" @type = "radio" - @check_answer_label = "Is this the right address?" end def answer_options diff --git a/app/models/form/sales/questions/uprn_known.rb b/app/models/form/sales/questions/uprn_known.rb index fdd0c9e9a..e35642bee 100644 --- a/app/models/form/sales/questions/uprn_known.rb +++ b/app/models/form/sales/questions/uprn_known.rb @@ -2,13 +2,9 @@ class Form::Sales::Questions::UprnKnown < ::Form::Question def initialize(id, hsh, page) super @id = "uprn_known" - @check_answer_label = "UPRN known?" - @header = "Do you know the property's UPRN?" + @copy_key = "sales.property_information.uprn.uprn_known" @type = "radio" @answer_options = ANSWER_OPTIONS - @hint_text = "The Unique Property Reference Number (UPRN) is a unique number system created by Ordnance Survey and used by housing providers and various industries across the UK. An example UPRN is 10010457355.

    - The UPRN may not be the same as the property reference assigned by your organisation.

    - If you don’t know the UPRN you can enter the address of the property instead on the next screen." @conditional_for = { "uprn" => [1] } @inferred_check_answers_value = [ { diff --git a/app/models/form/sales/questions/uprn_selection.rb b/app/models/form/sales/questions/uprn_selection.rb index f916dcd47..282aed353 100644 --- a/app/models/form/sales/questions/uprn_selection.rb +++ b/app/models/form/sales/questions/uprn_selection.rb @@ -2,9 +2,7 @@ class Form::Sales::Questions::UprnSelection < ::Form::Question def initialize(id, hsh, page) super @id = "uprn_selection" - @header = "Select the correct address" @type = "radio" - @check_answer_label = "Select the correct address" @disable_clearing_if_not_routed_or_dynamic_answer_options = true end diff --git a/app/models/form/sales/subsections/property_information.rb b/app/models/form/sales/subsections/property_information.rb index 2c530ab60..c59c159ae 100644 --- a/app/models/form/sales/subsections/property_information.rb +++ b/app/models/form/sales/subsections/property_information.rb @@ -16,7 +16,6 @@ class Form::Sales::Subsections::PropertyInformation < ::Form::Subsection Form::Sales::Pages::PercentageDiscountValueCheck.new("percentage_discount_proptype_value_check", nil, self), Form::Sales::Pages::PropertyBuildingType.new(nil, nil, self), (uprn_questions if form.start_date.year == 2023), - (postcode_and_la_questions if form.start_date.year < 2023), Form::Sales::Pages::PropertyWheelchairAccessible.new(nil, nil, self), ].flatten.compact end @@ -49,15 +48,4 @@ class Form::Sales::Subsections::PropertyInformation < ::Form::Subsection ] end end - - def postcode_and_la_questions - [ - Form::Sales::Pages::Postcode.new(nil, nil, self), - Form::Sales::Pages::PropertyLocalAuthority.new(nil, nil, self), - Form::Sales::Pages::Buyer1IncomeMaxValueCheck.new("local_authority_buyer_1_income_max_value_check", nil, self, check_answers_card_number: nil), - Form::Sales::Pages::Buyer2IncomeMaxValueCheck.new("local_authority_buyer_2_income_max_value_check", nil, self, check_answers_card_number: nil), - Form::Sales::Pages::CombinedIncomeMaxValueCheck.new("local_authority_combined_income_max_value_check", nil, self, check_answers_card_number: nil), - Form::Sales::Pages::AboutPriceValueCheck.new("about_price_la_value_check", nil, self), - ] - end end diff --git a/config/locales/en.yml b/config/locales/en.yml index 7ed8f42e8..a0d31fee5 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -234,7 +234,7 @@ en: scheme_deleted: "%{service_name} has been deleted." user_deleted: "%{name} has been deleted." organisation_deleted: "%{name} has been deleted." - user_updated: + user_updated: self: "Your account details have been updated." other: "%{name}’s details have been updated." @@ -650,9 +650,6 @@ en: outside_range_title: "You told us the rent is %{brent}." informative_text: "This is %{higher_or_lower} than we would expect." hint_text: "Check the following:
    • the decimal point
    • the frequency, for example every week or every calendar month
    • the rent type is correct, for example affordable or social rent
    " - purchase_price: - title_text: "You told us the purchase price is %{value}." - hint_text: "This is %{higher_or_lower} than we would expect." staircase_owned: title_text: one: "You told us that the buyer now owns %{stairowned} of the property." @@ -684,17 +681,11 @@ Make sure these answers are correct." staircase_bought_seems_high: title_text: "You told us that %{percentage}% was bought in this staircasing transaction." hint_text: "Most staircasing transactions are less than 50%" - monthly_charges_over_soft_max: - title_text: "You told us that the monthly charges were %{mscharge}." - hint_text: "This is higher than we would expect." discounted_sale_value: title_text: "Mortgage, deposit, and grant total must equal %{value_with_discount}." informative_text: "Your given mortgage, deposit and grant total is %{mortgage_deposit_and_grant_total}." care_home_charges: title_text: "Care home charges should be provided if this is a care home accommodation." - percentage_discount_value: - title_text: "You told us that the percentage discount is %{discount}." - hint_text: "This is higher than we would expect." grant: title_text: "You told us that the grant amount is %{grant}." hint_text: "Loans, grants and subsidies are usually between £9,000 and £16,000." @@ -722,9 +713,6 @@ Make sure these answers are correct." must_be_less_than_3_years_from_saledate: "You told us practical completion or handover date is more than 3 years before sale completion date." saledate: must_be_less_than_3_years_from_hodate: "You told us sale completion date is more than 3 years after practical completion or handover date." - no_address_found: - title_text: "No address found." - informative_text: "We could not find an address that matches your search. You can search again or continue to enter the address manually." partner_under_16_lettings: title: "You told us this person is aged %{age} years and has 'Partner' relationship to the lead tenant." multiple_partners_lettings: diff --git a/config/locales/forms/2023/sales/property_information.en.yml b/config/locales/forms/2023/sales/property_information.en.yml new file mode 100644 index 000000000..c4dd84130 --- /dev/null +++ b/config/locales/forms/2023/sales/property_information.en.yml @@ -0,0 +1,74 @@ +en: + forms: + 2023: + sales: + property_information: + uprn: + page_header: "" + uprn_known: + check_answer_label: "UPRN known?" + hint_text: "The Unique Property Reference Number (UPRN) is a unique number system created by Ordnance Survey and used by housing providers and various industries across the UK. An example UPRN is 10010457355.

    The UPRN may not be the same as the property reference assigned by your organisation.

    If you don’t know the UPRN you can enter the address of the property instead on the next screen." + question_text: "Do you know the property's UPRN?" + uprn: + check_answer_label: "UPRN" + hint_text: "" + question_text: "What is the property's UPRN?" + + uprn_confirmed: + page_header: "We found an address that might be this property" + check_answer_label: "Is this the right address?" + hint_text: "" + question_text: "Is this the property address?" + + address: + page_header: "Q15 - What is the property's address?" + address_line1: + check_answer_label: "Address lines 1 and 2" + hint_text: "" + question_text: "Address line 1" + address_line2: + check_answer_label: "" + hint_text: "" + question_text: "Address line 2 (optional)" + town_or_city: + check_answer_label: "Town or city" + hint_text: "" + question_text: "Town or city" + county: + check_answer_label: "County" + hint_text: "" + question_text: "County (optional)" + postcode_full: + check_answer_label: "Postcode" + hint_text: "" + question_text: "Postcode" + + la: + page_header: "" + check_answer_label: "Local authority" + hint_text: "" + question_text: "What is the property’s local authority?" + + beds: + page_header: "" + check_answer_label: "Number of bedrooms" + hint_text: "A bedsit has 1 bedroom." + question_text: "How many bedrooms does the property have?" + + proptype: + page_header: "" + check_answer_label: "Type of unit" + hint_text: "" + question_text: "What type of unit is the property?" + + builtype: + page_header: "" + check_answer_label: "Type of building" + hint_text: "" + question_text: "What type of building is the property?" + + wchair: + page_header: "" + check_answer_label: "Property built or adapted to wheelchair-user standards" + hint_text: "" + question_text: "Is the property built or adapted to wheelchair-user standards?" diff --git a/config/locales/forms/2023/sales/soft_validations.en.yml b/config/locales/forms/2023/sales/soft_validations.en.yml index 3467b9432..11a7406e4 100644 --- a/config/locales/forms/2023/sales/soft_validations.en.yml +++ b/config/locales/forms/2023/sales/soft_validations.en.yml @@ -38,6 +38,7 @@ en: max: page_header: "" title_text: "You told us the income of buyer 1 is %{income}. This seems high. Are you sure this is correct?" + income2_value_check: check_answer_label: "Buyer 2 income confirmation" hint_text: "" @@ -49,12 +50,22 @@ en: max: page_header: "" title_text: "You told us the income of buyer 2 is %{income}. This seems high. Are you sure this is correct?" + combined_income_value_check: page_header: "" check_answer_label: "Combined income confirmation" hint_text: "" question_text: "Are you sure this is correct?" title_text: "You told us the combined income of this household is %{combined_income}. This seems high. Are you sure this is correct?" + + value_value_check: + page_header: "" + check_answer_label: "Purchase price confirmation" + hint_text: "" + question_text: "Are you sure?" + title_text: "You told us the purchase price is %{value}." + informative_text: "This is %{higher_or_lower} than we would expect." + mortgage_value_check: page_header: "" check_answer_label: "Mortgage confirmation" @@ -62,18 +73,36 @@ en: question_text: "Are you sure that the mortgage is more than 5 times the income used for the mortgage application?" title_text: "You told us that the mortgage amount is %{mortgage}." informative_text: "This is more than 5 times the income, which is higher than we would expect." + + monthly_charges_value_check: + page_header: "" + check_answer_label: "Monthly charges confirmation" + hint_text: "" + question_text: "Are you sure this is correct?" + title_text: "You told us that the monthly charges were %{mscharge}." + informative_text: "This is higher than we would expect." + + percentage_discount_value_check: + page_header: "" + check_answer_label: "Percentage discount confirmation" + hint_text: "" + question_text: "Are you sure this is correct?" + title_text: "You told us that the percentage discount is %{discount}." + informative_text: "This is higher than we would expect." + savings_value_check: page_header: "" check_answer_label: "Savings confirmation" hint_text: "" question_text: "Are you sure the savings are higher than £100,000?" joint_purchase: - title_text: You told us the buyers’ savings were %{savings}." + title_text: "You told us the buyers’ savings were %{savings}." informative_text: "This is higher than we would expect." not_joint_purchase: title_text: "You told us the buyer’s savings were %{savings}." informative_text: "This is higher than we would expect." - deposit_value_check:: + + deposit_value_check: page_header: "" check_answer_label: "Deposit confirmation" hint_text: "" diff --git a/config/locales/forms/2024/sales/property_information.en.yml b/config/locales/forms/2024/sales/property_information.en.yml new file mode 100644 index 000000000..269f4fdca --- /dev/null +++ b/config/locales/forms/2024/sales/property_information.en.yml @@ -0,0 +1,91 @@ +en: + forms: + 2024: + sales: + property_information: + uprn: + page_header: "" + uprn_known: + check_answer_label: "UPRN known?" + hint_text: "The Unique Property Reference Number (UPRN) is a unique number system created by Ordnance Survey and used by housing providers and various industries across the UK. An example UPRN is 10010457355.

    The UPRN may not be the same as the property reference assigned by your organisation.

    If you don’t know the UPRN you can enter the address of the property instead on the next screen." + question_text: "Do you know the property's UPRN?" + uprn: + check_answer_label: "UPRN" + hint_text: "" + question_text: "What is the property's UPRN?" + + uprn_confirmed: + page_header: "We found an address that might be this property" + check_answer_label: "Is this the right address?" + hint_text: "" + question_text: "Is this the property address?" + + address_matcher: + page_header: "Find an address" + address_line1_input: + check_answer_label: "Find address" + hint_text: "" + question_text: "Address line 1" + postcode_full_input: + check_answer_label: "" + hint_text: "" + question_text: "Postcode" + + uprn_selection: + page_header: "We found an address that might be this property" + check_answer_label: "Select the correct address" + hint_text: "" + question_text: "Select the correct address" + + address: + page_header: "Q12 - What is the property's address?" + address_line1: + check_answer_label: "Address lines 1 and 2" + hint_text: "" + question_text: "Address line 1" + address_line2: + check_answer_label: "" + hint_text: "" + question_text: "Address line 2 (optional)" + town_or_city: + check_answer_label: "Town or city" + hint_text: "" + question_text: "Town or city" + county: + check_answer_label: "County" + hint_text: "" + question_text: "County (optional)" + postcode_full: + check_answer_label: "Postcode" + hint_text: "" + question_text: "Postcode" + + la: + page_header: "" + check_answer_label: "Local authority" + hint_text: "" + question_text: "What is the property’s local authority?" + + beds: + page_header: "" + check_answer_label: "Number of bedrooms" + hint_text: "A bedsit has 1 bedroom." + question_text: "How many bedrooms does the property have?" + + proptype: + page_header: "" + check_answer_label: "Type of unit" + hint_text: "" + question_text: "What type of unit is the property?" + + builtype: + page_header: "" + check_answer_label: "Type of building" + hint_text: "" + question_text: "What type of building is the property?" + + wchair: + page_header: "" + check_answer_label: "Property built or adapted to wheelchair-user standards" + hint_text: "This is whether someone who uses a wheelchair is able to make full use of all of the property’s rooms and facilities, including use of both inside and outside space, and entering and exiting the property." + question_text: "Is the property built or adapted to wheelchair-user standards?" diff --git a/config/locales/forms/2024/sales/soft_validations.en.yml b/config/locales/forms/2024/sales/soft_validations.en.yml index 39af6cb38..872db4679 100644 --- a/config/locales/forms/2024/sales/soft_validations.en.yml +++ b/config/locales/forms/2024/sales/soft_validations.en.yml @@ -38,6 +38,7 @@ en: max: page_header: "" title_text: "You told us the income of buyer 1 is %{income}. This seems high. Are you sure this is correct?" + income2_value_check: check_answer_label: "Buyer 2 income confirmation" hint_text: "" @@ -49,12 +50,23 @@ en: max: page_header: "" title_text: "You told us the income of buyer 2 is %{income}. This seems high. Are you sure this is correct?" + combined_income_value_check: page_header: "" check_answer_label: "Combined income confirmation" hint_text: "" question_text: "Are you sure this is correct?" title_text: "You told us the combined income of this household is %{combined_income}. This seems high. Are you sure this is correct?" + informative_text: "" + + value_value_check: + page_header: "" + check_answer_label: "Purchase price confirmation" + hint_text: "" + question_text: "Are you sure?" + title_text: "You told us the purchase price is %{value}." + informative_text: "This is %{higher_or_lower} than we would expect." + mortgage_value_check: page_header: "" check_answer_label: "Mortgage confirmation" @@ -62,17 +74,35 @@ en: question_text: "Are you sure that the mortgage is more than 5 times the income used for the mortgage application?" title_text: "You told us that the mortgage amount is %{mortgage}." informative_text: "This is more than 5 times the income, which is higher than we would expect." + + monthly_charges_value_check: + page_header: "" + check_answer_label: "Monthly charges confirmation" + hint_text: "" + question_text: "Are you sure this is correct?" + title_text: "You told us that the monthly charges were %{mscharge}." + informative_text: "This is higher than we would expect." + + percentage_discount_value_check: + page_header: "" + check_answer_label: "Percentage discount confirmation" + hint_text: "" + question_text: "Are you sure this is correct?" + title_text: "You told us that the percentage discount is %{discount}." + informative_text: "This is higher than we would expect." + savings_value_check: page_header: "" check_answer_label: "Savings confirmation" hint_text: "" question_text: "Are you sure the savings are higher than £100,000?" joint_purchase: - title_text: You told us the buyers’ savings were %{savings}." + title_text: "You told us the buyers’ savings were %{savings}." informative_text: "This is higher than we would expect." not_joint_purchase: title_text: "You told us the buyer’s savings were %{savings}." informative_text: "This is higher than we would expect." + deposit_value_check: page_header: "" check_answer_label: "Deposit confirmation" @@ -84,6 +114,15 @@ en: not_joint_purchase: title_text: "You told us the buyer’s deposit was %{deposit} and their savings were %{savings}." informative_text: "The deposit amount is higher than we would expect for the amount of savings they have." + + address_search_value_check: + page_header: "" + check_answer_label: "" + hint_text: "" + question_text: "" + title_text: "No address found." + informative_text: "We could not find an address that matches your search. You can search again or continue to enter the address manually." + wheel_value_check: page_header: "" check_answer_label: "Does anyone in the household use a wheelchair?" diff --git a/spec/models/form/sales/pages/about_price_value_check_spec.rb b/spec/models/form/sales/pages/about_price_value_check_spec.rb index 7d3c31537..1193768db 100644 --- a/spec/models/form/sales/pages/about_price_value_check_spec.rb +++ b/spec/models/form/sales/pages/about_price_value_check_spec.rb @@ -5,7 +5,8 @@ RSpec.describe Form::Sales::Pages::AboutPriceValueCheck, type: :model do let(:page_id) { "savings_value_check" } let(:page_definition) { nil } - let(:subsection) { instance_double(Form::Subsection) } + let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) } + let(:subsection) { instance_double(Form::Subsection, form:) } it "has correct subsection" do expect(page.subsection).to eq(subsection) @@ -28,12 +29,12 @@ RSpec.describe Form::Sales::Pages::AboutPriceValueCheck, type: :model do end it "has the correct title_text" do - expect(page.title_text).to eq({ "arguments" => [{ "i18n_template" => "value", "key" => "value", "label" => true }], "translation" => "soft_validations.purchase_price.title_text" }) + expect(page.title_text).to eq({ "arguments" => [{ "i18n_template" => "value", "key" => "value", "label" => true }], "translation" => "forms.2024.sales.soft_validations.value_value_check.title_text" }) end it "has the correct informative_text" do expect(page.informative_text).to eq({ - "translation" => "soft_validations.purchase_price.hint_text", + "translation" => "forms.2024.sales.soft_validations.value_value_check.informative_text", "arguments" => [ { "key" => "field_formatted_as_currency", diff --git a/spec/models/form/sales/pages/monthly_charges_value_check_spec.rb b/spec/models/form/sales/pages/monthly_charges_value_check_spec.rb index cb187ecfd..ce72bbda8 100644 --- a/spec/models/form/sales/pages/monthly_charges_value_check_spec.rb +++ b/spec/models/form/sales/pages/monthly_charges_value_check_spec.rb @@ -5,7 +5,8 @@ RSpec.describe Form::Sales::Pages::MonthlyChargesValueCheck, type: :model do let(:page_id) { "monthly_charges_value_check" } let(:page_definition) { nil } - let(:subsection) { instance_double(Form::Subsection) } + let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) } + let(:subsection) { instance_double(Form::Subsection, form:) } it "has correct subsection" do expect(page.subsection).to eq(subsection) @@ -33,13 +34,13 @@ RSpec.describe Form::Sales::Pages::MonthlyChargesValueCheck, type: :model do it "has correct title_text" do expect(page.title_text).to eq({ - "translation" => "soft_validations.monthly_charges_over_soft_max.title_text", + "translation" => "forms.2024.sales.soft_validations.monthly_charges_value_check.title_text", "arguments" => [{ "arguments_for_key" => "mscharge", "i18n_template" => "mscharge", "key" => "field_formatted_as_currency" }], }) end it "has correct informative_text" do - expect(page.informative_text).to eq({ "arguments" => [], "translation" => "soft_validations.monthly_charges_over_soft_max.hint_text" }) + expect(page.informative_text).to eq({ "arguments" => [], "translation" => "forms.2024.sales.soft_validations.monthly_charges_value_check.informative_text" }) end it "has correct interruption_screen_question_ids" do diff --git a/spec/models/form/sales/pages/no_address_found_spec.rb b/spec/models/form/sales/pages/no_address_found_spec.rb index 1a40abba4..b6dbd677e 100644 --- a/spec/models/form/sales/pages/no_address_found_spec.rb +++ b/spec/models/form/sales/pages/no_address_found_spec.rb @@ -5,8 +5,9 @@ RSpec.describe Form::Sales::Pages::NoAddressFound, type: :model do let(:page_id) { nil } let(:page_definition) { nil } - let(:subsection) { instance_double(Form::Subsection) } let(:log) { create(:sales_log) } + let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) } + let(:subsection) { instance_double(Form::Subsection, form:) } it "has correct subsection" do expect(page.subsection).to eq(subsection) @@ -31,11 +32,11 @@ RSpec.describe Form::Sales::Pages::NoAddressFound, type: :model do end it "has the correct title_text" do - expect(page.title_text).to eq({ "arguments" => [], "translation" => "soft_validations.no_address_found.title_text" }) + expect(page.title_text).to eq({ "arguments" => [], "translation" => "forms.2024.sales.soft_validations.address_search_value_check.title_text" }) end it "has the correct informative_text" do - expect(page.informative_text).to eq({ "arguments" => [], "translation" => "soft_validations.no_address_found.informative_text" }) + expect(page.informative_text).to eq({ "arguments" => [], "translation" => "forms.2024.sales.soft_validations.address_search_value_check.informative_text" }) end it "has the correct interruption_screen_question_ids" do diff --git a/spec/models/form/sales/pages/percentage_discount_value_check_spec.rb b/spec/models/form/sales/pages/percentage_discount_value_check_spec.rb index 5fc3e05ad..0b8cf0152 100644 --- a/spec/models/form/sales/pages/percentage_discount_value_check_spec.rb +++ b/spec/models/form/sales/pages/percentage_discount_value_check_spec.rb @@ -5,7 +5,8 @@ RSpec.describe Form::Sales::Pages::PercentageDiscountValueCheck, type: :model do let(:page_id) { "percentage_discount_value_check" } let(:page_definition) { nil } - let(:subsection) { instance_double(Form::Subsection) } + let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) } + let(:subsection) { instance_double(Form::Subsection, form:) } it "has correct subsection" do expect(page.subsection).to eq(subsection) @@ -21,14 +22,14 @@ RSpec.describe Form::Sales::Pages::PercentageDiscountValueCheck, type: :model do it "has the correct title_text" do expect(page.title_text).to eq({ - "translation" => "soft_validations.percentage_discount_value.title_text", + "translation" => "forms.2024.sales.soft_validations.percentage_discount_value_check.title_text", "arguments" => [{ "key" => "discount", "label" => true, "i18n_template" => "discount" }], }) end it "has the correct informative_text" do expect(page.informative_text).to eq({ - "translation" => "soft_validations.percentage_discount_value.hint_text", + "translation" => "forms.2024.sales.soft_validations.percentage_discount_value_check.informative_text", "arguments" => [], }) end diff --git a/spec/models/form/sales/pages/postcode_spec.rb b/spec/models/form/sales/pages/postcode_spec.rb deleted file mode 100644 index 8f9c7273c..000000000 --- a/spec/models/form/sales/pages/postcode_spec.rb +++ /dev/null @@ -1,29 +0,0 @@ -require "rails_helper" - -RSpec.describe Form::Sales::Pages::Postcode, type: :model do - subject(:page) { described_class.new(page_id, page_definition, subsection) } - - let(:page_id) { nil } - let(:page_definition) { nil } - let(:subsection) { instance_double(Form::Subsection) } - - it "has correct subsection" do - expect(page.subsection).to eq(subsection) - end - - it "has correct questions" do - expect(page.questions.map(&:id)).to eq(%w[pcodenk postcode_full]) - end - - it "has the correct id" do - expect(page.id).to eq("property_postcode") - end - - it "has the correct description" do - expect(page.description).to be_nil - end - - it "has correct depends_on" do - expect(page.depends_on).to be_nil - end -end diff --git a/spec/models/form/sales/pages/property_local_authority_spec.rb b/spec/models/form/sales/pages/property_local_authority_spec.rb index 016d0534d..faba75665 100644 --- a/spec/models/form/sales/pages/property_local_authority_spec.rb +++ b/spec/models/form/sales/pages/property_local_authority_spec.rb @@ -18,19 +18,6 @@ RSpec.describe Form::Sales::Pages::PropertyLocalAuthority, type: :model do end describe "has correct questions" do - context "when 2022" do - let(:start_date) { Time.utc(2022, 2, 8) } - - it "has correct questions" do - expect(page.questions.map(&:id)).to eq( - %w[ - la_known - la - ], - ) - end - end - context "when 2023" do let(:start_date) { Time.utc(2023, 2, 8) } diff --git a/spec/models/form/sales/questions/postcode_known_spec.rb b/spec/models/form/sales/questions/postcode_known_spec.rb deleted file mode 100644 index 794c981d4..000000000 --- a/spec/models/form/sales/questions/postcode_known_spec.rb +++ /dev/null @@ -1,47 +0,0 @@ -require "rails_helper" - -RSpec.describe Form::Sales::Questions::PostcodeKnown, type: :model do - subject(:question) { described_class.new(question_id, question_definition, page) } - - let(:question_id) { nil } - let(:question_definition) { nil } - let(:page) { instance_double(Form::Page) } - - it "has correct page" do - expect(question.page).to eq(page) - end - - it "has the correct id" do - expect(question.id).to eq("pcodenk") - end - - it "has the correct type" do - expect(question.type).to eq("radio") - end - - it "is not marked as derived" do - expect(question.derived?(nil)).to be false - end - - it "has the correct answer_options" do - expect(question.answer_options).to eq({ - "0" => { "value" => "Yes" }, - "1" => { "value" => "No" }, - }) - end - - it "has correct conditional for" do - expect(question.conditional_for).to eq({ - "postcode_full" => [0], - }) - end - - it "has the correct hidden_in_check_answers" do - expect(question.hidden_in_check_answers).to eq({ - "depends_on" => [ - { "pcodenk" => 0 }, - { "pcodenk" => 1 }, - ], - }) - end -end diff --git a/spec/models/form/sales/questions/postcode_spec.rb b/spec/models/form/sales/questions/postcode_spec.rb deleted file mode 100644 index 480d6af60..000000000 --- a/spec/models/form/sales/questions/postcode_spec.rb +++ /dev/null @@ -1,46 +0,0 @@ -require "rails_helper" - -RSpec.describe Form::Sales::Questions::Postcode, type: :model do - subject(:question) { described_class.new(question_id, question_definition, page) } - - let(:question_id) { nil } - let(:question_definition) { nil } - let(:page) { instance_double(Form::Page) } - - it "has correct page" do - expect(question.page).to eq(page) - end - - it "has the correct id" do - expect(question.id).to eq("postcode_full") - end - - it "has the correct type" do - expect(question.type).to eq("text") - end - - it "is not marked as derived" do - expect(question.derived?(nil)).to be false - end - - it "has the correct width" do - expect(question.width).to eq(5) - end - - it "has the correct inferred_answers" do - expect(question.inferred_answers).to eq({ - "la" => { - "is_la_inferred" => true, - }, - }) - end - - it "has the correct inferred_check_answers_value" do - expect(question.inferred_check_answers_value).to eq([{ - "condition" => { - "pcodenk" => 1, - }, - "value" => "Not known", - }]) - end -end diff --git a/spec/models/form/sales/questions/uprn_confirmation_spec.rb b/spec/models/form/sales/questions/uprn_confirmation_spec.rb index ddb047937..0e54155b6 100644 --- a/spec/models/form/sales/questions/uprn_confirmation_spec.rb +++ b/spec/models/form/sales/questions/uprn_confirmation_spec.rb @@ -1,11 +1,13 @@ require "rails_helper" RSpec.describe Form::Sales::Questions::UprnConfirmation, type: :model do + include FormattingHelper + subject(:question) { described_class.new(question_id, question_definition, page) } let(:question_id) { nil } let(:question_definition) { nil } - let(:page) { instance_double(Form::Page) } + let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 4), type: "sales"), id: "property_information")) } it "has correct page" do expect(question.page).to eq(page) @@ -24,7 +26,7 @@ RSpec.describe Form::Sales::Questions::UprnConfirmation, type: :model do end it "has the correct unanswered_error_message" do - expect(question.unanswered_error_message).to eq("You must answer is this the right address?") + expect(question.unanswered_error_message).to eq("You must answer #{format_ending(I18n.t('forms.2023.sales.property_information.uprn_confirmed.check_answer_label'))}") end describe "notification_banner" do diff --git a/spec/models/form/sales/questions/uprn_known_spec.rb b/spec/models/form/sales/questions/uprn_known_spec.rb index d3a91a3ef..e551ca430 100644 --- a/spec/models/form/sales/questions/uprn_known_spec.rb +++ b/spec/models/form/sales/questions/uprn_known_spec.rb @@ -1,6 +1,8 @@ require "rails_helper" RSpec.describe Form::Sales::Questions::UprnKnown, type: :model do + include FormattingHelper + subject(:question) { described_class.new(question_id, question_definition, page) } let(:question_id) { nil } @@ -35,7 +37,7 @@ RSpec.describe Form::Sales::Questions::UprnKnown, type: :model do end it "has the correct unanswered_error_message" do - expect(question.unanswered_error_message).to eq("You must answer UPRN known?") + expect(question.unanswered_error_message).to eq("You must answer #{format_ending(I18n.t('forms.2023.sales.property_information.uprn.uprn_known.check_answer_label'))}") end it "has the correct hidden_in_check_answers" do diff --git a/spec/models/form/sales/subsections/property_information_spec.rb b/spec/models/form/sales/subsections/property_information_spec.rb index e0bf51e11..6e181f738 100644 --- a/spec/models/form/sales/subsections/property_information_spec.rb +++ b/spec/models/form/sales/subsections/property_information_spec.rb @@ -17,30 +17,6 @@ RSpec.describe Form::Sales::Subsections::PropertyInformation, type: :model do allow(form).to receive(:start_year_after_2024?).and_return(false) end - context "when 2022" do - let(:start_date) { Time.utc(2022, 2, 8) } - - it "has correct pages" do - expect(property_information.pages.compact.map(&:id)).to eq( - %w[ - property_number_of_bedrooms - about_price_bedrooms_value_check - property_unit_type - monthly_charges_property_type_value_check - percentage_discount_proptype_value_check - property_building_type - property_postcode - property_local_authority - local_authority_buyer_1_income_max_value_check - local_authority_buyer_2_income_max_value_check - local_authority_combined_income_max_value_check - about_price_la_value_check - property_wheelchair_accessible - ], - ) - end - end - context "when 2023" do let(:start_date) { Time.utc(2023, 2, 8) } From 7f016f898fcda81a8e9eab6a3add6b26371f30e1 Mon Sep 17 00:00:00 2001 From: Manny Dinssa <44172848+Dinssa@users.noreply.github.com> Date: Wed, 30 Oct 2024 16:41:22 +0000 Subject: [PATCH 25/30] CLDC-3687: Extract copy - lettings date validations (#2738) --- app/models/validations/date_validations.rb | 22 ++++++++-------- config/locales/en.yml | 13 ---------- .../locales/validations/lettings/date.en.yml | 20 ++++++++++++++ .../validations/date_validations_spec.rb | 26 +++++++++---------- 4 files changed, 44 insertions(+), 37 deletions(-) create mode 100644 config/locales/validations/lettings/date.en.yml diff --git a/app/models/validations/date_validations.rb b/app/models/validations/date_validations.rb index dce5c1ef0..7462290b6 100644 --- a/app/models/validations/date_validations.rb +++ b/app/models/validations/date_validations.rb @@ -4,30 +4,30 @@ module Validations::DateValidations def validate_property_major_repairs(record) date_valid?("mrcdate", record) if record["startdate"].present? && record["mrcdate"].present? && record["startdate"] < record["mrcdate"] - record.errors.add :mrcdate, I18n.t("validations.property.mrcdate.before_tenancy_start") + record.errors.add :mrcdate, I18n.t("validations.lettings.date.mrcdate.before_tenancy_start") end if is_rsnvac_first_let?(record) && record["mrcdate"].present? - record.errors.add :mrcdate, I18n.t("validations.property.mrcdate.not_first_let") + record.errors.add :mrcdate, I18n.t("validations.lettings.date.mrcdate.not_first_let") end if record["mrcdate"].present? && record["startdate"].present? && record["startdate"].to_date - record["mrcdate"].to_date > 3650 - record.errors.add :mrcdate, I18n.t("validations.property.mrcdate.ten_years_before_tenancy_start") + record.errors.add :mrcdate, I18n.t("validations.lettings.date.mrcdate.ten_years_before_tenancy_start") end end def validate_property_void_date(record) if record["voiddate"].present? && record["startdate"].present? && record["startdate"].to_date - record["voiddate"].to_date > 3650 - record.errors.add :voiddate, I18n.t("validations.property.void_date.ten_years_before_tenancy_start") + record.errors.add :voiddate, I18n.t("validations.lettings.date.void_date.ten_years_before_tenancy_start") end if record["voiddate"].present? && record["startdate"].present? && record["startdate"].to_date < record["voiddate"].to_date - record.errors.add :voiddate, I18n.t("validations.property.void_date.before_tenancy_start") + record.errors.add :voiddate, I18n.t("validations.lettings.date.void_date.before_tenancy_start") end if record["voiddate"].present? && record["mrcdate"].present? && record["mrcdate"].to_date < record["voiddate"].to_date - record.errors.add :voiddate, :after_mrcdate, message: I18n.t("validations.property.void_date.after_mrcdate") - record.errors.add :mrcdate, I18n.t("validations.property.mrcdate.before_void_date") + record.errors.add :voiddate, :after_mrcdate, message: I18n.t("validations.lettings.date.void_date.after_mrcdate") + record.errors.add :mrcdate, I18n.t("validations.lettings.date.mrcdate.before_void_date") end end @@ -35,19 +35,19 @@ module Validations::DateValidations return unless record.startdate && date_valid?("startdate", record) if record["voiddate"].present? && record.startdate < record["voiddate"] - record.errors.add :startdate, I18n.t("validations.setup.startdate.after_void_date") + record.errors.add :startdate, I18n.t("validations.lettings.date.startdate.after_void_date") end if record["mrcdate"].present? && record.startdate < record["mrcdate"] - record.errors.add :startdate, I18n.t("validations.setup.startdate.after_major_repair_date") + record.errors.add :startdate, I18n.t("validations.lettings.date.startdate.after_major_repair_date") end if record["voiddate"].present? && record["startdate"].to_date - record["voiddate"].to_date > 3650 - record.errors.add :startdate, I18n.t("validations.setup.startdate.ten_years_after_void_date") + record.errors.add :startdate, I18n.t("validations.lettings.date.startdate.ten_years_after_void_date") end if record["mrcdate"].present? && record["startdate"].to_date - record["mrcdate"].to_date > 3650 - record.errors.add :startdate, I18n.t("validations.setup.startdate.ten_years_after_mrc_date") + record.errors.add :startdate, I18n.t("validations.lettings.date.startdate.ten_years_after_mrc_date") end end diff --git a/config/locales/en.yml b/config/locales/en.yml index a0d31fee5..5baa98338 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -295,11 +295,7 @@ en: "Enter a date within the %{previous_start_year_short} to %{previous_end_year_short} or %{previous_end_year_short} to %{current_end_year_short} collection years, which is between %{previous_start_year_long} and %{current_end_year_long}." later_than_14_days_after: "The tenancy start date must not be later than 14 days from today’s date." before_scheme_end_date: "The tenancy start date must be before the end date for this supported housing scheme." - after_void_date: "Enter a tenancy start date that is after the void date." - after_major_repair_date: "Enter a tenancy start date that is after the major repair date." year_not_two_or_four_digits: "Tenancy start year must be 2 or 4 digits." - ten_years_after_void_date: "Enter a tenancy start date that is no more than 10 years after the void date." - ten_years_after_mrc_date: "Enter a tenancy start date that is no more than 10 years after the major repairs completion date." invalid_merged_organisations_start_date: same_organisation: "Enter a date when the owning and managing organisation was active. %{owning_organisation} became inactive on %{owning_organisation_merge_date} and was replaced by %{owning_absorbing_organisation}." same_merge: "Enter a date when the owning and managing organisations were active. %{owning_organisation} and %{managing_organisation} became inactive on %{owning_organisation_merge_date} and were replaced by %{owning_absorbing_organisation}." @@ -362,15 +358,6 @@ en: invalid: "UPRN must be 12 digits or less." uprn_known: invalid: "You must answer UPRN known?" - mrcdate: - before_tenancy_start: "Enter a major repairs date that is before the tenancy start date." - not_first_let: "Major repairs date must not be completed if the tenancy is a first let." - ten_years_before_tenancy_start: "Enter a major repairs completion date that is no more than 10 years before the tenancy start date." - before_void_date: "Major repairs date must be after the void date if provided." - void_date: - ten_years_before_tenancy_start: "Enter a void date no more than 10 years before the tenancy start date." - before_tenancy_start: "Enter a void date that is before the tenancy start date." - after_mrcdate: "Void date must be before the major repairs date if provided." la: la_invalid_for_org: "%{org_name} does not operate in %{la_name}." postcode_invalid_for_org: "Enter a postcode in an area covered by %{org_name}." diff --git a/config/locales/validations/lettings/date.en.yml b/config/locales/validations/lettings/date.en.yml new file mode 100644 index 000000000..54c53996f --- /dev/null +++ b/config/locales/validations/lettings/date.en.yml @@ -0,0 +1,20 @@ +en: + validations: + lettings: + date: + startdate: + after_void_date: "Enter a tenancy start date that is after the void date." + after_major_repair_date: "Enter a tenancy start date that is after the major repair date." + ten_years_after_void_date: "Enter a tenancy start date that is no more than 10 years after the void date." + ten_years_after_mrc_date: "Enter a tenancy start date that is no more than 10 years after the major repairs completion date." + + mrcdate: + before_tenancy_start: "Enter a major repairs date that is before the tenancy start date." + not_first_let: "Major repairs date must not be completed if the tenancy is a first let." + ten_years_before_tenancy_start: "Enter a major repairs completion date that is no more than 10 years before the tenancy start date." + before_void_date: "Major repairs date must be after the void date if provided." + + void_date: + ten_years_before_tenancy_start: "Enter a void date no more than 10 years before the tenancy start date." + before_tenancy_start: "Enter a void date that is before the tenancy start date." + after_mrcdate: "Void date must be before the major repairs date if provided." diff --git a/spec/models/validations/date_validations_spec.rb b/spec/models/validations/date_validations_spec.rb index 59be2537e..f6c81a088 100644 --- a/spec/models/validations/date_validations_spec.rb +++ b/spec/models/validations/date_validations_spec.rb @@ -26,7 +26,7 @@ RSpec.describe Validations::DateValidations do record.voiddate = Time.zone.local(2022, 2, 1) date_validator.validate_startdate(record) expect(record.errors["startdate"]) - .to include(match I18n.t("validations.setup.startdate.after_void_date")) + .to include(match I18n.t("validations.lettings.date.startdate.after_void_date")) end it "validates that the tenancy start date is after the major repair date if it has a major repair date" do @@ -34,7 +34,7 @@ RSpec.describe Validations::DateValidations do record.mrcdate = Time.zone.local(2022, 2, 1) date_validator.validate_startdate(record) expect(record.errors["startdate"]) - .to include(match I18n.t("validations.setup.startdate.after_major_repair_date")) + .to include(match I18n.t("validations.lettings.date.startdate.after_major_repair_date")) end it "produces no error when the tenancy start date is before the end date of the chosen scheme if it has an end date" do @@ -58,7 +58,7 @@ RSpec.describe Validations::DateValidations do record.mrcdate = Time.zone.local(2022, 2, 1) date_validator.validate_property_major_repairs(record) expect(record.errors["mrcdate"]) - .to include(match I18n.t("validations.property.mrcdate.before_tenancy_start")) + .to include(match I18n.t("validations.lettings.date.mrcdate.before_tenancy_start")) end it "must be before the tenancy start date" do @@ -74,9 +74,9 @@ RSpec.describe Validations::DateValidations do date_validator.validate_property_major_repairs(record) date_validator.validate_startdate(record) expect(record.errors["mrcdate"]) - .to include(match I18n.t("validations.property.mrcdate.ten_years_before_tenancy_start")) + .to include(match I18n.t("validations.lettings.date.mrcdate.ten_years_before_tenancy_start")) expect(record.errors["startdate"]) - .to include(match I18n.t("validations.setup.startdate.ten_years_after_mrc_date")) + .to include(match I18n.t("validations.lettings.date.startdate.ten_years_after_mrc_date")) end it "must be within 10 years of the tenancy start date" do @@ -93,7 +93,7 @@ RSpec.describe Validations::DateValidations do record.mrcdate = Time.zone.local(2022, 1, 1) date_validator.validate_property_major_repairs(record) expect(record.errors["mrcdate"]) - .to include(match I18n.t("validations.property.mrcdate.not_first_let")) + .to include(match I18n.t("validations.lettings.date.mrcdate.not_first_let")) end it "validates that no major repair date is provided for a conversion" do @@ -101,7 +101,7 @@ RSpec.describe Validations::DateValidations do record.mrcdate = Time.zone.local(2022, 1, 1) date_validator.validate_property_major_repairs(record) expect(record.errors["mrcdate"]) - .to include(match I18n.t("validations.property.mrcdate.not_first_let")) + .to include(match I18n.t("validations.lettings.date.mrcdate.not_first_let")) end it "validates that no major repair date is provided for a leased property" do @@ -109,7 +109,7 @@ RSpec.describe Validations::DateValidations do record.mrcdate = Time.zone.local(2022, 1, 1) date_validator.validate_property_major_repairs(record) expect(record.errors["mrcdate"]) - .to include(match I18n.t("validations.property.mrcdate.not_first_let")) + .to include(match I18n.t("validations.lettings.date.mrcdate.not_first_let")) end end @@ -129,7 +129,7 @@ RSpec.describe Validations::DateValidations do record.voiddate = Time.zone.local(2022, 2, 1) date_validator.validate_property_void_date(record) expect(record.errors["voiddate"]) - .to include(match I18n.t("validations.property.void_date.before_tenancy_start")) + .to include(match I18n.t("validations.lettings.date.void_date.before_tenancy_start")) end it "must be before the tenancy start date" do @@ -145,9 +145,9 @@ RSpec.describe Validations::DateValidations do date_validator.validate_property_void_date(record) date_validator.validate_startdate(record) expect(record.errors["voiddate"]) - .to include(match I18n.t("validations.property.void_date.ten_years_before_tenancy_start")) + .to include(match I18n.t("validations.lettings.date.void_date.ten_years_before_tenancy_start")) expect(record.errors["startdate"]) - .to include(match I18n.t("validations.setup.startdate.ten_years_after_void_date")) + .to include(match I18n.t("validations.lettings.date.startdate.ten_years_after_void_date")) end it "must be within 10 years of the tenancy start date" do @@ -164,9 +164,9 @@ RSpec.describe Validations::DateValidations do record.voiddate = Time.zone.local(2022, 2, 1) date_validator.validate_property_void_date(record) expect(record.errors["voiddate"]) - .to include(match I18n.t("validations.property.void_date.after_mrcdate")) + .to include(match I18n.t("validations.lettings.date.void_date.after_mrcdate")) expect(record.errors["mrcdate"]) - .to include(match I18n.t("validations.property.mrcdate.before_void_date")) + .to include(match I18n.t("validations.lettings.date.mrcdate.before_void_date")) end it "must be before major repairs date" do From 47928f384295e629dcb1d8b67074bb97b2d84d8f Mon Sep 17 00:00:00 2001 From: Manny Dinssa <44172848+Dinssa@users.noreply.github.com> Date: Thu, 31 Oct 2024 09:09:37 +0000 Subject: [PATCH 26/30] CLDC-3680: Copy changes lettings property information questions (#2726) --- app/models/form/lettings/pages/address.rb | 2 +- .../form/lettings/pages/address_fallback.rb | 2 +- .../form/lettings/pages/address_matcher.rb | 2 +- .../lettings/pages/property_major_repairs.rb | 1 + app/models/form/lettings/pages/uprn.rb | 1 + .../form/lettings/pages/uprn_selection.rb | 1 - app/models/form/lettings/pages/void_date.rb | 1 - .../form/lettings/questions/address_line1.rb | 3 +- .../address_line1_for_address_matcher.rb | 3 +- .../form/lettings/questions/address_line2.rb | 2 +- app/models/form/lettings/questions/beds.rb | 6 - .../form/lettings/questions/builtype.rb | 3 - app/models/form/lettings/questions/county.rb | 3 +- ...rst_time_property_let_as_social_housing.rb | 3 - app/models/form/lettings/questions/la.rb | 2 - .../form/lettings/questions/majorrepairs.rb | 4 +- app/models/form/lettings/questions/mrcdate.rb | 3 +- app/models/form/lettings/questions/offered.rb | 2 - .../questions/postcode_for_address_matcher.rb | 2 +- .../questions/postcode_for_full_address.rb | 3 +- .../lettings/questions/previous_let_type.rb | 3 - app/models/form/lettings/questions/rsnvac.rb | 3 - .../lettings/questions/rsnvac_first_let.rb | 3 - .../form/lettings/questions/town_or_city.rb | 3 +- .../form/lettings/questions/unittype_gn.rb | 3 - app/models/form/lettings/questions/uprn.rb | 3 +- .../form/lettings/questions/uprn_known.rb | 6 +- .../form/lettings/questions/uprn_selection.rb | 2 - .../form/lettings/questions/voiddate.rb | 2 - .../form/lettings/questions/wheelchair.rb | 3 - .../subsections/property_information.rb | 2 +- config/locales/en.yml | 3 - .../2023/lettings/property_information.en.yml | 104 ++++++++++++++ .../forms/2023/sales/soft_validations.en.yml | 7 + .../2024/lettings/property_information.en.yml | 127 ++++++++++++++++++ .../duplicate_logs_controller_spec.rb | 7 - 36 files changed, 255 insertions(+), 75 deletions(-) create mode 100644 config/locales/forms/2023/lettings/property_information.en.yml create mode 100644 config/locales/forms/2024/lettings/property_information.en.yml diff --git a/app/models/form/lettings/pages/address.rb b/app/models/form/lettings/pages/address.rb index 9fe18d3ef..eadda7f46 100644 --- a/app/models/form/lettings/pages/address.rb +++ b/app/models/form/lettings/pages/address.rb @@ -2,7 +2,7 @@ class Form::Lettings::Pages::Address < ::Form::Page def initialize(id, hsh, subsection) super @id = "address" - @header = "Q#{QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]} - What is the property's address?" + @copy_key = "lettings.property_information.address" @depends_on = [ { "is_supported_housing?" => false, "uprn_known" => nil }, { "is_supported_housing?" => false, "uprn_known" => 0 }, diff --git a/app/models/form/lettings/pages/address_fallback.rb b/app/models/form/lettings/pages/address_fallback.rb index 67f8ef5b1..2d5249671 100644 --- a/app/models/form/lettings/pages/address_fallback.rb +++ b/app/models/form/lettings/pages/address_fallback.rb @@ -2,7 +2,7 @@ class Form::Lettings::Pages::AddressFallback < ::Form::Page def initialize(id, hsh, subsection) super @id = "address" - @header = "Q12 - What is the property's address?" + @copy_key = "lettings.property_information.address" @depends_on = [ { "is_supported_housing?" => false, "uprn_known" => nil, "uprn_selection" => "uprn_not_listed" }, { "is_supported_housing?" => false, "uprn_known" => 0, "uprn_selection" => "uprn_not_listed" }, diff --git a/app/models/form/lettings/pages/address_matcher.rb b/app/models/form/lettings/pages/address_matcher.rb index 859e31077..b1fc885be 100644 --- a/app/models/form/lettings/pages/address_matcher.rb +++ b/app/models/form/lettings/pages/address_matcher.rb @@ -2,7 +2,7 @@ class Form::Lettings::Pages::AddressMatcher < ::Form::Page def initialize(id, hsh, subsection) super @id = "address_matcher" - @header = "Find an address" + @copy_key = "lettings.property_information.address_matcher" @depends_on = [ { "is_supported_housing?" => false, "uprn_known" => nil }, { "is_supported_housing?" => false, "uprn_known" => 0 }, diff --git a/app/models/form/lettings/pages/property_major_repairs.rb b/app/models/form/lettings/pages/property_major_repairs.rb index 985b5dce1..92bbadc0b 100644 --- a/app/models/form/lettings/pages/property_major_repairs.rb +++ b/app/models/form/lettings/pages/property_major_repairs.rb @@ -2,6 +2,7 @@ class Form::Lettings::Pages::PropertyMajorRepairs < ::Form::Page def initialize(id, hsh, subsection) super @id = "property_major_repairs" + @copy_key = "lettings.property_information.property_major_repairs" @depends_on = [{ "is_renewal?" => false, "vacancy_reason_not_renewal_or_first_let?" => true }] end diff --git a/app/models/form/lettings/pages/uprn.rb b/app/models/form/lettings/pages/uprn.rb index d3c744b8f..474928eb3 100644 --- a/app/models/form/lettings/pages/uprn.rb +++ b/app/models/form/lettings/pages/uprn.rb @@ -2,6 +2,7 @@ class Form::Lettings::Pages::Uprn < ::Form::Page def initialize(id, hsh, subsection) super @id = "uprn" + @copy_key = "lettings.property_information.uprn" @depends_on = [{ "is_supported_housing?" => false }] end diff --git a/app/models/form/lettings/pages/uprn_selection.rb b/app/models/form/lettings/pages/uprn_selection.rb index 4c7ca4ae1..96bfe68e8 100644 --- a/app/models/form/lettings/pages/uprn_selection.rb +++ b/app/models/form/lettings/pages/uprn_selection.rb @@ -2,7 +2,6 @@ class Form::Lettings::Pages::UprnSelection < ::Form::Page def initialize(id, hsh, subsection) super @id = "uprn_selection" - @header = "We found some addresses that might be this property" @depends_on = [ { "is_supported_housing?" => false, "uprn_known" => nil, "address_options_present?" => true }, { "is_supported_housing?" => false, "uprn_known" => 0, "address_options_present?" => true }, diff --git a/app/models/form/lettings/pages/void_date.rb b/app/models/form/lettings/pages/void_date.rb index 2187ebe57..5ba80d41e 100644 --- a/app/models/form/lettings/pages/void_date.rb +++ b/app/models/form/lettings/pages/void_date.rb @@ -2,7 +2,6 @@ class Form::Lettings::Pages::VoidDate < ::Form::Page def initialize(id, hsh, subsection) super @id = "void_date" - @header = "Void date" @depends_on = [{ "is_renewal?" => false }] end diff --git a/app/models/form/lettings/questions/address_line1.rb b/app/models/form/lettings/questions/address_line1.rb index f90da8b26..7da9720eb 100644 --- a/app/models/form/lettings/questions/address_line1.rb +++ b/app/models/form/lettings/questions/address_line1.rb @@ -2,11 +2,10 @@ class Form::Lettings::Questions::AddressLine1 < ::Form::Question def initialize(id, hsh, page) super @id = "address_line1" - @header = "Address line 1" + @copy_key = "lettings.property_information.address.address_line1" @error_label = "Address line 1" @type = "text" @plain_label = true - @check_answer_label = "Address lines 1 and 2" @disable_clearing_if_not_routed_or_dynamic_answer_options = true @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] @hide_question_number_on_page = true diff --git a/app/models/form/lettings/questions/address_line1_for_address_matcher.rb b/app/models/form/lettings/questions/address_line1_for_address_matcher.rb index b2247a8f0..0e8f59da3 100644 --- a/app/models/form/lettings/questions/address_line1_for_address_matcher.rb +++ b/app/models/form/lettings/questions/address_line1_for_address_matcher.rb @@ -2,11 +2,10 @@ class Form::Lettings::Questions::AddressLine1ForAddressMatcher < ::Form::Questio def initialize(id, hsh, page) super @id = "address_line1_input" - @header = "Address line 1" + @copy_key = "lettings.property_information.address_matcher.address_line1_input" @error_label = "Address line 1" @type = "text" @plain_label = true - @check_answer_label = "Find address" @disable_clearing_if_not_routed_or_dynamic_answer_options = true @hide_question_number_on_page = true end diff --git a/app/models/form/lettings/questions/address_line2.rb b/app/models/form/lettings/questions/address_line2.rb index 3b2c36dbc..0d4d2a705 100644 --- a/app/models/form/lettings/questions/address_line2.rb +++ b/app/models/form/lettings/questions/address_line2.rb @@ -2,7 +2,7 @@ class Form::Lettings::Questions::AddressLine2 < ::Form::Question def initialize(id, hsh, page) super @id = "address_line2" - @header = "Address line 2 (optional)" + @copy_key = "lettings.property_information.address.address_line2" @type = "text" @plain_label = true @disable_clearing_if_not_routed_or_dynamic_answer_options = true diff --git a/app/models/form/lettings/questions/beds.rb b/app/models/form/lettings/questions/beds.rb index 8c0399a61..4661f5367 100644 --- a/app/models/form/lettings/questions/beds.rb +++ b/app/models/form/lettings/questions/beds.rb @@ -2,8 +2,6 @@ class Form::Lettings::Questions::Beds < ::Form::Question def initialize(id, hsh, page) super @id = "beds" - @check_answer_label = "Number of bedrooms" - @header = "How many bedrooms does the property have?" @type = "numeric" @width = 2 @check_answers_card_number = 0 @@ -17,9 +15,5 @@ class Form::Lettings::Questions::Beds < ::Form::Question log.is_bedsit? end - def hint_text - form.start_year_after_2024? ? "If shared accommodation, enter the number of bedrooms occupied by this household." : "If shared accommodation, enter the number of bedrooms occupied by this household. A bedsit has 1 bedroom." - end - QUESTION_NUMBER_FROM_YEAR = { 2023 => 22 }.freeze end diff --git a/app/models/form/lettings/questions/builtype.rb b/app/models/form/lettings/questions/builtype.rb index a95d88b13..7df3c46dd 100644 --- a/app/models/form/lettings/questions/builtype.rb +++ b/app/models/form/lettings/questions/builtype.rb @@ -2,11 +2,8 @@ class Form::Lettings::Questions::Builtype < ::Form::Question def initialize(id, hsh, page) super @id = "builtype" - @check_answer_label = "Type of building" - @header = "What type of building is the property?" @type = "radio" @check_answers_card_number = 0 - @hint_text = "" @answer_options = ANSWER_OPTIONS @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end diff --git a/app/models/form/lettings/questions/county.rb b/app/models/form/lettings/questions/county.rb index f3c780257..27e17645e 100644 --- a/app/models/form/lettings/questions/county.rb +++ b/app/models/form/lettings/questions/county.rb @@ -2,10 +2,9 @@ class Form::Lettings::Questions::County < ::Form::Question def initialize(id, hsh, page) super @id = "county" - @header = "County (optional)" + @copy_key = "lettings.property_information.address.county" @type = "text" @plain_label = true - @check_answer_label = "County" @disable_clearing_if_not_routed_or_dynamic_answer_options = true @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] @hide_question_number_on_page = true diff --git a/app/models/form/lettings/questions/first_time_property_let_as_social_housing.rb b/app/models/form/lettings/questions/first_time_property_let_as_social_housing.rb index 6e36c9911..9d54cfcb3 100644 --- a/app/models/form/lettings/questions/first_time_property_let_as_social_housing.rb +++ b/app/models/form/lettings/questions/first_time_property_let_as_social_housing.rb @@ -2,11 +2,8 @@ class Form::Lettings::Questions::FirstTimePropertyLetAsSocialHousing < ::Form::Q def initialize(id, hsh, page) super @id = "first_time_property_let_as_social_housing" - @check_answer_label = "First time being let as social-housing?" - @header = "Is this the first time the property has been let as social housing?" @type = "radio" @check_answers_card_number = 0 - @hint_text = "" @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end diff --git a/app/models/form/lettings/questions/la.rb b/app/models/form/lettings/questions/la.rb index 6038bc2ad..5e1c8ae2b 100644 --- a/app/models/form/lettings/questions/la.rb +++ b/app/models/form/lettings/questions/la.rb @@ -2,8 +2,6 @@ class Form::Lettings::Questions::La < ::Form::Question def initialize(id, hsh, page) super @id = "la" - @check_answer_label = "Local Authority" - @header = "What is the property’s local authority?" @type = "select" @check_answers_card_number = nil @hint_text = "" diff --git a/app/models/form/lettings/questions/majorrepairs.rb b/app/models/form/lettings/questions/majorrepairs.rb index d2d94224e..ef33c1e01 100644 --- a/app/models/form/lettings/questions/majorrepairs.rb +++ b/app/models/form/lettings/questions/majorrepairs.rb @@ -2,11 +2,9 @@ class Form::Lettings::Questions::Majorrepairs < ::Form::Question def initialize(id, hsh, page) super @id = "majorrepairs" - @check_answer_label = "Major repairs carried out during void period" - @header = "Were any major repairs carried out during the void period?" + @copy_key = "lettings.property_information.property_major_repairs.majorrepairs" @type = "radio" @check_answers_card_number = 0 - @hint_text = "Major repairs are works that could not be reasonably carried out with a tenant living at the property. For example, structural repairs." @answer_options = ANSWER_OPTIONS @conditional_for = { "mrcdate" => [1] } @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] diff --git a/app/models/form/lettings/questions/mrcdate.rb b/app/models/form/lettings/questions/mrcdate.rb index 8bbd8223b..33c8f2c5f 100644 --- a/app/models/form/lettings/questions/mrcdate.rb +++ b/app/models/form/lettings/questions/mrcdate.rb @@ -2,8 +2,7 @@ class Form::Lettings::Questions::Mrcdate < ::Form::Question def initialize(id, hsh, page) super @id = "mrcdate" - @check_answer_label = "Completion date of repairs" - @header = "When were the repairs completed?" + @copy_key = "lettings.property_information.property_major_repairs.mrcdate" @type = "date" @check_answers_card_number = 0 @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] diff --git a/app/models/form/lettings/questions/offered.rb b/app/models/form/lettings/questions/offered.rb index 6d98f405c..701a6f737 100644 --- a/app/models/form/lettings/questions/offered.rb +++ b/app/models/form/lettings/questions/offered.rb @@ -2,8 +2,6 @@ class Form::Lettings::Questions::Offered < ::Form::Question def initialize(id, hsh, page) super @id = "offered" - @check_answer_label = I18n.t("check_answer_labels.offered") - @header = I18n.t("questions.offered") @type = "numeric" @width = 2 @check_answers_card_number = 0 diff --git a/app/models/form/lettings/questions/postcode_for_address_matcher.rb b/app/models/form/lettings/questions/postcode_for_address_matcher.rb index 2cac3ce92..9a7751904 100644 --- a/app/models/form/lettings/questions/postcode_for_address_matcher.rb +++ b/app/models/form/lettings/questions/postcode_for_address_matcher.rb @@ -2,7 +2,7 @@ class Form::Lettings::Questions::PostcodeForAddressMatcher < ::Form::Question def initialize(id, hsh, page) super @id = "postcode_full_input" - @header = "Postcode" + @copy_key = "lettings.property_information.address_matcher.postcode_full_input" @type = "text" @width = 5 @plain_label = true diff --git a/app/models/form/lettings/questions/postcode_for_full_address.rb b/app/models/form/lettings/questions/postcode_for_full_address.rb index ef93b003d..d6ee9859f 100644 --- a/app/models/form/lettings/questions/postcode_for_full_address.rb +++ b/app/models/form/lettings/questions/postcode_for_full_address.rb @@ -2,7 +2,7 @@ class Form::Lettings::Questions::PostcodeForFullAddress < ::Form::Question def initialize(id, hsh, page) super @id = "postcode_full" - @header = "Postcode" + @copy_key = "lettings.property_information.address.postcode_full" @type = "text" @width = 5 @inferred_check_answers_value = [{ @@ -17,7 +17,6 @@ class Form::Lettings::Questions::PostcodeForFullAddress < ::Form::Question }, } @plain_label = true - @check_answer_label = "Postcode" @disable_clearing_if_not_routed_or_dynamic_answer_options = true @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] @hide_question_number_on_page = true diff --git a/app/models/form/lettings/questions/previous_let_type.rb b/app/models/form/lettings/questions/previous_let_type.rb index d9c018820..577571571 100644 --- a/app/models/form/lettings/questions/previous_let_type.rb +++ b/app/models/form/lettings/questions/previous_let_type.rb @@ -2,11 +2,8 @@ class Form::Lettings::Questions::PreviousLetType < ::Form::Question def initialize(id, hsh, page) super @id = "unitletas" - @check_answer_label = "Most recent let type" - @header = "What type was the property most recently let as?" @type = "radio" @check_answers_card_number = 0 - @hint_text = form.start_year_after_2024? ? "This is the rent type of the previous tenancy in this property." : "" @answer_options = form.start_year_after_2024? ? ANSWER_OPTIONS_AFTER_2024 : ANSWER_OPTIONS @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end diff --git a/app/models/form/lettings/questions/rsnvac.rb b/app/models/form/lettings/questions/rsnvac.rb index 303f2ea48..935980712 100644 --- a/app/models/form/lettings/questions/rsnvac.rb +++ b/app/models/form/lettings/questions/rsnvac.rb @@ -2,11 +2,8 @@ class Form::Lettings::Questions::Rsnvac < ::Form::Question def initialize(id, hsh, page) super @id = "rsnvac" - @check_answer_label = "Vacancy reason" - @header = "What is the reason for the property being vacant?" @type = "radio" @check_answers_card_number = 0 - @hint_text = "" @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end diff --git a/app/models/form/lettings/questions/rsnvac_first_let.rb b/app/models/form/lettings/questions/rsnvac_first_let.rb index f03c64995..4b87d059f 100644 --- a/app/models/form/lettings/questions/rsnvac_first_let.rb +++ b/app/models/form/lettings/questions/rsnvac_first_let.rb @@ -2,11 +2,8 @@ class Form::Lettings::Questions::RsnvacFirstLet < ::Form::Question def initialize(id, hsh, page) super @id = "rsnvac" - @check_answer_label = "Vacancy reason" - @header = "What is the reason for the property being vacant?" @type = "radio" @check_answers_card_number = 0 - @hint_text = "" @answer_options = ANSWER_OPTIONS @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end diff --git a/app/models/form/lettings/questions/town_or_city.rb b/app/models/form/lettings/questions/town_or_city.rb index 745810893..14ed19dfc 100644 --- a/app/models/form/lettings/questions/town_or_city.rb +++ b/app/models/form/lettings/questions/town_or_city.rb @@ -2,10 +2,9 @@ class Form::Lettings::Questions::TownOrCity < ::Form::Question def initialize(id, hsh, page) super @id = "town_or_city" - @header = "Town or city" + @copy_key = "lettings.property_information.address.town_or_city" @type = "text" @plain_label = true - @check_answer_label = "Town or city" @disable_clearing_if_not_routed_or_dynamic_answer_options = true @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] @hide_question_number_on_page = true diff --git a/app/models/form/lettings/questions/unittype_gn.rb b/app/models/form/lettings/questions/unittype_gn.rb index 501f25ee7..95a199b98 100644 --- a/app/models/form/lettings/questions/unittype_gn.rb +++ b/app/models/form/lettings/questions/unittype_gn.rb @@ -2,11 +2,8 @@ class Form::Lettings::Questions::UnittypeGn < ::Form::Question def initialize(id, hsh, page) super @id = "unittype_gn" - @check_answer_label = "Type of unit" - @header = "What type of unit is the property?" @type = "radio" @check_answers_card_number = 0 - @hint_text = "" @answer_options = ANSWER_OPTIONS @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end diff --git a/app/models/form/lettings/questions/uprn.rb b/app/models/form/lettings/questions/uprn.rb index 7c860e01b..53df6bcf2 100644 --- a/app/models/form/lettings/questions/uprn.rb +++ b/app/models/form/lettings/questions/uprn.rb @@ -2,8 +2,7 @@ class Form::Lettings::Questions::Uprn < ::Form::Question def initialize(id, hsh, page) super @id = "uprn" - @check_answer_label = "UPRN" - @header = "What is the property's UPRN?" + @copy_key = "lettings.property_information.uprn.uprn" @type = "text" @width = 10 @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] diff --git a/app/models/form/lettings/questions/uprn_known.rb b/app/models/form/lettings/questions/uprn_known.rb index a9840667c..29d415134 100644 --- a/app/models/form/lettings/questions/uprn_known.rb +++ b/app/models/form/lettings/questions/uprn_known.rb @@ -2,13 +2,9 @@ class Form::Lettings::Questions::UprnKnown < ::Form::Question def initialize(id, hsh, page) super @id = "uprn_known" - @check_answer_label = "UPRN known?" - @header = "Do you know the property's UPRN?" + @copy_key = "lettings.property_information.uprn.uprn_known" @type = "radio" @answer_options = ANSWER_OPTIONS - @hint_text = "The Unique Property Reference Number (UPRN) is a unique number system created by Ordnance Survey and used by housing providers and various industries across the UK. An example UPRN is 10010457355.

    - The UPRN may not be the same as the property reference assigned by your organisation.

    - If you don’t know the UPRN you can enter the address of the property instead on the next screen." @conditional_for = { "uprn" => [1] } @inferred_check_answers_value = [ { diff --git a/app/models/form/lettings/questions/uprn_selection.rb b/app/models/form/lettings/questions/uprn_selection.rb index f6c71f498..90fa319b7 100644 --- a/app/models/form/lettings/questions/uprn_selection.rb +++ b/app/models/form/lettings/questions/uprn_selection.rb @@ -2,9 +2,7 @@ class Form::Lettings::Questions::UprnSelection < ::Form::Question def initialize(id, hsh, page) super @id = "uprn_selection" - @header = "Select the correct address" @type = "radio" - @check_answer_label = "Select the correct address" @disable_clearing_if_not_routed_or_dynamic_answer_options = true end diff --git a/app/models/form/lettings/questions/voiddate.rb b/app/models/form/lettings/questions/voiddate.rb index 9d47fe1ea..1f5d2317a 100644 --- a/app/models/form/lettings/questions/voiddate.rb +++ b/app/models/form/lettings/questions/voiddate.rb @@ -2,8 +2,6 @@ class Form::Lettings::Questions::Voiddate < ::Form::Question def initialize(id, hsh, page) super @id = "voiddate" - @check_answer_label = "Void date" - @header = "What is the void date?" @type = "date" @check_answers_card_number = 0 @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] diff --git a/app/models/form/lettings/questions/wheelchair.rb b/app/models/form/lettings/questions/wheelchair.rb index 7d8dcfa25..f766a0e44 100644 --- a/app/models/form/lettings/questions/wheelchair.rb +++ b/app/models/form/lettings/questions/wheelchair.rb @@ -2,11 +2,8 @@ class Form::Lettings::Questions::Wheelchair < ::Form::Question def initialize(id, hsh, page) super @id = "wchair" - @check_answer_label = "Property built or adapted to wheelchair-user standards" - @header = "Is the property built or adapted to wheelchair-user standards?" @type = "radio" @check_answers_card_number = 0 - @hint_text = form.start_year_after_2024? ? "This is whether someone who uses a wheelchair is able to make full use of all of the property’s rooms and facilities, including use of both inside and outside space, and entering and exiting the property." : "" @answer_options = ANSWER_OPTIONS @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end diff --git a/app/models/form/lettings/subsections/property_information.rb b/app/models/form/lettings/subsections/property_information.rb index 7b9aead2d..fa2ff0efa 100644 --- a/app/models/form/lettings/subsections/property_information.rb +++ b/app/models/form/lettings/subsections/property_information.rb @@ -34,7 +34,7 @@ class Form::Lettings::Subsections::PropertyInformation < ::Form::Subsection Form::Lettings::Pages::Uprn.new(nil, nil, self), Form::Lettings::Pages::UprnConfirmation.new(nil, nil, self), Form::Lettings::Pages::AddressMatcher.new(nil, nil, self), - Form::Lettings::Pages::NoAddressFound.new(nil, nil, self), + Form::Lettings::Pages::NoAddressFound.new(nil, nil, self), # soft validation Form::Lettings::Pages::UprnSelection.new(nil, nil, self), Form::Lettings::Pages::AddressFallback.new(nil, nil, self), ] diff --git a/config/locales/en.yml b/config/locales/en.yml index 5baa98338..c78ba2463 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -741,7 +741,6 @@ Make sure these answers are correct." stairowned: one: "What percentage of the property does the buyer now own in total?" other: "What percentage of the property do the buyers now own in total?" - offered: "How many times was the property offered between becoming vacant and this letting?" hints: location: @@ -754,7 +753,6 @@ Make sure these answers are correct." toggle_active: "If the date is before %{date}, select ‘From the start of the open collection period’ because the previous period has now closed." bulk_upload: needstype: "General needs housing includes both self-contained and shared housing without support or specific adaptations. Supported housing can include direct access hostels, group homes, residential care and nursing homes." - offered: "Do not include the offer that led to this letting. This is after the last tenancy ended. If the property is being offered for let for the first time, enter 0." check_answer_labels: soctenant: @@ -763,7 +761,6 @@ Make sure these answers are correct." stairowned: one: "Percentage the buyer now owns in total." other: "Percentage the buyers now own in total." - offered: "Times previously offered since becoming available." warnings: organisation: diff --git a/config/locales/forms/2023/lettings/property_information.en.yml b/config/locales/forms/2023/lettings/property_information.en.yml new file mode 100644 index 000000000..f1b652935 --- /dev/null +++ b/config/locales/forms/2023/lettings/property_information.en.yml @@ -0,0 +1,104 @@ +en: + forms: + 2023: + lettings: + property_information: + uprn: + page_header: "" + uprn_known: + check_answer_label: "UPRN known?" + hint_text: "The Unique Property Reference Number (UPRN) is a unique number system created by Ordnance Survey and used by housing providers and various industries across the UK. An example UPRN is 10010457355.

    The UPRN may not be the same as the property reference assigned by your organisation.

    If you don’t know the UPRN you can enter the address of the property instead on the next screen." + question_text: "Do you know the property's UPRN?" + uprn: + check_answer_label: "UPRN" + hint_text: "" + question_text: "What is the property's UPRN?" + + uprn_confirmed: + page_header: "We found an address that might be this property" + check_answer_label: "Is this the right address?" + hint_text: "" + question_text: "Is this the property address?" + + address: + page_header: "Q12 - What is the property's address?" + address_line1: + check_answer_label: "Address lines 1 and 2" + hint_text: "" + question_text: "Address line 1" + address_line2: + check_answer_label: "" + hint_text: "" + question_text: "Address line 2 (optional)" + town_or_city: + check_answer_label: "Town or city" + hint_text: "" + question_text: "Town or city" + county: + check_answer_label: "County" + hint_text: "" + question_text: "County (optional)" + postcode_full: + check_answer_label: "Postcode" + hint_text: "" + question_text: "Postcode" + + la: + page_header: "" + check_answer_label: "Local authority" + hint_text: "" + question_text: "What is the property’s local authority?" + + first_time_property_let_as_social_housing: + page_header: "" + check_answer_label: "First time being let as social-housing?" + hint_text: "" + question_text: "Is this the first time the property has been let as social housing?" + + unitletas: + page_header: "" + check_answer_label: "Most recent let type" + hint_text: "" + question_text: "What type was the property most recently let as?" + + rsnvac: + page_header: "" + check_answer_label: "Vacancy reason" + hint_text: "" + question_text: "What is the reason for the property being vacant?" + + offered: + page_header: "" + check_answer_label: "Times previously offered since becoming available." + hint_text: "Do not include the offer that led to this letting. This is after the last tenancy ended. If the property is being offered for let for the first time, enter 0." + question_text: "How many times was the property offered between becoming vacant and this letting?" + + unittype_gn: + page_header: "" + check_answer_label: "Type of unit" + hint_text: "" + question_text: "What type of unit is the property?" + + builtype: + page_header: "" + check_answer_label: "Type of building" + hint_text: "" + question_text: "What type of building is the property?" + + wchair: + page_header: "" + check_answer_label: "Property built or adapted to wheelchair-user standards" + hint_text: "" + question_text: "Is the property built or adapted to wheelchair-user standards?" + + beds: + page_header: "" + check_answer_label: "Number of bedrooms" + hint_text: "If shared accommodation, enter the number of bedrooms occupied by this household. A bedsit has 1 bedroom." + question_text: "How many bedrooms does the property have?" + + voiddate: + page_header: "Void date" + check_answer_label: "Void date" + hint_text: "" + question_text: "What is the void date?" diff --git a/config/locales/forms/2023/sales/soft_validations.en.yml b/config/locales/forms/2023/sales/soft_validations.en.yml index 11a7406e4..1c3cd4955 100644 --- a/config/locales/forms/2023/sales/soft_validations.en.yml +++ b/config/locales/forms/2023/sales/soft_validations.en.yml @@ -18,6 +18,7 @@ en: question_text: "Are you sure this person is retired?" title_text: "You told us this person is aged %{age} years and retired." informative_text: "The minimum expected retirement age in England is 66." + old_persons_shared_ownership_value_check: page_header: "" check_answer_label: "Shared ownership confirmation" @@ -27,6 +28,7 @@ en: joint_purchase: "You told us the buyers are using the Older Persons Shared Ownership scheme." not_joint_purchase: "You told us the buyer is using the Older Persons Shared Ownership scheme." informative_text: "At least one buyer must be aged 65 years and over to use this scheme." + income1_value_check: check_answer_label: "Buyer 1 income confirmation" hint_text: "" @@ -113,12 +115,14 @@ en: not_joint_purchase: title_text: "You told us the buyer’s deposit was %{deposit} and their savings were %{savings}." informative_text: "The deposit amount is higher than we would expect for the amount of savings they have." + wheel_value_check: page_header: "" check_answer_label: "Does anyone in the household use a wheelchair?" hint_text: "" question_text: "You told us that someone in the household uses a wheelchair." title_text: "You told us that someone in the household uses a wheelchair." + buyer_livein_value_check: buyer1: page_header: "" @@ -134,6 +138,7 @@ en: question_text: "Are you sure this is correct?" title_text: "You told us that buyer 2 will not live in the property." informative_text: "For %{ownership_scheme} types, the buyer usually lives in the property." + student_not_child_value_check: page_header: "" check_answer_label: "Student not a child confirmation" @@ -141,6 +146,7 @@ en: question_text: "Are you sure this person is not a child?" title_text: "You told us this person is a student aged between 16 and 19." informative_text: "Are you sure this person is not a child?" + partner_under_16_value_check: page_header: "" check_answer_label: "Partner under 16 confirmation" @@ -148,6 +154,7 @@ en: question_text: "Are you sure this is correct?" title_text: "You told us this person is aged %{age} years and has 'Partner' relationship to buyer 1." informative_text: "Are you sure this is correct?" + multiple_partners_value_check: page_header: "" check_answer_label: "Multiple partners confirmation" diff --git a/config/locales/forms/2024/lettings/property_information.en.yml b/config/locales/forms/2024/lettings/property_information.en.yml new file mode 100644 index 000000000..012ff0e0d --- /dev/null +++ b/config/locales/forms/2024/lettings/property_information.en.yml @@ -0,0 +1,127 @@ +en: + forms: + 2024: + lettings: + property_information: + first_time_property_let_as_social_housing: + page_header: "" + check_answer_label: "First time being let as social-housing?" + hint_text: "" + question_text: "Is this the first time the property has been let as social housing?" + + uprn: + page_header: "" + uprn_known: + check_answer_label: "UPRN known?" + hint_text: "The Unique Property Reference Number (UPRN) is a unique number system created by Ordnance Survey and used by housing providers and various industries across the UK. An example UPRN is 10010457355.

    The UPRN may not be the same as the property reference assigned by your organisation.

    If you don’t know the UPRN you can enter the address of the property instead on the next screen." + question_text: "Do you know the property's UPRN?" + uprn: + check_answer_label: "UPRN" + hint_text: "" + question_text: "What is the property's UPRN?" + + uprn_confirmed: + page_header: "We found an address that might be this property" + check_answer_label: "Is this the right address?" + hint_text: "" + question_text: "Is this the property address?" + + address_matcher: + page_header: "Find an address" + address_line1_input: + check_answer_label: "Find address" + hint_text: "" + question_text: "Address line 1" + postcode_full_input: + check_answer_label: "" + hint_text: "" + question_text: "Postcode" + + uprn_selection: + page_header: "We found an address that might be this property" + check_answer_label: "Select the correct address" + hint_text: "" + question_text: "Select the correct address" + + address: + page_header: "Q12 - What is the property's address?" + address_line1: + check_answer_label: "Address lines 1 and 2" + hint_text: "" + question_text: "Address line 1" + address_line2: + check_answer_label: "" + hint_text: "" + question_text: "Address line 2 (optional)" + town_or_city: + check_answer_label: "Town or city" + hint_text: "" + question_text: "Town or city" + county: + check_answer_label: "County" + hint_text: "" + question_text: "County (optional)" + postcode_full: + check_answer_label: "Postcode" + hint_text: "" + question_text: "Postcode" + + la: + page_header: "" + check_answer_label: "Local authority" + hint_text: "" + question_text: "What is the property’s local authority?" + + + unitletas: + page_header: "" + check_answer_label: "Most recent let type" + hint_text: "This is the rent type of the previous tenancy in this property." + question_text: "What type was the property most recently let as?" + + rsnvac: + page_header: "" + check_answer_label: "Vacancy reason" + hint_text: "" + question_text: "What is the reason for the property being vacant?" + + unittype_gn: + page_header: "" + check_answer_label: "Type of unit" + hint_text: "" + question_text: "What type of unit is the property?" + + builtype: + page_header: "" + check_answer_label: "Type of building" + hint_text: "" + question_text: "What type of building is the property?" + + wchair: + page_header: "" + check_answer_label: "Property built or adapted to wheelchair-user standards" + hint_text: "This is whether someone who uses a wheelchair is able to make full use of all of the property’s rooms and facilities, including use of both inside and outside space, and entering and exiting the property." + question_text: "Is the property built or adapted to wheelchair-user standards?" + + beds: + page_header: "" + check_answer_label: "Number of bedrooms" + hint_text: "If shared accommodation, enter the number of bedrooms occupied by this household." + question_text: "How many bedrooms does the property have?" + + voiddate: + page_header: "Void date" + check_answer_label: "Void date" + hint_text: "" + question_text: "What is the void date?" + + property_major_repairs: + page_header: "" + majorrepairs: + check_answer_label: "Major repairs carried out during void period" + hint_text: "Major repairs are works that could not be reasonably carried out with a tenant living at the property. For example, structural repairs." + question_text: "Were any major repairs carried out during the void period?" + mrcdate: + check_answer_label: "Completion date of repairs" + hint_text: "" + question_text: "When were the repairs completed?" diff --git a/spec/requests/duplicate_logs_controller_spec.rb b/spec/requests/duplicate_logs_controller_spec.rb index c06d30baf..700964fcf 100644 --- a/spec/requests/duplicate_logs_controller_spec.rb +++ b/spec/requests/duplicate_logs_controller_spec.rb @@ -66,7 +66,6 @@ RSpec.describe DuplicateLogsController, type: :request do it "displays check your answers for each log with correct questions" do expect(page).to have_content("Q5 - Tenancy start date", count: 3) expect(page).to have_content("Q7 - Tenant code", count: 3) - expect(page).to have_content("Q12 - Postcode", count: 3) expect(page).to have_content("Q32 - Lead tenant’s age", count: 3) expect(page).to have_content("Q33 - Lead tenant’s gender identity", count: 3) expect(page).to have_content("Q37 - Lead tenant’s working situation", count: 3) @@ -84,7 +83,6 @@ RSpec.describe DuplicateLogsController, type: :request do expect(page).to have_content("Q5 - Tenancy start date", count: 3) expect(page).to have_content("Q7 - Tenant code", count: 3) - expect(page).to have_content("Q12 - Postcode", count: 1) expect(page).to have_content("Postcode (from UPRN)", count: 2) expect(page).to have_content("Q32 - Lead tenant’s age", count: 3) expect(page).to have_content("Q33 - Lead tenant’s gender identity", count: 3) @@ -114,7 +112,6 @@ RSpec.describe DuplicateLogsController, type: :request do it "displays check your answers for each log with correct questions" do expect(page).to have_content("Q5 - Tenancy start date", count: 1) expect(page).to have_content("Q7 - Tenant code", count: 1) - expect(page).to have_content("Q12 - Postcode", count: 1) expect(page).to have_content("Q32 - Lead tenant’s age", count: 1) expect(page).to have_content("Q33 - Lead tenant’s gender identity", count: 1) expect(page).to have_content("Q37 - Lead tenant’s working situation", count: 1) @@ -141,7 +138,6 @@ RSpec.describe DuplicateLogsController, type: :request do it "displays check your answers for each log with correct questions" do expect(page).to have_content("Q5 - Tenancy start date", count: 1) expect(page).to have_content("Q7 - Tenant code", count: 1) - expect(page).to have_content("Q12 - Postcode", count: 1) expect(page).to have_content("Q32 - Lead tenant’s age", count: 1) expect(page).to have_content("Q33 - Lead tenant’s gender identity", count: 1) expect(page).to have_content("Q37 - Lead tenant’s working situation", count: 1) @@ -295,7 +291,6 @@ RSpec.describe DuplicateLogsController, type: :request do it "displays check your answers for each log with correct questions" do expect(page).to have_content("Q5 - Tenancy start date", count: 3) expect(page).to have_content("Q7 - Tenant code", count: 3) - expect(page).to have_content("Q12 - Postcode", count: 3) expect(page).to have_content("Q32 - Lead tenant’s age", count: 3) expect(page).to have_content("Q33 - Lead tenant’s gender identity", count: 3) expect(page).to have_content("Q37 - Lead tenant’s working situation", count: 3) @@ -324,7 +319,6 @@ RSpec.describe DuplicateLogsController, type: :request do it "displays check your answers for each log with correct questions" do expect(page).to have_content("Q5 - Tenancy start date", count: 1) expect(page).to have_content("Q7 - Tenant code", count: 1) - expect(page).to have_content("Q12 - Postcode", count: 1) expect(page).to have_content("Q32 - Lead tenant’s age", count: 1) expect(page).to have_content("Q33 - Lead tenant’s gender identity", count: 1) expect(page).to have_content("Q37 - Lead tenant’s working situation", count: 1) @@ -351,7 +345,6 @@ RSpec.describe DuplicateLogsController, type: :request do it "displays check your answers for each log with correct questions" do expect(page).to have_content("Q5 - Tenancy start date", count: 1) expect(page).to have_content("Q7 - Tenant code", count: 1) - expect(page).to have_content("Q12 - Postcode", count: 1) expect(page).to have_content("Q32 - Lead tenant’s age", count: 1) expect(page).to have_content("Q33 - Lead tenant’s gender identity", count: 1) expect(page).to have_content("Q37 - Lead tenant’s working situation", count: 1) From 576d0900fa63326e57f03a140cfa56d7030db5d4 Mon Sep 17 00:00:00 2001 From: Manny Dinssa <44172848+Dinssa@users.noreply.github.com> Date: Thu, 31 Oct 2024 09:44:51 +0000 Subject: [PATCH 27/30] CLDC-3691: Extract copy - lettings setup validations (#2739) --- app/models/validations/setup_validations.rb | 80 +++++++++---------- config/locales/en.yml | 34 -------- .../locales/validations/lettings/setup.en.yml | 53 ++++++++++++ .../validations/setup_validations_spec.rb | 18 ++--- 4 files changed, 102 insertions(+), 83 deletions(-) create mode 100644 config/locales/validations/lettings/setup.en.yml diff --git a/app/models/validations/setup_validations.rb b/app/models/validations/setup_validations.rb index 913cc9c96..d8e5dbf93 100644 --- a/app/models/validations/setup_validations.rb +++ b/app/models/validations/setup_validations.rb @@ -16,42 +16,42 @@ module Validations::SetupValidations end if record.startdate > Time.zone.today + 14.days - record.errors.add :startdate, I18n.t("validations.setup.startdate.later_than_14_days_after") + record.errors.add :startdate, I18n.t("validations.lettings.setup.startdate.not_within.next_two_weeks") end end def validate_organisation(record) assigned_to, managing_organisation, owning_organisation = record.values_at("assigned_to", "managing_organisation", "owning_organisation") unless [assigned_to, managing_organisation, owning_organisation].any?(&:blank?) || ((assigned_to.organisation.absorbed_organisations + [assigned_to.organisation]) & [managing_organisation, owning_organisation]).present? - record.errors.add :assigned_to, I18n.t("validations.setup.assigned_to.invalid") - record.errors.add :owning_organisation_id, I18n.t("validations.setup.owning_organisation.invalid") - record.errors.add :managing_organisation_id, I18n.t("validations.setup.managing_organisation.invalid") + record.errors.add :assigned_to, I18n.t("validations.lettings.setup.assigned_to.invalid") + record.errors.add :owning_organisation_id, I18n.t("validations.lettings.setup.owning_organisation.invalid") + record.errors.add :managing_organisation_id, I18n.t("validations.lettings.setup.managing_organisation.invalid") end return unless record.startdate if owning_organisation.present? if owning_organisation&.merge_date.present? && owning_organisation.merge_date <= record.startdate - record.errors.add :owning_organisation_id, I18n.t("validations.setup.owning_organisation.inactive_merged_organisation", + record.errors.add :owning_organisation_id, I18n.t("validations.lettings.setup.owning_organisation.inactive.merged_organisation", owning_organisation: record.owning_organisation.name, - owning_organisation_merge_date: record.owning_organisation.merge_date.to_formatted_s(:govuk_date), - owning_absorbing_organisation: record.owning_organisation.absorbing_organisation.name) + merge_date: record.owning_organisation.merge_date.to_formatted_s(:govuk_date), + absorbing_organisation: record.owning_organisation.absorbing_organisation.name) elsif owning_organisation&.absorbed_organisations.present? && owning_organisation.available_from.present? && owning_organisation.available_from.to_date > record.startdate.to_date - record.errors.add :owning_organisation_id, I18n.t("validations.setup.owning_organisation.inactive_absorbing_organisation", + record.errors.add :owning_organisation_id, I18n.t("validations.lettings.setup.owning_organisation.inactive.absorbing_organisation", owning_organisation: record.owning_organisation.name, - owning_organisation_available_from: record.owning_organisation.available_from.to_formatted_s(:govuk_date)) + available_from: record.owning_organisation.available_from.to_formatted_s(:govuk_date)) end end if managing_organisation.present? if managing_organisation&.merge_date.present? && managing_organisation.merge_date <= record.startdate - record.errors.add :managing_organisation_id, I18n.t("validations.setup.managing_organisation.inactive_merged_organisation", + record.errors.add :managing_organisation_id, I18n.t("validations.lettings.setup.managing_organisation.inactive.merged_organisation", managing_organisation: record.managing_organisation.name, - managing_organisation_merge_date: record.managing_organisation.merge_date.to_formatted_s(:govuk_date), - managing_absorbing_organisation: record.managing_organisation.absorbing_organisation.name) + merge_date: record.managing_organisation.merge_date.to_formatted_s(:govuk_date), + absorbing_organisation: record.managing_organisation.absorbing_organisation.name) elsif managing_organisation&.absorbed_organisations.present? && managing_organisation.available_from.present? && managing_organisation.available_from.to_date > record.startdate.to_date - record.errors.add :managing_organisation_id, I18n.t("validations.setup.managing_organisation.inactive_absorbing_organisation", + record.errors.add :managing_organisation_id, I18n.t("validations.lettings.setup.managing_organisation.inactive.absorbing_organisation", managing_organisation: record.managing_organisation.name, - managing_organisation_available_from: record.managing_organisation.available_from.to_formatted_s(:govuk_date)) + available_from: record.managing_organisation.available_from.to_formatted_s(:govuk_date)) end end end @@ -68,7 +68,7 @@ module Validations::SetupValidations def validate_irproduct_other(record) if intermediate_product_rent_type?(record) && record.irproduct_other.blank? - record.errors.add :irproduct_other, I18n.t("validations.setup.intermediate_rent_product_name.blank") + record.errors.add :irproduct_other, I18n.t("validations.lettings.setup.intermediate_rent_product_name.blank") end end @@ -76,13 +76,13 @@ module Validations::SetupValidations return unless record.scheme unless record.scheme.locations.confirmed.any? - record.errors.add :scheme_id, :no_completed_locations, message: I18n.t("validations.scheme.no_completed_locations") + record.errors.add :scheme_id, :no_completed_locations, message: I18n.t("validations.lettings.setup.scheme.no_completed_locations") end end def validate_scheme(record) if record.scheme&.status == :incomplete - record.errors.add :scheme_id, :incomplete, message: I18n.t("validations.setup.scheme.incomplete") + record.errors.add :scheme_id, :incomplete, message: I18n.t("validations.lettings.setup.scheme.incomplete") end scheme_during_startdate_validation(record) @@ -93,8 +93,8 @@ module Validations::SetupValidations location_during_startdate_validation(record) if record.location&.status == :incomplete - record.errors.add :location_id, :incomplete, message: I18n.t("validations.setup.location.incomplete") - record.errors.add :scheme_id, :incomplete, message: I18n.t("validations.setup.location.incomplete") + record.errors.add :location_id, :incomplete, message: I18n.t("validations.lettings.setup.location.incomplete") + record.errors.add :scheme_id, :incomplete, message: I18n.t("validations.lettings.setup.location.incomplete") end end @@ -102,7 +102,7 @@ module Validations::SetupValidations return if record.skip_dpo_validation if record.managing_organisation_id_changed? && record.managing_organisation.present? && !record.managing_organisation.data_protection_confirmed? - record.errors.add :managing_organisation_id, I18n.t("validations.setup.managing_organisation.data_sharing_agreement_not_signed") + record.errors.add :managing_organisation_id, I18n.t("validations.lettings.setup.managing_organisation.data_sharing_agreement_not_signed") end end @@ -129,7 +129,7 @@ private if FormHandler.instance.lettings_in_crossover_period? I18n.t( - "validations.setup.startdate.previous_and_current_collection_year", + "validations.lettings.setup.startdate.must_be_within.previous_and_current_collection_year", previous_start_year_short: previous_collection_start_date.strftime("%Y"), previous_end_year_short: previous_collection_end_date.strftime("%Y"), previous_start_year_long: previous_collection_start_date.strftime("#{previous_collection_start_date.day.ordinalize} %B %Y"), @@ -138,7 +138,7 @@ private ) else I18n.t( - "validations.setup.startdate.current_collection_year", + "validations.lettings.setup.startdate.must_be_within.current_collection_year", current_start_year_short: current_collection_start_date.strftime("%Y"), current_end_year_short: current_collection_end_date.strftime("%Y"), current_start_year_long: current_collection_start_date.strftime("#{current_collection_start_date.day.ordinalize} %B %Y"), @@ -153,20 +153,20 @@ private def add_same_merge_organisation_error(record) if merged_owning_organisation_inactive?(record) - record.errors.add :startdate, I18n.t("validations.setup.startdate.invalid_merged_organisations_start_date.same_organisation", + record.errors.add :startdate, I18n.t("validations.lettings.setup.startdate.invalid_merged_organisations_start_date.same_organisation", owning_organisation: record.owning_organisation.name, - owning_organisation_merge_date: record.owning_organisation.merge_date.to_formatted_s(:govuk_date), - owning_absorbing_organisation: record.owning_organisation.absorbing_organisation.name) + merge_date: record.owning_organisation.merge_date.to_formatted_s(:govuk_date), + absorbing_organisation: record.owning_organisation.absorbing_organisation.name) elsif absorbing_owning_organisation_inactive?(record) - record.errors.add :startdate, I18n.t("validations.setup.startdate.invalid_absorbing_organisations_start_date.same_organisation", + record.errors.add :startdate, I18n.t("validations.lettings.setup.startdate.invalid_absorbing_organisations_start_date.same_organisation", owning_organisation: record.owning_organisation.name, - owning_organisation_available_from: record.owning_organisation.available_from.to_formatted_s(:govuk_date)) + available_from: record.owning_organisation.available_from.to_formatted_s(:govuk_date)) end end def add_same_merge_error(record) if merged_owning_organisation_inactive?(record) - record.errors.add :startdate, I18n.t("validations.setup.startdate.invalid_merged_organisations_start_date.same_merge", + record.errors.add :startdate, I18n.t("validations.lettings.setup.startdate.invalid_merged_organisations_start_date.same_merge", owning_organisation: record.owning_organisation.name, managing_organisation: record.managing_organisation.name, owning_organisation_merge_date: record.owning_organisation.merge_date.to_formatted_s(:govuk_date), @@ -176,7 +176,7 @@ private def add_merged_organisations_errors(record) if merged_owning_organisation_inactive?(record) && merged_managing_organisation_inactive?(record) - record.errors.add :startdate, I18n.t("validations.setup.startdate.invalid_merged_organisations_start_date.different_merge", + record.errors.add :startdate, I18n.t("validations.lettings.setup.startdate.invalid_merged_organisations_start_date.different_merge", owning_organisation: record.owning_organisation.name, owning_organisation_merge_date: record.owning_organisation.merge_date.to_formatted_s(:govuk_date), owning_absorbing_organisation: record.owning_organisation.absorbing_organisation.name, @@ -185,39 +185,39 @@ private managing_absorbing_organisation: record.managing_organisation.absorbing_organisation.name) else if merged_owning_organisation_inactive?(record) - record.errors.add :startdate, I18n.t("validations.setup.startdate.invalid_merged_organisations_start_date.owning_organisation", + record.errors.add :startdate, I18n.t("validations.lettings.setup.startdate.invalid_merged_organisations_start_date.owning_organisation", owning_organisation: record.owning_organisation.name, - owning_organisation_merge_date: record.owning_organisation.merge_date.to_formatted_s(:govuk_date), - owning_absorbing_organisation: record.owning_organisation.absorbing_organisation.name) + merge_date: record.owning_organisation.merge_date.to_formatted_s(:govuk_date), + absorbing_organisation: record.owning_organisation.absorbing_organisation.name) end if merged_managing_organisation_inactive?(record) - record.errors.add :startdate, I18n.t("validations.setup.startdate.invalid_merged_organisations_start_date.managing_organisation", + record.errors.add :startdate, I18n.t("validations.lettings.setup.startdate.invalid_merged_organisations_start_date.managing_organisation", managing_organisation: record.managing_organisation.name, - managing_organisation_merge_date: record.managing_organisation.merge_date.to_formatted_s(:govuk_date), - managing_absorbing_organisation: record.managing_organisation.absorbing_organisation.name) + merge_date: record.managing_organisation.merge_date.to_formatted_s(:govuk_date), + absorbing_organisation: record.managing_organisation.absorbing_organisation.name) end end end def add_absorbing_organisations_errors(record) if absorbing_owning_organisation_inactive?(record) && absorbing_managing_organisation_inactive?(record) - record.errors.add :startdate, I18n.t("validations.setup.startdate.invalid_absorbing_organisations_start_date.different_organisations", + record.errors.add :startdate, I18n.t("validations.lettings.setup.startdate.invalid_absorbing_organisations_start_date.different_organisations", owning_organisation: record.owning_organisation.name, owning_organisation_active_from: record.owning_organisation.available_from.to_formatted_s(:govuk_date), managing_organisation: record.managing_organisation.name, managing_organisation_active_from: record.managing_organisation.available_from.to_formatted_s(:govuk_date)) else if absorbing_owning_organisation_inactive?(record) - record.errors.add :startdate, I18n.t("validations.setup.startdate.invalid_absorbing_organisations_start_date.owning_organisation", + record.errors.add :startdate, I18n.t("validations.lettings.setup.startdate.invalid_absorbing_organisations_start_date.owning_organisation", owning_organisation: record.owning_organisation.name, - owning_organisation_available_from: record.owning_organisation.available_from.to_formatted_s(:govuk_date)) + available_from: record.owning_organisation.available_from.to_formatted_s(:govuk_date)) end if absorbing_managing_organisation_inactive?(record) - record.errors.add :startdate, I18n.t("validations.setup.startdate.invalid_absorbing_organisations_start_date.managing_organisation", + record.errors.add :startdate, I18n.t("validations.lettings.setup.startdate.invalid_absorbing_organisations_start_date.managing_organisation", managing_organisation: record.managing_organisation.name, - managing_organisation_available_from: record.managing_organisation.available_from.to_formatted_s(:govuk_date)) + available_from: record.managing_organisation.available_from.to_formatted_s(:govuk_date)) end end end diff --git a/config/locales/en.yml b/config/locales/en.yml index c78ba2463..106ccb9fa 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -281,33 +281,14 @@ en: invalid: "Role must be data accessor, data provider or data coordinator." setup: - intermediate_rent_product_name: - blank: "Enter name of other intermediate rent product." saledate: year_not_two_or_four_digits: "Sale completion year must be 2 or 4 digits." type: percentage_bought_must_be_at_least_threshold: "The minimum increase in equity while staircasing is %{threshold}% for this shared ownership type." startdate: - current_collection_year: - "Enter a date within the %{current_start_year_short} to %{current_end_year_short} collection year, which is between %{current_start_year_long} and %{current_end_year_long}." - previous_and_current_collection_year: - "Enter a date within the %{previous_start_year_short} to %{previous_end_year_short} or %{previous_end_year_short} to %{current_end_year_short} collection years, which is between %{previous_start_year_long} and %{current_end_year_long}." - later_than_14_days_after: "The tenancy start date must not be later than 14 days from today’s date." before_scheme_end_date: "The tenancy start date must be before the end date for this supported housing scheme." year_not_two_or_four_digits: "Tenancy start year must be 2 or 4 digits." - invalid_merged_organisations_start_date: - same_organisation: "Enter a date when the owning and managing organisation was active. %{owning_organisation} became inactive on %{owning_organisation_merge_date} and was replaced by %{owning_absorbing_organisation}." - same_merge: "Enter a date when the owning and managing organisations were active. %{owning_organisation} and %{managing_organisation} became inactive on %{owning_organisation_merge_date} and were replaced by %{owning_absorbing_organisation}." - owning_organisation: "Enter a date when the owning organisation was active. %{owning_organisation} became inactive on %{owning_organisation_merge_date} and was replaced by %{owning_absorbing_organisation}." - managing_organisation: "Enter a date when the managing organisation was active. %{managing_organisation} became inactive on %{managing_organisation_merge_date} and was replaced by %{managing_absorbing_organisation}." - different_merge: "Enter a date when the owning and managing organisations were active. %{owning_organisation} became inactive on %{owning_organisation_merge_date} and was replaced by %{owning_absorbing_organisation}. %{managing_organisation} became inactive on %{managing_organisation_merge_date} and was replaced by %{managing_absorbing_organisation}." - invalid_absorbing_organisations_start_date: - same_organisation: "Enter a date when the owning and managing organisation was active. %{owning_organisation} became active on %{owning_organisation_available_from}." - owning_organisation: "Enter a date when the owning organisation was active. %{owning_organisation} became active on %{owning_organisation_available_from}." - managing_organisation: "Enter a date when the managing organisation was active. %{managing_organisation} became active on %{managing_organisation_available_from}." - different_organisations: "Enter a date when the owning and managing organisations were active. %{owning_organisation} became active on %{owning_organisation_active_from}, and %{managing_organisation} became active on %{managing_organisation_active_from}." - location: deactivated: startdate: "The location %{postcode} is inactive on this date. Enter another date or choose another location." @@ -329,17 +310,7 @@ en: startdate: "The scheme %{name} has no locations that are active on this date. Enter another date or choose another scheme." scheme_id: "The scheme %{name} has no locations that are active on this date. Enter another date or choose another scheme." owning_organisation: - invalid: "Please select the owning organisation or managing organisation that you belong to." data_sharing_agreement_not_signed: "The organisation must accept the Data Sharing Agreement before it can be selected as the owning organisation." - inactive_merged_organisation: "The owning organisation must be active on the tenancy start date. %{owning_organisation} became inactive on %{owning_organisation_merge_date} and was replaced by %{owning_absorbing_organisation}." - inactive_absorbing_organisation: "The owning organisation must be active on the tenancy start date. %{owning_organisation} became active on %{owning_organisation_available_from}." - managing_organisation: - invalid: "Please select the owning organisation or managing organisation that you belong to." - data_sharing_agreement_not_signed: "The organisation must accept the Data Sharing Agreement before it can be selected as the managing organisation." - inactive_merged_organisation: "The managing organisation must be active on the tenancy start date. %{managing_organisation} became inactive on %{managing_organisation_merge_date} and was replaced by %{managing_absorbing_organisation}." - inactive_absorbing_organisation: "The managing organisation must be active on the tenancy start date. %{managing_organisation} became active on %{managing_organisation_available_from}." - assigned_to: - invalid: "Please select the owning organisation or managing organisation that you belong to." lettype: general_needs_mismatch: "Lettings type must be a general needs type because you selected general needs when uploading the file." supported_housing_mismatch: "Lettings type must be a supported housing type because you selected supported housing when uploading the file." @@ -348,10 +319,6 @@ en: needstype: lettype_not_general_needs: "This letting type is supported housing, but the needs type is general needs. Change either the needs type or the letting type." lettype_not_supported_housing: "This letting type is general needs, but the needs type is supported housing. Change either the needs type or the letting type." - location: - incomplete: "This location is incomplete. Select another location or update this one." - scheme: - incomplete: "This scheme is incomplete. Select another scheme or update this one." property: uprn: @@ -603,7 +570,6 @@ en: during_deactivated_period: "The scheme is already deactivated during this date, please enter a different date." owning_organisation: does_not_own_stock: "Enter an organisation that owns housing stock." - no_completed_locations: "This scheme cannot be chosen as it has no completed locations." location: postcode_blank: "Enter a postcode." diff --git a/config/locales/validations/lettings/setup.en.yml b/config/locales/validations/lettings/setup.en.yml new file mode 100644 index 000000000..d2ee9bf0f --- /dev/null +++ b/config/locales/validations/lettings/setup.en.yml @@ -0,0 +1,53 @@ +en: + validations: + lettings: + setup: + startdate: + not_within: + next_two_weeks: "The tenancy start date must not be later than 14 days from today’s date." + must_be_within: + current_collection_year: + "Enter a date within the %{current_start_year_short} to %{current_end_year_short} collection year, which is between %{current_start_year_long} and %{current_end_year_long}." + previous_and_current_collection_year: + "Enter a date within the %{previous_start_year_short} to %{previous_end_year_short} or %{previous_end_year_short} to %{current_end_year_short} collection years, which is between %{previous_start_year_long} and %{current_end_year_long}." + invalid_merged_organisations_start_date: + same_organisation: "Enter a date when the owning and managing organisation was active. %{owning_organisation} became inactive on %{merge_date} and was replaced by %{absorbing_organisation}." + same_merge: "Enter a date when the owning and managing organisations were active. %{owning_organisation} and %{managing_organisation} became inactive on %{owning_organisation_merge_date} and were replaced by %{owning_absorbing_organisation}." + owning_organisation: "Enter a date when the owning organisation was active. %{owning_organisation} became inactive on %{merge_date} and was replaced by %{absorbing_organisation}." + managing_organisation: "Enter a date when the managing organisation was active. %{managing_organisation} became inactive on %{merge_date} and was replaced by %{absorbing_organisation}." + different_merge: "Enter a date when the owning and managing organisations were active. %{owning_organisation} became inactive on %{owning_organisation_merge_date} and was replaced by %{owning_absorbing_organisation}. %{managing_organisation} became inactive on %{managing_organisation_merge_date} and was replaced by %{managing_absorbing_organisation}." + invalid_absorbing_organisations_start_date: + same_organisation: "Enter a date when the owning and managing organisation was active. %{owning_organisation} became active on %{available_from}." + owning_organisation: "Enter a date when the owning organisation was active. %{owning_organisation} became active on %{available_from}." + managing_organisation: "Enter a date when the managing organisation was active. %{managing_organisation} became active on %{available_from}." + different_organisations: "Enter a date when the owning and managing organisations were active. %{owning_organisation} became active on %{owning_organisation_active_from}, and %{managing_organisation} became active on %{managing_organisation_active_from}." + + assigned_to: + invalid: "Please select the owning organisation or managing organisation that you belong to." + + owning_organisation: + invalid: "Please select the owning organisation or managing organisation that you belong to." + inactive: + merged_organisation: + "The owning organisation must be active on the tenancy start date. %{owning_organisation} became inactive on %{merge_date} and was replaced by %{absorbing_organisation}." + absorbing_organisation: + "The owning organisation must be active on the tenancy start date. %{owning_organisation} became active on %{available_from}." + + managing_organisation: + invalid: "Please select the owning organisation or managing organisation that you belong to." + data_sharing_agreement_not_signed: "The organisation must accept the Data Sharing Agreement before it can be selected as the managing organisation." + inactive: + merged_organisation: + "The managing organisation must be active on the tenancy start date. %{managing_organisation} became inactive on %{merge_date} and was replaced by %{absorbing_organisation}." + absorbing_organisation: + "The managing organisation must be active on the tenancy start date. %{managing_organisation} became active on %{available_from}." + + intermediate_rent_product_name: + blank: "Enter name of other intermediate rent product." + + scheme: + incomplete: "This scheme is incomplete. Select another scheme or update this one." + no_completed_locations: "This scheme cannot be chosen as it has no completed locations." + + location: + incomplete: "This location is incomplete. Select another location or update this one." diff --git a/spec/models/validations/setup_validations_spec.rb b/spec/models/validations/setup_validations_spec.rb index f1e306a89..0c99d3628 100644 --- a/spec/models/validations/setup_validations_spec.rb +++ b/spec/models/validations/setup_validations_spec.rb @@ -149,7 +149,7 @@ RSpec.describe Validations::SetupValidations do it "adds an error to startdate" do record.startdate = Time.zone.local(2024, 3, 31) setup_validator.validate_startdate_setup(record) - expect(record.errors["startdate"]).to include(match I18n.t("validations.setup.startdate.later_than_14_days_after")) + expect(record.errors["startdate"]).to include(match I18n.t("validations.lettings.setup.startdate.not_within.next_two_weeks")) end context "and the attempted startdate is in a future collection year" do @@ -158,7 +158,7 @@ RSpec.describe Validations::SetupValidations do setup_validator.validate_startdate_setup(record) expect(record.errors["startdate"].length).to be >= 2 expect(record.errors["startdate"][0]).to eq("Enter a date within the 2023 to 2024 collection year, which is between 1st April 2023 and 31st March 2024.") - expect(record.errors["startdate"][1]).to eq(I18n.t("validations.setup.startdate.later_than_14_days_after")) + expect(record.errors["startdate"][1]).to eq(I18n.t("validations.lettings.setup.startdate.not_within.next_two_weeks")) end end end @@ -401,7 +401,7 @@ RSpec.describe Validations::SetupValidations do record.irproduct_other = nil setup_validator.validate_irproduct_other(record) expect(record.errors["irproduct_other"]) - .to include(match I18n.t("validations.setup.intermediate_rent_product_name.blank")) + .to include(match I18n.t("validations.lettings.setup.intermediate_rent_product_name.blank")) end it "adds an error when the intermediate rent product name is blank but the rent type was given as other intermediate rent product" do @@ -409,7 +409,7 @@ RSpec.describe Validations::SetupValidations do record.irproduct_other = "" setup_validator.validate_irproduct_other(record) expect(record.errors["irproduct_other"]) - .to include(match I18n.t("validations.setup.intermediate_rent_product_name.blank")) + .to include(match I18n.t("validations.lettings.setup.intermediate_rent_product_name.blank")) end it "Does not add an error when the intermediate rent product name is provided and the rent type was given as other intermediate rent product" do @@ -572,7 +572,7 @@ RSpec.describe Validations::SetupValidations do it "adds an error to scheme_id" do record.scheme = scheme setup_validator.validate_scheme(record) - expect(record.errors["scheme_id"]).to include(I18n.t("validations.setup.scheme.incomplete")) + expect(record.errors["scheme_id"]).to include(I18n.t("validations.lettings.setup.scheme.incomplete")) end end end @@ -748,9 +748,9 @@ RSpec.describe Validations::SetupValidations do record.managing_organisation = other_organisation setup_validator.validate_organisation(record) - expect(record.errors["assigned_to"]).to include(I18n.t("validations.setup.assigned_to.invalid")) - expect(record.errors["owning_organisation_id"]).to include(I18n.t("validations.setup.owning_organisation.invalid")) - expect(record.errors["managing_organisation_id"]).to include(I18n.t("validations.setup.managing_organisation.invalid")) + expect(record.errors["assigned_to"]).to include(I18n.t("validations.lettings.setup.assigned_to.invalid")) + expect(record.errors["owning_organisation_id"]).to include(I18n.t("validations.lettings.setup.owning_organisation.invalid")) + expect(record.errors["managing_organisation_id"]).to include(I18n.t("validations.lettings.setup.managing_organisation.invalid")) end it "does not validate if either managing or owning organisation is the same as current user organisation" do @@ -902,7 +902,7 @@ RSpec.describe Validations::SetupValidations do record.scheme = scheme setup_validator.validate_scheme_has_confirmed_locations_validation(record) expect(record.errors["scheme_id"]) - .to include(match I18n.t("validations.scheme.no_completed_locations")) + .to include(match I18n.t("validations.lettings.setup.scheme.no_completed_locations")) end end From 625b0c757c70dcb8b212386a31083d259feb6eed Mon Sep 17 00:00:00 2001 From: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com> Date: Thu, 31 Oct 2024 16:29:55 +0000 Subject: [PATCH 28/30] CLDC-3668 Extract guidance copy (#2737) * Extract guidance copy * Update tests and lint --- .../form/lettings/questions/declaration.rb | 2 +- .../form/lettings/questions/rent_type.rb | 2 +- .../form/sales/questions/privacy_notice.rb | 6 +- .../sales/questions/shared_ownership_type.rb | 10 +-- ..._discounted_ownership_type_definitions.erb | 28 ++------- app/views/form/guidance/_finding_location.erb | 10 +-- app/views/form/guidance/_finding_scheme.erb | 13 ++-- .../form/guidance/_mortgage_lender.html.erb | 8 +-- .../_outright_sale_type_definitions.erb | 13 ++-- .../form/guidance/_privacy_notice_buyer.erb | 4 +- .../guidance/_privacy_notice_buyer_2024.erb | 1 - ...ivacy_notice_buyer_2024_joint_purchase.erb | 1 - .../_privacy_notice_buyer_joint_purchase.erb | 4 +- .../form/guidance/_privacy_notice_tenant.erb | 4 +- .../guidance/_privacy_notice_tenant_2024.erb | 1 - .../form/guidance/_rent_type_definitions.erb | 26 ++------ .../guidance/_rent_type_definitions_2024.erb | 21 ------- .../form/guidance/_scheme_selection.html.erb | 4 +- .../_shared_ownership_type_definitions.erb | 31 ++------- ...shared_ownership_type_definitions_2024.erb | 26 -------- app/views/form/guidance/_void_date.html.erb | 14 ++--- .../guidance/_what_counts_as_income.html.erb | 21 ++----- .../forms/2023/lettings/guidance.en.yml | 63 +++++++++++++++++++ .../locales/forms/2023/sales/guidance.en.yml | 47 ++++++++++++++ .../forms/2024/lettings/guidance.en.yml | 63 +++++++++++++++++++ .../locales/forms/2024/sales/guidance.en.yml | 46 ++++++++++++++ .../lettings/questions/declaration_spec.rb | 2 +- .../form/lettings/questions/rent_type_spec.rb | 2 +- .../sales/questions/privacy_notice_spec.rb | 4 +- .../questions/shared_ownership_type_spec.rb | 2 +- spec/requests/form_controller_spec.rb | 2 +- spec/views/form/page_view_spec.rb | 2 +- 32 files changed, 286 insertions(+), 197 deletions(-) delete mode 100644 app/views/form/guidance/_privacy_notice_buyer_2024.erb delete mode 100644 app/views/form/guidance/_privacy_notice_buyer_2024_joint_purchase.erb delete mode 100644 app/views/form/guidance/_privacy_notice_tenant_2024.erb delete mode 100644 app/views/form/guidance/_rent_type_definitions_2024.erb delete mode 100644 app/views/form/guidance/_shared_ownership_type_definitions_2024.erb create mode 100644 config/locales/forms/2023/lettings/guidance.en.yml create mode 100644 config/locales/forms/2023/sales/guidance.en.yml create mode 100644 config/locales/forms/2024/lettings/guidance.en.yml create mode 100644 config/locales/forms/2024/sales/guidance.en.yml diff --git a/app/models/form/lettings/questions/declaration.rb b/app/models/form/lettings/questions/declaration.rb index c88c7cf3c..0e2fd5b2c 100644 --- a/app/models/form/lettings/questions/declaration.rb +++ b/app/models/form/lettings/questions/declaration.rb @@ -4,7 +4,7 @@ class Form::Lettings::Questions::Declaration < ::Form::Question @id = "declaration" @type = "checkbox" @check_answers_card_number = 0 unless form.start_year_after_2024? - @top_guidance_partial = form.start_year_after_2024? ? "privacy_notice_tenant_2024" : "privacy_notice_tenant" + @top_guidance_partial = "privacy_notice_tenant" @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end diff --git a/app/models/form/lettings/questions/rent_type.rb b/app/models/form/lettings/questions/rent_type.rb index 818ead98a..bc6934200 100644 --- a/app/models/form/lettings/questions/rent_type.rb +++ b/app/models/form/lettings/questions/rent_type.rb @@ -4,7 +4,7 @@ class Form::Lettings::Questions::RentType < ::Form::Question @id = "rent_type" @copy_key = "lettings.setup.rent_type.rent_type" @type = "radio" - @top_guidance_partial = form.start_year_after_2024? ? "rent_type_definitions_2024" : "rent_type_definitions" + @top_guidance_partial = "rent_type_definitions" @answer_options = form.start_year_after_2024? ? ANSWER_OPTIONS_2024 : ANSWER_OPTIONS @conditional_for = { "irproduct_other" => [5] } @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] if form.start_date.present? diff --git a/app/models/form/sales/questions/privacy_notice.rb b/app/models/form/sales/questions/privacy_notice.rb index 95921737f..57f77041b 100644 --- a/app/models/form/sales/questions/privacy_notice.rb +++ b/app/models/form/sales/questions/privacy_notice.rb @@ -29,11 +29,7 @@ class Form::Sales::Questions::PrivacyNotice < ::Form::Question end def guidance - if form.start_year_after_2024? - @joint_purchase ? "privacy_notice_buyer_2024_joint_purchase" : "privacy_notice_buyer_2024" - else - @joint_purchase ? "privacy_notice_buyer_joint_purchase" : "privacy_notice_buyer" - end + @joint_purchase ? "privacy_notice_buyer_joint_purchase" : "privacy_notice_buyer" end QUESTION_NUMBER_FROM_YEAR = { 2023 => 19, 2024 => 14 }.freeze diff --git a/app/models/form/sales/questions/shared_ownership_type.rb b/app/models/form/sales/questions/shared_ownership_type.rb index 1ede14a4d..9ac998313 100644 --- a/app/models/form/sales/questions/shared_ownership_type.rb +++ b/app/models/form/sales/questions/shared_ownership_type.rb @@ -3,7 +3,7 @@ class Form::Sales::Questions::SharedOwnershipType < ::Form::Question super @id = "type" @copy_key = "sales.setup.type.shared_ownership" - @top_guidance_partial = guidance_partial + @top_guidance_partial = "shared_ownership_type_definitions" @type = "radio" @answer_options = answer_options @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] @@ -34,13 +34,5 @@ class Form::Sales::Questions::SharedOwnershipType < ::Form::Question end end - def guidance_partial - if form.start_year_after_2024? - "shared_ownership_type_definitions_2024" - elsif form.start_date.year >= 2023 - "shared_ownership_type_definitions" - end - end - QUESTION_NUMBER_FROM_YEAR = { 2023 => 4, 2024 => 6 }.freeze end diff --git a/app/views/form/guidance/_discounted_ownership_type_definitions.erb b/app/views/form/guidance/_discounted_ownership_type_definitions.erb index 0102a836a..2895e751d 100644 --- a/app/views/form/guidance/_discounted_ownership_type_definitions.erb +++ b/app/views/form/guidance/_discounted_ownership_type_definitions.erb @@ -1,23 +1,5 @@ -<%= govuk_details(summary_text: "Discounted ownership type definitions") do %> -

    - Right to Acquire (RTA): a discounted sale of a property built or purchased after 31 March 1997 to tenants of a private registered provider. -

    -

    - Preserved Right to Buy (PRTB): a discounted sale of a property that used to be owned by a council to tenants of a private registered provider. -

    -

    - Voluntary Right to Buy (VRTB): a discounted sale to tenants in this PRP owned property, as part of a pilot scheme. -

    -

    - Right to Buy (RTB): a discounted sale to tenants in this council owned property. -

    -

    - Rent to Buy full ownership: a sale on full ownership terms following a period of discounted rent. -

    -

    - Social HomeBuy for outright purchase: a discounted sale to tenants of a private registered provider on full ownership terms. -

    -

    - Any other equity loan scheme: any scheme, not covered elsewhere, in which a loan is used to purchase equity. -

    -<% end %> +
    + <%= govuk_details(summary_text: I18n.t("forms.#{@log.form.start_date.year}.sales.guidance.discounted_ownership_type_definitions.title")) do %> + <%= I18n.t("forms.#{@log.form.start_date.year}.sales.guidance.discounted_ownership_type_definitions.content").html_safe %> + <% end %> +
    diff --git a/app/views/form/guidance/_finding_location.erb b/app/views/form/guidance/_finding_location.erb index b50d1802a..41c9bd0ab 100644 --- a/app/views/form/guidance/_finding_location.erb +++ b/app/views/form/guidance/_finding_location.erb @@ -1,4 +1,6 @@ -<%= govuk_details(summary_text: "What is a location?") do %> -

    A location is a postcode area where supported housing is provided under a scheme. A scheme can have multiple locations, and a location can have multiple units at the same postcode.

    -

    <%= govuk_link_to("Read more about schemes and locations", scheme_changes_path) %>

    -<% end %> +
    + <%= govuk_details(summary_text: I18n.t("forms.#{@log.form.start_date.year}.lettings.guidance.finding_location.title")) do %> +

    <%= I18n.t("forms.#{@log.form.start_date.year}.lettings.guidance.finding_location.content").html_safe %>

    +

    <%= govuk_link_to(I18n.t("forms.#{@log.form.start_date.year}.lettings.guidance.finding_location.scheme_changes_link_text"), scheme_changes_path) %>

    + <% end %> +
    diff --git a/app/views/form/guidance/_finding_scheme.erb b/app/views/form/guidance/_finding_scheme.erb index 8101c5a6d..40b6fe823 100644 --- a/app/views/form/guidance/_finding_scheme.erb +++ b/app/views/form/guidance/_finding_scheme.erb @@ -1,6 +1,7 @@ -<%= govuk_details(summary_text: "Can’t find your scheme?") do %> -

    Schemes are attached to the organisation that owns the property. Check you have correctly answered question 1 "Which organisation owns this property?"

    -

    If your organisation’s schemes were migrated from old CORE, they may have new names and codes. Search by postcode to find your scheme.

    -

    <%= govuk_link_to("View your organisation’s schemes", clear_filters_url(filter_type: "schemes")) %>

    -

    <%= govuk_link_to("Read more about how schemes have changed", scheme_changes_path) %>

    -<% end %> +
    + <%= govuk_details(summary_text: I18n.t("forms.#{@log.form.start_date.year}.lettings.guidance.finding_scheme.title")) do %> + <%= I18n.t("forms.#{@log.form.start_date.year}.lettings.guidance.finding_scheme.content").html_safe %> +

    <%= govuk_link_to(I18n.t("forms.#{@log.form.start_date.year}.lettings.guidance.finding_scheme.view_schemes_link_text"), clear_filters_url(filter_type: "schemes")) %>

    +

    <%= govuk_link_to(I18n.t("forms.#{@log.form.start_date.year}.lettings.guidance.finding_scheme.scheme_changes_link_text"), scheme_changes_path) %>

    + <% end %> +
    diff --git a/app/views/form/guidance/_mortgage_lender.html.erb b/app/views/form/guidance/_mortgage_lender.html.erb index 7991182ed..c3f016a82 100644 --- a/app/views/form/guidance/_mortgage_lender.html.erb +++ b/app/views/form/guidance/_mortgage_lender.html.erb @@ -1,7 +1,3 @@ -<%= govuk_details(summary_text: "Can’t find the mortgage lender you’re looking for?") do %> -
      -
    • Double check the spelling and try again
    • -
    • Type the first few letters to see the suggestions
    • -
    • Type Other and continue - we’ll ask you to type in your answer in the next question
    • -
    +<%= govuk_details(summary_text: I18n.t("forms.#{@log.form.start_date.year}.sales.guidance.mortgage_lender.title")) do %> + <%= I18n.t("forms.#{@log.form.start_date.year}.sales.guidance.mortgage_lender.content").html_safe %> <% end %> diff --git a/app/views/form/guidance/_outright_sale_type_definitions.erb b/app/views/form/guidance/_outright_sale_type_definitions.erb index 01e5253d0..c0e4eb1c3 100644 --- a/app/views/form/guidance/_outright_sale_type_definitions.erb +++ b/app/views/form/guidance/_outright_sale_type_definitions.erb @@ -1,8 +1,5 @@ -<%= govuk_details(summary_text: "Outright sale type definitions") do %> -

    - Outright sale: the full purchase of a property, usually with a mortgage or cash. -

    -

    - Other sale: any sale which does not fit the criteria of any of the remaining options. -

    -<% end %> +
    + <%= govuk_details(summary_text: I18n.t("forms.#{@log.form.start_date.year}.sales.guidance.outright_sale_type_definitions.title")) do %> + <%= I18n.t("forms.#{@log.form.start_date.year}.sales.guidance.outright_sale_type_definitions.content").html_safe %> + <% end %> +
    diff --git a/app/views/form/guidance/_privacy_notice_buyer.erb b/app/views/form/guidance/_privacy_notice_buyer.erb index 599574a06..88dfdda41 100644 --- a/app/views/form/guidance/_privacy_notice_buyer.erb +++ b/app/views/form/guidance/_privacy_notice_buyer.erb @@ -1 +1,3 @@ -

    Make sure the buyer has seen <%= govuk_link_to "the Ministry of Housing, Communities and Local Government (MHCLG) privacy notice", privacy_notice_path, target: :_blank %> before completing this log.

    +

    + <%= I18n.t("forms.#{@log.form.start_date.year}.sales.guidance.privacy_notice_buyer.content", privacy_notice_link: "#{govuk_link_to I18n.t("forms.#{@log.form.start_date.year}.sales.guidance.privacy_notice_buyer.privacy_notice_link_text"), privacy_notice_path, target: :_blank}").html_safe %> +

    diff --git a/app/views/form/guidance/_privacy_notice_buyer_2024.erb b/app/views/form/guidance/_privacy_notice_buyer_2024.erb deleted file mode 100644 index 1ed6e683e..000000000 --- a/app/views/form/guidance/_privacy_notice_buyer_2024.erb +++ /dev/null @@ -1 +0,0 @@ -

    Make sure the buyer has seen or been given access to <%= govuk_link_to "the Ministry of Housing, Communities and Local Government (MHCLG) privacy notice", privacy_notice_path, target: :_blank %> before completing this log. This is a legal requirement under data protection legislation.

    diff --git a/app/views/form/guidance/_privacy_notice_buyer_2024_joint_purchase.erb b/app/views/form/guidance/_privacy_notice_buyer_2024_joint_purchase.erb deleted file mode 100644 index 74ce54a3d..000000000 --- a/app/views/form/guidance/_privacy_notice_buyer_2024_joint_purchase.erb +++ /dev/null @@ -1 +0,0 @@ -

    Make sure the buyers have seen or been given access to <%= govuk_link_to "the Ministry of Housing, Communities and Local Government (MHCLG) privacy notice", privacy_notice_path, target: :_blank %> before completing this log. This is a legal requirement under data protection legislation.

    diff --git a/app/views/form/guidance/_privacy_notice_buyer_joint_purchase.erb b/app/views/form/guidance/_privacy_notice_buyer_joint_purchase.erb index edab9e1e9..c23f5fd52 100644 --- a/app/views/form/guidance/_privacy_notice_buyer_joint_purchase.erb +++ b/app/views/form/guidance/_privacy_notice_buyer_joint_purchase.erb @@ -1 +1,3 @@ -

    Make sure the buyers have seen <%= govuk_link_to "the Ministry of Housing, Communities and Local Government (MHCLG) privacy notice", privacy_notice_path, target: :_blank %> before completing this log.

    +

    + <%= I18n.t("forms.#{@log.form.start_date.year}.sales.guidance.privacy_notice_buyer_joint_purchase.content", privacy_notice_link: "#{govuk_link_to I18n.t("forms.#{@log.form.start_date.year}.sales.guidance.privacy_notice_buyer_joint_purchase.privacy_notice_link_text"), privacy_notice_path, target: :_blank}").html_safe %> +

    diff --git a/app/views/form/guidance/_privacy_notice_tenant.erb b/app/views/form/guidance/_privacy_notice_tenant.erb index 7df685448..8b557c992 100644 --- a/app/views/form/guidance/_privacy_notice_tenant.erb +++ b/app/views/form/guidance/_privacy_notice_tenant.erb @@ -1 +1,3 @@ -

    Make sure the tenant has seen <%= govuk_link_to "the Ministry of Housing, Communities and Local Government (MHCLG) privacy notice", privacy_notice_path, target: :_blank %> before completing this log.

    +

    + <%= I18n.t("forms.#{@log.form.start_date.year}.lettings.guidance.privacy_notice_tenant.content", privacy_notice_link: "#{govuk_link_to I18n.t("forms.#{@log.form.start_date.year}.lettings.guidance.privacy_notice_tenant.privacy_notice_link_text"), privacy_notice_path, target: :_blank}").html_safe %> +

    diff --git a/app/views/form/guidance/_privacy_notice_tenant_2024.erb b/app/views/form/guidance/_privacy_notice_tenant_2024.erb deleted file mode 100644 index 12de7baba..000000000 --- a/app/views/form/guidance/_privacy_notice_tenant_2024.erb +++ /dev/null @@ -1 +0,0 @@ -

    Make sure the lead tenant has seen or been given access to <%= govuk_link_to "the Ministry of Housing, Communities and Local Government (MHCLG) privacy notice", privacy_notice_path, target: :_blank %> before completing this log. This is a legal requirement under data protection legislation.

    diff --git a/app/views/form/guidance/_rent_type_definitions.erb b/app/views/form/guidance/_rent_type_definitions.erb index 1e008ee60..1c3b038e8 100644 --- a/app/views/form/guidance/_rent_type_definitions.erb +++ b/app/views/form/guidance/_rent_type_definitions.erb @@ -1,21 +1,5 @@ -<%= govuk_details(summary_text: "Rent type definitions") do %> -

    - Affordable Rent: where up to 80% of market rent can be charged. A new supply agreement is signed with Homes England or the Greater London Authority (GLA). -

    -

    - London Affordable Rent: a tenure of affordable housing available in London by the GLA. It is an affordable rent which must be set in accordance with the Regulator of Social Housing’s Affordable Rent guidance. The landlord of these homes must be registered with the Regulator of Social Housing. These are a type of Affordable Rent lettings. -

    -

    - London Living Rent: a tenure of affordable housing available in London by the GLA. It was introduced in Affordable Homes Programme 2016 to 2021. These are a type of Intermediate Rent lettings. -

    -

    - Rent to Buy: a discount of up to 20% market rent is charged for a single rental period for a minimum of 5 years. After that period, the tenant is offered first chance to purchase the property (either shared ownership or outright) at full market value. These are a type of Intermediate Rent lettings. -

    -

    - Social Rent: where target rents are determined through the national rent regime. This is sometimes also known as 'formula rent'. -

    - -

    - Other intermediate rent: any other specific scheme where up to 80% of market rent can be charged. This includes schemes with reduced rent so tenants can save towards a house purchasing deposit and schemes with an in-built future opportunity to buy the property being rented. -

    -<% end %> +
    + <%= govuk_details(summary_text: I18n.t("forms.#{@log.form.start_date.year}.lettings.guidance.rent_type_definitions.title")) do %> + <%= I18n.t("forms.#{@log.form.start_date.year}.lettings.guidance.rent_type_definitions.content").html_safe %> + <% end %> +
    \ No newline at end of file diff --git a/app/views/form/guidance/_rent_type_definitions_2024.erb b/app/views/form/guidance/_rent_type_definitions_2024.erb deleted file mode 100644 index ee835b4a0..000000000 --- a/app/views/form/guidance/_rent_type_definitions_2024.erb +++ /dev/null @@ -1,21 +0,0 @@ -<%= govuk_details(summary_text: "Rent type definitions") do %> -

    - Social Rent: where target rents are determined through the national rent regime. This is sometimes also known as 'formula rent'. -

    -

    - Affordable Rent: where up to 80% of market rent can be charged. A new supply agreement is signed with Homes England or the Greater London Authority (GLA). -

    -

    - London Affordable Rent: a tenure of affordable housing available in London by the GLA. It is an affordable rent which must be set in accordance with the Regulator of Social Housing’s Affordable Rent guidance. The landlord of these homes must be registered with the Regulator of Social Housing. These are a type of Affordable Rent lettings. -

    -

    - Rent to Buy: a discount of up to 20% market rent is charged for a single rental period for a minimum of 5 years. After that period, the tenant is offered first chance to purchase the property (either shared ownership or outright) at full market value. These are a type of Intermediate Rent lettings. -

    -

    - London Living Rent: a tenure of affordable housing available in London by the GLA. It was introduced in Affordable Homes Programme 2016 to 2021. These are a type of Intermediate Rent lettings. -

    - -

    - Other intermediate rent: any other specific scheme where up to 80% of market rent can be charged. This includes schemes with reduced rent so tenants can save towards a house purchasing deposit and schemes with an in-built future opportunity to buy the property being rented. -

    -<% end %> diff --git a/app/views/form/guidance/_scheme_selection.html.erb b/app/views/form/guidance/_scheme_selection.html.erb index c13edb05b..3aaff4a4a 100644 --- a/app/views/form/guidance/_scheme_selection.html.erb +++ b/app/views/form/guidance/_scheme_selection.html.erb @@ -1,5 +1,5 @@ <% if current_user.data_provider? %> -

    If you’re not sure which scheme to choose, ask a data coordinator. Find your data coordinators on the <%= govuk_link_to("users page", users_path) %>.

    +

    <%= I18n.t("forms.#{@log.form.start_date.year}.lettings.guidance.scheme_selection.data_provider.content", users_page_link: govuk_link_to(I18n.t("forms.#{@log.form.start_date.year}.lettings.guidance.scheme_selection.data_provider.users_page_link_text"), users_path).to_s).html_safe %>

    <% elsif current_user.data_coordinator? %> -

    <%= govuk_link_to "Create a new supported housing scheme", new_scheme_path %>

    +

    <%= govuk_link_to I18n.t("forms.#{@log.form.start_date.year}.lettings.guidance.scheme_selection.data_coordinator.create_scheme_link_text"), new_scheme_path %>

    <% end %> diff --git a/app/views/form/guidance/_shared_ownership_type_definitions.erb b/app/views/form/guidance/_shared_ownership_type_definitions.erb index 95cd65533..06c5f864e 100644 --- a/app/views/form/guidance/_shared_ownership_type_definitions.erb +++ b/app/views/form/guidance/_shared_ownership_type_definitions.erb @@ -1,26 +1,5 @@ -<%= govuk_details(summary_text: "Shared ownership type definitions") do %> -

    - Shared ownership: Cannot be used for homes funded through the Affordable Homes Programme 2021 to 2026. Use the 2021 model lease for these properties. -

    -

    - Shared ownership 2021 model lease: Homes bought using the Affordable Homes Programme 2021 to 2026. -

    -

    - Older Persons Shared Ownership: A type of shared ownership for those 55 years and over. -

    -

    - Social HomeBuy shared ownership purchase: Tenants of private registered providers purchase their home at discount on Shared Ownership terms. -

    -

    - Home Ownership for people with Long-Term Disabilities (HOLD): A shared ownership sale for those with long term disabilities. -

    -

    - Rent to Buy shared ownership: A sale following a period of discounted rent. -

    -

    - Right to Shared Ownership: A sale of a share of a rented home to a tenant using this scheme. -

    -

    - London Living Rent shared ownership: A shared ownership sale following a period of discounted rent as part of the London Living Rent scheme. -

    -<% end %> +
    + <%= govuk_details(summary_text: I18n.t("forms.#{@log.form.start_date.year}.sales.guidance.shared_ownership_type_definitions.title")) do %> + <%= I18n.t("forms.#{@log.form.start_date.year}.sales.guidance.shared_ownership_type_definitions.content").html_safe %> + <% end %> +
    diff --git a/app/views/form/guidance/_shared_ownership_type_definitions_2024.erb b/app/views/form/guidance/_shared_ownership_type_definitions_2024.erb deleted file mode 100644 index bce41c43b..000000000 --- a/app/views/form/guidance/_shared_ownership_type_definitions_2024.erb +++ /dev/null @@ -1,26 +0,0 @@ -<%= govuk_details(summary_text: "Shared ownership type definitions") do %> -

    - Shared Ownership (old model lease): Cannot be used for homes funded through the Affordable Homes Programme 2021 to 2026. Use the new model lease for these properties. -

    -

    - Shared Ownership (new model lease): Homes bought using the Affordable Homes Programme 2021 to 2026. -

    -

    - Social HomeBuy — shared ownership purchase: Tenants of private registered providers purchase their home at discount on Shared Ownership terms. -

    -

    - Home Ownership for people with Long-Term Disabilities (HOLD): A shared ownership sale for those with long term disabilities. -

    -

    - Older Persons Shared Ownership: A type of shared ownership for those 55 years and over. -

    -

    - Rent to Buy — Shared Ownership: A sale following a period of discounted rent. -

    -

    - Right to Shared Ownership (RtSO): A sale of a share of a rented home to a tenant using this scheme. -

    -

    - London Living Rent — Shared Ownership: A shared ownership sale following a period of discounted rent as part of the London Living Rent scheme. -

    -<% end %> diff --git a/app/views/form/guidance/_void_date.html.erb b/app/views/form/guidance/_void_date.html.erb index 69ea9384f..76e9e22e2 100644 --- a/app/views/form/guidance/_void_date.html.erb +++ b/app/views/form/guidance/_void_date.html.erb @@ -1,9 +1,5 @@ -<%= govuk_details(summary_text: "What is a void date?") do %> -

    Date the property was (legally or contractually) available to let, or for:

    -
      -
    • re-lets: the day after the previous tenant's contract ended
    • -
    • new builds: the day the landlord legally first owned the property (‘completion date’)
    • -
    • new conversions or acquisitions: completion date, or the day after rehabilitation work ended
    • -
    • new leases: the day the landlord got contractual property rights and could let it out to tenants
    • -
    -<% end %> +
    + <%= govuk_details(summary_text: I18n.t("forms.#{@log.form.start_date.year}.lettings.guidance.void_date.title")) do %> + <%= I18n.t("forms.#{@log.form.start_date.year}.lettings.guidance.void_date.content").html_safe %> + <% end %> +
    diff --git a/app/views/form/guidance/_what_counts_as_income.html.erb b/app/views/form/guidance/_what_counts_as_income.html.erb index 55362d941..2ebeda481 100644 --- a/app/views/form/guidance/_what_counts_as_income.html.erb +++ b/app/views/form/guidance/_what_counts_as_income.html.erb @@ -1,16 +1,5 @@ -<%= govuk_details(summary_text: "What counts as income?") do %> -

    You should include any income after tax from:

    -
      -
    • employment
    • -
    • pensions
    • -
    • Universal Credit
    • -
    - -

    Don’t include:

    -
      -
    • National Insurance (NI) contributions and tax
    • -
    • housing benefit
    • -
    • child benefit
    • -
    • council tax support
    • -
    -<% end %> +
    + <%= govuk_details(summary_text: I18n.t("forms.#{@log.form.start_date.year}.lettings.guidance.what_counts_as_income.title")) do %> + <%= I18n.t("forms.#{@log.form.start_date.year}.lettings.guidance.what_counts_as_income.content").html_safe %> + <% end %> +
    diff --git a/config/locales/forms/2023/lettings/guidance.en.yml b/config/locales/forms/2023/lettings/guidance.en.yml new file mode 100644 index 000000000..1ce7e8a0c --- /dev/null +++ b/config/locales/forms/2023/lettings/guidance.en.yml @@ -0,0 +1,63 @@ +en: + forms: + 2023: + lettings: + guidance: + finding_location: + title: "What is a location?" + content: "A location is a postcode area where supported housing is provided under a scheme. A scheme can have multiple locations, and a location can have multiple units at the same postcode." + scheme_changes_link_text: "Read more about schemes and locations" + + finding_scheme: + title: "Can’t find your scheme?" + content: "

    Schemes are attached to the organisation that owns the property. Check you have correctly answered question 1 \"Which organisation owns this property?\"

    +

    If your organisation’s schemes were migrated from old CORE, they may have new names and codes. Search by postcode to find your scheme.

    " + scheme_changes_link_text: "Read more about how schemes have changed" + view_schemes_link_text: "View your organisation’s schemes" + + privacy_notice_tenant: + content: "Make sure the tenant has seen %{privacy_notice_link} before completing this log." + privacy_notice_link_text: "the Ministry of Housing, Communities and Local Government (MHCLG) privacy notice" + + rent_type_definitions: + title: "Rent type definitions" + content: "

    Affordable Rent: where up to 80% of market rent can be charged. A new supply agreement is signed with Homes England or the Greater London Authority (GLA).

    +

    London Affordable Rent: a tenure of affordable housing available in London by the GLA. It is an affordable rent which must be set in accordance with the Regulator of Social Housing’s Affordable Rent guidance. The landlord of these homes must be registered with the Regulator of Social Housing. These are a type of Affordable Rent lettings.

    +

    London Living Rent: a tenure of affordable housing available in London by the GLA. It was introduced in Affordable Homes Programme 2016 to 2021. These are a type of Intermediate Rent lettings.

    +

    Rent to Buy: a discount of up to 20% market rent is charged for a single rental period for a minimum of 5 years. After that period, the tenant is offered first chance to purchase the property (either shared ownership or outright) at full market value. These are a type of Intermediate Rent lettings.

    +

    Social Rent: where target rents are determined through the national rent regime. This is sometimes also known as 'formula rent'.

    +

    Other intermediate rent: any other specific scheme where up to 80% of market rent can be charged. This includes schemes with reduced rent so tenants can save towards a house purchasing deposit and schemes with an in-built future opportunity to buy the property being rented.

    " + + scheme_selection: + data_provider: + content: "If you’re not sure which scheme to choose, ask a data coordinator. Find your data coordinators on the %{users_page_link}." + users_page_link_text: "users page" + data_coordinator: + create_scheme_link_text: "Create a new supported housing scheme" + + void_date: + title: "What is a void date?" + content: "

    Date the property was (legally or contractually) available to let, or for:

    +
      +
    • re-lets: the day after the previous tenant's contract ended
    • +
    • new builds: the day the landlord legally first owned the property (‘completion date’)
    • +
    • new conversions or acquisitions: completion date, or the day after rehabilitation work ended
    • +
    • new leases: the day the landlord got contractual property rights and could let it out to tenants
    • +
    " + + what_counts_as_income: + title: "What counts as income?" + content: "

    You should include any income after tax from:

    +
      +
    • employment
    • +
    • pensions
    • +
    • Universal Credit
    • +
    + +

    Don’t include:

    +
      +
    • National Insurance (NI) contributions and tax
    • +
    • housing benefit
    • +
    • child benefit
    • +
    • council tax support
    • +
    " \ No newline at end of file diff --git a/config/locales/forms/2023/sales/guidance.en.yml b/config/locales/forms/2023/sales/guidance.en.yml new file mode 100644 index 000000000..22e953521 --- /dev/null +++ b/config/locales/forms/2023/sales/guidance.en.yml @@ -0,0 +1,47 @@ +en: + forms: + 2023: + sales: + guidance: + shared_ownership_type_definitions: + title: "Shared Ownership Type Definitions" + content: "

    Shared ownership: Cannot be used for homes funded through the Affordable Homes Programme 2021 to 2026. Use the 2021 model lease for these properties.

    +

    Shared ownership 2021 model lease: Homes bought using the Affordable Homes Programme 2021 to 2026.

    +

    Older Persons Shared Ownership: A type of shared ownership for those 55 years and over.

    +

    Social HomeBuy shared ownership purchase: Tenants of private registered providers purchase their home at discount on Shared Ownership terms.

    +

    >Home Ownership for people with Long-Term Disabilities (HOLD): A shared ownership sale for those with long term disabilities.

    +

    Rent to Buy shared ownership: A sale following a period of discounted rent.

    +

    Right to Shared Ownership: A sale of a share of a rented home to a tenant using this scheme.

    +

    London Living Rent shared ownership: A shared ownership sale following a period of discounted rent as part of the London Living Rent scheme.

    " + + discounted_ownership_type_definitions: + title: "Discounted Ownership Type Definitions" + content: "

    Right to Acquire (RTA): a discounted sale of a property built or purchased after 31 March 1997 to tenants of a private registered provider.

    +

    Preserved Right to Buy (PRTB): a discounted sale of a property that used to be owned by a council to tenants of a private registered provider.

    +

    Voluntary Right to Buy (VRTB): a discounted sale to tenants in this PRP owned property, as part of a pilot scheme.

    +

    Right to Buy (RTB): a discounted sale to tenants in this council owned property.

    +

    Rent to Buy full ownership: a sale on full ownership terms following a period of discounted rent.

    +

    Social HomeBuy for outright purchase: a discounted sale to tenants of a private registered provider on full ownership terms.

    +

    Any other equity loan scheme: any scheme, not covered elsewhere, in which a loan is used to purchase equity.

    " + + mortgage_lender: + title: "Can’t find the mortgage lender you’re looking for?" + content: "
      +
    • Double check the spelling and try again
    • +
    • Type the first few letters to see the suggestions
    • +
    • Type Other and continue - we’ll ask you to type in your answer in the next question
    • +
    " + + outright_sale_type_definitions: + title: "Outright sale type definitions" + content: "

    Outright sale: the full purchase of a property, usually with a mortgage or cash.

    +

    Other sale: any sale which does not fit the criteria of any of the remaining options.

    " + + privacy_notice_buyer_joint_purchase: + content: "Make sure the buyers have seen %{privacy_notice_link} before completing this log." + privacy_notice_link_text: "the Ministry of Housing, Communities and Local Government (MHCLG) privacy notice" + + privacy_notice_buyer: + content: "Make sure the buyer has seen %{privacy_notice_link} before completing this log." + privacy_notice_link_text: "the Ministry of Housing, Communities and Local Government (MHCLG) privacy notice" + \ No newline at end of file diff --git a/config/locales/forms/2024/lettings/guidance.en.yml b/config/locales/forms/2024/lettings/guidance.en.yml new file mode 100644 index 000000000..922124a94 --- /dev/null +++ b/config/locales/forms/2024/lettings/guidance.en.yml @@ -0,0 +1,63 @@ +en: + forms: + 2024: + lettings: + guidance: + finding_location: + title: "What is a location?" + content: "A location is a postcode area where supported housing is provided under a scheme. A scheme can have multiple locations, and a location can have multiple units at the same postcode." + scheme_changes_link_text: "Read more about schemes and locations" + + finding_scheme: + title: "Can’t find your scheme?" + content: "

    Schemes are attached to the organisation that owns the property. Check you have correctly answered question 1 \"Which organisation owns this property?\"

    +

    If your organisation’s schemes were migrated from old CORE, they may have new names and codes. Search by postcode to find your scheme.

    " + scheme_changes_link_text: "Read more about how schemes have changed" + view_schemes_link_text: "View your organisation’s schemes" + + privacy_notice_tenant: + content: "Make sure the lead tenant has seen or been given access to %{privacy_notice_link} before completing this log. This is a legal requirement under data protection legislation." + privacy_notice_link_text: "the Ministry of Housing, Communities and Local Government (MHCLG) privacy notice" + + rent_type_definitions: + title: "Rent type definitions" + content: "

    Social Rent: where target rents are determined through the national rent regime. This is sometimes also known as 'formula rent'.

    +

    Affordable Rent: where up to 80% of market rent can be charged. A new supply agreement is signed with Homes England or the Greater London Authority (GLA).

    +

    London Affordable Rent: a tenure of affordable housing available in London by the GLA. It is an affordable rent which must be set in accordance with the Regulator of Social Housing’s Affordable Rent guidance. The landlord of these homes must be registered with the Regulator of Social Housing. These are a type of Affordable Rent lettings.

    +

    Rent to Buy: a discount of up to 20% market rent is charged for a single rental period for a minimum of 5 years. After that period, the tenant is offered first chance to purchase the property (either shared ownership or outright) at full market value. These are a type of Intermediate Rent lettings.

    +

    London Living Rent: a tenure of affordable housing available in London by the GLA. It was introduced in Affordable Homes Programme 2016 to 2021. These are a type of Intermediate Rent lettings.

    +

    Other intermediate rent: any other specific scheme where up to 80% of market rent can be charged. This includes schemes with reduced rent so tenants can save towards a house purchasing deposit and schemes with an in-built future opportunity to buy the property being rented.

    " + + scheme_selection: + data_provider: + content: "If you’re not sure which scheme to choose, ask a data coordinator. Find your data coordinators on the %{users_page_link}." + users_page_link_text: "users page" + data_coordinator: + create_scheme_link_text: "Create a new supported housing scheme" + + void_date: + title: "What is a void date?" + content: "

    Date the property was (legally or contractually) available to let, or for:

    +
      +
    • re-lets: the day after the previous tenant's contract ended
    • +
    • new builds: the day the landlord legally first owned the property (‘completion date’)
    • +
    • new conversions or acquisitions: completion date, or the day after rehabilitation work ended
    • +
    • new leases: the day the landlord got contractual property rights and could let it out to tenants
    • +
    " + + what_counts_as_income: + title: "What counts as income?" + content: "

    You should include any income after tax from:

    +
      +
    • employment
    • +
    • pensions
    • +
    • Universal Credit
    • +
    + +

    Don’t include:

    +
      +
    • National Insurance (NI) contributions and tax
    • +
    • housing benefit
    • +
    • child benefit
    • +
    • council tax support
    • +
    " \ No newline at end of file diff --git a/config/locales/forms/2024/sales/guidance.en.yml b/config/locales/forms/2024/sales/guidance.en.yml new file mode 100644 index 000000000..801c43a5c --- /dev/null +++ b/config/locales/forms/2024/sales/guidance.en.yml @@ -0,0 +1,46 @@ +en: + forms: + 2024: + sales: + guidance: + shared_ownership_type_definitions: + title: "Shared Ownership Type Definitions" + content: "

    Shared Ownership (old model lease): Cannot be used for homes funded through the Affordable Homes Programme 2021 to 2026. Use the new model lease for these properties.

    +

    Shared Ownership (new model lease): Homes bought using the Affordable Homes Programme 2021 to 2026.

    +

    Social HomeBuy — shared ownership purchase: Tenants of private registered providers purchase their home at discount on Shared Ownership terms.

    +

    Home Ownership for people with Long-Term Disabilities (HOLD): A shared ownership sale for those with long term disabilities.

    +

    Older Persons Shared Ownership: A type of shared ownership for those 55 years and over.

    +

    Rent to Buy — Shared Ownership: A sale following a period of discounted rent.

    +

    Right to Shared Ownership (RtSO): A sale of a share of a rented home to a tenant using this scheme.

    +

    London Living Rent — Shared Ownership: A shared ownership sale following a period of discounted rent as part of the London Living Rent scheme.

    " + + discounted_ownership_type_definitions: + title: "Discounted Ownership Type Definitions" + content: "

    Right to Acquire (RTA): a discounted sale of a property built or purchased after 31 March 1997 to tenants of a private registered provider.

    +

    Preserved Right to Buy (PRTB): a discounted sale of a property that used to be owned by a council to tenants of a private registered provider.

    +

    Voluntary Right to Buy (VRTB): a discounted sale to tenants in this PRP owned property, as part of a pilot scheme.

    +

    Right to Buy (RTB): a discounted sale to tenants in this council owned property.

    +

    Rent to Buy full ownership: a sale on full ownership terms following a period of discounted rent.

    +

    Social HomeBuy for outright purchase: a discounted sale to tenants of a private registered provider on full ownership terms.

    +

    Any other equity loan scheme: any scheme, not covered elsewhere, in which a loan is used to purchase equity.

    " + + mortgage_lender: + title: "Can’t find the mortgage lender you’re looking for?" + content: "
      +
    • Double check the spelling and try again
    • +
    • Type the first few letters to see the suggestions
    • +
    • Type Other and continue - we’ll ask you to type in your answer in the next question
    • +
    " + + outright_sale_type_definitions: + title: "Outright sale type definitions" + content: "

    Outright sale: the full purchase of a property, usually with a mortgage or cash.

    +

    Other sale: any sale which does not fit the criteria of any of the remaining options.

    " + + privacy_notice_buyer_joint_purchase: + content: "Make sure the buyers have seen or been given access to %{privacy_notice_link} before completing this log. This is a legal requirement under data protection legislation." + privacy_notice_link_text: "the Ministry of Housing, Communities and Local Government (MHCLG) privacy notice" + + privacy_notice_buyer: + content: "Make sure the buyer has seen or been given access to %{privacy_notice_link} before completing this log. This is a legal requirement under data protection legislation." + privacy_notice_link_text: "the Ministry of Housing, Communities and Local Government (MHCLG) privacy notice" diff --git a/spec/models/form/lettings/questions/declaration_spec.rb b/spec/models/form/lettings/questions/declaration_spec.rb index bf8743520..fe1ae882d 100644 --- a/spec/models/form/lettings/questions/declaration_spec.rb +++ b/spec/models/form/lettings/questions/declaration_spec.rb @@ -67,7 +67,7 @@ RSpec.describe Form::Lettings::Questions::Declaration, type: :model do end it "uses the expected top guidance partial" do - expect(question.top_guidance_partial).to eq("privacy_notice_tenant_2024") + expect(question.top_guidance_partial).to eq("privacy_notice_tenant") end it "has check_answers_card_number nil" do diff --git a/spec/models/form/lettings/questions/rent_type_spec.rb b/spec/models/form/lettings/questions/rent_type_spec.rb index 15183ce6b..0716cdbf7 100644 --- a/spec/models/form/lettings/questions/rent_type_spec.rb +++ b/spec/models/form/lettings/questions/rent_type_spec.rb @@ -73,7 +73,7 @@ RSpec.describe Form::Lettings::Questions::RentType, type: :model do end it "has the correct guidance partial" do - expect(question.top_guidance_partial).to eq("rent_type_definitions_2024") + expect(question.top_guidance_partial).to eq("rent_type_definitions") end end end diff --git a/spec/models/form/sales/questions/privacy_notice_spec.rb b/spec/models/form/sales/questions/privacy_notice_spec.rb index 48de6056f..3f8c030b0 100644 --- a/spec/models/form/sales/questions/privacy_notice_spec.rb +++ b/spec/models/form/sales/questions/privacy_notice_spec.rb @@ -94,7 +94,7 @@ RSpec.describe Form::Sales::Questions::PrivacyNotice, type: :model do end it "uses the expected top guidance partial" do - expect(question.top_guidance_partial).to eq("privacy_notice_buyer_2024") + expect(question.top_guidance_partial).to eq("privacy_notice_buyer") end it "returns correct unanswered_error_message" do @@ -116,7 +116,7 @@ RSpec.describe Form::Sales::Questions::PrivacyNotice, type: :model do end it "uses the expected top guidance partial" do - expect(question.top_guidance_partial).to eq("privacy_notice_buyer_2024_joint_purchase") + expect(question.top_guidance_partial).to eq("privacy_notice_buyer_joint_purchase") end it "returns correct unanswered_error_message" do diff --git a/spec/models/form/sales/questions/shared_ownership_type_spec.rb b/spec/models/form/sales/questions/shared_ownership_type_spec.rb index 19cae6e89..91cf6da9e 100644 --- a/spec/models/form/sales/questions/shared_ownership_type_spec.rb +++ b/spec/models/form/sales/questions/shared_ownership_type_spec.rb @@ -63,7 +63,7 @@ RSpec.describe Form::Sales::Questions::SharedOwnershipType, type: :model do end it "shows shows correct top_guidance_partial" do - expect(question.top_guidance_partial).to eq("shared_ownership_type_definitions_2024") + expect(question.top_guidance_partial).to eq("shared_ownership_type_definitions") end end end diff --git a/spec/requests/form_controller_spec.rb b/spec/requests/form_controller_spec.rb index 94f6595c7..13d711c20 100644 --- a/spec/requests/form_controller_spec.rb +++ b/spec/requests/form_controller_spec.rb @@ -412,7 +412,7 @@ RSpec.describe FormController, type: :request do context "with a form page that has custom guidance" do it "displays the correct partial" do get "/lettings-logs/#{lettings_log.id}/net-income", headers: headers, params: {} - expect(response.body).to match("What counts as income?") + expect(response.body).to match(I18n.t("forms.2021.lettings.guidance.what_counts_as_income.title")) end end diff --git a/spec/views/form/page_view_spec.rb b/spec/views/form/page_view_spec.rb index 16c4c0672..a95c98e93 100644 --- a/spec/views/form/page_view_spec.rb +++ b/spec/views/form/page_view_spec.rb @@ -100,7 +100,7 @@ RSpec.describe "form/page" do end context "with a question containing extra guidance" do - let(:expected_guidance) { /What counts as income?/ } + let(:expected_guidance) { /#{I18n.t("forms.2021.lettings.guidance.what_counts_as_income.content")}/ } context "with radio type" do let(:question_attributes) { { type: "radio", answer_options: { "1": "A", "2": "B" } } } From 3cda5adf5c83608c9e9ead13447b2d05491760c1 Mon Sep 17 00:00:00 2001 From: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com> Date: Thu, 31 Oct 2024 16:47:40 +0000 Subject: [PATCH 29/30] CLDC-3683 Extract lettings household situation copy (#2730) * Extract lettings household situation copy * Update wrong copy, remove duplicate keys --- .../pages/previous_housing_situation.rb | 1 + .../previous_housing_situation_renewal.rb | 1 + .../pages/previous_local_authority.rb | 1 + .../form/lettings/pages/previous_postcode.rb | 1 + .../reason_for_leaving_last_settled_home.rb | 1 + ...n_for_leaving_last_settled_home_renewal.rb | 1 + app/models/form/lettings/pages/referral.rb | 1 + .../form/lettings/pages/referral_prp.rb | 1 + .../pages/referral_supported_housing.rb | 1 + .../pages/referral_supported_housing_prp.rb | 1 + .../form/lettings/questions/homeless.rb | 3 - app/models/form/lettings/questions/layear.rb | 3 - .../lettings/questions/letting_allocation.rb | 3 - .../form/lettings/questions/ppcodenk.rb | 4 +- .../form/lettings/questions/ppostcode_full.rb | 4 +- .../lettings/questions/previous_la_known.rb | 4 +- .../lettings/questions/previous_tenure.rb | 4 +- .../questions/previous_tenure_renewal.rb | 5 +- app/models/form/lettings/questions/prevloc.rb | 4 +- app/models/form/lettings/questions/reason.rb | 4 +- .../form/lettings/questions/reason_renewal.rb | 4 +- .../questions/reasonable_preference_reason.rb | 3 - .../form/lettings/questions/reasonother.rb | 4 +- .../form/lettings/questions/reasonpref.rb | 3 - .../form/lettings/questions/referral.rb | 4 +- .../form/lettings/questions/referral_prp.rb | 4 +- .../questions/referral_supported_housing.rb | 4 +- .../referral_supported_housing_prp.rb | 4 +- .../form/lettings/questions/waityear.rb | 3 - .../2023/lettings/household_situation.en.yml | 120 ++++++++++++++++++ .../2024/lettings/household_situation.en.yml | 120 ++++++++++++++++++ .../form/lettings/questions/homeless_spec.rb | 2 +- .../lettings/questions/reason_renewal_spec.rb | 2 +- .../form/lettings/questions/reason_spec.rb | 2 +- 34 files changed, 266 insertions(+), 61 deletions(-) create mode 100644 config/locales/forms/2023/lettings/household_situation.en.yml create mode 100644 config/locales/forms/2024/lettings/household_situation.en.yml diff --git a/app/models/form/lettings/pages/previous_housing_situation.rb b/app/models/form/lettings/pages/previous_housing_situation.rb index aafabe7f3..8fc907435 100644 --- a/app/models/form/lettings/pages/previous_housing_situation.rb +++ b/app/models/form/lettings/pages/previous_housing_situation.rb @@ -2,6 +2,7 @@ class Form::Lettings::Pages::PreviousHousingSituation < ::Form::Page def initialize(id, hsh, subsection) super @id = "previous_housing_situation" + @copy_key = "lettings.household_situation.prevten.not_renewal" @depends_on = [{ "is_renewal?" => false }] end diff --git a/app/models/form/lettings/pages/previous_housing_situation_renewal.rb b/app/models/form/lettings/pages/previous_housing_situation_renewal.rb index 317350911..62d37bf33 100644 --- a/app/models/form/lettings/pages/previous_housing_situation_renewal.rb +++ b/app/models/form/lettings/pages/previous_housing_situation_renewal.rb @@ -2,6 +2,7 @@ class Form::Lettings::Pages::PreviousHousingSituationRenewal < ::Form::Page def initialize(id, hsh, subsection) super @id = "previous_housing_situation_renewal" + @copy_key = "lettings.household_situation.prevten.renewal" @depends_on = [{ "is_renewal?" => true, "is_supported_housing?" => true }] end diff --git a/app/models/form/lettings/pages/previous_local_authority.rb b/app/models/form/lettings/pages/previous_local_authority.rb index 48233e64a..30a17448f 100644 --- a/app/models/form/lettings/pages/previous_local_authority.rb +++ b/app/models/form/lettings/pages/previous_local_authority.rb @@ -2,6 +2,7 @@ class Form::Lettings::Pages::PreviousLocalAuthority < ::Form::Page def initialize(id, hsh, subsection) super @id = "previous_local_authority" + @copy_key = "lettings.household_situation.previous_local_authority" @depends_on = [{ "is_previous_la_inferred" => false, "renewal" => 0 }] end diff --git a/app/models/form/lettings/pages/previous_postcode.rb b/app/models/form/lettings/pages/previous_postcode.rb index 61d08f3a9..0bf0d108f 100644 --- a/app/models/form/lettings/pages/previous_postcode.rb +++ b/app/models/form/lettings/pages/previous_postcode.rb @@ -2,6 +2,7 @@ class Form::Lettings::Pages::PreviousPostcode < ::Form::Page def initialize(id, hsh, page) super @depends_on = [{ "renewal" => 0 }] + @copy_key = "lettings.household_situation.previous_postcode" end def questions diff --git a/app/models/form/lettings/pages/reason_for_leaving_last_settled_home.rb b/app/models/form/lettings/pages/reason_for_leaving_last_settled_home.rb index f5e3a24d1..a32dab9a2 100644 --- a/app/models/form/lettings/pages/reason_for_leaving_last_settled_home.rb +++ b/app/models/form/lettings/pages/reason_for_leaving_last_settled_home.rb @@ -2,6 +2,7 @@ class Form::Lettings::Pages::ReasonForLeavingLastSettledHome < ::Form::Page def initialize(id, hsh, subsection) super @id = "reason_for_leaving_last_settled_home" + @copy_key = "lettings.household_situation.reason.reason_for_leaving_last_settled_home" @depends_on = [{ "renewal" => 0 }] end diff --git a/app/models/form/lettings/pages/reason_for_leaving_last_settled_home_renewal.rb b/app/models/form/lettings/pages/reason_for_leaving_last_settled_home_renewal.rb index acc8e7045..0a052b300 100644 --- a/app/models/form/lettings/pages/reason_for_leaving_last_settled_home_renewal.rb +++ b/app/models/form/lettings/pages/reason_for_leaving_last_settled_home_renewal.rb @@ -2,6 +2,7 @@ class Form::Lettings::Pages::ReasonForLeavingLastSettledHomeRenewal < ::Form::Pa def initialize(id, hsh, subsection) super @id = "reason_for_leaving_last_settled_home_renewal" + @copy_key = "lettings.household_situation.reason.reason_for_leaving_last_settled_home_renewal" @depends_on = [{ "renewal" => 1 }] end diff --git a/app/models/form/lettings/pages/referral.rb b/app/models/form/lettings/pages/referral.rb index 9bda8c77e..8b6fcadbb 100644 --- a/app/models/form/lettings/pages/referral.rb +++ b/app/models/form/lettings/pages/referral.rb @@ -2,6 +2,7 @@ class Form::Lettings::Pages::Referral < ::Form::Page def initialize(id, hsh, subsection) super @id = "referral" + @copy_key = "lettings.household_situation.referral.general_needs.la" @depends_on = [{ "owning_organisation_provider_type" => "LA", "needstype" => 1, "renewal" => 0 }] end diff --git a/app/models/form/lettings/pages/referral_prp.rb b/app/models/form/lettings/pages/referral_prp.rb index d9c37b6d6..baeb01784 100644 --- a/app/models/form/lettings/pages/referral_prp.rb +++ b/app/models/form/lettings/pages/referral_prp.rb @@ -2,6 +2,7 @@ class Form::Lettings::Pages::ReferralPrp < ::Form::Page def initialize(id, hsh, subsection) super @id = "referral_prp" + @copy_key = "lettings.household_situation.referral.general_needs.prp" @depends_on = [{ "owning_organisation_provider_type" => "PRP", "needstype" => 1, "renewal" => 0 }] end diff --git a/app/models/form/lettings/pages/referral_supported_housing.rb b/app/models/form/lettings/pages/referral_supported_housing.rb index 8464ae366..a3e915e26 100644 --- a/app/models/form/lettings/pages/referral_supported_housing.rb +++ b/app/models/form/lettings/pages/referral_supported_housing.rb @@ -2,6 +2,7 @@ class Form::Lettings::Pages::ReferralSupportedHousing < ::Form::Page def initialize(id, hsh, subsection) super @id = "referral_supported_housing" + @copy_key = "lettings.household_situation.referral.supported_housing.la" @depends_on = [{ "owning_organisation_provider_type" => "LA", "needstype" => 2, "renewal" => 0 }] end diff --git a/app/models/form/lettings/pages/referral_supported_housing_prp.rb b/app/models/form/lettings/pages/referral_supported_housing_prp.rb index 289ae5eb6..66b6f370e 100644 --- a/app/models/form/lettings/pages/referral_supported_housing_prp.rb +++ b/app/models/form/lettings/pages/referral_supported_housing_prp.rb @@ -2,6 +2,7 @@ class Form::Lettings::Pages::ReferralSupportedHousingPrp < ::Form::Page def initialize(id, hsh, subsection) super @id = "referral_supported_housing_prp" + @copy_key = "lettings.household_situation.referral.supported_housing.prp" @depends_on = [{ "owning_organisation_provider_type" => "PRP", "needstype" => 2, "renewal" => 0 }] end diff --git a/app/models/form/lettings/questions/homeless.rb b/app/models/form/lettings/questions/homeless.rb index 081e1a8cf..1194fa929 100644 --- a/app/models/form/lettings/questions/homeless.rb +++ b/app/models/form/lettings/questions/homeless.rb @@ -2,11 +2,8 @@ class Form::Lettings::Questions::Homeless < ::Form::Question def initialize(id, hsh, page) super @id = "homeless" - @check_answer_label = "Household homeless immediately before letting" - @header = "Did the household experience homelessness immediately before this letting?" @type = "radio" @check_answers_card_number = 0 - @hint_text = "" @answer_options = ANSWER_OPTIONS @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end diff --git a/app/models/form/lettings/questions/layear.rb b/app/models/form/lettings/questions/layear.rb index 5c2e9c195..63f99c36f 100644 --- a/app/models/form/lettings/questions/layear.rb +++ b/app/models/form/lettings/questions/layear.rb @@ -2,11 +2,8 @@ class Form::Lettings::Questions::Layear < ::Form::Question def initialize(id, hsh, page) super @id = "layear" - @check_answer_label = "Length of time in local authority area" - @header = "How long has the household continuously lived in the local authority area of the new letting?" @type = "radio" @check_answers_card_number = 0 - @hint_text = "" @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end diff --git a/app/models/form/lettings/questions/letting_allocation.rb b/app/models/form/lettings/questions/letting_allocation.rb index c9742e97f..0ae7b740d 100644 --- a/app/models/form/lettings/questions/letting_allocation.rb +++ b/app/models/form/lettings/questions/letting_allocation.rb @@ -2,11 +2,8 @@ class Form::Lettings::Questions::LettingAllocation < ::Form::Question def initialize(id, hsh, page) super @id = "letting_allocation" - @check_answer_label = "Allocation system" - @header = "How was this letting allocated?" @type = "checkbox" @check_answers_card_number = 0 - @hint_text = "Select all that apply." @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end diff --git a/app/models/form/lettings/questions/ppcodenk.rb b/app/models/form/lettings/questions/ppcodenk.rb index 4af3b17f0..5eec607eb 100644 --- a/app/models/form/lettings/questions/ppcodenk.rb +++ b/app/models/form/lettings/questions/ppcodenk.rb @@ -2,11 +2,9 @@ class Form::Lettings::Questions::Ppcodenk < ::Form::Question def initialize(id, hsh, page) super @id = "ppcodenk" - @check_answer_label = "" - @header = "Do you know the postcode of the household’s last settled accommodation?" + @copy_key = "lettings.household_situation.previous_postcode.ppcodenk" @type = "radio" @check_answers_card_number = 0 - @hint_text = form.start_year_after_2024? ? "This is the tenant’s last long-standing home. It is where the tenant was living before any period in temporary accommodation, sleeping rough or otherwise homeless." : "This is also known as the household’s ‘last settled home’." @answer_options = ANSWER_OPTIONS @conditional_for = { "ppostcode_full" => [0] } @hidden_in_check_answers = { "depends_on" => [{ "ppcodenk" => 0 }, { "ppcodenk" => 1 }] } diff --git a/app/models/form/lettings/questions/ppostcode_full.rb b/app/models/form/lettings/questions/ppostcode_full.rb index ed0439805..804576ca1 100644 --- a/app/models/form/lettings/questions/ppostcode_full.rb +++ b/app/models/form/lettings/questions/ppostcode_full.rb @@ -2,8 +2,7 @@ class Form::Lettings::Questions::PpostcodeFull < ::Form::Question def initialize(id, hsh, page) super @id = "ppostcode_full" - @check_answer_label = "Postcode of household’s last settled accommodation" - @header = "Postcode for the previous accommodation" + @copy_key = "lettings.household_situation.previous_postcode.ppostcode_full" @type = "text" @width = 5 @inferred_check_answers_value = [{ @@ -13,7 +12,6 @@ class Form::Lettings::Questions::PpostcodeFull < ::Form::Question "value" => "Not known", }] @check_answers_card_number = 0 - @hint_text = "" @inferred_answers = { "prevloc" => { "is_previous_la_inferred" => true } } @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] @disable_clearing_if_not_routed_or_dynamic_answer_options = true diff --git a/app/models/form/lettings/questions/previous_la_known.rb b/app/models/form/lettings/questions/previous_la_known.rb index d99c1e057..2145e9d1f 100644 --- a/app/models/form/lettings/questions/previous_la_known.rb +++ b/app/models/form/lettings/questions/previous_la_known.rb @@ -2,11 +2,9 @@ class Form::Lettings::Questions::PreviousLaKnown < ::Form::Question def initialize(id, hsh, page) super @id = "previous_la_known" - @check_answer_label = "Do you know the local authority of the household’s last settled accommodation?" - @header = "Do you know the local authority of the household’s last settled accommodation?" + @copy_key = "lettings.household_situation.previous_local_authority.previous_la_known" @type = "radio" @check_answers_card_number = 0 - @hint_text = form.start_year_after_2024? ? "This is the tenant’s last long-standing home. It is where the tenant was living before any period in temporary accommodation, sleeping rough or otherwise homeless." : "This is also known as the household’s ‘last settled home’." @answer_options = ANSWER_OPTIONS @conditional_for = { "prevloc" => [1] } @hidden_in_check_answers = { "depends_on" => [{ "previous_la_known" => 0 }, { "previous_la_known" => 1 }] } diff --git a/app/models/form/lettings/questions/previous_tenure.rb b/app/models/form/lettings/questions/previous_tenure.rb index a9ed5202a..360f1960a 100644 --- a/app/models/form/lettings/questions/previous_tenure.rb +++ b/app/models/form/lettings/questions/previous_tenure.rb @@ -2,11 +2,9 @@ class Form::Lettings::Questions::PreviousTenure < ::Form::Question def initialize(id, hsh, page) super @id = "prevten" - @check_answer_label = "Where was the household immediately before this letting?" - @header = "Where was the household immediately before this letting?" + @copy_key = "lettings.household_situation.prevten.not_renewal" @type = "radio" @check_answers_card_number = 0 - @hint_text = "This is where the household was the night before they moved into this new let." @answer_options = ANSWER_OPTIONS @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end diff --git a/app/models/form/lettings/questions/previous_tenure_renewal.rb b/app/models/form/lettings/questions/previous_tenure_renewal.rb index d4849d3c2..c882eb6fe 100644 --- a/app/models/form/lettings/questions/previous_tenure_renewal.rb +++ b/app/models/form/lettings/questions/previous_tenure_renewal.rb @@ -2,12 +2,9 @@ class Form::Lettings::Questions::PreviousTenureRenewal < ::Form::Question def initialize(id, hsh, page) super @id = "prevten" - @check_answer_label = "Where was the household immediately before this letting?" - @header = "Where was the household immediately before this letting?" + @copy_key = "lettings.household_situation.prevten.renewal" @type = "radio" @check_answers_card_number = 0 - @hint_text = "You told us this letting is a renewal. We have removed some options because of this.

    - This is where the household was the night before they moved into this new let." @answer_options = ANSWER_OPTIONS @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end diff --git a/app/models/form/lettings/questions/prevloc.rb b/app/models/form/lettings/questions/prevloc.rb index 7f9c0db8b..4ad7dbf11 100644 --- a/app/models/form/lettings/questions/prevloc.rb +++ b/app/models/form/lettings/questions/prevloc.rb @@ -2,12 +2,10 @@ class Form::Lettings::Questions::Prevloc < ::Form::Question def initialize(id, hsh, page) super @id = "prevloc" - @check_answer_label = "Location of household’s last settled accommodation" - @header = "Select a local authority" + @copy_key = "lettings.household_situation.previous_local_authority.prevloc" @type = "select" @inferred_check_answers_value = [{ "condition" => { "previous_la_known" => 0 }, "value" => "Not known" }] @check_answers_card_number = 0 - @hint_text = "Select ‘Northern Ireland’, ‘Scotland’, ‘Wales’ or ‘Outside the UK’ if the household’s last settled home was outside England." @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] @disable_clearing_if_not_routed_or_dynamic_answer_options = true end diff --git a/app/models/form/lettings/questions/reason.rb b/app/models/form/lettings/questions/reason.rb index 223d68634..4bc00ce43 100644 --- a/app/models/form/lettings/questions/reason.rb +++ b/app/models/form/lettings/questions/reason.rb @@ -2,11 +2,9 @@ class Form::Lettings::Questions::Reason < ::Form::Question def initialize(id, hsh, page) super @id = "reason" - @check_answer_label = "Reason for leaving last settled home" - @header = "What is the tenant’s main reason for the household leaving their last settled home?" + @copy_key = "lettings.household_situation.reason.#{page.id}.reason" @type = "radio" @check_answers_card_number = 0 - @hint_text = form.start_year_after_2024? ? "The tenant’s ‘last settled home’ is their last long-standing home. For tenants who were in temporary accommodation, sleeping rough or otherwise homeless, their last settled home is where they were living previously." : "The tenant’s ‘last settled home’ is their last long-standing home. For tenants who were in temporary accommodation or sleeping rough, their last settled home is where they were living previously." @conditional_for = { "reasonother" => [ 20, diff --git a/app/models/form/lettings/questions/reason_renewal.rb b/app/models/form/lettings/questions/reason_renewal.rb index 7f32b0bba..9a9ee72de 100644 --- a/app/models/form/lettings/questions/reason_renewal.rb +++ b/app/models/form/lettings/questions/reason_renewal.rb @@ -2,11 +2,9 @@ class Form::Lettings::Questions::ReasonRenewal < ::Form::Question def initialize(id, hsh, page) super @id = "reason" - @check_answer_label = "Reason for leaving last settled home" - @header = "What is the tenant’s main reason for the household leaving their last settled home?" @type = "radio" + @copy_key = "lettings.household_situation.reason.#{page.id}.reason" @check_answers_card_number = 0 - @hint_text = "You told us this letting is a renewal. We have removed some options because of this." @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] @conditional_for = { "reasonother" => [ diff --git a/app/models/form/lettings/questions/reasonable_preference_reason.rb b/app/models/form/lettings/questions/reasonable_preference_reason.rb index 235cf6342..75b450b91 100644 --- a/app/models/form/lettings/questions/reasonable_preference_reason.rb +++ b/app/models/form/lettings/questions/reasonable_preference_reason.rb @@ -2,11 +2,8 @@ class Form::Lettings::Questions::ReasonablePreferenceReason < ::Form::Question def initialize(id, hsh, page) super @id = "reasonable_preference_reason" - @check_answer_label = "Reason for reasonable preference" - @header = "Why was the household given ‘reasonable preference’?" @type = "checkbox" @check_answers_card_number = 0 - @hint_text = "Select all that apply." @answer_options = ANSWER_OPTIONS @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end diff --git a/app/models/form/lettings/questions/reasonother.rb b/app/models/form/lettings/questions/reasonother.rb index 37bfd8c7b..7e600916b 100644 --- a/app/models/form/lettings/questions/reasonother.rb +++ b/app/models/form/lettings/questions/reasonother.rb @@ -2,11 +2,9 @@ class Form::Lettings::Questions::Reasonother < ::Form::Question def initialize(id, hsh, page) super @id = "reasonother" - @check_answer_label = "" - @header = "What is the reason?" + @copy_key = "lettings.household_situation.reason.#{@page.id}.reasonother" @type = "text" @check_answers_card_number = 0 - @hint_text = "" @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end diff --git a/app/models/form/lettings/questions/reasonpref.rb b/app/models/form/lettings/questions/reasonpref.rb index 522576ec6..e63f65584 100644 --- a/app/models/form/lettings/questions/reasonpref.rb +++ b/app/models/form/lettings/questions/reasonpref.rb @@ -2,11 +2,8 @@ class Form::Lettings::Questions::Reasonpref < ::Form::Question def initialize(id, hsh, page) super @id = "reasonpref" - @check_answer_label = "Household given reasonable preference" - @header = "Was the household given ‘reasonable preference’ by the local authority?" @type = "radio" @check_answers_card_number = 0 - @hint_text = form.start_year_after_2024? ? "Households may be given ‘reasonable preference’ for social housing under one or more specific categories by the local authority. This is also known as ‘priority need’." : "Households may be given ‘reasonable preference’ for social housing, also known as ‘priority need’, by the local authority." @answer_options = ANSWER_OPTIONS @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end diff --git a/app/models/form/lettings/questions/referral.rb b/app/models/form/lettings/questions/referral.rb index feb0082f4..904668a4b 100644 --- a/app/models/form/lettings/questions/referral.rb +++ b/app/models/form/lettings/questions/referral.rb @@ -2,11 +2,9 @@ class Form::Lettings::Questions::Referral < ::Form::Question def initialize(id, hsh, page) super @id = "referral" - @check_answer_label = "Source of referral for letting" - @header = "What was the source of referral for this letting?" + @copy_key = "lettings.household_situation.referral.general_needs.la" @type = "radio" @check_answers_card_number = 0 - @hint_text = "You told us that you are a local authority and that the needs type is general needs. We have removed some options because of this." @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end diff --git a/app/models/form/lettings/questions/referral_prp.rb b/app/models/form/lettings/questions/referral_prp.rb index 6a8fa63de..76ad3fbf8 100644 --- a/app/models/form/lettings/questions/referral_prp.rb +++ b/app/models/form/lettings/questions/referral_prp.rb @@ -2,11 +2,9 @@ class Form::Lettings::Questions::ReferralPrp < ::Form::Question def initialize(id, hsh, page) super @id = "referral" - @check_answer_label = "Source of referral for letting" - @header = "What was the source of referral for this letting?" + @copy_key = "lettings.household_situation.referral.general_needs.prp" @type = "radio" @check_answers_card_number = 0 - @hint_text = "You told us that the needs type is general needs. We have removed some options because of this." @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end diff --git a/app/models/form/lettings/questions/referral_supported_housing.rb b/app/models/form/lettings/questions/referral_supported_housing.rb index d9ede5a83..50822705e 100644 --- a/app/models/form/lettings/questions/referral_supported_housing.rb +++ b/app/models/form/lettings/questions/referral_supported_housing.rb @@ -2,11 +2,9 @@ class Form::Lettings::Questions::ReferralSupportedHousing < ::Form::Question def initialize(id, hsh, page) super @id = "referral" - @check_answer_label = "Source of referral for letting" - @header = "What was the source of referral for this letting?" + @copy_key = "lettings.household_situation.referral.supported_housing.la" @type = "radio" @check_answers_card_number = 0 - @hint_text = "You told us that you are a local authority. We have removed some options because of this." @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end diff --git a/app/models/form/lettings/questions/referral_supported_housing_prp.rb b/app/models/form/lettings/questions/referral_supported_housing_prp.rb index ffdd7eafb..cab8fbbc9 100644 --- a/app/models/form/lettings/questions/referral_supported_housing_prp.rb +++ b/app/models/form/lettings/questions/referral_supported_housing_prp.rb @@ -2,11 +2,9 @@ class Form::Lettings::Questions::ReferralSupportedHousingPrp < ::Form::Question def initialize(id, hsh, page) super @id = "referral" - @check_answer_label = "Source of referral for letting" - @header = "What was the source of referral for this letting?" + @copy_key = "lettings.household_situation.referral.supported_housing.prp" @type = "radio" @check_answers_card_number = 0 - @hint_text = "" @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end diff --git a/app/models/form/lettings/questions/waityear.rb b/app/models/form/lettings/questions/waityear.rb index 94187e62b..045765951 100644 --- a/app/models/form/lettings/questions/waityear.rb +++ b/app/models/form/lettings/questions/waityear.rb @@ -2,11 +2,8 @@ class Form::Lettings::Questions::Waityear < ::Form::Question def initialize(id, hsh, page) super @id = "waityear" - @check_answer_label = "Length of time on local authority waiting list" - @header = form.start_year_after_2024? ? "How long has the household been on the local authority waiting list for the area of the new letting?" : "How long has the household been on the local authority waiting list for the new letting?" @type = "radio" @check_answers_card_number = 0 - @hint_text = "" @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end diff --git a/config/locales/forms/2023/lettings/household_situation.en.yml b/config/locales/forms/2023/lettings/household_situation.en.yml new file mode 100644 index 000000000..9e5e50918 --- /dev/null +++ b/config/locales/forms/2023/lettings/household_situation.en.yml @@ -0,0 +1,120 @@ +en: + forms: + 2023: + lettings: + household_situation: + layear: + page_header: "" + check_answer_label: "Length of time in local authority area" + hint_text: "" + question_text: "How long has the household continuously lived in the local authority area of the new letting?" + + waityear: + page_header: "" + check_answer_label: "Length of time on local authority waiting list" + hint_text: "" + question_text: "How long has the household been on the local authority waiting list for the new letting?" + + reason: + reason_for_leaving_last_settled_home_renewal: + page_header: "" + reason: + check_answer_label: "Reason for leaving last settled home" + hint_text: "You told us this letting is a renewal. We have removed some options because of this." + question_text: "What is the tenant’s main reason for the household leaving their last settled home?" + reasonother: + check_answer_label: "Length of time on local authority waiting list" + hint_text: "" + question_text: "How long has the household been on the local authority waiting list for the new letting?" + reason_for_leaving_last_settled_home: + page_header: "" + reason: + check_answer_label: "Reason for leaving last settled home" + hint_text: "The tenant’s ‘last settled home’ is their last long-standing home. For tenants who were in temporary accommodation or sleeping rough, their last settled home is where they were living previously." + question_text: "What is the tenant’s main reason for the household leaving their last settled home?" + reasonother: + check_answer_label: "" + hint_text: "" + question_text: "What is the reason?" + + prevten: + renewal: + page_header: "" + check_answer_label: "Where was the household immediately before this letting?" + hint_text: "You told us this letting is a renewal. We have removed some options because of this.

    This is where the household was the night before they moved into this new let." + question_text: "Where was the household immediately before this letting?" + not_renewal: + page_header: "" + check_answer_label: "Where was the household immediately before this letting?" + hint_text: "This is where the household was the night before they moved into this new let." + question_text: "Where was the household immediately before this letting?" + + homeless: + page_header: "" + check_answer_label: "Household homeless immediately before letting" + hint_text: "" + question_text: "Did the household experience homelessness immediately before this letting?" + + previous_postcode: + page_header: "" + ppcodenk: + check_answer_label: "" + hint_text: "This is also known as the household’s ‘last settled home’." + question_text: "Do you know the postcode of the household’s last settled accommodation?" + ppostcode_full: + check_answer_label: "Postcode of household’s last settled accommodation" + hint_text: "" + question_text: "Postcode for the previous accommodation" + + previous_local_authority: + page_header: "" + previous_la_known: + check_answer_label: "" + hint_text: "This is also known as the household’s ‘last settled home’." + question_text: "Do you know the local authority of the household’s last settled accommodation?" + prevloc: + check_answer_label: "Location of household’s last settled accommodation" + hint_text: "Select ‘Northern Ireland’, ‘Scotland’, ‘Wales’ or ‘Outside the UK’ if the household’s last settled home was outside England." + question_text: "Select a local authority" + + reasonpref: + page_header: "" + check_answer_label: "Household given reasonable preference" + hint_text: "Households may be given ‘reasonable preference’ for social housing, also known as ‘priority need’, by the local authority." + question_text: "Was the household given ‘reasonable preference’ by the local authority?" + + reasonable_preference_reason: + page_header: "" + check_answer_label: "Reason for reasonable preference" + hint_text: "Select all that apply." + question_text: "Why was the household given ‘reasonable preference’?" + + letting_allocation: + page_header: "" + check_answer_label: "Allocation system" + hint_text: "Select all that apply." + question_text: "How was this letting allocated?" + + referral: + supported_housing: + prp: + page_header: "" + check_answer_label: "Source of referral for letting" + hint_text: "" + question_text: "What was the source of referral for this letting?" + la: + page_header: "" + check_answer_label: "Source of referral for letting" + hint_text: "You told us that you are a local authority. We have removed some options because of this." + question_text: "What was the source of referral for this letting?" + general_needs: + prp: + page_header: "" + check_answer_label: "Source of referral for letting" + hint_text: "You told us that the needs type is general needs. We have removed some options because of this." + question_text: "What was the source of referral for this letting?" + la: + page_header: "" + check_answer_label: "Source of referral for letting" + hint_text: "You told us that you are a local authority and that the needs type is general needs. We have removed some options because of this." + question_text: "What was the source of referral for this letting?" \ No newline at end of file diff --git a/config/locales/forms/2024/lettings/household_situation.en.yml b/config/locales/forms/2024/lettings/household_situation.en.yml new file mode 100644 index 000000000..e1bf4c0ce --- /dev/null +++ b/config/locales/forms/2024/lettings/household_situation.en.yml @@ -0,0 +1,120 @@ +en: + forms: + 2024: + lettings: + household_situation: + layear: + page_header: "" + check_answer_label: "Length of time in local authority area" + hint_text: "" + question_text: "How long has the household continuously lived in the local authority area of the new letting?" + + waityear: + page_header: "" + check_answer_label: "Length of time on local authority waiting list" + hint_text: "" + question_text: "How long has the household been on the local authority waiting list for the area of the new letting?" + + reason: + reason_for_leaving_last_settled_home_renewal: + page_header: "" + reason: + check_answer_label: "Reason for leaving last settled home" + hint_text: "You told us this letting is a renewal. We have removed some options because of this." + question_text: "What is the tenant’s main reason for the household leaving their last settled home?" + reasonother: + check_answer_label: "Length of time on local authority waiting list" + hint_text: "" + question_text: "How long has the household been on the local authority waiting list for the area of the new letting?" + reason_for_leaving_last_settled_home: + page_header: "" + reason: + check_answer_label: "Reason for leaving last settled home" + hint_text: "The tenant’s ‘last settled home’ is their last long-standing home. For tenants who were in temporary accommodation, sleeping rough or otherwise homeless, their last settled home is where they were living previously." + question_text: "What is the tenant’s main reason for the household leaving their last settled home?" + reasonother: + check_answer_label: "" + hint_text: "" + question_text: "What is the reason?" + + prevten: + renewal: + page_header: "" + check_answer_label: "Where was the household immediately before this letting?" + hint_text: "You told us this letting is a renewal. We have removed some options because of this.

    This is where the household was the night before they moved into this new let." + question_text: "Where was the household immediately before this letting?" + not_renewal: + page_header: "" + check_answer_label: "Where was the household immediately before this letting?" + hint_text: "This is where the household was the night before they moved into this new let." + question_text: "Where was the household immediately before this letting?" + + homeless: + page_header: "" + check_answer_label: "Household homeless immediately before letting" + hint_text: "" + question_text: "Did the household experience homelessness immediately before this letting?" + + previous_postcode: + page_header: "" + ppcodenk: + check_answer_label: "" + hint_text: "This is the tenant’s last long-standing home. It is where the tenant was living before any period in temporary accommodation, sleeping rough or otherwise homeless." + question_text: "Do you know the postcode of the household’s last settled accommodation?" + ppostcode_full: + check_answer_label: "Postcode of household’s last settled accommodation" + hint_text: "" + question_text: "Postcode for the previous accommodation" + + previous_local_authority: + page_header: "" + previous_la_known: + check_answer_label: "" + hint_text: "This is the tenant’s last long-standing home. It is where the tenant was living before any period in temporary accommodation, sleeping rough or otherwise homeless." + question_text: "Do you know the local authority of the household’s last settled accommodation?" + prevloc: + check_answer_label: "Location of household’s last settled accommodation" + hint_text: "Select ‘Northern Ireland’, ‘Scotland’, ‘Wales’ or ‘Outside the UK’ if the household’s last settled home was outside England." + question_text: "Select a local authority" + + reasonpref: + page_header: "" + check_answer_label: "Household given reasonable preference" + hint_text: "Households may be given ‘reasonable preference’ for social housing under one or more specific categories by the local authority. This is also known as ‘priority need’." + question_text: "Was the household given ‘reasonable preference’ by the local authority?" + + reasonable_preference_reason: + page_header: "" + check_answer_label: "Reason for reasonable preference" + hint_text: "Select all that apply." + question_text: "Why was the household given ‘reasonable preference’?" + + letting_allocation: + page_header: "" + check_answer_label: "Allocation system" + hint_text: "Select all that apply." + question_text: "How was this letting allocated?" + + referral: + supported_housing: + prp: + page_header: "" + check_answer_label: "Source of referral for letting" + hint_text: "" + question_text: "What was the source of referral for this letting?" + la: + page_header: "" + check_answer_label: "Source of referral for letting" + hint_text: "You told us that you are a local authority. We have removed some options because of this." + question_text: "What was the source of referral for this letting?" + general_needs: + prp: + page_header: "" + check_answer_label: "Source of referral for letting" + hint_text: "You told us that the needs type is general needs. We have removed some options because of this." + question_text: "What was the source of referral for this letting?" + la: + page_header: "" + check_answer_label: "Source of referral for letting" + hint_text: "You told us that you are a local authority and that the needs type is general needs. We have removed some options because of this." + question_text: "What was the source of referral for this letting?" \ No newline at end of file diff --git a/spec/models/form/lettings/questions/homeless_spec.rb b/spec/models/form/lettings/questions/homeless_spec.rb index 40beb9698..f18a8ece7 100644 --- a/spec/models/form/lettings/questions/homeless_spec.rb +++ b/spec/models/form/lettings/questions/homeless_spec.rb @@ -3,7 +3,7 @@ require "rails_helper" RSpec.describe Form::Lettings::Questions::Homeless, type: :model do subject(:question) { described_class.new(nil, nil, page) } - let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 4)))) } + let(:page) { instance_double(Form::Page, subsection: instance_double(Form::Subsection, form: instance_double(Form, start_date: Time.zone.local(2023, 4, 4), type: "lettings"), id: "household_situation")) } it "has correct page" do expect(question.page).to eq(page) diff --git a/spec/models/form/lettings/questions/reason_renewal_spec.rb b/spec/models/form/lettings/questions/reason_renewal_spec.rb index 02abe1527..3cdff75e7 100644 --- a/spec/models/form/lettings/questions/reason_renewal_spec.rb +++ b/spec/models/form/lettings/questions/reason_renewal_spec.rb @@ -5,7 +5,7 @@ RSpec.describe Form::Lettings::Questions::ReasonRenewal, type: :model do let(:question_id) { nil } let(:question_definition) { nil } - let(:page) { instance_double(Form::Page) } + let(:page) { instance_double(Form::Page, id: "reason_renewal") } let(:subsection) { instance_double(Form::Subsection) } let(:form) { instance_double(Form, start_date: Time.zone.local(2023, 4, 1)) } diff --git a/spec/models/form/lettings/questions/reason_spec.rb b/spec/models/form/lettings/questions/reason_spec.rb index 81fd7a5c1..0b82eca42 100644 --- a/spec/models/form/lettings/questions/reason_spec.rb +++ b/spec/models/form/lettings/questions/reason_spec.rb @@ -5,7 +5,7 @@ RSpec.describe Form::Lettings::Questions::Reason, type: :model do let(:question_id) { nil } let(:question_definition) { nil } - let(:page) { instance_double(Form::Page) } + let(:page) { instance_double(Form::Page, id: "reason") } let(:subsection) { instance_double(Form::Subsection) } let(:form) { instance_double(Form, start_date: Time.zone.local(2023, 4, 1)) } From 85859407698db9c29211a176e33d5d89283b629c Mon Sep 17 00:00:00 2001 From: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com> Date: Thu, 31 Oct 2024 17:07:50 +0000 Subject: [PATCH 30/30] CLDC-3365 Validate BU file size (#2725) * Validate BU file size * Rebase update * Update error messages --- .../bulk_upload_lettings/upload_your_file.rb | 11 ++++++++++ .../bulk_upload_sales/upload_your_file.rb | 11 ++++++++++ config/locales/en.yml | 2 ++ .../bulk_upload_lettings_logs_spec.rb | 19 ++++++++++++++++++ spec/features/bulk_upload_sales_logs_spec.rb | 20 +++++++++++++++++++ 5 files changed, 63 insertions(+) diff --git a/app/models/forms/bulk_upload_lettings/upload_your_file.rb b/app/models/forms/bulk_upload_lettings/upload_your_file.rb index 82b5c75d5..552710885 100644 --- a/app/models/forms/bulk_upload_lettings/upload_your_file.rb +++ b/app/models/forms/bulk_upload_lettings/upload_your_file.rb @@ -15,6 +15,7 @@ module Forms validates :file, presence: true validate :validate_file_is_csv + validate :validate_file_size def view_path "bulk_upload_lettings_logs/forms/upload_your_file" @@ -73,6 +74,16 @@ module Forms errors.add(:file, :not_csv) end end + + MAX_FILE_SIZE = 10.megabytes + + def validate_file_size + return unless file + + if file.size > MAX_FILE_SIZE + errors.add(:file, :file_too_large) + end + end end end end diff --git a/app/models/forms/bulk_upload_sales/upload_your_file.rb b/app/models/forms/bulk_upload_sales/upload_your_file.rb index 83ce04e10..447574d1a 100644 --- a/app/models/forms/bulk_upload_sales/upload_your_file.rb +++ b/app/models/forms/bulk_upload_sales/upload_your_file.rb @@ -14,6 +14,7 @@ module Forms validates :file, presence: true validate :validate_file_is_csv + validate :validate_file_size def view_path "bulk_upload_sales_logs/forms/upload_your_file" @@ -67,6 +68,16 @@ module Forms errors.add(:file, :not_csv) end end + + MAX_FILE_SIZE = 10.megabytes + + def validate_file_size + return unless file + + if file.size > MAX_FILE_SIZE + errors.add(:file, :file_too_large) + end + end end end end diff --git a/config/locales/en.yml b/config/locales/en.yml index 106ccb9fa..4ef35d19e 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -90,11 +90,13 @@ en: file: blank: "Select which file to upload." not_csv: "Your file must be in CSV format." + file_too_large: "File must be 10MB or less. Check your file and delete data that does not need to be uploaded." forms/bulk_upload_sales/upload_your_file: attributes: file: blank: "Select which file to upload." not_csv: "Your file must be in CSV format." + file_too_large: "File must be 10MB or less. Check your file and delete data that does not need to be uploaded." forms/bulk_upload_lettings/needstype: attributes: needstype: diff --git a/spec/features/bulk_upload_lettings_logs_spec.rb b/spec/features/bulk_upload_lettings_logs_spec.rb index 315e1461e..b3e403cbf 100644 --- a/spec/features/bulk_upload_lettings_logs_spec.rb +++ b/spec/features/bulk_upload_lettings_logs_spec.rb @@ -74,6 +74,25 @@ RSpec.describe "Bulk upload lettings log" do expect(page).to have_content("Upload lettings logs in bulk") end + + it "shows file to large error" do + stub_const("Forms::BulkUploadLettings::UploadYourFile::MAX_FILE_SIZE", 1.bytes) + visit("/lettings-logs") + + click_link("Upload lettings logs in bulk") + expect(page).to have_content("Which year") + click_button("Continue") + choose(current_formatted_year) + click_button("Continue") + click_button("Continue") + + allow_any_instance_of(Forms::BulkUploadLettings::UploadYourFile).to receive(:`).and_return("text/csv") + + attach_file "file", file_fixture("2023_24_lettings_bulk_upload.xlsx") + click_button("Upload") + + expect(page).to have_content("File must be 10MB or less. Check your file and delete data that does not need to be uploaded.") + end end # rubocop:enable RSpec/AnyInstance diff --git a/spec/features/bulk_upload_sales_logs_spec.rb b/spec/features/bulk_upload_sales_logs_spec.rb index b7098999d..b32df43e1 100644 --- a/spec/features/bulk_upload_sales_logs_spec.rb +++ b/spec/features/bulk_upload_sales_logs_spec.rb @@ -71,6 +71,26 @@ RSpec.describe "Bulk upload sales log" do expect(page).to have_content("Upload sales logs in bulk") end + + it "shows file to large error" do + stub_const("Forms::BulkUploadSales::UploadYourFile::MAX_FILE_SIZE", 1.bytes) + visit("/sales-logs") + click_link("Upload sales logs in bulk") + + expect(page).to have_content("Which year") + click_button("Continue") + click_button("Continue") + choose("2023 to 2024") + click_button("Continue") + click_button("Continue") + + allow_any_instance_of(Forms::BulkUploadSales::UploadYourFile).to receive(:`).and_return("text/csv") + + attach_file "file", file_fixture("2023_24_lettings_bulk_upload.xlsx") + click_button("Upload") + + expect(page).to have_content("File must be 10MB or less. Check your file and delete data that does not need to be uploaded.") + end end # rubocop:enable RSpec/AnyInstance