diff --git a/.github/workflows/staging_pipeline.yml b/.github/workflows/staging_pipeline.yml index 8c0553741..e5447f4ef 100644 --- a/.github/workflows/staging_pipeline.yml +++ b/.github/workflows/staging_pipeline.yml @@ -8,6 +8,7 @@ on: types: - opened - synchronize + merge_group: workflow_dispatch: defaults: diff --git a/app/components/create_log_actions_component.html.erb b/app/components/create_log_actions_component.html.erb index 8af78b169..53e2bb57b 100644 --- a/app/components/create_log_actions_component.html.erb +++ b/app/components/create_log_actions_component.html.erb @@ -1,11 +1,11 @@ +
diff --git a/app/helpers/filters_helper.rb b/app/helpers/filters_helper.rb index 35fea17e9..3a4c337ea 100644 --- a/app/helpers/filters_helper.rb +++ b/app/helpers/filters_helper.rb @@ -143,7 +143,11 @@ module FiltersHelper } if FormHandler.instance.in_crossover_period? - return years.merge({ archived_collection_start_year.to_s => year_combo(archived_collection_start_year) }) + years = years.merge({ archived_collection_start_year.to_s => year_combo(archived_collection_start_year) }) + end + + if FeatureToggle.allow_future_form_use? + years = { next_collection_start_year.to_s => year_combo(next_collection_start_year) }.merge(years) end years diff --git a/app/helpers/interruption_screen_helper.rb b/app/helpers/interruption_screen_helper.rb index b28c7eaa9..e4c09a050 100644 --- a/app/helpers/interruption_screen_helper.rb +++ b/app/helpers/interruption_screen_helper.rb @@ -1,6 +1,7 @@ module InterruptionScreenHelper def display_informative_text(informative_text, log) return informative_text if informative_text.is_a? String + return "" if informative_text.blank? return "" unless informative_text["arguments"] translation_params = {} diff --git a/app/models/bulk_upload.rb b/app/models/bulk_upload.rb index 93f661225..a0ed265c9 100644 --- a/app/models/bulk_upload.rb +++ b/app/models/bulk_upload.rb @@ -32,6 +32,8 @@ class BulkUpload < ApplicationRecord scope :filter_by_user, ->(user_id, _user = nil) { user_id.present? ? where(user_id:) : all } scope :filter_by_uploading_organisation, ->(organisation_id, _user = nil) { where(organisation_id:) } + has_paper_trail + def completed? incomplete_logs = logs.where.not(status: "completed") !incomplete_logs.exists? diff --git a/app/models/derived_variables/lettings_log_variables.rb b/app/models/derived_variables/lettings_log_variables.rb index e50161188..9219392f7 100644 --- a/app/models/derived_variables/lettings_log_variables.rb +++ b/app/models/derived_variables/lettings_log_variables.rb @@ -65,7 +65,7 @@ module DerivedVariables::LettingsLogVariables self.has_benefits = get_has_benefits self.tshortfall_known = 0 if tshortfall self.nocharge = household_charge&.zero? ? 1 : 0 - if form.start_year_after_2024? && is_bedsit? + if form.start_year_2024_or_later? && is_bedsit? self.beds = 1 end @@ -186,7 +186,7 @@ private self.wchair = nil self.location_id = nil end - if form.start_year_after_2024? && (unittype_gn_changed? && unittype_gn_was == 2) + if form.start_year_2024_or_later? && (unittype_gn_changed? && unittype_gn_was == 2) self.beds = nil end end diff --git a/app/models/derived_variables/sales_log_variables.rb b/app/models/derived_variables/sales_log_variables.rb index f23f9eb28..a1462454c 100644 --- a/app/models/derived_variables/sales_log_variables.rb +++ b/app/models/derived_variables/sales_log_variables.rb @@ -29,7 +29,7 @@ module DerivedVariables::SalesLogVariables end end - if saledate && form.start_year_after_2024? && discounted_ownership_sale? + if saledate && form.start_year_2024_or_later? && discounted_ownership_sale? self.ppostcode_full = postcode_full self.ppcodenk = pcodenk self.prevloc = la @@ -44,7 +44,7 @@ module DerivedVariables::SalesLogVariables self.hhmemb = number_of_household_members self.hhtype = household_type - if saledate && form.start_year_after_2024? + if saledate && form.start_year_2024_or_later? self.soctenant = soctenant_from_prevten_values child_under_16_constraints! end @@ -68,6 +68,10 @@ module DerivedVariables::SalesLogVariables self.la = nil end + if form.start_year_2025_or_later? && is_bedsit? + self.beds = 1 + end + self.nationality_all = nationality_all_group if nationality_uk_or_prefers_not_to_say? self.nationality_all_buyer2 = nationality_all_buyer2_group if nationality2_uk_or_prefers_not_to_say? diff --git a/app/models/form.rb b/app/models/form.rb index 4336376e6..ce77378ca 100644 --- a/app/models/form.rb +++ b/app/models/form.rb @@ -334,7 +334,11 @@ class Form type == "sales" || (start_year && start_year.to_i > 2022) end - def start_year_after_2024? + def start_year_2024_or_later? start_date && start_date.year >= 2024 end + + def start_year_2025_or_later? + start_date && start_date.year >= 2025 + end end diff --git a/app/models/form/lettings/pages/care_home_charges_value_check.rb b/app/models/form/lettings/pages/care_home_charges_value_check.rb index 2cf253bf6..78e598e86 100644 --- a/app/models/form/lettings/pages/care_home_charges_value_check.rb +++ b/app/models/form/lettings/pages/care_home_charges_value_check.rb @@ -2,11 +2,15 @@ class Form::Lettings::Pages::CareHomeChargesValueCheck < ::Form::Page def initialize(id, hsh, subsection) super @id = "care_home_charges_value_check" + @copy_key = "lettings.soft_validations.care_home_charges_value_check" @depends_on = [{ "care_home_charge_expected_not_provided?" => true }] @title_text = { - "translation" => "soft_validations.care_home_charges.title_text", + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text", + } + @informative_text = { + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text", + "arguments" => [], } - @informative_text = "" end def questions diff --git a/app/models/form/lettings/pages/care_home_weekly.rb b/app/models/form/lettings/pages/care_home_weekly.rb index 56165ce62..ef0ca01c3 100644 --- a/app/models/form/lettings/pages/care_home_weekly.rb +++ b/app/models/form/lettings/pages/care_home_weekly.rb @@ -2,6 +2,7 @@ class Form::Lettings::Pages::CareHomeWeekly < ::Form::Page def initialize(id, hsh, subsection) super @id = "care_home_weekly" + @copy_key = "lettings.income_and_benefits.care_home" @depends_on = [ { "rent_and_charges_paid_weekly?" => true, "is_supported_housing?" => true, "household_charge" => 0 }, { "rent_and_charges_paid_weekly?" => true, "is_supported_housing?" => true, "household_charge" => nil }, diff --git a/app/models/form/lettings/pages/females_in_soft_age_range_in_pregnant_household_lead_age_value_check.rb b/app/models/form/lettings/pages/females_in_soft_age_range_in_pregnant_household_lead_age_value_check.rb index d91794525..5b06d6a28 100644 --- a/app/models/form/lettings/pages/females_in_soft_age_range_in_pregnant_household_lead_age_value_check.rb +++ b/app/models/form/lettings/pages/females_in_soft_age_range_in_pregnant_household_lead_age_value_check.rb @@ -2,14 +2,15 @@ class Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdLeadAgeValu def initialize(id, hsh, subsection) super(id, hsh, subsection) @id = "females_in_soft_age_range_in_pregnant_household_lead_age_value_check" + @copy_key = "lettings.soft_validations.pregnancy_value_check.females_in_soft_age_range_in_pregnant_household_value_check" @depends_on = [{ "female_in_pregnant_household_in_soft_validation_range?" => true }] @title_text = { - "translation" => "soft_validations.pregnancy.title", - "arguments" => [{ "key" => "sex1", "label" => true, "i18n_template" => "sex1" }], + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text", + "arguments" => [], } @informative_text = { - "translation" => "soft_validations.pregnancy.females_not_in_soft_age_range", - "arguments" => [{ "key" => "sex1", "label" => true, "i18n_template" => "sex1" }], + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text", + "arguments" => [], } end diff --git a/app/models/form/lettings/pages/females_in_soft_age_range_in_pregnant_household_lead_hhmemb_value_check.rb b/app/models/form/lettings/pages/females_in_soft_age_range_in_pregnant_household_lead_hhmemb_value_check.rb index 6fc8bdd16..3e961b283 100644 --- a/app/models/form/lettings/pages/females_in_soft_age_range_in_pregnant_household_lead_hhmemb_value_check.rb +++ b/app/models/form/lettings/pages/females_in_soft_age_range_in_pregnant_household_lead_hhmemb_value_check.rb @@ -2,14 +2,15 @@ class Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdLeadHhmembV def initialize(id, hsh, subsection) super(id, hsh, subsection) @id = "females_in_soft_age_range_in_pregnant_household_lead_hhmemb_value_check" + @copy_key = "lettings.soft_validations.pregnancy_value_check.females_in_soft_age_range_in_pregnant_household_value_check" @depends_on = [{ "female_in_pregnant_household_in_soft_validation_range?" => true }] @title_text = { - "translation" => "soft_validations.pregnancy.title", - "arguments" => [{ "key" => "sex1", "label" => true, "i18n_template" => "sex1" }], + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text", + "arguments" => [], } @informative_text = { - "translation" => "soft_validations.pregnancy.females_not_in_soft_age_range", - "arguments" => [{ "key" => "sex1", "label" => true, "i18n_template" => "sex1" }], + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text", + "arguments" => [], } end diff --git a/app/models/form/lettings/pages/females_in_soft_age_range_in_pregnant_household_lead_value_check.rb b/app/models/form/lettings/pages/females_in_soft_age_range_in_pregnant_household_lead_value_check.rb index 9a2b707b3..af568b039 100644 --- a/app/models/form/lettings/pages/females_in_soft_age_range_in_pregnant_household_lead_value_check.rb +++ b/app/models/form/lettings/pages/females_in_soft_age_range_in_pregnant_household_lead_value_check.rb @@ -2,14 +2,15 @@ class Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdLeadValueCh def initialize(id, hsh, subsection) super @id = "females_in_soft_age_range_in_pregnant_household_lead_value_check" + @copy_key = "lettings.soft_validations.pregnancy_value_check.females_in_soft_age_range_in_pregnant_household_value_check" @depends_on = [{ "female_in_pregnant_household_in_soft_validation_range?" => true }] @title_text = { - "translation" => "soft_validations.pregnancy.title", - "arguments" => [{ "key" => "sex1", "label" => true, "i18n_template" => "sex1" }], + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text", + "arguments" => [], } @informative_text = { - "translation" => "soft_validations.pregnancy.females_not_in_soft_age_range", - "arguments" => [{ "key" => "sex1", "label" => true, "i18n_template" => "sex1" }], + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text", + "arguments" => [], } end diff --git a/app/models/form/lettings/pages/females_in_soft_age_range_in_pregnant_household_person_age_value_check.rb b/app/models/form/lettings/pages/females_in_soft_age_range_in_pregnant_household_person_age_value_check.rb index 0b2e2451f..ddc8789f9 100644 --- a/app/models/form/lettings/pages/females_in_soft_age_range_in_pregnant_household_person_age_value_check.rb +++ b/app/models/form/lettings/pages/females_in_soft_age_range_in_pregnant_household_person_age_value_check.rb @@ -2,6 +2,7 @@ class Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdPersonAgeVa def initialize(id, hsh, subsection, person_index:) super(id, hsh, subsection) @id = "females_in_soft_age_range_in_pregnant_household_person_#{person_index}_age_value_check" + @copy_key = "lettings.soft_validations.pregnancy_value_check.females_in_soft_age_range_in_pregnant_household_value_check" @depends_on = [ { "female_in_pregnant_household_in_soft_validation_range?" => true, @@ -9,24 +10,12 @@ class Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdPersonAgeVa }, ] @title_text = { - "translation" => "soft_validations.pregnancy.title", - "arguments" => [ - { - "key" => "sex1", - "label" => true, - "i18n_template" => "sex1", - }, - ], + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text", + "arguments" => [], } @informative_text = { - "translation" => "soft_validations.pregnancy.females_not_in_soft_age_range", - "arguments" => [ - { - "key" => "sex1", - "label" => true, - "i18n_template" => "sex1", - }, - ], + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text", + "arguments" => [], } @person_index = person_index end diff --git a/app/models/form/lettings/pages/females_in_soft_age_range_in_pregnant_household_person_value_check.rb b/app/models/form/lettings/pages/females_in_soft_age_range_in_pregnant_household_person_value_check.rb index c8d484bf4..099bea5d9 100644 --- a/app/models/form/lettings/pages/females_in_soft_age_range_in_pregnant_household_person_value_check.rb +++ b/app/models/form/lettings/pages/females_in_soft_age_range_in_pregnant_household_person_value_check.rb @@ -2,6 +2,8 @@ class Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdPersonValue def initialize(id, hsh, subsection, person_index:) super(id, hsh, subsection) @id = "females_in_soft_age_range_in_pregnant_household_person_#{person_index}_value_check" + @copy_key = "lettings.soft_validations.pregnancy_value_check.females_in_soft_age_range_in_pregnant_household_value_check" + @depends_on = [ { "female_in_pregnant_household_in_soft_validation_range?" => true, @@ -9,24 +11,12 @@ class Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdPersonValue }, ] @title_text = { - "translation" => "soft_validations.pregnancy.title", - "arguments" => [ - { - "key" => "sex1", - "label" => true, - "i18n_template" => "sex1", - }, - ], + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text", + "arguments" => [], } @informative_text = { - "translation" => "soft_validations.pregnancy.females_not_in_soft_age_range", - "arguments" => [ - { - "key" => "sex1", - "label" => true, - "i18n_template" => "sex1", - }, - ], + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text", + "arguments" => [], } @person_index = person_index end diff --git a/app/models/form/lettings/pages/females_in_soft_age_range_in_pregnant_household_value_check.rb b/app/models/form/lettings/pages/females_in_soft_age_range_in_pregnant_household_value_check.rb index c816fb0b2..3822ec940 100644 --- a/app/models/form/lettings/pages/females_in_soft_age_range_in_pregnant_household_value_check.rb +++ b/app/models/form/lettings/pages/females_in_soft_age_range_in_pregnant_household_value_check.rb @@ -2,14 +2,15 @@ class Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdValueCheck def initialize(id, hsh, subsection) super @id = "females_in_soft_age_range_in_pregnant_household_value_check" + @copy_key = "lettings.soft_validations.pregnancy_value_check.females_in_soft_age_range_in_pregnant_household_value_check" @depends_on = [{ "female_in_pregnant_household_in_soft_validation_range?" => true }] @title_text = { - "translation" => "soft_validations.pregnancy.title", - "arguments" => [{ "key" => "sex1", "label" => true, "i18n_template" => "sex1" }], + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text", + "arguments" => [], } @informative_text = { - "translation" => "soft_validations.pregnancy.females_not_in_soft_age_range", - "arguments" => [{ "key" => "sex1", "label" => true, "i18n_template" => "sex1" }], + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text", + "arguments" => [], } end diff --git a/app/models/form/lettings/pages/income_amount.rb b/app/models/form/lettings/pages/income_amount.rb index 589ae463a..71151e695 100644 --- a/app/models/form/lettings/pages/income_amount.rb +++ b/app/models/form/lettings/pages/income_amount.rb @@ -2,7 +2,7 @@ class Form::Lettings::Pages::IncomeAmount < ::Form::Page def initialize(id, hsh, subsection) super @id = "income_amount" - @header = "Total household income" + @copy_key = "lettings.income_and_benefits.income_amount" @depends_on = [{ "net_income_known" => 0 }] end diff --git a/app/models/form/lettings/pages/income_known.rb b/app/models/form/lettings/pages/income_known.rb index c031b1521..ba026d93f 100644 --- a/app/models/form/lettings/pages/income_known.rb +++ b/app/models/form/lettings/pages/income_known.rb @@ -2,7 +2,6 @@ class Form::Lettings::Pages::IncomeKnown < ::Form::Page def initialize(id, hsh, subsection) super @id = "income_known" - @header = "Household’s combined income after tax" end def questions diff --git a/app/models/form/lettings/pages/lead_tenant_nationality.rb b/app/models/form/lettings/pages/lead_tenant_nationality.rb index d4845f8f9..410a6320f 100644 --- a/app/models/form/lettings/pages/lead_tenant_nationality.rb +++ b/app/models/form/lettings/pages/lead_tenant_nationality.rb @@ -2,12 +2,12 @@ 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'}" + @copy_key = "lettings.household_characteristics.#{form.start_year_2024_or_later? ? 'nationality_all' : 'national'}" @depends_on = [{ "declaration" => 1 }] end def questions - @questions ||= if form.start_year_after_2024? + @questions ||= if form.start_year_2024_or_later? [ Form::Lettings::Questions::NationalityAllGroup.new(nil, nil, self), Form::Lettings::Questions::NationalityAll.new(nil, nil, self), diff --git a/app/models/form/lettings/pages/lead_tenant_over_retirement_value_check.rb b/app/models/form/lettings/pages/lead_tenant_over_retirement_value_check.rb index b5add868b..43b00844c 100644 --- a/app/models/form/lettings/pages/lead_tenant_over_retirement_value_check.rb +++ b/app/models/form/lettings/pages/lead_tenant_over_retirement_value_check.rb @@ -2,11 +2,13 @@ class Form::Lettings::Pages::LeadTenantOverRetirementValueCheck < ::Form::Page def initialize(id, hsh, subsection) super @depends_on = [{ "person_1_not_retired_over_soft_max_age?" => true }] + @copy_key = "lettings.soft_validations.retirement_value_check" @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/lettings/pages/lead_tenant_under_retirement_value_check.rb b/app/models/form/lettings/pages/lead_tenant_under_retirement_value_check.rb index 0c7a3ed2e..66a87c2bf 100644 --- a/app/models/form/lettings/pages/lead_tenant_under_retirement_value_check.rb +++ b/app/models/form/lettings/pages/lead_tenant_under_retirement_value_check.rb @@ -2,8 +2,9 @@ class Form::Lettings::Pages::LeadTenantUnderRetirementValueCheck < ::Form::Page def initialize(id, hsh, subsection) super @depends_on = [{ "person_1_retired_under_soft_min_age?" => true }] + @copy_key = "lettings.soft_validations.no_retirement_value_check" @title_text = { - "translation" => "soft_validations.retirement.min.title", + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text", "arguments" => [ { "key" => "age1", @@ -12,7 +13,10 @@ class Form::Lettings::Pages::LeadTenantUnderRetirementValueCheck < ::Form::Page }, ], } - @informative_text = {} + @informative_text = { + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text", + "arguments" => [], + } end def questions diff --git a/app/models/form/lettings/pages/multiple_partners_value_check.rb b/app/models/form/lettings/pages/multiple_partners_value_check.rb index 3f9cdb3ae..4e9167a12 100644 --- a/app/models/form/lettings/pages/multiple_partners_value_check.rb +++ b/app/models/form/lettings/pages/multiple_partners_value_check.rb @@ -6,12 +6,16 @@ class Form::Lettings::Pages::MultiplePartnersValueCheck < Form::Page "multiple_partners?" => true, }, ] + @copy_key = "lettings.soft_validations.multiple_partners_value_check" @person_index = person_index @title_text = { - "translation" => "soft_validations.multiple_partners_lettings.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/lettings/pages/net_income_value_check.rb b/app/models/form/lettings/pages/net_income_value_check.rb index ccb2b2a08..9bdce131d 100644 --- a/app/models/form/lettings/pages/net_income_value_check.rb +++ b/app/models/form/lettings/pages/net_income_value_check.rb @@ -2,9 +2,10 @@ class Form::Lettings::Pages::NetIncomeValueCheck < ::Form::Page def initialize(id, hsh, subsection) super @id = "net_income_value_check" + @copy_key = "lettings.soft_validations.net_income_value_check" @depends_on = [{ "net_income_soft_validation_triggered?" => true }] @title_text = { - "translation" => "soft_validations.net_income.title_text", + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text", "arguments" => [ { "key" => "incfreq", @@ -20,7 +21,7 @@ class Form::Lettings::Pages::NetIncomeValueCheck < ::Form::Page } @informative_text = { - "translation" => "soft_validations.net_income.hint_text", + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text", "arguments" => [ { "key" => "net_income_higher_or_lower_text", diff --git a/app/models/form/lettings/pages/no_females_pregnant_household_lead_age_value_check.rb b/app/models/form/lettings/pages/no_females_pregnant_household_lead_age_value_check.rb index 68b1c7f09..7e530a9ad 100644 --- a/app/models/form/lettings/pages/no_females_pregnant_household_lead_age_value_check.rb +++ b/app/models/form/lettings/pages/no_females_pregnant_household_lead_age_value_check.rb @@ -2,14 +2,15 @@ class Form::Lettings::Pages::NoFemalesPregnantHouseholdLeadAgeValueCheck < ::For def initialize(id, hsh, subsection) super(id, hsh, subsection) @id = "no_females_pregnant_household_lead_age_value_check" + @copy_key = "lettings.soft_validations.pregnancy_value_check.no_females_pregnant_household_value_check" @depends_on = [{ "all_male_tenants_in_a_pregnant_household?" => true }] @title_text = { - "translation" => "soft_validations.pregnancy.title", - "arguments" => [{ "key" => "sex1", "label" => true, "i18n_template" => "sex1" }], + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text", + "arguments" => [], } @informative_text = { - "translation" => "soft_validations.pregnancy.all_male_tenants", - "arguments" => [{ "key" => "sex1", "label" => true, "i18n_template" => "sex1" }], + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text", + "arguments" => [], } end diff --git a/app/models/form/lettings/pages/no_females_pregnant_household_lead_hhmemb_value_check.rb b/app/models/form/lettings/pages/no_females_pregnant_household_lead_hhmemb_value_check.rb index e1d1235ef..47ac7493b 100644 --- a/app/models/form/lettings/pages/no_females_pregnant_household_lead_hhmemb_value_check.rb +++ b/app/models/form/lettings/pages/no_females_pregnant_household_lead_hhmemb_value_check.rb @@ -2,14 +2,15 @@ class Form::Lettings::Pages::NoFemalesPregnantHouseholdLeadHhmembValueCheck < :: def initialize(id, hsh, subsection) super @id = "no_females_pregnant_household_lead_hhmemb_value_check" + @copy_key = "lettings.soft_validations.pregnancy_value_check.no_females_pregnant_household_value_check" @depends_on = [{ "all_male_tenants_in_a_pregnant_household?" => true }] @title_text = { - "translation" => "soft_validations.pregnancy.title", - "arguments" => [{ "key" => "sex1", "label" => true, "i18n_template" => "sex1" }], + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text", + "arguments" => [], } @informative_text = { - "translation" => "soft_validations.pregnancy.all_male_tenants", - "arguments" => [{ "key" => "sex1", "label" => true, "i18n_template" => "sex1" }], + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text", + "arguments" => [], } end diff --git a/app/models/form/lettings/pages/no_females_pregnant_household_lead_value_check.rb b/app/models/form/lettings/pages/no_females_pregnant_household_lead_value_check.rb index 416845735..edfe2c631 100644 --- a/app/models/form/lettings/pages/no_females_pregnant_household_lead_value_check.rb +++ b/app/models/form/lettings/pages/no_females_pregnant_household_lead_value_check.rb @@ -2,14 +2,15 @@ class Form::Lettings::Pages::NoFemalesPregnantHouseholdLeadValueCheck < ::Form:: def initialize(id, hsh, subsection) super @id = "no_females_pregnant_household_lead_value_check" + @copy_key = "lettings.soft_validations.pregnancy_value_check.no_females_pregnant_household_value_check" @depends_on = [{ "all_male_tenants_in_a_pregnant_household?" => true }] @title_text = { - "translation" => "soft_validations.pregnancy.title", - "arguments" => [{ "key" => "sex1", "label" => true, "i18n_template" => "sex1" }], + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text", + "arguments" => [], } @informative_text = { - "translation" => "soft_validations.pregnancy.all_male_tenants", - "arguments" => [{ "key" => "sex1", "label" => true, "i18n_template" => "sex1" }], + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text", + "arguments" => [], } end diff --git a/app/models/form/lettings/pages/no_females_pregnant_household_person_age_value_check.rb b/app/models/form/lettings/pages/no_females_pregnant_household_person_age_value_check.rb index 12db3a08e..5e808b853 100644 --- a/app/models/form/lettings/pages/no_females_pregnant_household_person_age_value_check.rb +++ b/app/models/form/lettings/pages/no_females_pregnant_household_person_age_value_check.rb @@ -2,14 +2,15 @@ class Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonAgeValueCheck < ::F def initialize(id, hsh, subsection, person_index:) super(id, hsh, subsection) @id = "no_females_pregnant_household_person_#{person_index}_age_value_check" + @copy_key = "lettings.soft_validations.pregnancy_value_check.no_females_pregnant_household_value_check" @depends_on = [{ "all_male_tenants_in_a_pregnant_household?" => true, "age#{person_index}_known" => 0 }] @title_text = { - "translation" => "soft_validations.pregnancy.title", - "arguments" => [{ "key" => "sex1", "label" => true, "i18n_template" => "sex1" }], + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text", + "arguments" => [], } @informative_text = { - "translation" => "soft_validations.pregnancy.all_male_tenants", - "arguments" => [{ "key" => "sex1", "label" => true, "i18n_template" => "sex1" }], + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text", + "arguments" => [], } @person_index = person_index end diff --git a/app/models/form/lettings/pages/no_females_pregnant_household_person_value_check.rb b/app/models/form/lettings/pages/no_females_pregnant_household_person_value_check.rb index f04333ec0..fb77eec18 100644 --- a/app/models/form/lettings/pages/no_females_pregnant_household_person_value_check.rb +++ b/app/models/form/lettings/pages/no_females_pregnant_household_person_value_check.rb @@ -2,14 +2,15 @@ class Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonValueCheck < ::Form def initialize(id, hsh, subsection, person_index:) super(id, hsh, subsection) @id = "no_females_pregnant_household_person_#{person_index}_value_check" + @copy_key = "lettings.soft_validations.pregnancy_value_check.no_females_pregnant_household_value_check" @depends_on = [{ "all_male_tenants_in_a_pregnant_household?" => true, "details_known_#{person_index}" => 0 }] @title_text = { - "translation" => "soft_validations.pregnancy.title", - "arguments" => [{ "key" => "sex1", "label" => true, "i18n_template" => "sex1" }], + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text", + "arguments" => [], } @informative_text = { - "translation" => "soft_validations.pregnancy.all_male_tenants", - "arguments" => [{ "key" => "sex1", "label" => true, "i18n_template" => "sex1" }], + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text", + "arguments" => [], } @person_index = person_index end diff --git a/app/models/form/lettings/pages/no_females_pregnant_household_value_check.rb b/app/models/form/lettings/pages/no_females_pregnant_household_value_check.rb index 9c84a953f..bce8a87ae 100644 --- a/app/models/form/lettings/pages/no_females_pregnant_household_value_check.rb +++ b/app/models/form/lettings/pages/no_females_pregnant_household_value_check.rb @@ -2,14 +2,15 @@ class Form::Lettings::Pages::NoFemalesPregnantHouseholdValueCheck < ::Form::Page def initialize(id, hsh, subsection) super @id = "no_females_pregnant_household_value_check" + @copy_key = "lettings.soft_validations.pregnancy_value_check.no_females_pregnant_household_value_check" @depends_on = [{ "all_male_tenants_in_a_pregnant_household?" => true }] @title_text = { - "translation" => "soft_validations.pregnancy.title", - "arguments" => [{ "key" => "sex1", "label" => true, "i18n_template" => "sex1" }], + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text", + "arguments" => [], } @informative_text = { - "translation" => "soft_validations.pregnancy.all_male_tenants", - "arguments" => [{ "key" => "sex1", "label" => true, "i18n_template" => "sex1" }], + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text", + "arguments" => [], } end diff --git a/app/models/form/lettings/pages/partner_under_16_value_check.rb b/app/models/form/lettings/pages/partner_under_16_value_check.rb index 87d5865c4..b33a827d4 100644 --- a/app/models/form/lettings/pages/partner_under_16_value_check.rb +++ b/app/models/form/lettings/pages/partner_under_16_value_check.rb @@ -6,9 +6,10 @@ class Form::Lettings::Pages::PartnerUnder16ValueCheck < Form::Page "person_#{person_index}_partner_under_16?" => true, }, ] + @copy_key = "lettings.soft_validations.partner_under_16_value_check" @person_index = person_index @title_text = { - "translation" => "soft_validations.partner_under_16_lettings.title", + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text", "arguments" => [ { "key" => "age#{person_index}", @@ -17,7 +18,10 @@ class Form::Lettings::Pages::PartnerUnder16ValueCheck < Form::Page }, ], } - @informative_text = {} + @informative_text = { + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text", + "arguments" => [], + } end def questions diff --git a/app/models/form/lettings/pages/person_over_retirement_value_check.rb b/app/models/form/lettings/pages/person_over_retirement_value_check.rb index dbaf2d2e2..c094d4a93 100644 --- a/app/models/form/lettings/pages/person_over_retirement_value_check.rb +++ b/app/models/form/lettings/pages/person_over_retirement_value_check.rb @@ -2,11 +2,13 @@ class Form::Lettings::Pages::PersonOverRetirementValueCheck < ::Form::Page def initialize(id, hsh, subsection, person_index:) super(id, hsh, subsection) @depends_on = [{ "person_#{person_index}_not_retired_over_soft_max_age?" => true }] + @copy_key = "lettings.soft_validations.retirement_value_check" @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" => [], } @person_index = person_index end diff --git a/app/models/form/lettings/pages/person_under_retirement_value_check.rb b/app/models/form/lettings/pages/person_under_retirement_value_check.rb index ab9c81beb..853afafe0 100644 --- a/app/models/form/lettings/pages/person_under_retirement_value_check.rb +++ b/app/models/form/lettings/pages/person_under_retirement_value_check.rb @@ -2,8 +2,9 @@ class Form::Lettings::Pages::PersonUnderRetirementValueCheck < ::Form::Page def initialize(id, hsh, subsection, person_index:) super(id, hsh, subsection) @depends_on = [{ "person_#{person_index}_retired_under_soft_min_age?" => true }] + @copy_key = "lettings.soft_validations.no_retirement_value_check" @title_text = { - "translation" => "soft_validations.retirement.min.title", + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text", "arguments" => [ { "key" => "age#{person_index}", @@ -12,7 +13,10 @@ class Form::Lettings::Pages::PersonUnderRetirementValueCheck < ::Form::Page }, ], } - @informative_text = {} + @informative_text = { + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text", + "arguments" => [], + } @person_index = person_index end diff --git a/app/models/form/lettings/pages/property_local_authority.rb b/app/models/form/lettings/pages/property_local_authority.rb index 1e3d34bd2..339ccb4d8 100644 --- a/app/models/form/lettings/pages/property_local_authority.rb +++ b/app/models/form/lettings/pages/property_local_authority.rb @@ -3,8 +3,8 @@ class Form::Lettings::Pages::PropertyLocalAuthority < ::Form::Page super @id = "property_local_authority" @depends_on = [ - { "is_la_inferred" => false, "is_general_needs?" => true, "form.start_year_after_2024?" => false }, - { "is_la_inferred" => false, "is_general_needs?" => true, "form.start_year_after_2024?" => true, "address_search_given?" => true }, + { "is_la_inferred" => false, "is_general_needs?" => true, "form.start_year_2024_or_later?" => false }, + { "is_la_inferred" => false, "is_general_needs?" => true, "form.start_year_2024_or_later?" => true, "address_search_given?" => true }, ] end diff --git a/app/models/form/lettings/pages/property_major_repairs_value_check.rb b/app/models/form/lettings/pages/property_major_repairs_value_check.rb index 08672aff6..d1c7be34c 100644 --- a/app/models/form/lettings/pages/property_major_repairs_value_check.rb +++ b/app/models/form/lettings/pages/property_major_repairs_value_check.rb @@ -2,10 +2,11 @@ class Form::Lettings::Pages::PropertyMajorRepairsValueCheck < ::Form::Page def initialize(id, hsh, subsection) super @id = "property_major_repairs_value_check" + @copy_key = "lettings.soft_validations.major_repairs_date_value_check" @depends_on = [{ "major_repairs_date_in_soft_range?" => true }] - @title_text = { "translation" => "soft_validations.major_repairs_date.title_text" } + @title_text = { "translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text" } @informative_text = { - "translation" => "soft_validations.major_repairs_date.hint_text", + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text", "arguments" => [], } end diff --git a/app/models/form/lettings/pages/pscharge_value_check.rb b/app/models/form/lettings/pages/pscharge_value_check.rb index 6c8ada196..8ff953afd 100644 --- a/app/models/form/lettings/pages/pscharge_value_check.rb +++ b/app/models/form/lettings/pages/pscharge_value_check.rb @@ -2,16 +2,20 @@ class Form::Lettings::Pages::PschargeValueCheck < ::Form::Page def initialize(id, hsh, subsection) super @id = "pscharge_value_check" + @copy_key = "lettings.soft_validations.pscharge_value_check" @depends_on = [{ "pscharge_in_soft_max_range?" => true }] @title_text = { - "translation" => "soft_validations.pscharge.over_soft_max_title", + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text", "arguments" => [{ "key" => "pscharge", "label" => true, "i18n_template" => "pscharge", }], } - @informative_text = I18n.t("soft_validations.charges.informative_text") + @informative_text = { + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text", + "arguments" => [], + } end def questions diff --git a/app/models/form/lettings/pages/reasonother_value_check.rb b/app/models/form/lettings/pages/reasonother_value_check.rb index ccda997a7..ccc6be70d 100644 --- a/app/models/form/lettings/pages/reasonother_value_check.rb +++ b/app/models/form/lettings/pages/reasonother_value_check.rb @@ -2,13 +2,14 @@ class Form::Lettings::Pages::ReasonotherValueCheck < ::Form::Page def initialize(id, hsh, subsection) super @id = "reasonother_value_check" + @copy_key = "lettings.soft_validations.reasonother_value_check" @depends_on = [{ "reasonother_might_be_existing_category?" => true }] @title_text = { - "translation" => "soft_validations.reasonother.title_text", + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text", "arguments" => [{ "key" => "reasonother", "i18n_template" => "reasonother" }], } @informative_text = { - "translation" => "soft_validations.reasonother.informative_text", + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text", "arguments" => [], } end diff --git a/app/models/form/lettings/pages/referral_value_check.rb b/app/models/form/lettings/pages/referral_value_check.rb index 55f6f3e8b..aa3a34200 100644 --- a/app/models/form/lettings/pages/referral_value_check.rb +++ b/app/models/form/lettings/pages/referral_value_check.rb @@ -2,12 +2,13 @@ class Form::Lettings::Pages::ReferralValueCheck < ::Form::Page def initialize(id, hsh, subsection) super @id = "referral_value_check" + @copy_key = "lettings.soft_validations.referral_value_check" @depends_on = [{ "la_referral_for_general_needs?" => true }] @title_text = { - "translation" => "soft_validations.referral.title_text", + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text", } @informative_text = { - "translation" => "soft_validations.referral.hint_text", + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text", "arguments" => [], } end diff --git a/app/models/form/lettings/pages/rent_4_weekly.rb b/app/models/form/lettings/pages/rent_4_weekly.rb index e71cd7ffa..aa6441f6e 100644 --- a/app/models/form/lettings/pages/rent_4_weekly.rb +++ b/app/models/form/lettings/pages/rent_4_weekly.rb @@ -2,7 +2,7 @@ class Form::Lettings::Pages::Rent4Weekly < ::Form::Page def initialize(id, hsh, subsection) super @id = "rent_4_weekly" - @header = "Household rent and charges" + @copy_key = "lettings.income_and_benefits.rent_and_charges" @depends_on = [ { "household_charge" => 0, "rent_and_charges_paid_every_4_weeks?" => true, "is_carehome?" => false }, { "household_charge" => nil, "rent_and_charges_paid_every_4_weeks?" => true, "is_carehome?" => false }, diff --git a/app/models/form/lettings/pages/rent_bi_weekly.rb b/app/models/form/lettings/pages/rent_bi_weekly.rb index 0b1b9c884..7eab8daf4 100644 --- a/app/models/form/lettings/pages/rent_bi_weekly.rb +++ b/app/models/form/lettings/pages/rent_bi_weekly.rb @@ -2,7 +2,7 @@ class Form::Lettings::Pages::RentBiWeekly < ::Form::Page def initialize(id, hsh, subsection) super @id = "rent_bi_weekly" - @header = "Household rent and charges" + @copy_key = "lettings.income_and_benefits.rent_and_charges" @depends_on = [ { "household_charge" => nil, "rent_and_charges_paid_every_2_weeks?" => true, "is_carehome?" => false }, { "household_charge" => 0, "rent_and_charges_paid_every_2_weeks?" => true, "is_carehome?" => false }, diff --git a/app/models/form/lettings/pages/rent_monthly.rb b/app/models/form/lettings/pages/rent_monthly.rb index d6af7a08c..9a3cd6a7e 100644 --- a/app/models/form/lettings/pages/rent_monthly.rb +++ b/app/models/form/lettings/pages/rent_monthly.rb @@ -2,7 +2,7 @@ class Form::Lettings::Pages::RentMonthly < ::Form::Page def initialize(id, hsh, subsection) super @id = "rent_monthly" - @header = "Household rent and charges" + @copy_key = "lettings.income_and_benefits.rent_and_charges" @depends_on = [ { "household_charge" => nil, "rent_and_charges_paid_monthly?" => true, "is_carehome?" => false }, { "household_charge" => 0, "rent_and_charges_paid_monthly?" => true, "is_carehome?" => false }, diff --git a/app/models/form/lettings/pages/rent_value_check.rb b/app/models/form/lettings/pages/rent_value_check.rb index a80dc7339..5a1ecc847 100644 --- a/app/models/form/lettings/pages/rent_value_check.rb +++ b/app/models/form/lettings/pages/rent_value_check.rb @@ -2,8 +2,9 @@ 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 }] + @copy_key = "lettings.soft_validations.rent_value_check" @title_text = { - "translation" => "soft_validations.rent.outside_range_title", + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text", "arguments" => [ { "key" => "brent", @@ -13,7 +14,7 @@ class Form::Lettings::Pages::RentValueCheck < ::Form::Page ], } @informative_text = { - "translation" => "soft_validations.rent.informative_text", + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text", "arguments" => [ { "key" => "rent_soft_validation_higher_or_lower_text", diff --git a/app/models/form/lettings/pages/rent_weekly.rb b/app/models/form/lettings/pages/rent_weekly.rb index 4f1709820..86106cfe3 100644 --- a/app/models/form/lettings/pages/rent_weekly.rb +++ b/app/models/form/lettings/pages/rent_weekly.rb @@ -2,7 +2,7 @@ class Form::Lettings::Pages::RentWeekly < ::Form::Page def initialize(id, hsh, subsection) super @id = "rent_weekly" - @header = "Household rent and charges" + @copy_key = "lettings.income_and_benefits.rent_and_charges" @depends_on = [ { "rent_and_charges_paid_weekly?" => true, "household_charge" => 0, "is_carehome?" => false }, { "rent_and_charges_paid_weekly?" => true, "household_charge" => nil, "is_carehome?" => false }, diff --git a/app/models/form/lettings/pages/scharge_value_check.rb b/app/models/form/lettings/pages/scharge_value_check.rb index 73ee41920..bd9accfc1 100644 --- a/app/models/form/lettings/pages/scharge_value_check.rb +++ b/app/models/form/lettings/pages/scharge_value_check.rb @@ -2,16 +2,20 @@ class Form::Lettings::Pages::SchargeValueCheck < ::Form::Page def initialize(id, hsh, subsection) super @id = "scharge_value_check" + @copy_key = "lettings.soft_validations.scharge_value_check" @depends_on = [{ "scharge_in_soft_max_range?" => true }] @title_text = { - "translation" => "soft_validations.scharge.over_soft_max_title", + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text", "arguments" => [{ "key" => "scharge", "label" => true, "i18n_template" => "scharge", }], } - @informative_text = I18n.t("soft_validations.charges.informative_text") + @title_text = { + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text", + "arguments" => [], + } end def questions diff --git a/app/models/form/lettings/pages/supcharg_value_check.rb b/app/models/form/lettings/pages/supcharg_value_check.rb index a974a8f89..89dcc89c1 100644 --- a/app/models/form/lettings/pages/supcharg_value_check.rb +++ b/app/models/form/lettings/pages/supcharg_value_check.rb @@ -2,16 +2,20 @@ class Form::Lettings::Pages::SupchargValueCheck < ::Form::Page def initialize(id, hsh, subsection) super @id = "supcharg_value_check" + @copy_key = "lettings.soft_validations.supcharg_value_check" @depends_on = [{ "supcharg_in_soft_max_range?" => true }] @title_text = { - "translation" => "soft_validations.supcharg.over_soft_max_title", + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text", "arguments" => [{ "key" => "supcharg", "label" => true, "i18n_template" => "supcharg", }], } - @informative_text = I18n.t("soft_validations.charges.informative_text") + @informative_text = { + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text", + "arguments" => [], + } end def questions diff --git a/app/models/form/lettings/pages/uprn.rb b/app/models/form/lettings/pages/uprn.rb index 474928eb3..b9a3a4e94 100644 --- a/app/models/form/lettings/pages/uprn.rb +++ b/app/models/form/lettings/pages/uprn.rb @@ -14,7 +14,7 @@ class Form::Lettings::Pages::Uprn < ::Form::Page end def skip_text - if form.start_year_after_2024? + if form.start_year_2024_or_later? "Search for address instead" else "Enter address instead" @@ -24,7 +24,7 @@ class Form::Lettings::Pages::Uprn < ::Form::Page def skip_href(log = nil) return unless log - if form.start_year_after_2024? + if form.start_year_2024_or_later? "address-matcher" else "address" diff --git a/app/models/form/lettings/pages/void_date_value_check.rb b/app/models/form/lettings/pages/void_date_value_check.rb index 6ebd3a175..b5d7fdadd 100644 --- a/app/models/form/lettings/pages/void_date_value_check.rb +++ b/app/models/form/lettings/pages/void_date_value_check.rb @@ -2,10 +2,11 @@ class Form::Lettings::Pages::VoidDateValueCheck < ::Form::Page def initialize(id, hsh, subsection) super @id = "void_date_value_check" + @copy_key = "lettings.soft_validations.void_date_value_check" @depends_on = [{ "voiddate_in_soft_range?" => true }] - @title_text = { "translation" => "soft_validations.void_date.title_text" } + @title_text = { "translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text" } @informative_text = { - "translation" => "soft_validations.void_date.hint_text", + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text", "arguments" => [], } end diff --git a/app/models/form/lettings/questions/age.rb b/app/models/form/lettings/questions/age.rb index b861cb39f..f35abe61e 100644 --- a/app/models/form/lettings/questions/age.rb +++ b/app/models/form/lettings/questions/age.rb @@ -27,7 +27,7 @@ class Form::Lettings::Questions::Age < ::Form::Question end def hint_text - if form.start_year_after_2024? + if form.start_year_2024_or_later? "Answer 1 for children aged under 1 year old" end end diff --git a/app/models/form/lettings/questions/benefits.rb b/app/models/form/lettings/questions/benefits.rb index bc17396fb..f5f2a3ee1 100644 --- a/app/models/form/lettings/questions/benefits.rb +++ b/app/models/form/lettings/questions/benefits.rb @@ -2,11 +2,8 @@ class Form::Lettings::Questions::Benefits < ::Form::Question def initialize(id, hsh, page) super @id = "benefits" - @check_answer_label = "Household income from Universal Credit, state pension or benefits" - @header = "How much of the household’s income is from Universal Credit, state pensions or benefits?" @type = "radio" @check_answers_card_number = 0 - @hint_text = "This excludes child and housing benefit, council tax support and tax credits." @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/brent_4_weekly.rb b/app/models/form/lettings/questions/brent_4_weekly.rb index 436b628ad..2dc18ba56 100644 --- a/app/models/form/lettings/questions/brent_4_weekly.rb +++ b/app/models/form/lettings/questions/brent_4_weekly.rb @@ -2,13 +2,11 @@ class Form::Lettings::Questions::Brent4Weekly < ::Form::Question def initialize(id, hsh, page) super @id = "brent" - @check_answer_label = "Basic rent" - @header = "What is the basic rent?" + @copy_key = "lettings.income_and_benefits.rent_and_charges.brent" @type = "numeric" @width = 5 @check_answers_card_number = 0 @min = 0 - @hint_text = "This is the amount paid before any charges are added for services (for example, hot water or cleaning). Households may receive housing benefit or Universal Credit towards basic rent." @step = 0.01 @fields_to_add = %w[brent scharge pscharge supcharg] @result_field = "tcharge" diff --git a/app/models/form/lettings/questions/brent_bi_weekly.rb b/app/models/form/lettings/questions/brent_bi_weekly.rb index 8dc27b610..d8bcfa136 100644 --- a/app/models/form/lettings/questions/brent_bi_weekly.rb +++ b/app/models/form/lettings/questions/brent_bi_weekly.rb @@ -2,13 +2,11 @@ class Form::Lettings::Questions::BrentBiWeekly < ::Form::Question def initialize(id, hsh, page) super @id = "brent" - @check_answer_label = "Basic rent" - @header = "What is the basic rent?" + @copy_key = "lettings.income_and_benefits.rent_and_charges.brent" @type = "numeric" @width = 5 @check_answers_card_number = 0 @min = 0 - @hint_text = "This is the amount paid before any charges are added for services (for example, hot water or cleaning). Households may receive housing benefit or Universal Credit towards basic rent." @step = 0.01 @fields_to_add = %w[brent scharge pscharge supcharg] @result_field = "tcharge" diff --git a/app/models/form/lettings/questions/brent_monthly.rb b/app/models/form/lettings/questions/brent_monthly.rb index 7b567736b..a96239d7a 100644 --- a/app/models/form/lettings/questions/brent_monthly.rb +++ b/app/models/form/lettings/questions/brent_monthly.rb @@ -2,13 +2,11 @@ class Form::Lettings::Questions::BrentMonthly < ::Form::Question def initialize(id, hsh, page) super @id = "brent" - @check_answer_label = "Basic rent" - @header = "What is the basic rent?" + @copy_key = "lettings.income_and_benefits.rent_and_charges.brent" @type = "numeric" @width = 5 @check_answers_card_number = 0 @min = 0 - @hint_text = "This is the amount paid before any charges are added for services (for example, hot water or cleaning). Households may receive housing benefit or Universal Credit towards basic rent." @step = 0.01 @fields_to_add = %w[brent scharge pscharge supcharg] @result_field = "tcharge" diff --git a/app/models/form/lettings/questions/brent_weekly.rb b/app/models/form/lettings/questions/brent_weekly.rb index e604e5f34..155addfec 100644 --- a/app/models/form/lettings/questions/brent_weekly.rb +++ b/app/models/form/lettings/questions/brent_weekly.rb @@ -2,13 +2,11 @@ class Form::Lettings::Questions::BrentWeekly < ::Form::Question def initialize(id, hsh, page) super @id = "brent" - @check_answer_label = "Basic rent" - @header = "What is the basic rent?" + @copy_key = "lettings.income_and_benefits.rent_and_charges.brent" @type = "numeric" @width = 5 @check_answers_card_number = 0 @min = 0 - @hint_text = "This is the amount paid before any charges are added for services (for example, hot water or cleaning). Households may receive housing benefit or Universal Credit towards basic rent." @step = 0.01 @fields_to_add = %w[brent scharge pscharge supcharg] @result_field = "tcharge" diff --git a/app/models/form/lettings/questions/care_home_charges_value_check.rb b/app/models/form/lettings/questions/care_home_charges_value_check.rb index fdb5aabbd..a5f0d2522 100644 --- a/app/models/form/lettings/questions/care_home_charges_value_check.rb +++ b/app/models/form/lettings/questions/care_home_charges_value_check.rb @@ -2,8 +2,7 @@ class Form::Lettings::Questions::CareHomeChargesValueCheck < ::Form::Question def initialize(id, hsh, page) super @id = "carehome_charges_value_check" - @check_answer_label = "Care home charges confirmation" - @header = "Are you sure there are no care home charges?" + @copy_key = "lettings.soft_validations.care_home_charges_value_check" @type = "interruption_screen" @check_answers_card_number = 0 @answer_options = ANSWER_OPTIONS diff --git a/app/models/form/lettings/questions/chcharge_4_weekly.rb b/app/models/form/lettings/questions/chcharge_4_weekly.rb index b42bbe052..1cf3adae4 100644 --- a/app/models/form/lettings/questions/chcharge_4_weekly.rb +++ b/app/models/form/lettings/questions/chcharge_4_weekly.rb @@ -2,12 +2,10 @@ class Form::Lettings::Questions::Chcharge4Weekly < ::Form::Question def initialize(id, hsh, page) super @id = "chcharge" - @check_answer_label = "Care home charges" - @header = "How much does the household pay every 4 weeks?" + @copy_key = "lettings.income_and_benefits.care_home.chcharge_4_weekly" @type = "numeric" @width = 5 @check_answers_card_number = 0 - @hint_text = "" @step = 0.01 @prefix = "£" @suffix = " every 4 weeks" diff --git a/app/models/form/lettings/questions/chcharge_bi_weekly.rb b/app/models/form/lettings/questions/chcharge_bi_weekly.rb index 72de6d32b..c2abc4bdd 100644 --- a/app/models/form/lettings/questions/chcharge_bi_weekly.rb +++ b/app/models/form/lettings/questions/chcharge_bi_weekly.rb @@ -2,12 +2,10 @@ class Form::Lettings::Questions::ChchargeBiWeekly < ::Form::Question def initialize(id, hsh, page) super @id = "chcharge" - @check_answer_label = "Care home charges" - @header = "How much does the household pay every 2 weeks?" + @copy_key = "lettings.income_and_benefits.care_home.chcharge_bi_weekly" @type = "numeric" @width = 5 @check_answers_card_number = 0 - @hint_text = "" @step = 0.01 @prefix = "£" @suffix = " every 2 weeks" diff --git a/app/models/form/lettings/questions/chcharge_monthly.rb b/app/models/form/lettings/questions/chcharge_monthly.rb index c640085d2..d76a4ae1f 100644 --- a/app/models/form/lettings/questions/chcharge_monthly.rb +++ b/app/models/form/lettings/questions/chcharge_monthly.rb @@ -2,12 +2,10 @@ class Form::Lettings::Questions::ChchargeMonthly < ::Form::Question def initialize(id, hsh, page) super @id = "chcharge" - @check_answer_label = "Care home charges" - @header = "How much does the household pay every month?" + @copy_key = "lettings.income_and_benefits.care_home.chcharge_monthly" @type = "numeric" @width = 5 @check_answers_card_number = 0 - @hint_text = "" @step = 0.01 @prefix = "£" @suffix = " every month" diff --git a/app/models/form/lettings/questions/chcharge_weekly.rb b/app/models/form/lettings/questions/chcharge_weekly.rb index 484da8b5b..ab7f64622 100644 --- a/app/models/form/lettings/questions/chcharge_weekly.rb +++ b/app/models/form/lettings/questions/chcharge_weekly.rb @@ -2,12 +2,10 @@ class Form::Lettings::Questions::ChchargeWeekly < ::Form::Question def initialize(id, hsh, page) super @id = "chcharge" - @check_answer_label = "Care home charges" - @header = "How much does the household pay every week?" + @copy_key = "lettings.income_and_benefits.care_home.chcharge_weekly" @type = "numeric" @width = 5 @check_answers_card_number = 0 - @hint_text = "" @step = 0.01 @prefix = "£" @suffix = " every week" diff --git a/app/models/form/lettings/questions/declaration.rb b/app/models/form/lettings/questions/declaration.rb index 0e2fd5b2c..3261452cd 100644 --- a/app/models/form/lettings/questions/declaration.rb +++ b/app/models/form/lettings/questions/declaration.rb @@ -3,13 +3,13 @@ class Form::Lettings::Questions::Declaration < ::Form::Question super @id = "declaration" @type = "checkbox" - @check_answers_card_number = 0 unless form.start_year_after_2024? + @check_answers_card_number = 0 unless form.start_year_2024_or_later? @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 def answer_options - declaration_text = if form.start_year_after_2024? + declaration_text = if form.start_year_2024_or_later? "The tenant has seen or been given access to the MHCLG privacy notice" else "The tenant has seen the MHCLG privacy notice" @@ -19,7 +19,7 @@ class Form::Lettings::Questions::Declaration < ::Form::Question end def unanswered_error_message - if form.start_year_after_2024? + if form.start_year_2024_or_later? I18n.t("validations.declaration.missing.post_2024") else I18n.t("validations.declaration.missing.pre_2024") diff --git a/app/models/form/lettings/questions/earnings.rb b/app/models/form/lettings/questions/earnings.rb index 2ebb3e30b..9dc070e6a 100644 --- a/app/models/form/lettings/questions/earnings.rb +++ b/app/models/form/lettings/questions/earnings.rb @@ -2,14 +2,12 @@ class Form::Lettings::Questions::Earnings < ::Form::Question def initialize(id, hsh, page) super @id = "earnings" - @check_answer_label = "Total household income" - @header = "How much income does the household have in total?" + @copy_key = "lettings.income_and_benefits.income_amount.earnings" @type = "numeric" @width = 5 @check_answers_card_number = 0 @min = 0 @top_guidance_partial = "what_counts_as_income" - @hint_text = "" @step = 0.01 @prefix = "£" @suffix = [ diff --git a/app/models/form/lettings/questions/ethnic_white.rb b/app/models/form/lettings/questions/ethnic_white.rb index 40b99bc9f..74430d840 100644 --- a/app/models/form/lettings/questions/ethnic_white.rb +++ b/app/models/form/lettings/questions/ethnic_white.rb @@ -9,7 +9,7 @@ class Form::Lettings::Questions::EthnicWhite < ::Form::Question end def answer_options - if form.start_year_after_2024? + if form.start_year_2024_or_later? { "1" => { "value" => "English, Welsh, Northern Irish, Scottish or British" }, "2" => { "value" => "Irish" }, 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 9d54cfcb3..bc1c66cb4 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 @@ -15,11 +15,11 @@ class Form::Lettings::Questions::FirstTimePropertyLetAsSocialHousing < ::Form::Q end def yes_hint - form.start_year_after_2024? ? "This property was previously used for other purposes or is a new-build." : "This is a new let." + form.start_year_2024_or_later? ? "This property was previously used for other purposes or is a new-build." : "This is a new let." end def no_hint - form.start_year_after_2024? ? "This is a re-let of existing social housing stock." : "This is a re-let of existing social housing." + form.start_year_2024_or_later? ? "This is a re-let of existing social housing stock." : "This is a re-let of existing social housing." end QUESTION_NUMBER_FROM_YEAR = { 2023 => 14, 2024 => 15 }.freeze diff --git a/app/models/form/lettings/questions/hb.rb b/app/models/form/lettings/questions/hb.rb index a3feba77a..4f4703993 100644 --- a/app/models/form/lettings/questions/hb.rb +++ b/app/models/form/lettings/questions/hb.rb @@ -2,11 +2,8 @@ class Form::Lettings::Questions::Hb < ::Form::Question def initialize(id, hsh, page) super @id = "hb" - @check_answer_label = "Housing-related benefits received" - @header = "Is the household likely to be receiving any of these housing-related benefits?" @type = "radio" @check_answers_card_number = 0 - @hint_text = form.start_year_after_2024? ? "This is about when the tenant is in their new let. If they are unsure about the situation for their new let and their financial and working situation hasn’t changed significantly, answer based on what housing-related benefits they currently receive." : "" @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/hbrentshortfall.rb b/app/models/form/lettings/questions/hbrentshortfall.rb index ee9546e73..a34df70e0 100644 --- a/app/models/form/lettings/questions/hbrentshortfall.rb +++ b/app/models/form/lettings/questions/hbrentshortfall.rb @@ -2,11 +2,8 @@ class Form::Lettings::Questions::Hbrentshortfall < ::Form::Question def initialize(id, hsh, page) super @id = "hbrentshortfall" - @check_answer_label = "Any outstanding amount for basic rent and charges" - @header = "After the household has received any housing-related benefits, will they still need to pay for rent and charges?" @type = "radio" @check_answers_card_number = 0 - @hint_text = "Also known as the ‘outstanding amount’." @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/household_charge.rb b/app/models/form/lettings/questions/household_charge.rb index 7f89aa548..60fee977d 100644 --- a/app/models/form/lettings/questions/household_charge.rb +++ b/app/models/form/lettings/questions/household_charge.rb @@ -2,11 +2,8 @@ class Form::Lettings::Questions::HouseholdCharge < ::Form::Question def initialize(id, hsh, page) super @id = "household_charge" - @check_answer_label = "Does the household pay rent or charges?" - @header = "Does the household pay rent or other charges for the accommodation?" @type = "radio" @check_answers_card_number = 0 - @hint_text = "If rent is charged on the property then answer Yes to this question, even if the tenants do not pay it themselves." @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 75834d3bb..fc403d00c 100644 --- a/app/models/form/lettings/questions/housingneeds_other.rb +++ b/app/models/form/lettings/questions/housingneeds_other.rb @@ -9,7 +9,7 @@ class Form::Lettings::Questions::HousingneedsOther < ::Form::Question end def answer_options - if form.start_year_after_2024? + if form.start_year_2024_or_later? { "1" => { "value" => "Yes" }, "0" => { "value" => "No" }, diff --git a/app/models/form/lettings/questions/incfreq.rb b/app/models/form/lettings/questions/incfreq.rb index 3067c5c98..d4384218e 100644 --- a/app/models/form/lettings/questions/incfreq.rb +++ b/app/models/form/lettings/questions/incfreq.rb @@ -2,11 +2,9 @@ class Form::Lettings::Questions::Incfreq < ::Form::Question def initialize(id, hsh, page) super @id = "incfreq" - @check_answer_label = "How often does the household receive this amount?" - @header = "How often does the household receive this amount?" + @copy_key = "lettings.income_and_benefits.income_amount.incfreq" @type = "radio" @check_answers_card_number = 0 - @hint_text = "" @answer_options = ANSWER_OPTIONS @hidden_in_check_answers = true @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/is_carehome.rb b/app/models/form/lettings/questions/is_carehome.rb index 41996b4f0..25dae3fc6 100644 --- a/app/models/form/lettings/questions/is_carehome.rb +++ b/app/models/form/lettings/questions/is_carehome.rb @@ -2,17 +2,15 @@ class Form::Lettings::Questions::IsCarehome < ::Form::Question def initialize(id, hsh, page) super @id = "is_carehome" - @check_answer_label = "Care home accommodation" - @header = "Is this accommodation a care home?" + @copy_key = "lettings.income_and_benefits.care_home.is_carehome" @type = "radio" @check_answers_card_number = 0 - @hint_text = "" @conditional_for = { "chcharge" => [1] } @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end def answer_options - if form.start_year_after_2024? + if form.start_year_2024_or_later? { "1" => { "value" => "Yes" }, "0" => { "value" => "No" }, diff --git a/app/models/form/lettings/questions/layear.rb b/app/models/form/lettings/questions/layear.rb index 63f99c36f..fdaad6c22 100644 --- a/app/models/form/lettings/questions/layear.rb +++ b/app/models/form/lettings/questions/layear.rb @@ -8,7 +8,7 @@ class Form::Lettings::Questions::Layear < ::Form::Question end def answer_options - if form.start_year_after_2024? + if form.start_year_2024_or_later? { "1" => { "value" => "Just moved to local authority area with this new let" }, "2" => { "value" => "Less than 1 year" }, diff --git a/app/models/form/lettings/questions/letting_allocation.rb b/app/models/form/lettings/questions/letting_allocation.rb index 0ae7b740d..08310da13 100644 --- a/app/models/form/lettings/questions/letting_allocation.rb +++ b/app/models/form/lettings/questions/letting_allocation.rb @@ -8,7 +8,7 @@ class Form::Lettings::Questions::LettingAllocation < ::Form::Question end def answer_options - if form.start_year_after_2024? + if form.start_year_2024_or_later? { "cbl" => { "value" => "Choice-based lettings (CBL)", "hint" => "Where available vacant properties are advertised and applicants are able to bid for specific properties." }, "cap" => { "value" => "Common Allocation Policy (CAP)", "hint" => "Where a common system agreed between a group of housing providers is used to determine applicant’s priority for housing." }, diff --git a/app/models/form/lettings/questions/major_repairs_date_value_check.rb b/app/models/form/lettings/questions/major_repairs_date_value_check.rb index d024f1a8d..0e9cb4171 100644 --- a/app/models/form/lettings/questions/major_repairs_date_value_check.rb +++ b/app/models/form/lettings/questions/major_repairs_date_value_check.rb @@ -2,8 +2,7 @@ class Form::Lettings::Questions::MajorRepairsDateValueCheck < ::Form::Question def initialize(id, hsh, page) super @id = "major_repairs_date_value_check" - @check_answer_label = "Major repairs date confirmation" - @header = "Are you sure the property has been vacant for this long?" + @copy_key = "lettings.soft_validations.major_repairs_date_value_check" @type = "interruption_screen" @check_answers_card_number = 0 @answer_options = ANSWER_OPTIONS diff --git a/app/models/form/lettings/questions/multiple_partners_value_check.rb b/app/models/form/lettings/questions/multiple_partners_value_check.rb index 65320ffdf..9dd9f7015 100644 --- a/app/models/form/lettings/questions/multiple_partners_value_check.rb +++ b/app/models/form/lettings/questions/multiple_partners_value_check.rb @@ -2,7 +2,7 @@ class Form::Lettings::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 = "lettings.soft_validations.multiple_partners_value_check" @type = "interruption_screen" @answer_options = { "0" => { "value" => "Yes" }, @@ -19,6 +19,5 @@ class Form::Lettings::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/lettings/questions/net_income_known.rb b/app/models/form/lettings/questions/net_income_known.rb index 5858d4d26..01c3bcaa3 100644 --- a/app/models/form/lettings/questions/net_income_known.rb +++ b/app/models/form/lettings/questions/net_income_known.rb @@ -2,12 +2,9 @@ class Form::Lettings::Questions::NetIncomeKnown < ::Form::Question def initialize(id, hsh, page) super @id = "net_income_known" - @check_answer_label = "Do you know the household’s combined total income after tax?" - @header = "Do you know the household’s combined income after tax?" @type = "radio" @check_answers_card_number = 0 @top_guidance_partial = "what_counts_as_income" - @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/net_income_value_check.rb b/app/models/form/lettings/questions/net_income_value_check.rb index 8267b3b22..4e85fee90 100644 --- a/app/models/form/lettings/questions/net_income_value_check.rb +++ b/app/models/form/lettings/questions/net_income_value_check.rb @@ -2,8 +2,7 @@ class Form::Lettings::Questions::NetIncomeValueCheck < ::Form::Question def initialize(id, hsh, page) super @id = "net_income_value_check" - @check_answer_label = "Net income confirmation" - @header = "Are you sure this is correct?" + @copy_key = "lettings.soft_validations.net_income_value_check" @type = "interruption_screen" @check_answers_card_number = 0 @answer_options = ANSWER_OPTIONS diff --git a/app/models/form/lettings/questions/no_retirement_value_check.rb b/app/models/form/lettings/questions/no_retirement_value_check.rb index 0e2033c61..82784dec8 100644 --- a/app/models/form/lettings/questions/no_retirement_value_check.rb +++ b/app/models/form/lettings/questions/no_retirement_value_check.rb @@ -2,8 +2,7 @@ class Form::Lettings::Questions::NoRetirementValueCheck < ::Form::Question def initialize(id, hsh, page, person_index:) super(id, hsh, page) @id = "retirement_value_check" - @check_answer_label = "Retirement confirmation" - @header = "Are you sure this person is retired?" + @copy_key = "lettings.soft_validations.no_retirement_value_check" @type = "interruption_screen" @check_answers_card_number = person_index @answer_options = ANSWER_OPTIONS diff --git a/app/models/form/lettings/questions/partner_under_16_value_check.rb b/app/models/form/lettings/questions/partner_under_16_value_check.rb index 7cda45cb5..bc11aec47 100644 --- a/app/models/form/lettings/questions/partner_under_16_value_check.rb +++ b/app/models/form/lettings/questions/partner_under_16_value_check.rb @@ -2,7 +2,7 @@ class Form::Lettings::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 = "lettings.soft_validations.partner_under_16_value_check" @type = "interruption_screen" @answer_options = { "0" => { "value" => "Yes" }, @@ -19,6 +19,5 @@ class Form::Lettings::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/lettings/questions/period.rb b/app/models/form/lettings/questions/period.rb index aefe8be84..6f98bd2a8 100644 --- a/app/models/form/lettings/questions/period.rb +++ b/app/models/form/lettings/questions/period.rb @@ -2,11 +2,8 @@ class Form::Lettings::Questions::Period < ::Form::Question def initialize(id, hsh, page) super @id = "period" - @check_answer_label = "Frequency of household rent and charges" - @header = "How often does the household pay rent and other charges?" @type = "radio" @check_answers_card_number = 0 - @hint_text = "Select how often the household is charged. This may be different to how often they pay." @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/person_relationship.rb b/app/models/form/lettings/questions/person_relationship.rb index ec7a78969..d39cb49ff 100644 --- a/app/models/form/lettings/questions/person_relationship.rb +++ b/app/models/form/lettings/questions/person_relationship.rb @@ -10,7 +10,7 @@ class Form::Lettings::Questions::PersonRelationship < ::Form::Question end def answer_options - if form.start_year_after_2024? + if form.start_year_2024_or_later? { "P" => { "value" => "Partner" }, "C" => { "value" => "Child" }, diff --git a/app/models/form/lettings/questions/pregnancy_value_check.rb b/app/models/form/lettings/questions/pregnancy_value_check.rb index 9ef1778c2..0ddddecec 100644 --- a/app/models/form/lettings/questions/pregnancy_value_check.rb +++ b/app/models/form/lettings/questions/pregnancy_value_check.rb @@ -2,8 +2,7 @@ class Form::Lettings::Questions::PregnancyValueCheck < ::Form::Question def initialize(id, hsh, page, person_index:) super(id, hsh, page) @id = "pregnancy_value_check" - @check_answer_label = "Pregnancy confirmation" - @header = "Are you sure this is correct?" + @copy_key = page.copy_key @type = "interruption_screen" @check_answers_card_number = person_index @answer_options = ANSWER_OPTIONS diff --git a/app/models/form/lettings/questions/previous_let_type.rb b/app/models/form/lettings/questions/previous_let_type.rb index 577571571..8c50cb41a 100644 --- a/app/models/form/lettings/questions/previous_let_type.rb +++ b/app/models/form/lettings/questions/previous_let_type.rb @@ -4,7 +4,7 @@ class Form::Lettings::Questions::PreviousLetType < ::Form::Question @id = "unitletas" @type = "radio" @check_answers_card_number = 0 - @answer_options = form.start_year_after_2024? ? ANSWER_OPTIONS_AFTER_2024 : ANSWER_OPTIONS + @answer_options = form.start_year_2024_or_later? ? 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/pscharge_4_weekly.rb b/app/models/form/lettings/questions/pscharge_4_weekly.rb index 0340e55b8..56d2e60b8 100644 --- a/app/models/form/lettings/questions/pscharge_4_weekly.rb +++ b/app/models/form/lettings/questions/pscharge_4_weekly.rb @@ -2,13 +2,11 @@ class Form::Lettings::Questions::Pscharge4Weekly < ::Form::Question def initialize(id, hsh, page) super @id = "pscharge" - @check_answer_label = "Personal service charge" - @header = "What is the personal service charge?" + @copy_key = "lettings.income_and_benefits.rent_and_charges.pscharge" @type = "numeric" @width = 5 @check_answers_card_number = 0 @min = 0 - @hint_text = "For example, for heating or hot water. This doesn’t include housing benefit or Universal Credit." @step = 0.01 @fields_to_add = %w[brent scharge pscharge supcharg] @result_field = "tcharge" diff --git a/app/models/form/lettings/questions/pscharge_bi_weekly.rb b/app/models/form/lettings/questions/pscharge_bi_weekly.rb index db4e040f0..6022f6019 100644 --- a/app/models/form/lettings/questions/pscharge_bi_weekly.rb +++ b/app/models/form/lettings/questions/pscharge_bi_weekly.rb @@ -2,13 +2,11 @@ class Form::Lettings::Questions::PschargeBiWeekly < ::Form::Question def initialize(id, hsh, page) super @id = "pscharge" - @check_answer_label = "Personal service charge" - @header = "What is the personal service charge?" + @copy_key = "lettings.income_and_benefits.rent_and_charges.pscharge" @type = "numeric" @width = 5 @check_answers_card_number = 0 @min = 0 - @hint_text = "For example, for heating or hot water. This doesn’t include housing benefit or Universal Credit." @step = 0.01 @fields_to_add = %w[brent scharge pscharge supcharg] @result_field = "tcharge" diff --git a/app/models/form/lettings/questions/pscharge_monthly.rb b/app/models/form/lettings/questions/pscharge_monthly.rb index e96cd32d4..225db53d3 100644 --- a/app/models/form/lettings/questions/pscharge_monthly.rb +++ b/app/models/form/lettings/questions/pscharge_monthly.rb @@ -2,13 +2,11 @@ class Form::Lettings::Questions::PschargeMonthly < ::Form::Question def initialize(id, hsh, page) super @id = "pscharge" - @check_answer_label = "Personal service charge" - @header = "What is the personal service charge?" + @copy_key = "lettings.income_and_benefits.rent_and_charges.pscharge" @type = "numeric" @width = 5 @check_answers_card_number = 0 @min = 0 - @hint_text = "For example, for heating or hot water. This doesn’t include housing benefit or Universal Credit." @step = 0.01 @fields_to_add = %w[brent scharge pscharge supcharg] @result_field = "tcharge" diff --git a/app/models/form/lettings/questions/pscharge_value_check.rb b/app/models/form/lettings/questions/pscharge_value_check.rb index b44979ae1..efb94fb53 100644 --- a/app/models/form/lettings/questions/pscharge_value_check.rb +++ b/app/models/form/lettings/questions/pscharge_value_check.rb @@ -2,13 +2,11 @@ class Form::Lettings::Questions::PschargeValueCheck < ::Form::Question def initialize(id, hsh, page) super @id = "pscharge_value_check" - @check_answer_label = "Personal service charge confirmation" - @header = "Are you sure?" + @copy_key = "lettings.soft_validations.pscharge_value_check" @type = "interruption_screen" @check_answers_card_number = 0 @answer_options = ANSWER_OPTIONS @hidden_in_check_answers = { "depends_on" => [{ "pscharge_value_check" => 0 }, { "pscharge_value_check" => 1 }] } - @hint_text = I18n.t("soft_validations.charges.hint_text") end ANSWER_OPTIONS = { "0" => { "value" => "Yes" }, "1" => { "value" => "No" } }.freeze diff --git a/app/models/form/lettings/questions/pscharge_weekly.rb b/app/models/form/lettings/questions/pscharge_weekly.rb index 6b5fa9889..2ff06301c 100644 --- a/app/models/form/lettings/questions/pscharge_weekly.rb +++ b/app/models/form/lettings/questions/pscharge_weekly.rb @@ -2,13 +2,11 @@ class Form::Lettings::Questions::PschargeWeekly < ::Form::Question def initialize(id, hsh, page) super @id = "pscharge" - @check_answer_label = "Personal service charge" - @header = "What is the personal service charge?" + @copy_key = "lettings.income_and_benefits.rent_and_charges.pscharge" @type = "numeric" @width = 5 @check_answers_card_number = 0 @min = 0 - @hint_text = "For example, for heating or hot water. This doesn’t include housing benefit or Universal Credit." @step = 0.01 @fields_to_add = %w[brent scharge pscharge supcharg] @result_field = "tcharge" diff --git a/app/models/form/lettings/questions/reason.rb b/app/models/form/lettings/questions/reason.rb index 4bc00ce43..3a659fc5c 100644 --- a/app/models/form/lettings/questions/reason.rb +++ b/app/models/form/lettings/questions/reason.rb @@ -14,7 +14,7 @@ class Form::Lettings::Questions::Reason < ::Form::Question end def answer_options - if form.start_year_after_2024? + if form.start_year_2024_or_later? { "50" => { "value" => "End of social or private sector tenancy - no fault" }, "51" => { "value" => "End of social or private sector tenancy - evicted due to anti-social behaviour (ASB)" }, diff --git a/app/models/form/lettings/questions/reason_renewal.rb b/app/models/form/lettings/questions/reason_renewal.rb index 9a9ee72de..c00bd2581 100644 --- a/app/models/form/lettings/questions/reason_renewal.rb +++ b/app/models/form/lettings/questions/reason_renewal.rb @@ -14,7 +14,7 @@ class Form::Lettings::Questions::ReasonRenewal < ::Form::Question end def answer_options - if form.start_year_after_2024? + if form.start_year_2024_or_later? { "50" => { "value" => "End of social or private sector tenancy - no fault" }, "51" => { "value" => "End of social or private sector tenancy - evicted due to anti-social behaviour (ASB)" }, diff --git a/app/models/form/lettings/questions/reasonother_value_check.rb b/app/models/form/lettings/questions/reasonother_value_check.rb index 865f38764..9fb5618fc 100644 --- a/app/models/form/lettings/questions/reasonother_value_check.rb +++ b/app/models/form/lettings/questions/reasonother_value_check.rb @@ -2,8 +2,7 @@ class Form::Lettings::Questions::ReasonotherValueCheck < ::Form::Question def initialize(id, hsh, page) super @id = "reasonother_value_check" - @check_answer_label = "Reason other confirmation" - @header = "Are you sure this doesn’t fit an existing category?" + @copy_key = "lettings.soft_validations.reasonother_value_check" @type = "interruption_screen" @check_answers_card_number = 0 @answer_options = ANSWER_OPTIONS diff --git a/app/models/form/lettings/questions/referral.rb b/app/models/form/lettings/questions/referral.rb index 904668a4b..98e5a9186 100644 --- a/app/models/form/lettings/questions/referral.rb +++ b/app/models/form/lettings/questions/referral.rb @@ -9,7 +9,7 @@ class Form::Lettings::Questions::Referral < ::Form::Question end def answer_options - if form.start_year_after_2024? + if form.start_year_2024_or_later? { "1" => { "value" => "Internal transfer", diff --git a/app/models/form/lettings/questions/referral_prp.rb b/app/models/form/lettings/questions/referral_prp.rb index 76ad3fbf8..96da2cba3 100644 --- a/app/models/form/lettings/questions/referral_prp.rb +++ b/app/models/form/lettings/questions/referral_prp.rb @@ -9,7 +9,7 @@ class Form::Lettings::Questions::ReferralPrp < ::Form::Question end def answer_options - if form.start_year_after_2024? + if form.start_year_2024_or_later? { "1" => { "value" => "Internal transfer", diff --git a/app/models/form/lettings/questions/referral_supported_housing.rb b/app/models/form/lettings/questions/referral_supported_housing.rb index 50822705e..d8d05fade 100644 --- a/app/models/form/lettings/questions/referral_supported_housing.rb +++ b/app/models/form/lettings/questions/referral_supported_housing.rb @@ -9,7 +9,7 @@ class Form::Lettings::Questions::ReferralSupportedHousing < ::Form::Question end def answer_options - if form.start_year_after_2024? + if form.start_year_2024_or_later? { "1" => { "value" => "Internal transfer", 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 cab8fbbc9..75cc218fe 100644 --- a/app/models/form/lettings/questions/referral_supported_housing_prp.rb +++ b/app/models/form/lettings/questions/referral_supported_housing_prp.rb @@ -9,7 +9,7 @@ class Form::Lettings::Questions::ReferralSupportedHousingPrp < ::Form::Question end def answer_options - if form.start_year_after_2024? + if form.start_year_2024_or_later? { "1" => { "value" => "Internal transfer", diff --git a/app/models/form/lettings/questions/referral_value_check.rb b/app/models/form/lettings/questions/referral_value_check.rb index 30aa45f4c..04dfadd9e 100644 --- a/app/models/form/lettings/questions/referral_value_check.rb +++ b/app/models/form/lettings/questions/referral_value_check.rb @@ -2,8 +2,7 @@ class Form::Lettings::Questions::ReferralValueCheck < ::Form::Question def initialize(id, hsh, page) super @id = "referral_value_check" - @check_answer_label = "Referral confirmation" - @header = "Are you sure?" + @copy_key = "lettings.soft_validations.referral_value_check" @type = "interruption_screen" @check_answers_card_number = 0 @answer_options = ANSWER_OPTIONS diff --git a/app/models/form/lettings/questions/rent_type.rb b/app/models/form/lettings/questions/rent_type.rb index bc6934200..b941dfcc3 100644 --- a/app/models/form/lettings/questions/rent_type.rb +++ b/app/models/form/lettings/questions/rent_type.rb @@ -5,7 +5,7 @@ class Form::Lettings::Questions::RentType < ::Form::Question @copy_key = "lettings.setup.rent_type.rent_type" @type = "radio" @top_guidance_partial = "rent_type_definitions" - @answer_options = form.start_year_after_2024? ? ANSWER_OPTIONS_2024 : ANSWER_OPTIONS + @answer_options = form.start_year_2024_or_later? ? 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? end diff --git a/app/models/form/lettings/questions/rent_value_check.rb b/app/models/form/lettings/questions/rent_value_check.rb index 688499259..fb7ac8d16 100644 --- a/app/models/form/lettings/questions/rent_value_check.rb +++ b/app/models/form/lettings/questions/rent_value_check.rb @@ -2,10 +2,8 @@ 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?" + @copy_key = "lettings.soft_validations.rent_value_check" @type = "interruption_screen" - @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/questions/retirement_value_check.rb b/app/models/form/lettings/questions/retirement_value_check.rb index 63a286d61..23d077fbf 100644 --- a/app/models/form/lettings/questions/retirement_value_check.rb +++ b/app/models/form/lettings/questions/retirement_value_check.rb @@ -2,8 +2,7 @@ class Form::Lettings::Questions::RetirementValueCheck < ::Form::Question def initialize(id, hsh, page, person_index:) super(id, hsh, page) @id = "retirement_value_check" - @check_answer_label = "Retirement confirmation" - @header = "Are you sure this person isn’t retired?" + @copy_key = "lettings.soft_validations.retirement_value_check" @type = "interruption_screen" @check_answers_card_number = person_index @answer_options = ANSWER_OPTIONS diff --git a/app/models/form/lettings/questions/rsnvac.rb b/app/models/form/lettings/questions/rsnvac.rb index 935980712..3f767d311 100644 --- a/app/models/form/lettings/questions/rsnvac.rb +++ b/app/models/form/lettings/questions/rsnvac.rb @@ -8,7 +8,7 @@ class Form::Lettings::Questions::Rsnvac < ::Form::Question end def answer_options - if form.start_year_after_2024? + if form.start_year_2024_or_later? { "14" => { "value" => "Renewal of fixed-term tenancy", diff --git a/app/models/form/lettings/questions/scharge_4_weekly.rb b/app/models/form/lettings/questions/scharge_4_weekly.rb index a2f81c6ef..e91dadab3 100644 --- a/app/models/form/lettings/questions/scharge_4_weekly.rb +++ b/app/models/form/lettings/questions/scharge_4_weekly.rb @@ -2,13 +2,11 @@ class Form::Lettings::Questions::Scharge4Weekly < ::Form::Question def initialize(id, hsh, page) super @id = "scharge" - @check_answer_label = "Service charge" - @header = "What is the service charge?" + @copy_key = "lettings.income_and_benefits.rent_and_charges.scharge" @type = "numeric" @width = 5 @check_answers_card_number = 0 @min = 0 - @hint_text = "For example, for cleaning. Households may receive housing benefit or Universal Credit towards the service charge." @step = 0.01 @fields_to_add = %w[brent scharge pscharge supcharg] @result_field = "tcharge" diff --git a/app/models/form/lettings/questions/scharge_bi_weekly.rb b/app/models/form/lettings/questions/scharge_bi_weekly.rb index a19acbab5..59138835d 100644 --- a/app/models/form/lettings/questions/scharge_bi_weekly.rb +++ b/app/models/form/lettings/questions/scharge_bi_weekly.rb @@ -2,13 +2,11 @@ class Form::Lettings::Questions::SchargeBiWeekly < ::Form::Question def initialize(id, hsh, page) super @id = "scharge" - @check_answer_label = "Service charge" - @header = "What is the service charge?" + @copy_key = "lettings.income_and_benefits.rent_and_charges.scharge" @type = "numeric" @width = 5 @check_answers_card_number = 0 @min = 0 - @hint_text = "For example, for cleaning. Households may receive housing benefit or Universal Credit towards the service charge." @step = 0.01 @fields_to_add = %w[brent scharge pscharge supcharg] @result_field = "tcharge" diff --git a/app/models/form/lettings/questions/scharge_monthly.rb b/app/models/form/lettings/questions/scharge_monthly.rb index eb399b0de..33404a8ce 100644 --- a/app/models/form/lettings/questions/scharge_monthly.rb +++ b/app/models/form/lettings/questions/scharge_monthly.rb @@ -2,13 +2,11 @@ class Form::Lettings::Questions::SchargeMonthly < ::Form::Question def initialize(id, hsh, page) super @id = "scharge" - @check_answer_label = "Service charge" - @header = "What is the service charge?" + @copy_key = "lettings.income_and_benefits.rent_and_charges.scharge" @type = "numeric" @width = 5 @check_answers_card_number = 0 @min = 0 - @hint_text = "For example, for cleaning. Households may receive housing benefit or Universal Credit towards the service charge." @step = 0.01 @fields_to_add = %w[brent scharge pscharge supcharg] @result_field = "tcharge" diff --git a/app/models/form/lettings/questions/scharge_value_check.rb b/app/models/form/lettings/questions/scharge_value_check.rb index 1946d603f..0f761b7aa 100644 --- a/app/models/form/lettings/questions/scharge_value_check.rb +++ b/app/models/form/lettings/questions/scharge_value_check.rb @@ -2,13 +2,11 @@ class Form::Lettings::Questions::SchargeValueCheck < ::Form::Question def initialize(id, hsh, page) super @id = "scharge_value_check" - @check_answer_label = "Service charge confirmation" - @header = "Are you sure?" + @copy_key = "lettings.soft_validations.scharge_value_check" @type = "interruption_screen" @check_answers_card_number = 0 @answer_options = ANSWER_OPTIONS @hidden_in_check_answers = { "depends_on" => [{ "scharge_value_check" => 0 }, { "scharge_value_check" => 1 }] } - @hint_text = I18n.t("soft_validations.charges.hint_text") end ANSWER_OPTIONS = { "0" => { "value" => "Yes" }, "1" => { "value" => "No" } }.freeze diff --git a/app/models/form/lettings/questions/scharge_weekly.rb b/app/models/form/lettings/questions/scharge_weekly.rb index faf854b82..d8e16986e 100644 --- a/app/models/form/lettings/questions/scharge_weekly.rb +++ b/app/models/form/lettings/questions/scharge_weekly.rb @@ -2,13 +2,11 @@ class Form::Lettings::Questions::SchargeWeekly < ::Form::Question def initialize(id, hsh, page) super @id = "scharge" - @check_answer_label = "Service charge" - @header = "What is the service charge?" + @copy_key = "lettings.income_and_benefits.rent_and_charges.scharge" @type = "numeric" @width = 5 @check_answers_card_number = 0 @min = 0 - @hint_text = "For example, for cleaning. Households may receive housing benefit or Universal Credit towards the service charge." @step = 0.01 @fields_to_add = %w[brent scharge pscharge supcharg] @result_field = "tcharge" diff --git a/app/models/form/lettings/questions/sheltered.rb b/app/models/form/lettings/questions/sheltered.rb index 7b80bb5bf..458772675 100644 --- a/app/models/form/lettings/questions/sheltered.rb +++ b/app/models/form/lettings/questions/sheltered.rb @@ -8,7 +8,7 @@ class Form::Lettings::Questions::Sheltered < ::Form::Question end def answer_options - if form.start_year_after_2024? + if form.start_year_2024_or_later? { "1" => { "value" => "Yes – specialist retirement housing" }, "2" => { "value" => "Yes – extra care housing" }, "5" => { "value" => "Yes – sheltered housing for adults aged under 55 years" }, diff --git a/app/models/form/lettings/questions/starter_tenancy_type.rb b/app/models/form/lettings/questions/starter_tenancy_type.rb index 85d4a14ff..03d3fee88 100644 --- a/app/models/form/lettings/questions/starter_tenancy_type.rb +++ b/app/models/form/lettings/questions/starter_tenancy_type.rb @@ -10,7 +10,7 @@ class Form::Lettings::Questions::StarterTenancyType < ::Form::Question end def answer_options - if form.start_year_after_2024? + if form.start_year_2024_or_later? { "4" => { "value" => "Assured Shorthold Tenancy (AST) – Fixed term", diff --git a/app/models/form/lettings/questions/supcharg_4_weekly.rb b/app/models/form/lettings/questions/supcharg_4_weekly.rb index 292578d56..cd3b7beed 100644 --- a/app/models/form/lettings/questions/supcharg_4_weekly.rb +++ b/app/models/form/lettings/questions/supcharg_4_weekly.rb @@ -2,13 +2,11 @@ class Form::Lettings::Questions::Supcharg4Weekly < ::Form::Question def initialize(id, hsh, page) super @id = "supcharg" - @check_answer_label = "Support charge" - @header = "What is the support charge?" + @copy_key = "lettings.income_and_benefits.rent_and_charges.supcharg" @type = "numeric" @width = 5 @check_answers_card_number = 0 @min = 0 - @hint_text = "Any charges made to fund support services included in tenancy agreement." @step = 0.01 @fields_to_add = %w[brent scharge pscharge supcharg] @result_field = "tcharge" diff --git a/app/models/form/lettings/questions/supcharg_bi_weekly.rb b/app/models/form/lettings/questions/supcharg_bi_weekly.rb index 4f6daf141..dba861ebe 100644 --- a/app/models/form/lettings/questions/supcharg_bi_weekly.rb +++ b/app/models/form/lettings/questions/supcharg_bi_weekly.rb @@ -2,13 +2,11 @@ class Form::Lettings::Questions::SupchargBiWeekly < ::Form::Question def initialize(id, hsh, page) super @id = "supcharg" - @check_answer_label = "Support charge" - @header = "What is the support charge?" + @copy_key = "lettings.income_and_benefits.rent_and_charges.supcharg" @type = "numeric" @width = 5 @check_answers_card_number = 0 @min = 0 - @hint_text = "Any charges made to fund support services included in tenancy agreement." @step = 0.01 @fields_to_add = %w[brent scharge pscharge supcharg] @result_field = "tcharge" diff --git a/app/models/form/lettings/questions/supcharg_monthly.rb b/app/models/form/lettings/questions/supcharg_monthly.rb index 9dd1c669b..3b5b3e41c 100644 --- a/app/models/form/lettings/questions/supcharg_monthly.rb +++ b/app/models/form/lettings/questions/supcharg_monthly.rb @@ -2,13 +2,11 @@ class Form::Lettings::Questions::SupchargMonthly < ::Form::Question def initialize(id, hsh, page) super @id = "supcharg" - @check_answer_label = "Support charge" - @header = "What is the support charge?" + @copy_key = "lettings.income_and_benefits.rent_and_charges.supcharg" @type = "numeric" @width = 5 @check_answers_card_number = 0 @min = 0 - @hint_text = "Any charges made to fund support services included in tenancy agreement." @step = 0.01 @fields_to_add = %w[brent scharge pscharge supcharg] @result_field = "tcharge" diff --git a/app/models/form/lettings/questions/supcharg_value_check.rb b/app/models/form/lettings/questions/supcharg_value_check.rb index 978c5e3ef..10fd6562c 100644 --- a/app/models/form/lettings/questions/supcharg_value_check.rb +++ b/app/models/form/lettings/questions/supcharg_value_check.rb @@ -2,13 +2,11 @@ class Form::Lettings::Questions::SupchargValueCheck < ::Form::Question def initialize(id, hsh, page) super @id = "supcharg_value_check" - @check_answer_label = "Support charge confirmation" - @header = "Are you sure?" + @copy_key = "lettings.soft_validations.supcharg_value_check" @type = "interruption_screen" @check_answers_card_number = 0 @answer_options = ANSWER_OPTIONS @hidden_in_check_answers = { "depends_on" => [{ "supcharg_value_check" => 0 }, { "supcharg_value_check" => 1 }] } - @hint_text = I18n.t("soft_validations.charges.hint_text") end ANSWER_OPTIONS = { "0" => { "value" => "Yes" }, "1" => { "value" => "No" } }.freeze diff --git a/app/models/form/lettings/questions/supcharg_weekly.rb b/app/models/form/lettings/questions/supcharg_weekly.rb index 54a9743b6..f48a8ccfe 100644 --- a/app/models/form/lettings/questions/supcharg_weekly.rb +++ b/app/models/form/lettings/questions/supcharg_weekly.rb @@ -2,13 +2,11 @@ class Form::Lettings::Questions::SupchargWeekly < ::Form::Question def initialize(id, hsh, page) super @id = "supcharg" - @check_answer_label = "Support charge" - @header = "What is the support charge?" + @copy_key = "lettings.income_and_benefits.rent_and_charges.supcharg" @type = "numeric" @width = 5 @check_answers_card_number = 0 @min = 0 - @hint_text = "Any charges made to fund support services included in tenancy agreement." @step = 0.01 @fields_to_add = %w[brent scharge pscharge supcharg] @result_field = "tcharge" diff --git a/app/models/form/lettings/questions/tcharge_4_weekly.rb b/app/models/form/lettings/questions/tcharge_4_weekly.rb index 3a353efe8..6475adab0 100644 --- a/app/models/form/lettings/questions/tcharge_4_weekly.rb +++ b/app/models/form/lettings/questions/tcharge_4_weekly.rb @@ -2,13 +2,11 @@ class Form::Lettings::Questions::Tcharge4Weekly < ::Form::Question def initialize(id, hsh, page) super @id = "tcharge" - @check_answer_label = "Household rent and charges" - @header = "Total charge" + @copy_key = "lettings.income_and_benefits.rent_and_charges.tcharge" @type = "numeric_output" @width = 5 @check_answers_card_number = 0 @min = 0 - @hint_text = "This is the total for rent and all charges." @step = 0.01 @readonly = true @prefix = "£" diff --git a/app/models/form/lettings/questions/tcharge_bi_weekly.rb b/app/models/form/lettings/questions/tcharge_bi_weekly.rb index 42fd9398b..446886d9d 100644 --- a/app/models/form/lettings/questions/tcharge_bi_weekly.rb +++ b/app/models/form/lettings/questions/tcharge_bi_weekly.rb @@ -2,13 +2,11 @@ class Form::Lettings::Questions::TchargeBiWeekly < ::Form::Question def initialize(id, hsh, page) super @id = "tcharge" - @check_answer_label = "Household rent and charges" - @header = "Total charge" + @copy_key = "lettings.income_and_benefits.rent_and_charges.tcharge" @type = "numeric_output" @width = 5 @check_answers_card_number = 0 @min = 0 - @hint_text = "This is the total for rent and all charges." @step = 0.01 @readonly = true @prefix = "£" diff --git a/app/models/form/lettings/questions/tcharge_monthly.rb b/app/models/form/lettings/questions/tcharge_monthly.rb index 3fcabdace..2c52f4c92 100644 --- a/app/models/form/lettings/questions/tcharge_monthly.rb +++ b/app/models/form/lettings/questions/tcharge_monthly.rb @@ -2,13 +2,11 @@ class Form::Lettings::Questions::TchargeMonthly < ::Form::Question def initialize(id, hsh, page) super @id = "tcharge" - @check_answer_label = "Household rent and charges" - @header = "Total charge" + @copy_key = "lettings.income_and_benefits.rent_and_charges.tcharge" @type = "numeric_output" @width = 5 @check_answers_card_number = 0 @min = 0 - @hint_text = "This is the total for rent and all charges." @step = 0.01 @readonly = true @prefix = "£" diff --git a/app/models/form/lettings/questions/tcharge_weekly.rb b/app/models/form/lettings/questions/tcharge_weekly.rb index d1ac7cb34..0c0ee5d8e 100644 --- a/app/models/form/lettings/questions/tcharge_weekly.rb +++ b/app/models/form/lettings/questions/tcharge_weekly.rb @@ -2,13 +2,11 @@ class Form::Lettings::Questions::TchargeWeekly < ::Form::Question def initialize(id, hsh, page) super @id = "tcharge" - @check_answer_label = "Household rent and charges" - @header = "Total charge" + @copy_key = "lettings.income_and_benefits.rent_and_charges.tcharge" @type = "numeric_output" @width = 5 @check_answers_card_number = 0 @min = 0 - @hint_text = "This is the total for rent and all charges." @step = 0.01 @readonly = true @prefix = "£" diff --git a/app/models/form/lettings/questions/tenancy_type.rb b/app/models/form/lettings/questions/tenancy_type.rb index 9a83b44cb..c67895bef 100644 --- a/app/models/form/lettings/questions/tenancy_type.rb +++ b/app/models/form/lettings/questions/tenancy_type.rb @@ -10,7 +10,7 @@ class Form::Lettings::Questions::TenancyType < ::Form::Question end def answer_options - if form.start_year_after_2024? + if form.start_year_2024_or_later? { "4" => { "value" => "Assured Shorthold Tenancy (AST) – Fixed term", diff --git a/app/models/form/lettings/questions/tshortfall.rb b/app/models/form/lettings/questions/tshortfall.rb index 75583008c..3219c7689 100644 --- a/app/models/form/lettings/questions/tshortfall.rb +++ b/app/models/form/lettings/questions/tshortfall.rb @@ -2,8 +2,7 @@ class Form::Lettings::Questions::Tshortfall < ::Form::Question def initialize(id, hsh, page) super @id = "tshortfall" - @check_answer_label = "Estimated outstanding amount" - @header = "Estimated outstanding amount" + @copy_key = "lettings.income_and_benefits.outstanding_amount.tshortfall" @type = "numeric" @width = 5 @check_answers_card_number = 0 diff --git a/app/models/form/lettings/questions/tshortfall_known.rb b/app/models/form/lettings/questions/tshortfall_known.rb index 600736077..7a5da7127 100644 --- a/app/models/form/lettings/questions/tshortfall_known.rb +++ b/app/models/form/lettings/questions/tshortfall_known.rb @@ -2,11 +2,9 @@ class Form::Lettings::Questions::TshortfallKnown < ::Form::Question def initialize(id, hsh, page) super @id = "tshortfall_known" - @check_answer_label = "Do you know the outstanding amount?" - @header = "Can you estimate the outstanding amount?" + @copy_key = "lettings.income_and_benefits.outstanding_amount.tshortfall_known" @type = "radio" @check_answers_card_number = 0 - @hint_text = "You only need to give an approximate figure." @answer_options = ANSWER_OPTIONS @conditional_for = { "tshortfall" => [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/uprn_confirmation.rb b/app/models/form/lettings/questions/uprn_confirmation.rb index 1c31485b6..2f03cb357 100644 --- a/app/models/form/lettings/questions/uprn_confirmation.rb +++ b/app/models/form/lettings/questions/uprn_confirmation.rb @@ -8,7 +8,7 @@ class Form::Lettings::Questions::UprnConfirmation < ::Form::Question end def answer_options - if form.start_year_after_2024? + if form.start_year_2024_or_later? { "1" => { "value" => "Yes" }, "0" => { "value" => "No, I want to search for the address instead" }, diff --git a/app/models/form/lettings/questions/void_date_value_check.rb b/app/models/form/lettings/questions/void_date_value_check.rb index 22446061f..faf507a1b 100644 --- a/app/models/form/lettings/questions/void_date_value_check.rb +++ b/app/models/form/lettings/questions/void_date_value_check.rb @@ -2,8 +2,7 @@ class Form::Lettings::Questions::VoidDateValueCheck < ::Form::Question def initialize(id, hsh, page) super @id = "void_date_value_check" - @check_answer_label = "Void date confirmation" - @header = "Are you sure the property has been vacant for this long?" + @copy_key = "lettings.soft_validations.void_date_value_check" @type = "interruption_screen" @check_answers_card_number = 0 @answer_options = ANSWER_OPTIONS diff --git a/app/models/form/lettings/questions/waityear.rb b/app/models/form/lettings/questions/waityear.rb index 045765951..67a560167 100644 --- a/app/models/form/lettings/questions/waityear.rb +++ b/app/models/form/lettings/questions/waityear.rb @@ -8,7 +8,7 @@ class Form::Lettings::Questions::Waityear < ::Form::Question end def answer_options - if form.start_year_after_2024? + if form.start_year_2024_or_later? { "2" => { "value" => "Less than 1 year" }, "7" => { "value" => "1 year but under 2 years" }, diff --git a/app/models/form/lettings/subsections/household_characteristics.rb b/app/models/form/lettings/subsections/household_characteristics.rb index e95cdf19c..61334d84c 100644 --- a/app/models/form/lettings/subsections/household_characteristics.rb +++ b/app/models/form/lettings/subsections/household_characteristics.rb @@ -8,7 +8,7 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection def pages @pages ||= [ - (Form::Lettings::Pages::Declaration.new(nil, nil, self) unless form.start_year_after_2024?), + (Form::Lettings::Pages::Declaration.new(nil, nil, self) unless form.start_year_2024_or_later?), Form::Lettings::Pages::HouseholdMembers.new(nil, nil, self), Form::Lettings::Pages::NoFemalesPregnantHouseholdLeadHhmembValueCheck.new(nil, nil, self), Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdLeadHhmembValueCheck.new(nil, nil, self), @@ -33,8 +33,8 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection Form::Lettings::Pages::LeadTenantOverRetirementValueCheck.new("working_situation_lead_tenant_over_retirement_value_check", nil, self), Form::Lettings::Pages::PersonKnown.new(nil, nil, self, person_index: 2), 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::PartnerUnder16ValueCheck.new("relationship_2_partner_under_16_value_check", nil, self, person_index: 2) if form.start_year_2024_or_later?), + (Form::Lettings::Pages::MultiplePartnersValueCheck.new("relationship_2_multiple_partners_value_check", nil, self, person_index: 2) if form.start_year_2024_or_later?), Form::Lettings::Pages::PersonAge.new(nil, nil, self, person_index: 2), Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonAgeValueCheck.new(nil, nil, self, person_index: 2), @@ -42,7 +42,7 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection person_index: 2), Form::Lettings::Pages::PersonUnderRetirementValueCheck.new("age_2_under_retirement_value_check", nil, self, person_index: 2), Form::Lettings::Pages::PersonOverRetirementValueCheck.new("age_2_over_retirement_value_check", nil, self, person_index: 2), - (Form::Lettings::Pages::PartnerUnder16ValueCheck.new("age_2_partner_under_16_value_check", nil, self, person_index: 2) if form.start_year_after_2024?), + (Form::Lettings::Pages::PartnerUnder16ValueCheck.new("age_2_partner_under_16_value_check", nil, self, person_index: 2) if form.start_year_2024_or_later?), Form::Lettings::Pages::PersonGenderIdentity.new(nil, nil, self, person_index: 2), Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonValueCheck.new(nil, nil, self, person_index: 2), Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdPersonValueCheck.new(nil, nil, self, @@ -53,8 +53,8 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection Form::Lettings::Pages::PersonOverRetirementValueCheck.new("working_situation_2_over_retirement_value_check", nil, self, person_index: 2), Form::Lettings::Pages::PersonKnown.new(nil, nil, self, person_index: 3), 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::PartnerUnder16ValueCheck.new("relationship_3_partner_under_16_value_check", nil, self, person_index: 3) if form.start_year_2024_or_later?), + (Form::Lettings::Pages::MultiplePartnersValueCheck.new("relationship_3_multiple_partners_value_check", nil, self, person_index: 3) if form.start_year_2024_or_later?), Form::Lettings::Pages::PersonAge.new(nil, nil, self, person_index: 3), Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonAgeValueCheck.new(nil, nil, self, person_index: 3), @@ -62,7 +62,7 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection person_index: 3), Form::Lettings::Pages::PersonUnderRetirementValueCheck.new("age_3_under_retirement_value_check", nil, self, person_index: 3), Form::Lettings::Pages::PersonOverRetirementValueCheck.new("age_3_over_retirement_value_check", nil, self, person_index: 3), - (Form::Lettings::Pages::PartnerUnder16ValueCheck.new("age_3_partner_under_16_value_check", nil, self, person_index: 3) if form.start_year_after_2024?), + (Form::Lettings::Pages::PartnerUnder16ValueCheck.new("age_3_partner_under_16_value_check", nil, self, person_index: 3) if form.start_year_2024_or_later?), Form::Lettings::Pages::PersonGenderIdentity.new(nil, nil, self, person_index: 3), Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonValueCheck.new(nil, nil, self, person_index: 3), Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdPersonValueCheck.new(nil, nil, self, @@ -73,8 +73,8 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection Form::Lettings::Pages::PersonOverRetirementValueCheck.new("working_situation_3_over_retirement_value_check", nil, self, person_index: 3), Form::Lettings::Pages::PersonKnown.new(nil, nil, self, person_index: 4), 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::PartnerUnder16ValueCheck.new("relationship_4_partner_under_16_value_check", nil, self, person_index: 4) if form.start_year_2024_or_later?), + (Form::Lettings::Pages::MultiplePartnersValueCheck.new("relationship_4_multiple_partners_value_check", nil, self, person_index: 4) if form.start_year_2024_or_later?), Form::Lettings::Pages::PersonAge.new(nil, nil, self, person_index: 4), Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonAgeValueCheck.new(nil, nil, self, person_index: 4), @@ -82,7 +82,7 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection person_index: 4), Form::Lettings::Pages::PersonUnderRetirementValueCheck.new("age_4_under_retirement_value_check", nil, self, person_index: 4), Form::Lettings::Pages::PersonOverRetirementValueCheck.new("age_4_over_retirement_value_check", nil, self, person_index: 4), - (Form::Lettings::Pages::PartnerUnder16ValueCheck.new("age_4_partner_under_16_value_check", nil, self, person_index: 4) if form.start_year_after_2024?), + (Form::Lettings::Pages::PartnerUnder16ValueCheck.new("age_4_partner_under_16_value_check", nil, self, person_index: 4) if form.start_year_2024_or_later?), Form::Lettings::Pages::PersonGenderIdentity.new(nil, nil, self, person_index: 4), Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonValueCheck.new(nil, nil, self, person_index: 4), Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdPersonValueCheck.new(nil, nil, self, @@ -93,8 +93,8 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection Form::Lettings::Pages::PersonOverRetirementValueCheck.new("working_situation_4_over_retirement_value_check", nil, self, person_index: 4), Form::Lettings::Pages::PersonKnown.new(nil, nil, self, person_index: 5), 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::PartnerUnder16ValueCheck.new("relationship_5_partner_under_16_value_check", nil, self, person_index: 5) if form.start_year_2024_or_later?), + (Form::Lettings::Pages::MultiplePartnersValueCheck.new("relationship_5_multiple_partners_value_check", nil, self, person_index: 5) if form.start_year_2024_or_later?), Form::Lettings::Pages::PersonAge.new(nil, nil, self, person_index: 5), Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonAgeValueCheck.new(nil, nil, self, person_index: 5), @@ -102,7 +102,7 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection person_index: 5), Form::Lettings::Pages::PersonUnderRetirementValueCheck.new("age_5_under_retirement_value_check", nil, self, person_index: 5), Form::Lettings::Pages::PersonOverRetirementValueCheck.new("age_5_over_retirement_value_check", nil, self, person_index: 5), - (Form::Lettings::Pages::PartnerUnder16ValueCheck.new("age_5_partner_under_16_value_check", nil, self, person_index: 5) if form.start_year_after_2024?), + (Form::Lettings::Pages::PartnerUnder16ValueCheck.new("age_5_partner_under_16_value_check", nil, self, person_index: 5) if form.start_year_2024_or_later?), Form::Lettings::Pages::PersonGenderIdentity.new(nil, nil, self, person_index: 5), Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonValueCheck.new(nil, nil, self, person_index: 5), Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdPersonValueCheck.new(nil, nil, self, @@ -113,8 +113,8 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection Form::Lettings::Pages::PersonOverRetirementValueCheck.new("working_situation_5_over_retirement_value_check", nil, self, person_index: 5), Form::Lettings::Pages::PersonKnown.new(nil, nil, self, person_index: 6), 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::PartnerUnder16ValueCheck.new("relationship_6_partner_under_16_value_check", nil, self, person_index: 6) if form.start_year_2024_or_later?), + (Form::Lettings::Pages::MultiplePartnersValueCheck.new("relationship_6_multiple_partners_value_check", nil, self, person_index: 6) if form.start_year_2024_or_later?), Form::Lettings::Pages::PersonAge.new(nil, nil, self, person_index: 6), Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonAgeValueCheck.new(nil, nil, self, person_index: 6), @@ -122,7 +122,7 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection person_index: 6), Form::Lettings::Pages::PersonUnderRetirementValueCheck.new("age_6_under_retirement_value_check", nil, self, person_index: 6), Form::Lettings::Pages::PersonOverRetirementValueCheck.new("age_6_over_retirement_value_check", nil, self, person_index: 6), - (Form::Lettings::Pages::PartnerUnder16ValueCheck.new("age_6_partner_under_16_value_check", nil, self, person_index: 6) if form.start_year_after_2024?), + (Form::Lettings::Pages::PartnerUnder16ValueCheck.new("age_6_partner_under_16_value_check", nil, self, person_index: 6) if form.start_year_2024_or_later?), Form::Lettings::Pages::PersonGenderIdentity.new(nil, nil, self, person_index: 6), Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonValueCheck.new(nil, nil, self, person_index: 6), Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdPersonValueCheck.new(nil, nil, self, @@ -133,8 +133,8 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection Form::Lettings::Pages::PersonOverRetirementValueCheck.new("working_situation_6_over_retirement_value_check", nil, self, person_index: 6), Form::Lettings::Pages::PersonKnown.new(nil, nil, self, person_index: 7), 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::PartnerUnder16ValueCheck.new("relationship_7_partner_under_16_value_check", nil, self, person_index: 7) if form.start_year_2024_or_later?), + (Form::Lettings::Pages::MultiplePartnersValueCheck.new("relationship_7_multiple_partners_value_check", nil, self, person_index: 7) if form.start_year_2024_or_later?), Form::Lettings::Pages::PersonAge.new(nil, nil, self, person_index: 7), Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonAgeValueCheck.new(nil, nil, self, person_index: 7), @@ -142,7 +142,7 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection person_index: 7), Form::Lettings::Pages::PersonUnderRetirementValueCheck.new("age_7_under_retirement_value_check", nil, self, person_index: 7), Form::Lettings::Pages::PersonOverRetirementValueCheck.new("age_7_over_retirement_value_check", nil, self, person_index: 7), - (Form::Lettings::Pages::PartnerUnder16ValueCheck.new("age_7_partner_under_16_value_check", nil, self, person_index: 7) if form.start_year_after_2024?), + (Form::Lettings::Pages::PartnerUnder16ValueCheck.new("age_7_partner_under_16_value_check", nil, self, person_index: 7) if form.start_year_2024_or_later?), Form::Lettings::Pages::PersonGenderIdentity.new(nil, nil, self, person_index: 7), Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonValueCheck.new(nil, nil, self, person_index: 7), Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdPersonValueCheck.new(nil, nil, self, @@ -153,8 +153,8 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection Form::Lettings::Pages::PersonOverRetirementValueCheck.new("working_situation_7_over_retirement_value_check", nil, self, person_index: 7), Form::Lettings::Pages::PersonKnown.new(nil, nil, self, person_index: 8), 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::PartnerUnder16ValueCheck.new("relationship_8_partner_under_16_value_check", nil, self, person_index: 8) if form.start_year_2024_or_later?), + (Form::Lettings::Pages::MultiplePartnersValueCheck.new("relationship_8_multiple_partners_value_check", nil, self, person_index: 8) if form.start_year_2024_or_later?), Form::Lettings::Pages::PersonAge.new(nil, nil, self, person_index: 8), Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonAgeValueCheck.new(nil, nil, self, person_index: 8), @@ -162,7 +162,7 @@ class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection person_index: 8), Form::Lettings::Pages::PersonUnderRetirementValueCheck.new("age_8_under_retirement_value_check", nil, self, person_index: 8), Form::Lettings::Pages::PersonOverRetirementValueCheck.new("age_8_over_retirement_value_check", nil, self, person_index: 8), - (Form::Lettings::Pages::PartnerUnder16ValueCheck.new("age_8_partner_under_16_value_check", nil, self, person_index: 8) if form.start_year_after_2024?), + (Form::Lettings::Pages::PartnerUnder16ValueCheck.new("age_8_partner_under_16_value_check", nil, self, person_index: 8) if form.start_year_2024_or_later?), Form::Lettings::Pages::PersonGenderIdentity.new(nil, nil, self, person_index: 8), Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonValueCheck.new(nil, nil, self, person_index: 8), Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdPersonValueCheck.new(nil, nil, self, diff --git a/app/models/form/lettings/subsections/household_situation.rb b/app/models/form/lettings/subsections/household_situation.rb index 6646d7230..dc3fd608b 100644 --- a/app/models/form/lettings/subsections/household_situation.rb +++ b/app/models/form/lettings/subsections/household_situation.rb @@ -12,7 +12,7 @@ class Form::Lettings::Subsections::HouseholdSituation < ::Form::Subsection Form::Lettings::Pages::TimeOnWaitingList.new(nil, nil, self), Form::Lettings::Pages::ReasonForLeavingLastSettledHome.new(nil, nil, self), Form::Lettings::Pages::ReasonForLeavingLastSettledHomeRenewal.new(nil, nil, self), - (Form::Lettings::Pages::ReasonotherValueCheck.new(nil, nil, self) if form.start_year_after_2024?), + (Form::Lettings::Pages::ReasonotherValueCheck.new(nil, nil, self) if form.start_year_2024_or_later?), Form::Lettings::Pages::PreviousHousingSituation.new(nil, nil, self), Form::Lettings::Pages::PreviousHousingSituationRenewal.new(nil, nil, self), Form::Lettings::Pages::Homelessness.new("homelessness", nil, self), diff --git a/app/models/form/lettings/subsections/property_information.rb b/app/models/form/lettings/subsections/property_information.rb index fa2ff0efa..c80e49e84 100644 --- a/app/models/form/lettings/subsections/property_information.rb +++ b/app/models/form/lettings/subsections/property_information.rb @@ -29,7 +29,7 @@ class Form::Lettings::Subsections::PropertyInformation < ::Form::Subsection end def uprn_questions - if form.start_year_after_2024? + if form.start_year_2024_or_later? [ Form::Lettings::Pages::Uprn.new(nil, nil, self), Form::Lettings::Pages::UprnConfirmation.new(nil, nil, self), @@ -48,7 +48,7 @@ class Form::Lettings::Subsections::PropertyInformation < ::Form::Subsection end def number_of_times_relet - Form::Lettings::Pages::PropertyNumberOfTimesRelet.new(nil, nil, self) unless form.start_year_after_2024? + Form::Lettings::Pages::PropertyNumberOfTimesRelet.new(nil, nil, self) unless form.start_year_2024_or_later? end def displayed_in_tasklist?(log) diff --git a/app/models/form/lettings/subsections/setup.rb b/app/models/form/lettings/subsections/setup.rb index 1970149ed..0e65c2f13 100644 --- a/app/models/form/lettings/subsections/setup.rb +++ b/app/models/form/lettings/subsections/setup.rb @@ -20,7 +20,7 @@ class Form::Lettings::Subsections::Setup < ::Form::Subsection Form::Lettings::Pages::RentType.new(nil, nil, self), Form::Lettings::Pages::TenantCode.new(nil, nil, self), Form::Lettings::Pages::PropertyReference.new(nil, nil, self), - (Form::Lettings::Pages::Declaration.new(nil, nil, self) if form.start_year_after_2024?), + (Form::Lettings::Pages::Declaration.new(nil, nil, self) if form.start_year_2024_or_later?), ].compact end diff --git a/app/models/form/lettings/subsections/tenancy_information.rb b/app/models/form/lettings/subsections/tenancy_information.rb index 5525c182f..f0b7f4bef 100644 --- a/app/models/form/lettings/subsections/tenancy_information.rb +++ b/app/models/form/lettings/subsections/tenancy_information.rb @@ -15,7 +15,7 @@ class Form::Lettings::Subsections::TenancyInformation < ::Form::Subsection Form::Lettings::Pages::TenancyLength.new(nil, nil, self), Form::Lettings::Pages::TenancyLengthAffordableRent.new(nil, nil, self), Form::Lettings::Pages::TenancyLengthIntermediateRent.new(nil, nil, self), - (Form::Lettings::Pages::TenancyLengthPeriodic.new(nil, nil, self) if form.start_year_after_2024?), + (Form::Lettings::Pages::TenancyLengthPeriodic.new(nil, nil, self) if form.start_year_2024_or_later?), Form::Lettings::Pages::ShelteredAccommodation.new(nil, nil, self), ].flatten.compact end diff --git a/app/models/form/sales/pages/about_staircase.rb b/app/models/form/sales/pages/about_staircase.rb index 4d5882916..d736bae15 100644 --- a/app/models/form/sales/pages/about_staircase.rb +++ b/app/models/form/sales/pages/about_staircase.rb @@ -2,7 +2,7 @@ class Form::Sales::Pages::AboutStaircase < ::Form::Page def initialize(id, hsh, subsection, joint_purchase:) super(id, hsh, subsection) @joint_purchase = joint_purchase - @header = "About the staircasing transaction" + @copy_key = "sales.sale_information.about_staircasing" @depends_on = [{ "staircase" => 1, "joint_purchase?" => joint_purchase, diff --git a/app/models/form/sales/pages/buyer1_nationality.rb b/app/models/form/sales/pages/buyer1_nationality.rb index 6bcf12952..791ecafac 100644 --- a/app/models/form/sales/pages/buyer1_nationality.rb +++ b/app/models/form/sales/pages/buyer1_nationality.rb @@ -13,7 +13,7 @@ class Form::Sales::Pages::Buyer1Nationality < ::Form::Page end def questions - @questions ||= if form.start_year_after_2024? + @questions ||= if form.start_year_2024_or_later? [ Form::Sales::Questions::NationalityAllGroup.new("nationality_all_group", nil, self, 1), Form::Sales::Questions::NationalityAll.new("nationality_all", nil, self, 1), diff --git a/app/models/form/sales/pages/buyer2_nationality.rb b/app/models/form/sales/pages/buyer2_nationality.rb index bbec2a105..30790fd63 100644 --- a/app/models/form/sales/pages/buyer2_nationality.rb +++ b/app/models/form/sales/pages/buyer2_nationality.rb @@ -15,7 +15,7 @@ class Form::Sales::Pages::Buyer2Nationality < ::Form::Page end def questions - @questions ||= if form.start_year_after_2024? + @questions ||= if form.start_year_2024_or_later? [ Form::Sales::Questions::NationalityAllGroup.new("nationality_all_buyer2_group", nil, self, 2), Form::Sales::Questions::NationalityAll.new("nationality_all_buyer2", nil, self, 2), diff --git a/app/models/form/sales/pages/buyer_live.rb b/app/models/form/sales/pages/buyer_live.rb index d0b772355..8bde09ddb 100644 --- a/app/models/form/sales/pages/buyer_live.rb +++ b/app/models/form/sales/pages/buyer_live.rb @@ -2,9 +2,10 @@ class Form::Sales::Pages::BuyerLive < ::Form::Page def initialize(id, hsh, subsection) super @id = "buyer_live" - @depends_on = [{ - "companybuy" => 2, - }] + end + + def depends_on + [{ "companybuy" => 2 }] unless form.start_year_2025_or_later? end def questions diff --git a/app/models/form/sales/pages/buyer_previous.rb b/app/models/form/sales/pages/buyer_previous.rb index 87f87b66b..197a68971 100644 --- a/app/models/form/sales/pages/buyer_previous.rb +++ b/app/models/form/sales/pages/buyer_previous.rb @@ -2,6 +2,7 @@ class Form::Sales::Pages::BuyerPrevious < ::Form::Page def initialize(id, hsh, subsection, joint_purchase:) super(id, hsh, subsection) @joint_purchase = joint_purchase + @copy_key = "sales.sale_information.soctenant.#{joint_purchase ? 'joint_purchase' : 'not_joint_purchase'}" @depends_on = [{ "joint_purchase?" => joint_purchase, "soctenant_is_inferred?" => false }] end @@ -12,7 +13,7 @@ class Form::Sales::Pages::BuyerPrevious < ::Form::Page end def routed_to?(log, _current_user) - return false if log.is_staircase? && form.start_year_after_2024? + return false if log.is_staircase? && form.start_year_2024_or_later? super end diff --git a/app/models/form/sales/pages/deposit.rb b/app/models/form/sales/pages/deposit.rb index 3e298e4f6..4870a3c35 100644 --- a/app/models/form/sales/pages/deposit.rb +++ b/app/models/form/sales/pages/deposit.rb @@ -3,7 +3,7 @@ class Form::Sales::Pages::Deposit < ::Form::Page super(id, hsh, subsection) @ownershipsch = ownershipsch @optional = optional - @header = "About the deposit" + @copy_key = "sales.sale_information.deposit" end def questions @@ -15,7 +15,7 @@ class Form::Sales::Pages::Deposit < ::Form::Page def routed_to?(log, _user) return false unless super return true if log.ownershipsch == 2 || (log.ownershipsch == 3 && log.mortgageused == 1) - return false if log.stairowned_100? != @optional && form.start_year_after_2024? + return false if log.stairowned_100? != @optional && form.start_year_2024_or_later? log.ownershipsch == 1 end diff --git a/app/models/form/sales/pages/deposit_and_mortgage_value_check.rb b/app/models/form/sales/pages/deposit_and_mortgage_value_check.rb index fe5ad4acb..142c79cb5 100644 --- a/app/models/form/sales/pages/deposit_and_mortgage_value_check.rb +++ b/app/models/form/sales/pages/deposit_and_mortgage_value_check.rb @@ -6,8 +6,9 @@ class Form::Sales::Pages::DepositAndMortgageValueCheck < ::Form::Page "mortgage_plus_deposit_less_than_discounted_value?" => true, }, ] + @copy_key = "sales.soft_validations.deposit_and_mortgage_value_check" @title_text = { - "translation" => "soft_validations.deposit_and_mortgage.title_text", + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text", "arguments" => [ { "key" => "mortgage", @@ -27,7 +28,7 @@ class Form::Sales::Pages::DepositAndMortgageValueCheck < ::Form::Page ], } @informative_text = { - "translation" => "soft_validations.deposit_and_mortgage.hint_text", + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text", "arguments" => [], } end diff --git a/app/models/form/sales/pages/deposit_discount.rb b/app/models/form/sales/pages/deposit_discount.rb index 6931a7510..84fcbb45f 100644 --- a/app/models/form/sales/pages/deposit_discount.rb +++ b/app/models/form/sales/pages/deposit_discount.rb @@ -2,7 +2,7 @@ class Form::Sales::Pages::DepositDiscount < ::Form::Page def initialize(id, hsh, subsection, optional:) super(id, hsh, subsection) @optional = optional - @header = "About the deposit" + @copy_key = "sales.sale_information.cashdis" end def questions @@ -12,7 +12,7 @@ class Form::Sales::Pages::DepositDiscount < ::Form::Page end def depends_on - if form.start_year_after_2024? + if form.start_year_2024_or_later? [{ "social_homebuy?" => true, "stairowned_100?" => @optional }] else [{ "social_homebuy?" => true }] diff --git a/app/models/form/sales/pages/deposit_value_check.rb b/app/models/form/sales/pages/deposit_value_check.rb index cbec4b031..fea99b28b 100644 --- a/app/models/form/sales/pages/deposit_value_check.rb +++ b/app/models/form/sales/pages/deposit_value_check.rb @@ -26,7 +26,7 @@ class Form::Sales::Pages::DepositValueCheck < ::Form::Page def questions @questions ||= [ - Form::Sales::Questions::DepositValueCheck.new(nil, nil, self), + Form::Sales::Questions::DepositValueCheck.new(nil, nil, self, joint_purchase: @joint_purchase), ] end diff --git a/app/models/form/sales/pages/discount.rb b/app/models/form/sales/pages/discount.rb index 56670075b..2d632985e 100644 --- a/app/models/form/sales/pages/discount.rb +++ b/app/models/form/sales/pages/discount.rb @@ -2,7 +2,7 @@ class Form::Sales::Pages::Discount < ::Form::Page def initialize(id, hsh, subsection) super @id = "discount" - @header = "About the price of the property" + @copy_key = "sales.sale_information.discount" @depends_on = [{ "right_to_buy?" => true, }] diff --git a/app/models/form/sales/pages/discounted_sale_value_check.rb b/app/models/form/sales/pages/discounted_sale_value_check.rb index dcb820e49..4fbff90c6 100644 --- a/app/models/form/sales/pages/discounted_sale_value_check.rb +++ b/app/models/form/sales/pages/discounted_sale_value_check.rb @@ -2,8 +2,9 @@ class Form::Sales::Pages::DiscountedSaleValueCheck < ::Form::Page def initialize(id, hsh, subsection, person_index = nil) super(id, hsh, subsection) @depends_on = depends_on + @copy_key = "sales.soft_validations.discounted_sale_value_check" @title_text = { - "translation" => "soft_validations.discounted_sale_value.title_text", + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text", "arguments" => [ { "key" => "field_formatted_as_currency", @@ -13,7 +14,7 @@ class Form::Sales::Pages::DiscountedSaleValueCheck < ::Form::Page ], } @informative_text = { - "translation" => "soft_validations.discounted_sale_value.informative_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/equity.rb b/app/models/form/sales/pages/equity.rb index 018ba6f79..9bf3050a0 100644 --- a/app/models/form/sales/pages/equity.rb +++ b/app/models/form/sales/pages/equity.rb @@ -2,7 +2,7 @@ class Form::Sales::Pages::Equity < ::Form::Page def initialize(id, hsh, subsection) super @id = "equity" - @header = "About the price of the property" + @copy_key = "sales.sale_information.equity" end def questions diff --git a/app/models/form/sales/pages/exchange_date.rb b/app/models/form/sales/pages/exchange_date.rb index ec71b0647..4317c39e0 100644 --- a/app/models/form/sales/pages/exchange_date.rb +++ b/app/models/form/sales/pages/exchange_date.rb @@ -2,6 +2,7 @@ class Form::Sales::Pages::ExchangeDate < ::Form::Page def initialize(id, hsh, subsection) super @id = "exchange_contracts" + @copy_key = "sales.sale_information.exchange_date" @depends_on = [{ "resale" => 2, }] diff --git a/app/models/form/sales/pages/extra_borrowing.rb b/app/models/form/sales/pages/extra_borrowing.rb index 4bb8d0530..c6ddb705a 100644 --- a/app/models/form/sales/pages/extra_borrowing.rb +++ b/app/models/form/sales/pages/extra_borrowing.rb @@ -2,7 +2,7 @@ class Form::Sales::Pages::ExtraBorrowing < ::Form::Page def initialize(id, hsh, subsection, ownershipsch:) super(id, hsh, subsection) @ownershipsch = ownershipsch - @header = "" + @copy_key = "sales.sale_information.extrabor" @description = "" @subsection = subsection @depends_on = [{ diff --git a/app/models/form/sales/pages/extra_borrowing_value_check.rb b/app/models/form/sales/pages/extra_borrowing_value_check.rb index b3cf0b2db..9fc621611 100644 --- a/app/models/form/sales/pages/extra_borrowing_value_check.rb +++ b/app/models/form/sales/pages/extra_borrowing_value_check.rb @@ -6,8 +6,9 @@ class Form::Sales::Pages::ExtraBorrowingValueCheck < Form::Page "extra_borrowing_expected_but_not_reported?" => true, }, ] + @copy_key = "sales.soft_validations.extra_borrowing_value_check" @title_text = { - "translation" => "soft_validations.extra_borrowing.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::ExtraBorrowingValueCheck < Form::Page ], } @informative_text = { - "translation" => "soft_validations.extra_borrowing.hint_text", + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text", "arguments" => [], } end diff --git a/app/models/form/sales/pages/grant.rb b/app/models/form/sales/pages/grant.rb index 7c7d2a625..2f96701c5 100644 --- a/app/models/form/sales/pages/grant.rb +++ b/app/models/form/sales/pages/grant.rb @@ -2,7 +2,7 @@ class Form::Sales::Pages::Grant < ::Form::Page def initialize(id, hsh, subsection) super @id = "grant" - @header = "About the price of the property" + @copy_key = "sales.sale_information.grant" @depends_on = [{ "right_to_buy?" => false, "rent_to_buy_full_ownership?" => false, diff --git a/app/models/form/sales/pages/grant_value_check.rb b/app/models/form/sales/pages/grant_value_check.rb index 6b53d74ee..0c5d50901 100644 --- a/app/models/form/sales/pages/grant_value_check.rb +++ b/app/models/form/sales/pages/grant_value_check.rb @@ -2,13 +2,14 @@ class Form::Sales::Pages::GrantValueCheck < ::Form::Page def initialize(id, hsh, subsection) super @id = "grant_value_check" + @copy_key = "sales.soft_validations.grant_value_check" @depends_on = [ { "grant_outside_common_range?" => true, }, ] @title_text = { - "translation" => "soft_validations.grant.title_text", + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text", "arguments" => [ { "key" => "field_formatted_as_currency", @@ -18,7 +19,7 @@ class Form::Sales::Pages::GrantValueCheck < ::Form::Page ], } @informative_text = { - "translation" => "soft_validations.grant.hint_text", + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text", "arguments" => [], } end diff --git a/app/models/form/sales/pages/handover_date.rb b/app/models/form/sales/pages/handover_date.rb index 35fbe7822..c40effc8e 100644 --- a/app/models/form/sales/pages/handover_date.rb +++ b/app/models/form/sales/pages/handover_date.rb @@ -2,6 +2,7 @@ class Form::Sales::Pages::HandoverDate < ::Form::Page def initialize(id, hsh, subsection) super @id = "handover_date" + @copy_key = "sales.sale_information.handover_date" @depends_on = [ { "ownershipsch" => 1, "resale" => 2 }, ] diff --git a/app/models/form/sales/pages/handover_date_check.rb b/app/models/form/sales/pages/handover_date_check.rb index e8d666f60..690c3dde7 100644 --- a/app/models/form/sales/pages/handover_date_check.rb +++ b/app/models/form/sales/pages/handover_date_check.rb @@ -2,11 +2,12 @@ class Form::Sales::Pages::HandoverDateCheck < ::Form::Page def initialize(id, hsh, subsection) super @id = "handover_date_check" + @copy_key = "sales.soft_validations.hodate_check" @depends_on = [{ "saledate_check" => nil, "hodate_3_years_or_more_saledate?" => true }, { "saledate_check" => 1, "hodate_3_years_or_more_saledate?" => true }] @informative_text = {} @title_text = { - "translation" => "soft_validations.hodate.must_be_less_than_3_years_from_saledate", + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text", "arguments" => [], } end diff --git a/app/models/form/sales/pages/joint_purchase.rb b/app/models/form/sales/pages/joint_purchase.rb index bec7c88c1..a8382d1fb 100644 --- a/app/models/form/sales/pages/joint_purchase.rb +++ b/app/models/form/sales/pages/joint_purchase.rb @@ -2,11 +2,21 @@ class Form::Sales::Pages::JointPurchase < ::Form::Page def initialize(id, hsh, subsection) super @id = "joint_purchase" - @depends_on = [ - { "ownershipsch" => 1 }, - { "ownershipsch" => 2 }, - { "companybuy" => 2 }, - ] + end + + def depends_on + if form.start_year_2025_or_later? + [ + { "ownershipsch" => 1 }, + { "ownershipsch" => 2 }, + ] + else + [ + { "ownershipsch" => 1 }, + { "ownershipsch" => 2 }, + { "companybuy" => 2 }, + ] + end end def questions diff --git a/app/models/form/sales/pages/la_nominations.rb b/app/models/form/sales/pages/la_nominations.rb index fc3f39f6a..e86e0374a 100644 --- a/app/models/form/sales/pages/la_nominations.rb +++ b/app/models/form/sales/pages/la_nominations.rb @@ -2,6 +2,7 @@ class Form::Sales::Pages::LaNominations < ::Form::Page def initialize(id, hsh, subsection) super @id = "la_nominations" + @copy_key = "sales.sale_information.la_nominations" end def questions @@ -11,7 +12,7 @@ class Form::Sales::Pages::LaNominations < ::Form::Page end def routed_to?(log, _current_user) - return false if log.staircase == 1 && form.start_year_after_2024? + return false if log.staircase == 1 && form.start_year_2024_or_later? super end diff --git a/app/models/form/sales/pages/last_accommodation.rb b/app/models/form/sales/pages/last_accommodation.rb index f9d167028..42620038b 100644 --- a/app/models/form/sales/pages/last_accommodation.rb +++ b/app/models/form/sales/pages/last_accommodation.rb @@ -13,7 +13,7 @@ class Form::Sales::Pages::LastAccommodation < ::Form::Page end def routed_to?(log, _user) - return false if form.start_year_after_2024? && log.discounted_ownership_sale? + return false if form.start_year_2024_or_later? && log.discounted_ownership_sale? super end diff --git a/app/models/form/sales/pages/last_accommodation_la.rb b/app/models/form/sales/pages/last_accommodation_la.rb index 9cae326bf..ceb5b272c 100644 --- a/app/models/form/sales/pages/last_accommodation_la.rb +++ b/app/models/form/sales/pages/last_accommodation_la.rb @@ -16,7 +16,7 @@ class Form::Sales::Pages::LastAccommodationLa < ::Form::Page end def routed_to?(log, _user) - return false if form.start_year_after_2024? && log.discounted_ownership_sale? + return false if form.start_year_2024_or_later? && log.discounted_ownership_sale? super end diff --git a/app/models/form/sales/pages/leasehold_charges.rb b/app/models/form/sales/pages/leasehold_charges.rb index a8ce52805..72b2eeea3 100644 --- a/app/models/form/sales/pages/leasehold_charges.rb +++ b/app/models/form/sales/pages/leasehold_charges.rb @@ -2,6 +2,7 @@ class Form::Sales::Pages::LeaseholdCharges < ::Form::Page def initialize(id, hsh, subsection, ownershipsch:) super(id, hsh, subsection) @ownershipsch = ownershipsch + @copy_key = "sales.sale_information.leaseholdcharges" end def questions diff --git a/app/models/form/sales/pages/living_before_purchase.rb b/app/models/form/sales/pages/living_before_purchase.rb index c5dd64330..3bb5510ce 100644 --- a/app/models/form/sales/pages/living_before_purchase.rb +++ b/app/models/form/sales/pages/living_before_purchase.rb @@ -3,12 +3,13 @@ class Form::Sales::Pages::LivingBeforePurchase < ::Form::Page super(id, hsh, subsection) @ownershipsch = ownershipsch @joint_purchase = joint_purchase + @copy_key = "sales.sale_information.living_before_purchase.#{joint_purchase ? 'joint_purchase' : 'not_joint_purchase'}" end def questions @questions ||= [ living_before_purchase, - Form::Sales::Questions::LivingBeforePurchaseYears.new(nil, nil, self, ownershipsch: @ownershipsch), + Form::Sales::Questions::LivingBeforePurchaseYears.new(nil, nil, self, ownershipsch: @ownershipsch, joint_purchase: @joint_purchase), ].compact end diff --git a/app/models/form/sales/pages/managing_organisation.rb b/app/models/form/sales/pages/managing_organisation.rb index 3d8e59383..bf51602a4 100644 --- a/app/models/form/sales/pages/managing_organisation.rb +++ b/app/models/form/sales/pages/managing_organisation.rb @@ -13,7 +13,7 @@ class Form::Sales::Pages::ManagingOrganisation < ::Form::Page def routed_to?(log, current_user) return false unless current_user - if form.start_year_after_2024? + if form.start_year_2024_or_later? organisation = current_user.support? ? log.owning_organisation : current_user.organisation return false unless organisation diff --git a/app/models/form/sales/pages/monthly_rent.rb b/app/models/form/sales/pages/monthly_rent.rb index 29f0d895f..943e47cff 100644 --- a/app/models/form/sales/pages/monthly_rent.rb +++ b/app/models/form/sales/pages/monthly_rent.rb @@ -2,6 +2,7 @@ class Form::Sales::Pages::MonthlyRent < ::Form::Page def initialize(id, hsh, subsection) super @id = "monthly_rent" + @copy_key = "sales.sale_information.mrent" end def questions diff --git a/app/models/form/sales/pages/mortgage_amount.rb b/app/models/form/sales/pages/mortgage_amount.rb index 73e306c2a..41fba167c 100644 --- a/app/models/form/sales/pages/mortgage_amount.rb +++ b/app/models/form/sales/pages/mortgage_amount.rb @@ -2,7 +2,7 @@ class Form::Sales::Pages::MortgageAmount < ::Form::Page def initialize(id, hsh, subsection, ownershipsch:) super(id, hsh, subsection) @ownershipsch = ownershipsch - @header = "Mortgage Amount" + @copy_key = "sales.sale_information.mortgage" @depends_on = [{ "mortgage_used?" => true }] end diff --git a/app/models/form/sales/pages/mortgage_lender.rb b/app/models/form/sales/pages/mortgage_lender.rb index f187815b1..87646a514 100644 --- a/app/models/form/sales/pages/mortgage_lender.rb +++ b/app/models/form/sales/pages/mortgage_lender.rb @@ -2,7 +2,7 @@ class Form::Sales::Pages::MortgageLender < ::Form::Page def initialize(id, hsh, subsection, ownershipsch:) super(id, hsh, subsection) @ownershipsch = ownershipsch - @header = "" + @copy_key = "sales.sale_information.mortgagelender" @description = "" @subsection = subsection @depends_on = [{ diff --git a/app/models/form/sales/pages/mortgage_lender_other.rb b/app/models/form/sales/pages/mortgage_lender_other.rb index 903a7dba8..903d6518f 100644 --- a/app/models/form/sales/pages/mortgage_lender_other.rb +++ b/app/models/form/sales/pages/mortgage_lender_other.rb @@ -2,7 +2,7 @@ class Form::Sales::Pages::MortgageLenderOther < ::Form::Page def initialize(id, hsh, subsection, ownershipsch:) super(id, hsh, subsection) @ownershipsch = ownershipsch - @header = "" + @copy_key = "sales.sale_information.mortgagelenderother" @description = "" @subsection = subsection @depends_on = [{ diff --git a/app/models/form/sales/pages/mortgage_length.rb b/app/models/form/sales/pages/mortgage_length.rb index dbc01a695..76c46694a 100644 --- a/app/models/form/sales/pages/mortgage_length.rb +++ b/app/models/form/sales/pages/mortgage_length.rb @@ -2,6 +2,7 @@ class Form::Sales::Pages::MortgageLength < ::Form::Page def initialize(id, hsh, subsection, ownershipsch:) super(id, hsh, subsection) @ownershipsch = ownershipsch + @copy_key = "sales.sale_information.mortlen" @depends_on = [{ "mortgageused" => 1, }] diff --git a/app/models/form/sales/pages/mortgageused.rb b/app/models/form/sales/pages/mortgageused.rb index a4912b12d..ab48b0c2d 100644 --- a/app/models/form/sales/pages/mortgageused.rb +++ b/app/models/form/sales/pages/mortgageused.rb @@ -1,7 +1,7 @@ class Form::Sales::Pages::Mortgageused < ::Form::Page def initialize(id, hsh, subsection, ownershipsch:) super(id, hsh, subsection) - @header = "Mortgage Amount" + @copy_key = "sales.sale_information.mortgageused" @ownershipsch = ownershipsch end diff --git a/app/models/form/sales/pages/previous_bedrooms.rb b/app/models/form/sales/pages/previous_bedrooms.rb index 722822c2d..26b3ef050 100644 --- a/app/models/form/sales/pages/previous_bedrooms.rb +++ b/app/models/form/sales/pages/previous_bedrooms.rb @@ -2,7 +2,7 @@ class Form::Sales::Pages::PreviousBedrooms < ::Form::Page def initialize(id, hsh, subsection) super @id = "previous_bedrooms" - @header = "About the buyers’ previous property" + @copy_key = "sales.sale_information.frombeds" @depends_on = [ { "soctenant" => 1, diff --git a/app/models/form/sales/pages/previous_property_type.rb b/app/models/form/sales/pages/previous_property_type.rb index 8c46963d0..c5dd4f66a 100644 --- a/app/models/form/sales/pages/previous_property_type.rb +++ b/app/models/form/sales/pages/previous_property_type.rb @@ -2,7 +2,7 @@ class Form::Sales::Pages::PreviousPropertyType < ::Form::Page def initialize(id, hsh, subsection) super @id = "previous_property_type" - @header = "" + @copy_key = "sales.sale_information.fromprop" @description = "" @subsection = subsection @depends_on = [ diff --git a/app/models/form/sales/pages/previous_tenure.rb b/app/models/form/sales/pages/previous_tenure.rb index 0f4a4b250..c35b6bd67 100644 --- a/app/models/form/sales/pages/previous_tenure.rb +++ b/app/models/form/sales/pages/previous_tenure.rb @@ -2,6 +2,7 @@ class Form::Sales::Pages::PreviousTenure < ::Form::Page def initialize(id, hsh, subsection) super @id = "shared_ownership_previous_tenure" + @copy_key = "sales.sale_information.socprevten" @header = "" @description = "" @subsection = subsection diff --git a/app/models/form/sales/pages/property_building_type.rb b/app/models/form/sales/pages/property_building_type.rb index 40c8f3738..b9a829a64 100644 --- a/app/models/form/sales/pages/property_building_type.rb +++ b/app/models/form/sales/pages/property_building_type.rb @@ -2,6 +2,10 @@ class Form::Sales::Pages::PropertyBuildingType < ::Form::Page def initialize(id, hsh, subsection) super @id = "property_building_type" + @depends_on = [ + { "form.start_year_2025_or_later?" => false }, + { "is_staircase?" => false }, + ] end def questions diff --git a/app/models/form/sales/pages/property_local_authority.rb b/app/models/form/sales/pages/property_local_authority.rb index 649a445f9..fe9ad1bc0 100644 --- a/app/models/form/sales/pages/property_local_authority.rb +++ b/app/models/form/sales/pages/property_local_authority.rb @@ -3,8 +3,8 @@ class Form::Sales::Pages::PropertyLocalAuthority < ::Form::Page super @id = "property_local_authority" @depends_on = [ - { "is_la_inferred" => false, "form.start_year_after_2024?" => false }, - { "is_la_inferred" => false, "form.start_year_after_2024?" => true, "address_search_given?" => true }, + { "is_la_inferred" => false, "form.start_year_2024_or_later?" => false }, + { "is_la_inferred" => false, "form.start_year_2024_or_later?" => true, "address_search_given?" => true }, ] end diff --git a/app/models/form/sales/pages/property_number_of_bedrooms.rb b/app/models/form/sales/pages/property_number_of_bedrooms.rb index 796a617d5..a51cbfeca 100644 --- a/app/models/form/sales/pages/property_number_of_bedrooms.rb +++ b/app/models/form/sales/pages/property_number_of_bedrooms.rb @@ -2,6 +2,7 @@ class Form::Sales::Pages::PropertyNumberOfBedrooms < ::Form::Page def initialize(id, hsh, subsection) super @id = "property_number_of_bedrooms" + @depends_on = [{ "is_beds_inferred?" => false }] end def questions diff --git a/app/models/form/sales/pages/property_wheelchair_accessible.rb b/app/models/form/sales/pages/property_wheelchair_accessible.rb index a63964059..358f16d50 100644 --- a/app/models/form/sales/pages/property_wheelchair_accessible.rb +++ b/app/models/form/sales/pages/property_wheelchair_accessible.rb @@ -2,6 +2,10 @@ class Form::Sales::Pages::PropertyWheelchairAccessible < ::Form::Page def initialize(id, hsh, subsection) super @id = "property_wheelchair_accessible" + @depends_on = [ + { "form.start_year_2025_or_later?" => false }, + { "is_staircase?" => false }, + ] end def questions diff --git a/app/models/form/sales/pages/purchase_price.rb b/app/models/form/sales/pages/purchase_price.rb index 2203375ef..0bb1da53e 100644 --- a/app/models/form/sales/pages/purchase_price.rb +++ b/app/models/form/sales/pages/purchase_price.rb @@ -2,7 +2,7 @@ class Form::Sales::Pages::PurchasePrice < ::Form::Page def initialize(id, hsh, subsection) super @id = "purchase_price" - @header = "About the price of the property" + @copy_key = "sales.sale_information.purchase_price.discounted_ownership" @depends_on = [{ "right_to_buy?" => true }, { "right_to_buy?" => false, diff --git a/app/models/form/sales/pages/purchase_price_outright_ownership.rb b/app/models/form/sales/pages/purchase_price_outright_ownership.rb index 897a19c2e..ea42a7001 100644 --- a/app/models/form/sales/pages/purchase_price_outright_ownership.rb +++ b/app/models/form/sales/pages/purchase_price_outright_ownership.rb @@ -4,11 +4,21 @@ class Form::Sales::Pages::PurchasePriceOutrightOwnership < ::Form::Page @depends_on = [ { "outright_sale_or_discounted_with_full_ownership?" => true }, ] - @header = "About the price of the property" @top_guidance_partial = "financial_calculations_outright_sale" @ownershipsch = ownershipsch end + def copy_key + case @ownershipsch + when 1 + "sales.sale_information.purchase_price.shared_ownership" + when 2 + "sales.sale_information.purchase_price.discounted_ownership" + when 3 + "sales.sale_information.purchase_price.outright_sale" + end + end + def questions @questions ||= [ Form::Sales::Questions::PurchasePrice.new(nil, nil, self, ownershipsch: @ownershipsch), diff --git a/app/models/form/sales/pages/resale.rb b/app/models/form/sales/pages/resale.rb index ffdbbc046..6f4cd24e2 100644 --- a/app/models/form/sales/pages/resale.rb +++ b/app/models/form/sales/pages/resale.rb @@ -2,6 +2,7 @@ class Form::Sales::Pages::Resale < ::Form::Page def initialize(id, hsh, subsection) super @id = "resale" + @copy_key = "sales.sale_information.resale" @depends_on = [ { "staircase" => 2, diff --git a/app/models/form/sales/pages/shared_ownership_deposit_value_check.rb b/app/models/form/sales/pages/shared_ownership_deposit_value_check.rb index bc8df6743..e56db3e38 100644 --- a/app/models/form/sales/pages/shared_ownership_deposit_value_check.rb +++ b/app/models/form/sales/pages/shared_ownership_deposit_value_check.rb @@ -6,9 +6,9 @@ class Form::Sales::Pages::SharedOwnershipDepositValueCheck < ::Form::Page "shared_ownership_deposit_invalid?" => true, }, ] - @informative_text = {} + @copy_key = "sales.soft_validations.shared_ownership_deposit_value_check" @title_text = { - "translation" => "soft_validations.shared_ownership_deposit.title_text", + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text", "arguments" => [ { "key" => "mortgage_deposit_and_discount_error_fields", diff --git a/app/models/form/sales/pages/staircase.rb b/app/models/form/sales/pages/staircase.rb index 6ab76e2bf..1413abadc 100644 --- a/app/models/form/sales/pages/staircase.rb +++ b/app/models/form/sales/pages/staircase.rb @@ -2,6 +2,8 @@ class Form::Sales::Pages::Staircase < ::Form::Page def initialize(id, hsh, subsection) super @id = "staircasing" + @depends_on = [{ "ownershipsch" => 1 }] + @copy_key = "sales.#{subsection.id}.staircasing" end def questions diff --git a/app/models/form/sales/pages/staircase_bought_value_check.rb b/app/models/form/sales/pages/staircase_bought_value_check.rb index 283261a53..3b505f3cc 100644 --- a/app/models/form/sales/pages/staircase_bought_value_check.rb +++ b/app/models/form/sales/pages/staircase_bought_value_check.rb @@ -7,8 +7,9 @@ class Form::Sales::Pages::StaircaseBoughtValueCheck < ::Form::Page "staircase_bought_above_fifty?" => true, }, ] + @copy_key = "sales.soft_validations.staircase_bought_value_check" @title_text = { - "translation" => "soft_validations.staircase_bought_seems_high.title_text", + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text", "arguments" => [ { "key" => "stairbought", @@ -17,7 +18,7 @@ class Form::Sales::Pages::StaircaseBoughtValueCheck < ::Form::Page ], } @informative_text = { - "translation" => "soft_validations.staircase_bought_seems_high.hint_text", + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text", "arguments" => [], } end diff --git a/app/models/form/sales/pages/staircase_owned_value_check.rb b/app/models/form/sales/pages/staircase_owned_value_check.rb index d83bf7d5d..1a26215e3 100644 --- a/app/models/form/sales/pages/staircase_owned_value_check.rb +++ b/app/models/form/sales/pages/staircase_owned_value_check.rb @@ -8,8 +8,9 @@ class Form::Sales::Pages::StaircaseOwnedValueCheck < ::Form::Page "joint_purchase?" => joint_purchase, }, ] + @copy_key = "sales.soft_validations.stairowned_value_check.#{joint_purchase ? 'joint_purchase' : 'not_joint_purchase'}" @title_text = { - "translation" => joint_purchase ? "soft_validations.staircase_owned.title_text.two" : "soft_validations.staircase_owned.title_text.one", + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text", "arguments" => [ { "key" => "stairowned", @@ -19,14 +20,14 @@ class Form::Sales::Pages::StaircaseOwnedValueCheck < ::Form::Page ], } @informative_text = { - "translation" => "soft_validations.staircase_owned.hint_text", + "translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text", "arguments" => [], } end def questions @questions ||= [ - Form::Sales::Questions::StaircaseOwnedValueCheck.new(nil, nil, self), + Form::Sales::Questions::StaircaseOwnedValueCheck.new(nil, nil, self, joint_purchase: @joint_purchase), ] end diff --git a/app/models/form/sales/pages/uprn.rb b/app/models/form/sales/pages/uprn.rb index fce51e543..a78b87c2f 100644 --- a/app/models/form/sales/pages/uprn.rb +++ b/app/models/form/sales/pages/uprn.rb @@ -13,7 +13,7 @@ class Form::Sales::Pages::Uprn < ::Form::Page end def skip_text - if form.start_year_after_2024? + if form.start_year_2024_or_later? "Search for address instead" else "Enter address instead" @@ -23,7 +23,7 @@ class Form::Sales::Pages::Uprn < ::Form::Page def skip_href(log = nil) return unless log - if form.start_year_after_2024? + if form.start_year_2024_or_later? "address-matcher" else "address" diff --git a/app/models/form/sales/pages/value_shared_ownership.rb b/app/models/form/sales/pages/value_shared_ownership.rb index a4f6dbe1c..c2212c787 100644 --- a/app/models/form/sales/pages/value_shared_ownership.rb +++ b/app/models/form/sales/pages/value_shared_ownership.rb @@ -2,7 +2,7 @@ class Form::Sales::Pages::ValueSharedOwnership < ::Form::Page def initialize(id, hsh, subsection) super @id = "value_shared_ownership" - @header = "About the price of the property" + @copy_key = "sales.sale_information.value" end def questions 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 2bbe4939f..619c958f9 100644 --- a/app/models/form/sales/questions/buyer1_ethnic_background_white.rb +++ b/app/models/form/sales/questions/buyer1_ethnic_background_white.rb @@ -9,7 +9,7 @@ class Form::Sales::Questions::Buyer1EthnicBackgroundWhite < ::Form::Question end def answer_options - if form.start_year_after_2024? + if form.start_year_2024_or_later? { "1" => { "value" => "English, Welsh, Northern Irish, Scottish or British" }, "2" => { "value" => "Irish" }, diff --git a/app/models/form/sales/questions/buyer1_working_situation.rb b/app/models/form/sales/questions/buyer1_working_situation.rb index b00db033f..dbbc24eff 100644 --- a/app/models/form/sales/questions/buyer1_working_situation.rb +++ b/app/models/form/sales/questions/buyer1_working_situation.rb @@ -3,7 +3,7 @@ class Form::Sales::Questions::Buyer1WorkingSituation < ::Form::Question super @id = "ecstat1" @type = "radio" - @answer_options = ANSWER_OPTIONS + @answer_options = answer_options @check_answers_card_number = 1 @inferred_check_answers_value = [{ "condition" => { @@ -14,18 +14,35 @@ class Form::Sales::Questions::Buyer1WorkingSituation < ::Form::Question @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" => "Full-time - 30 hours or more" }, - "2" => { "value" => "Part-time - Less than 30 hours" }, - "3" => { "value" => "In government training into work" }, - "4" => { "value" => "Jobseeker" }, - "6" => { "value" => "Not seeking work" }, - "8" => { "value" => "Unable to work due to long term sick or disability" }, - "5" => { "value" => "Retired" }, - "0" => { "value" => "Other" }, - "10" => { "value" => "Buyer prefers not to say" }, - "7" => { "value" => "Full-time student" }, - }.freeze + def answer_options + if form.start_year_2025_or_later? + { + "1" => { "value" => "Full-time - 30 hours or more" }, + "2" => { "value" => "Part-time - Less than 30 hours" }, + "3" => { "value" => "In government training into work" }, + "4" => { "value" => "Jobseeker" }, + "5" => { "value" => "Retired" }, + "6" => { "value" => "Not seeking work" }, + "7" => { "value" => "Full-time student" }, + "8" => { "value" => "Unable to work due to long term sick or disability" }, + "0" => { "value" => "Other" }, + "10" => { "value" => "Buyer prefers not to say" }, + }.freeze + else + { + "1" => { "value" => "Full-time - 30 hours or more" }, + "2" => { "value" => "Part-time - Less than 30 hours" }, + "3" => { "value" => "In government training into work" }, + "4" => { "value" => "Jobseeker" }, + "6" => { "value" => "Not seeking work" }, + "8" => { "value" => "Unable to work due to long term sick or disability" }, + "5" => { "value" => "Retired" }, + "0" => { "value" => "Other" }, + "10" => { "value" => "Buyer prefers not to say" }, + "7" => { "value" => "Full-time student" }, + }.freeze + end + end QUESTION_NUMBER_FROM_YEAR = { 2023 => 25, 2024 => 27 }.freeze end 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 232e0f99e..be3e3ccff 100644 --- a/app/models/form/sales/questions/buyer2_ethnic_background_white.rb +++ b/app/models/form/sales/questions/buyer2_ethnic_background_white.rb @@ -9,7 +9,7 @@ class Form::Sales::Questions::Buyer2EthnicBackgroundWhite < ::Form::Question end def answer_options - if form.start_year_after_2024? + if form.start_year_2024_or_later? { "1" => { "value" => "English, Welsh, Northern Irish, Scottish or British" }, "2" => { "value" => "Irish" }, 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 3f0fc299c..9520ace67 100644 --- a/app/models/form/sales/questions/buyer2_relationship_to_buyer1.rb +++ b/app/models/form/sales/questions/buyer2_relationship_to_buyer1.rb @@ -16,7 +16,7 @@ class Form::Sales::Questions::Buyer2RelationshipToBuyer1 < ::Form::Question end def answer_options - if form.start_year_after_2024? + if form.start_year_2024_or_later? { "P" => { "value" => "Partner" }, diff --git a/app/models/form/sales/questions/buyer2_working_situation.rb b/app/models/form/sales/questions/buyer2_working_situation.rb index 5356cb8e8..38ab320b3 100644 --- a/app/models/form/sales/questions/buyer2_working_situation.rb +++ b/app/models/form/sales/questions/buyer2_working_situation.rb @@ -4,7 +4,7 @@ class Form::Sales::Questions::Buyer2WorkingSituation < ::Form::Question @id = "ecstat2" @copy_key = "sales.household_characteristics.ecstat2.buyer" @type = "radio" - @answer_options = ANSWER_OPTIONS + @answer_options = answer_options @check_answers_card_number = 2 @inferred_check_answers_value = [{ "condition" => { @@ -15,18 +15,35 @@ class Form::Sales::Questions::Buyer2WorkingSituation < ::Form::Question @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" => "Full-time - 30 hours or more" }, - "2" => { "value" => "Part-time - Less than 30 hours" }, - "3" => { "value" => "In government training into work" }, - "4" => { "value" => "Jobseeker" }, - "6" => { "value" => "Not seeking work" }, - "8" => { "value" => "Unable to work due to long term sick or disability" }, - "5" => { "value" => "Retired" }, - "0" => { "value" => "Other" }, - "10" => { "value" => "Buyer prefers not to say" }, - "7" => { "value" => "Full-time student" }, - }.freeze + def answer_options + if form.start_year_2025_or_later? + { + "1" => { "value" => "Full-time - 30 hours or more" }, + "2" => { "value" => "Part-time - Less than 30 hours" }, + "3" => { "value" => "In government training into work" }, + "4" => { "value" => "Jobseeker" }, + "5" => { "value" => "Retired" }, + "6" => { "value" => "Not seeking work" }, + "7" => { "value" => "Full-time student" }, + "8" => { "value" => "Unable to work due to long term sick or disability" }, + "0" => { "value" => "Other" }, + "10" => { "value" => "Buyer prefers not to say" }, + }.freeze + else + { + "1" => { "value" => "Full-time - 30 hours or more" }, + "2" => { "value" => "Part-time - Less than 30 hours" }, + "3" => { "value" => "In government training into work" }, + "4" => { "value" => "Jobseeker" }, + "6" => { "value" => "Not seeking work" }, + "8" => { "value" => "Unable to work due to long term sick or disability" }, + "5" => { "value" => "Retired" }, + "0" => { "value" => "Other" }, + "10" => { "value" => "Buyer prefers not to say" }, + "7" => { "value" => "Full-time student" }, + }.freeze + end + end QUESTION_NUMBER_FROM_YEAR = { 2023 => 33, 2024 => 35 }.freeze end diff --git a/app/models/form/sales/questions/buyer_previous.rb b/app/models/form/sales/questions/buyer_previous.rb index b35a67c5e..4daf963bf 100644 --- a/app/models/form/sales/questions/buyer_previous.rb +++ b/app/models/form/sales/questions/buyer_previous.rb @@ -2,8 +2,7 @@ class Form::Sales::Questions::BuyerPrevious < ::Form::Question def initialize(id, hsh, page, joint_purchase:) super(id, hsh, page) @id = "soctenant" - @check_answer_label = I18n.t("check_answer_labels.soctenant", count: joint_purchase ? 2 : 1) - @header = I18n.t("questions.soctenant", count: joint_purchase ? 2 : 1) + @copy_key = "sales.sale_information.soctenant.#{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] @@ -23,7 +22,7 @@ class Form::Sales::Questions::BuyerPrevious < ::Form::Question end def derived?(_log) - form.start_year_after_2024? + form.start_year_2024_or_later? end QUESTION_NUMBER_FROM_YEAR = { 2023 => 84 }.freeze diff --git a/app/models/form/sales/questions/deposit_amount.rb b/app/models/form/sales/questions/deposit_amount.rb index c1d91cc12..41586cd94 100644 --- a/app/models/form/sales/questions/deposit_amount.rb +++ b/app/models/form/sales/questions/deposit_amount.rb @@ -2,8 +2,7 @@ class Form::Sales::Questions::DepositAmount < ::Form::Question def initialize(id, hsh, subsection, ownershipsch:, optional:) super(id, hsh, subsection) @id = "deposit" - @check_answer_label = "Cash deposit" - @header = "How much cash deposit was paid on the property?" + @copy_key = "sales.sale_information.deposit" @type = "numeric" @min = 0 @max = 999_999 @@ -25,14 +24,6 @@ class Form::Sales::Questions::DepositAmount < ::Form::Question 2024 => { 1 => 96, 2 => 109, 3 => 116 }, }.freeze - def hint_text - if @optional - "Enter the total cash sum paid by the buyer towards the property that was not funded by the mortgage. This excludes any grant or loan. As this is a fully staircased sale this question is optional. If you do not have the information available click save and continue" - else - "Enter the total cash sum paid by the buyer towards the property that was not funded by the mortgage. This excludes any grant or loan" - end - end - def top_guidance_partial return "financial_calculations_shared_ownership" if @ownershipsch == 1 return "financial_calculations_discounted_ownership" if @ownershipsch == 2 diff --git a/app/models/form/sales/questions/deposit_and_mortgage_value_check.rb b/app/models/form/sales/questions/deposit_and_mortgage_value_check.rb index 263cf4342..3a60e2afa 100644 --- a/app/models/form/sales/questions/deposit_and_mortgage_value_check.rb +++ b/app/models/form/sales/questions/deposit_and_mortgage_value_check.rb @@ -2,8 +2,7 @@ class Form::Sales::Questions::DepositAndMortgageValueCheck < ::Form::Question def initialize(id, hsh, page) super @id = "deposit_and_mortgage_value_check" - @check_answer_label = "Deposit and mortgage against discount confirmation" - @header = "Are you sure? Mortgage and deposit usually equal or are more than (value - discount)" + @copy_key = "sales.soft_validations.deposit_and_mortgage_value_check" @type = "interruption_screen" @answer_options = { "0" => { "value" => "Yes" }, diff --git a/app/models/form/sales/questions/deposit_discount.rb b/app/models/form/sales/questions/deposit_discount.rb index faf8d76f7..289e3962c 100644 --- a/app/models/form/sales/questions/deposit_discount.rb +++ b/app/models/form/sales/questions/deposit_discount.rb @@ -2,15 +2,13 @@ class Form::Sales::Questions::DepositDiscount < ::Form::Question def initialize(id, hsh, page) super @id = "cashdis" - @check_answer_label = "Cash discount through SocialHomeBuy" - @header = "How much cash discount was given through Social HomeBuy?" + @copy_key = "sales.sale_information.cashdis" @type = "numeric" @min = 0 @max = 999_999 @step = 1 @width = 5 @prefix = "£" - @hint_text = "Enter the total cash discount given on the property being purchased through the Social HomeBuy scheme" @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] @top_guidance_partial = "financial_calculations_shared_ownership" end diff --git a/app/models/form/sales/questions/deposit_value_check.rb b/app/models/form/sales/questions/deposit_value_check.rb index f8d403d9c..71560fa84 100644 --- a/app/models/form/sales/questions/deposit_value_check.rb +++ b/app/models/form/sales/questions/deposit_value_check.rb @@ -1,8 +1,8 @@ class Form::Sales::Questions::DepositValueCheck < ::Form::Question - def initialize(id, hsh, page) - super + def initialize(id, hsh, page, joint_purchase:) + super(id, hsh, page) @id = "deposit_value_check" - @copy_key = "sales.soft_validations.deposit_value_check" + @copy_key = "sales.soft_validations.deposit_value_check.#{joint_purchase ? 'joint_purchase' : 'not_joint_purchase'}" @type = "interruption_screen" @answer_options = { "0" => { "value" => "Yes" }, diff --git a/app/models/form/sales/questions/discount.rb b/app/models/form/sales/questions/discount.rb index f99203ebe..3807a8cfc 100644 --- a/app/models/form/sales/questions/discount.rb +++ b/app/models/form/sales/questions/discount.rb @@ -2,17 +2,13 @@ class Form::Sales::Questions::Discount < ::Form::Question def initialize(id, hsh, page) super @id = "discount" - @check_answer_label = "Percentage discount" - @header = "What was the percentage discount?" @type = "numeric" + @copy_key = "sales.sale_information.discount" @min = 0 - @max = form.start_year_after_2024? ? 70 : 100 + @max = form.start_year_2024_or_later? ? 70 : 100 @step = 0.1 @width = 5 @suffix = "%" - @hint_text = "For Right to Buy (RTB), Preserved Right to Buy (PRTB), and Voluntary Right to Buy (VRTB) - If discount capped, enter capped % - If the property is being sold to an existing tenant under the RTB, PRTB, or VRTB schemes, enter the % discount from the full market value that is being given." @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] @top_guidance_partial = "financial_calculations_discounted_ownership" end diff --git a/app/models/form/sales/questions/discounted_sale_value_check.rb b/app/models/form/sales/questions/discounted_sale_value_check.rb index 1d86b2f32..a02aaac72 100644 --- a/app/models/form/sales/questions/discounted_sale_value_check.rb +++ b/app/models/form/sales/questions/discounted_sale_value_check.rb @@ -2,8 +2,7 @@ class Form::Sales::Questions::DiscountedSaleValueCheck < ::Form::Question def initialize(id, hsh, page) super @id = "discounted_sale_value_check" - @check_answer_label = "Discounted sale value confirmation" - @header = "Are you sure this is correct?" + @copy_key = "sales.soft_validations.discounted_sale_value_check" @type = "interruption_screen" @answer_options = { "0" => { "value" => "Yes" }, diff --git a/app/models/form/sales/questions/equity.rb b/app/models/form/sales/questions/equity.rb index c6578f969..4aae785b8 100644 --- a/app/models/form/sales/questions/equity.rb +++ b/app/models/form/sales/questions/equity.rb @@ -2,15 +2,13 @@ class Form::Sales::Questions::Equity < ::Form::Question def initialize(id, hsh, page) super @id = "equity" - @check_answer_label = "Initial percentage equity stake" - @header = "What was the initial percentage equity stake purchased?" + @copy_key = "sales.sale_information.equity" @type = "numeric" @min = 0 @max = 100 @step = 0.1 @width = 5 @suffix = "%" - @hint_text = "Enter the amount of initial equity held by the purchaser (for example, 25% or 50%)" @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] @top_guidance_partial = "financial_calculations_shared_ownership" end diff --git a/app/models/form/sales/questions/exchange_date.rb b/app/models/form/sales/questions/exchange_date.rb index 8e9dd4691..a29a7a6c7 100644 --- a/app/models/form/sales/questions/exchange_date.rb +++ b/app/models/form/sales/questions/exchange_date.rb @@ -2,8 +2,7 @@ class Form::Sales::Questions::ExchangeDate < ::Form::Question def initialize(id, hsh, page) super @id = "exdate" - @check_answer_label = "Exchange of contracts date" - @header = "What is the exchange of contracts date?" + @copy_key = "sales.sale_information.exchange_date" @type = "date" @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/extra_borrowing.rb b/app/models/form/sales/questions/extra_borrowing.rb index 2b4303423..e3cd0ff7e 100644 --- a/app/models/form/sales/questions/extra_borrowing.rb +++ b/app/models/form/sales/questions/extra_borrowing.rb @@ -2,12 +2,10 @@ class Form::Sales::Questions::ExtraBorrowing < ::Form::Question def initialize(id, hsh, subsection, ownershipsch:) super(id, hsh, subsection) @id = "extrabor" - @check_answer_label = "Any other borrowing?" - @header = "Does this include any extra borrowing?" + @copy_key = "sales.sale_information.extrabor" @type = "radio" @answer_options = ANSWER_OPTIONS @page = page - @hint_text = "" @ownershipsch = ownershipsch @question_number = QUESTION_NUMBER_FROM_YEAR_AND_OWNERSHIP.fetch(form.start_date.year, QUESTION_NUMBER_FROM_YEAR_AND_OWNERSHIP.max_by { |k, _v| k }.last)[ownershipsch] end diff --git a/app/models/form/sales/questions/extra_borrowing_value_check.rb b/app/models/form/sales/questions/extra_borrowing_value_check.rb index 0f12ce110..7a251fab8 100644 --- a/app/models/form/sales/questions/extra_borrowing_value_check.rb +++ b/app/models/form/sales/questions/extra_borrowing_value_check.rb @@ -2,7 +2,7 @@ class Form::Sales::Questions::ExtraBorrowingValueCheck < ::Form::Question def initialize(id, hsh, page) super(id, hsh, page) @id = "extrabor_value_check" - @check_answer_label = "Extra borrowing confirmation" + @copy_key = "sales.soft_validations.extra_borrowing_value_check" @type = "interruption_screen" @answer_options = { "0" => { "value" => "Yes" }, @@ -18,6 +18,5 @@ class Form::Sales::Questions::ExtraBorrowingValueCheck < ::Form::Question }, ], } - @header = "Are you sure there is no extra borrowing?" end end diff --git a/app/models/form/sales/questions/fromprop.rb b/app/models/form/sales/questions/fromprop.rb index ec17e5939..1a3393b7a 100644 --- a/app/models/form/sales/questions/fromprop.rb +++ b/app/models/form/sales/questions/fromprop.rb @@ -2,10 +2,8 @@ class Form::Sales::Questions::Fromprop < ::Form::Question def initialize(id, hsh, page) super @id = "fromprop" - @check_answer_label = "Previous property type" - @header = "What was the previous property type?" + @copy_key = "sales.sale_information.fromprop" @type = "radio" - @hint_text = "" @page = page @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/grant.rb b/app/models/form/sales/questions/grant.rb index 45b70d61f..17361fe9c 100644 --- a/app/models/form/sales/questions/grant.rb +++ b/app/models/form/sales/questions/grant.rb @@ -2,15 +2,13 @@ class Form::Sales::Questions::Grant < ::Form::Question def initialize(id, hsh, page) super @id = "grant" - @check_answer_label = "Amount of any loan, grant or subsidy" - @header = "What was the amount of any loan, grant, discount or subsidy given?" + @copy_key = "sales.sale_information.grant" @type = "numeric" @min = 0 @max = 999_999 @step = 1 @width = 5 @prefix = "£" - @hint_text = "For all schemes except Right to Buy (RTB), Preserved Right to Buy (PRTB), Voluntary Right to Buy (VRTB) and Rent to Buy" @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] @top_guidance_partial = "financial_calculations_discounted_ownership" end diff --git a/app/models/form/sales/questions/grant_value_check.rb b/app/models/form/sales/questions/grant_value_check.rb index a7efdbaee..63dbb7bac 100644 --- a/app/models/form/sales/questions/grant_value_check.rb +++ b/app/models/form/sales/questions/grant_value_check.rb @@ -2,8 +2,7 @@ class Form::Sales::Questions::GrantValueCheck < ::Form::Question def initialize(id, hsh, page) super @id = "grant_value_check" - @check_answer_label = "Grant value confirmation" - @header = "Are you sure? Grants are usually £9,000 - £16,000" + @copy_key = "sales.soft_validations.grant_value_check" @type = "interruption_screen" @answer_options = { "0" => { "value" => "Yes" }, diff --git a/app/models/form/sales/questions/handover_date.rb b/app/models/form/sales/questions/handover_date.rb index 5fb55e5c8..8994ecc40 100644 --- a/app/models/form/sales/questions/handover_date.rb +++ b/app/models/form/sales/questions/handover_date.rb @@ -2,10 +2,8 @@ class Form::Sales::Questions::HandoverDate < ::Form::Question def initialize(id, hsh, page) super @id = "hodate" - @check_answer_label = "Practical completion or handover date" - @header = "What is the practical completion or handover date?" + @copy_key = "sales.sale_information.handover_date" @type = "date" - @hint_text = "This is the date on which the building contractor hands over responsibility for the completed property to the private registered provider (PRP)" @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/handover_date_check.rb b/app/models/form/sales/questions/handover_date_check.rb index f19ee0196..233c449bb 100644 --- a/app/models/form/sales/questions/handover_date_check.rb +++ b/app/models/form/sales/questions/handover_date_check.rb @@ -2,8 +2,7 @@ class Form::Sales::Questions::HandoverDateCheck < ::Form::Question def initialize(id, hsh, page) super @id = "hodate_check" - @check_answer_label = "Practical completion or handover date check" - @header = "Are you sure?" + @copy_key = "sales.soft_validations.hodate_check" @type = "interruption_screen" @answer_options = { "0" => { "value" => "Yes" }, diff --git a/app/models/form/sales/questions/has_leasehold_charges.rb b/app/models/form/sales/questions/has_leasehold_charges.rb index 3e021daa0..fced1d3da 100644 --- a/app/models/form/sales/questions/has_leasehold_charges.rb +++ b/app/models/form/sales/questions/has_leasehold_charges.rb @@ -2,9 +2,7 @@ class Form::Sales::Questions::HasLeaseholdCharges < ::Form::Question def initialize(id, hsh, subsection, ownershipsch:) super(id, hsh, subsection) @id = "has_mscharge" - @check_answer_label = "Does the property have any monthly leasehold charges?" - @header = "Does the property have any monthly leasehold charges?" - @hint_text = "For example, service and management charges" + @copy_key = "sales.sale_information.leaseholdcharges.has_mscharge" @type = "radio" @answer_options = ANSWER_OPTIONS @conditional_for = { diff --git a/app/models/form/sales/questions/la_nominations.rb b/app/models/form/sales/questions/la_nominations.rb index 0d6e9e249..34540677f 100644 --- a/app/models/form/sales/questions/la_nominations.rb +++ b/app/models/form/sales/questions/la_nominations.rb @@ -2,11 +2,9 @@ class Form::Sales::Questions::LaNominations < ::Form::Question def initialize(id, hsh, page) super @id = "lanomagr" - @check_answer_label = "Household rehoused under a local authority nominations agreement?" - @header = "Was the household rehoused under a 'local authority nominations agreement'?" + @copy_key = "sales.sale_information.la_nominations" @type = "radio" @answer_options = ANSWER_OPTIONS - @hint_text = "A local authority nominations agreement is a written agreement between a local authority and private registered provider (PRP) that some or all of its sales vacancies are offered to local authorities for rehousing" @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/leasehold_charges.rb b/app/models/form/sales/questions/leasehold_charges.rb index 2561ccc1d..73d57b1e4 100644 --- a/app/models/form/sales/questions/leasehold_charges.rb +++ b/app/models/form/sales/questions/leasehold_charges.rb @@ -2,8 +2,7 @@ class Form::Sales::Questions::LeaseholdCharges < ::Form::Question def initialize(id, hsh, subsection, ownershipsch:) super(id, hsh, subsection) @id = "mscharge" - @check_answer_label = "Monthly leasehold charges" - @header = "Enter the total monthly charge" + @copy_key = "sales.sale_information.leaseholdcharges.mscharge" @type = "numeric" @min = 1 @step = 0.01 diff --git a/app/models/form/sales/questions/living_before_purchase.rb b/app/models/form/sales/questions/living_before_purchase.rb index 9f28d61ee..c4337e38d 100644 --- a/app/models/form/sales/questions/living_before_purchase.rb +++ b/app/models/form/sales/questions/living_before_purchase.rb @@ -2,9 +2,7 @@ class Form::Sales::Questions::LivingBeforePurchase < ::Form::Question def initialize(id, hsh, page, ownershipsch:, joint_purchase:) super(id, hsh, page) @id = "proplen_asked" - @check_answer_label = "#{joint_purchase ? 'Buyers' : 'Buyer'} lived in the property before purchasing" - @header = "Did the #{joint_purchase ? 'buyers' : 'buyer'} live in the property before purchasing it?" - @hint_text = nil + @copy_key = "sales.sale_information.living_before_purchase.#{joint_purchase ? 'joint_purchase' : 'not_joint_purchase'}.proplen_asked" @type = "radio" @answer_options = ANSWER_OPTIONS @conditional_for = { diff --git a/app/models/form/sales/questions/living_before_purchase_years.rb b/app/models/form/sales/questions/living_before_purchase_years.rb index 4ef92a46c..465ba9877 100644 --- a/app/models/form/sales/questions/living_before_purchase_years.rb +++ b/app/models/form/sales/questions/living_before_purchase_years.rb @@ -1,10 +1,8 @@ class Form::Sales::Questions::LivingBeforePurchaseYears < ::Form::Question - def initialize(id, hsh, page, ownershipsch:) + def initialize(id, hsh, page, ownershipsch:, joint_purchase:) super(id, hsh, page) @id = "proplen" - @check_answer_label = "Number of years living in the property before purchase" - @header = header_text - @hint_text = hint_text + @copy_key = "sales.sale_information.living_before_purchase.#{joint_purchase ? 'joint_purchase' : 'not_joint_purchase'}.proplen" @type = "numeric" @min = 0 @max = 80 @@ -14,22 +12,6 @@ class Form::Sales::Questions::LivingBeforePurchaseYears < ::Form::Question @question_number = question_number end - def header_text - if form.start_date.year >= 2023 - "How long did they live there?" - else - "How long did the buyer(s) live in the property before purchase?" - end - end - - def hint_text - if form.start_date.year >= 2023 - "You should round up to the nearest year" - else - "You should round this up to the nearest year. If the buyers haven't been living in the property, enter '0'" - end - end - def suffix_label(log) " #{'year'.pluralize(log[id])}" end diff --git a/app/models/form/sales/questions/monthly_rent.rb b/app/models/form/sales/questions/monthly_rent.rb index c53f1b7e6..7e64d8571 100644 --- a/app/models/form/sales/questions/monthly_rent.rb +++ b/app/models/form/sales/questions/monthly_rent.rb @@ -2,14 +2,12 @@ class Form::Sales::Questions::MonthlyRent < ::Form::Question def initialize(id, hsh, page) super @id = "mrent" - @check_answer_label = "Monthly rent" - @header = "What is the basic monthly rent?" + @copy_key = "sales.sale_information.mrent" @type = "numeric" @min = 0 @step = 0.01 @width = 5 @prefix = "£" - @hint_text = "Amount paid before any charges" @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/mortgage_amount.rb b/app/models/form/sales/questions/mortgage_amount.rb index cfd031f27..a6ffcf26a 100644 --- a/app/models/form/sales/questions/mortgage_amount.rb +++ b/app/models/form/sales/questions/mortgage_amount.rb @@ -2,14 +2,12 @@ class Form::Sales::Questions::MortgageAmount < ::Form::Question def initialize(id, hsh, subsection, ownershipsch:) super(id, hsh, subsection) @id = "mortgage" - @check_answer_label = "Mortgage amount" - @header = "What is the mortgage amount?" + @copy_key = "sales.sale_information.mortgage" @type = "numeric" @min = 1 @step = 1 @width = 5 @prefix = "£" - @hint_text = "Enter the amount of mortgage agreed with the mortgage lender. Exclude any deposits or cash payments. Numeric in pounds. Rounded to the nearest pound." @ownershipsch = ownershipsch @question_number = QUESTION_NUMBER_FROM_YEAR_AND_OWNERSHIP.fetch(form.start_date.year, QUESTION_NUMBER_FROM_YEAR_AND_OWNERSHIP.max_by { |k, _v| k }.last)[ownershipsch] @top_guidance_partial = top_guidance_partial diff --git a/app/models/form/sales/questions/mortgage_lender.rb b/app/models/form/sales/questions/mortgage_lender.rb index bf4c93b55..a4aa55f17 100644 --- a/app/models/form/sales/questions/mortgage_lender.rb +++ b/app/models/form/sales/questions/mortgage_lender.rb @@ -2,10 +2,8 @@ class Form::Sales::Questions::MortgageLender < ::Form::Question def initialize(id, hsh, subsection, ownershipsch:) super(id, hsh, subsection) @id = "mortgagelender" - @check_answer_label = "Mortgage Lender" - @header = "What is the name of the mortgage lender?" + @copy_key = "sales.sale_information.mortgagelender" @type = "select" - @hint_text = "" @page = page @bottom_guidance_partial = "mortgage_lender" @ownershipsch = ownershipsch @@ -62,7 +60,7 @@ class Form::Sales::Questions::MortgageLender < ::Form::Question OPTIONS_NOT_DISPLAYED = %w[0].freeze def answer_options - if form.start_year_after_2024? + if form.start_year_2024_or_later? ANSWER_OPTIONS else ANSWER_OPTIONS.dup.reject { |k, _v| OPTIONS_INTRODUCED_2024.include?(k) } diff --git a/app/models/form/sales/questions/mortgage_lender_other.rb b/app/models/form/sales/questions/mortgage_lender_other.rb index 677b1c117..49876efb0 100644 --- a/app/models/form/sales/questions/mortgage_lender_other.rb +++ b/app/models/form/sales/questions/mortgage_lender_other.rb @@ -2,8 +2,7 @@ class Form::Sales::Questions::MortgageLenderOther < ::Form::Question def initialize(id, hsh, subsection, ownershipsch:) super(id, hsh, subsection) @id = "mortgagelenderother" - @check_answer_label = "Other Mortgage Lender" - @header = "What is the other mortgage lender?" + @copy_key = "sales.sale_information.mortgagelenderother" @type = "text" @page = page @ownershipsch = ownershipsch diff --git a/app/models/form/sales/questions/mortgage_length.rb b/app/models/form/sales/questions/mortgage_length.rb index e1bda4ea0..877818b98 100644 --- a/app/models/form/sales/questions/mortgage_length.rb +++ b/app/models/form/sales/questions/mortgage_length.rb @@ -2,14 +2,12 @@ class Form::Sales::Questions::MortgageLength < ::Form::Question def initialize(id, hsh, subsection, ownershipsch:) super(id, hsh, subsection) @id = "mortlen" - @check_answer_label = "Length of mortgage" - @header = "What is the length of the mortgage?" + @copy_key = "sales.sale_information.mortlen" @type = "numeric" @min = 0 @max = 60 @step = 1 @width = 5 - @hint_text = "You should round up to the nearest year. Value should not exceed 60 years." @ownershipsch = ownershipsch @question_number = QUESTION_NUMBER_FROM_YEAR_AND_OWNERSHIP.fetch(form.start_date.year, QUESTION_NUMBER_FROM_YEAR_AND_OWNERSHIP.max_by { |k, _v| k }.last)[ownershipsch] end diff --git a/app/models/form/sales/questions/mortgageused.rb b/app/models/form/sales/questions/mortgageused.rb index 4ece2544e..e4a101072 100644 --- a/app/models/form/sales/questions/mortgageused.rb +++ b/app/models/form/sales/questions/mortgageused.rb @@ -2,8 +2,7 @@ class Form::Sales::Questions::Mortgageused < ::Form::Question def initialize(id, hsh, subsection, ownershipsch:) super(id, hsh, subsection) @id = "mortgageused" - @check_answer_label = "Mortgage used" - @header = "Was a mortgage used for the purchase of this property?" + @copy_key = "sales.sale_information.mortgageused" @type = "radio" @answer_options = ANSWER_OPTIONS @ownershipsch = ownershipsch @@ -12,7 +11,7 @@ class Form::Sales::Questions::Mortgageused < ::Form::Question end def displayed_answer_options(log, _user = nil) - if log.outright_sale? && log.saledate && !form.start_year_after_2024? + if log.outright_sale? && log.saledate && !form.start_year_2024_or_later? answer_options_without_dont_know elsif log.stairowned == 100 || log.outright_sale? ANSWER_OPTIONS diff --git a/app/models/form/sales/questions/ownership_scheme.rb b/app/models/form/sales/questions/ownership_scheme.rb index 6b33a2566..5eacb8f26 100644 --- a/app/models/form/sales/questions/ownership_scheme.rb +++ b/app/models/form/sales/questions/ownership_scheme.rb @@ -7,7 +7,12 @@ class Form::Sales::Questions::OwnershipScheme < ::Form::Question end def answer_options - if form.start_year_after_2024? + if form.start_year_2025_or_later? + { + "1" => { "value" => "Yes - a shared ownership scheme", "hint" => "When the purchaser buys an initial share of up to 75% of the property value and pays rent to the Private Registered Provider (PRP) on the remaining portion, or a subsequent staircasing transaction" }, + "2" => { "value" => "Yes - a discounted ownership scheme" }, + }.freeze + elsif form.start_year_2024_or_later? { "1" => { "value" => "Yes - a shared ownership scheme", "hint" => "When the purchaser buys an initial share of up to 75% of the property value and pays rent to the Private Registered Provider (PRP) on the remaining portion, or a subsequent staircasing transaction" }, "2" => { "value" => "Yes - a discounted ownership scheme" }, 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 af3f2a78b..9ac0791a4 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 @@ -16,7 +16,7 @@ class Form::Sales::Questions::PersonRelationshipToBuyer1 < ::Form::Question end def answer_options - if form.start_year_after_2024? + if form.start_year_2024_or_later? { "P" => { "value" => "Partner" }, "C" => { "value" => "Child" }, diff --git a/app/models/form/sales/questions/person_working_situation.rb b/app/models/form/sales/questions/person_working_situation.rb index 488a77092..f3fbebd6f 100644 --- a/app/models/form/sales/questions/person_working_situation.rb +++ b/app/models/form/sales/questions/person_working_situation.rb @@ -16,27 +16,51 @@ class Form::Sales::Questions::PersonWorkingSituation < ::Form::Question end def answer_options - { - "1" => { "value" => "Full-time - 30 hours or more" }, - "2" => { "value" => "Part-time - Less than 30 hours" }, - "3" => { "value" => "In government training into work" }, - "4" => { "value" => "Jobseeker" }, - "6" => { "value" => "Not seeking work" }, - "8" => { "value" => "Unable to work due to long term sick or disability" }, - "5" => { "value" => "Retired" }, - "0" => { "value" => "Other" }, - "10" => { "value" => "Person prefers not to say" }, - "7" => { "value" => "Full-time student" }, - "9" => { - "value" => "Child under 16", - "depends_on" => [ - { "saledate" => { "operator" => "<", "operand" => Time.zone.local(2024, 4, 1) } }, - { "age#{@person_index}_known" => 1 }, - { "age#{@person_index}_known" => nil }, - { "age#{@person_index}" => { "operator" => "<", "operand" => 16 } }, - ], - }, - } + if form.start_year_2025_or_later? + { + "1" => { "value" => "Full-time - 30 hours or more" }, + "2" => { "value" => "Part-time - Less than 30 hours" }, + "3" => { "value" => "In government training into work" }, + "4" => { "value" => "Jobseeker" }, + "5" => { "value" => "Retired" }, + "6" => { "value" => "Not seeking work" }, + "7" => { "value" => "Full-time student" }, + "8" => { "value" => "Unable to work due to long term sick or disability" }, + "9" => { + "value" => "Child under 16", + "depends_on" => [ + { "saledate" => { "operator" => "<", "operand" => Time.zone.local(2024, 4, 1) } }, + { "age#{@person_index}_known" => 1 }, + { "age#{@person_index}_known" => nil }, + { "age#{@person_index}" => { "operator" => "<", "operand" => 16 } }, + ], + }, + "0" => { "value" => "Other" }, + "10" => { "value" => "Person prefers not to say" }, + } + else + { + "1" => { "value" => "Full-time - 30 hours or more" }, + "2" => { "value" => "Part-time - Less than 30 hours" }, + "3" => { "value" => "In government training into work" }, + "4" => { "value" => "Jobseeker" }, + "6" => { "value" => "Not seeking work" }, + "8" => { "value" => "Unable to work due to long term sick or disability" }, + "5" => { "value" => "Retired" }, + "0" => { "value" => "Other" }, + "10" => { "value" => "Person prefers not to say" }, + "7" => { "value" => "Full-time student" }, + "9" => { + "value" => "Child under 16", + "depends_on" => [ + { "saledate" => { "operator" => "<", "operand" => Time.zone.local(2024, 4, 1) } }, + { "age#{@person_index}_known" => 1 }, + { "age#{@person_index}_known" => nil }, + { "age#{@person_index}" => { "operator" => "<", "operand" => 16 } }, + ], + }, + } + end end def question_number diff --git a/app/models/form/sales/questions/previous_bedrooms.rb b/app/models/form/sales/questions/previous_bedrooms.rb index 50970bc89..d29da208a 100644 --- a/app/models/form/sales/questions/previous_bedrooms.rb +++ b/app/models/form/sales/questions/previous_bedrooms.rb @@ -2,14 +2,12 @@ class Form::Sales::Questions::PreviousBedrooms < ::Form::Question def initialize(id, hsh, page) super @id = "frombeds" - @check_answer_label = "Number of bedrooms in previous property" - @header = "How many bedrooms did the property have?" + @copy_key = "sales.sale_information.frombeds" @type = "numeric" @width = 5 @min = 1 @max = 6 @step = 1 - @hint_text = "For bedsits enter 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/previous_tenure.rb b/app/models/form/sales/questions/previous_tenure.rb index 7227fa00e..55b103f0d 100644 --- a/app/models/form/sales/questions/previous_tenure.rb +++ b/app/models/form/sales/questions/previous_tenure.rb @@ -2,10 +2,8 @@ class Form::Sales::Questions::PreviousTenure < ::Form::Question def initialize(id, hsh, page) super @id = "socprevten" - @check_answer_label = "Previous property tenure" - @header = "What was the previous tenure of the buyer?" + @copy_key = "sales.sale_information.socprevten" @type = "radio" - @hint_text = "" @page = page @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/privacy_notice.rb b/app/models/form/sales/questions/privacy_notice.rb index 57f77041b..5e73e7a3a 100644 --- a/app/models/form/sales/questions/privacy_notice.rb +++ b/app/models/form/sales/questions/privacy_notice.rb @@ -10,7 +10,7 @@ class Form::Sales::Questions::PrivacyNotice < ::Form::Question end def answer_options - declaration_text = if form.start_year_after_2024? + declaration_text = if form.start_year_2024_or_later? "The #{@joint_purchase ? 'buyers have' : 'buyer has'} seen or been given access to the MHCLG privacy notice" else "The #{@joint_purchase ? 'buyers have' : 'buyer has'} seen the MHCLG privacy notice" @@ -21,7 +21,7 @@ class Form::Sales::Questions::PrivacyNotice < ::Form::Question def unanswered_error_message buyer_or_buyers = @joint_purchase ? "buyers" : "buyer" - if form.start_year_after_2024? + if form.start_year_2024_or_later? I18n.t("validations.privacynotice.missing.post_2024", buyer_or_buyers:) else I18n.t("validations.privacynotice.missing.pre_2024", buyer_or_buyers:) diff --git a/app/models/form/sales/questions/purchase_price.rb b/app/models/form/sales/questions/purchase_price.rb index 3a9bd4ee7..44497b727 100644 --- a/app/models/form/sales/questions/purchase_price.rb +++ b/app/models/form/sales/questions/purchase_price.rb @@ -2,14 +2,11 @@ class Form::Sales::Questions::PurchasePrice < ::Form::Question def initialize(id, hsh, page, ownershipsch:) super(id, hsh, page) @id = "value" - @check_answer_label = "Purchase price" - @header = "What is the full purchase price?" @type = "numeric" @min = 0 @step = 0.01 @width = 5 @prefix = "£" - @hint_text = hint_text @ownership_sch = ownershipsch @question_number = QUESTION_NUMBER_FROM_YEAR_AND_OWNERSHIP.fetch(form.start_date.year, QUESTION_NUMBER_FROM_YEAR_AND_OWNERSHIP.max_by { |k, _v| k }.last)[ownershipsch] @top_guidance_partial = top_guidance_partial @@ -20,10 +17,13 @@ class Form::Sales::Questions::PurchasePrice < ::Form::Question 2024 => { 2 => 101, 3 => 111 }, }.freeze - def hint_text - return if @ownership_sch == 3 # outright sale - - "For all schemes, including Right to Acquire (RTA), Right to Buy (RTB), Voluntary Right to Buy (VRTB) or Preserved Right to Buy (PRTB) sales, enter the full price of the property without any discount" + def copy_key + case @ownership_sch + when 2 + "sales.sale_information.purchase_price.discounted_ownership" + when 3 + "sales.sale_information.purchase_price.outright_sale" + end end def top_guidance_partial diff --git a/app/models/form/sales/questions/resale.rb b/app/models/form/sales/questions/resale.rb index be4e5535d..0026adb48 100644 --- a/app/models/form/sales/questions/resale.rb +++ b/app/models/form/sales/questions/resale.rb @@ -2,11 +2,9 @@ class Form::Sales::Questions::Resale < ::Form::Question def initialize(id, hsh, page) super @id = "resale" - @check_answer_label = "Is this a resale?" - @header = "Is this a resale?" + @copy_key = "sales.sale_information.resale" @type = "radio" @answer_options = ANSWER_OPTIONS - @hint_text = "If the social landlord has previously sold the property to another buyer and is now reselling the property, select 'yes'. If this is the first time the property has been sold, select 'no'." @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/shared_ownership_deposit_value_check.rb b/app/models/form/sales/questions/shared_ownership_deposit_value_check.rb index 3f8111881..e7f520b43 100644 --- a/app/models/form/sales/questions/shared_ownership_deposit_value_check.rb +++ b/app/models/form/sales/questions/shared_ownership_deposit_value_check.rb @@ -2,9 +2,8 @@ class Form::Sales::Questions::SharedOwnershipDepositValueCheck < ::Form::Questio def initialize(id, hsh, page) super @id = "shared_ownership_deposit_value_check" - @check_answer_label = "Shared ownership deposit confirmation" + @copy_key = "sales.soft_validations.shared_ownership_deposit_value_check" @type = "interruption_screen" - @header = "Are you sure this is correct?" @answer_options = { "0" => { "value" => "Yes" }, "1" => { "value" => "No" }, diff --git a/app/models/form/sales/questions/staircase.rb b/app/models/form/sales/questions/staircase.rb index 1eb84bfb5..6c98397ff 100644 --- a/app/models/form/sales/questions/staircase.rb +++ b/app/models/form/sales/questions/staircase.rb @@ -2,19 +2,25 @@ class Form::Sales::Questions::Staircase < ::Form::Question def initialize(id, hsh, page) super @id = "staircase" - @check_answer_label = "Staircasing transaction" - @header = "Is this a staircasing transaction?" + @copy_key = "sales.#{page.subsection.id}.staircasing" @type = "radio" - @answer_options = ANSWER_OPTIONS - @hint_text = "A staircasing transaction is when the household purchases more shares in their property, increasing the proportion they own and decreasing the proportion the housing association owns. Once the household purchases 100% of the shares, they own the property" @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" }, - "2" => { "value" => "No" }, - "3" => { "value" => "Don’t know" }, - }.freeze + def answer_options + if form.start_year_2025_or_later? + { + "1" => { "value" => "Yes" }, + "2" => { "value" => "No" }, + }.freeze + else + { + "1" => { "value" => "Yes" }, + "2" => { "value" => "No" }, + "3" => { "value" => "Don’t know" }, + }.freeze + end + end QUESTION_NUMBER_FROM_YEAR = { 2023 => 76, 2024 => 78 }.freeze end diff --git a/app/models/form/sales/questions/staircase_bought.rb b/app/models/form/sales/questions/staircase_bought.rb index 5218ca297..a9a3d6f23 100644 --- a/app/models/form/sales/questions/staircase_bought.rb +++ b/app/models/form/sales/questions/staircase_bought.rb @@ -2,8 +2,7 @@ class Form::Sales::Questions::StaircaseBought < ::Form::Question def initialize(id, hsh, page) super @id = "stairbought" - @check_answer_label = "Percentage bought in this staircasing transaction" - @header = "What percentage of the property has been bought in this staircasing transaction?" + @copy_key = "sales.sale_information.about_staircasing.stairbought" @type = "numeric" @width = 5 @min = 0 diff --git a/app/models/form/sales/questions/staircase_bought_value_check.rb b/app/models/form/sales/questions/staircase_bought_value_check.rb index 65fe02e66..146e89dfd 100644 --- a/app/models/form/sales/questions/staircase_bought_value_check.rb +++ b/app/models/form/sales/questions/staircase_bought_value_check.rb @@ -2,8 +2,7 @@ class Form::Sales::Questions::StaircaseBoughtValueCheck < ::Form::Question def initialize(id, hsh, page) super @id = "staircase_bought_value_check" - @check_answer_label = "Percentage bought confirmation" - @header = "Are you sure this is correct?" + @copy_key = "sales.soft_validations.staircase_bought_value_check" @type = "interruption_screen" @answer_options = { "0" => { "value" => "Yes" }, diff --git a/app/models/form/sales/questions/staircase_owned.rb b/app/models/form/sales/questions/staircase_owned.rb index 04403771e..e0ec8865c 100644 --- a/app/models/form/sales/questions/staircase_owned.rb +++ b/app/models/form/sales/questions/staircase_owned.rb @@ -2,8 +2,7 @@ class Form::Sales::Questions::StaircaseOwned < ::Form::Question def initialize(id, hsh, page, joint_purchase:) super(id, hsh, page) @id = "stairowned" - @check_answer_label = I18n.t("check_answer_labels.stairowned", count: joint_purchase ? 2 : 1) - @header = I18n.t("questions.stairowned", count: joint_purchase ? 2 : 1) + @copy_key = "sales.sale_information.about_staircasing.stairowned.#{joint_purchase ? 'joint_purchase' : 'not_joint_purchase'}" @type = "numeric" @width = 5 @min = 0 diff --git a/app/models/form/sales/questions/staircase_owned_value_check.rb b/app/models/form/sales/questions/staircase_owned_value_check.rb index eb742b196..3457d60fe 100644 --- a/app/models/form/sales/questions/staircase_owned_value_check.rb +++ b/app/models/form/sales/questions/staircase_owned_value_check.rb @@ -1,9 +1,8 @@ class Form::Sales::Questions::StaircaseOwnedValueCheck < ::Form::Question - def initialize(id, hsh, page) - super + def initialize(id, hsh, page, joint_purchase:) + super(id, hsh, page) @id = "stairowned_value_check" - @check_answer_label = "Percentage owned confirmation" - @header = "Are you sure?" + @copy_key = "sales.soft_validations.stairowned_value_check.#{joint_purchase ? 'joint_purchase' : 'not_joint_purchase'}" @type = "interruption_screen" @answer_options = { "0" => { "value" => "Yes" }, diff --git a/app/models/form/sales/questions/staircase_sale.rb b/app/models/form/sales/questions/staircase_sale.rb index de1c8305a..ac54084f5 100644 --- a/app/models/form/sales/questions/staircase_sale.rb +++ b/app/models/form/sales/questions/staircase_sale.rb @@ -2,8 +2,7 @@ class Form::Sales::Questions::StaircaseSale < ::Form::Question def initialize(id, hsh, page) super @id = "staircasesale" - @check_answer_label = "Part of a back-to-back staircasing transaction" - @header = "Is this transaction part of a back-to-back staircasing transaction to facilitate sale of the home on the open market?" + @copy_key = "sales.sale_information.about_staircasing.staircasesale" @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/uprn_confirmation.rb b/app/models/form/sales/questions/uprn_confirmation.rb index 94c1afa36..fed35f665 100644 --- a/app/models/form/sales/questions/uprn_confirmation.rb +++ b/app/models/form/sales/questions/uprn_confirmation.rb @@ -6,7 +6,7 @@ class Form::Sales::Questions::UprnConfirmation < ::Form::Question end def answer_options - if form.start_year_after_2024? + if form.start_year_2024_or_later? { "1" => { "value" => "Yes" }, "0" => { "value" => "No, I want to search for the address instead" }, diff --git a/app/models/form/sales/questions/value.rb b/app/models/form/sales/questions/value.rb index 3ec96e76e..257344fa2 100644 --- a/app/models/form/sales/questions/value.rb +++ b/app/models/form/sales/questions/value.rb @@ -2,14 +2,12 @@ class Form::Sales::Questions::Value < ::Form::Question def initialize(id, hsh, page) super @id = "value" - @check_answer_label = "Full purchase price" - @header = "What was the full purchase price?" + @copy_key = "sales.sale_information.value" @type = "numeric" @min = 0 @step = 1 @width = 5 @prefix = "£" - @hint_text = "Enter the full purchase price of the property before any discounts are applied. For shared ownership, enter the full purchase price paid for 100% equity (this is equal to the value of the share owned by the PRP plus the value bought by the purchaser)" @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] @top_guidance_partial = "financial_calculations_shared_ownership" end diff --git a/app/models/form/sales/subsections/household_characteristics.rb b/app/models/form/sales/subsections/household_characteristics.rb index afbbe4278..f1f01ba62 100644 --- a/app/models/form/sales/subsections/household_characteristics.rb +++ b/app/models/form/sales/subsections/household_characteristics.rb @@ -8,13 +8,13 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection def pages @pages ||= [ - (Form::Sales::Pages::BuyerInterview.new("buyer_interview_joint_purchase", nil, self, joint_purchase: true) unless form.start_year_after_2024?), - (Form::Sales::Pages::BuyerInterview.new("buyer_interview", nil, self, joint_purchase: false) unless form.start_year_after_2024?), - (Form::Sales::Pages::PrivacyNotice.new("privacy_notice_joint_purchase", nil, self, joint_purchase: true) unless form.start_year_after_2024?), - (Form::Sales::Pages::PrivacyNotice.new("privacy_notice", nil, self, joint_purchase: false) unless form.start_year_after_2024?), + (Form::Sales::Pages::BuyerInterview.new("buyer_interview_joint_purchase", nil, self, joint_purchase: true) unless form.start_year_2024_or_later?), + (Form::Sales::Pages::BuyerInterview.new("buyer_interview", nil, self, joint_purchase: false) unless form.start_year_2024_or_later?), + (Form::Sales::Pages::PrivacyNotice.new("privacy_notice_joint_purchase", nil, self, joint_purchase: true) unless form.start_year_2024_or_later?), + (Form::Sales::Pages::PrivacyNotice.new("privacy_notice", nil, self, joint_purchase: false) unless form.start_year_2024_or_later?), Form::Sales::Pages::Age1.new(nil, nil, self), Form::Sales::Pages::RetirementValueCheck.new("age_1_retirement_value_check", nil, self, person_index: 1), - (Form::Sales::Pages::NotRetiredValueCheck.new("age_1_not_retired_value_check", nil, self, person_index: 1) if form.start_year_after_2024?), + (Form::Sales::Pages::NotRetiredValueCheck.new("age_1_not_retired_value_check", nil, self, person_index: 1) if form.start_year_2024_or_later?), Form::Sales::Pages::OldPersonsSharedOwnershipValueCheck.new("age_1_old_persons_shared_ownership_joint_purchase_value_check", nil, self, joint_purchase: true), Form::Sales::Pages::OldPersonsSharedOwnershipValueCheck.new("age_1_old_persons_shared_ownership_value_check", nil, self, joint_purchase: false), Form::Sales::Pages::GenderIdentity1.new(nil, nil, self), @@ -27,7 +27,7 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection Form::Sales::Pages::Buyer1Nationality.new(nil, nil, self), Form::Sales::Pages::Buyer1WorkingSituation.new(nil, nil, self), Form::Sales::Pages::RetirementValueCheck.new("working_situation_1_retirement_value_check", nil, self, person_index: 1), - (Form::Sales::Pages::NotRetiredValueCheck.new("working_situation_1_not_retired_value_check", nil, self, person_index: 1) if form.start_year_after_2024?), + (Form::Sales::Pages::NotRetiredValueCheck.new("working_situation_1_not_retired_value_check", nil, self, person_index: 1) if form.start_year_2024_or_later?), Form::Sales::Pages::Buyer1IncomeMinValueCheck.new("working_situation_buyer_1_income_min_value_check", nil, self), Form::Sales::Pages::Buyer1LiveInProperty.new(nil, nil, self), Form::Sales::Pages::BuyerLiveInValueCheck.new("buyer_1_live_in_property_value_check", nil, self, person_index: 1), @@ -37,13 +37,13 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection Form::Sales::Pages::OldPersonsSharedOwnershipValueCheck.new("age_2_old_persons_shared_ownership_joint_purchase_value_check", nil, self, joint_purchase: true), Form::Sales::Pages::OldPersonsSharedOwnershipValueCheck.new("age_2_old_persons_shared_ownership_value_check", nil, self, joint_purchase: false), Form::Sales::Pages::RetirementValueCheck.new("age_2_buyer_retirement_value_check", nil, self, person_index: 2), - (Form::Sales::Pages::NotRetiredValueCheck.new("age_2_buyer_not_retired_value_check", nil, self, person_index: 2) if form.start_year_after_2024?), + (Form::Sales::Pages::NotRetiredValueCheck.new("age_2_buyer_not_retired_value_check", nil, self, person_index: 2) if form.start_year_2024_or_later?), Form::Sales::Pages::PersonStudentNotChildValueCheck.new("buyer_2_age_student_not_child_value_check", nil, self, person_index: 2), Form::Sales::Pages::GenderIdentity2.new(nil, nil, self), buyer_2_ethnicity_nationality_pages, Form::Sales::Pages::Buyer2WorkingSituation.new(nil, nil, self), Form::Sales::Pages::RetirementValueCheck.new("working_situation_2_retirement_value_check_joint_purchase", nil, self, person_index: 2), - (Form::Sales::Pages::NotRetiredValueCheck.new("working_situation_2_not_retired_value_check_joint_purchase", nil, self, person_index: 2) if form.start_year_after_2024?), + (Form::Sales::Pages::NotRetiredValueCheck.new("working_situation_2_not_retired_value_check_joint_purchase", nil, self, person_index: 2) if form.start_year_2024_or_later?), Form::Sales::Pages::Buyer2IncomeMinValueCheck.new("working_situation_buyer_2_income_min_value_check", nil, self), Form::Sales::Pages::PersonStudentNotChildValueCheck.new("buyer_2_working_situation_student_not_child_value_check", nil, self, person_index: 2), Form::Sales::Pages::Buyer2LiveInProperty.new(nil, nil, self), @@ -52,78 +52,78 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection Form::Sales::Pages::NumberOfOthersInProperty.new("number_of_others_in_property_joint_purchase", nil, self, joint_purchase: true), Form::Sales::Pages::PersonKnown.new("person_2_known", nil, self, person_index: 2), Form::Sales::Pages::PersonRelationshipToBuyer1.new("person_2_relationship_to_buyer_1", nil, self, person_index: 2), - (Form::Sales::Pages::PartnerUnder16ValueCheck.new("relationship_2_partner_under_16_value_check", nil, self, person_index: 2) if form.start_year_after_2024?), - (Form::Sales::Pages::MultiplePartnersValueCheck.new("relationship_2_multiple_partners_value_check", nil, self, person_index: 2) if form.start_year_after_2024?), + (Form::Sales::Pages::PartnerUnder16ValueCheck.new("relationship_2_partner_under_16_value_check", nil, self, person_index: 2) if form.start_year_2024_or_later?), + (Form::Sales::Pages::MultiplePartnersValueCheck.new("relationship_2_multiple_partners_value_check", nil, self, person_index: 2) if form.start_year_2024_or_later?), Form::Sales::Pages::PersonStudentNotChildValueCheck.new("relationship_2_student_not_child_value_check", nil, self, person_index: 2), Form::Sales::Pages::PersonAge.new("person_2_age", nil, self, person_index: 2), Form::Sales::Pages::RetirementValueCheck.new("age_2_retirement_value_check", nil, self, person_index: 2), - (Form::Sales::Pages::NotRetiredValueCheck.new("age_2_not_retired_value_check", nil, self, person_index: 2) if form.start_year_after_2024?), + (Form::Sales::Pages::NotRetiredValueCheck.new("age_2_not_retired_value_check", nil, self, person_index: 2) if form.start_year_2024_or_later?), Form::Sales::Pages::PersonStudentNotChildValueCheck.new("age_2_student_not_child_value_check", nil, self, person_index: 2), - (Form::Sales::Pages::PartnerUnder16ValueCheck.new("age_2_partner_under_16_value_check", nil, self, person_index: 2) if form.start_year_after_2024?), + (Form::Sales::Pages::PartnerUnder16ValueCheck.new("age_2_partner_under_16_value_check", nil, self, person_index: 2) if form.start_year_2024_or_later?), Form::Sales::Pages::PersonGenderIdentity.new("person_2_gender_identity", nil, self, person_index: 2), Form::Sales::Pages::PersonWorkingSituation.new("person_2_working_situation", nil, self, person_index: 2), Form::Sales::Pages::RetirementValueCheck.new("working_situation_2_retirement_value_check", nil, self, person_index: 2), - (Form::Sales::Pages::NotRetiredValueCheck.new("working_situation_2_not_retired_value_check", nil, self, person_index: 2) if form.start_year_after_2024?), + (Form::Sales::Pages::NotRetiredValueCheck.new("working_situation_2_not_retired_value_check", nil, self, person_index: 2) if form.start_year_2024_or_later?), Form::Sales::Pages::PersonStudentNotChildValueCheck.new("working_situation_2_student_not_child_value_check", nil, self, person_index: 2), Form::Sales::Pages::PersonKnown.new("person_3_known", nil, self, person_index: 3), Form::Sales::Pages::PersonRelationshipToBuyer1.new("person_3_relationship_to_buyer_1", nil, self, person_index: 3), - (Form::Sales::Pages::PartnerUnder16ValueCheck.new("relationship_3_partner_under_16_value_check", nil, self, person_index: 3) if form.start_year_after_2024?), - (Form::Sales::Pages::MultiplePartnersValueCheck.new("relationship_3_multiple_partners_value_check", nil, self, person_index: 3) if form.start_year_after_2024?), + (Form::Sales::Pages::PartnerUnder16ValueCheck.new("relationship_3_partner_under_16_value_check", nil, self, person_index: 3) if form.start_year_2024_or_later?), + (Form::Sales::Pages::MultiplePartnersValueCheck.new("relationship_3_multiple_partners_value_check", nil, self, person_index: 3) if form.start_year_2024_or_later?), Form::Sales::Pages::PersonStudentNotChildValueCheck.new("relationship_3_student_not_child_value_check", nil, self, person_index: 3), Form::Sales::Pages::PersonAge.new("person_3_age", nil, self, person_index: 3), Form::Sales::Pages::RetirementValueCheck.new("age_3_retirement_value_check", nil, self, person_index: 3), - (Form::Sales::Pages::NotRetiredValueCheck.new("age_3_not_retired_value_check", nil, self, person_index: 3) if form.start_year_after_2024?), + (Form::Sales::Pages::NotRetiredValueCheck.new("age_3_not_retired_value_check", nil, self, person_index: 3) if form.start_year_2024_or_later?), Form::Sales::Pages::PersonStudentNotChildValueCheck.new("age_3_student_not_child_value_check", nil, self, person_index: 3), - (Form::Sales::Pages::PartnerUnder16ValueCheck.new("age_3_partner_under_16_value_check", nil, self, person_index: 3) if form.start_year_after_2024?), + (Form::Sales::Pages::PartnerUnder16ValueCheck.new("age_3_partner_under_16_value_check", nil, self, person_index: 3) if form.start_year_2024_or_later?), Form::Sales::Pages::PersonGenderIdentity.new("person_3_gender_identity", nil, self, person_index: 3), Form::Sales::Pages::PersonWorkingSituation.new("person_3_working_situation", nil, self, person_index: 3), Form::Sales::Pages::RetirementValueCheck.new("working_situation_3_retirement_value_check", nil, self, person_index: 3), - (Form::Sales::Pages::NotRetiredValueCheck.new("working_situation_3_not_retired_value_check", nil, self, person_index: 3) if form.start_year_after_2024?), + (Form::Sales::Pages::NotRetiredValueCheck.new("working_situation_3_not_retired_value_check", nil, self, person_index: 3) if form.start_year_2024_or_later?), Form::Sales::Pages::PersonStudentNotChildValueCheck.new("working_situation_3_student_not_child_value_check", nil, self, person_index: 3), Form::Sales::Pages::PersonKnown.new("person_4_known", nil, self, person_index: 4), Form::Sales::Pages::PersonRelationshipToBuyer1.new("person_4_relationship_to_buyer_1", nil, self, person_index: 4), - (Form::Sales::Pages::PartnerUnder16ValueCheck.new("relationship_4_partner_under_16_value_check", nil, self, person_index: 4) if form.start_year_after_2024?), - (Form::Sales::Pages::MultiplePartnersValueCheck.new("relationship_4_multiple_partners_value_check", nil, self, person_index: 4) if form.start_year_after_2024?), + (Form::Sales::Pages::PartnerUnder16ValueCheck.new("relationship_4_partner_under_16_value_check", nil, self, person_index: 4) if form.start_year_2024_or_later?), + (Form::Sales::Pages::MultiplePartnersValueCheck.new("relationship_4_multiple_partners_value_check", nil, self, person_index: 4) if form.start_year_2024_or_later?), Form::Sales::Pages::PersonStudentNotChildValueCheck.new("relationship_4_student_not_child_value_check", nil, self, person_index: 4), Form::Sales::Pages::PersonAge.new("person_4_age", nil, self, person_index: 4), Form::Sales::Pages::RetirementValueCheck.new("age_4_retirement_value_check", nil, self, person_index: 4), - (Form::Sales::Pages::NotRetiredValueCheck.new("age_4_not_retired_value_check", nil, self, person_index: 4) if form.start_year_after_2024?), + (Form::Sales::Pages::NotRetiredValueCheck.new("age_4_not_retired_value_check", nil, self, person_index: 4) if form.start_year_2024_or_later?), Form::Sales::Pages::PersonStudentNotChildValueCheck.new("age_4_student_not_child_value_check", nil, self, person_index: 4), - (Form::Sales::Pages::PartnerUnder16ValueCheck.new("age_4_partner_under_16_value_check", nil, self, person_index: 4) if form.start_year_after_2024?), + (Form::Sales::Pages::PartnerUnder16ValueCheck.new("age_4_partner_under_16_value_check", nil, self, person_index: 4) if form.start_year_2024_or_later?), Form::Sales::Pages::PersonGenderIdentity.new("person_4_gender_identity", nil, self, person_index: 4), Form::Sales::Pages::PersonWorkingSituation.new("person_4_working_situation", nil, self, person_index: 4), Form::Sales::Pages::RetirementValueCheck.new("working_situation_4_retirement_value_check", nil, self, person_index: 4), - (Form::Sales::Pages::NotRetiredValueCheck.new("working_situation_4_not_retired_value_check", nil, self, person_index: 4) if form.start_year_after_2024?), + (Form::Sales::Pages::NotRetiredValueCheck.new("working_situation_4_not_retired_value_check", nil, self, person_index: 4) if form.start_year_2024_or_later?), Form::Sales::Pages::PersonStudentNotChildValueCheck.new("working_situation_4_student_not_child_value_check", nil, self, person_index: 4), Form::Sales::Pages::PersonKnown.new("person_5_known", nil, self, person_index: 5), Form::Sales::Pages::PersonRelationshipToBuyer1.new("person_5_relationship_to_buyer_1", nil, self, person_index: 5), - (Form::Sales::Pages::PartnerUnder16ValueCheck.new("relationship_5_partner_under_16_value_check", nil, self, person_index: 5) if form.start_year_after_2024?), - (Form::Sales::Pages::MultiplePartnersValueCheck.new("relationship_5_multiple_partners_value_check", nil, self, person_index: 5) if form.start_year_after_2024?), + (Form::Sales::Pages::PartnerUnder16ValueCheck.new("relationship_5_partner_under_16_value_check", nil, self, person_index: 5) if form.start_year_2024_or_later?), + (Form::Sales::Pages::MultiplePartnersValueCheck.new("relationship_5_multiple_partners_value_check", nil, self, person_index: 5) if form.start_year_2024_or_later?), Form::Sales::Pages::PersonStudentNotChildValueCheck.new("relationship_5_student_not_child_value_check", nil, self, person_index: 5), Form::Sales::Pages::PersonAge.new("person_5_age", nil, self, person_index: 5), Form::Sales::Pages::RetirementValueCheck.new("age_5_retirement_value_check", nil, self, person_index: 5), - (Form::Sales::Pages::NotRetiredValueCheck.new("age_5_not_retired_value_check", nil, self, person_index: 5) if form.start_year_after_2024?), + (Form::Sales::Pages::NotRetiredValueCheck.new("age_5_not_retired_value_check", nil, self, person_index: 5) if form.start_year_2024_or_later?), Form::Sales::Pages::PersonStudentNotChildValueCheck.new("age_5_student_not_child_value_check", nil, self, person_index: 5), - (Form::Sales::Pages::PartnerUnder16ValueCheck.new("age_5_partner_under_16_value_check", nil, self, person_index: 5) if form.start_year_after_2024?), + (Form::Sales::Pages::PartnerUnder16ValueCheck.new("age_5_partner_under_16_value_check", nil, self, person_index: 5) if form.start_year_2024_or_later?), Form::Sales::Pages::PersonGenderIdentity.new("person_5_gender_identity", nil, self, person_index: 5), Form::Sales::Pages::PersonWorkingSituation.new("person_5_working_situation", nil, self, person_index: 5), Form::Sales::Pages::RetirementValueCheck.new("working_situation_5_retirement_value_check", nil, self, person_index: 5), - (Form::Sales::Pages::NotRetiredValueCheck.new("working_situation_5_not_retired_value_check", nil, self, person_index: 5) if form.start_year_after_2024?), + (Form::Sales::Pages::NotRetiredValueCheck.new("working_situation_5_not_retired_value_check", nil, self, person_index: 5) if form.start_year_2024_or_later?), Form::Sales::Pages::PersonStudentNotChildValueCheck.new("working_situation_5_student_not_child_value_check", nil, self, person_index: 5), Form::Sales::Pages::PersonKnown.new("person_6_known", nil, self, person_index: 6), Form::Sales::Pages::PersonRelationshipToBuyer1.new("person_6_relationship_to_buyer_1", nil, self, person_index: 6), - (Form::Sales::Pages::PartnerUnder16ValueCheck.new("relationship_6_partner_under_16_value_check", nil, self, person_index: 6) if form.start_year_after_2024?), - (Form::Sales::Pages::MultiplePartnersValueCheck.new("relationship_6_multiple_partners_value_check", nil, self, person_index: 6) if form.start_year_after_2024?), + (Form::Sales::Pages::PartnerUnder16ValueCheck.new("relationship_6_partner_under_16_value_check", nil, self, person_index: 6) if form.start_year_2024_or_later?), + (Form::Sales::Pages::MultiplePartnersValueCheck.new("relationship_6_multiple_partners_value_check", nil, self, person_index: 6) if form.start_year_2024_or_later?), Form::Sales::Pages::PersonStudentNotChildValueCheck.new("relationship_6_student_not_child_value_check", nil, self, person_index: 6), Form::Sales::Pages::PersonAge.new("person_6_age", nil, self, person_index: 6), Form::Sales::Pages::RetirementValueCheck.new("age_6_retirement_value_check", nil, self, person_index: 6), - (Form::Sales::Pages::NotRetiredValueCheck.new("age_6_not_retired_value_check", nil, self, person_index: 6) if form.start_year_after_2024?), + (Form::Sales::Pages::NotRetiredValueCheck.new("age_6_not_retired_value_check", nil, self, person_index: 6) if form.start_year_2024_or_later?), Form::Sales::Pages::PersonStudentNotChildValueCheck.new("age_6_student_not_child_value_check", nil, self, person_index: 6), - (Form::Sales::Pages::PartnerUnder16ValueCheck.new("age_6_partner_under_16_value_check", nil, self, person_index: 6) if form.start_year_after_2024?), + (Form::Sales::Pages::PartnerUnder16ValueCheck.new("age_6_partner_under_16_value_check", nil, self, person_index: 6) if form.start_year_2024_or_later?), Form::Sales::Pages::PersonGenderIdentity.new("person_6_gender_identity", nil, self, person_index: 6), Form::Sales::Pages::PersonWorkingSituation.new("person_6_working_situation", nil, self, person_index: 6), Form::Sales::Pages::RetirementValueCheck.new("working_situation_6_retirement_value_check", nil, self, person_index: 6), - (Form::Sales::Pages::NotRetiredValueCheck.new("working_situation_6_not_retired_value_check", nil, self, person_index: 6) if form.start_year_after_2024?), + (Form::Sales::Pages::NotRetiredValueCheck.new("working_situation_6_not_retired_value_check", nil, self, person_index: 6) if form.start_year_2024_or_later?), Form::Sales::Pages::PersonStudentNotChildValueCheck.new("working_situation_6_student_not_child_value_check", nil, self, person_index: 6), ].flatten.compact end diff --git a/app/models/form/sales/subsections/household_situation.rb b/app/models/form/sales/subsections/household_situation.rb index 225b1ae43..2e496908b 100644 --- a/app/models/form/sales/subsections/household_situation.rb +++ b/app/models/form/sales/subsections/household_situation.rb @@ -11,17 +11,9 @@ class Form::Sales::Subsections::HouseholdSituation < ::Form::Subsection Form::Sales::Pages::Buyer1PreviousTenure.new(nil, nil, self), Form::Sales::Pages::LastAccommodation.new(nil, nil, self), Form::Sales::Pages::LastAccommodationLa.new(nil, nil, self), - Form::Sales::Pages::BuyersOrganisations.new(nil, nil, self), - buyer_2_situation_pages, + (Form::Sales::Pages::BuyersOrganisations.new(nil, nil, self) unless form.start_year_2025_or_later?), + Form::Sales::Pages::Buyer2LivingIn.new(nil, nil, self), + Form::Sales::Pages::Buyer2PreviousHousingSituation.new(nil, nil, self), ].flatten.compact end - - def buyer_2_situation_pages - if form.start_date.year >= 2023 - [ - Form::Sales::Pages::Buyer2LivingIn.new(nil, nil, self), - Form::Sales::Pages::Buyer2PreviousHousingSituation.new(nil, nil, self), - ] - end - end end diff --git a/app/models/form/sales/subsections/outright_sale.rb b/app/models/form/sales/subsections/outright_sale.rb index 6b29313a1..af63c8179 100644 --- a/app/models/form/sales/subsections/outright_sale.rb +++ b/app/models/form/sales/subsections/outright_sale.rb @@ -14,8 +14,8 @@ class Form::Sales::Subsections::OutrightSale < ::Form::Subsection Form::Sales::Pages::MortgageValueCheck.new("outright_sale_mortgage_used_mortgage_value_check", nil, self), Form::Sales::Pages::MortgageAmount.new("mortgage_amount_outright_sale", nil, self, ownershipsch: 3), Form::Sales::Pages::MortgageValueCheck.new("outright_sale_mortgage_amount_mortgage_value_check", nil, self), - (Form::Sales::Pages::MortgageLender.new("mortgage_lender_outright_sale", nil, self, ownershipsch: 3) unless form.start_year_after_2024?), - (Form::Sales::Pages::MortgageLenderOther.new("mortgage_lender_other_outright_sale", nil, self, ownershipsch: 3) unless form.start_year_after_2024?), + (Form::Sales::Pages::MortgageLender.new("mortgage_lender_outright_sale", nil, self, ownershipsch: 3) unless form.start_year_2024_or_later?), + (Form::Sales::Pages::MortgageLenderOther.new("mortgage_lender_other_outright_sale", nil, self, ownershipsch: 3) unless form.start_year_2024_or_later?), Form::Sales::Pages::MortgageLength.new("mortgage_length_outright_sale", nil, self, ownershipsch: 3), Form::Sales::Pages::ExtraBorrowing.new("extra_borrowing_outright_sale", nil, self, ownershipsch: 3), Form::Sales::Pages::Deposit.new("deposit_outright_sale", nil, self, ownershipsch: 3, optional: false), diff --git a/app/models/form/sales/subsections/property_information.rb b/app/models/form/sales/subsections/property_information.rb index c59c159ae..5d4021681 100644 --- a/app/models/form/sales/subsections/property_information.rb +++ b/app/models/form/sales/subsections/property_information.rb @@ -9,9 +9,10 @@ class Form::Sales::Subsections::PropertyInformation < ::Form::Subsection def pages @pages ||= [ (uprn_questions if form.start_date.year >= 2024), + (Form::Sales::Pages::PropertyUnitType.new(nil, nil, self) if form.start_year_2025_or_later?), Form::Sales::Pages::PropertyNumberOfBedrooms.new(nil, nil, self), Form::Sales::Pages::AboutPriceValueCheck.new("about_price_bedrooms_value_check", nil, self), - Form::Sales::Pages::PropertyUnitType.new(nil, nil, self), + (Form::Sales::Pages::PropertyUnitType.new(nil, nil, self) unless form.start_year_2025_or_later?), Form::Sales::Pages::MonthlyChargesValueCheck.new("monthly_charges_property_type_value_check", nil, self), Form::Sales::Pages::PercentageDiscountValueCheck.new("percentage_discount_proptype_value_check", nil, self), Form::Sales::Pages::PropertyBuildingType.new(nil, nil, self), @@ -21,7 +22,7 @@ class Form::Sales::Subsections::PropertyInformation < ::Form::Subsection end def uprn_questions - if form.start_year_after_2024? + if form.start_year_2024_or_later? [ Form::Sales::Pages::Uprn.new(nil, nil, self), Form::Sales::Pages::UprnConfirmation.new(nil, nil, self), diff --git a/app/models/form/sales/subsections/setup.rb b/app/models/form/sales/subsections/setup.rb index f954e24e6..0c667ebda 100644 --- a/app/models/form/sales/subsections/setup.rb +++ b/app/models/form/sales/subsections/setup.rb @@ -7,23 +7,24 @@ class Form::Sales::Subsections::Setup < ::Form::Subsection def pages @pages ||= [ + Form::Sales::Pages::SaleDate.new(nil, nil, self), Form::Sales::Pages::OwningOrganisation.new(nil, nil, self), Form::Sales::Pages::ManagingOrganisation.new(nil, nil, self), Form::Sales::Pages::CreatedBy.new(nil, nil, self), - Form::Sales::Pages::SaleDate.new(nil, nil, self), Form::Sales::Pages::PurchaserCode.new(nil, nil, self), Form::Sales::Pages::OwnershipScheme.new(nil, nil, self), + (Form::Sales::Pages::Staircase.new(nil, nil, self) if form.start_year_2025_or_later?), Form::Sales::Pages::SharedOwnershipType.new(nil, nil, self), Form::Sales::Pages::DiscountedOwnershipType.new(nil, nil, self), - Form::Sales::Pages::OutrightOwnershipType.new(nil, nil, self), - Form::Sales::Pages::BuyerCompany.new(nil, nil, self), - Form::Sales::Pages::BuyerLive.new(nil, nil, self), + (Form::Sales::Pages::OutrightOwnershipType.new(nil, nil, self) unless form.start_year_2025_or_later?), + (Form::Sales::Pages::BuyerCompany.new(nil, nil, self) unless form.start_year_2025_or_later?), + (Form::Sales::Pages::BuyerLive.new(nil, nil, self) unless form.start_year_2025_or_later?), Form::Sales::Pages::JointPurchase.new(nil, nil, self), Form::Sales::Pages::NumberJointBuyers.new(nil, nil, self), - (Form::Sales::Pages::BuyerInterview.new("buyer_interview_joint_purchase", nil, self, joint_purchase: true) if form.start_year_after_2024?), - (Form::Sales::Pages::BuyerInterview.new("buyer_interview", nil, self, joint_purchase: false) if form.start_year_after_2024?), - (Form::Sales::Pages::PrivacyNotice.new("privacy_notice_joint_purchase", nil, self, joint_purchase: true) if form.start_year_after_2024?), - (Form::Sales::Pages::PrivacyNotice.new("privacy_notice", nil, self, joint_purchase: false) if form.start_year_after_2024?), + (Form::Sales::Pages::BuyerInterview.new("buyer_interview_joint_purchase", nil, self, joint_purchase: true) if form.start_year_2024_or_later?), + (Form::Sales::Pages::BuyerInterview.new("buyer_interview", nil, self, joint_purchase: false) if form.start_year_2024_or_later?), + (Form::Sales::Pages::PrivacyNotice.new("privacy_notice_joint_purchase", nil, self, joint_purchase: true) if form.start_year_2024_or_later?), + (Form::Sales::Pages::PrivacyNotice.new("privacy_notice", nil, self, joint_purchase: false) if form.start_year_2024_or_later?), ].flatten.compact end end diff --git a/app/models/form/sales/subsections/shared_ownership_scheme.rb b/app/models/form/sales/subsections/shared_ownership_scheme.rb index c955929dc..455755e31 100644 --- a/app/models/form/sales/subsections/shared_ownership_scheme.rb +++ b/app/models/form/sales/subsections/shared_ownership_scheme.rb @@ -10,7 +10,7 @@ class Form::Sales::Subsections::SharedOwnershipScheme < ::Form::Subsection @pages ||= [ Form::Sales::Pages::LivingBeforePurchase.new("living_before_purchase_shared_ownership_joint_purchase", nil, self, ownershipsch: 1, joint_purchase: true), Form::Sales::Pages::LivingBeforePurchase.new("living_before_purchase_shared_ownership", nil, self, ownershipsch: 1, joint_purchase: false), - Form::Sales::Pages::Staircase.new(nil, nil, self), + (Form::Sales::Pages::Staircase.new(nil, nil, self) unless form.start_year_2025_or_later?), Form::Sales::Pages::AboutStaircase.new("about_staircasing_joint_purchase", nil, self, joint_purchase: true), Form::Sales::Pages::AboutStaircase.new("about_staircasing_not_joint_purchase", nil, self, joint_purchase: false), Form::Sales::Pages::StaircaseBoughtValueCheck.new(nil, nil, self), @@ -40,11 +40,11 @@ class Form::Sales::Subsections::SharedOwnershipScheme < ::Form::Subsection Form::Sales::Pages::MortgageLength.new("mortgage_length_shared_ownership", nil, self, ownershipsch: 1), Form::Sales::Pages::ExtraBorrowing.new("extra_borrowing_shared_ownership", nil, self, ownershipsch: 1), Form::Sales::Pages::Deposit.new("deposit_shared_ownership", nil, self, ownershipsch: 1, optional: false), - (Form::Sales::Pages::Deposit.new("deposit_shared_ownership_optional", nil, self, ownershipsch: 1, optional: true) if form.start_year_after_2024?), + (Form::Sales::Pages::Deposit.new("deposit_shared_ownership_optional", nil, self, ownershipsch: 1, optional: true) if form.start_year_2024_or_later?), Form::Sales::Pages::DepositValueCheck.new("deposit_joint_purchase_value_check", nil, self, joint_purchase: true), Form::Sales::Pages::DepositValueCheck.new("deposit_value_check", nil, self, joint_purchase: false), Form::Sales::Pages::DepositDiscount.new("deposit_discount", nil, self, optional: false), - (Form::Sales::Pages::DepositDiscount.new("deposit_discount_optional", nil, self, optional: true) if form.start_year_after_2024?), + (Form::Sales::Pages::DepositDiscount.new("deposit_discount_optional", nil, self, optional: true) if form.start_year_2024_or_later?), Form::Sales::Pages::SharedOwnershipDepositValueCheck.new("shared_ownership_deposit_value_check", nil, self), Form::Sales::Pages::MonthlyRent.new(nil, nil, self), Form::Sales::Pages::LeaseholdCharges.new("leasehold_charges_shared_ownership", nil, self, ownershipsch: 1), diff --git a/app/models/lettings_log.rb b/app/models/lettings_log.rb index 7cab576c4..d1ff6f738 100644 --- a/app/models/lettings_log.rb +++ b/app/models/lettings_log.rb @@ -391,7 +391,7 @@ class LettingsLog < Log end def is_beds_inferred? - form.start_year_after_2024? && is_bedsit? + form.start_year_2024_or_later? && is_bedsit? end def is_shared_housing? @@ -508,12 +508,6 @@ class LettingsLog < Log hb == 10 end - # Option 7 has been removed starting from 22/23 - def receives_universal_credit_but_no_housing_benefit? - # 7: Universal Credit (without housing element) - hb == 7 - end - def receives_housing_related_benefits? if collection_start_year <= 2021 receives_housing_benefit_only? || receives_uc_with_housing_element_excl_housing_benefit? || @@ -899,7 +893,7 @@ private def should_process_address_change? return unless uprn_selection || select_best_address_match return unless startdate - return unless form.start_year_after_2024? + return unless form.start_year_2024_or_later? if select_best_address_match address_line1_input.present? && postcode_full_input.present? diff --git a/app/models/sales_log.rb b/app/models/sales_log.rb index aca80ef94..01741fbc5 100644 --- a/app/models/sales_log.rb +++ b/app/models/sales_log.rb @@ -131,7 +131,7 @@ class SalesLog < Log not_required << "proplen" if proplen_optional? not_required << "mortlen" if mortlen_optional? not_required << "frombeds" if frombeds_optional? - not_required << "deposit" if form.start_year_after_2024? && stairowned_100? + not_required << "deposit" if form.start_year_2024_or_later? && stairowned_100? not_required |= %w[address_line2 county postcode_full] if saledate && collection_start_year_for_date(saledate) >= 2023 @@ -396,6 +396,10 @@ class SalesLog < Log proptype == 2 end + def is_beds_inferred? + form.start_year_2025_or_later? && is_bedsit? + end + def shared_ownership_scheme? ownershipsch == 1 end @@ -453,7 +457,7 @@ class SalesLog < Log def should_process_address_change? return unless uprn_selection || select_best_address_match return unless saledate - return unless form.start_year_after_2024? + return unless form.start_year_2024_or_later? if select_best_address_match address_line1_input.present? && postcode_full_input.present? @@ -515,7 +519,7 @@ class SalesLog < Log end def soctenant_is_inferred? - form.start_year_after_2024? + form.start_year_2024_or_later? end def duplicates diff --git a/app/models/user.rb b/app/models/user.rb index 75b5a366b..3d6dbe893 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -19,7 +19,7 @@ class User < ApplicationRecord validates :password, presence: { if: :password_required? } validates :password, length: { within: Devise.password_length, allow_blank: true } validates :password, confirmation: { if: :password_required? } - validates :phone_extension, format: { with: /\A\d+\z/, allow_blank: true, message: I18n.t("validations.numeric.format", field: "") } + validates :phone_extension, format: { with: /\A\d+\z/, allow_blank: true, message: I18n.t("validations.not_number", field: "") } after_validation :send_data_protection_confirmation_reminder, if: :is_dpo_changed? diff --git a/app/models/validations/financial_validations.rb b/app/models/validations/financial_validations.rb index 724fa9b6e..19209f2d8 100644 --- a/app/models/validations/financial_validations.rb +++ b/app/models/validations/financial_validations.rb @@ -6,8 +6,8 @@ module Validations::FinancialValidations # or 'validate_' to run on submit as well def validate_outstanding_rent_amount(record) if !record.has_housing_benefit_rent_shortfall? && record.tshortfall.present? - record.errors.add :tshortfall, :no_outstanding_charges, message: I18n.t("validations.financial.tshortfall.outstanding_amount_not_expected") - record.errors.add :hbrentshortfall, :no_outstanding_charges, message: I18n.t("validations.financial.hbrentshortfall.outstanding_amount_not_expected") + record.errors.add :tshortfall, :no_outstanding_charges, message: I18n.t("validations.lettings.financial.tshortfall.outstanding_amount_not_expected") + record.errors.add :hbrentshortfall, :no_outstanding_charges, message: I18n.t("validations.lettings.financial.hbrentshortfall.outstanding_amount_not_expected") end end @@ -19,7 +19,7 @@ module Validations::FinancialValidations relationship = record["relat#{n}"] is_partner_or_main = relationship == "P" || (relationship.nil? && economic_status.present?) if is_employed && is_partner_or_main && record.benefits&.zero? - record.errors.add :benefits, I18n.t("validations.financial.benefits.part_or_full_time") + record.errors.add :benefits, I18n.t("validations.lettings.financial.benefits.part_or_full_time") end end end @@ -32,25 +32,25 @@ module Validations::FinancialValidations record.errors.add( :earnings, :over_hard_max, - message: I18n.t("validations.financial.earnings.over_hard_max", hard_max:), + message: I18n.t("validations.lettings.financial.earnings.over_hard_max", hard_max:), ) record.errors.add( :hhmemb, :over_hard_max, - message: I18n.t("validations.financial.hhmemb.earnings.over_hard_max", earnings: format_as_currency(record.earnings), frequency:), + message: I18n.t("validations.lettings.financial.hhmemb.earnings_over_hard_max", earnings: format_as_currency(record.earnings), frequency:), ) (1..record.hhmemb).each do |n| record.errors.add( "ecstat#{n}", :over_hard_max, - message: I18n.t("validations.financial.ecstat.over_hard_max", earnings: format_as_currency(record.earnings), frequency:), + message: I18n.t("validations.lettings.financial.ecstat.earnings_over_hard_max", earnings: format_as_currency(record.earnings), frequency:), ) next unless record["ecstat#{n}"] == 9 record.errors.add( "age#{n}", :over_hard_max, - message: I18n.t("validations.financial.age.earnings_over_hard_max", earnings: format_as_currency(record.earnings), frequency:), + message: I18n.t("validations.lettings.financial.age.earnings_over_hard_max", earnings: format_as_currency(record.earnings), frequency:), ) end end @@ -61,18 +61,18 @@ module Validations::FinancialValidations record.errors.add( :earnings, :under_hard_min, - message: I18n.t("validations.financial.earnings.under_hard_min", hard_min:), + message: I18n.t("validations.lettings.financial.earnings.under_hard_min", hard_min:), ) record.errors.add( :hhmemb, :under_hard_min, - message: I18n.t("validations.financial.hhmemb.earnings.under_hard_min", earnings: format_as_currency(record.earnings), frequency:), + message: I18n.t("validations.lettings.financial.hhmemb.earnings_under_hard_min", earnings: format_as_currency(record.earnings), frequency:), ) (1..record.hhmemb).each do |n| record.errors.add( "ecstat#{n}", :under_hard_min, - message: I18n.t("validations.financial.ecstat.under_hard_min", earnings: format_as_currency(record.earnings), frequency:), + message: I18n.t("validations.lettings.financial.ecstat.earnings_under_hard_min", earnings: format_as_currency(record.earnings), frequency:), ) # N.B. It is not possible for a change to an age field to increase the hard min end @@ -80,69 +80,61 @@ module Validations::FinancialValidations end if record.earnings.present? && record.incfreq.blank? - record.errors.add :incfreq, I18n.t("validations.financial.earnings.freq_missing") - record.errors.add :earnings, I18n.t("validations.financial.earnings.freq_missing") + record.errors.add :incfreq, I18n.t("validations.lettings.financial.incfreq.incfreq_missing") + record.errors.add :earnings, I18n.t("validations.lettings.financial.earnings.incfreq_missing") end if record.incfreq.present? && record.earnings.blank? - record.errors.add :earnings, I18n.t("validations.financial.earnings.earnings_missing") - record.errors.add :incfreq, I18n.t("validations.financial.earnings.earnings_missing") + record.errors.add :earnings, I18n.t("validations.lettings.financial.earnings.earnings_missing") + record.errors.add :incfreq, I18n.t("validations.lettings.financial.incfreq.earnings_missing") end end def validate_negative_currency(record) - t = %w[earnings brent scharge pscharge supcharg] - t.each do |x| - if record[x].present? && record[x].negative? - record.errors.add x.to_sym, I18n.t("validations.financial.negative_currency") + fields = %w[earnings brent scharge pscharge supcharg] + fields.each do |field| + if record[field].present? && record[field].negative? + record.errors.add field.to_sym, I18n.t("validations.lettings.financial.#{field}.negative_currency") end end end def validate_tshortfall(record) if record.has_housing_benefit_rent_shortfall? && no_known_benefits?(record) - record.errors.add :tshortfall, I18n.t("validations.financial.hbrentshortfall.outstanding_no_benefits") + record.errors.add :tshortfall, I18n.t("validations.lettings.financial.tshortfall.outstanding_no_benefits") end end def no_known_benefits?(record) return true unless record.collection_start_year - if record.collection_start_year <= 2021 - record.benefits_unknown? || - record.receives_no_benefits? || - record.receives_universal_credit_but_no_housing_benefit? - else - record.benefits_unknown? || - record.receives_no_benefits? || - record.tenant_refuses_to_say_benefits? - end + record.benefits_unknown? || record.receives_no_benefits? || record.tenant_refuses_to_say_benefits? end def validate_rent_amount(record) if record.wtshortfall if record.is_supported_housing? && record.wchchrg && (record.wtshortfall > record.wchchrg) - record.errors.add :tshortfall, message: I18n.t("validations.financial.tshortfall.more_than_carehome_charge") - record.errors.add :chcharge, I18n.t("validations.financial.carehome.less_than_shortfall") + record.errors.add :tshortfall, message: I18n.t("validations.lettings.financial.tshortfall.more_than_carehome_charge") + record.errors.add :chcharge, I18n.t("validations.lettings.financial.chcharge.less_than_shortfall") end if record.wtcharge && (record.wtshortfall > record.wtcharge) - record.errors.add :tshortfall, :more_than_rent, message: I18n.t("validations.financial.tshortfall.more_than_total_charge") - record.errors.add :tcharge, I18n.t("validations.financial.tcharge.less_than_shortfall") + record.errors.add :tshortfall, :more_than_rent, message: I18n.t("validations.lettings.financial.tshortfall.more_than_total_charge") + record.errors.add :tcharge, I18n.t("validations.lettings.financial.tcharge.less_than_shortfall") elsif record.wtshortfall < 0.01 - record.errors.add :tshortfall, :must_be_positive, message: I18n.t("validations.financial.tshortfall.must_be_positive") + record.errors.add :tshortfall, :must_be_positive, message: I18n.t("validations.lettings.financial.tshortfall.must_be_positive") end end if record.tcharge.present? && weekly_value_in_range(record, "tcharge", 0, 9.99) - record.errors.add :tcharge, :under_10, message: I18n.t("validations.financial.tcharge.under_10") + record.errors.add :tcharge, :under_10, message: I18n.t("validations.lettings.financial.tcharge.under_10") end answered_questions = [record.tcharge, record.chcharge].concat(record.household_charge && record.household_charge == 1 ? [record.household_charge] : []) if answered_questions.count(&:present?) > 1 - record.errors.add :tcharge, :complete_1_of_3, message: I18n.t("validations.financial.charges.complete_1_of_3") if record.tcharge.present? - record.errors.add :chcharge, I18n.t("validations.financial.charges.complete_1_of_3") if record.chcharge.present? - record.errors.add :household_charge, I18n.t("validations.financial.charges.complete_1_of_3") if record.household_charge.present? + record.errors.add :tcharge, :complete_1_of_3, message: I18n.t("validations.lettings.financial.tcharge.complete_1_of_3") if record.tcharge.present? + record.errors.add :chcharge, I18n.t("validations.lettings.financial.chcharge.complete_1_of_3") if record.chcharge.present? + record.errors.add :household_charge, I18n.t("validations.lettings.financial.household_charge.complete_1_of_3") if record.household_charge.present? end validate_charges(record) @@ -154,12 +146,12 @@ module Validations::FinancialValidations unless record.managing_organisation.rent_periods.include? record.period record.errors.add :period, :wrong_rent_period, message: I18n.t( - "validations.financial.rent_period.invalid_for_org.period", + "validations.lettings.financial.period.invalid_period_for_org", org_name: record.managing_organisation.name, rent_period: record.form.get_question("period", record).label_from_value(record.period).downcase, ) record.errors.add :managing_organisation_id, :skip_bu_error, message: I18n.t( - "validations.financial.rent_period.invalid_for_org.managing_org", + "validations.lettings.financial.managing_organisation_id.invalid_period_for_org", org_name: record.managing_organisation.name, rent_period: record.form.get_question("period", record).label_from_value(record.period).downcase, ) @@ -169,18 +161,12 @@ module Validations::FinancialValidations def validate_care_home_charges(record) if record.is_carehome? period = record.form.get_question("period", record).label_from_value(record.period).downcase - # NOTE: This is a temporary change to allow `ccharge` values despite `is_carehome` being true. This value - # is going to be moved to a soft validation in CLDC-2074, so we can safely do this. - if record.chcharge.blank? - # record.errors.add :is_carehome, I18n.t("validations.financial.carehome.not_provided", period:) - # record.errors.add :chcharge, I18n.t("validations.financial.carehome.not_provided", period:) - elsif !weekly_value_in_range(record, "chcharge", 10, 5000) + if record.chcharge.present? && !weekly_value_in_range(record, "chcharge", 10, 5000) max_chcharge = record.weekly_to_value_per_period(5000) min_chcharge = record.weekly_to_value_per_period(10) - message = I18n.t("validations.financial.carehome.out_of_range", period:, min_chcharge:, max_chcharge:) - record.errors.add :period, message - record.errors.add :chcharge, :out_of_range, message: + record.errors.add :period, I18n.t("validations.lettings.financial.period.chcharge_out_of_range", period:, min_chcharge:, max_chcharge:) + record.errors.add :chcharge, :out_of_range, message: I18n.t("validations.lettings.financial.chcharge.out_of_range", period:, min_chcharge:, max_chcharge:) end end end @@ -202,8 +188,8 @@ private provider_type_label = PROVIDER_TYPE[provider_type].to_s.humanize(capitalize: false) maximum_per_period = record.weekly_to_value_per_period(maximum_per_week) - record.errors.add charge, :outside_the_range, message: I18n.t("validations.financial.rent.out_of_range", charge_name:, maximum_per_period:, frequency:, letting_type:, provider_type: provider_type_label) - record.errors.add :period, :outside_the_range, message: I18n.t("validations.financial.rent.out_of_range", charge_name:, maximum_per_period:, frequency:, letting_type:, provider_type: provider_type_label) + record.errors.add charge, :outside_the_range, message: I18n.t("validations.lettings.financial.#{charge}.rent_out_of_range", charge_name:, maximum_per_period:, frequency:, letting_type:, provider_type: provider_type_label) + record.errors.add :period, :outside_the_range, message: I18n.t("validations.lettings.financial.period.rent_out_of_range", charge_name:, maximum_per_period:, frequency:, letting_type:, provider_type: provider_type_label) end end @@ -225,29 +211,29 @@ private if rent_range.present? && !weekly_value_in_range(record, "brent", rent_range.hard_min, rent_range.hard_max) && record.brent.present? && record.period.present? if record.weekly_value(record["brent"]) < rent_range.hard_min - record.errors.add :brent, :below_hard_min, message: I18n.t("validations.financial.brent.below_hard_min") - record.errors.add :beds, I18n.t("validations.financial.brent.beds.below_hard_min") - record.errors.add :uprn, I18n.t("validations.financial.brent.uprn.below_hard_min") - record.errors.add :la, I18n.t("validations.financial.brent.la.below_hard_min") - record.errors.add :postcode_known, I18n.t("validations.financial.brent.postcode_known.below_hard_min") - record.errors.add :scheme_id, I18n.t("validations.financial.brent.scheme_id.below_hard_min") - record.errors.add :location_id, I18n.t("validations.financial.brent.location_id.below_hard_min") - record.errors.add :rent_type, I18n.t("validations.financial.brent.rent_type.below_hard_min") - record.errors.add :needstype, I18n.t("validations.financial.brent.needstype.below_hard_min") - record.errors.add :period, I18n.t("validations.financial.brent.period.below_hard_min") + record.errors.add :brent, :below_hard_min, message: I18n.t("validations.lettings.financial.brent.below_hard_min") + record.errors.add :beds, I18n.t("validations.lettings.financial.beds.rent_below_hard_min") + record.errors.add :uprn, I18n.t("validations.lettings.financial.uprn.rent_below_hard_min") + record.errors.add :la, I18n.t("validations.lettings.financial.la.rent_below_hard_min") + record.errors.add :postcode_known, I18n.t("validations.lettings.financial.postcode_known.rent_below_hard_min") + record.errors.add :scheme_id, I18n.t("validations.lettings.financial.scheme_id.rent_below_hard_min") + record.errors.add :location_id, I18n.t("validations.lettings.financial.location_id.rent_below_hard_min") + record.errors.add :rent_type, I18n.t("validations.lettings.financial.rent_type.rent_below_hard_min") + record.errors.add :needstype, I18n.t("validations.lettings.financial.needstype.rent_below_hard_min") + record.errors.add :period, I18n.t("validations.lettings.financial.period.rent_below_hard_min") end if record.weekly_value(record["brent"]) > rent_range.hard_max - record.errors.add :brent, :over_hard_max, message: I18n.t("validations.financial.brent.above_hard_max") - record.errors.add :beds, I18n.t("validations.financial.brent.beds.above_hard_max") - record.errors.add :uprn, I18n.t("validations.financial.brent.uprn.above_hard_max") - record.errors.add :la, I18n.t("validations.financial.brent.la.above_hard_max") - record.errors.add :postcode_known, I18n.t("validations.financial.brent.postcode_known.above_hard_max") - record.errors.add :scheme_id, I18n.t("validations.financial.brent.scheme_id.above_hard_max") - record.errors.add :location_id, I18n.t("validations.financial.brent.location_id.above_hard_max") - record.errors.add :rent_type, I18n.t("validations.financial.brent.rent_type.above_hard_max") - record.errors.add :needstype, I18n.t("validations.financial.brent.needstype.above_hard_max") - record.errors.add :period, I18n.t("validations.financial.brent.period.above_hard_max") + record.errors.add :brent, :over_hard_max, message: I18n.t("validations.lettings.financial.brent.above_hard_max") + record.errors.add :beds, I18n.t("validations.lettings.financial.beds.rent_above_hard_max") + record.errors.add :uprn, I18n.t("validations.lettings.financial.uprn.rent_above_hard_max") + record.errors.add :la, I18n.t("validations.lettings.financial.la.rent_above_hard_max") + record.errors.add :postcode_known, I18n.t("validations.lettings.financial.postcode_known.rent_above_hard_max") + record.errors.add :scheme_id, I18n.t("validations.lettings.financial.scheme_id.rent_above_hard_max") + record.errors.add :location_id, I18n.t("validations.lettings.financial.location_id.rent_above_hard_max") + record.errors.add :rent_type, I18n.t("validations.lettings.financial.rent_type.rent_above_hard_max") + record.errors.add :needstype, I18n.t("validations.lettings.financial.needstype.rent_above_hard_max") + record.errors.add :period, I18n.t("validations.lettings.financial.period.rent_above_hard_max") end end end diff --git a/app/models/validations/household_validations.rb b/app/models/validations/household_validations.rb index 8fe940ae5..703e9f394 100644 --- a/app/models/validations/household_validations.rb +++ b/app/models/validations/household_validations.rb @@ -35,7 +35,7 @@ module Validations::HouseholdValidations record.errors.add :reason, I18n.t("validations.household.reason.not_internal_transfer") end - return unless record.form.start_year_after_2024? + return unless record.form.start_year_2024_or_later? if record.reason == 20 && PHRASES_INDICATING_HOMELESSNESS_REGEX.match?(record.reasonother) record.errors.add :reason, I18n.t("validations.household.reason.other_not_settled") @@ -52,11 +52,18 @@ module Validations::HouseholdValidations end def validate_partner_count(record) - shared_validate_partner_count(record, 8) + return if record.form.start_year_2024_or_later? + + partner_numbers = (2..8).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.lettings.household.relat.one_partner") + end + end end def validate_person_1_economic(record) - return unless record.age1 && record.ecstat1 && !record.form.start_year_after_2024? + return unless record.age1 && record.ecstat1 && !record.form.start_year_2024_or_later? if record.age1 < 16 && !economic_status_is_child_other_or_refused?(record.ecstat1) record.errors.add "ecstat1", I18n.t("validations.household.ecstat.child_under_16", person_num: 1) @@ -74,7 +81,7 @@ module Validations::HouseholdValidations economic_status = record.public_send("ecstat#{person_num}") next unless age && economic_status - if age < 16 && !economic_status_is_child_other_or_refused?(economic_status) && !record.form.start_year_after_2024? + if age < 16 && !economic_status_is_child_other_or_refused?(economic_status) && !record.form.start_year_2024_or_later? 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:) end @@ -86,7 +93,7 @@ module Validations::HouseholdValidations end def validate_person_age_matches_relationship(record) - return unless record.startdate && !record.form.start_year_after_2024? + return unless record.startdate && !record.form.start_year_2024_or_later? (2..8).each do |person_num| age = record.public_send("age#{person_num}") @@ -101,7 +108,7 @@ module Validations::HouseholdValidations end def validate_person_age_and_relationship_matches_economic_status(record) - return unless record.startdate && !record.form.start_year_after_2024? + return unless record.startdate && !record.form.start_year_2024_or_later? (2..8).each do |person_num| age = record.public_send("age#{person_num}") diff --git a/app/models/validations/property_validations.rb b/app/models/validations/property_validations.rb index 52afecb49..1864adc5c 100644 --- a/app/models/validations/property_validations.rb +++ b/app/models/validations/property_validations.rb @@ -35,7 +35,7 @@ module Validations::PropertyValidations def validate_shared_housing_rooms(record) return unless record.unittype_gn - if record.is_bedsit? && record.beds != 1 && record.beds.present? && !record.form.start_year_after_2024? + if record.is_bedsit? && record.beds != 1 && record.beds.present? && !record.form.start_year_2024_or_later? record.errors.add :unittype_gn, I18n.t("validations.property.unittype_gn.one_bedroom_bedsit") record.errors.add :beds, I18n.t("validations.property.unittype_gn.one_bedroom_bedsit") end @@ -57,4 +57,12 @@ module Validations::PropertyValidations record.errors.add :uprn, I18n.t("validations.property.uprn.invalid") end + + def validate_property_postcode(record) + postcode = record.postcode_full + if record.postcode_known? && (postcode.blank? || !postcode.match(POSTCODE_REGEXP)) + error_message = I18n.t("validations.lettings.property_information.postcode_full.invalid") + record.errors.add :postcode_full, :wrong_format, message: error_message + end + end end diff --git a/app/models/validations/sales/financial_validations.rb b/app/models/validations/sales/financial_validations.rb index b05fbc48f..1d2ef3d6f 100644 --- a/app/models/validations/sales/financial_validations.rb +++ b/app/models/validations/sales/financial_validations.rb @@ -55,7 +55,7 @@ module Validations::Sales::FinancialValidations def validate_percentage_bought_not_equal_percentage_owned(record) return unless record.stairbought && record.stairowned - return unless record.saledate && record.form.start_year_after_2024? + return unless record.saledate && record.form.start_year_2024_or_later? if record.stairbought == record.stairowned record.errors.add :stairbought, I18n.t("validations.sales.financial.stairbought.percentage_bought_equal_percentage_owned", stairbought: sprintf("%g", record.stairbought), stairowned: sprintf("%g", record.stairowned)) @@ -106,7 +106,7 @@ module Validations::Sales::FinancialValidations def validate_equity_less_than_staircase_difference(record) return unless record.equity && record.stairbought && record.stairowned - return unless record.saledate && record.form.start_year_after_2024? + return unless record.saledate && record.form.start_year_2024_or_later? if record.equity > record.stairowned - record.stairbought formatted_equity = sprintf("%g", record.equity) diff --git a/app/models/validations/sales/household_validations.rb b/app/models/validations/sales/household_validations.rb index fb1ea65c2..175474098 100644 --- a/app/models/validations/sales/household_validations.rb +++ b/app/models/validations/sales/household_validations.rb @@ -2,7 +2,14 @@ module Validations::Sales::HouseholdValidations include Validations::SharedValidations def validate_partner_count(record) - shared_validate_partner_count(record, 6) + return if record.form.start_year_2024_or_later? + + partner_numbers = (2..6).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.sales.household.relat.one_partner") + end + end end def validate_buyers_living_in_property(record) @@ -16,7 +23,7 @@ module Validations::Sales::HouseholdValidations end def validate_buyer1_previous_tenure(record) - return unless record.saledate && record.form.start_year_after_2024? + return unless record.saledate && record.form.start_year_2024_or_later? return unless record.discounted_ownership_sale? && record.prevten if [3, 4, 5, 6, 7, 9, 0].include?(record.prevten) @@ -26,7 +33,7 @@ module Validations::Sales::HouseholdValidations end def validate_person_age_matches_relationship(record) - return unless record.saledate && !record.form.start_year_after_2024? + return unless record.saledate && !record.form.start_year_2024_or_later? (2..6).each do |person_num| age = record.public_send("age#{person_num}") @@ -44,7 +51,7 @@ module Validations::Sales::HouseholdValidations end def validate_person_age_and_relationship_matches_economic_status(record) - return unless record.saledate && !record.form.start_year_after_2024? + return unless record.saledate && !record.form.start_year_2024_or_later? (2..6).each do |person_num| age = record.public_send("age#{person_num}") @@ -77,7 +84,7 @@ module Validations::Sales::HouseholdValidations economic_status = record.public_send("ecstat#{person_num}") next unless age && economic_status - if age < 16 && !economic_status_is_child_other_or_refused?(economic_status) && !record.form.start_year_after_2024? + if age < 16 && !economic_status_is_child_other_or_refused?(economic_status) && !record.form.start_year_2024_or_later? 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 @@ -89,7 +96,7 @@ module Validations::Sales::HouseholdValidations end def validate_child_12_years_younger(record) - return unless record.saledate && !record.form.start_year_after_2024? + return unless record.saledate && !record.form.start_year_2024_or_later? (2..6).each do |person_num| buyer_1_age = record.public_send("age1") @@ -106,7 +113,7 @@ module Validations::Sales::HouseholdValidations end def validate_buyer_not_child(record) - return unless record.saledate && record.form.start_year_after_2024? + return unless record.saledate && record.form.start_year_2024_or_later? 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? diff --git a/app/models/validations/sales/property_validations.rb b/app/models/validations/sales/property_validations.rb index 59d616c9a..5cf70ed8d 100644 --- a/app/models/validations/sales/property_validations.rb +++ b/app/models/validations/sales/property_validations.rb @@ -1,6 +1,6 @@ module Validations::Sales::PropertyValidations def validate_postcodes_match_if_discounted_ownership(record) - return unless record.saledate && !record.form.start_year_after_2024? + return unless record.saledate && !record.form.start_year_2024_or_later? return unless record.ppostcode_full.present? && record.postcode_full.present? if record.discounted_ownership_sale? && record.ppostcode_full != record.postcode_full @@ -28,4 +28,12 @@ module Validations::Sales::PropertyValidations record.errors.add :uprn, I18n.t("validations.sales.property_information.uprn.invalid") end + + def validate_property_postcode(record) + postcode = record.postcode_full + if record.postcode_known? && (postcode.blank? || !postcode.match(POSTCODE_REGEXP)) + error_message = I18n.t("validations.sales.property_information.postcode_full.invalid") + record.errors.add :postcode_full, :wrong_format, message: error_message + end + end end diff --git a/app/models/validations/sales/sale_information_validations.rb b/app/models/validations/sales/sale_information_validations.rb index 700867e66..3c5e3f2b9 100644 --- a/app/models/validations/sales/sale_information_validations.rb +++ b/app/models/validations/sales/sale_information_validations.rb @@ -12,7 +12,7 @@ module Validations::Sales::SaleInformationValidations 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? + if record.saledate - record.hodate >= 3.years && record.form.start_year_2024_or_later? 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 @@ -42,7 +42,7 @@ module Validations::Sales::SaleInformationValidations end def validate_discounted_ownership_value(record) - return unless record.saledate && record.form.start_year_after_2024? + return unless record.saledate && record.form.start_year_2024_or_later? return unless record.value && record.deposit && record.ownershipsch return unless record.mortgage || record.mortgageused == 2 || record.mortgageused == 3 return unless record.discount || record.grant || record.type == 29 @@ -65,7 +65,7 @@ module Validations::Sales::SaleInformationValidations end def validate_outright_sale_value_matches_mortgage_plus_deposit(record) - return unless record.saledate && record.form.start_year_after_2024? + return unless record.saledate && record.form.start_year_2024_or_later? return unless record.outright_sale? return unless record.mortgage_used? && record.mortgage return unless record.deposit && record.value @@ -96,7 +96,7 @@ module Validations::Sales::SaleInformationValidations end def validate_grant_amount(record) - return unless record.saledate && record.form.start_year_after_2024? + return unless record.saledate && record.form.start_year_2024_or_later? return unless record.grant && (record.type == 8 || record.type == 21) unless record.grant.between?(9_000, 16_000) @@ -106,7 +106,7 @@ module Validations::Sales::SaleInformationValidations def validate_stairbought(record) return unless record.stairbought && record.type - return unless record.saledate && record.form.start_year_after_2024? + return unless record.saledate && record.form.start_year_2024_or_later? max_stairbought = case record.type when 30, 16, 28, 31, 32 @@ -124,7 +124,7 @@ module Validations::Sales::SaleInformationValidations end def validate_discount_and_value(record) - return unless record.saledate && record.form.start_year_after_2024? + return unless record.saledate && record.form.start_year_2024_or_later? return unless record.discount && record.value && record.la if record.london_property? && record.discount_value > 136_400 @@ -139,7 +139,7 @@ module Validations::Sales::SaleInformationValidations end def validate_non_staircasing_mortgage(record) - return unless record.saledate && record.form.start_year_after_2024? + return unless record.saledate && record.form.start_year_2024_or_later? return unless record.value && record.deposit && record.equity return unless record.shared_ownership_scheme? && record.type && record.mortgageused && record.is_not_staircasing? @@ -151,7 +151,7 @@ module Validations::Sales::SaleInformationValidations end def validate_staircasing_mortgage(record) - return unless record.saledate && record.form.start_year_after_2024? + return unless record.saledate && record.form.start_year_2024_or_later? return unless record.value && record.deposit && record.stairbought return unless record.shared_ownership_scheme? && record.type && record.mortgageused && record.is_staircase? @@ -334,7 +334,7 @@ module Validations::Sales::SaleInformationValidations if record.discounted_ownership_sale? record.errors.add :mortgageused, I18n.t("validations.invalid_option", question: "was a mortgage used for the purchase of this property?") end - if record.outright_sale? && record.saledate && !record.form.start_year_after_2024? + if record.outright_sale? && record.saledate && !record.form.start_year_2024_or_later? 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.sales.sale_information.saledate.mortgage_used_year") end diff --git a/app/models/validations/sales/setup_validations.rb b/app/models/validations/sales/setup_validations.rb index 6fdc2f1a3..75e79f15a 100644 --- a/app/models/validations/sales/setup_validations.rb +++ b/app/models/validations/sales/setup_validations.rb @@ -58,6 +58,14 @@ module Validations::Sales::SetupValidations end end + def validate_owning_organisation_data_sharing_agremeent_signed(record) + return if record.skip_dpo_validation + + if record.owning_organisation_id_changed? && record.owning_organisation.present? && !record.owning_organisation.data_protection_confirmed? + record.errors.add :owning_organisation_id, I18n.t("validations.sales.setup.owning_organisation.data_sharing_agreement_not_signed") + end + end + private def active_collection_start_date diff --git a/app/models/validations/sales/soft_validations.rb b/app/models/validations/sales/soft_validations.rb index fccd9bf83..fe05ec13c 100644 --- a/app/models/validations/sales/soft_validations.rb +++ b/app/models/validations/sales/soft_validations.rb @@ -68,7 +68,7 @@ module Validations::Sales::SoftValidations end def extra_borrowing_expected_but_not_reported? - return unless saledate && !form.start_year_after_2024? + return unless saledate && !form.start_year_2024_or_later? return unless extrabor && mortgage && deposit && value && discount extrabor != 1 && mortgage + deposit > value - value * discount / 100 @@ -118,7 +118,7 @@ module Validations::Sales::SoftValidations def grant_outside_common_range? return unless grant && type && saledate - return if form.start_year_after_2024? && (type == 21 || type == 8) + return if form.start_year_2024_or_later? && (type == 21 || type == 8) !grant.between?(9_000, 16_000) end diff --git a/app/models/validations/setup_validations.rb b/app/models/validations/setup_validations.rb index d8e5dbf93..8d1884fc2 100644 --- a/app/models/validations/setup_validations.rb +++ b/app/models/validations/setup_validations.rb @@ -72,17 +72,15 @@ module Validations::SetupValidations end end - def validate_scheme_has_confirmed_locations_validation(record) + def validate_scheme(record) return unless record.scheme - unless record.scheme.locations.confirmed.any? - record.errors.add :scheme_id, :no_completed_locations, message: I18n.t("validations.lettings.setup.scheme.no_completed_locations") + if record.scheme.status == :incomplete + record.errors.add :scheme_id, :incomplete, message: I18n.t("validations.lettings.setup.scheme.incomplete") end - end - def validate_scheme(record) - if record.scheme&.status == :incomplete - record.errors.add :scheme_id, :incomplete, message: I18n.t("validations.lettings.setup.scheme.incomplete") + if record.scheme.locations.nil? || (record.scheme.locations.present? && record.scheme.locations.confirmed.none?) + record.errors.add :scheme_id, :no_completed_locations, message: I18n.t("validations.lettings.setup.scheme.no_completed_locations") end scheme_during_startdate_validation(record) @@ -98,6 +96,35 @@ module Validations::SetupValidations end end + def location_during_startdate_validation(record) + location_inactive_status = inactive_status(record.startdate, record.location) + + if location_inactive_status.present? + date, scope, deactivation_date = location_inactive_status.values_at(:date, :scope, :deactivation_date) + record.errors.add :startdate, :not_active, message: I18n.t("validations.lettings.setup.startdate.location.#{scope}.startdate", postcode: record.location.postcode, date:, deactivation_date:) + record.errors.add :location_id, :not_active, message: I18n.t("validations.lettings.setup.startdate.location.#{scope}.location_id", postcode: record.location.postcode, date:, deactivation_date:) + record.errors.add :scheme_id, :not_active, message: I18n.t("validations.lettings.setup.startdate.location.#{scope}.location_id", postcode: record.location.postcode, date:, deactivation_date:) + end + end + + def scheme_during_startdate_validation(record) + scheme_inactive_status = inactive_status(record.startdate, record.scheme) + + if scheme_inactive_status.present? + date, scope, deactivation_date = scheme_inactive_status.values_at(:date, :scope, :deactivation_date) + record.errors.add :startdate, I18n.t("validations.lettings.setup.startdate.scheme.#{scope}.startdate", name: record.scheme.service_name, date:, deactivation_date:) + record.errors.add :scheme_id, I18n.t("validations.lettings.setup.startdate.scheme.#{scope}.scheme_id", name: record.scheme.service_name, date:, deactivation_date:) + end + end + + def tenancy_startdate_with_scheme_locations(record) + return if record.scheme.blank? || record.startdate.blank? + return if record.scheme.has_active_locations_on_date?(record.startdate) + + record.errors.add :startdate, I18n.t("validations.lettings.setup.startdate.scheme.locations_inactive.startdate", name: record.scheme.service_name) + record.errors.add :scheme_id, I18n.t("validations.lettings.setup.startdate.scheme.locations_inactive.scheme_id", name: record.scheme.service_name) + end + def validate_managing_organisation_data_sharing_agremeent_signed(record) return if record.skip_dpo_validation @@ -106,6 +133,14 @@ module Validations::SetupValidations end end + def validate_owning_organisation_data_sharing_agremeent_signed(record) + return if record.skip_dpo_validation + + if record.owning_organisation_id_changed? && record.owning_organisation.present? && !record.owning_organisation.data_protection_confirmed? + record.errors.add :owning_organisation_id, I18n.t("validations.lettings.setup.owning_organisation.data_sharing_agreement_not_signed") + end + end + private def active_collection_start_date diff --git a/app/models/validations/shared_validations.rb b/app/models/validations/shared_validations.rb index a2ae916c1..da79599ee 100644 --- a/app/models/validations/shared_validations.rb +++ b/app/models/validations/shared_validations.rb @@ -7,12 +7,12 @@ module Validations::SharedValidations main_field_label = main_label || main_field.to_s.humanize(capitalize: false) other_field_label = other_label || other_field.to_s.humanize(capitalize: false) if record[main_field] == value_other && record[other_field].blank? - record.errors.add main_field.to_sym, I18n.t("validations.other_field_missing", main_field_label:, other_field_label:) - record.errors.add other_field.to_sym, I18n.t("validations.other_field_missing", main_field_label:, other_field_label:) + record.errors.add main_field.to_sym, I18n.t("validations.shared.other_field_missing", main_field_label:, other_field_label:) + record.errors.add other_field.to_sym, I18n.t("validations.shared.other_field_missing", main_field_label:, other_field_label:) end if record[main_field] != value_other && record[other_field].present? - record.errors.add other_field.to_sym, I18n.t("validations.other_field_not_required", main_field_label:, other_field_label:) + record.errors.add other_field.to_sym, I18n.t("validations.shared.other_field_not_required", main_field_label:, other_field_label:) end end @@ -22,7 +22,7 @@ module Validations::SharedValidations next if record.send("#{question.id}_before_type_cast").to_s.match?(/\A\d+(\.\d+)?\z/) field = question.check_answer_label || question.id - record.errors.add question.id.to_sym, I18n.t("validations.numeric.format", field:) + record.errors.add question.id.to_sym, I18n.t("validations.shared.numeric.format", field:) end end @@ -55,46 +55,17 @@ module Validations::SharedValidations incorrect_accuracy = (value.to_d * 100) % (question.step * 100) != 0 if question.step < 1 && incorrect_accuracy - record.errors.add question.id.to_sym, I18n.t("validations.numeric.nearest_hundredth", field:) + record.errors.add question.id.to_sym, I18n.t("validations.shared.numeric.nearest_hundredth", field:) elsif incorrect_accuracy || value.to_d != value.to_i # if the user enters a value in exponent notation (eg '4e1') the to_i method does not convert this to the correct value field = question.check_answer_label || question.id case question.step - when 1 then record.errors.add question.id.to_sym, :not_integer, message: I18n.t("validations.numeric.whole_number", field:) - when 10 then record.errors.add question.id.to_sym, I18n.t("validations.numeric.nearest_ten", field:) + when 1 then record.errors.add question.id.to_sym, :not_integer, message: I18n.t("validations.shared.numeric.whole_number", field:) + when 10 then record.errors.add question.id.to_sym, I18n.t("validations.shared.numeric.nearest_ten", field:) end end end end - def validate_property_postcode(record) - postcode = record.postcode_full - if record.postcode_known? && (postcode.blank? || !postcode.match(POSTCODE_REGEXP)) - error_message = I18n.t("validations.postcode") - record.errors.add :postcode_full, :wrong_format, message: error_message - end - end - - def location_during_startdate_validation(record) - location_inactive_status = inactive_status(record.startdate, record.location) - - if location_inactive_status.present? - date, scope, deactivation_date = location_inactive_status.values_at(:date, :scope, :deactivation_date) - record.errors.add :startdate, :not_active, message: I18n.t("validations.setup.startdate.location.#{scope}.startdate", postcode: record.location.postcode, date:, deactivation_date:) - record.errors.add :location_id, :not_active, message: I18n.t("validations.setup.startdate.location.#{scope}.location_id", postcode: record.location.postcode, date:, deactivation_date:) - record.errors.add :scheme_id, :not_active, message: I18n.t("validations.setup.startdate.location.#{scope}.location_id", postcode: record.location.postcode, date:, deactivation_date:) - end - end - - def scheme_during_startdate_validation(record) - scheme_inactive_status = inactive_status(record.startdate, record.scheme) - - if scheme_inactive_status.present? - date, scope, deactivation_date = scheme_inactive_status.values_at(:date, :scope, :deactivation_date) - record.errors.add :startdate, I18n.t("validations.setup.startdate.scheme.#{scope}.startdate", name: record.scheme.service_name, date:, deactivation_date:) - record.errors.add :scheme_id, I18n.t("validations.setup.startdate.scheme.#{scope}.scheme_id", name: record.scheme.service_name, date:, deactivation_date:) - end - end - def inactive_status(date, resource) return if date.blank? || resource.blank? @@ -117,46 +88,15 @@ module Validations::SharedValidations { scope: status, date: date&.to_formatted_s(:govuk_date), deactivation_date: closest_reactivation&.deactivation_date&.to_formatted_s(:govuk_date) } end - def tenancy_startdate_with_scheme_locations(record) - return if record.scheme.blank? || record.startdate.blank? - return if record.scheme.has_active_locations_on_date?(record.startdate) - - record.errors.add :startdate, I18n.t("validations.setup.startdate.scheme.locations_inactive.startdate", name: record.scheme.service_name) - record.errors.add :scheme_id, I18n.t("validations.setup.startdate.scheme.locations_inactive.scheme_id", name: record.scheme.service_name) - end - - def shared_validate_partner_count(record, max_people) - return if record.form.start_year_after_2024? - - partner_numbers = (2..max_people).select { |n| person_is_partner?(record["relat#{n}"]) } - if partner_numbers.count > 1 - partner_numbers.each do |n| - 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 - def date_valid?(question, record) if record[question].is_a?(ActiveSupport::TimeWithZone) && record[question].year.zero? - record.errors.add question, I18n.t("validations.date.invalid_date") + record.errors.add question, I18n.t("validations.shared.date.invalid_date") false else true end end - def validate_owning_organisation_data_sharing_agremeent_signed(record) - return if record.skip_dpo_validation - - if record.owning_organisation_id_changed? && record.owning_organisation.present? && !record.owning_organisation.data_protection_confirmed? - record.errors.add :owning_organisation_id, I18n.t("validations.setup.owning_organisation.data_sharing_agreement_not_signed") - end - end - private def person_is_partner?(relationship) @@ -169,9 +109,9 @@ private max = [question.prefix, number_with_delimiter(question.max, delimiter: ","), question.suffix].join("") if question.max if min && max - record.errors.add question.id.to_sym, :outside_the_range, message: I18n.t("validations.numeric.within_range", field:, min:, max:) + record.errors.add question.id.to_sym, :outside_the_range, message: I18n.t("validations.shared.numeric.within_range", field:, min:, max:) elsif min - record.errors.add question.id.to_sym, :under_min, message: I18n.t("validations.numeric.above_min", field:, min:) + record.errors.add question.id.to_sym, :under_min, message: I18n.t("validations.shared.numeric.above_min", field:, min:) end end end diff --git a/app/models/validations/tenancy_validations.rb b/app/models/validations/tenancy_validations.rb index bd55203fb..d08f8a071 100644 --- a/app/models/validations/tenancy_validations.rb +++ b/app/models/validations/tenancy_validations.rb @@ -10,10 +10,9 @@ module Validations::TenancyValidations min_tenancy_length = 1 return if record.tenancylength.to_i.between?(min_tenancy_length, 99) - message = I18n.t("validations.tenancy.length.invalid_fixed", min_tenancy_length:) - record.errors.add :needstype, message - record.errors.add :tenancylength, :tenancylength_invalid, message: message - record.errors.add :tenancy, message + record.errors.add :needstype, I18n.t("validations.lettings.tenancy.needstype.invalid_fixed_tenancylength", min_tenancy_length:) + record.errors.add :tenancylength, :tenancylength_invalid, message: I18n.t("validations.lettings.tenancy.tenancylength.invalid_fixed_tenancylength", min_tenancy_length:) + record.errors.add :tenancy, I18n.t("validations.lettings.tenancy.tenancy.invalid_fixed_tenancylength", min_tenancy_length:) end def validate_general_needs_fixed_tenancy_length_affordable_social_rent(record) @@ -23,11 +22,10 @@ module Validations::TenancyValidations min_tenancy_length = 2 return if record.tenancylength.to_i.between?(min_tenancy_length, 99) - message = I18n.t("validations.tenancy.length.invalid_fixed", min_tenancy_length:) - record.errors.add :needstype, message - record.errors.add :rent_type, message - record.errors.add :tenancylength, :tenancylength_invalid, message: message - record.errors.add :tenancy, message + record.errors.add :needstype, I18n.t("validations.lettings.tenancy.needstype.invalid_fixed_tenancylength", min_tenancy_length:) + record.errors.add :rent_type, I18n.t("validations.lettings.tenancy.rent_type.invalid_fixed_tenancylength", min_tenancy_length:) + record.errors.add :tenancylength, :tenancylength_invalid, message: I18n.t("validations.lettings.tenancy.tenancylength.invalid_fixed_tenancylength", min_tenancy_length:) + record.errors.add :tenancy, I18n.t("validations.lettings.tenancy.tenancy.invalid_fixed_tenancylength", min_tenancy_length:) end def validate_general_needs_fixed_tenancy_length_intermediate_rent(record) @@ -37,11 +35,10 @@ module Validations::TenancyValidations min_tenancy_length = 1 return if record.tenancylength.to_i.between?(min_tenancy_length, 99) - message = I18n.t("validations.tenancy.length.invalid_fixed", min_tenancy_length:) - record.errors.add :needstype, message - record.errors.add :rent_type, message - record.errors.add :tenancylength, :tenancylength_invalid, message: message - record.errors.add :tenancy, message + record.errors.add :needstype, I18n.t("validations.lettings.tenancy.needstype.invalid_fixed_tenancylength", min_tenancy_length:) + record.errors.add :rent_type, I18n.t("validations.lettings.tenancy.rent_type.invalid_fixed_tenancylength", min_tenancy_length:) + record.errors.add :tenancylength, :tenancylength_invalid, message: I18n.t("validations.lettings.tenancy.tenancylength.invalid_fixed_tenancylength", min_tenancy_length:) + record.errors.add :tenancy, I18n.t("validations.lettings.tenancy.tenancy.invalid_fixed_tenancylength", min_tenancy_length:) end def validate_periodic_tenancy_length(record) @@ -50,18 +47,16 @@ module Validations::TenancyValidations min_tenancy_length = 1 return if record.tenancylength.to_i.between?(min_tenancy_length, 99) - message = I18n.t("validations.tenancy.length.invalid_periodic", min_tenancy_length:) - record.errors.add :tenancylength, :tenancylength_invalid, message: message - record.errors.add :tenancy, message + record.errors.add :tenancylength, :tenancylength_invalid, message: I18n.t("validations.lettings.tenancy.tenancylength.invalid_periodic_tenancylength", min_tenancy_length:) + record.errors.add :tenancy, I18n.t("validations.lettings.tenancy.tenancy.invalid_periodic_tenancylength", min_tenancy_length:) end def validate_tenancy_length_blank_when_not_required(record) return if record.tenancylength.blank? return if record.tenancy_type_fixed_term? || record.is_periodic_tenancy? - message = I18n.t("validations.tenancy.length.fixed_term_not_required") - record.errors.add :tenancylength, :tenancylength_invalid, message: message - record.errors.add :tenancy, message + record.errors.add :tenancylength, :tenancylength_invalid, message: I18n.t("validations.lettings.tenancy.tenancylength.fixed_term_not_required") + record.errors.add :tenancy, I18n.t("validations.lettings.tenancy.tenancy.fixed_term_not_required") end def validate_other_tenancy_type(record) @@ -72,8 +67,8 @@ module Validations::TenancyValidations return unless record.collection_start_year && record.joint if record.hhmemb == 1 && record.joint == 1 && record.collection_start_year >= 2022 - record.errors.add :joint, :not_joint_tenancy, message: I18n.t("validations.tenancy.not_joint") - record.errors.add :hhmemb, I18n.t("validations.tenancy.joint_more_than_one_member") + record.errors.add :joint, :not_joint_tenancy, message: I18n.t("validations.lettings.tenancy.joint.sole_tenancy") + record.errors.add :hhmemb, I18n.t("validations.lettings.tenancy.joint.multiple_members_required") end end end diff --git a/app/services/bulk_upload/lettings/log_creator.rb b/app/services/bulk_upload/lettings/log_creator.rb index 3aaf1d69d..1fd0d45b6 100644 --- a/app/services/bulk_upload/lettings/log_creator.rb +++ b/app/services/bulk_upload/lettings/log_creator.rb @@ -15,7 +15,7 @@ class BulkUpload::Lettings::LogCreator row_parser.log.blank_invalid_non_setup_fields! row_parser.log.bulk_upload = bulk_upload - row_parser.log.creation_method_bulk_upload! + row_parser.log.creation_method = "bulk upload" row_parser.log.skip_update_status = true row_parser.log.status = "pending" row_parser.log.status_cache = row_parser.log.calculate_status diff --git a/app/services/bulk_upload/lettings/validator.rb b/app/services/bulk_upload/lettings/validator.rb index 4da5b2c40..116c3b745 100644 --- a/app/services/bulk_upload/lettings/validator.rb +++ b/app/services/bulk_upload/lettings/validator.rb @@ -158,7 +158,7 @@ private def validate_file_not_empty if File.size(path).zero? || csv_parser.body_rows.flatten.compact.empty? - errors.add(:base, :blank_file) + errors.add(:base, I18n.t("validations.lettings.#{@bulk_upload.year}.bulk_upload.blank_file")) halt_validations! end @@ -168,7 +168,7 @@ private return if halt_validations? unless csv_parser.correct_field_count? - errors.add(:base, :wrong_field_numbers_count) + errors.add(:base, I18n.t("validations.lettings.#{@bulk_upload.year}.bulk_upload.wrong_template.wrong_field_numbers_count")) halt_validations! end end @@ -177,7 +177,7 @@ private return if halt_validations? if csv_parser.too_many_columns? - errors.add(:base, :over_max_column_count) + errors.add(:base, I18n.t("validations.lettings.#{@bulk_upload.year}.bulk_upload.wrong_template.over_max_column_count")) halt_validations! end end @@ -185,14 +185,14 @@ private def validate_correct_template return if halt_validations? - errors.add(:base, :wrong_template) if csv_parser.wrong_template_for_year? + errors.add(:base, I18n.t("validations.lettings.#{@bulk_upload.year}.bulk_upload.wrong_template.wrong_template")) if csv_parser.wrong_template_for_year? end def validate_missing_required_headers return if halt_validations? if csv_parser.missing_required_headers? - errors.add :base, I18n.t("activemodel.errors.models.bulk_upload/lettings/validator.attributes.base.no_headers", guidance_link: bulk_upload_lettings_log_url(id: "guidance", form: { year: bulk_upload.year }, host: ENV["APP_HOST"], anchor: "using-the-bulk-upload-template")) + errors.add :base, I18n.t("validations.lettings.#{@bulk_upload.year}.bulk_upload.wrong_template.no_headers", guidance_link: bulk_upload_lettings_log_url(id: "guidance", form: { year: bulk_upload.year }, host: ENV["APP_HOST"], anchor: "using-the-bulk-upload-template")) halt_validations! 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 59cf7ea34..3424e0608 100644 --- a/app/services/bulk_upload/lettings/year2023/row_parser.rb +++ b/app/services/bulk_upload/lettings/year2023/row_parser.rb @@ -141,6 +141,8 @@ class BulkUpload::Lettings::Year2023::RowParser field_134: "What do you expect the outstanding amount to be?", }.freeze + ERROR_BASE_KEY = "validations.lettings.2023.bulk_upload".freeze + attribute :bulk_upload attribute :block_log_creation, :boolean, default: -> { false } @@ -285,12 +287,12 @@ class BulkUpload::Lettings::Year2023::RowParser validates :field_5, presence: { - message: I18n.t("validations.not_answered", question: "letting type."), + message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "letting type."), category: :setup, }, inclusion: { in: (1..12).to_a, - message: I18n.t("validations.invalid_option", question: "letting type."), + message: I18n.t("#{ERROR_BASE_KEY}.invalid_option", question: "letting type."), unless: -> { field_5.blank? }, category: :setup, }, @@ -298,33 +300,33 @@ class BulkUpload::Lettings::Year2023::RowParser validates :field_6, presence: { - message: I18n.t("validations.not_answered", question: "property renewal."), + message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "property renewal."), category: :setup, }, on: :after_log validates :field_7, presence: { - message: I18n.t("validations.not_answered", question: "tenancy start date (day)."), + message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "tenancy start date (day)."), category: :setup, }, on: :after_log validates :field_8, presence: { - message: I18n.t("validations.not_answered", question: "tenancy start date (month)."), + message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "tenancy start date (month)."), category: :setup, }, on: :after_log validates :field_9, presence: { - message: I18n.t("validations.not_answered", question: "tenancy start date (year)."), + message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "tenancy start date (year)."), category: :setup, }, format: { with: /\A(\d{2}|\d{4})\z/, - message: I18n.t("validations.setup.startdate.year_not_two_or_four_digits"), + message: I18n.t("#{ERROR_BASE_KEY}.startdate.year_not_two_or_four_digits"), category: :setup, unless: -> { field_9.blank? }, }, @@ -333,55 +335,55 @@ class BulkUpload::Lettings::Year2023::RowParser validates :field_16, presence: { if: proc { supported_housing? }, - message: I18n.t("validations.not_answered", question: "scheme code."), + message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "scheme code."), category: :setup, }, on: :after_log validates :field_116, presence: { - message: I18n.t("validations.not_answered", question: "was the letting made under the Choice-Based Lettings (CBL)?"), + message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "was the letting made under the Choice-Based Lettings (CBL)?"), category: :not_answered, }, inclusion: { in: [1, 2], - message: I18n.t("validations.invalid_option", question: "was the letting made under the Choice-Based Lettings (CBL)?"), + message: I18n.t("#{ERROR_BASE_KEY}.invalid_option", question: "was the letting made under the Choice-Based Lettings (CBL)?"), if: -> { field_116.present? }, }, on: :after_log validates :field_117, presence: { - message: I18n.t("validations.not_answered", question: "was the letting made under the Common Allocation Policy (CAP)?"), + message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "was the letting made under the Common Allocation Policy (CAP)?"), category: :not_answered, }, inclusion: { in: [1, 2], - message: I18n.t("validations.invalid_option", question: "was the letting made under the Common Allocation Policy (CAP)?"), + message: I18n.t("#{ERROR_BASE_KEY}.invalid_option", question: "was the letting made under the Common Allocation Policy (CAP)?"), if: -> { field_117.present? }, }, on: :after_log validates :field_118, presence: { - message: I18n.t("validations.not_answered", question: "was the letting made under the Common Housing Register (CHR)?"), + message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "was the letting made under the Common Housing Register (CHR)?"), category: :not_answered, }, inclusion: { in: [1, 2], - message: I18n.t("validations.invalid_option", question: "was the letting made under the Common Housing Register (CHR)?"), + message: I18n.t("#{ERROR_BASE_KEY}.invalid_option", question: "was the letting made under the Common Housing Register (CHR)?"), if: -> { field_118.present? }, }, on: :after_log - validates :field_46, format: { with: /\A\d{1,3}\z|\AR\z/, message: "Age of person 1 must be a number or the letter R" }, on: :after_log - validates :field_52, format: { with: /\A\d{1,3}\z|\AR\z/, message: "Age of person 2 must be a number or the letter R" }, on: :after_log, if: proc { details_known?(2).zero? } - validates :field_56, format: { with: /\A\d{1,3}\z|\AR\z/, message: "Age of person 3 must be a number or the letter R" }, on: :after_log, if: proc { details_known?(3).zero? } - validates :field_60, format: { with: /\A\d{1,3}\z|\AR\z/, message: "Age of person 4 must be a number or the letter R" }, on: :after_log, if: proc { details_known?(4).zero? } - validates :field_64, format: { with: /\A\d{1,3}\z|\AR\z/, message: "Age of person 5 must be a number or the letter R" }, on: :after_log, if: proc { details_known?(5).zero? } - validates :field_68, format: { with: /\A\d{1,3}\z|\AR\z/, message: "Age of person 6 must be a number or the letter R" }, on: :after_log, if: proc { details_known?(6).zero? } - validates :field_72, format: { with: /\A\d{1,3}\z|\AR\z/, message: "Age of person 7 must be a number or the letter R" }, on: :after_log, if: proc { details_known?(7).zero? } - validates :field_76, format: { with: /\A\d{1,3}\z|\AR\z/, message: "Age of person 8 must be a number or the letter R" }, on: :after_log, if: proc { details_known?(8).zero? } + validates :field_46, format: { with: /\A\d{1,3}\z|\AR\z/, message: I18n.t("#{ERROR_BASE_KEY}.age.invalid", person_num: 1) }, on: :after_log + validates :field_52, format: { with: /\A\d{1,3}\z|\AR\z/, message: I18n.t("#{ERROR_BASE_KEY}.age.invalid", person_num: 2) }, on: :after_log, if: proc { details_known?(2).zero? } + validates :field_56, format: { with: /\A\d{1,3}\z|\AR\z/, message: I18n.t("#{ERROR_BASE_KEY}.age.invalid", person_num: 3) }, on: :after_log, if: proc { details_known?(3).zero? } + validates :field_60, format: { with: /\A\d{1,3}\z|\AR\z/, message: I18n.t("#{ERROR_BASE_KEY}.age.invalid", person_num: 4) }, on: :after_log, if: proc { details_known?(4).zero? } + validates :field_64, format: { with: /\A\d{1,3}\z|\AR\z/, message: I18n.t("#{ERROR_BASE_KEY}.age.invalid", person_num: 5) }, on: :after_log, if: proc { details_known?(5).zero? } + validates :field_68, format: { with: /\A\d{1,3}\z|\AR\z/, message: I18n.t("#{ERROR_BASE_KEY}.age.invalid", person_num: 6) }, on: :after_log, if: proc { details_known?(6).zero? } + validates :field_72, format: { with: /\A\d{1,3}\z|\AR\z/, message: I18n.t("#{ERROR_BASE_KEY}.age.invalid", person_num: 7) }, on: :after_log, if: proc { details_known?(7).zero? } + validates :field_76, format: { with: /\A\d{1,3}\z|\AR\z/, message: I18n.t("#{ERROR_BASE_KEY}.age.invalid", person_num: 8) }, on: :after_log, if: proc { details_known?(8).zero? } validate :validate_needs_type_present, on: :after_log validate :validate_data_types, on: :after_log @@ -521,7 +523,7 @@ class BulkUpload::Lettings::Year2023::RowParser def add_duplicate_found_in_spreadsheet_errors spreadsheet_duplicate_hash.each_key do |field| - errors.add(field, :spreadsheet_dupe, category: :setup) + errors.add(field, I18n.t("#{ERROR_BASE_KEY}.spreadsheet_dupe"), category: :setup) end end @@ -529,7 +531,7 @@ private def validate_declaration_acceptance unless field_45 == 1 - errors.add(:field_45, I18n.t("validations.declaration.missing.pre_2024"), category: :setup) + errors.add(:field_45, I18n.t("#{ERROR_BASE_KEY}.declaration.missing"), category: :setup) end end @@ -544,9 +546,9 @@ private fields.each do |field| if setup_question?(question) - errors.add(field, I18n.t("validations.invalid_option", question: format_ending(QUESTIONS[field])), category: :setup) + errors.add(field, I18n.t("#{ERROR_BASE_KEY}.invalid_option", question: format_ending(QUESTIONS[field])), category: :setup) else - errors.add(field, I18n.t("validations.invalid_option", question: format_ending(QUESTIONS[field]))) + errors.add(field, I18n.t("#{ERROR_BASE_KEY}.invalid_option", question: format_ending(QUESTIONS[field]))) end end end @@ -556,7 +558,7 @@ private return if field_3.blank? unless assigned_to - errors.add(:field_3, "User with the specified email could not be found.") + errors.add(:field_3, I18n.t("#{ERROR_BASE_KEY}.assigned_to.not_found")) end end @@ -566,7 +568,7 @@ private return if assigned_to.organisation == owning_organisation&.absorbing_organisation || assigned_to.organisation == managing_organisation&.absorbing_organisation block_log_creation! - errors.add(:field_3, "User must be related to owning organisation or managing organisation.") + errors.add(:field_3, I18n.t("#{ERROR_BASE_KEY}.assigned_to.organisation_not_related")) end def assigned_to @@ -575,7 +577,7 @@ private def validate_uprn_exists_if_any_key_address_fields_are_blank if field_18.blank? && (field_19.blank? || field_21.blank?) - errors.add(:field_18, I18n.t("validations.not_answered", question: "UPRN."), category: :not_answered) + errors.add(:field_18, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "UPRN."), category: :not_answered) end end @@ -614,21 +616,21 @@ private def validate_needs_type_present if field_4.blank? - errors.add(:field_4, I18n.t("validations.not_answered", question: "needs type."), category: :setup) + errors.add(:field_4, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "needs type."), category: :setup) end 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")) - errors.add(:field_88, I18n.t("validations.household.housingneeds.no_and_dont_know_disabled_needs_conjunction")) + errors.add(:field_87, I18n.t("#{ERROR_BASE_KEY}.housingneeds.no_and_dont_know_disabled_needs_conjunction")) + errors.add(:field_88, I18n.t("#{ERROR_BASE_KEY}.housingneeds.no_and_dont_know_disabled_needs_conjunction")) end end def validate_dont_know_disabled_needs_conjunction if field_88 == 1 && [field_83, field_84, field_85, field_86].count(1).positive? %i[field_88 field_83 field_84 field_85 field_86].each do |field| - errors.add(field, I18n.t("validations.household.housingneeds.dont_know_disabled_needs_conjunction")) if send(field) == 1 + errors.add(field, I18n.t("#{ERROR_BASE_KEY}.housingneeds.dont_know_disabled_needs_conjunction")) if send(field) == 1 end end end @@ -636,7 +638,7 @@ private def validate_no_disabled_needs_conjunction if field_87 == 1 && [field_83, field_84, field_85, field_86].count(1).positive? %i[field_87 field_83 field_84 field_85 field_86].each do |field| - errors.add(field, I18n.t("validations.household.housingneeds.no_disabled_needs_conjunction")) if send(field) == 1 + errors.add(field, I18n.t("#{ERROR_BASE_KEY}.housingneeds.no_disabled_needs_conjunction")) if send(field) == 1 end end end @@ -644,17 +646,17 @@ private def validate_only_one_housing_needs_type if [field_83, field_84, field_85].count(1) > 1 %i[field_83 field_84 field_85].each do |field| - errors.add(field, I18n.t("validations.household.housingneeds_type.only_one_option_permitted")) if send(field) == 1 + errors.add(field, I18n.t("#{ERROR_BASE_KEY}.housingneeds_type.only_one_option_permitted")) if send(field) == 1 end end end def validate_no_housing_needs_questions_answered if [field_83, field_84, field_85, field_86, field_87, field_88].all?(&:blank?) - errors.add(:field_87, I18n.t("validations.not_answered", question: "anybody with disabled access needs."), category: :not_answered) - errors.add(:field_86, I18n.t("validations.not_answered", question: "other access needs."), category: :not_answered) + errors.add(:field_87, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "anybody with disabled access needs."), category: :not_answered) + errors.add(:field_86, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "other access needs."), category: :not_answered) %i[field_83 field_84 field_85].each do |field| - errors.add(field, I18n.t("validations.not_answered", question: "disabled access needs type."), category: :not_answered) + errors.add(field, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "disabled access needs type."), category: :not_answered) end end end @@ -663,7 +665,7 @@ private reason_fields = %i[field_111 field_112 field_113 field_114 field_115] if field_110 == 1 && reason_fields.all? { |field| attributes[field.to_s].blank? } reason_fields.each do |field| - errors.add(field, I18n.t("validations.not_answered", question: "reason for reasonable preference."), category: :not_answered) + errors.add(field, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "reason for reasonable preference."), category: :not_answered) end end end @@ -673,12 +675,12 @@ private if household_no_illness? illness_option_fields.each do |field| if attributes[field.to_s] == 1 - errors.add(field, I18n.t("validations.household.condition_effects.no_choices")) + errors.add(field, I18n.t("#{ERROR_BASE_KEY}.condition_effects.no_choices")) end end elsif illness_option_fields.all? { |field| attributes[field.to_s].blank? } illness_option_fields.each do |field| - errors.add(field, I18n.t("validations.not_answered", question: "how is person affected by condition or illness."), category: :not_answered) + errors.add(field, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "how is person affected by condition or illness."), category: :not_answered) end end end @@ -690,20 +692,20 @@ private def validate_lettings_type_matches_bulk_upload if [1, 3, 5, 7, 9, 11].include?(field_5) && !general_needs? block_log_creation! - errors.add(:field_4, I18n.t("validations.setup.needstype.lettype_not_supported_housing"), category: :setup) - errors.add(:field_5, I18n.t("validations.setup.lettype.needstype_supported_housing"), category: :setup) + errors.add(:field_4, I18n.t("#{ERROR_BASE_KEY}.needstype.lettype_not_supported_housing"), category: :setup) + errors.add(:field_5, I18n.t("#{ERROR_BASE_KEY}.lettype.needstype_supported_housing"), category: :setup) end if [2, 4, 6, 8, 10, 12].include?(field_5) && !supported_housing? block_log_creation! - errors.add(:field_4, I18n.t("validations.setup.needstype.lettype_not_general_needs"), category: :setup) - errors.add(:field_5, I18n.t("validations.setup.lettype.needstype_general_needs"), category: :setup) + errors.add(:field_4, I18n.t("#{ERROR_BASE_KEY}.needstype.lettype_not_general_needs"), category: :setup) + errors.add(:field_5, I18n.t("#{ERROR_BASE_KEY}.lettype.needstype_general_needs"), category: :setup) end end def validate_leaving_reason_for_renewal if field_6 == 1 && ![40, 42].include?(field_102) - errors.add(:field_102, I18n.t("validations.household.reason.renewal_reason_needed")) + errors.add(:field_102, I18n.t("#{ERROR_BASE_KEY}.reason.renewal_reason_needed")) end end @@ -717,13 +719,13 @@ private def validate_cannot_be_la_referral_if_general_needs_and_la if field_119 == 4 && general_needs? && owning_organisation && owning_organisation.la? - errors.add :field_119, I18n.t("validations.household.referral.la_general_needs.prp_referred_by_la") + errors.add :field_119, I18n.t("#{ERROR_BASE_KEY}.referral.general_needs_prp_referred_by_la") end end def validate_la_with_local_housing_referral if field_119 == 3 && owning_organisation && owning_organisation.la? - errors.add(:field_119, I18n.t("validations.household.referral.nominated_by_local_ha_but_la")) + errors.add(:field_119, I18n.t("#{ERROR_BASE_KEY}.referral.nominated_by_local_ha_but_la")) end end @@ -731,15 +733,15 @@ private return if startdate.blank? || bulk_upload.form.blank? 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) + errors.add(:field_7, I18n.t("#{ERROR_BASE_KEY}.startdate.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("#{ERROR_BASE_KEY}.startdate.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("#{ERROR_BASE_KEY}.startdate.outside_collection_window", year_combo: bulk_upload.year_combo, start_year: bulk_upload.year, end_year: bulk_upload.end_year), category: :setup) end end def validate_data_types unless attribute_set["field_5"].value_before_type_cast&.match?(/^\d+\.?0*$/) - errors.add(:field_5, I18n.t("validations.invalid_number", question: "letting type.")) + errors.add(:field_5, I18n.t("#{ERROR_BASE_KEY}.invalid_number", question: "letting type.")) end end @@ -756,14 +758,14 @@ private fields.each do |field| if errors.select { |e| fields.include?(e.attribute) }.none? question_text = question.error_display_label.presence || "this question." - errors.add(field, I18n.t("validations.not_answered", question: format_ending(question_text)), category: :setup) if field.present? + errors.add(field, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: format_ending(question_text)), category: :setup) if field.present? end end else fields.each do |field| unless errors.any? { |e| fields.include?(e.attribute) } question_text = question.error_display_label.presence || "this question." - errors.add(field, I18n.t("validations.not_answered", question: format_ending(question_text)), category: :not_answered) + errors.add(field, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: format_ending(question_text)), category: :not_answered) end end end @@ -773,28 +775,28 @@ private def validate_related_location_exists if scheme && location_id.present? && location.nil? && location_field.present? block_log_creation! - errors.add(location_field, "#{location_or_scheme.capitalize} code must relate to a #{location_or_scheme} that is owned by the owning organisation or managing organisation.", category: :setup) + errors.add(location_field, I18n.t("#{ERROR_BASE_KEY}.scheme.must_relate_to_org", capitalised_location_or_scheme: location_or_scheme.capitalize, location_or_scheme:), category: :setup) end end def validate_location_data_given if supported_housing? && location_id.blank? && location_field.present? block_log_creation! - errors.add(location_field, I18n.t("validations.not_answered", question: "#{location_or_scheme} code."), category: :setup) + errors.add(location_field, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "#{location_or_scheme} code."), category: :setup) end end def validate_related_scheme_exists if scheme_id.present? && scheme_field.present? && owning_organisation.present? && managing_organisation.present? && scheme.nil? block_log_creation! - errors.add(scheme_field, "This #{scheme_or_management_group} code does not belong to the owning organisation or managing organisation.", category: :setup) + errors.add(scheme_field, I18n.t("#{ERROR_BASE_KEY}.scheme.does_not_belong_to_org", scheme_or_management_group:), category: :setup) end end def validate_scheme_data_given if supported_housing? && scheme_field.present? && scheme_id.blank? block_log_creation! - errors.add(scheme_field, I18n.t("validations.not_answered", question: "#{scheme_or_management_group} code."), category: :setup) + errors.add(scheme_field, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "#{scheme_or_management_group} code."), category: :setup) end end @@ -803,7 +805,7 @@ private block_log_creation! if errors[:field_2].blank? - errors.add(:field_2, "This managing organisation does not have a relationship with the owning organisation.", category: :setup) + errors.add(:field_2, I18n.t("#{ERROR_BASE_KEY}.managing_organisation.no_relationship"), category: :setup) end end end @@ -813,7 +815,7 @@ private block_log_creation! if errors[:field_2].blank? - errors.add(:field_2, "The managing organisation code is incorrect.", category: :setup) + errors.add(:field_2, I18n.t("#{ERROR_BASE_KEY}.managing_organisation.not_found"), category: :setup) end end end @@ -821,7 +823,7 @@ private def validate_managing_org_data_given if field_2.blank? block_log_creation! - errors.add(:field_2, "The managing organisation code is incorrect.", category: :setup) + errors.add(:field_2, I18n.t("#{ERROR_BASE_KEY}.managing_organisation.not_answered"), category: :setup) end end @@ -830,7 +832,7 @@ private block_log_creation! if errors[:field_1].blank? - errors.add(:field_1, "The owning organisation code provided is for an organisation that does not own stock.", category: :setup) + errors.add(:field_1, I18n.t("#{ERROR_BASE_KEY}.owning_organisation.not_stock_owner"), category: :setup) end end end @@ -840,7 +842,7 @@ private block_log_creation! if errors[:field_1].blank? - errors.add(:field_1, "The owning organisation code is incorrect.", category: :setup) + errors.add(:field_1, I18n.t("#{ERROR_BASE_KEY}.owning_organisation.not_found"), category: :setup) end end end @@ -848,7 +850,7 @@ private def validate_owning_org_data_given if field_1.blank? block_log_creation! - errors.add(:field_1, I18n.t("validations.not_answered", question: "owning organisation."), category: :setup) + errors.add(:field_1, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "owning organisation."), category: :setup) end end @@ -857,20 +859,20 @@ private block_log_creation! if errors[:field_1].blank? - errors.add(:field_1, "You do not have permission to add logs for this owning organisation.", category: :setup) + errors.add(:field_1, I18n.t("#{ERROR_BASE_KEY}.owning_organisation.not_permitted"), category: :setup) end end end def validate_correct_intermediate_rent_type if field_11.blank? || ![1, 2, 3].include?(field_11.to_i) - errors.add(:field_11, I18n.t("validations.not_answered", question: "intermediate rent type."), category: :setup) + errors.add(:field_11, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "intermediate rent type."), category: :setup) end end def validate_correct_affordable_rent_type if field_10.blank? || ![1, 2, 3].include?(field_10.to_i) - errors.add(:field_10, I18n.t("validations.not_answered", question: "is this a London Affordable Rent letting."), category: :setup) + errors.add(:field_10, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "is this a London Affordable Rent letting."), category: :setup) end end @@ -880,7 +882,7 @@ private def validate_if_log_already_exists if log_already_exists? - error_message = "This is a duplicate log." + error_message = I18n.t("#{ERROR_BASE_KEY}.duplicate") errors.add(:field_1, error_message) # owning_organisation errors.add(:field_7, error_message) # startdate diff --git a/app/services/bulk_upload/lettings/year2024/row_parser.rb b/app/services/bulk_upload/lettings/year2024/row_parser.rb index 312a5472a..ef7433614 100644 --- a/app/services/bulk_upload/lettings/year2024/row_parser.rb +++ b/app/services/bulk_upload/lettings/year2024/row_parser.rb @@ -146,6 +146,8 @@ class BulkUpload::Lettings::Year2024::RowParser 6 => 5, }.freeze + ERROR_BASE_KEY = "validations.lettings.2024.bulk_upload".freeze + attribute :bulk_upload attribute :block_log_creation, :boolean, default: -> { false } @@ -286,12 +288,12 @@ class BulkUpload::Lettings::Year2024::RowParser validates :field_11, presence: { - message: I18n.t("validations.not_answered", question: "rent type."), + message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "rent type."), category: :setup, }, inclusion: { in: (1..6).to_a, - message: I18n.t("validations.invalid_option", question: "rent type."), + message: I18n.t("#{ERROR_BASE_KEY}.invalid_option", question: "rent type."), unless: -> { field_11.blank? }, category: :setup, }, @@ -299,33 +301,33 @@ class BulkUpload::Lettings::Year2024::RowParser validates :field_7, presence: { - message: I18n.t("validations.not_answered", question: "property renewal."), + message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "property renewal."), category: :setup, }, on: :after_log validates :field_8, presence: { - message: I18n.t("validations.not_answered", question: "tenancy start date (day)."), + message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "tenancy start date (day)."), category: :setup, }, on: :after_log validates :field_9, presence: { - message: I18n.t("validations.not_answered", question: "tenancy start date (month)."), + message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "tenancy start date (month)."), category: :setup, }, on: :after_log validates :field_10, presence: { - message: I18n.t("validations.not_answered", question: "tenancy start date (year)."), + message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "tenancy start date (year)."), category: :setup, }, format: { with: /\A(\d{2}|\d{4})\z/, - message: I18n.t("validations.setup.startdate.year_not_two_or_four_digits"), + message: I18n.t("#{ERROR_BASE_KEY}.startdate.year_not_two_or_four_digits"), category: :setup, unless: -> { field_10.blank? }, }, @@ -334,7 +336,7 @@ class BulkUpload::Lettings::Year2024::RowParser validates :field_5, presence: { if: proc { supported_housing? }, - message: I18n.t("validations.not_answered", question: "scheme code."), + message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "scheme code."), category: :setup, }, on: :after_log @@ -342,67 +344,67 @@ class BulkUpload::Lettings::Year2024::RowParser validates :field_6, presence: { if: proc { supported_housing? }, - message: I18n.t("validations.not_answered", question: "location code."), + message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "location code."), category: :setup, }, on: :after_log validates :field_112, presence: { - message: I18n.t("validations.not_answered", question: "was the letting made under the Choice-Based Lettings (CBL)?"), + message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "was the letting made under the Choice-Based Lettings (CBL)?"), category: :not_answered, }, inclusion: { in: [1, 2], - message: I18n.t("validations.invalid_option", question: "was the letting made under the Choice-Based Lettings (CBL)?"), + message: I18n.t("#{ERROR_BASE_KEY}.invalid_option", question: "was the letting made under the Choice-Based Lettings (CBL)?"), if: -> { field_112.present? }, }, on: :after_log validates :field_113, presence: { - message: I18n.t("validations.not_answered", question: "was the letting made under the Common Allocation Policy (CAP)?"), + message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "was the letting made under the Common Allocation Policy (CAP)?"), category: :not_answered, }, inclusion: { in: [1, 2], - message: I18n.t("validations.invalid_option", question: "was the letting made under the Common Allocation Policy (CAP)?"), + message: I18n.t("#{ERROR_BASE_KEY}.invalid_option", question: "was the letting made under the Common Allocation Policy (CAP)?"), if: -> { field_113.present? }, }, on: :after_log validates :field_114, presence: { - message: I18n.t("validations.not_answered", question: "was the letting made under the Common Housing Register (CHR)?"), + message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "was the letting made under the Common Housing Register (CHR)?"), category: :not_answered, }, inclusion: { in: [1, 2], - message: I18n.t("validations.invalid_option", question: "was the letting made under the Common Housing Register (CHR)?"), + message: I18n.t("#{ERROR_BASE_KEY}.invalid_option", question: "was the letting made under the Common Housing Register (CHR)?"), if: -> { field_114.present? }, }, on: :after_log validates :field_115, presence: { - message: I18n.t("validations.not_answered", question: "was the letting made under the Accessible Register?"), + message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "was the letting made under the Accessible Register?"), category: :not_answered, }, inclusion: { in: [1, 2], - message: I18n.t("validations.invalid_option", question: "was the letting made under the Accessible Register?"), + message: I18n.t("#{ERROR_BASE_KEY}.invalid_option", question: "was the letting made under the Accessible Register?"), if: -> { field_115.present? }, }, on: :after_log - validates :field_42, format: { with: /\A\d{1,3}\z|\AR\z/, message: "Age of person 1 must be a number or the letter R" }, on: :after_log - validates :field_48, format: { with: /\A\d{1,3}\z|\AR\z/, message: "Age of person 2 must be a number or the letter R" }, on: :after_log, if: proc { details_known?(2).zero? } - validates :field_52, format: { with: /\A\d{1,3}\z|\AR\z/, message: "Age of person 3 must be a number or the letter R" }, on: :after_log, if: proc { details_known?(3).zero? } - validates :field_56, format: { with: /\A\d{1,3}\z|\AR\z/, message: "Age of person 4 must be a number or the letter R" }, on: :after_log, if: proc { details_known?(4).zero? } - validates :field_60, format: { with: /\A\d{1,3}\z|\AR\z/, message: "Age of person 5 must be a number or the letter R" }, on: :after_log, if: proc { details_known?(5).zero? } - validates :field_64, format: { with: /\A\d{1,3}\z|\AR\z/, message: "Age of person 6 must be a number or the letter R" }, on: :after_log, if: proc { details_known?(6).zero? } - validates :field_68, format: { with: /\A\d{1,3}\z|\AR\z/, message: "Age of person 7 must be a number or the letter R" }, on: :after_log, if: proc { details_known?(7).zero? } - validates :field_72, format: { with: /\A\d{1,3}\z|\AR\z/, message: "Age of person 8 must be a number or the letter R" }, on: :after_log, if: proc { details_known?(8).zero? } + validates :field_42, format: { with: /\A\d{1,3}\z|\AR\z/, message: I18n.t("#{ERROR_BASE_KEY}.age.invalid", person_num: 1) }, on: :after_log + validates :field_48, format: { with: /\A\d{1,3}\z|\AR\z/, message: I18n.t("#{ERROR_BASE_KEY}.age.invalid", person_num: 2) }, on: :after_log, if: proc { details_known?(2).zero? } + validates :field_52, format: { with: /\A\d{1,3}\z|\AR\z/, message: I18n.t("#{ERROR_BASE_KEY}.age.invalid", person_num: 3) }, on: :after_log, if: proc { details_known?(3).zero? } + validates :field_56, format: { with: /\A\d{1,3}\z|\AR\z/, message: I18n.t("#{ERROR_BASE_KEY}.age.invalid", person_num: 4) }, on: :after_log, if: proc { details_known?(4).zero? } + validates :field_60, format: { with: /\A\d{1,3}\z|\AR\z/, message: I18n.t("#{ERROR_BASE_KEY}.age.invalid", person_num: 5) }, on: :after_log, if: proc { details_known?(5).zero? } + validates :field_64, format: { with: /\A\d{1,3}\z|\AR\z/, message: I18n.t("#{ERROR_BASE_KEY}.age.invalid", person_num: 6) }, on: :after_log, if: proc { details_known?(6).zero? } + validates :field_68, format: { with: /\A\d{1,3}\z|\AR\z/, message: I18n.t("#{ERROR_BASE_KEY}.age.invalid", person_num: 7) }, on: :after_log, if: proc { details_known?(7).zero? } + validates :field_72, format: { with: /\A\d{1,3}\z|\AR\z/, message: I18n.t("#{ERROR_BASE_KEY}.age.invalid", person_num: 8) }, on: :after_log, if: proc { details_known?(8).zero? } validate :validate_needs_type_present, on: :after_log validate :validate_data_types, on: :after_log @@ -547,10 +549,10 @@ class BulkUpload::Lettings::Year2024::RowParser spreadsheet_duplicate_hash.each_key do |field| if field == "tcharge" %w[field_125 field_126 field_127 field_128].each do |sub_field| - errors.add(sub_field, :spreadsheet_dupe, category: :setup) + errors.add(sub_field, I18n.t("#{ERROR_BASE_KEY}.spreadsheet_dupe"), category: :setup) end else - errors.add(field, :spreadsheet_dupe, category: :setup) + errors.add(field, I18n.t("#{ERROR_BASE_KEY}.spreadsheet_dupe"), category: :setup) end end end @@ -568,9 +570,9 @@ private fields.each do |field| if setup_question?(question) - errors.add(field, I18n.t("validations.invalid_option", question: format_ending(QUESTIONS[field])), category: :setup) + errors.add(field, I18n.t("#{ERROR_BASE_KEY}.invalid_option", question: format_ending(QUESTIONS[field])), category: :setup) else - errors.add(field, I18n.t("validations.invalid_option", question: format_ending(QUESTIONS[field]))) + errors.add(field, I18n.t("#{ERROR_BASE_KEY}.invalid_option", question: format_ending(QUESTIONS[field]))) end end end @@ -580,13 +582,13 @@ private return if field_3.blank? unless assigned_to - errors.add(:field_3, "User with the specified email could not be found.") + errors.add(:field_3, I18n.t("#{ERROR_BASE_KEY}.assigned_to.not_found")) end end def validate_assigned_to_when_support if field_3.blank? && bulk_upload.user.support? - errors.add(:field_3, category: :setup, message: I18n.t("validations.not_answered", question: "what is the CORE username of the account this letting log should be assigned to?")) + errors.add(:field_3, category: :setup, message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "what is the CORE username of the account this letting log should be assigned to?")) end end @@ -596,7 +598,7 @@ private return if assigned_to.organisation == owning_organisation&.absorbing_organisation || assigned_to.organisation == managing_organisation&.absorbing_organisation block_log_creation! - errors.add(:field_3, "User must be related to owning organisation or managing organisation.") + errors.add(:field_3, I18n.t("#{ERROR_BASE_KEY}.assigned_to.organisation_not_related")) end def assigned_to @@ -605,14 +607,14 @@ private def validate_uprn_exists_if_any_key_address_fields_are_blank if field_16.blank? && !key_address_fields_provided? - errors.add(:field_16, I18n.t("validations.not_answered", question: "UPRN.")) + errors.add(:field_16, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "UPRN.")) end end def validate_address_option_found if log.uprn.nil? && field_16.blank? && key_address_fields_provided? %i[field_17 field_18 field_19 field_20 field_21 field_22].each do |field| - errors.add(field, I18n.t("validations.no_address_found")) + errors.add(field, I18n.t("#{ERROR_BASE_KEY}.address.not_found")) end end end @@ -624,19 +626,19 @@ private def validate_address_fields if field_16.blank? || log.errors.attribute_names.include?(:uprn) if field_17.blank? - errors.add(:field_17, I18n.t("validations.not_answered", question: "address line 1.")) + errors.add(:field_17, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "address line 1.")) end if field_19.blank? - errors.add(:field_19, I18n.t("validations.not_answered", question: "town or city.")) + errors.add(:field_19, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "town or city.")) end if field_21.blank? - errors.add(:field_21, I18n.t("validations.not_answered", question: "part 1 of postcode.")) + errors.add(:field_21, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "part 1 of postcode.")) end if field_22.blank? - errors.add(:field_22, I18n.t("validations.not_answered", question: "part 2 of postcode.")) + errors.add(:field_22, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "part 2 of postcode.")) end end end @@ -661,7 +663,7 @@ private def validate_nationality if field_45.present? && !valid_nationality_options.include?(field_45.to_s) - errors.add(:field_45, I18n.t("validations.household.nationality")) + errors.add(:field_45, I18n.t("#{ERROR_BASE_KEY}.nationality.invalid")) end end @@ -682,21 +684,21 @@ private def validate_needs_type_present if field_4.blank? - errors.add(:field_4, I18n.t("validations.not_answered", question: "needs type."), category: :setup) + errors.add(:field_4, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "needs type."), category: :setup) end 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")) - errors.add(:field_84, I18n.t("validations.household.housingneeds.no_and_dont_know_disabled_needs_conjunction")) + errors.add(:field_83, I18n.t("#{ERROR_BASE_KEY}.housingneeds.no_and_dont_know_disabled_needs_conjunction")) + errors.add(:field_84, I18n.t("#{ERROR_BASE_KEY}.housingneeds.no_and_dont_know_disabled_needs_conjunction")) end end def validate_dont_know_disabled_needs_conjunction if field_84 == 1 && [field_79, field_80, field_81, field_82].count(1).positive? %i[field_84 field_79 field_80 field_81 field_82].each do |field| - errors.add(field, I18n.t("validations.household.housingneeds.dont_know_disabled_needs_conjunction")) if send(field) == 1 + errors.add(field, I18n.t("#{ERROR_BASE_KEY}.housingneeds.dont_know_disabled_needs_conjunction")) if send(field) == 1 end end end @@ -704,7 +706,7 @@ private def validate_no_disabled_needs_conjunction if field_83 == 1 && [field_79, field_80, field_81, field_82].count(1).positive? %i[field_83 field_79 field_80 field_81 field_82].each do |field| - errors.add(field, I18n.t("validations.household.housingneeds.no_disabled_needs_conjunction")) if send(field) == 1 + errors.add(field, I18n.t("#{ERROR_BASE_KEY}.housingneeds.no_disabled_needs_conjunction")) if send(field) == 1 end end end @@ -712,17 +714,17 @@ private def validate_only_one_housing_needs_type if [field_79, field_80, field_81].count(1) > 1 %i[field_79 field_80 field_81].each do |field| - errors.add(field, I18n.t("validations.household.housingneeds_type.only_one_option_permitted")) if send(field) == 1 + errors.add(field, I18n.t("#{ERROR_BASE_KEY}.housingneeds_type.only_one_option_permitted")) if send(field) == 1 end end end def validate_no_housing_needs_questions_answered if [field_79, field_80, field_81, field_82, field_83, field_84].all?(&:blank?) - errors.add(:field_83, I18n.t("validations.not_answered", question: "anybody with disabled access needs.")) - errors.add(:field_82, I18n.t("validations.not_answered", question: "other access needs.")) + errors.add(:field_83, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "anybody with disabled access needs.")) + errors.add(:field_82, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "other access needs.")) %i[field_79 field_80 field_81].each do |field| - errors.add(field, I18n.t("validations.not_answered", question: "disabled access needs type.")) + errors.add(field, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "disabled access needs type.")) end end end @@ -731,7 +733,7 @@ private reason_fields = %i[field_107 field_108 field_109 field_110 field_111] if field_106 == 1 && reason_fields.all? { |field| attributes[field.to_s].blank? } reason_fields.each do |field| - errors.add(field, I18n.t("validations.not_answered", question: "reason for reasonable preference.")) + errors.add(field, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "reason for reasonable preference.")) end end end @@ -741,12 +743,12 @@ private if household_no_illness? illness_option_fields.each do |field| if attributes[field.to_s] == 1 - errors.add(field, I18n.t("validations.household.condition_effects.no_choices")) + errors.add(field, I18n.t("#{ERROR_BASE_KEY}.condition_effects.no_choices")) end end elsif illness_option_fields.all? { |field| attributes[field.to_s].blank? } illness_option_fields.each do |field| - errors.add(field, I18n.t("validations.not_answered", question: "how is person affected by condition or illness.")) + errors.add(field, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "how is person affected by condition or illness.")) end end end @@ -757,7 +759,7 @@ private def validate_leaving_reason_for_renewal if field_7 == 1 && ![50, 51, 52, 53].include?(field_98) - errors.add(:field_98, I18n.t("validations.household.reason.renewal_reason_needed_2024")) + errors.add(:field_98, I18n.t("#{ERROR_BASE_KEY}.reason.renewal_reason_needed")) end end @@ -771,13 +773,13 @@ private def validate_cannot_be_la_referral_if_general_needs_and_la if field_116 == 4 && general_needs? && owning_organisation && owning_organisation.la? - errors.add :field_116, I18n.t("validations.household.referral.la_general_needs.prp_referred_by_la") + errors.add :field_116, I18n.t("#{ERROR_BASE_KEY}.referral.general_needs_prp_referred_by_la") end end def validate_la_with_local_housing_referral if field_116 == 3 && owning_organisation && owning_organisation.la? - errors.add(:field_116, I18n.t("validations.household.referral.nominated_by_local_ha_but_la")) + errors.add(:field_116, I18n.t("#{ERROR_BASE_KEY}.referral.nominated_by_local_ha_but_la")) end end @@ -785,15 +787,15 @@ private return if startdate.blank? || bulk_upload.form.blank? 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) + errors.add(:field_8, I18n.t("#{ERROR_BASE_KEY}.startdate.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("#{ERROR_BASE_KEY}.startdate.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("#{ERROR_BASE_KEY}.startdate.outside_collection_window", year_combo: bulk_upload.year_combo, start_year: bulk_upload.year, end_year: bulk_upload.end_year), category: :setup) end end def validate_data_types unless attribute_set["field_11"].value_before_type_cast&.match?(/^\d+\.?0*$/) - errors.add(:field_11, I18n.t("validations.invalid_number", question: "rent type.")) + errors.add(:field_11, I18n.t("#{ERROR_BASE_KEY}.invalid_number", question: "rent type.")) end end @@ -825,14 +827,14 @@ private def validate_related_location_exists if scheme && field_6.present? && location.nil? && :field_6.present? block_log_creation! - errors.add(:field_6, "Location code must relate to a location that is owned by the owning organisation or managing organisation.", category: :setup) + errors.add(:field_6, I18n.t("#{ERROR_BASE_KEY}.location.must_relate_to_org"), category: :setup) end end def validate_related_scheme_exists if field_5.present? && :field_5.present? && owning_organisation.present? && managing_organisation.present? && scheme.nil? block_log_creation! - errors.add(:field_5, "This scheme code does not belong to the owning organisation or managing organisation.", category: :setup) + errors.add(:field_5, I18n.t("#{ERROR_BASE_KEY}.scheme.must_relate_to_org"), category: :setup) end end @@ -841,7 +843,7 @@ private block_log_creation! if errors[:field_2].blank? - errors.add(:field_2, "This managing organisation does not have a relationship with the owning organisation.", category: :setup) + errors.add(:field_2, I18n.t("#{ERROR_BASE_KEY}.managing_organisation.no_relationship"), category: :setup) end end end @@ -851,7 +853,7 @@ private block_log_creation! if field_2.present? && errors[:field_2].blank? - errors.add(:field_2, "The managing organisation code is incorrect.", category: :setup) + errors.add(:field_2, I18n.t("#{ERROR_BASE_KEY}.managing_organisation.not_found"), category: :setup) end end end @@ -859,7 +861,7 @@ private def validate_managing_org_data_given if field_2.blank? block_log_creation! - errors.add(:field_2, I18n.t("validations.not_answered", question: "managing organisation."), category: :setup) + errors.add(:field_2, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "managing organisation."), category: :setup) end end @@ -868,7 +870,7 @@ private block_log_creation! if errors[:field_1].blank? - errors.add(:field_1, "The owning organisation code provided is for an organisation that does not own stock.", category: :setup) + errors.add(:field_1, I18n.t("#{ERROR_BASE_KEY}.owning_organisation.not_stock_owner"), category: :setup) end end end @@ -878,7 +880,7 @@ private block_log_creation! if field_1.present? && errors[:field_1].blank? - errors.add(:field_1, "The owning organisation code is incorrect.", category: :setup) + errors.add(:field_1, I18n.t("#{ERROR_BASE_KEY}.owning_organisation.not_found"), category: :setup) end end end @@ -886,7 +888,7 @@ private def validate_owning_org_data_given if field_1.blank? block_log_creation! - errors.add(:field_1, I18n.t("validations.not_answered", question: "owning organisation."), category: :setup) + errors.add(:field_1, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "owning organisation."), category: :setup) end end @@ -899,9 +901,9 @@ private return if errors[:field_1].present? if bulk_upload.user.support? - errors.add(:field_1, "This owning organisation is not affiliated with #{bulk_upload_organisation.name}.", category: :setup) + errors.add(:field_1, I18n.t("#{ERROR_BASE_KEY}.owning_organisation.not_permitted.support", org_name: bulk_upload_organisation.name), category: :setup) else - errors.add(:field_1, "You do not have permission to add logs for this owning organisation.", category: :setup) + errors.add(:field_1, I18n.t("#{ERROR_BASE_KEY}.owning_organisation.not_permitted.not_support"), category: :setup) end end @@ -916,12 +918,12 @@ private }.partition { |field, _| public_send(field).blank? }.map(&:to_h) blank_charge_fields.each do |field, charge| - errors.add(field, I18n.t("validations.financial.charges.missing_charges", sentence_fragment: charge)) + errors.add(field, I18n.t("#{ERROR_BASE_KEY}.charges.missing_charges", sentence_fragment: charge)) end other_charge_fields.each do |field, _charge| blank_charge_fields.each do |_blank_field, blank_charge| - errors.add(field, I18n.t("validations.financial.charges.missing_charges", sentence_fragment: blank_charge)) + errors.add(field, I18n.t("#{ERROR_BASE_KEY}.charges.missing_charges", sentence_fragment: blank_charge)) end end end @@ -936,7 +938,7 @@ private def validate_if_log_already_exists if log_already_exists? - error_message = "This is a duplicate log." + error_message = I18n.t("#{ERROR_BASE_KEY}.duplicate") errors.add(:field_1, error_message) # owning_organisation errors.add(:field_8, error_message) # startdate diff --git a/app/services/bulk_upload/processor.rb b/app/services/bulk_upload/processor.rb index 83a8d1ca0..38f67ede4 100644 --- a/app/services/bulk_upload/processor.rb +++ b/app/services/bulk_upload/processor.rb @@ -1,15 +1,24 @@ class BulkUpload::Processor + include CollectionTimeHelper attr_reader :bulk_upload - BLANK_TEMPLATE_ERRORS = [ - I18n.t("activemodel.errors.models.bulk_upload/lettings/validator.attributes.base.blank_file"), - I18n.t("activemodel.errors.models.bulk_upload/sales/validator.attributes.base.blank_file"), - ].freeze + def blank_template_errors + [ + I18n.t("validations.lettings.#{current_collection_start_year}.bulk_upload.blank_file"), + I18n.t("validations.lettings.#{previous_collection_start_year}.bulk_upload.blank_file"), + I18n.t("validations.sales.#{current_collection_start_year}.bulk_upload.blank_file"), + I18n.t("validations.sales.#{previous_collection_start_year}.bulk_upload.blank_file"), + ].freeze + end - WRONG_TEMPLATE_ERRORS = [ - *I18n.t("activemodel.errors.models.bulk_upload/lettings/validator.attributes.base", default: {}).values, - *I18n.t("activemodel.errors.models.bulk_upload/sales/validator.attributes.base", default: {}).values, - ].freeze + def wrong_template_errors + [ + *I18n.t("validations.lettings.#{current_collection_start_year}.bulk_upload.wrong_template", default: {}).values, + *I18n.t("validations.lettings.#{previous_collection_start_year}.bulk_upload.wrong_template", default: {}).values, + *I18n.t("validations.sales.#{current_collection_start_year}.bulk_upload.wrong_template", default: {}).values, + *I18n.t("validations.sales.#{previous_collection_start_year}.bulk_upload.wrong_template", default: {}).values, + ].freeze + end def initialize(bulk_upload:) @bulk_upload = bulk_upload @@ -157,9 +166,9 @@ private end def handle_invalid_validator - if BLANK_TEMPLATE_ERRORS.any? { |error| validator.errors.full_messages.include?(error) } + if blank_template_errors.any? { |error| validator.errors.full_messages.include?(error) } @bulk_upload.update!(failure_reason: "blank_template") - elsif WRONG_TEMPLATE_ERRORS.any? { |error| validator.errors.full_messages.include?(error) } + elsif wrong_template_errors.any? { |error| validator.errors.full_messages.include?(error) } @bulk_upload.update!(failure_reason: "wrong_template") end diff --git a/app/services/bulk_upload/sales/log_creator.rb b/app/services/bulk_upload/sales/log_creator.rb index 2d0888e4d..ea337d220 100644 --- a/app/services/bulk_upload/sales/log_creator.rb +++ b/app/services/bulk_upload/sales/log_creator.rb @@ -14,7 +14,7 @@ class BulkUpload::Sales::LogCreator row_parser.log.blank_invalid_non_setup_fields! row_parser.log.bulk_upload = bulk_upload - row_parser.log.creation_method_bulk_upload! + row_parser.log.creation_method = "bulk upload" row_parser.log.skip_update_status = true row_parser.log.status = "pending" row_parser.log.status_cache = row_parser.log.calculate_status diff --git a/app/services/bulk_upload/sales/validator.rb b/app/services/bulk_upload/sales/validator.rb index a473a6461..76fb6f1ae 100644 --- a/app/services/bulk_upload/sales/validator.rb +++ b/app/services/bulk_upload/sales/validator.rb @@ -153,7 +153,7 @@ private def validate_file_not_empty if File.size(path).zero? || csv_parser.body_rows.flatten.compact.empty? - errors.add(:base, :blank_file) + errors.add(:base, I18n.t("validations.sales.#{@bulk_upload.year}.bulk_upload.blank_file")) halt_validations! end @@ -164,20 +164,20 @@ private column_count = rows.map(&:size).max - errors.add(:base, :over_max_column_count) if column_count > csv_parser.class::MAX_COLUMNS + errors.add(:base, I18n.t("validations.sales.#{@bulk_upload.year}.bulk_upload.wrong_template.over_max_column_count")) if column_count > csv_parser.class::MAX_COLUMNS end def validate_correct_template return if halt_validations? - errors.add(:base, :wrong_template) if csv_parser.wrong_template_for_year? + errors.add(:base, I18n.t("validations.sales.#{@bulk_upload.year}.bulk_upload.wrong_template.wrong_template")) if csv_parser.wrong_template_for_year? end def validate_missing_required_headers return if halt_validations? if csv_parser.missing_required_headers? - errors.add :base, I18n.t("activemodel.errors.models.bulk_upload/sales/validator.attributes.base.no_headers", guidance_link: bulk_upload_sales_log_url(id: "guidance", form: { year: bulk_upload.year }, host: ENV["APP_HOST"], anchor: "using-the-bulk-upload-template")) + errors.add :base, I18n.t("validations.sales.#{@bulk_upload.year}.bulk_upload.wrong_template.no_headers", guidance_link: bulk_upload_sales_log_url(id: "guidance", form: { year: bulk_upload.year }, host: ENV["APP_HOST"], anchor: "using-the-bulk-upload-template")) end end @@ -185,7 +185,7 @@ private return if halt_validations? unless csv_parser.correct_field_count? - errors.add(:base, :wrong_field_numbers_count) + errors.add(:base, I18n.t("validations.sales.#{@bulk_upload.year}.bulk_upload.wrong_template.wrong_field_numbers_count")) halt_validations! 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 d87c94dce..39fb41d6b 100644 --- a/app/services/bulk_upload/sales/year2023/row_parser.rb +++ b/app/services/bulk_upload/sales/year2023/row_parser.rb @@ -155,6 +155,8 @@ class BulkUpload::Sales::Year2023::RowParser field_135: "What are the total monthly leasehold charges for the property?", }.freeze + ERROR_BASE_KEY = "validations.sales.2023.bulk_upload".freeze + attribute :bulk_upload attribute :block_log_creation, :boolean, default: -> { false } @@ -311,32 +313,32 @@ class BulkUpload::Sales::Year2023::RowParser validates :field_3, presence: { - message: I18n.t("validations.not_answered", question: "sale completion date (day)."), + message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "sale completion date (day)."), category: :setup, }, on: :after_log validates :field_4, presence: { - message: I18n.t("validations.not_answered", question: "sale completion date (month)."), + message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "sale completion date (month)."), category: :setup, }, on: :after_log validates :field_5, presence: { - message: I18n.t("validations.not_answered", question: "sale completion date (year)."), + message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "sale completion date (year)."), category: :setup, }, format: { with: /\A(\d{2}|\d{4})\z/, - message: I18n.t("validations.setup.saledate.year_not_two_or_four_digits"), + message: I18n.t("#{ERROR_BASE_KEY}.saledate.year_not_two_or_four_digits"), category: :setup, if: proc { field_5.present? }, }, on: :after_log validates :field_7, presence: { - message: I18n.t("validations.not_answered", question: "purchase made under ownership scheme."), + message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "purchase made under ownership scheme."), category: :setup, }, on: :after_log @@ -352,7 +354,7 @@ class BulkUpload::Sales::Year2023::RowParser validates :field_8, presence: { - message: I18n.t("validations.not_answered", question: "type of shared ownership sale."), + message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "type of shared ownership sale."), category: :setup, if: :shared_ownership?, }, @@ -369,7 +371,7 @@ class BulkUpload::Sales::Year2023::RowParser validates :field_9, presence: { - message: I18n.t("validations.not_answered", question: "type of discounted ownership sale."), + message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "type of discounted ownership sale."), category: :setup, if: :discounted_ownership?, }, @@ -386,7 +388,7 @@ class BulkUpload::Sales::Year2023::RowParser validates :field_10, presence: { - message: I18n.t("validations.not_answered", question: "type of outright sale."), + message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "type of outright sale."), category: :setup, if: :outright_sale?, }, @@ -394,7 +396,7 @@ class BulkUpload::Sales::Year2023::RowParser validates :field_11, presence: { - message: I18n.t("validations.not_answered", question: "type of outright sale."), + message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "type of outright sale."), category: :setup, if: proc { field_10 == 12 }, }, @@ -411,7 +413,7 @@ class BulkUpload::Sales::Year2023::RowParser validates :field_12, presence: { - message: I18n.t("validations.not_answered", question: "company buyer."), + message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "company buyer."), category: :setup, if: :outright_sale?, }, @@ -428,7 +430,7 @@ class BulkUpload::Sales::Year2023::RowParser validates :field_13, presence: { - message: I18n.t("validations.not_answered", question: "buyers living in property."), + message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "buyers living in property."), category: :setup, if: :outright_sale?, }, @@ -436,7 +438,7 @@ class BulkUpload::Sales::Year2023::RowParser validates :field_14, presence: { - message: I18n.t("validations.not_answered", question: "joint purchase."), + message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "joint purchase."), category: :setup, if: :joint_purchase_asked?, }, @@ -444,7 +446,7 @@ class BulkUpload::Sales::Year2023::RowParser validates :field_15, presence: { - message: I18n.t("validations.not_answered", question: "more than 2 joint buyers."), + message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "more than 2 joint buyers."), category: :setup, if: :joint_purchase?, }, @@ -560,7 +562,7 @@ class BulkUpload::Sales::Year2023::RowParser def add_duplicate_found_in_spreadsheet_errors spreadsheet_duplicate_hash.each_key do |field| - errors.add(field, :spreadsheet_dupe, category: :setup) + errors.add(field, I18n.t("#{ERROR_BASE_KEY}.spreadsheet_dupe"), category: :setup) end end @@ -568,7 +570,7 @@ private def validate_data_protection_answered unless field_29 == 1 - errors.add(:field_29, I18n.t("validations.not_answered", question: "Data Protection question."), category: :setup) + errors.add(:field_29, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "Data Protection question."), category: :setup) end end @@ -600,18 +602,19 @@ private def validate_uprn_exists_if_any_key_address_fields_are_blank if field_19.blank? && (field_20.blank? || field_22.blank?) - errors.add(:field_19, I18n.t("validations.not_answered", question: "UPRN."), category: :not_answered) + # I18n.t("#{ERROR_BASE_KEY}.not_answered", question: question.error_display_label) + errors.add(:field_19, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "UPRN."), category: :not_answered) end end def validate_address_fields if field_19.blank? || log.errors.attribute_names.include?(:uprn) if field_20.blank? - errors.add(:field_20, I18n.t("validations.not_answered", question: "address line 1."), category: :not_answered) + errors.add(:field_20, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "address line 1."), category: :not_answered) end if field_22.blank? - errors.add(:field_22, I18n.t("validations.not_answered", question: "town or city."), category: :not_answered) + errors.add(:field_22, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "town or city."), category: :not_answered) end end end @@ -1162,7 +1165,7 @@ private block_log_creation! if errors[:field_1].blank? - errors.add(:field_1, "The owning organisation code is incorrect.", category: :setup) + errors.add(:field_1, I18n.t("#{ERROR_BASE_KEY}.owning_organisation.not_answered"), category: :setup) end end end @@ -1172,7 +1175,7 @@ private block_log_creation! if errors[:field_1].blank? - errors.add(:field_1, "The owning organisation code is incorrect.", category: :setup) + errors.add(:field_1, I18n.t("#{ERROR_BASE_KEY}.owning_organisation.not_found"), category: :setup) end end end @@ -1182,7 +1185,7 @@ private block_log_creation! if errors[:field_1].blank? - errors.add(:field_1, "The owning organisation code provided is for an organisation that does not own stock.", category: :setup) + errors.add(:field_1, I18n.t("#{ERROR_BASE_KEY}.owning_organisation.not_stock_owner"), category: :setup) end end end @@ -1192,7 +1195,7 @@ private block_log_creation! if errors[:field_1].blank? - errors.add(:field_1, "You do not have permission to add logs for this owning organisation.", category: :setup) + errors.add(:field_1, I18n.t("#{ERROR_BASE_KEY}.owning_organisation.not_permitted"), category: :setup) end end end @@ -1201,7 +1204,7 @@ private return if field_2.blank? unless assigned_to - errors.add(:field_2, "User with the specified email could not be found.") + errors.add(:field_2, I18n.t("#{ERROR_BASE_KEY}.assigned_to.not_found")) end end @@ -1211,7 +1214,7 @@ private return if assigned_to.organisation == owning_organisation&.absorbing_organisation || assigned_to.organisation == managing_organisation&.absorbing_organisation block_log_creation! - errors.add(:field_2, "User must be related to owning organisation or managing organisation.", category: :setup) + errors.add(:field_2, I18n.t("#{ERROR_BASE_KEY}.assigned_to.organisation_not_related"), category: :setup) end def managing_organisation @@ -1225,7 +1228,7 @@ private block_log_creation! if errors[:field_2].blank? - errors.add(:field_2, "This user belongs to an organisation that does not have a relationship with the owning organisation.", category: :setup) + errors.add(:field_2, I18n.t("#{ERROR_BASE_KEY}.assigned_to.managing_organisation_not_related"), category: :setup) end end end @@ -1246,13 +1249,13 @@ private if setup_question?(question) fields.each do |field| unless errors.any? { |e| fields.include?(e.attribute) } - errors.add(field, I18n.t("validations.not_answered", question: question.error_display_label), category: :setup) + errors.add(field, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: question.error_display_label), category: :setup) end end else fields.each do |field| unless errors.any? { |e| fields.include?(e.attribute) } - errors.add(field, I18n.t("validations.not_answered", question: question.error_display_label), category: :not_answered) + errors.add(field, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: question.error_display_label), category: :not_answered) end end end @@ -1272,15 +1275,15 @@ private if setup_question?(question) fields.each do |field| - if errors[field].none? - block_log_creation! - errors.add(field, I18n.t("validations.invalid_option", question: format_ending(QUESTIONS[field])), category: :setup) - end + next unless errors[field].none? + + block_log_creation! + errors.add(field, I18n.t("#{ERROR_BASE_KEY}.invalid_option", question: format_ending(QUESTIONS[field])), category: :setup) end else fields.each do |field| unless errors.any? { |e| fields.include?(e.attribute) } - errors.add(field, I18n.t("validations.invalid_option", question: format_ending(QUESTIONS[field]))) + errors.add(field, I18n.t("#{ERROR_BASE_KEY}.invalid_option", question: format_ending(QUESTIONS[field]))) end end end @@ -1292,15 +1295,15 @@ private return if errors.key?(:field_3) || errors.key?(:field_4) || errors.key?(:field_5) unless bulk_upload.form.valid_start_date_for_form?(saledate) - errors.add(:field_3, 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_4, 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_5, 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_3, I18n.t("#{ERROR_BASE_KEY}.saledate.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_4, I18n.t("#{ERROR_BASE_KEY}.saledate.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_5, I18n.t("#{ERROR_BASE_KEY}.saledate.outside_collection_window", year_combo: bulk_upload.year_combo, start_year: bulk_upload.year, end_year: bulk_upload.end_year), category: :setup) end end def validate_if_log_already_exists if log_already_exists? - error_message = "This is a duplicate log." + error_message = I18n.t("#{ERROR_BASE_KEY}.duplicate") errors.add(:field_1, error_message) # Owning org errors.add(:field_3, error_message) # Sale completion date @@ -1335,7 +1338,7 @@ private def validate_buyer1_economic_status if field_35 == 9 - errors.add(:field_35, "Buyer 1 cannot be a child under 16.") + errors.add(:field_35, I18n.t("#{ERROR_BASE_KEY}.ecstat1.child_under_16")) 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 7b72eef5c..fdef65aec 100644 --- a/app/services/bulk_upload/sales/year2024/row_parser.rb +++ b/app/services/bulk_upload/sales/year2024/row_parser.rb @@ -151,6 +151,8 @@ class BulkUpload::Sales::Year2024::RowParser field_131: "What are the total monthly leasehold charges for the property?", }.freeze + ERROR_BASE_KEY = "validations.sales.2024.bulk_upload".freeze + attribute :bulk_upload attribute :block_log_creation, :boolean, default: -> { false } @@ -303,32 +305,32 @@ class BulkUpload::Sales::Year2024::RowParser validates :field_4, presence: { - message: I18n.t("validations.not_answered", question: "sale completion date (day)."), + message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "sale completion date (day)."), category: :setup, }, on: :after_log validates :field_5, presence: { - message: I18n.t("validations.not_answered", question: "sale completion date (month)."), + message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "sale completion date (month)."), category: :setup, }, on: :after_log validates :field_6, presence: { - message: I18n.t("validations.not_answered", question: "sale completion date (year)."), + message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "sale completion date (year)."), category: :setup, }, format: { with: /\A(\d{2}|\d{4})\z/, - message: I18n.t("validations.setup.saledate.year_not_two_or_four_digits"), + message: I18n.t("#{ERROR_BASE_KEY}.saledate.year_not_two_or_four_digits"), category: :setup, if: proc { field_6.present? }, }, on: :after_log validates :field_8, presence: { - message: I18n.t("validations.not_answered", question: "purchase made under ownership scheme."), + message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "purchase made under ownership scheme."), category: :setup, }, on: :after_log @@ -344,7 +346,7 @@ class BulkUpload::Sales::Year2024::RowParser validates :field_9, presence: { - message: I18n.t("validations.not_answered", question: "type of shared ownership sale."), + message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "type of shared ownership sale."), category: :setup, if: :shared_ownership?, }, @@ -361,7 +363,7 @@ class BulkUpload::Sales::Year2024::RowParser validates :field_10, presence: { - message: I18n.t("validations.not_answered", question: "type of discounted ownership sale."), + message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "type of discounted ownership sale."), category: :setup, if: :discounted_ownership?, }, @@ -369,7 +371,7 @@ class BulkUpload::Sales::Year2024::RowParser validates :field_116, numericality: { - message: I18n.t("validations.numeric.within_range", field: "Percentage discount", min: "0%", max: "70%"), + message: I18n.t("#{ERROR_BASE_KEY}.numeric.within_range", field: "Percentage discount", min: "0%", max: "70%"), greater_than_or_equal_to: 0, less_than_or_equal_to: 70, if: :discounted_ownership?, @@ -387,7 +389,7 @@ class BulkUpload::Sales::Year2024::RowParser validates :field_11, presence: { - message: I18n.t("validations.not_answered", question: "type of outright sale."), + message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "type of outright sale."), category: :setup, if: :outright_sale?, }, @@ -395,7 +397,7 @@ class BulkUpload::Sales::Year2024::RowParser validates :field_12, presence: { - message: I18n.t("validations.not_answered", question: "type of outright sale."), + message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "type of outright sale."), category: :setup, if: proc { field_11 == 12 }, }, @@ -412,7 +414,7 @@ class BulkUpload::Sales::Year2024::RowParser validates :field_13, presence: { - message: I18n.t("validations.not_answered", question: "company buyer."), + message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "company buyer."), category: :setup, if: :outright_sale?, }, @@ -429,7 +431,7 @@ class BulkUpload::Sales::Year2024::RowParser validates :field_14, presence: { - message: I18n.t("validations.not_answered", question: "buyers living in property."), + message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "buyers living in property."), category: :setup, if: :outright_sale?, }, @@ -437,7 +439,7 @@ class BulkUpload::Sales::Year2024::RowParser validates :field_15, presence: { - message: I18n.t("validations.not_answered", question: "joint purchase."), + message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "joint purchase."), category: :setup, if: :joint_purchase_asked?, }, @@ -445,7 +447,7 @@ class BulkUpload::Sales::Year2024::RowParser validates :field_16, presence: { - message: I18n.t("validations.not_answered", question: "more than 2 joint buyers."), + message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "more than 2 joint buyers."), category: :setup, if: :joint_purchase?, }, @@ -569,7 +571,7 @@ class BulkUpload::Sales::Year2024::RowParser def add_duplicate_found_in_spreadsheet_errors spreadsheet_duplicate_hash.each_key do |field| - errors.add(field, :spreadsheet_dupe, category: :setup) + errors.add(field, I18n.t("#{ERROR_BASE_KEY}.spreadsheet_dupe"), category: :setup) end end @@ -603,14 +605,14 @@ private def validate_uprn_exists_if_any_key_address_fields_are_blank if field_22.blank? && !key_address_fields_provided? - errors.add(:field_22, I18n.t("validations.not_answered", question: "UPRN.")) + errors.add(:field_22, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "UPRN.")) end end def validate_address_option_found if log.uprn.nil? && field_22.blank? && key_address_fields_provided? %i[field_23 field_24 field_25 field_26 field_27 field_28].each do |field| - errors.add(field, I18n.t("validations.no_address_found")) + errors.add(field, I18n.t("#{ERROR_BASE_KEY}.address.not_found")) end end end @@ -622,19 +624,19 @@ private def validate_address_fields if field_22.blank? || log.errors.attribute_names.include?(:uprn) if field_23.blank? - errors.add(:field_23, I18n.t("validations.not_answered", question: "address line 1.")) + errors.add(:field_23, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "address line 1.")) end if field_25.blank? - errors.add(:field_25, I18n.t("validations.not_answered", question: "town or city.")) + errors.add(:field_25, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "town or city.")) end if field_27.blank? - errors.add(:field_27, I18n.t("validations.not_answered", question: "part 1 of postcode.")) + errors.add(:field_27, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "part 1 of postcode.")) end if field_28.blank? - errors.add(:field_28, I18n.t("validations.not_answered", question: "part 2 of postcode.")) + errors.add(:field_28, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "part 2 of postcode.")) end end end @@ -1281,7 +1283,7 @@ private block_log_creation! if errors[:field_1].blank? - errors.add(:field_1, I18n.t("validations.not_answered", question: "owning organisation."), category: :setup) + errors.add(:field_1, I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "owning organisation."), category: :setup) end end end @@ -1291,7 +1293,7 @@ private block_log_creation! if field_1.present? && errors[:field_1].blank? - errors.add(:field_1, "The owning organisation code is incorrect.", category: :setup) + errors.add(:field_1, I18n.t("#{ERROR_BASE_KEY}.owning_organisation.not_found"), category: :setup) end end end @@ -1301,7 +1303,7 @@ private block_log_creation! if errors[:field_1].blank? - errors.add(:field_1, "The owning organisation code provided is for an organisation that does not own stock.", category: :setup) + errors.add(:field_1, I18n.t("#{ERROR_BASE_KEY}.owning_organisation.not_stock_owner"), category: :setup) end end end @@ -1315,9 +1317,9 @@ private return if errors[:field_1].present? if bulk_upload.user.support? - errors.add(:field_1, "This owning organisation is not affiliated with #{bulk_upload_organisation.name}.", category: :setup) + errors.add(:field_1, I18n.t("#{ERROR_BASE_KEY}.owning_organisation.not_permitted.support", name: bulk_upload_organisation.name), category: :setup) else - errors.add(:field_1, "You do not have permission to add logs for this owning organisation.", category: :setup) + errors.add(:field_1, I18n.t("#{ERROR_BASE_KEY}.owning_organisation.not_permitted.not_support"), category: :setup) end end @@ -1325,13 +1327,13 @@ private return if field_3.blank? unless assigned_to - errors.add(:field_3, "User with the specified email could not be found.") + errors.add(:field_3, I18n.t("#{ERROR_BASE_KEY}.assigned_to.not_found")) end end def validate_assigned_to_when_support if field_3.blank? && bulk_upload.user.support? - errors.add(:field_3, category: :setup, message: I18n.t("validations.not_answered", question: "what is the CORE username of the account this sales log should be assigned to?")) + errors.add(:field_3, category: :setup, message: I18n.t("#{ERROR_BASE_KEY}.not_answered", question: "what is the CORE username of the account this sales log should be assigned to?")) end end @@ -1341,7 +1343,7 @@ private return if assigned_to.organisation == owning_organisation&.absorbing_organisation || assigned_to.organisation == managing_organisation&.absorbing_organisation block_log_creation! - errors.add(:field_3, "User must be related to owning organisation or managing organisation.", category: :setup) + errors.add(:field_3, I18n.t("#{ERROR_BASE_KEY}.assigned_to.organisation_not_related"), category: :setup) end def managing_organisation @@ -1361,7 +1363,7 @@ private block_log_creation! if errors[:field_2].blank? - errors.add(:field_2, "This organisation does not have a relationship with the owning organisation.", category: :setup) + errors.add(:field_2, I18n.t("#{ERROR_BASE_KEY}.assigned_to.managing_organisation_not_related"), category: :setup) end end end @@ -1410,13 +1412,13 @@ private fields.each do |field| if errors[field].none? block_log_creation! - errors.add(field, I18n.t("validations.invalid_option", question: format_ending(QUESTIONS[field])), category: :setup) + errors.add(field, I18n.t("#{ERROR_BASE_KEY}.invalid_option", question: format_ending(QUESTIONS[field])), category: :setup) end end else fields.each do |field| unless errors.any? { |e| fields.include?(e.attribute) } - errors.add(field, I18n.t("validations.invalid_option", question: format_ending(QUESTIONS[field]))) + errors.add(field, I18n.t("#{ERROR_BASE_KEY}.invalid_option", question: format_ending(QUESTIONS[field]))) end end end @@ -1428,15 +1430,15 @@ private return if errors.key?(:field_4) || errors.key?(:field_5) || errors.key?(:field_6) unless bulk_upload.form.valid_start_date_for_form?(saledate) - errors.add(:field_4, 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_5, 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_6, 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_4, I18n.t("#{ERROR_BASE_KEY}.saledate.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_5, I18n.t("#{ERROR_BASE_KEY}.saledate.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_6, I18n.t("#{ERROR_BASE_KEY}.saledate.outside_collection_window", year_combo: bulk_upload.year_combo, start_year: bulk_upload.year, end_year: bulk_upload.end_year), category: :setup) end end def validate_if_log_already_exists if log_already_exists? - error_message = "This is a duplicate log." + error_message = I18n.t("#{ERROR_BASE_KEY}.duplicate") errors.add(:field_1, error_message) # Owning org errors.add(:field_4, error_message) # Sale completion date @@ -1472,10 +1474,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.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")) + errors.add(:field_35, I18n.t("#{ERROR_BASE_KEY}.ecstat1.buyer_cannot_be_over_16_and_child")) + errors.add(:field_31, I18n.t("#{ERROR_BASE_KEY}.age1.buyer_cannot_be_over_16_and_child")) else - errors.add(:field_35, I18n.t("validations.sales.household.ecstat1.buyer_cannot_be_child")) + errors.add(:field_35, I18n.t("#{ERROR_BASE_KEY}.ecstat1.buyer_cannot_be_child")) end end end @@ -1485,23 +1487,23 @@ private if field_42 == 9 if field_38.present? && field_38.to_i >= 16 - 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")) + errors.add(:field_42, I18n.t("#{ERROR_BASE_KEY}.ecstat2.buyer_cannot_be_over_16_and_child")) + errors.add(:field_38, I18n.t("#{ERROR_BASE_KEY}.age2.buyer_cannot_be_over_16_and_child")) else - errors.add(:field_42, I18n.t("validations.sales.household.ecstat2.buyer_cannot_be_child")) + errors.add(:field_42, I18n.t("#{ERROR_BASE_KEY}.ecstat2.buyer_cannot_be_child")) end end end def validate_nationality if field_34.present? && !valid_nationality_options.include?(field_34.to_s) - errors.add(:field_34, I18n.t("validations.household.nationality")) + errors.add(:field_34, I18n.t("#{ERROR_BASE_KEY}.nationality.invalid")) end end def validate_buyer_2_nationality if field_41.present? && !valid_nationality_options.include?(field_41.to_s) - errors.add(:field_41, I18n.t("validations.household.nationality")) + errors.add(:field_41, I18n.t("#{ERROR_BASE_KEY}.nationality.invalid")) end end diff --git a/app/services/exports/lettings_log_export_service.rb b/app/services/exports/lettings_log_export_service.rb index b21099a06..97f495e0c 100644 --- a/app/services/exports/lettings_log_export_service.rb +++ b/app/services/exports/lettings_log_export_service.rb @@ -146,8 +146,8 @@ module Exports field_name.starts_with?(details_known_prefix) || pattern_age.match(field_name) || !EXPORT_FIELDS.include?(field_name) || - (lettings_log.form.start_year_after_2024? && PRE_2024_EXPORT_FIELDS.include?(field_name)) || - (!lettings_log.form.start_year_after_2024? && POST_2024_EXPORT_FIELDS.include?(field_name)) + (lettings_log.form.start_year_2024_or_later? && PRE_2024_EXPORT_FIELDS.include?(field_name)) || + (!lettings_log.form.start_year_2024_or_later? && POST_2024_EXPORT_FIELDS.include?(field_name)) end def build_export_xml(lettings_logs) diff --git a/app/services/feature_toggle.rb b/app/services/feature_toggle.rb index 5312d1964..1b67b8b37 100644 --- a/app/services/feature_toggle.rb +++ b/app/services/feature_toggle.rb @@ -1,6 +1,6 @@ class FeatureToggle def self.allow_future_form_use? - false + Rails.env.development? || Rails.env.review? || Rails.env.staging? end def self.bulk_upload_duplicate_log_check_enabled? diff --git a/app/views/logs/_create_for_org_actions.html.erb b/app/views/logs/_create_for_org_actions.html.erb index 9b5935cb0..76b8f7d0d 100644 --- a/app/views/logs/_create_for_org_actions.html.erb +++ b/app/views/logs/_create_for_org_actions.html.erb @@ -1,13 +1,13 @@ -