diff --git a/app/components/check_answers_summary_list_card_component.html.erb b/app/components/check_answers_summary_list_card_component.html.erb index 0005ed790..e5b5388ab 100644 --- a/app/components/check_answers_summary_list_card_component.html.erb +++ b/app/components/check_answers_summary_list_card_component.html.erb @@ -5,6 +5,7 @@

<%= check_answers_card_title(applicable_questions.first) %>

<% end %> +
<%= govuk_summary_list do |summary_list| %> <% applicable_questions.each do |question| %> @@ -12,15 +13,20 @@ <% row.key { question.check_answer_label.to_s.presence || question.header.to_s } %> <% row.value do %> <%= get_answer_label(question) %> + <% extra_value = question.get_extra_check_answer_value(log) %> + <% if extra_value %> <%= extra_value %> <% end %> +
+ <% question.get_inferred_answers(log).each do |inferred_answer| %> <%= inferred_answer %> <% end %> <% end %> + <% if @log.collection_period_open? %> <% row.action( text: question.action_text(log), diff --git a/app/components/check_answers_summary_list_card_component.rb b/app/components/check_answers_summary_list_card_component.rb index 113303ba0..874ac8c10 100644 --- a/app/components/check_answers_summary_list_card_component.rb +++ b/app/components/check_answers_summary_list_card_component.rb @@ -5,6 +5,7 @@ class CheckAnswersSummaryListCardComponent < ViewComponent::Base @questions = questions @log = log @user = user + super end @@ -13,7 +14,7 @@ class CheckAnswersSummaryListCardComponent < ViewComponent::Base end def get_answer_label(question) - question.answer_label(log, user).presence || "You didn’t answer this question".html_safe + question.answer_label(log, user).presence || unanswered_value end def check_answers_card_title(question) @@ -36,6 +37,18 @@ class CheckAnswersSummaryListCardComponent < ViewComponent::Base private + def unanswered_value + if bulk_uploaded? + "You still need to answer this question".html_safe + else + "You didn’t answer this question".html_safe + end + end + + def bulk_uploaded? + log.bulk_upload + end + def number_of_buyers log[:jointpur] == 1 ? 2 : 1 end diff --git a/app/controllers/lettings_logs_controller.rb b/app/controllers/lettings_logs_controller.rb index a7bc2dc56..5181d21ca 100644 --- a/app/controllers/lettings_logs_controller.rb +++ b/app/controllers/lettings_logs_controller.rb @@ -119,8 +119,8 @@ private end def extract_bulk_upload_from_session_filters - id = ((@session_filters["bulk_upload_id"] || []).reject(&:blank?))[0] - @bulk_upload = current_user.bulk_uploads.find_by(id:) + filter_service = FilterService.new(current_user:, session:) + @bulk_upload = filter_service.bulk_upload end def permitted_log_params diff --git a/app/frontend/styles/application.scss b/app/frontend/styles/application.scss index 93d6dd99a..03a6ab6f2 100644 --- a/app/frontend/styles/application.scss +++ b/app/frontend/styles/application.scss @@ -51,6 +51,10 @@ $govuk-breakpoints: ( color: $govuk-secondary-text-colour !important; } +.app-\!-colour-red { + color: govuk-colour("red"); +} + .app-\!-font-tabular { @include govuk-font($size: false, $tabular: true); } diff --git a/app/helpers/collection_time_helper.rb b/app/helpers/collection_time_helper.rb new file mode 100644 index 000000000..8478d06e7 --- /dev/null +++ b/app/helpers/collection_time_helper.rb @@ -0,0 +1,16 @@ +module CollectionTimeHelper + def current_collection_start_year + today = Time.zone.now + window_end_date = Time.zone.local(today.year, 4, 1) + today < window_end_date ? today.year - 1 : today.year + end + + def collection_start_date(date) + window_end_date = Time.zone.local(date.year, 4, 1) + date < window_end_date ? Time.zone.local(date.year - 1, 4, 1) : Time.zone.local(date.year, 4, 1) + end + + def current_collection_start_date + Time.zone.local(current_collection_start_year, 4, 1) + end +end diff --git a/app/mailers/bulk_upload_mailer.rb b/app/mailers/bulk_upload_mailer.rb index 5ab0d70b0..ac8f626f3 100644 --- a/app/mailers/bulk_upload_mailer.rb +++ b/app/mailers/bulk_upload_mailer.rb @@ -1,20 +1,34 @@ class BulkUploadMailer < NotifyMailer + include ActionView::Helpers::TextHelper + BULK_UPLOAD_COMPLETE_TEMPLATE_ID = "83279578-c890-4168-838b-33c9cf0dc9f0".freeze BULK_UPLOAD_FAILED_CSV_ERRORS_TEMPLATE_ID = "e27abcd4-5295-48c2-b127-e9ee4b781b75".freeze BULK_UPLOAD_FAILED_FILE_SETUP_ERROR_TEMPLATE_ID = "24c9f4c7-96ad-470a-ba31-eb51b7cbafd9".freeze BULK_UPLOAD_FAILED_SERVICE_ERROR_TEMPLATE_ID = "c3f6288c-7a74-4e77-99ee-6c4a0f6e125a".freeze BULK_UPLOAD_WITH_ERRORS_TEMPLATE_ID = "eb539005-6234-404e-812d-167728cf4274".freeze - def send_bulk_upload_complete_mail(user, bulk_upload) + def send_bulk_upload_complete_mail(user:, bulk_upload:) + url = if bulk_upload.lettings? + lettings_logs_url + else + sales_logs_url + end + + n_logs = pluralize(bulk_upload.logs.count, "log") + + title = "You’ve successfully uploaded #{n_logs}" + + success_description = "The #{bulk_upload.log_type} #{bulk_upload.year_combo} data you uploaded has been checked. The #{n_logs} you uploaded are now complete." + send_email( user.email, BULK_UPLOAD_COMPLETE_TEMPLATE_ID, { - title: "[#{bulk_upload} title]", - filename: "[#{bulk_upload} filename]", - upload_timestamp: "[#{bulk_upload} upload_timestamp]", - success_description: "[#{bulk_upload} success_description]", - logs_link: "[#{bulk_upload} logs_link]", + title:, + filename: bulk_upload.filename, + upload_timestamp: bulk_upload.created_at, + success_description:, + logs_link: url, }, ) end @@ -49,16 +63,22 @@ class BulkUploadMailer < NotifyMailer ) end - def send_bulk_upload_failed_service_error_mail(user, bulk_upload) + def send_bulk_upload_failed_service_error_mail(bulk_upload:) + bulk_upload_link = if bulk_upload.lettings? + start_bulk_upload_lettings_logs_url + else + start_bulk_upload_sales_logs_url + end + send_email( - user.email, + bulk_upload.user.email, BULK_UPLOAD_FAILED_SERVICE_ERROR_TEMPLATE_ID, { - filename: "[#{bulk_upload} filename]", - upload_timestamp: "[#{bulk_upload} upload_timestamp]", - lettings_or_sales: "[#{bulk_upload} lettings_or_sales]", - year_combo: "[#{bulk_upload} year_combo]", - bulk_upload_link: "[#{bulk_upload} bulk_upload_link]", + filename: bulk_upload.filename, + upload_timestamp: bulk_upload.created_at, + lettings_or_sales: bulk_upload.log_type, + year_combo: bulk_upload.year_combo, + bulk_upload_link:, }, ) end diff --git a/app/models/bulk_upload.rb b/app/models/bulk_upload.rb index 3d0ef93f0..56e10f399 100644 --- a/app/models/bulk_upload.rb +++ b/app/models/bulk_upload.rb @@ -14,6 +14,14 @@ class BulkUpload < ApplicationRecord "#{year}/#{year - 2000 + 1}" end + def logs + if lettings? + lettings_logs + else + sales_logs + end + end + private def generate_identifier diff --git a/app/models/form/lettings/pages/access_needs_exist.rb b/app/models/form/lettings/pages/access_needs_exist.rb new file mode 100644 index 000000000..a1a7d5b86 --- /dev/null +++ b/app/models/form/lettings/pages/access_needs_exist.rb @@ -0,0 +1,5 @@ +class Form::Lettings::Pages::AccessNeedsExist < ::Form::Page + def questions + @questions ||= [Form::Lettings::Questions::Housingneeds.new(nil, nil, self)] + end +end diff --git a/app/models/form/lettings/pages/allocation_system.rb b/app/models/form/lettings/pages/allocation_system.rb new file mode 100644 index 000000000..3b1f0b521 --- /dev/null +++ b/app/models/form/lettings/pages/allocation_system.rb @@ -0,0 +1,5 @@ +class Form::Lettings::Pages::AllocationSystem < ::Form::Page + def questions + @questions ||= [Form::Lettings::Questions::LettingAllocation.new(nil, nil, self)] + end +end diff --git a/app/models/form/lettings/pages/armed_forces.rb b/app/models/form/lettings/pages/armed_forces.rb new file mode 100644 index 000000000..44fad8e06 --- /dev/null +++ b/app/models/form/lettings/pages/armed_forces.rb @@ -0,0 +1,5 @@ +class Form::Lettings::Pages::ArmedForces < ::Form::Page + def questions + @questions ||= [Form::Lettings::Questions::Armedforces.new(nil, nil, self)] + end +end diff --git a/app/models/form/lettings/pages/armed_forces_injured.rb b/app/models/form/lettings/pages/armed_forces_injured.rb new file mode 100644 index 000000000..cbd1aec71 --- /dev/null +++ b/app/models/form/lettings/pages/armed_forces_injured.rb @@ -0,0 +1,11 @@ +class Form::Lettings::Pages::ArmedForcesInjured < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "armed_forces_injured" + @depends_on = [{ "armedforces" => 1 }, { "armedforces" => 4 }] + end + + def questions + @questions ||= [Form::Lettings::Questions::Reservist.new(nil, nil, self)] + end +end diff --git a/app/models/form/lettings/pages/armed_forces_serving.rb b/app/models/form/lettings/pages/armed_forces_serving.rb new file mode 100644 index 000000000..90ca06287 --- /dev/null +++ b/app/models/form/lettings/pages/armed_forces_serving.rb @@ -0,0 +1,11 @@ +class Form::Lettings::Pages::ArmedForcesServing < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "armed_forces_serving" + @depends_on = [{ "armedforces" => 1 }] + end + + def questions + @questions ||= [Form::Lettings::Questions::Leftreg.new(nil, nil, self)] + end +end diff --git a/app/models/form/lettings/pages/benefits_proportion.rb b/app/models/form/lettings/pages/benefits_proportion.rb new file mode 100644 index 000000000..bbb1347ec --- /dev/null +++ b/app/models/form/lettings/pages/benefits_proportion.rb @@ -0,0 +1,5 @@ +class Form::Lettings::Pages::BenefitsProportion < ::Form::Page + def questions + @questions ||= [Form::Lettings::Questions::Benefits.new(nil, nil, self)] + end +end diff --git a/app/models/form/lettings/pages/care_home_4_weekly.rb b/app/models/form/lettings/pages/care_home_4_weekly.rb new file mode 100644 index 000000000..262713d55 --- /dev/null +++ b/app/models/form/lettings/pages/care_home_4_weekly.rb @@ -0,0 +1,17 @@ +class Form::Lettings::Pages::CareHome4Weekly < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "care_home_4_weekly" + @depends_on = [ + { "period" => 3, "needstype" => 2, "household_charge" => 0 }, + { "period" => 3, "needstype" => 2, "household_charge" => nil }, + ] + end + + def questions + @questions ||= [ + Form::Lettings::Questions::IsCarehome.new(nil, nil, self), + Form::Lettings::Questions::Chcharge4Weekly.new(nil, nil, self), + ] + end +end diff --git a/app/models/form/lettings/pages/care_home_bi_weekly.rb b/app/models/form/lettings/pages/care_home_bi_weekly.rb new file mode 100644 index 000000000..6c4b791ed --- /dev/null +++ b/app/models/form/lettings/pages/care_home_bi_weekly.rb @@ -0,0 +1,17 @@ +class Form::Lettings::Pages::CareHomeBiWeekly < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "care_home_bi_weekly" + @depends_on = [ + { "period" => 2, "needstype" => 2, "household_charge" => 0 }, + { "period" => 2, "needstype" => 2, "household_charge" => nil }, + ] + end + + def questions + @questions ||= [ + Form::Lettings::Questions::IsCarehome.new(nil, nil, self), + Form::Lettings::Questions::ChchargeBiWeekly.new(nil, nil, self), + ] + end +end diff --git a/app/models/form/lettings/pages/care_home_monthly.rb b/app/models/form/lettings/pages/care_home_monthly.rb new file mode 100644 index 000000000..8e41474e7 --- /dev/null +++ b/app/models/form/lettings/pages/care_home_monthly.rb @@ -0,0 +1,17 @@ +class Form::Lettings::Pages::CareHomeMonthly < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "care_home_monthly" + @depends_on = [ + { "period" => 4, "needstype" => 2, "household_charge" => 0 }, + { "period" => 4, "needstype" => 2, "household_charge" => nil }, + ] + end + + def questions + @questions ||= [ + Form::Lettings::Questions::IsCarehome.new(nil, nil, self), + Form::Lettings::Questions::ChchargeMonthly.new(nil, nil, self), + ] + end +end diff --git a/app/models/form/lettings/pages/care_home_weekly.rb b/app/models/form/lettings/pages/care_home_weekly.rb new file mode 100644 index 000000000..ee8f7962e --- /dev/null +++ b/app/models/form/lettings/pages/care_home_weekly.rb @@ -0,0 +1,27 @@ +class Form::Lettings::Pages::CareHomeWeekly < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "care_home_weekly" + @depends_on = [ + { "period" => 1, "needstype" => 2, "household_charge" => 0 }, + { "period" => 1, "needstype" => 2, "household_charge" => nil }, + { "period" => 5, "needstype" => 2, "household_charge" => 0 }, + { "period" => 5, "needstype" => 2, "household_charge" => nil }, + { "period" => 6, "needstype" => 2, "household_charge" => 0 }, + { "period" => 6, "needstype" => 2, "household_charge" => nil }, + { "period" => 7, "needstype" => 2, "household_charge" => 0 }, + { "period" => 7, "needstype" => 2, "household_charge" => nil }, + { "period" => 8, "needstype" => 2, "household_charge" => 0 }, + { "period" => 8, "needstype" => 2, "household_charge" => nil }, + { "period" => 9, "needstype" => 2, "household_charge" => 0 }, + { "period" => 9, "needstype" => 2, "household_charge" => nil }, + ] + end + + def questions + @questions ||= [ + Form::Lettings::Questions::IsCarehome.new(nil, nil, self), + Form::Lettings::Questions::ChchargeWeekly.new(nil, nil, self), + ] + end +end diff --git a/app/models/form/lettings/pages/declaration.rb b/app/models/form/lettings/pages/declaration.rb new file mode 100644 index 000000000..1a1740aaf --- /dev/null +++ b/app/models/form/lettings/pages/declaration.rb @@ -0,0 +1,11 @@ +class Form::Lettings::Pages::Declaration < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "declaration" + @header = "Department for Levelling Up, Housing & Communities privacy notice" + end + + def questions + @questions ||= [Form::Lettings::Questions::Declaration.new(nil, nil, self)] + end +end 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 new file mode 100644 index 000000000..b143023ca --- /dev/null +++ b/app/models/form/lettings/pages/females_in_soft_age_range_in_pregnant_household_lead_age_value_check.rb @@ -0,0 +1,19 @@ +class Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdLeadAgeValueCheck < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "females_in_soft_age_range_in_pregnant_household_lead_age_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" }], + } + @informative_text = { + "translation" => "soft_validations.pregnancy.females_not_in_soft_age_range", + "arguments" => [{ "key" => "sex1", "label" => true, "i18n_template" => "sex1" }], + } + end + + def questions + @questions ||= [Form::Lettings::Questions::PregnancyValueCheck.new(nil, nil, self)] + end +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 new file mode 100644 index 000000000..fa85ee7cb --- /dev/null +++ b/app/models/form/lettings/pages/females_in_soft_age_range_in_pregnant_household_lead_hhmemb_value_check.rb @@ -0,0 +1,19 @@ +class Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdLeadHhmembValueCheck < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "females_in_soft_age_range_in_pregnant_household_lead_hhmemb_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" }], + } + @informative_text = { + "translation" => "soft_validations.pregnancy.females_not_in_soft_age_range", + "arguments" => [{ "key" => "sex1", "label" => true, "i18n_template" => "sex1" }], + } + end + + def questions + @questions ||= [Form::Lettings::Questions::PregnancyValueCheck.new(nil, nil, self)] + end +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 new file mode 100644 index 000000000..7eeca3bbd --- /dev/null +++ b/app/models/form/lettings/pages/females_in_soft_age_range_in_pregnant_household_lead_value_check.rb @@ -0,0 +1,19 @@ +class Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdLeadValueCheck < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "females_in_soft_age_range_in_pregnant_household_lead_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" }], + } + @informative_text = { + "translation" => "soft_validations.pregnancy.females_not_in_soft_age_range", + "arguments" => [{ "key" => "sex1", "label" => true, "i18n_template" => "sex1" }], + } + end + + def questions + @questions ||= [Form::Lettings::Questions::PregnancyValueCheck.new(nil, nil, self)] + end +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 new file mode 100644 index 000000000..29109f7ba --- /dev/null +++ b/app/models/form/lettings/pages/females_in_soft_age_range_in_pregnant_household_person_age_value_check.rb @@ -0,0 +1,36 @@ +class Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdPersonAgeValueCheck < ::Form::Page + 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" + @depends_on = [ + { + "female_in_pregnant_household_in_soft_validation_range?" => true, + "age#{person_index}_known" => 0, + }, + ] + @title_text = { + "translation" => "soft_validations.pregnancy.title", + "arguments" => [ + { + "key" => "sex1", + "label" => true, + "i18n_template" => "sex1", + }, + ], + } + @informative_text = { + "translation" => "soft_validations.pregnancy.females_not_in_soft_age_range", + "arguments" => [ + { + "key" => "sex1", + "label" => true, + "i18n_template" => "sex1", + }, + ], + } + end + + def questions + @questions ||= [Form::Lettings::Questions::PregnancyValueCheck.new(nil, nil, self)] + end +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 new file mode 100644 index 000000000..b0084d723 --- /dev/null +++ b/app/models/form/lettings/pages/females_in_soft_age_range_in_pregnant_household_person_value_check.rb @@ -0,0 +1,36 @@ +class Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdPersonValueCheck < ::Form::Page + 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" + @depends_on = [ + { + "female_in_pregnant_household_in_soft_validation_range?" => true, + "details_known_#{person_index}" => 0, + }, + ] + @title_text = { + "translation" => "soft_validations.pregnancy.title", + "arguments" => [ + { + "key" => "sex1", + "label" => true, + "i18n_template" => "sex1", + }, + ], + } + @informative_text = { + "translation" => "soft_validations.pregnancy.females_not_in_soft_age_range", + "arguments" => [ + { + "key" => "sex1", + "label" => true, + "i18n_template" => "sex1", + }, + ], + } + end + + def questions + @questions ||= [Form::Lettings::Questions::PregnancyValueCheck.new(nil, nil, self)] + end +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 new file mode 100644 index 000000000..9a4d93de1 --- /dev/null +++ b/app/models/form/lettings/pages/females_in_soft_age_range_in_pregnant_household_value_check.rb @@ -0,0 +1,19 @@ +class Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdValueCheck < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "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" }], + } + @informative_text = { + "translation" => "soft_validations.pregnancy.females_not_in_soft_age_range", + "arguments" => [{ "key" => "sex1", "label" => true, "i18n_template" => "sex1" }], + } + end + + def questions + @questions ||= [Form::Lettings::Questions::PregnancyValueCheck.new(nil, nil, self)] + end +end diff --git a/app/models/form/lettings/pages/first_time_property_let_as_social_housing.rb b/app/models/form/lettings/pages/first_time_property_let_as_social_housing.rb new file mode 100644 index 000000000..fc65488e2 --- /dev/null +++ b/app/models/form/lettings/pages/first_time_property_let_as_social_housing.rb @@ -0,0 +1,11 @@ +class Form::Lettings::Pages::FirstTimePropertyLetAsSocialHousing < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "first_time_property_let_as_social_housing" + @depends_on = [{ "renewal" => 0 }] + end + + def questions + @questions ||= [Form::Lettings::Questions::FirstTimePropertyLetAsSocialHousing.new(nil, nil, self)] + end +end diff --git a/app/models/form/lettings/pages/health_condition_effects.rb b/app/models/form/lettings/pages/health_condition_effects.rb new file mode 100644 index 000000000..94a32cd1f --- /dev/null +++ b/app/models/form/lettings/pages/health_condition_effects.rb @@ -0,0 +1,11 @@ +class Form::Lettings::Pages::HealthConditionEffects < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "health_condition_effects" + @depends_on = [{ "illness" => 1 }] + end + + def questions + @questions ||= [Form::Lettings::Questions::ConditionEffects.new(nil, nil, self)] + end +end diff --git a/app/models/form/lettings/pages/health_conditions.rb b/app/models/form/lettings/pages/health_conditions.rb new file mode 100644 index 000000000..5cb39787a --- /dev/null +++ b/app/models/form/lettings/pages/health_conditions.rb @@ -0,0 +1,5 @@ +class Form::Lettings::Pages::HealthConditions < ::Form::Page + def questions + @questions ||= [Form::Lettings::Questions::Illness.new(nil, nil, self)] + end +end diff --git a/app/models/form/lettings/pages/homelessness.rb b/app/models/form/lettings/pages/homelessness.rb new file mode 100644 index 000000000..224585268 --- /dev/null +++ b/app/models/form/lettings/pages/homelessness.rb @@ -0,0 +1,5 @@ +class Form::Lettings::Pages::Homelessness < ::Form::Page + def questions + @questions ||= [Form::Lettings::Questions::Homeless.new(nil, nil, self)] + end +end diff --git a/app/models/form/lettings/pages/household_members.rb b/app/models/form/lettings/pages/household_members.rb new file mode 100644 index 000000000..9872add53 --- /dev/null +++ b/app/models/form/lettings/pages/household_members.rb @@ -0,0 +1,11 @@ +class Form::Lettings::Pages::HouseholdMembers < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "household_members" + @depends_on = [{ "declaration" => 1 }] + end + + def questions + @questions ||= [Form::Lettings::Questions::Hhmemb.new(nil, nil, self)] + end +end diff --git a/app/models/form/lettings/pages/housing_benefit.rb b/app/models/form/lettings/pages/housing_benefit.rb new file mode 100644 index 000000000..e31dd4311 --- /dev/null +++ b/app/models/form/lettings/pages/housing_benefit.rb @@ -0,0 +1,5 @@ +class Form::Lettings::Pages::HousingBenefit < ::Form::Page + def questions + @questions ||= [Form::Lettings::Questions::Hb.new(nil, nil, self)] + end +end diff --git a/app/models/form/lettings/pages/income_amount.rb b/app/models/form/lettings/pages/income_amount.rb new file mode 100644 index 000000000..c4ebaff2b --- /dev/null +++ b/app/models/form/lettings/pages/income_amount.rb @@ -0,0 +1,15 @@ +class Form::Lettings::Pages::IncomeAmount < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "income_amount" + @header = "Total household income" + @depends_on = [{ "net_income_known" => 0 }] + end + + def questions + @questions ||= [ + Form::Lettings::Questions::Earnings.new(nil, nil, self), + Form::Lettings::Questions::Incfreq.new(nil, nil, self), + ] + end +end diff --git a/app/models/form/lettings/pages/income_known.rb b/app/models/form/lettings/pages/income_known.rb new file mode 100644 index 000000000..c031b1521 --- /dev/null +++ b/app/models/form/lettings/pages/income_known.rb @@ -0,0 +1,11 @@ +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 + @questions ||= [Form::Lettings::Questions::NetIncomeKnown.new(nil, nil, self)] + end +end diff --git a/app/models/form/lettings/pages/joint.rb b/app/models/form/lettings/pages/joint.rb new file mode 100644 index 000000000..29cf9be4a --- /dev/null +++ b/app/models/form/lettings/pages/joint.rb @@ -0,0 +1,5 @@ +class Form::Lettings::Pages::Joint < ::Form::Page + def questions + @questions ||= [Form::Lettings::Questions::Joint.new(nil, nil, self)] + end +end diff --git a/app/models/form/lettings/pages/lead_tenant_age.rb b/app/models/form/lettings/pages/lead_tenant_age.rb new file mode 100644 index 000000000..640d23142 --- /dev/null +++ b/app/models/form/lettings/pages/lead_tenant_age.rb @@ -0,0 +1,14 @@ +class Form::Lettings::Pages::LeadTenantAge < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "lead_tenant_age" + @depends_on = [{ "declaration" => 1 }] + end + + def questions + @questions ||= [ + Form::Lettings::Questions::Age1Known.new(nil, nil, self), + Form::Lettings::Questions::Age1.new(nil, nil, self), + ] + end +end diff --git a/app/models/form/lettings/pages/lead_tenant_ethnic_background_arab.rb b/app/models/form/lettings/pages/lead_tenant_ethnic_background_arab.rb new file mode 100644 index 000000000..89d73fd34 --- /dev/null +++ b/app/models/form/lettings/pages/lead_tenant_ethnic_background_arab.rb @@ -0,0 +1,11 @@ +class Form::Lettings::Pages::LeadTenantEthnicBackgroundArab < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "lead_tenant_ethnic_background_arab" + @depends_on = [{ "ethnic_group" => 4 }] + end + + def questions + @questions ||= [Form::Lettings::Questions::EthnicArab.new(nil, nil, self)] + end +end diff --git a/app/models/form/lettings/pages/lead_tenant_ethnic_background_asian.rb b/app/models/form/lettings/pages/lead_tenant_ethnic_background_asian.rb new file mode 100644 index 000000000..d55ce9837 --- /dev/null +++ b/app/models/form/lettings/pages/lead_tenant_ethnic_background_asian.rb @@ -0,0 +1,11 @@ +class Form::Lettings::Pages::LeadTenantEthnicBackgroundAsian < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "lead_tenant_ethnic_background_asian" + @depends_on = [{ "ethnic_group" => 2 }] + end + + def questions + @questions ||= [Form::Lettings::Questions::EthnicAsian.new(nil, nil, self)] + end +end diff --git a/app/models/form/lettings/pages/lead_tenant_ethnic_background_black.rb b/app/models/form/lettings/pages/lead_tenant_ethnic_background_black.rb new file mode 100644 index 000000000..7ce2ef9c4 --- /dev/null +++ b/app/models/form/lettings/pages/lead_tenant_ethnic_background_black.rb @@ -0,0 +1,11 @@ +class Form::Lettings::Pages::LeadTenantEthnicBackgroundBlack < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "lead_tenant_ethnic_background_black" + @depends_on = [{ "ethnic_group" => 3 }] + end + + def questions + @questions ||= [Form::Lettings::Questions::EthnicBlack.new(nil, nil, self)] + end +end diff --git a/app/models/form/lettings/pages/lead_tenant_ethnic_background_mixed.rb b/app/models/form/lettings/pages/lead_tenant_ethnic_background_mixed.rb new file mode 100644 index 000000000..a4c225083 --- /dev/null +++ b/app/models/form/lettings/pages/lead_tenant_ethnic_background_mixed.rb @@ -0,0 +1,11 @@ +class Form::Lettings::Pages::LeadTenantEthnicBackgroundMixed < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "lead_tenant_ethnic_background_mixed" + @depends_on = [{ "ethnic_group" => 1 }] + end + + def questions + @questions ||= [Form::Lettings::Questions::EthnicMixed.new(nil, nil, self)] + end +end diff --git a/app/models/form/lettings/pages/lead_tenant_ethnic_background_white.rb b/app/models/form/lettings/pages/lead_tenant_ethnic_background_white.rb new file mode 100644 index 000000000..994e6e159 --- /dev/null +++ b/app/models/form/lettings/pages/lead_tenant_ethnic_background_white.rb @@ -0,0 +1,11 @@ +class Form::Lettings::Pages::LeadTenantEthnicBackgroundWhite < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "lead_tenant_ethnic_background_white" + @depends_on = [{ "ethnic_group" => 0 }] + end + + def questions + @questions ||= [Form::Lettings::Questions::EthnicWhite.new(nil, nil, self)] + end +end diff --git a/app/models/form/lettings/pages/lead_tenant_ethnic_group.rb b/app/models/form/lettings/pages/lead_tenant_ethnic_group.rb new file mode 100644 index 000000000..30fd906b8 --- /dev/null +++ b/app/models/form/lettings/pages/lead_tenant_ethnic_group.rb @@ -0,0 +1,11 @@ +class Form::Lettings::Pages::LeadTenantEthnicGroup < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "lead_tenant_ethnic_group" + @depends_on = [{ "declaration" => 1 }] + end + + def questions + @questions ||= [Form::Lettings::Questions::EthnicGroup.new(nil, nil, self)] + end +end diff --git a/app/models/form/lettings/pages/lead_tenant_gender_identity.rb b/app/models/form/lettings/pages/lead_tenant_gender_identity.rb new file mode 100644 index 000000000..ed0cc1b47 --- /dev/null +++ b/app/models/form/lettings/pages/lead_tenant_gender_identity.rb @@ -0,0 +1,11 @@ +class Form::Lettings::Pages::LeadTenantGenderIdentity < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "lead_tenant_gender_identity" + @depends_on = [{ "declaration" => 1 }] + end + + def questions + @questions ||= [Form::Lettings::Questions::GenderIdentity1.new(nil, nil, self)] + end +end diff --git a/app/models/form/lettings/pages/lead_tenant_nationality.rb b/app/models/form/lettings/pages/lead_tenant_nationality.rb new file mode 100644 index 000000000..ae67b1e32 --- /dev/null +++ b/app/models/form/lettings/pages/lead_tenant_nationality.rb @@ -0,0 +1,11 @@ +class Form::Lettings::Pages::LeadTenantNationality < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "lead_tenant_nationality" + @depends_on = [{ "declaration" => 1 }] + end + + def questions + @questions ||= [Form::Lettings::Questions::National.new(nil, nil, self)] + end +end 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 new file mode 100644 index 000000000..6990bf71e --- /dev/null +++ b/app/models/form/lettings/pages/lead_tenant_over_retirement_value_check.rb @@ -0,0 +1,32 @@ +class Form::Lettings::Pages::LeadTenantOverRetirementValueCheck < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "lead_tenant_over_retirement_value_check" + @depends_on = [{ "person_1_not_retired_over_soft_max_age?" => true }] + @title_text = { + "translation" => "soft_validations.retirement.max.title", + "arguments" => [ + { + "key" => "retirement_age_for_person_1", + "label" => false, + "i18n_template" => "age", + }, + ], + } + @informative_text = { + "translation" => "soft_validations.retirement.max.hint_text", + "arguments" => [ + { "key" => "plural_gender_for_person_1", "label" => false, "i18n_template" => "gender" }, + { + "key" => "retirement_age_for_person_1", + "label" => false, + "i18n_template" => "age", + }, + ], + } + end + + def questions + @questions ||= [Form::Lettings::Questions::RetirementValueCheck.new(nil, nil, self)] + end +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 new file mode 100644 index 000000000..34da02205 --- /dev/null +++ b/app/models/form/lettings/pages/lead_tenant_under_retirement_value_check.rb @@ -0,0 +1,32 @@ +class Form::Lettings::Pages::LeadTenantUnderRetirementValueCheck < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "lead_tenant_under_retirement_value_check" + @depends_on = [{ "person_1_retired_under_soft_min_age?" => true }] + @title_text = { + "translation" => "soft_validations.retirement.min.title", + "arguments" => [ + { + "key" => "retirement_age_for_person_1", + "label" => false, + "i18n_template" => "age", + }, + ], + } + @informative_text = { + "translation" => "soft_validations.retirement.min.hint_text", + "arguments" => [ + { "key" => "plural_gender_for_person_1", "label" => false, "i18n_template" => "gender" }, + { + "key" => "retirement_age_for_person_1", + "label" => false, + "i18n_template" => "age", + }, + ], + } + end + + def questions + @questions ||= [Form::Lettings::Questions::NoRetirementValueCheck.new(nil, nil, self)] + end +end diff --git a/app/models/form/lettings/pages/lead_tenant_working_situation.rb b/app/models/form/lettings/pages/lead_tenant_working_situation.rb new file mode 100644 index 000000000..ebdd630f0 --- /dev/null +++ b/app/models/form/lettings/pages/lead_tenant_working_situation.rb @@ -0,0 +1,11 @@ +class Form::Lettings::Pages::LeadTenantWorkingSituation < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "lead_tenant_working_situation" + @depends_on = [{ "declaration" => 1 }] + end + + def questions + @questions ||= [Form::Lettings::Questions::WorkingSituation1.new(nil, nil, self)] + end +end diff --git a/app/models/form/lettings/pages/location.rb b/app/models/form/lettings/pages/location.rb index 9641d0e1a..f20ca30d5 100644 --- a/app/models/form/lettings/pages/location.rb +++ b/app/models/form/lettings/pages/location.rb @@ -1,10 +1,12 @@ class Form::Lettings::Pages::Location < ::Form::Page def initialize(_id, hsh, subsection) super("location", hsh, subsection) - @depends_on = [{ - "needstype" => 2, - "scheme_has_multiple_locations?" => true, - }] + @depends_on = [ + { + "needstype" => 2, + "scheme_has_multiple_locations?" => true, + }, + ] @next_unresolved_page_id = :check_answers end diff --git a/app/models/form/lettings/pages/max_rent_value_check.rb b/app/models/form/lettings/pages/max_rent_value_check.rb new file mode 100644 index 000000000..88d0561bf --- /dev/null +++ b/app/models/form/lettings/pages/max_rent_value_check.rb @@ -0,0 +1,25 @@ +class Form::Lettings::Pages::MaxRentValueCheck < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "max_rent_value_check" + @depends_on = [{ "rent_in_soft_max_range?" => true }] + @title_text = { + "translation" => "soft_validations.rent.max.title_text", + "arguments" => [{ "key" => "brent", "label" => true, "i18n_template" => "brent" }], + } + @informative_text = { + "translation" => "soft_validations.rent.max.hint_text", + "arguments" => [ + { + "key" => "soft_max_for_period", + "label" => false, + "i18n_template" => "soft_max_for_period", + }, + ], + } + end + + def questions + @questions ||= [Form::Lettings::Questions::RentValueCheck.new(nil, nil, self)] + end +end diff --git a/app/models/form/lettings/pages/min_rent_value_check.rb b/app/models/form/lettings/pages/min_rent_value_check.rb new file mode 100644 index 000000000..3bcb95789 --- /dev/null +++ b/app/models/form/lettings/pages/min_rent_value_check.rb @@ -0,0 +1,25 @@ +class Form::Lettings::Pages::MinRentValueCheck < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "min_rent_value_check" + @depends_on = [{ "rent_in_soft_min_range?" => true }] + @title_text = { + "translation" => "soft_validations.rent.min.title_text", + "arguments" => [{ "key" => "brent", "label" => true, "i18n_template" => "brent" }], + } + @informative_text = { + "translation" => "soft_validations.rent.min.hint_text", + "arguments" => [ + { + "key" => "soft_min_for_period", + "label" => false, + "i18n_template" => "soft_min_for_period", + }, + ], + } + end + + def questions + @questions ||= [Form::Lettings::Questions::RentValueCheck.new(nil, nil, self)] + end +end diff --git a/app/models/form/lettings/pages/net_income_value_check.rb b/app/models/form/lettings/pages/net_income_value_check.rb new file mode 100644 index 000000000..9a9c1061f --- /dev/null +++ b/app/models/form/lettings/pages/net_income_value_check.rb @@ -0,0 +1,19 @@ +class Form::Lettings::Pages::NetIncomeValueCheck < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "net_income_value_check" + @depends_on = [{ "net_income_soft_validation_triggered?" => true }] + @title_text = { "translation" => "soft_validations.net_income.title_text" } + @informative_text = { + "translation" => "soft_validations.net_income.hint_text", + "arguments" => [ + { "key" => "ecstat1", "label" => true, "i18n_template" => "ecstat1" }, + { "key" => "earnings", "label" => true, "i18n_template" => "earnings" }, + ], + } + end + + def questions + @questions ||= [Form::Lettings::Questions::NetIncomeValueCheck.new(nil, nil, self)] + end +end diff --git a/app/models/form/lettings/pages/new_build_handover_date.rb b/app/models/form/lettings/pages/new_build_handover_date.rb new file mode 100644 index 000000000..7b13c7727 --- /dev/null +++ b/app/models/form/lettings/pages/new_build_handover_date.rb @@ -0,0 +1,15 @@ +class Form::Lettings::Pages::NewBuildHandoverDate < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "new_build_handover_date" + @depends_on = [ + { "renewal" => 0, "rsnvac" => 15 }, + { "renewal" => 0, "rsnvac" => 16 }, + { "renewal" => 0, "rsnvac" => 17 }, + ] + end + + def questions + @questions ||= [Form::Lettings::Questions::VoiddateNewBuild.new(nil, nil, self)] + end +end 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 new file mode 100644 index 000000000..d837ac0cb --- /dev/null +++ b/app/models/form/lettings/pages/no_females_pregnant_household_lead_age_value_check.rb @@ -0,0 +1,19 @@ +class Form::Lettings::Pages::NoFemalesPregnantHouseholdLeadAgeValueCheck < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "no_females_pregnant_household_lead_age_value_check" + @depends_on = [{ "no_females_in_a_pregnant_household?" => true }] + @title_text = { + "translation" => "soft_validations.pregnancy.title", + "arguments" => [{ "key" => "sex1", "label" => true, "i18n_template" => "sex1" }], + } + @informative_text = { + "translation" => "soft_validations.pregnancy.no_females", + "arguments" => [{ "key" => "sex1", "label" => true, "i18n_template" => "sex1" }], + } + end + + def questions + @questions ||= [Form::Lettings::Questions::PregnancyValueCheck.new(nil, nil, self)] + end +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 new file mode 100644 index 000000000..806153074 --- /dev/null +++ b/app/models/form/lettings/pages/no_females_pregnant_household_lead_hhmemb_value_check.rb @@ -0,0 +1,19 @@ +class Form::Lettings::Pages::NoFemalesPregnantHouseholdLeadHhmembValueCheck < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "no_females_pregnant_household_lead_hhmemb_value_check" + @depends_on = [{ "no_females_in_a_pregnant_household?" => true }] + @title_text = { + "translation" => "soft_validations.pregnancy.title", + "arguments" => [{ "key" => "sex1", "label" => true, "i18n_template" => "sex1" }], + } + @informative_text = { + "translation" => "soft_validations.pregnancy.no_females", + "arguments" => [{ "key" => "sex1", "label" => true, "i18n_template" => "sex1" }], + } + end + + def questions + @questions ||= [Form::Lettings::Questions::PregnancyValueCheck.new(nil, nil, self)] + end +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 new file mode 100644 index 000000000..44217e7fa --- /dev/null +++ b/app/models/form/lettings/pages/no_females_pregnant_household_lead_value_check.rb @@ -0,0 +1,19 @@ +class Form::Lettings::Pages::NoFemalesPregnantHouseholdLeadValueCheck < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "no_females_pregnant_household_lead_value_check" + @depends_on = [{ "no_females_in_a_pregnant_household?" => true }] + @title_text = { + "translation" => "soft_validations.pregnancy.title", + "arguments" => [{ "key" => "sex1", "label" => true, "i18n_template" => "sex1" }], + } + @informative_text = { + "translation" => "soft_validations.pregnancy.no_females", + "arguments" => [{ "key" => "sex1", "label" => true, "i18n_template" => "sex1" }], + } + end + + def questions + @questions ||= [Form::Lettings::Questions::PregnancyValueCheck.new(nil, nil, self)] + end +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 new file mode 100644 index 000000000..be833d9dc --- /dev/null +++ b/app/models/form/lettings/pages/no_females_pregnant_household_person_age_value_check.rb @@ -0,0 +1,19 @@ +class Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonAgeValueCheck < ::Form::Page + def initialize(id, hsh, subsection, person_index:) + super(id, hsh, subsection) + @id = "no_females_pregnant_household_person_#{person_index}_age_value_check" + @depends_on = [{ "no_females_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" }], + } + @informative_text = { + "translation" => "soft_validations.pregnancy.no_females", + "arguments" => [{ "key" => "sex1", "label" => true, "i18n_template" => "sex1" }], + } + end + + def questions + @questions ||= [Form::Lettings::Questions::PregnancyValueCheck.new(nil, nil, self)] + end +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 new file mode 100644 index 000000000..e81e5b339 --- /dev/null +++ b/app/models/form/lettings/pages/no_females_pregnant_household_person_value_check.rb @@ -0,0 +1,19 @@ +class Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonValueCheck < ::Form::Page + def initialize(id, hsh, subsection, person_index:) + super(id, hsh, subsection) + @id = "no_females_pregnant_household_person_#{person_index}_value_check" + @depends_on = [{ "no_females_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" }], + } + @informative_text = { + "translation" => "soft_validations.pregnancy.no_females", + "arguments" => [{ "key" => "sex1", "label" => true, "i18n_template" => "sex1" }], + } + end + + def questions + @questions ||= [Form::Lettings::Questions::PregnancyValueCheck.new(nil, nil, self)] + end +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 new file mode 100644 index 000000000..2438ef0b9 --- /dev/null +++ b/app/models/form/lettings/pages/no_females_pregnant_household_value_check.rb @@ -0,0 +1,19 @@ +class Form::Lettings::Pages::NoFemalesPregnantHouseholdValueCheck < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "no_females_pregnant_household_value_check" + @depends_on = [{ "no_females_in_a_pregnant_household?" => true }] + @title_text = { + "translation" => "soft_validations.pregnancy.title", + "arguments" => [{ "key" => "sex1", "label" => true, "i18n_template" => "sex1" }], + } + @informative_text = { + "translation" => "soft_validations.pregnancy.no_females", + "arguments" => [{ "key" => "sex1", "label" => true, "i18n_template" => "sex1" }], + } + end + + def questions + @questions ||= [Form::Lettings::Questions::PregnancyValueCheck.new(nil, nil, self)] + end +end diff --git a/app/models/form/lettings/pages/outstanding.rb b/app/models/form/lettings/pages/outstanding.rb new file mode 100644 index 000000000..a7bfa9290 --- /dev/null +++ b/app/models/form/lettings/pages/outstanding.rb @@ -0,0 +1,16 @@ +class Form::Lettings::Pages::Outstanding < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "outstanding" + @depends_on = [ + { "hb" => 1, "household_charge" => 0 }, + { "hb" => 1, "household_charge" => nil }, + { "hb" => 6, "household_charge" => 0 }, + { "hb" => 6, "household_charge" => nil }, + ] + end + + def questions + @questions ||= [Form::Lettings::Questions::Hbrentshortfall.new(nil, nil, self)] + end +end diff --git a/app/models/form/lettings/pages/outstanding_amount.rb b/app/models/form/lettings/pages/outstanding_amount.rb new file mode 100644 index 000000000..d624433ea --- /dev/null +++ b/app/models/form/lettings/pages/outstanding_amount.rb @@ -0,0 +1,14 @@ +class Form::Lettings::Pages::OutstandingAmount < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "outstanding_amount" + @depends_on = [{ "hb" => 1, "hbrentshortfall" => 1 }, { "hb" => 6, "hbrentshortfall" => 1 }] + end + + def questions + @questions ||= [ + Form::Lettings::Questions::TshortfallKnown.new(nil, nil, self), + Form::Lettings::Questions::Tshortfall.new(nil, nil, self), + ] + end +end diff --git a/app/models/form/lettings/pages/person_age.rb b/app/models/form/lettings/pages/person_age.rb new file mode 100644 index 000000000..66f7d3d89 --- /dev/null +++ b/app/models/form/lettings/pages/person_age.rb @@ -0,0 +1,15 @@ +class Form::Lettings::Pages::PersonAge < ::Form::Page + def initialize(id, hsh, subsection, person_index:) + super(id, hsh, subsection) + @id = "person_#{person_index}_age" + @depends_on = [{ "details_known_#{person_index}" => 0 }] + @person_index = person_index + end + + def questions + @questions ||= [ + Form::Lettings::Questions::AgeKnown.new(nil, nil, self, person_index: @person_index), + Form::Lettings::Questions::Age.new(nil, nil, self, person_index: @person_index), + ] + end +end diff --git a/app/models/form/lettings/pages/person_gender_identity.rb b/app/models/form/lettings/pages/person_gender_identity.rb new file mode 100644 index 000000000..512dd12a1 --- /dev/null +++ b/app/models/form/lettings/pages/person_gender_identity.rb @@ -0,0 +1,12 @@ +class Form::Lettings::Pages::PersonGenderIdentity < ::Form::Page + def initialize(id, hsh, subsection, person_index:) + super(id, hsh, subsection) + @id = "person_#{person_index}_gender_identity" + @depends_on = [{ "details_known_#{person_index}" => 0 }] + @person_index = person_index + end + + def questions + @questions ||= [Form::Lettings::Questions::PersonGenderIdentity.new(nil, nil, self, person_index: @person_index)] + end +end diff --git a/app/models/form/lettings/pages/person_known.rb b/app/models/form/lettings/pages/person_known.rb new file mode 100644 index 000000000..b864ab708 --- /dev/null +++ b/app/models/form/lettings/pages/person_known.rb @@ -0,0 +1,13 @@ +class Form::Lettings::Pages::PersonKnown < ::Form::Page + def initialize(id, hsh, subsection, person_index:) + super(id, hsh, subsection) + @id = "person_#{person_index}_known" + @header = "You’ve given us the details for #{person_index - 1} person in the household" + @depends_on = (person_index..8).map { |index| { "hhmemb" => index } } + @person_index = person_index + end + + def questions + @questions ||= [Form::Lettings::Questions::DetailsKnown.new(nil, nil, self, person_index: @person_index)] + end +end 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 new file mode 100644 index 000000000..3de5246e6 --- /dev/null +++ b/app/models/form/lettings/pages/person_over_retirement_value_check.rb @@ -0,0 +1,36 @@ +class Form::Lettings::Pages::PersonOverRetirementValueCheck < ::Form::Page + def initialize(id, hsh, subsection, person_index:) + super(id, hsh, subsection) + @id = "person_#{person_index}_over_retirement_value_check" + @depends_on = [{ "person_#{person_index}_not_retired_over_soft_max_age?" => true }] + @title_text = { + "translation" => "soft_validations.retirement.max.title", + "arguments" => [ + { + "key" => "retirement_age_for_person_#{person_index}", + "label" => false, + "i18n_template" => "age", + }, + ], + } + @informative_text = { + "translation" => "soft_validations.retirement.max.hint_text", + "arguments" => [ + { + "key" => "plural_gender_for_person_#{person_index}", + "label" => false, + "i18n_template" => "gender", + }, + { + "key" => "retirement_age_for_person_#{person_index}", + "label" => false, + "i18n_template" => "age", + }, + ], + } + end + + def questions + @questions ||= [Form::Lettings::Questions::RetirementValueCheck.new(nil, nil, self)] + end +end diff --git a/app/models/form/lettings/pages/person_relationship_to_lead.rb b/app/models/form/lettings/pages/person_relationship_to_lead.rb new file mode 100644 index 000000000..c4ad98bdc --- /dev/null +++ b/app/models/form/lettings/pages/person_relationship_to_lead.rb @@ -0,0 +1,12 @@ +class Form::Lettings::Pages::PersonRelationshipToLead < ::Form::Page + def initialize(id, hsh, subsection, person_index:) + super(id, hsh, subsection) + @id = "person_#{person_index}_relationship_to_lead" + @depends_on = [{ "details_known_#{person_index}" => 0 }] + @person_index = person_index + end + + def questions + @questions ||= [Form::Lettings::Questions::PersonRelationship.new(nil, nil, self, person_index: @person_index)] + end +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 new file mode 100644 index 000000000..a1b9253fd --- /dev/null +++ b/app/models/form/lettings/pages/person_under_retirement_value_check.rb @@ -0,0 +1,36 @@ +class Form::Lettings::Pages::PersonUnderRetirementValueCheck < ::Form::Page + def initialize(id, hsh, subsection, person_index:) + super(id, hsh, subsection) + @id = "person_#{person_index}_under_retirement_value_check" + @depends_on = [{ "person_#{person_index}_retired_under_soft_min_age?" => true }] + @title_text = { + "translation" => "soft_validations.retirement.min.title", + "arguments" => [ + { + "key" => "retirement_age_for_person_#{person_index}", + "label" => false, + "i18n_template" => "age", + }, + ], + } + @informative_text = { + "translation" => "soft_validations.retirement.min.hint_text", + "arguments" => [ + { + "key" => "plural_gender_for_person_#{person_index}", + "label" => false, + "i18n_template" => "gender", + }, + { + "key" => "retirement_age_for_person_#{person_index}", + "label" => false, + "i18n_template" => "age", + }, + ], + } + end + + def questions + @questions ||= [Form::Lettings::Questions::NoRetirementValueCheck.new(nil, nil, self)] + end +end diff --git a/app/models/form/lettings/pages/person_working_situation.rb b/app/models/form/lettings/pages/person_working_situation.rb new file mode 100644 index 000000000..ec475045a --- /dev/null +++ b/app/models/form/lettings/pages/person_working_situation.rb @@ -0,0 +1,21 @@ +class Form::Lettings::Pages::PersonWorkingSituation < ::Form::Page + def initialize(id, hsh, subsection, person_index:) + super(id, hsh, subsection) + @id = "person_#{person_index}_working_situation" + @depends_on = [ + { + "details_known_#{person_index}" => 0, + "age#{person_index}" => { + "operator" => ">", + "operand" => 15, + }, + }, + { "details_known_#{person_index}" => 0, "age#{person_index}" => nil }, + ] + @person_index = person_index + end + + def questions + @questions ||= [Form::Lettings::Questions::PersonWorkingSituation.new(nil, nil, self, person_index: @person_index)] + end +end diff --git a/app/models/form/lettings/pages/pregnant.rb b/app/models/form/lettings/pages/pregnant.rb new file mode 100644 index 000000000..b27c3d900 --- /dev/null +++ b/app/models/form/lettings/pages/pregnant.rb @@ -0,0 +1,5 @@ +class Form::Lettings::Pages::Pregnant < ::Form::Page + def questions + @questions ||= [Form::Lettings::Questions::PregOcc.new(nil, nil, self)] + end +end diff --git a/app/models/form/lettings/pages/previous_housing_situation.rb b/app/models/form/lettings/pages/previous_housing_situation.rb new file mode 100644 index 000000000..82bbda675 --- /dev/null +++ b/app/models/form/lettings/pages/previous_housing_situation.rb @@ -0,0 +1,11 @@ +class Form::Lettings::Pages::PreviousHousingSituation < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "previous_housing_situation" + @depends_on = [{ "renewal" => 0 }] + end + + def questions + @questions ||= [Form::Lettings::Questions::Prevten.new(nil, nil, self)] + end +end diff --git a/app/models/form/lettings/pages/previous_housing_situation_renewal.rb b/app/models/form/lettings/pages/previous_housing_situation_renewal.rb new file mode 100644 index 000000000..7f22150bf --- /dev/null +++ b/app/models/form/lettings/pages/previous_housing_situation_renewal.rb @@ -0,0 +1,11 @@ +class Form::Lettings::Pages::PreviousHousingSituationRenewal < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "previous_housing_situation_renewal" + @depends_on = [{ "renewal" => 1, "needstype" => 2 }] + end + + def questions + @questions ||= [Form::Lettings::Questions::PrevtenRenewal.new(nil, nil, self)] + end +end diff --git a/app/models/form/lettings/pages/previous_local_authority.rb b/app/models/form/lettings/pages/previous_local_authority.rb new file mode 100644 index 000000000..540857282 --- /dev/null +++ b/app/models/form/lettings/pages/previous_local_authority.rb @@ -0,0 +1,14 @@ +class Form::Lettings::Pages::PreviousLocalAuthority < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "previous_local_authority" + @depends_on = [{ "is_previous_la_inferred" => false }] + end + + def questions + @questions ||= [ + Form::Lettings::Questions::PreviousLaKnown.new(nil, nil, self), + Form::Lettings::Questions::Prevloc.new(nil, nil, self), + ] + end +end diff --git a/app/models/form/lettings/pages/previous_postcode.rb b/app/models/form/lettings/pages/previous_postcode.rb new file mode 100644 index 000000000..38be3ccbe --- /dev/null +++ b/app/models/form/lettings/pages/previous_postcode.rb @@ -0,0 +1,8 @@ +class Form::Lettings::Pages::PreviousPostcode < ::Form::Page + def questions + @questions ||= [ + Form::Lettings::Questions::Ppcodenk.new(nil, nil, self), + Form::Lettings::Questions::PpostcodeFull.new(nil, nil, self), + ] + end +end diff --git a/app/models/form/lettings/pages/property_building_type.rb b/app/models/form/lettings/pages/property_building_type.rb new file mode 100644 index 000000000..aec9fa4a9 --- /dev/null +++ b/app/models/form/lettings/pages/property_building_type.rb @@ -0,0 +1,11 @@ +class Form::Lettings::Pages::PropertyBuildingType < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "property_building_type" + @depends_on = [{ "needstype" => 1 }] + end + + def questions + @questions ||= [Form::Lettings::Questions::Builtype.new(nil, nil, self)] + end +end diff --git a/app/models/form/lettings/pages/property_let_type.rb b/app/models/form/lettings/pages/property_let_type.rb new file mode 100644 index 000000000..1f31af370 --- /dev/null +++ b/app/models/form/lettings/pages/property_let_type.rb @@ -0,0 +1,11 @@ +class Form::Lettings::Pages::PropertyLetType < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "property_let_type" + @depends_on = [{ "first_time_property_let_as_social_housing" => 0, "renewal" => 0, "needstype" => 1 }] + end + + def questions + @questions ||= [Form::Lettings::Questions::Unitletas.new(nil, nil, self)] + end +end diff --git a/app/models/form/lettings/pages/property_local_authority.rb b/app/models/form/lettings/pages/property_local_authority.rb new file mode 100644 index 000000000..711d908d8 --- /dev/null +++ b/app/models/form/lettings/pages/property_local_authority.rb @@ -0,0 +1,11 @@ +class Form::Lettings::Pages::PropertyLocalAuthority < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "property_local_authority" + @depends_on = [{ "is_la_inferred" => false, "needstype" => 1 }] + end + + def questions + @questions ||= [Form::Lettings::Questions::La.new(nil, nil, self)] + end +end diff --git a/app/models/form/lettings/pages/property_major_repairs.rb b/app/models/form/lettings/pages/property_major_repairs.rb new file mode 100644 index 000000000..54a32a1ad --- /dev/null +++ b/app/models/form/lettings/pages/property_major_repairs.rb @@ -0,0 +1,25 @@ +class Form::Lettings::Pages::PropertyMajorRepairs < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "property_major_repairs" + @depends_on = [ + { "renewal" => 0, "rsnvac" => 5 }, + { "renewal" => 0, "rsnvac" => 6 }, + { "renewal" => 0, "rsnvac" => 8 }, + { "renewal" => 0, "rsnvac" => 9 }, + { "renewal" => 0, "rsnvac" => 10 }, + { "renewal" => 0, "rsnvac" => 11 }, + { "renewal" => 0, "rsnvac" => 12 }, + { "renewal" => 0, "rsnvac" => 13 }, + { "renewal" => 0, "rsnvac" => 18 }, + { "renewal" => 0, "rsnvac" => 19 }, + ] + end + + def questions + @questions ||= [ + Form::Lettings::Questions::Majorrepairs.new(nil, nil, self), + Form::Lettings::Questions::Mrcdate.new(nil, nil, self), + ] + end +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 new file mode 100644 index 000000000..21e2b2b51 --- /dev/null +++ b/app/models/form/lettings/pages/property_major_repairs_value_check.rb @@ -0,0 +1,13 @@ +class Form::Lettings::Pages::PropertyMajorRepairsValueCheck < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "property_major_repairs_value_check" + @depends_on = [{ "major_repairs_date_in_soft_range?" => true }] + @title_text = { "translation" => "soft_validations.major_repairs_date.title_text" } + @informative_text = {} + end + + def questions + @questions ||= [Form::Lettings::Questions::MajorRepairsDateValueCheck.new(nil, nil, self)] + end +end diff --git a/app/models/form/lettings/pages/property_number_of_bedrooms.rb b/app/models/form/lettings/pages/property_number_of_bedrooms.rb new file mode 100644 index 000000000..89c056e00 --- /dev/null +++ b/app/models/form/lettings/pages/property_number_of_bedrooms.rb @@ -0,0 +1,11 @@ +class Form::Lettings::Pages::PropertyNumberOfBedrooms < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "property_number_of_bedrooms" + @depends_on = [{ "needstype" => 1 }] + end + + def questions + @questions ||= [Form::Lettings::Questions::Beds.new(nil, nil, self)] + end +end diff --git a/app/models/form/lettings/pages/property_number_of_times_relet_not_social_let.rb b/app/models/form/lettings/pages/property_number_of_times_relet_not_social_let.rb new file mode 100644 index 000000000..6061fcaaa --- /dev/null +++ b/app/models/form/lettings/pages/property_number_of_times_relet_not_social_let.rb @@ -0,0 +1,11 @@ +class Form::Lettings::Pages::PropertyNumberOfTimesReletNotSocialLet < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "property_number_of_times_relet_not_social_let" + @depends_on = [{ "first_time_property_let_as_social_housing" => 0, "renewal" => 0 }] + end + + def questions + @questions ||= [Form::Lettings::Questions::Offered.new(nil, nil, self)] + end +end diff --git a/app/models/form/lettings/pages/property_number_of_times_relet_social_let.rb b/app/models/form/lettings/pages/property_number_of_times_relet_social_let.rb new file mode 100644 index 000000000..f1a136249 --- /dev/null +++ b/app/models/form/lettings/pages/property_number_of_times_relet_social_let.rb @@ -0,0 +1,11 @@ +class Form::Lettings::Pages::PropertyNumberOfTimesReletSocialLet < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "property_number_of_times_relet_social_let" + @depends_on = [{ "first_time_property_let_as_social_housing" => 1, "renewal" => 0 }] + end + + def questions + @questions ||= [Form::Lettings::Questions::OfferedSocialLet.new(nil, nil, self)] + end +end diff --git a/app/models/form/lettings/pages/property_postcode.rb b/app/models/form/lettings/pages/property_postcode.rb new file mode 100644 index 000000000..720cd3106 --- /dev/null +++ b/app/models/form/lettings/pages/property_postcode.rb @@ -0,0 +1,14 @@ +class Form::Lettings::Pages::PropertyPostcode < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "property_postcode" + @depends_on = [{ "needstype" => 1 }] + end + + def questions + @questions ||= [ + Form::Lettings::Questions::PostcodeKnown.new(nil, nil, self), + Form::Lettings::Questions::PostcodeFull.new(nil, nil, self), + ] + end +end diff --git a/app/models/form/lettings/pages/property_unit_type.rb b/app/models/form/lettings/pages/property_unit_type.rb new file mode 100644 index 000000000..6db4db4e4 --- /dev/null +++ b/app/models/form/lettings/pages/property_unit_type.rb @@ -0,0 +1,11 @@ +class Form::Lettings::Pages::PropertyUnitType < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "property_unit_type" + @depends_on = [{ "needstype" => 1 }] + end + + def questions + @questions ||= [Form::Lettings::Questions::UnittypeGn.new(nil, nil, self)] + end +end diff --git a/app/models/form/lettings/pages/property_vacancy_reason_first_let.rb b/app/models/form/lettings/pages/property_vacancy_reason_first_let.rb new file mode 100644 index 000000000..3a14827de --- /dev/null +++ b/app/models/form/lettings/pages/property_vacancy_reason_first_let.rb @@ -0,0 +1,11 @@ +class Form::Lettings::Pages::PropertyVacancyReasonFirstLet < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "property_vacancy_reason_first_let" + @depends_on = [{ "first_time_property_let_as_social_housing" => 1, "renewal" => 0 }] + end + + def questions + @questions ||= [Form::Lettings::Questions::RsnvacFirstLet.new(nil, nil, self)] + end +end diff --git a/app/models/form/lettings/pages/property_vacancy_reason_not_first_let.rb b/app/models/form/lettings/pages/property_vacancy_reason_not_first_let.rb new file mode 100644 index 000000000..1b2c147ed --- /dev/null +++ b/app/models/form/lettings/pages/property_vacancy_reason_not_first_let.rb @@ -0,0 +1,11 @@ +class Form::Lettings::Pages::PropertyVacancyReasonNotFirstLet < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "property_vacancy_reason_not_first_let" + @depends_on = [{ "first_time_property_let_as_social_housing" => 0, "renewal" => 0 }] + end + + def questions + @questions ||= [Form::Lettings::Questions::Rsnvac.new(nil, nil, self)] + end +end diff --git a/app/models/form/lettings/pages/property_wheelchair_accessible.rb b/app/models/form/lettings/pages/property_wheelchair_accessible.rb new file mode 100644 index 000000000..5f12fb06c --- /dev/null +++ b/app/models/form/lettings/pages/property_wheelchair_accessible.rb @@ -0,0 +1,11 @@ +class Form::Lettings::Pages::PropertyWheelchairAccessible < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "property_wheelchair_accessible" + @depends_on = [{ "needstype" => 1 }] + end + + def questions + @questions ||= [Form::Lettings::Questions::Wchair.new(nil, nil, self)] + end +end diff --git a/app/models/form/lettings/pages/reason_for_leaving_last_settled_home.rb b/app/models/form/lettings/pages/reason_for_leaving_last_settled_home.rb new file mode 100644 index 000000000..f5e3a24d1 --- /dev/null +++ b/app/models/form/lettings/pages/reason_for_leaving_last_settled_home.rb @@ -0,0 +1,14 @@ +class Form::Lettings::Pages::ReasonForLeavingLastSettledHome < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "reason_for_leaving_last_settled_home" + @depends_on = [{ "renewal" => 0 }] + end + + def questions + @questions ||= [ + Form::Lettings::Questions::Reason.new(nil, nil, self), + Form::Lettings::Questions::Reasonother.new(nil, nil, self), + ] + end +end diff --git a/app/models/form/lettings/pages/reason_for_leaving_last_settled_home_renewal.rb b/app/models/form/lettings/pages/reason_for_leaving_last_settled_home_renewal.rb new file mode 100644 index 000000000..ba025915f --- /dev/null +++ b/app/models/form/lettings/pages/reason_for_leaving_last_settled_home_renewal.rb @@ -0,0 +1,11 @@ +class Form::Lettings::Pages::ReasonForLeavingLastSettledHomeRenewal < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "reason_for_leaving_last_settled_home_renewal" + @depends_on = [{ "renewal" => 1 }] + end + + def questions + @questions ||= [Form::Lettings::Questions::ReasonRenewal.new(nil, nil, self)] + end +end diff --git a/app/models/form/lettings/pages/reasonable_preference.rb b/app/models/form/lettings/pages/reasonable_preference.rb new file mode 100644 index 000000000..f25e9b8aa --- /dev/null +++ b/app/models/form/lettings/pages/reasonable_preference.rb @@ -0,0 +1,5 @@ +class Form::Lettings::Pages::ReasonablePreference < ::Form::Page + def questions + @questions ||= [Form::Lettings::Questions::Reasonpref.new(nil, nil, self)] + end +end diff --git a/app/models/form/lettings/pages/reasonable_preference_reason.rb b/app/models/form/lettings/pages/reasonable_preference_reason.rb new file mode 100644 index 000000000..d4d2bb1d0 --- /dev/null +++ b/app/models/form/lettings/pages/reasonable_preference_reason.rb @@ -0,0 +1,11 @@ +class Form::Lettings::Pages::ReasonablePreferenceReason < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "reasonable_preference_reason" + @depends_on = [{ "reasonpref" => 1 }] + end + + def questions + @questions ||= [Form::Lettings::Questions::ReasonablePreferenceReason.new(nil, nil, self)] + end +end diff --git a/app/models/form/lettings/pages/referral.rb b/app/models/form/lettings/pages/referral.rb new file mode 100644 index 000000000..3850fd400 --- /dev/null +++ b/app/models/form/lettings/pages/referral.rb @@ -0,0 +1,11 @@ +class Form::Lettings::Pages::Referral < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "referral" + @depends_on = [{ "managing_organisation_provider_type" => "LA", "needstype" => 1, "renewal" => 0 }] + end + + def questions + @questions ||= [Form::Lettings::Questions::Referral.new(nil, nil, self)] + end +end diff --git a/app/models/form/lettings/pages/referral_prp.rb b/app/models/form/lettings/pages/referral_prp.rb new file mode 100644 index 000000000..b1f650d8e --- /dev/null +++ b/app/models/form/lettings/pages/referral_prp.rb @@ -0,0 +1,11 @@ +class Form::Lettings::Pages::ReferralPrp < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "referral_prp" + @depends_on = [{ "managing_organisation_provider_type" => "PRP", "needstype" => 1, "renewal" => 0 }] + end + + def questions + @questions ||= [Form::Lettings::Questions::ReferralPrp.new(nil, nil, self)] + end +end diff --git a/app/models/form/lettings/pages/referral_supported_housing.rb b/app/models/form/lettings/pages/referral_supported_housing.rb new file mode 100644 index 000000000..80d69b8cd --- /dev/null +++ b/app/models/form/lettings/pages/referral_supported_housing.rb @@ -0,0 +1,11 @@ +class Form::Lettings::Pages::ReferralSupportedHousing < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "referral_supported_housing" + @depends_on = [{ "managing_organisation_provider_type" => "LA", "needstype" => 2, "renewal" => 0 }] + end + + def questions + @questions ||= [Form::Lettings::Questions::ReferralSupportedHousing.new(nil, nil, self)] + end +end diff --git a/app/models/form/lettings/pages/referral_supported_housing_prp.rb b/app/models/form/lettings/pages/referral_supported_housing_prp.rb new file mode 100644 index 000000000..244f85fcd --- /dev/null +++ b/app/models/form/lettings/pages/referral_supported_housing_prp.rb @@ -0,0 +1,11 @@ +class Form::Lettings::Pages::ReferralSupportedHousingPrp < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "referral_supported_housing_prp" + @depends_on = [{ "managing_organisation_provider_type" => "PRP", "needstype" => 2, "renewal" => 0 }] + end + + def questions + @questions ||= [Form::Lettings::Questions::ReferralSupportedHousingPrp.new(nil, nil, self)] + end +end diff --git a/app/models/form/lettings/pages/rent_4_weekly.rb b/app/models/form/lettings/pages/rent_4_weekly.rb new file mode 100644 index 000000000..fd8518e8e --- /dev/null +++ b/app/models/form/lettings/pages/rent_4_weekly.rb @@ -0,0 +1,23 @@ +class Form::Lettings::Pages::Rent4Weekly < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "rent_4_weekly" + @header = "Household rent and charges" + @depends_on = [ + { "household_charge" => 0, "period" => 3, "is_carehome" => 0 }, + { "household_charge" => nil, "period" => 3, "is_carehome" => 0 }, + { "household_charge" => 0, "period" => 3, "is_carehome" => nil }, + { "household_charge" => nil, "period" => 3, "is_carehome" => nil }, + ] + end + + def questions + @questions ||= [ + Form::Lettings::Questions::Brent4Weekly.new(nil, nil, self), + Form::Lettings::Questions::Scharge4Weekly.new(nil, nil, self), + Form::Lettings::Questions::Pscharge4Weekly.new(nil, nil, self), + Form::Lettings::Questions::Supcharg4Weekly.new(nil, nil, self), + Form::Lettings::Questions::Tcharge4Weekly.new(nil, nil, self), + ] + end +end diff --git a/app/models/form/lettings/pages/rent_bi_weekly.rb b/app/models/form/lettings/pages/rent_bi_weekly.rb new file mode 100644 index 000000000..66ebef76b --- /dev/null +++ b/app/models/form/lettings/pages/rent_bi_weekly.rb @@ -0,0 +1,23 @@ +class Form::Lettings::Pages::RentBiWeekly < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "rent_bi_weekly" + @header = "Household rent and charges" + @depends_on = [ + { "household_charge" => 0, "period" => 2, "is_carehome" => 0 }, + { "household_charge" => nil, "period" => 2, "is_carehome" => 0 }, + { "household_charge" => 0, "period" => 2, "is_carehome" => nil }, + { "household_charge" => nil, "period" => 2, "is_carehome" => nil }, + ] + end + + def questions + @questions ||= [ + Form::Lettings::Questions::BrentBiWeekly.new(nil, nil, self), + Form::Lettings::Questions::SchargeBiWeekly.new(nil, nil, self), + Form::Lettings::Questions::PschargeBiWeekly.new(nil, nil, self), + Form::Lettings::Questions::SupchargBiWeekly.new(nil, nil, self), + Form::Lettings::Questions::TchargeBiWeekly.new(nil, nil, self), + ] + end +end diff --git a/app/models/form/lettings/pages/rent_monthly.rb b/app/models/form/lettings/pages/rent_monthly.rb new file mode 100644 index 000000000..04664bc93 --- /dev/null +++ b/app/models/form/lettings/pages/rent_monthly.rb @@ -0,0 +1,23 @@ +class Form::Lettings::Pages::RentMonthly < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "rent_monthly" + @header = "Household rent and charges" + @depends_on = [ + { "household_charge" => 0, "period" => 4, "is_carehome" => 0 }, + { "household_charge" => nil, "period" => 4, "is_carehome" => 0 }, + { "household_charge" => 0, "period" => 4, "is_carehome" => nil }, + { "household_charge" => nil, "period" => 4, "is_carehome" => nil }, + ] + end + + def questions + @questions ||= [ + Form::Lettings::Questions::BrentMonthly.new(nil, nil, self), + Form::Lettings::Questions::SchargeMonthly.new(nil, nil, self), + Form::Lettings::Questions::PschargeMonthly.new(nil, nil, self), + Form::Lettings::Questions::SupchargMonthly.new(nil, nil, self), + Form::Lettings::Questions::TchargeMonthly.new(nil, nil, self), + ] + end +end diff --git a/app/models/form/lettings/pages/rent_or_other_charges.rb b/app/models/form/lettings/pages/rent_or_other_charges.rb new file mode 100644 index 000000000..0f27508e0 --- /dev/null +++ b/app/models/form/lettings/pages/rent_or_other_charges.rb @@ -0,0 +1,11 @@ +class Form::Lettings::Pages::RentOrOtherCharges < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "rent_or_other_charges" + @depends_on = [{ "needstype" => 2 }] + end + + def questions + @questions ||= [Form::Lettings::Questions::HouseholdCharge.new(nil, nil, self)] + end +end diff --git a/app/models/form/lettings/pages/rent_period.rb b/app/models/form/lettings/pages/rent_period.rb new file mode 100644 index 000000000..da121a305 --- /dev/null +++ b/app/models/form/lettings/pages/rent_period.rb @@ -0,0 +1,11 @@ +class Form::Lettings::Pages::RentPeriod < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "rent_period" + @depends_on = [{ "household_charge" => 0 }, { "household_charge" => nil }] + end + + def questions + @questions ||= [Form::Lettings::Questions::Period.new(nil, nil, self)] + end +end diff --git a/app/models/form/lettings/pages/rent_weekly.rb b/app/models/form/lettings/pages/rent_weekly.rb new file mode 100644 index 000000000..ab89b31af --- /dev/null +++ b/app/models/form/lettings/pages/rent_weekly.rb @@ -0,0 +1,43 @@ +class Form::Lettings::Pages::RentWeekly < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "rent_weekly" + @header = "Household rent and charges" + @depends_on = [ + { "period" => 1, "household_charge" => 0, "is_carehome" => 0 }, + { "period" => 1, "household_charge" => nil, "is_carehome" => 0 }, + { "period" => 5, "household_charge" => 0, "is_carehome" => 0 }, + { "period" => 5, "household_charge" => nil, "is_carehome" => 0 }, + { "period" => 6, "household_charge" => 0, "is_carehome" => 0 }, + { "period" => 6, "household_charge" => nil, "is_carehome" => 0 }, + { "period" => 7, "household_charge" => 0, "is_carehome" => 0 }, + { "period" => 7, "household_charge" => nil, "is_carehome" => 0 }, + { "period" => 8, "household_charge" => 0, "is_carehome" => 0 }, + { "period" => 8, "household_charge" => nil, "is_carehome" => 0 }, + { "period" => 9, "household_charge" => 0, "is_carehome" => 0 }, + { "period" => 9, "household_charge" => nil, "is_carehome" => 0 }, + { "period" => 1, "household_charge" => 0, "is_carehome" => nil }, + { "period" => 1, "household_charge" => nil, "is_carehome" => nil }, + { "period" => 5, "household_charge" => 0, "is_carehome" => nil }, + { "period" => 5, "household_charge" => nil, "is_carehome" => nil }, + { "period" => 6, "household_charge" => 0, "is_carehome" => nil }, + { "period" => 6, "household_charge" => nil, "is_carehome" => nil }, + { "period" => 7, "household_charge" => 0, "is_carehome" => nil }, + { "period" => 7, "household_charge" => nil, "is_carehome" => nil }, + { "period" => 8, "household_charge" => 0, "is_carehome" => nil }, + { "period" => 8, "household_charge" => nil, "is_carehome" => nil }, + { "period" => 9, "household_charge" => 0, "is_carehome" => nil }, + { "period" => 9, "household_charge" => nil, "is_carehome" => nil }, + ] + end + + def questions + @questions ||= [ + Form::Lettings::Questions::BrentWeekly.new(nil, nil, self), + Form::Lettings::Questions::SchargeWeekly.new(nil, nil, self), + Form::Lettings::Questions::PschargeWeekly.new(nil, nil, self), + Form::Lettings::Questions::SupchargWeekly.new(nil, nil, self), + Form::Lettings::Questions::TchargeWeekly.new(nil, nil, self), + ] + end +end diff --git a/app/models/form/lettings/pages/scheme.rb b/app/models/form/lettings/pages/scheme.rb index afa436864..9ac87a756 100644 --- a/app/models/form/lettings/pages/scheme.rb +++ b/app/models/form/lettings/pages/scheme.rb @@ -1,9 +1,11 @@ class Form::Lettings::Pages::Scheme < ::Form::Page def initialize(_id, hsh, subsection) super("scheme", hsh, subsection) - @depends_on = [{ - "needstype" => 2, - }] + @depends_on = [ + { + "needstype" => 2, + }, + ] @next_unresolved_page_id = "location" end diff --git a/app/models/form/lettings/pages/shelteredaccom.rb b/app/models/form/lettings/pages/shelteredaccom.rb new file mode 100644 index 000000000..df19b8c99 --- /dev/null +++ b/app/models/form/lettings/pages/shelteredaccom.rb @@ -0,0 +1,11 @@ +class Form::Lettings::Pages::Shelteredaccom < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "shelteredaccom" + @depends_on = [{ "needstype" => 2 }] + end + + def questions + @questions ||= [Form::Lettings::Questions::Sheltered.new(nil, nil, self)] + end +end diff --git a/app/models/form/lettings/pages/starter_tenancy.rb b/app/models/form/lettings/pages/starter_tenancy.rb new file mode 100644 index 000000000..09d76d46e --- /dev/null +++ b/app/models/form/lettings/pages/starter_tenancy.rb @@ -0,0 +1,5 @@ +class Form::Lettings::Pages::StarterTenancy < ::Form::Page + def questions + @questions ||= [Form::Lettings::Questions::Startertenancy.new(nil, nil, self)] + end +end diff --git a/app/models/form/lettings/pages/starter_tenancy_type.rb b/app/models/form/lettings/pages/starter_tenancy_type.rb new file mode 100644 index 000000000..c488b7b17 --- /dev/null +++ b/app/models/form/lettings/pages/starter_tenancy_type.rb @@ -0,0 +1,14 @@ +class Form::Lettings::Pages::StarterTenancyType < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "starter_tenancy_type" + @depends_on = [{ "startertenancy" => 1 }] + end + + def questions + @questions ||= [ + Form::Lettings::Questions::StarterTenancy.new(nil, nil, self), + Form::Lettings::Questions::Tenancyother.new(nil, nil, self), + ] + end +end diff --git a/app/models/form/lettings/pages/tenancy_length.rb b/app/models/form/lettings/pages/tenancy_length.rb new file mode 100644 index 000000000..943ea2bc9 --- /dev/null +++ b/app/models/form/lettings/pages/tenancy_length.rb @@ -0,0 +1,11 @@ +class Form::Lettings::Pages::TenancyLength < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "tenancy_length" + @depends_on = [{ "tenancy" => 4 }, { "tenancy" => 6 }, { "tenancy" => 3 }] + end + + def questions + @questions ||= [Form::Lettings::Questions::Tenancylength.new(nil, nil, self)] + end +end diff --git a/app/models/form/lettings/pages/tenancy_type.rb b/app/models/form/lettings/pages/tenancy_type.rb new file mode 100644 index 000000000..8ee6c3bbc --- /dev/null +++ b/app/models/form/lettings/pages/tenancy_type.rb @@ -0,0 +1,14 @@ +class Form::Lettings::Pages::TenancyType < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "tenancy_type" + @depends_on = [{ "startertenancy" => 2 }] + end + + def questions + @questions ||= [ + Form::Lettings::Questions::Tenancy.new(nil, nil, self), + Form::Lettings::Questions::Tenancyother.new(nil, nil, self), + ] + end +end diff --git a/app/models/form/lettings/pages/time_lived_in_local_authority.rb b/app/models/form/lettings/pages/time_lived_in_local_authority.rb new file mode 100644 index 000000000..b7ea61131 --- /dev/null +++ b/app/models/form/lettings/pages/time_lived_in_local_authority.rb @@ -0,0 +1,5 @@ +class Form::Lettings::Pages::TimeLivedInLocalAuthority < ::Form::Page + def questions + @questions ||= [Form::Lettings::Questions::Layear.new(nil, nil, self)] + end +end diff --git a/app/models/form/lettings/pages/time_on_waiting_list.rb b/app/models/form/lettings/pages/time_on_waiting_list.rb new file mode 100644 index 000000000..db424f898 --- /dev/null +++ b/app/models/form/lettings/pages/time_on_waiting_list.rb @@ -0,0 +1,11 @@ +class Form::Lettings::Pages::TimeOnWaitingList < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "time_on_waiting_list" + @depends_on = [{ "renewal" => 0 }] + end + + def questions + @questions ||= [Form::Lettings::Questions::Waityear.new(nil, nil, self)] + end +end diff --git a/app/models/form/lettings/pages/type_of_access_needs.rb b/app/models/form/lettings/pages/type_of_access_needs.rb new file mode 100644 index 000000000..670e2ef89 --- /dev/null +++ b/app/models/form/lettings/pages/type_of_access_needs.rb @@ -0,0 +1,15 @@ +class Form::Lettings::Pages::TypeOfAccessNeeds < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "type_of_access_needs" + @header = "Disabled access needs" + @depends_on = [{ "housingneeds" => 1 }] + end + + def questions + @questions ||= [ + Form::Lettings::Questions::HousingneedsType.new(nil, nil, self), + Form::Lettings::Questions::HousingneedsOther.new(nil, nil, self), + ] + end +end diff --git a/app/models/form/lettings/pages/void_date_value_check.rb b/app/models/form/lettings/pages/void_date_value_check.rb new file mode 100644 index 000000000..d717b38fe --- /dev/null +++ b/app/models/form/lettings/pages/void_date_value_check.rb @@ -0,0 +1,13 @@ +class Form::Lettings::Pages::VoidDateValueCheck < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "void_date_value_check" + @depends_on = [{ "voiddate_in_soft_range?" => true }] + @title_text = { "translation" => "soft_validations.void_date.title_text" } + @informative_text = {} + end + + def questions + @questions ||= [Form::Lettings::Questions::VoidDateValueCheck.new(nil, nil, self)] + end +end diff --git a/app/models/form/lettings/pages/void_or_renewal_date.rb b/app/models/form/lettings/pages/void_or_renewal_date.rb new file mode 100644 index 000000000..1ea4ea982 --- /dev/null +++ b/app/models/form/lettings/pages/void_or_renewal_date.rb @@ -0,0 +1,22 @@ +class Form::Lettings::Pages::VoidOrRenewalDate < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "void_or_renewal_date" + @depends_on = [ + { "renewal" => 0, "rsnvac" => 5 }, + { "renewal" => 0, "rsnvac" => 6 }, + { "renewal" => 0, "rsnvac" => 8 }, + { "renewal" => 0, "rsnvac" => 9 }, + { "renewal" => 0, "rsnvac" => 10 }, + { "renewal" => 0, "rsnvac" => 11 }, + { "renewal" => 0, "rsnvac" => 12 }, + { "renewal" => 0, "rsnvac" => 13 }, + { "renewal" => 0, "rsnvac" => 18 }, + { "renewal" => 0, "rsnvac" => 19 }, + ] + end + + def questions + @questions ||= [Form::Lettings::Questions::Voiddate.new(nil, nil, self)] + end +end diff --git a/app/models/form/lettings/questions/age.rb b/app/models/form/lettings/questions/age.rb new file mode 100644 index 000000000..f160f1948 --- /dev/null +++ b/app/models/form/lettings/questions/age.rb @@ -0,0 +1,15 @@ +class Form::Lettings::Questions::Age < ::Form::Question + def initialize(id, hsh, page, person_index:) + super(id, hsh, page) + @id = "age#{person_index}" + @check_answer_label = "Person #{person_index}’s age" + @header = "Age" + @type = "numeric" + @width = 2 + @inferred_check_answers_value = [{ "condition" => { "age#{person_index}_known" => 1 }, "value" => "Not known" }] + @check_answers_card_number = person_index + @max = 120 + @min = 0 + @step = 1 + end +end diff --git a/app/models/form/lettings/questions/age1.rb b/app/models/form/lettings/questions/age1.rb new file mode 100644 index 000000000..24512af28 --- /dev/null +++ b/app/models/form/lettings/questions/age1.rb @@ -0,0 +1,15 @@ +class Form::Lettings::Questions::Age1 < ::Form::Question + def initialize(id, hsh, page) + super + @id = "age1" + @check_answer_label = "Lead tenant’s age" + @header = "Age" + @type = "numeric" + @width = 2 + @inferred_check_answers_value = [{ "condition" => { "age1_known" => 1 }, "value" => "Not known" }] + @check_answers_card_number = 1 + @max = 120 + @min = 16 + @step = 1 + end +end diff --git a/app/models/form/lettings/questions/age1_known.rb b/app/models/form/lettings/questions/age1_known.rb new file mode 100644 index 000000000..d9899eb12 --- /dev/null +++ b/app/models/form/lettings/questions/age1_known.rb @@ -0,0 +1,16 @@ +class Form::Lettings::Questions::Age1Known < ::Form::Question + def initialize(id, hsh, page) + super + @id = "age1_known" + @check_answer_label = "" + @header = "Do you know the lead tenant’s age?" + @type = "radio" + @check_answers_card_number = 1 + @hint_text = "The ’lead’ or ’main’ tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest." + @answer_options = ANSWER_OPTIONS + @conditional_for = { "age1" => [0] } + @hidden_in_check_answers = { "depends_on" => [{ "age1_known" => 0 }, { "age1_known" => 1 }] } + end + + ANSWER_OPTIONS = { "0" => { "value" => "Yes" }, "1" => { "value" => "No" } }.freeze +end diff --git a/app/models/form/lettings/questions/age_known.rb b/app/models/form/lettings/questions/age_known.rb new file mode 100644 index 000000000..b7682c769 --- /dev/null +++ b/app/models/form/lettings/questions/age_known.rb @@ -0,0 +1,21 @@ +class Form::Lettings::Questions::AgeKnown < ::Form::Question + def initialize(id, hsh, page, person_index:) + super(id, hsh, page) + @id = "age#{person_index}_known" + @check_answer_label = "" + @header = "Do you know person #{person_index}’s age?" + @type = "radio" + @check_answers_card_number = person_index + @hint_text = "" + @answer_options = ANSWER_OPTIONS + @conditional_for = { "age#{person_index}" => [0] } + @hidden_in_check_answers = { + "depends_on" => [ + { "age#{person_index}_known" => 0 }, + { "age#{person_index}_known" => 1 }, + ], + } + end + + ANSWER_OPTIONS = { "0" => { "value" => "Yes" }, "1" => { "value" => "No" } }.freeze +end diff --git a/app/models/form/lettings/questions/armedforces.rb b/app/models/form/lettings/questions/armedforces.rb new file mode 100644 index 000000000..b5e34d81d --- /dev/null +++ b/app/models/form/lettings/questions/armedforces.rb @@ -0,0 +1,22 @@ +class Form::Lettings::Questions::Armedforces < ::Form::Question + def initialize(id, hsh, page) + super + @id = "armedforces" + @check_answer_label = "Household links to UK armed forces" + @header = "Does anybody in the household have any links to the UK armed forces?" + @type = "radio" + @check_answers_card_number = 0 + @hint_text = "This excludes national service.

If there are several people in the household with links to the UK armed forces, you should answer for the regular. If there’s no regular, answer for the reserve. If there’s no reserve, answer for the spouse or civil partner." + @answer_options = ANSWER_OPTIONS + end + + ANSWER_OPTIONS = { + "1" => { "value" => "Yes – the person is a current or former regular" }, + "4" => { "value" => "Yes – the person is a current or former reserve" }, + "5" => { "value" => "Yes – the person is a spouse or civil partner of a UK armed forces member and has been bereaved or separated from them within the last 2 years" }, + "2" => { "value" => "No" }, + "divider" => { "value" => true }, + "3" => { "value" => "Person prefers not to say" }, + "6" => { "value" => "Don’t know" }, + }.freeze +end diff --git a/app/models/form/lettings/questions/beds.rb b/app/models/form/lettings/questions/beds.rb new file mode 100644 index 000000000..cc3ceb885 --- /dev/null +++ b/app/models/form/lettings/questions/beds.rb @@ -0,0 +1,15 @@ +class Form::Lettings::Questions::Beds < ::Form::Question + def initialize(id, hsh, page) + super + @id = "beds" + @check_answer_label = "Number of bedrooms" + @header = "How many bedrooms does the property have?" + @type = "numeric" + @width = 2 + @check_answers_card_number = 0 + @max = 150 + @min = 0 + @hint_text = "If shared accommodation, enter the number of bedrooms occupied by this household. A bedsit has 1 bedroom." + @step = 1 + end +end diff --git a/app/models/form/lettings/questions/benefits.rb b/app/models/form/lettings/questions/benefits.rb new file mode 100644 index 000000000..27f90053d --- /dev/null +++ b/app/models/form/lettings/questions/benefits.rb @@ -0,0 +1,20 @@ +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 + end + + ANSWER_OPTIONS = { + "1" => { "value" => "All" }, + "2" => { "value" => "Some" }, + "3" => { "value" => "None" }, + "divider" => { "value" => true }, + "4" => { "value" => "Don’t know" }, + }.freeze +end diff --git a/app/models/form/lettings/questions/brent_4_weekly.rb b/app/models/form/lettings/questions/brent_4_weekly.rb new file mode 100644 index 000000000..c7659dbd4 --- /dev/null +++ b/app/models/form/lettings/questions/brent_4_weekly.rb @@ -0,0 +1,19 @@ +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?" + @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" + @hidden_in_check_answers = true + @prefix = "£" + @suffix = " every 4 weeks" + end +end diff --git a/app/models/form/lettings/questions/brent_bi_weekly.rb b/app/models/form/lettings/questions/brent_bi_weekly.rb new file mode 100644 index 000000000..7b1e1d04e --- /dev/null +++ b/app/models/form/lettings/questions/brent_bi_weekly.rb @@ -0,0 +1,19 @@ +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?" + @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" + @hidden_in_check_answers = true + @prefix = "£" + @suffix = " every 2 weeks" + end +end diff --git a/app/models/form/lettings/questions/brent_monthly.rb b/app/models/form/lettings/questions/brent_monthly.rb new file mode 100644 index 000000000..c58a21175 --- /dev/null +++ b/app/models/form/lettings/questions/brent_monthly.rb @@ -0,0 +1,19 @@ +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?" + @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" + @hidden_in_check_answers = true + @prefix = "£" + @suffix = " every month" + end +end diff --git a/app/models/form/lettings/questions/brent_weekly.rb b/app/models/form/lettings/questions/brent_weekly.rb new file mode 100644 index 000000000..0ea1f5359 --- /dev/null +++ b/app/models/form/lettings/questions/brent_weekly.rb @@ -0,0 +1,19 @@ +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?" + @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" + @hidden_in_check_answers = true + @prefix = "£" + @suffix = " every week" + end +end diff --git a/app/models/form/lettings/questions/builtype.rb b/app/models/form/lettings/questions/builtype.rb new file mode 100644 index 000000000..087699e0d --- /dev/null +++ b/app/models/form/lettings/questions/builtype.rb @@ -0,0 +1,17 @@ +class Form::Lettings::Questions::Builtype < ::Form::Question + def initialize(id, hsh, page) + super + @id = "builtype" + @check_answer_label = "Type of building" + @header = "What type of building is the property?" + @type = "radio" + @check_answers_card_number = 0 + @hint_text = "" + @answer_options = ANSWER_OPTIONS + end + + ANSWER_OPTIONS = { + "2" => { "value" => "Converted from previous residential or non-residential property" }, + "1" => { "value" => "Purpose built" }, + }.freeze +end diff --git a/app/models/form/lettings/questions/chcharge_4_weekly.rb b/app/models/form/lettings/questions/chcharge_4_weekly.rb new file mode 100644 index 000000000..c755a933b --- /dev/null +++ b/app/models/form/lettings/questions/chcharge_4_weekly.rb @@ -0,0 +1,15 @@ +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?" + @type = "numeric" + @width = 5 + @check_answers_card_number = 0 + @hint_text = "" + @step = 0.01 + @prefix = "£" + @suffix = " every 4 weeks" + end +end diff --git a/app/models/form/lettings/questions/chcharge_bi_weekly.rb b/app/models/form/lettings/questions/chcharge_bi_weekly.rb new file mode 100644 index 000000000..e65dc59a1 --- /dev/null +++ b/app/models/form/lettings/questions/chcharge_bi_weekly.rb @@ -0,0 +1,15 @@ +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?" + @type = "numeric" + @width = 5 + @check_answers_card_number = 0 + @hint_text = "" + @step = 0.01 + @prefix = "£" + @suffix = " every 2 weeks" + end +end diff --git a/app/models/form/lettings/questions/chcharge_monthly.rb b/app/models/form/lettings/questions/chcharge_monthly.rb new file mode 100644 index 000000000..f0bc7bb82 --- /dev/null +++ b/app/models/form/lettings/questions/chcharge_monthly.rb @@ -0,0 +1,15 @@ +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?" + @type = "numeric" + @width = 5 + @check_answers_card_number = 0 + @hint_text = "" + @step = 0.01 + @prefix = "£" + @suffix = " every month" + end +end diff --git a/app/models/form/lettings/questions/chcharge_weekly.rb b/app/models/form/lettings/questions/chcharge_weekly.rb new file mode 100644 index 000000000..874259215 --- /dev/null +++ b/app/models/form/lettings/questions/chcharge_weekly.rb @@ -0,0 +1,15 @@ +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?" + @type = "numeric" + @width = 5 + @check_answers_card_number = 0 + @hint_text = "" + @step = 0.01 + @prefix = "£" + @suffix = " every week" + end +end diff --git a/app/models/form/lettings/questions/condition_effects.rb b/app/models/form/lettings/questions/condition_effects.rb new file mode 100644 index 000000000..f89cfb3f2 --- /dev/null +++ b/app/models/form/lettings/questions/condition_effects.rb @@ -0,0 +1,31 @@ +class Form::Lettings::Questions::ConditionEffects < ::Form::Question + def initialize(id, hsh, page) + super + @id = "condition_effects" + @check_answer_label = "How is person affected by condition or illness" + @header = "How is the person affected by their condition or illness?" + @type = "checkbox" + @check_answers_card_number = 0 + @hint_text = "Select all that apply." + @answer_options = ANSWER_OPTIONS + end + + ANSWER_OPTIONS = { + "illness_type_4" => { + "value" => "Dexterity", + "hint" => "For example, lifting and carrying objects or using a keyboard.", + }, + "illness_type_5" => { "value" => "Learning or understanding or concentrating" }, + "illness_type_2" => { "value" => "Hearing", "hint" => "For example, deafness or partial hearing." }, + "illness_type_6" => { "value" => "Memory" }, + "illness_type_7" => { "value" => "Mental health", "hint" => "For example, depression or anxiety." }, + "illness_type_3" => { "value" => "Mobility", "hint" => "For example, walking short distances or climbing stairs." }, + "illness_type_9" => { + "value" => "Socially or behaviourally", + "hint" => "For example, associated with autism spectrum disorder (ASD) which includes Asperger’s or attention deficit hyperactivity disorder (ADHD).", + }, + "illness_type_8" => { "value" => "Stamina or breathing or fatigue" }, + "illness_type_1" => { "value" => "Vision", "hint" => "For example, blindness or partial sight." }, + "illness_type_10" => { "value" => "Other" }, + }.freeze +end diff --git a/app/models/form/lettings/questions/declaration.rb b/app/models/form/lettings/questions/declaration.rb new file mode 100644 index 000000000..a342fba6d --- /dev/null +++ b/app/models/form/lettings/questions/declaration.rb @@ -0,0 +1,14 @@ +class Form::Lettings::Questions::Declaration < ::Form::Question + def initialize(id, hsh, page) + super + @id = "declaration" + @check_answer_label = "Tenant has seen the privacy notice" + @header = "" + @type = "checkbox" + @check_answers_card_number = 0 + @guidance_partial = "privacy_notice_tenant" + @answer_options = ANSWER_OPTIONS + end + + ANSWER_OPTIONS = { "declaration" => { "value" => "The tenant has seen the DLUHC privacy notice" } }.freeze +end diff --git a/app/models/form/lettings/questions/details_known.rb b/app/models/form/lettings/questions/details_known.rb new file mode 100644 index 000000000..f2850b65e --- /dev/null +++ b/app/models/form/lettings/questions/details_known.rb @@ -0,0 +1,14 @@ +class Form::Lettings::Questions::DetailsKnown < ::Form::Question + def initialize(id, hsh, page, person_index:) + super(id, hsh, page) + @id = "details_known_#{person_index}" + @check_answer_label = "Details known for person #{person_index}" + @header = "Do you know details for person #{person_index}?" + @type = "radio" + @check_answers_card_number = person_index + @hint_text = "You must provide details for everyone in the household if you know them." + @answer_options = ANSWER_OPTIONS + end + + ANSWER_OPTIONS = { "0" => { "value" => "Yes" }, "1" => { "value" => "No" } }.freeze +end diff --git a/app/models/form/lettings/questions/earnings.rb b/app/models/form/lettings/questions/earnings.rb new file mode 100644 index 000000000..2647d0179 --- /dev/null +++ b/app/models/form/lettings/questions/earnings.rb @@ -0,0 +1,21 @@ +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?" + @type = "numeric" + @width = 5 + @check_answers_card_number = 0 + @min = 0 + @guidance_partial = "what_counts_as_income" + @hint_text = "" + @step = 1 + @prefix = "£" + @suffix = [ + { "label" => " every week", "depends_on" => { "incfreq" => 1 } }, + { "label" => " every month", "depends_on" => { "incfreq" => 2 } }, + { "label" => " every year", "depends_on" => { "incfreq" => 3 } }, + ] + end +end diff --git a/app/models/form/lettings/questions/ethnic_arab.rb b/app/models/form/lettings/questions/ethnic_arab.rb new file mode 100644 index 000000000..28b3591da --- /dev/null +++ b/app/models/form/lettings/questions/ethnic_arab.rb @@ -0,0 +1,21 @@ +class Form::Lettings::Questions::EthnicArab < ::Form::Question + def initialize(id, hsh, page) + super + @id = "ethnic" + @check_answer_label = "Lead tenant’s ethnic background" + @header = "Which of the following best describes the lead tenant’s Arab background?" + @type = "radio" + @check_answers_card_number = 1 + @hint_text = "The lead tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest." + @answer_options = ANSWER_OPTIONS + end + + ANSWER_OPTIONS = { + "19" => { + "value" => "Arab", + }, + "16" => { + "value" => "Other ethnic group", + }, + }.freeze +end diff --git a/app/models/form/lettings/questions/ethnic_asian.rb b/app/models/form/lettings/questions/ethnic_asian.rb new file mode 100644 index 000000000..96b8df9b5 --- /dev/null +++ b/app/models/form/lettings/questions/ethnic_asian.rb @@ -0,0 +1,30 @@ +class Form::Lettings::Questions::EthnicAsian < ::Form::Question + def initialize(id, hsh, page) + super + @id = "ethnic" + @check_answer_label = "Lead tenant’s ethnic background" + @header = "Which of the following best describes the lead tenant’s Asian or Asian British background?" + @type = "radio" + @check_answers_card_number = 1 + @hint_text = "The lead tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest." + @answer_options = ANSWER_OPTIONS + end + + ANSWER_OPTIONS = { + "10" => { + "value" => "Bangladeshi", + }, + "15" => { + "value" => "Chinese", + }, + "8" => { + "value" => "Indian", + }, + "9" => { + "value" => "Pakistani", + }, + "11" => { + "value" => "Any other Asian or Asian British background", + }, + }.freeze +end diff --git a/app/models/form/lettings/questions/ethnic_black.rb b/app/models/form/lettings/questions/ethnic_black.rb new file mode 100644 index 000000000..68beca8ad --- /dev/null +++ b/app/models/form/lettings/questions/ethnic_black.rb @@ -0,0 +1,24 @@ +class Form::Lettings::Questions::EthnicBlack < ::Form::Question + def initialize(id, hsh, page) + super + @id = "ethnic" + @check_answer_label = "Lead tenant’s ethnic background" + @header = "Which of the following best describes the lead tenant’s Black, African, Caribbean or Black British background?" + @type = "radio" + @check_answers_card_number = 1 + @hint_text = "The lead tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest." + @answer_options = ANSWER_OPTIONS + end + + ANSWER_OPTIONS = { + "13" => { + "value" => "African", + }, + "12" => { + "value" => "Caribbean", + }, + "14" => { + "value" => "Any other Black, African or Caribbean background", + }, + }.freeze +end diff --git a/app/models/form/lettings/questions/ethnic_group.rb b/app/models/form/lettings/questions/ethnic_group.rb new file mode 100644 index 000000000..4f7364296 --- /dev/null +++ b/app/models/form/lettings/questions/ethnic_group.rb @@ -0,0 +1,22 @@ +class Form::Lettings::Questions::EthnicGroup < ::Form::Question + def initialize(id, hsh, page) + super + @id = "ethnic_group" + @check_answer_label = "Lead tenant’s ethnic group" + @header = "What is the lead tenant’s ethnic group?" + @type = "radio" + @check_answers_card_number = 1 + @hint_text = "The lead tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest." + @answer_options = ANSWER_OPTIONS + end + + ANSWER_OPTIONS = { + "0" => { "value" => "White" }, + "1" => { "value" => "Mixed or Multiple ethnic groups" }, + "2" => { "value" => "Asian or Asian British" }, + "3" => { "value" => "Black, African, Caribbean or Black British" }, + "4" => { "value" => "Arab or other ethnic group" }, + "divider" => { "value" => true }, + "17" => { "value" => "Tenant prefers not to say" }, + }.freeze +end diff --git a/app/models/form/lettings/questions/ethnic_mixed.rb b/app/models/form/lettings/questions/ethnic_mixed.rb new file mode 100644 index 000000000..6160e40a5 --- /dev/null +++ b/app/models/form/lettings/questions/ethnic_mixed.rb @@ -0,0 +1,27 @@ +class Form::Lettings::Questions::EthnicMixed < ::Form::Question + def initialize(id, hsh, page) + super + @id = "ethnic" + @check_answer_label = "Lead tenant’s ethnic background" + @header = "Which of the following best describes the lead tenant’s Mixed or Multiple ethnic groups background?" + @type = "radio" + @check_answers_card_number = 1 + @hint_text = "The lead tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest." + @answer_options = ANSWER_OPTIONS + end + + ANSWER_OPTIONS = { + "4" => { + "value" => "White and Black Caribbean", + }, + "5" => { + "value" => "White and Black African", + }, + "6" => { + "value" => "White and Asian", + }, + "7" => { + "value" => "Any other Mixed or Multiple ethnic background", + }, + }.freeze +end diff --git a/app/models/form/lettings/questions/ethnic_white.rb b/app/models/form/lettings/questions/ethnic_white.rb new file mode 100644 index 000000000..993237a44 --- /dev/null +++ b/app/models/form/lettings/questions/ethnic_white.rb @@ -0,0 +1,19 @@ +class Form::Lettings::Questions::EthnicWhite < ::Form::Question + def initialize(id, hsh, page) + super + @id = "ethnic" + @check_answer_label = "Lead tenant’s ethnic background" + @header = "Which of the following best describes the lead tenant’s White background?" + @type = "radio" + @check_answers_card_number = 1 + @hint_text = "The lead tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest." + @answer_options = ANSWER_OPTIONS + end + + ANSWER_OPTIONS = { + "1" => { "value" => "English, Welsh, Northern Irish, Scottish or British" }, + "2" => { "value" => "Irish" }, + "18" => { "value" => "Gypsy or Irish Traveller" }, + "3" => { "value" => "Any other White background" }, + }.freeze +end 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 new file mode 100644 index 000000000..62f0bba19 --- /dev/null +++ b/app/models/form/lettings/questions/first_time_property_let_as_social_housing.rb @@ -0,0 +1,17 @@ +class Form::Lettings::Questions::FirstTimePropertyLetAsSocialHousing < ::Form::Question + def initialize(id, hsh, page) + super + @id = "first_time_property_let_as_social_housing" + @check_answer_label = "First time being let as social-housing?" + @header = "Is this the first time the property has been let as social housing?" + @type = "radio" + @check_answers_card_number = 0 + @hint_text = "" + @answer_options = ANSWER_OPTIONS + end + + ANSWER_OPTIONS = { + "1" => { "value" => "Yes", "hint" => "This is a new let." }, + "0" => { "value" => "No", "hint" => "This is a re-let of existing social housing." }, + }.freeze +end diff --git a/app/models/form/lettings/questions/gender_identity1.rb b/app/models/form/lettings/questions/gender_identity1.rb new file mode 100644 index 000000000..2f5c8f45e --- /dev/null +++ b/app/models/form/lettings/questions/gender_identity1.rb @@ -0,0 +1,20 @@ +class Form::Lettings::Questions::GenderIdentity1 < ::Form::Question + def initialize(id, hsh, page) + super + @id = "sex1" + @check_answer_label = "Lead tenant’s gender identity" + @header = "Which of these best describes the lead tenant’s gender identity?" + @type = "radio" + @check_answers_card_number = 1 + @hint_text = "The lead tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest." + @answer_options = ANSWER_OPTIONS + end + + ANSWER_OPTIONS = { + "F" => { "value" => "Female" }, + "M" => { "value" => "Male" }, + "X" => { "value" => "Non-binary" }, + "divider" => { "value" => true }, + "R" => { "value" => "Tenant prefers not to say" }, + }.freeze +end diff --git a/app/models/form/lettings/questions/hb.rb b/app/models/form/lettings/questions/hb.rb new file mode 100644 index 000000000..e8da0e146 --- /dev/null +++ b/app/models/form/lettings/questions/hb.rb @@ -0,0 +1,21 @@ +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 = "" + @answer_options = ANSWER_OPTIONS + end + + ANSWER_OPTIONS = { + "1" => { "value" => "Housing benefit" }, + "6" => { "value" => "Universal Credit housing element" }, + "9" => { "value" => "Neither" }, + "divider" => { "value" => true }, + "3" => { "value" => "Don’t know" }, + "10" => { "value" => "Tenant prefers not to say" }, + }.freeze +end diff --git a/app/models/form/lettings/questions/hbrentshortfall.rb b/app/models/form/lettings/questions/hbrentshortfall.rb new file mode 100644 index 000000000..687ac3aeb --- /dev/null +++ b/app/models/form/lettings/questions/hbrentshortfall.rb @@ -0,0 +1,18 @@ +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 + end + + ANSWER_OPTIONS = { + "1" => { "value" => "Yes" }, + "2" => { "value" => "No" }, + "3" => { "value" => "Don’t know" }, + }.freeze +end diff --git a/app/models/form/lettings/questions/hhmemb.rb b/app/models/form/lettings/questions/hhmemb.rb new file mode 100644 index 000000000..3c6e6c3af --- /dev/null +++ b/app/models/form/lettings/questions/hhmemb.rb @@ -0,0 +1,15 @@ +class Form::Lettings::Questions::Hhmemb < ::Form::Question + def initialize(id, hsh, page) + super + @id = "hhmemb" + @check_answer_label = "Number of household members" + @header = "How many people live in the household for this letting?" + @type = "numeric" + @width = 2 + @check_answers_card_number = 0 + @max = 8 + @min = 1 + @hint_text = "You can provide details for a maximum of 8 people." + @step = 1 + end +end diff --git a/app/models/form/lettings/questions/homeless.rb b/app/models/form/lettings/questions/homeless.rb new file mode 100644 index 000000000..fcfc117d2 --- /dev/null +++ b/app/models/form/lettings/questions/homeless.rb @@ -0,0 +1,17 @@ +class Form::Lettings::Questions::Homeless < ::Form::Question + def initialize(id, hsh, page) + super + @id = "homeless" + @check_answer_label = "Household homeless immediately before letting" + @header = "Did the household experience homelessness immediately before this letting?" + @type = "radio" + @check_answers_card_number = 0 + @hint_text = "" + @answer_options = ANSWER_OPTIONS + end + + ANSWER_OPTIONS = { + "11" => { "value" => "Assessed by a local authority as homeless" }, + "1" => { "value" => "No" }, + }.freeze +end diff --git a/app/models/form/lettings/questions/household_charge.rb b/app/models/form/lettings/questions/household_charge.rb new file mode 100644 index 000000000..1a8ade65a --- /dev/null +++ b/app/models/form/lettings/questions/household_charge.rb @@ -0,0 +1,14 @@ +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 + end + + ANSWER_OPTIONS = { "0" => { "value" => "Yes" }, "1" => { "value" => "No" } }.freeze +end diff --git a/app/models/form/lettings/questions/housingneeds.rb b/app/models/form/lettings/questions/housingneeds.rb new file mode 100644 index 000000000..cd8a3275d --- /dev/null +++ b/app/models/form/lettings/questions/housingneeds.rb @@ -0,0 +1,19 @@ +class Form::Lettings::Questions::Housingneeds < ::Form::Question + def initialize(id, hsh, page) + super + @id = "housingneeds" + @check_answer_label = "Anybody with disabled access needs" + @header = "Does anybody in the household have any disabled access needs?" + @type = "radio" + @check_answers_card_number = 0 + @hint_text = "" + @answer_options = ANSWER_OPTIONS + end + + ANSWER_OPTIONS = { + "1" => { "value" => "Yes" }, + "2" => { "value" => "No" }, + "divider" => { "value" => true }, + "3" => { "value" => "Don’t know" }, + }.freeze +end diff --git a/app/models/form/lettings/questions/housingneeds_other.rb b/app/models/form/lettings/questions/housingneeds_other.rb new file mode 100644 index 000000000..14d6c6d01 --- /dev/null +++ b/app/models/form/lettings/questions/housingneeds_other.rb @@ -0,0 +1,14 @@ +class Form::Lettings::Questions::HousingneedsOther < ::Form::Question + def initialize(id, hsh, page) + super + @id = "housingneeds_other" + @check_answer_label = "Other disabled access needs" + @header = "Do they have any other access needs?" + @type = "radio" + @check_answers_card_number = 0 + @hint_text = "" + @answer_options = ANSWER_OPTIONS + end + + ANSWER_OPTIONS = { "1" => { "value" => "Yes" }, "0" => { "value" => "No" } }.freeze +end diff --git a/app/models/form/lettings/questions/housingneeds_type.rb b/app/models/form/lettings/questions/housingneeds_type.rb new file mode 100644 index 000000000..a06f28705 --- /dev/null +++ b/app/models/form/lettings/questions/housingneeds_type.rb @@ -0,0 +1,20 @@ +class Form::Lettings::Questions::HousingneedsType < ::Form::Question + def initialize(id, hsh, page) + super + @id = "housingneeds_type" + @check_answer_label = "Disabled access needs" + @header = "What type of access needs do they have?" + @type = "radio" + @check_answers_card_number = 0 + @hint_text = "" + @answer_options = ANSWER_OPTIONS + end + + ANSWER_OPTIONS = { + "0" => { "value" => "Fully wheelchair accessible housing" }, + "1" => { "value" => "Wheelchair access to essential rooms" }, + "2" => { "value" => "Level access housing" }, + "divider" => { "value" => true }, + "3" => { "value" => "None of the listed options" }, + }.freeze +end diff --git a/app/models/form/lettings/questions/illness.rb b/app/models/form/lettings/questions/illness.rb new file mode 100644 index 000000000..d2a3b09dd --- /dev/null +++ b/app/models/form/lettings/questions/illness.rb @@ -0,0 +1,19 @@ +class Form::Lettings::Questions::Illness < ::Form::Question + def initialize(id, hsh, page) + super + @id = "illness" + @check_answer_label = "Anybody in household with physical or mental health condition" + @header = "Does anybody in the household have a physical or mental health condition (or other illness) expected to last 12 months or more?" + @type = "radio" + @check_answers_card_number = 0 + @hint_text = "" + @answer_options = ANSWER_OPTIONS + end + + ANSWER_OPTIONS = { + "1" => { "value" => "Yes" }, + "2" => { "value" => "No" }, + "divider" => { "value" => true }, + "3" => { "value" => "Tenant prefers not to say" }, + }.freeze +end diff --git a/app/models/form/lettings/questions/incfreq.rb b/app/models/form/lettings/questions/incfreq.rb new file mode 100644 index 000000000..0d347c0da --- /dev/null +++ b/app/models/form/lettings/questions/incfreq.rb @@ -0,0 +1,19 @@ +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?" + @type = "radio" + @check_answers_card_number = 0 + @hint_text = "" + @answer_options = ANSWER_OPTIONS + @hidden_in_check_answers = true + end + + ANSWER_OPTIONS = { + "1" => { "value" => "Weekly" }, + "2" => { "value" => "Monthly" }, + "3" => { "value" => "Yearly" }, + }.freeze +end diff --git a/app/models/form/lettings/questions/is_carehome.rb b/app/models/form/lettings/questions/is_carehome.rb new file mode 100644 index 000000000..6f17acc0d --- /dev/null +++ b/app/models/form/lettings/questions/is_carehome.rb @@ -0,0 +1,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?" + @type = "radio" + @check_answers_card_number = 0 + @hint_text = "" + @answer_options = ANSWER_OPTIONS + @conditional_for = { "chcharge" => [1] } + end + + ANSWER_OPTIONS = { "0" => { "value" => "No" }, "1" => { "value" => "Yes" } }.freeze +end diff --git a/app/models/form/lettings/questions/joint.rb b/app/models/form/lettings/questions/joint.rb new file mode 100644 index 000000000..484678f2b --- /dev/null +++ b/app/models/form/lettings/questions/joint.rb @@ -0,0 +1,19 @@ +class Form::Lettings::Questions::Joint < ::Form::Question + def initialize(id, hsh, page) + super + @id = "joint" + @check_answer_label = "Is this a joint tenancy?" + @header = "Is this a joint tenancy?" + @type = "radio" + @check_answers_card_number = 0 + @hint_text = "" + @answer_options = ANSWER_OPTIONS + end + + ANSWER_OPTIONS = { + "1" => { "value" => "Yes" }, + "2" => { "value" => "No" }, + "divider" => { "value" => "true" }, + "3" => { "value" => "Don’t know" }, + }.freeze +end diff --git a/app/models/form/lettings/questions/la.rb b/app/models/form/lettings/questions/la.rb new file mode 100644 index 000000000..a25bdac10 --- /dev/null +++ b/app/models/form/lettings/questions/la.rb @@ -0,0 +1,332 @@ +class Form::Lettings::Questions::La < ::Form::Question + def initialize(id, hsh, page) + super + @id = "la" + @check_answer_label = "Local Authority" + @header = "What is the local authority of the property?" + @type = "select" + @check_answers_card_number = 0 + @hint_text = "" + @answer_options = ANSWER_OPTIONS + end + + ANSWER_OPTIONS = { + "" => "Select an option", + "E07000223" => "Adur", + "E07000026" => "Allerdale", + "E07000032" => "Amber Valley", + "E07000224" => "Arun", + "E07000170" => "Ashfield", + "E07000105" => "Ashford", + "E07000200" => "Babergh", + "E09000002" => "Barking and Dagenham", + "E09000003" => "Barnet", + "E08000016" => "Barnsley", + "E07000027" => "Barrow-in-Furness", + "E07000066" => "Basildon", + "E07000084" => "Basingstoke and Deane", + "E07000171" => "Bassetlaw", + "E06000022" => "Bath and North East Somerset", + "E06000055" => "Bedford", + "E09000004" => "Bexley", + "E08000025" => "Birmingham", + "E07000129" => "Blaby", + "E06000008" => "Blackburn with Darwen", + "E06000009" => "Blackpool", + "E07000033" => "Bolsover", + "E08000001" => "Bolton", + "E07000136" => "Boston", + "E06000058" => "Bournemouth, Christchurch and Poole", + "E06000036" => "Bracknell Forest", + "E08000032" => "Bradford", + "E07000067" => "Braintree", + "E07000143" => "Breckland", + "E09000005" => "Brent", + "E07000068" => "Brentwood", + "E06000043" => "Brighton and Hove", + "E06000023" => "Bristol, City of", + "E07000144" => "Broadland", + "E09000006" => "Bromley", + "E07000234" => "Bromsgrove", + "E07000095" => "Broxbourne", + "E07000172" => "Broxtowe", + "E06000060" => "Buckinghamshire", + "E07000117" => "Burnley", + "E08000002" => "Bury", + "E08000033" => "Calderdale", + "E07000008" => "Cambridge", + "E09000007" => "Camden", + "E07000192" => "Cannock Chase", + "E07000106" => "Canterbury", + "E07000028" => "Carlisle", + "E07000069" => "Castle Point", + "E06000056" => "Central Bedfordshire", + "E07000130" => "Charnwood", + "E07000070" => "Chelmsford", + "E07000078" => "Cheltenham", + "E07000177" => "Cherwell", + "E06000049" => "Cheshire East", + "E06000050" => "Cheshire West and Chester", + "E07000034" => "Chesterfield", + "E07000225" => "Chichester", + "E07000118" => "Chorley", + "E09000001" => "City of London", + "E07000071" => "Colchester", + "E07000029" => "Copeland", + "E07000150" => "Corby", + "E06000052" => "Cornwall", + "E07000079" => "Cotswold", + "E06000047" => "County Durham", + "E08000026" => "Coventry", + "E07000163" => "Craven", + "E07000226" => "Crawley", + "E09000008" => "Croydon", + "E07000096" => "Dacorum", + "E06000005" => "Darlington", + "E07000107" => "Dartford", + "E07000151" => "Daventry", + "E06000015" => "Derby", + "E07000035" => "Derbyshire Dales", + "E08000017" => "Doncaster", + "E06000059" => "Dorset", + "E07000108" => "Dover", + "E08000027" => "Dudley", + "E09000009" => "Ealing", + "E07000009" => "East Cambridgeshire", + "E07000040" => "East Devon", + "E07000085" => "East Hampshire", + "E07000242" => "East Hertfordshire", + "E07000137" => "East Lindsey", + "E07000152" => "East Northamptonshire", + "E06000011" => "East Riding of Yorkshire", + "E07000193" => "East Staffordshire", + "E07000244" => "East Suffolk", + "E07000061" => "Eastbourne", + "E07000086" => "Eastleigh", + "E07000030" => "Eden", + "E07000207" => "Elmbridge", + "E09000010" => "Enfield", + "E07000072" => "Epping Forest", + "E07000208" => "Epsom and Ewell", + "E07000036" => "Erewash", + "E07000041" => "Exeter", + "E07000087" => "Fareham", + "E07000010" => "Fenland", + "E07000112" => "Folkestone and Hythe", + "E07000080" => "Forest of Dean", + "E07000119" => "Fylde", + "E08000037" => "Gateshead", + "E07000173" => "Gedling", + "E07000081" => "Gloucester", + "E07000088" => "Gosport", + "E07000109" => "Gravesham", + "E07000145" => "Great Yarmouth", + "E09000011" => "Greenwich", + "E07000209" => "Guildford", + "W06000002" => "Gwynedd", + "E09000012" => "Hackney", + "E06000006" => "Halton", + "E07000164" => "Hambleton", + "E09000013" => "Hammersmith and Fulham", + "E07000131" => "Harborough", + "E09000014" => "Haringey", + "E07000073" => "Harlow", + "E07000165" => "Harrogate", + "E09000015" => "Harrow", + "E07000089" => "Hart", + "E06000001" => "Hartlepool", + "E07000062" => "Hastings", + "E07000090" => "Havant", + "E09000016" => "Havering", + "E06000019" => "Herefordshire, County of", + "E07000098" => "Hertsmere", + "E07000037" => "High Peak", + "S12000017" => "Highland", + "E09000017" => "Hillingdon", + "E07000132" => "Hinckley and Bosworth", + "E07000227" => "Horsham", + "E09000018" => "Hounslow", + "E07000011" => "Huntingdonshire", + "E07000120" => "Hyndburn", + "E07000202" => "Ipswich", + "E06000046" => "Isle of Wight", + "E06000053" => "Isles of Scilly", + "E09000019" => "Islington", + "E09000020" => "Kensington and Chelsea", + "E07000153" => "Kettering", + "E07000146" => "King’s Lynn and West Norfolk", + "E06000010" => "Kingston upon Hull, City of", + "E09000021" => "Kingston upon Thames", + "E08000034" => "Kirklees", + "E08000011" => "Knowsley", + "E09000022" => "Lambeth", + "E07000121" => "Lancaster", + "E08000035" => "Leeds", + "E06000016" => "Leicester", + "E07000063" => "Lewes", + "E09000023" => "Lewisham", + "E07000194" => "Lichfield", + "E07000138" => "Lincoln", + "E08000012" => "Liverpool", + "E06000032" => "Luton", + "E07000110" => "Maidstone", + "E07000074" => "Maldon", + "E07000235" => "Malvern Hills", + "E08000003" => "Manchester", + "E07000174" => "Mansfield", + "E06000035" => "Medway", + "E07000133" => "Melton", + "E07000187" => "Mendip", + "E09000024" => "Merton", + "E07000042" => "Mid Devon", + "E07000203" => "Mid Suffolk", + "E07000228" => "Mid Sussex", + "E06000002" => "Middlesbrough", + "E06000042" => "Milton Keynes", + "E07000210" => "Mole Valley", + "E07000091" => "New Forest", + "E07000175" => "Newark and Sherwood", + "E08000021" => "Newcastle upon Tyne", + "E07000195" => "Newcastle-under-Lyme", + "E09000025" => "Newham", + "E07000043" => "North Devon", + "E07000038" => "North East Derbyshire", + "E06000012" => "North East Lincolnshire", + "E07000099" => "North Hertfordshire", + "E07000139" => "North Kesteven", + "E06000013" => "North Lincolnshire", + "E07000147" => "North Norfolk", + "E06000024" => "North Somerset", + "E08000022" => "North Tyneside", + "E07000218" => "North Warwickshire", + "E07000134" => "North West Leicestershire", + "E07000154" => "Northampton", + "E06000057" => "Northumberland", + "E07000148" => "Norwich", + "E06000018" => "Nottingham", + "E07000219" => "Nuneaton and Bedworth", + "E07000135" => "Oadby and Wigston", + "E08000004" => "Oldham", + "E07000178" => "Oxford", + "E07000122" => "Pendle", + "E06000031" => "Peterborough", + "E06000026" => "Plymouth", + "E06000044" => "Portsmouth", + "E07000123" => "Preston", + "E06000038" => "Reading", + "E09000026" => "Redbridge", + "E06000003" => "Redcar and Cleveland", + "E07000236" => "Redditch", + "E07000211" => "Reigate and Banstead", + "E07000124" => "Ribble Valley", + "E09000027" => "Richmond upon Thames", + "E07000166" => "Richmondshire", + "E08000005" => "Rochdale", + "E07000075" => "Rochford", + "E07000125" => "Rossendale", + "E07000064" => "Rother", + "E08000018" => "Rotherham", + "E07000220" => "Rugby", + "E07000212" => "Runnymede", + "E07000176" => "Rushcliffe", + "E07000092" => "Rushmoor", + "E06000017" => "Rutland", + "E07000167" => "Ryedale", + "E08000006" => "Salford", + "E08000028" => "Sandwell", + "E07000168" => "Scarborough", + "E07000188" => "Sedgemoor", + "E08000014" => "Sefton", + "E07000169" => "Selby", + "E07000111" => "Sevenoaks", + "E08000019" => "Sheffield", + "E06000051" => "Shropshire", + "E06000039" => "Slough", + "E08000029" => "Solihull", + "E07000246" => "Somerset West and Taunton", + "E07000012" => "South Cambridgeshire", + "E07000039" => "South Derbyshire", + "E06000025" => "South Gloucestershire", + "E07000044" => "South Hams", + "E07000140" => "South Holland", + "E07000141" => "South Kesteven", + "E07000031" => "South Lakeland", + "E07000149" => "South Norfolk", + "E07000155" => "South Northamptonshire", + "E07000179" => "South Oxfordshire", + "E07000126" => "South Ribble", + "E07000189" => "South Somerset", + "E07000196" => "South Staffordshire", + "E08000023" => "South Tyneside", + "E06000045" => "Southampton", + "E06000033" => "Southend-on-Sea", + "E09000028" => "Southwark", + "E07000213" => "Spelthorne", + "E07000240" => "St Albans", + "E08000013" => "St. Helens", + "E07000197" => "Stafford", + "E07000198" => "Staffordshire Moorlands", + "E07000243" => "Stevenage", + "E08000007" => "Stockport", + "E06000004" => "Stockton-on-Tees", + "E06000021" => "Stoke-on-Trent", + "E07000221" => "Stratford-on-Avon", + "E07000082" => "Stroud", + "E08000024" => "Sunderland", + "E07000214" => "Surrey Heath", + "E09000029" => "Sutton", + "E07000113" => "Swale", + "E06000030" => "Swindon", + "E08000008" => "Tameside", + "E07000199" => "Tamworth", + "E07000215" => "Tandridge", + "E07000045" => "Teignbridge", + "E06000020" => "Telford and Wrekin", + "E07000076" => "Tendring", + "E07000093" => "Test Valley", + "E07000083" => "Tewkesbury", + "E07000114" => "Thanet", + "E07000102" => "Three Rivers", + "E06000034" => "Thurrock", + "E07000115" => "Tonbridge and Malling", + "E06000027" => "Torbay", + "E07000046" => "Torridge", + "E09000030" => "Tower Hamlets", + "E08000009" => "Trafford", + "E07000116" => "Tunbridge Wells", + "E07000077" => "Uttlesford", + "E07000180" => "Vale of White Horse", + "E08000036" => "Wakefield", + "E08000030" => "Walsall", + "E09000031" => "Waltham Forest", + "E09000032" => "Wandsworth", + "E06000007" => "Warrington", + "E07000222" => "Warwick", + "E07000103" => "Watford", + "E07000216" => "Waverley", + "E07000065" => "Wealden", + "E07000156" => "Wellingborough", + "E07000241" => "Welwyn Hatfield", + "E06000037" => "West Berkshire", + "E07000047" => "West Devon", + "E07000127" => "West Lancashire", + "E07000142" => "West Lindsey", + "E07000181" => "West Oxfordshire", + "E07000245" => "West Suffolk", + "E09000033" => "Westminster", + "E08000010" => "Wigan", + "E06000054" => "Wiltshire", + "E07000094" => "Winchester", + "E06000040" => "Windsor and Maidenhead", + "E08000015" => "Wirral", + "E07000217" => "Woking", + "E06000041" => "Wokingham", + "E08000031" => "Wolverhampton", + "E07000237" => "Worcester", + "E07000229" => "Worthing", + "E07000238" => "Wychavon", + "E07000128" => "Wyre", + "E07000239" => "Wyre Forest", + "E06000014" => "York", + }.freeze +end diff --git a/app/models/form/lettings/questions/layear.rb b/app/models/form/lettings/questions/layear.rb new file mode 100644 index 000000000..14a334399 --- /dev/null +++ b/app/models/form/lettings/questions/layear.rb @@ -0,0 +1,24 @@ +class Form::Lettings::Questions::Layear < ::Form::Question + def initialize(id, hsh, page) + super + @id = "layear" + @check_answer_label = "Length of time in local authority area" + @header = "How long has the household continuously lived in the local authority area of the new letting?" + @type = "radio" + @check_answers_card_number = 0 + @hint_text = "" + @answer_options = ANSWER_OPTIONS + end + + ANSWER_OPTIONS = { + "1" => { "value" => "Just moved to local authority area" }, + "2" => { "value" => "Less than 1 year" }, + "7" => { "value" => "1 year but under 2 years" }, + "8" => { "value" => "2 years but under 3 years" }, + "9" => { "value" => "3 years but under 4 years" }, + "10" => { "value" => "4 years but under 5 years" }, + "5" => { "value" => "5 years or more" }, + "divider" => { "value" => true }, + "6" => { "value" => "Don’t know" }, + }.freeze +end diff --git a/app/models/form/lettings/questions/leftreg.rb b/app/models/form/lettings/questions/leftreg.rb new file mode 100644 index 000000000..2601f351d --- /dev/null +++ b/app/models/form/lettings/questions/leftreg.rb @@ -0,0 +1,20 @@ +class Form::Lettings::Questions::Leftreg < ::Form::Question + def initialize(id, hsh, page) + super + @id = "leftreg" + @check_answer_label = "Person still serving in UK armed forces" + @header = "Is the person still serving in the UK armed forces?" + @type = "radio" + @check_answers_card_number = 0 + @hint_text = "" + @answer_options = ANSWER_OPTIONS + end + + ANSWER_OPTIONS = { + "0" => { "value" => "Yes" }, + "1" => { "value" => "No – they left up to and including 5 years ago" }, + "2" => { "value" => "No – they left more than 5 years ago" }, + "divider" => { "value" => true }, + "3" => { "value" => "Person prefers not to say" }, + }.freeze +end diff --git a/app/models/form/lettings/questions/letting_allocation.rb b/app/models/form/lettings/questions/letting_allocation.rb new file mode 100644 index 000000000..e41f52b09 --- /dev/null +++ b/app/models/form/lettings/questions/letting_allocation.rb @@ -0,0 +1,20 @@ +class Form::Lettings::Questions::LettingAllocation < ::Form::Question + def initialize(id, hsh, page) + super + @id = "letting_allocation" + @check_answer_label = "Allocation system" + @header = "How was this letting allocated?" + @type = "checkbox" + @check_answers_card_number = 0 + @hint_text = "Select all that apply." + @answer_options = ANSWER_OPTIONS + end + + ANSWER_OPTIONS = { + "cbl" => { "value" => "Choice-based lettings (CBL)" }, + "cap" => { "value" => "Common Allocation Policy (CAP)" }, + "chr" => { "value" => "Common housing register (CHR)" }, + "divider" => { "value" => true }, + "letting_allocation_unknown" => { "value" => "None of these allocation systems" }, + }.freeze +end diff --git a/app/models/form/lettings/questions/location_id.rb b/app/models/form/lettings/questions/location_id.rb index 07ed61318..5a99e7734 100644 --- a/app/models/form/lettings/questions/location_id.rb +++ b/app/models/form/lettings/questions/location_id.rb @@ -16,7 +16,8 @@ class Form::Lettings::Questions::LocationId < ::Form::Question answer_opts = {} return answer_opts unless ActiveRecord::Base.connected? - Location.select(:id, :postcode, :name).where("startdate <= ? or startdate IS NULL", Time.zone.today).each_with_object(answer_opts) do |location, hsh| + Location.select(:id, :postcode, :name).where("startdate <= ? or startdate IS NULL", + Time.zone.today).each_with_object(answer_opts) do |location, hsh| hsh[location.id.to_s] = { "value" => location.postcode, "hint" => location.name } hsh end 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 new file mode 100644 index 000000000..d024f1a8d --- /dev/null +++ b/app/models/form/lettings/questions/major_repairs_date_value_check.rb @@ -0,0 +1,19 @@ +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?" + @type = "interruption_screen" + @check_answers_card_number = 0 + @answer_options = ANSWER_OPTIONS + @hidden_in_check_answers = { + "depends_on" => [ + { "major_repairs_date_value_check" => 0 }, + { "major_repairs_date_value_check" => 1 }, + ], + } + end + + ANSWER_OPTIONS = { "0" => { "value" => "Yes" }, "1" => { "value" => "No" } }.freeze +end diff --git a/app/models/form/lettings/questions/majorrepairs.rb b/app/models/form/lettings/questions/majorrepairs.rb new file mode 100644 index 000000000..e0a6fdb01 --- /dev/null +++ b/app/models/form/lettings/questions/majorrepairs.rb @@ -0,0 +1,15 @@ +class Form::Lettings::Questions::Majorrepairs < ::Form::Question + def initialize(id, hsh, page) + super + @id = "majorrepairs" + @check_answer_label = "Major repairs carried out during void period" + @header = "Were any major repairs carried out during the void period?" + @type = "radio" + @check_answers_card_number = 0 + @hint_text = "Major repairs are works that could not be reasonably carried out with a tenant living at the property. For example, structural repairs." + @answer_options = ANSWER_OPTIONS + @conditional_for = { "mrcdate" => [1] } + end + + ANSWER_OPTIONS = { "1" => { "value" => "Yes" }, "0" => { "value" => "No" } }.freeze +end diff --git a/app/models/form/lettings/questions/managing_organisation.rb b/app/models/form/lettings/questions/managing_organisation.rb index e2e3b3e3d..bd9cbb8b9 100644 --- a/app/models/form/lettings/questions/managing_organisation.rb +++ b/app/models/form/lettings/questions/managing_organisation.rb @@ -1,48 +1,45 @@ class Form::Lettings::Questions::ManagingOrganisation < ::Form::Question - attr_accessor :current_user, :log - def initialize(id, hsh, page) super @id = "managing_organisation_id" @check_answer_label = "Managing agent" @header = "Which organisation manages this letting?" @type = "select" - @answer_options = answer_options end - def answer_options + def answer_options(log = nil, user = nil) opts = { "" => "Select an option" } return opts unless ActiveRecord::Base.connected? - return opts unless current_user + return opts unless user return opts unless log if log.managing_organisation.present? opts = opts.merge({ log.managing_organisation.id => log.managing_organisation.name }) end - if current_user.support? + if user.support? if log.owning_organisation.holds_own_stock? opts[log.owning_organisation.id] = "#{log.owning_organisation.name} (Owning organisation)" end else - opts[current_user.organisation.id] = "#{current_user.organisation.name} (Your organisation)" + opts[user.organisation.id] = "#{user.organisation.name} (Your organisation)" end - opts.merge(managing_organisations_answer_options) + orgs = if user.support? + log.owning_organisation + else + user.organisation + end.managing_agents.pluck(:id, :name).to_h + + opts.merge(orgs) end def displayed_answer_options(log, user) - @current_user = user - @log = log - - answer_options + answer_options(log, user) end - def label_from_value(value, log = nil, user = nil) - @log = log - @current_user = user - + def label_from_value(value, _log = nil, _user = nil) return unless value answer_options[value] @@ -53,25 +50,20 @@ class Form::Lettings::Questions::ManagingOrganisation < ::Form::Question end def hidden_in_check_answers?(log, user = nil) - @current_user = user - @current_user.nil? || !@page.routed_to?(log, user) + user.nil? || !@page.routed_to?(log, user) end def enabled true end + def answer_label(log, _current_user = nil) + Organisation.find_by(id: log.managing_organisation_id)&.name + end + private def selected_answer_option_is_derived?(_log) true end - - def managing_organisations_answer_options - if current_user.support? - log.owning_organisation - else - current_user.organisation - end.managing_agents.pluck(:id, :name).to_h - end end diff --git a/app/models/form/lettings/questions/mrcdate.rb b/app/models/form/lettings/questions/mrcdate.rb new file mode 100644 index 000000000..a3718af47 --- /dev/null +++ b/app/models/form/lettings/questions/mrcdate.rb @@ -0,0 +1,11 @@ +class Form::Lettings::Questions::Mrcdate < ::Form::Question + def initialize(id, hsh, page) + super + @id = "mrcdate" + @check_answer_label = "Completion date of repairs" + @header = "When were the repairs completed?" + @type = "date" + @check_answers_card_number = 0 + @hint_text = "For example, 27 3 2021." + end +end diff --git a/app/models/form/lettings/questions/national.rb b/app/models/form/lettings/questions/national.rb new file mode 100644 index 000000000..0bfe198e0 --- /dev/null +++ b/app/models/form/lettings/questions/national.rb @@ -0,0 +1,21 @@ +class Form::Lettings::Questions::National < ::Form::Question + def initialize(id, hsh, page) + super + @id = "national" + @check_answer_label = "Lead tenant’s nationality" + @header = "What is the lead tenant’s nationality?" + @type = "radio" + @check_answers_card_number = 1 + @hint_text = "The lead tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest." + @answer_options = ANSWER_OPTIONS + end + + ANSWER_OPTIONS = { + "18" => { "value" => "United Kingdom" }, + "17" => { "value" => "Republic of Ireland" }, + "19" => { "value" => "European Economic Area (EEA) country, excluding Ireland" }, + "12" => { "value" => "Other" }, + "divider" => true, + "13" => { "value" => "Tenant prefers not to say" }, + }.freeze +end diff --git a/app/models/form/lettings/questions/net_income_known.rb b/app/models/form/lettings/questions/net_income_known.rb new file mode 100644 index 000000000..5e9b1b4da --- /dev/null +++ b/app/models/form/lettings/questions/net_income_known.rb @@ -0,0 +1,20 @@ +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 income?" + @header = "Do you know the household’s combined income after tax?" + @type = "radio" + @check_answers_card_number = 0 + @guidance_partial = "what_counts_as_income" + @hint_text = "" + @answer_options = ANSWER_OPTIONS + end + + ANSWER_OPTIONS = { + "0" => { "value" => "Yes" }, + "1" => { "value" => "No" }, + "divider_a" => { "value" => true }, + "2" => { "value" => "Tenant prefers not to say" }, + }.freeze +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 new file mode 100644 index 000000000..8267b3b22 --- /dev/null +++ b/app/models/form/lettings/questions/net_income_value_check.rb @@ -0,0 +1,19 @@ +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?" + @type = "interruption_screen" + @check_answers_card_number = 0 + @answer_options = ANSWER_OPTIONS + @hidden_in_check_answers = { + "depends_on" => [ + { "net_income_value_check" => 0 }, + { "net_income_value_check" => 1 }, + ], + } + end + + ANSWER_OPTIONS = { "0" => { "value" => "Yes" }, "1" => { "value" => "No" } }.freeze +end diff --git a/app/models/form/lettings/questions/no_retirement_value_check.rb b/app/models/form/lettings/questions/no_retirement_value_check.rb new file mode 100644 index 000000000..43fe68e10 --- /dev/null +++ b/app/models/form/lettings/questions/no_retirement_value_check.rb @@ -0,0 +1,19 @@ +class Form::Lettings::Questions::NoRetirementValueCheck < ::Form::Question + def initialize(id, hsh, page) + super + @id = "retirement_value_check" + @check_answer_label = "Retirement confirmation" + @header = "Are you sure this person is retired?" + @type = "interruption_screen" + @check_answers_card_number = 8 + @answer_options = ANSWER_OPTIONS + @hidden_in_check_answers = { + "depends_on" => [ + { "retirement_value_check" => 0 }, + { "retirement_value_check" => 1 }, + ], + } + end + + ANSWER_OPTIONS = { "0" => { "value" => "Yes" }, "1" => { "value" => "No" } }.freeze +end diff --git a/app/models/form/lettings/questions/offered.rb b/app/models/form/lettings/questions/offered.rb new file mode 100644 index 000000000..ebc2bac1b --- /dev/null +++ b/app/models/form/lettings/questions/offered.rb @@ -0,0 +1,15 @@ +class Form::Lettings::Questions::Offered < ::Form::Question + def initialize(id, hsh, page) + super + @id = "offered" + @check_answer_label = "Times previously offered since becoming available" + @header = "Since becoming available for re-let, how many times has the property been previously offered?" + @type = "numeric" + @width = 2 + @check_answers_card_number = 0 + @max = 150 + @min = 0 + @hint_text = "This is after the last tenancy ended. If the property is being offered for let for the first time, enter 0." + @step = 1 + end +end diff --git a/app/models/form/lettings/questions/offered_social_let.rb b/app/models/form/lettings/questions/offered_social_let.rb new file mode 100644 index 000000000..d2658a8e6 --- /dev/null +++ b/app/models/form/lettings/questions/offered_social_let.rb @@ -0,0 +1,15 @@ +class Form::Lettings::Questions::OfferedSocialLet < ::Form::Question + def initialize(id, hsh, page) + super + @id = "offered" + @check_answer_label = "Times previously offered since becoming available" + @header = "Since becoming available, how many times has the property been previously offered?" + @type = "numeric" + @width = 2 + @check_answers_card_number = 0 + @max = 150 + @min = 0 + @hint_text = "If the property is being offered for let for the first time, enter 0." + @step = 1 + end +end diff --git a/app/models/form/lettings/questions/period.rb b/app/models/form/lettings/questions/period.rb new file mode 100644 index 000000000..cf0b4d13a --- /dev/null +++ b/app/models/form/lettings/questions/period.rb @@ -0,0 +1,24 @@ +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 = "" + @answer_options = ANSWER_OPTIONS + end + + ANSWER_OPTIONS = { + "2" => { "value" => "Every 2 weeks" }, + "3" => { "value" => "Every 4 weeks" }, + "4" => { "value" => "Every calendar month" }, + "5" => { "value" => "Weekly for 50 weeks" }, + "6" => { "value" => "Weekly for 49 weeks" }, + "7" => { "value" => "Weekly for 48 weeks" }, + "8" => { "value" => "Weekly for 47 weeks" }, + "9" => { "value" => "Weekly for 46 weeks" }, + "1" => { "value" => "Weekly for 52 weeks" }, + }.freeze +end diff --git a/app/models/form/lettings/questions/person_gender_identity.rb b/app/models/form/lettings/questions/person_gender_identity.rb new file mode 100644 index 000000000..cb8f04ef2 --- /dev/null +++ b/app/models/form/lettings/questions/person_gender_identity.rb @@ -0,0 +1,20 @@ +class Form::Lettings::Questions::PersonGenderIdentity < ::Form::Question + def initialize(id, hsh, page, person_index:) + super(id, hsh, page) + @id = "sex#{person_index}" + @check_answer_label = "Person #{person_index}’s gender identity" + @header = "Which of these best describes person #{person_index}’s gender identity?" + @type = "radio" + @check_answers_card_number = person_index + @hint_text = "" + @answer_options = ANSWER_OPTIONS + end + + ANSWER_OPTIONS = { + "F" => { "value" => "Female" }, + "M" => { "value" => "Male" }, + "X" => { "value" => "Non-binary" }, + "divider" => { "value" => true }, + "R" => { "value" => "Person prefers not to say" }, + }.freeze +end diff --git a/app/models/form/lettings/questions/person_relationship.rb b/app/models/form/lettings/questions/person_relationship.rb new file mode 100644 index 000000000..debb14a03 --- /dev/null +++ b/app/models/form/lettings/questions/person_relationship.rb @@ -0,0 +1,23 @@ +class Form::Lettings::Questions::PersonRelationship < ::Form::Question + def initialize(id, hsh, page, person_index:) + super(id, hsh, page) + @id = "relat#{person_index}" + @check_answer_label = "Person #{person_index}’s relationship to the lead tenant" + @header = "What is person #{person_index}’s relationship to the lead tenant?" + @type = "radio" + @check_answers_card_number = person_index + @hint_text = "" + @answer_options = ANSWER_OPTIONS + end + + ANSWER_OPTIONS = { + "P" => { "value" => "Partner" }, + "C" => { + "value" => "Child", + "hint" => "Must be eligible for child benefit, aged under 16 or under 20 if still in full-time education.", + }, + "X" => { "value" => "Other" }, + "divider" => { "value" => true }, + "R" => { "value" => "Person prefers not to say" }, + }.freeze +end diff --git a/app/models/form/lettings/questions/person_working_situation.rb b/app/models/form/lettings/questions/person_working_situation.rb new file mode 100644 index 000000000..9174930a2 --- /dev/null +++ b/app/models/form/lettings/questions/person_working_situation.rb @@ -0,0 +1,33 @@ +class Form::Lettings::Questions::PersonWorkingSituation < ::Form::Question + def initialize(id, hsh, page, person_index:) + super(id, hsh, page) + @id = "ecstat#{person_index}" + @check_answer_label = "Person #{person_index}’s working situation" + @header = "Which of these best describes person #{person_index}’s working situation?" + @type = "radio" + @check_answers_card_number = person_index + @hint_text = "" + @answer_options = ANSWER_OPTIONS + end + + ANSWER_OPTIONS = { + "2" => { "value" => "Part-time – Less than 30 hours" }, + "1" => { "value" => "Full-time – 30 hours or more" }, + "7" => { "value" => "Full-time student" }, + "3" => { "value" => "In government training into work, such as New Deal" }, + "4" => { "value" => "Jobseeker" }, + "6" => { "value" => "Not seeking work" }, + "8" => { "value" => "Unable to work because of long term sick or disability" }, + "5" => { "value" => "Retired" }, + "9" => { + "value" => "Child under 16", + "depends_on" => [ + { "age2_known" => 1 }, + { "age2" => { "operator" => "<", "operand" => 16 } }, + ], + }, + "0" => { "value" => "Other" }, + "divider" => { "value" => true }, + "10" => { "value" => "Tenant prefers not to say" }, + }.freeze +end diff --git a/app/models/form/lettings/questions/postcode_full.rb b/app/models/form/lettings/questions/postcode_full.rb new file mode 100644 index 000000000..1f0a25c49 --- /dev/null +++ b/app/models/form/lettings/questions/postcode_full.rb @@ -0,0 +1,14 @@ +class Form::Lettings::Questions::PostcodeFull < ::Form::Question + def initialize(id, hsh, page) + super + @id = "postcode_full" + @check_answer_label = "Postcode" + @header = "What is the property’s postcode?" + @type = "text" + @width = 5 + @inferred_check_answers_value = [{ "condition" => { "postcode_known" => 0 }, "value" => "Not known" }] + @check_answers_card_number = 0 + @hint_text = "" + @inferred_answers = { "la" => { "is_la_inferred" => true } } + end +end diff --git a/app/models/form/lettings/questions/postcode_known.rb b/app/models/form/lettings/questions/postcode_known.rb new file mode 100644 index 000000000..6af30bb19 --- /dev/null +++ b/app/models/form/lettings/questions/postcode_known.rb @@ -0,0 +1,16 @@ +class Form::Lettings::Questions::PostcodeKnown < ::Form::Question + def initialize(id, hsh, page) + super + @id = "postcode_known" + @check_answer_label = "Do you know the property postcode?" + @header = "Do you know the property’s postcode?" + @type = "radio" + @check_answers_card_number = 0 + @hint_text = "" + @answer_options = ANSWER_OPTIONS + @conditional_for = { "postcode_full" => [1] } + @hidden_in_check_answers = { "depends_on" => [{ "postcode_known" => 0 }, { "postcode_known" => 1 }] } + end + + ANSWER_OPTIONS = { "1" => { "value" => "Yes" }, "0" => { "value" => "No" } }.freeze +end diff --git a/app/models/form/lettings/questions/ppcodenk.rb b/app/models/form/lettings/questions/ppcodenk.rb new file mode 100644 index 000000000..fa10f3d69 --- /dev/null +++ b/app/models/form/lettings/questions/ppcodenk.rb @@ -0,0 +1,16 @@ +class Form::Lettings::Questions::Ppcodenk < ::Form::Question + def initialize(id, hsh, page) + super + @id = "ppcodenk" + @check_answer_label = "" + @header = "Do you know the postcode of the household’s last settled accommodation?" + @type = "radio" + @check_answers_card_number = 0 + @hint_text = "This is also known as the household’s ‘last settled home’." + @answer_options = ANSWER_OPTIONS + @conditional_for = { "ppostcode_full" => [1] } + @hidden_in_check_answers = { "depends_on" => [{ "ppcodenk" => 0 }, { "ppcodenk" => 1 }] } + end + + ANSWER_OPTIONS = { "1" => { "value" => "Yes" }, "0" => { "value" => "No" } }.freeze +end diff --git a/app/models/form/lettings/questions/ppostcode_full.rb b/app/models/form/lettings/questions/ppostcode_full.rb new file mode 100644 index 000000000..736e06f16 --- /dev/null +++ b/app/models/form/lettings/questions/ppostcode_full.rb @@ -0,0 +1,14 @@ +class Form::Lettings::Questions::PpostcodeFull < ::Form::Question + def initialize(id, hsh, page) + super + @id = "ppostcode_full" + @check_answer_label = "Postcode of household’s last settled accommodation" + @header = "Postcode for the previous accommodation" + @type = "text" + @width = 5 + @inferred_check_answers_value = [{ "condition" => { "ppcodenk" => 0 }, "value" => "Not known" }] + @check_answers_card_number = 0 + @hint_text = "" + @inferred_answers = { "prevloc" => { "is_previous_la_inferred" => true } } + end +end diff --git a/app/models/form/lettings/questions/preg_occ.rb b/app/models/form/lettings/questions/preg_occ.rb new file mode 100644 index 000000000..c6b6f168f --- /dev/null +++ b/app/models/form/lettings/questions/preg_occ.rb @@ -0,0 +1,19 @@ +class Form::Lettings::Questions::PregOcc < ::Form::Question + def initialize(id, hsh, page) + super + @id = "preg_occ" + @check_answer_label = "Anybody in household pregnant" + @header = "Is anybody in the household pregnant?" + @type = "radio" + @check_answers_card_number = 0 + @hint_text = "" + @answer_options = ANSWER_OPTIONS + end + + ANSWER_OPTIONS = { + "1" => { "value" => "Yes" }, + "2" => { "value" => "No" }, + "divider" => { "value" => true }, + "3" => { "value" => "Tenant prefers not to say" }, + }.freeze +end diff --git a/app/models/form/lettings/questions/pregnancy_value_check.rb b/app/models/form/lettings/questions/pregnancy_value_check.rb new file mode 100644 index 000000000..a452e6015 --- /dev/null +++ b/app/models/form/lettings/questions/pregnancy_value_check.rb @@ -0,0 +1,14 @@ +class Form::Lettings::Questions::PregnancyValueCheck < ::Form::Question + def initialize(id, hsh, page) + super + @id = "pregnancy_value_check" + @check_answer_label = "Pregnancy confirmation" + @header = "Are you sure this is correct?" + @type = "interruption_screen" + @check_answers_card_number = 0 + @answer_options = ANSWER_OPTIONS + @hidden_in_check_answers = { "depends_on" => [{ "pregnancy_value_check" => 0 }, { "pregnancy_value_check" => 1 }] } + end + + ANSWER_OPTIONS = { "0" => { "value" => "Yes" }, "1" => { "value" => "No" } }.freeze +end diff --git a/app/models/form/lettings/questions/previous_la_known.rb b/app/models/form/lettings/questions/previous_la_known.rb new file mode 100644 index 000000000..0f563b62a --- /dev/null +++ b/app/models/form/lettings/questions/previous_la_known.rb @@ -0,0 +1,16 @@ +class Form::Lettings::Questions::PreviousLaKnown < ::Form::Question + def initialize(id, hsh, page) + super + @id = "previous_la_known" + @check_answer_label = "Do you know the local authority of the household’s last settled accommodation?" + @header = "Do you know the local authority of the household’s last settled accommodation?" + @type = "radio" + @check_answers_card_number = 0 + @hint_text = "This is also known as the household’s ‘last settled home’." + @answer_options = ANSWER_OPTIONS + @conditional_for = { "prevloc" => [1] } + @hidden_in_check_answers = { "depends_on" => [{ "previous_la_known" => 0 }, { "previous_la_known" => 1 }] } + end + + ANSWER_OPTIONS = { "1" => { "value" => "Yes" }, "0" => { "value" => "No" } }.freeze +end diff --git a/app/models/form/lettings/questions/prevloc.rb b/app/models/form/lettings/questions/prevloc.rb new file mode 100644 index 000000000..e5a433f3f --- /dev/null +++ b/app/models/form/lettings/questions/prevloc.rb @@ -0,0 +1,400 @@ +class Form::Lettings::Questions::Prevloc < ::Form::Question + def initialize(id, hsh, page) + super + @id = "prevloc" + @check_answer_label = "Location of household’s last settled accommodation" + @header = "Select a local authority" + @type = "select" + @inferred_check_answers_value = [{ "condition" => { "previous_la_known" => 0 }, "value" => "Not known" }] + @check_answers_card_number = 0 + @hint_text = "Select ‘Northern Ireland’, ‘Scotland’, ‘Wales’ or ‘Outside the UK’ if the household’s last settled home was outside England." + @answer_options = ANSWER_OPTIONS + end + + ANSWER_OPTIONS = { + "" => "Select an option", + "S12000033" => "Aberdeen City", + "S12000034" => "Aberdeenshire", + "E07000223" => "Adur", + "E07000026" => "Allerdale", + "E07000032" => "Amber Valley", + "S12000041" => "Angus", + "N09000001" => "Antrim and Newtownabbey", + "N09000011" => "Ards and North Down", + "S12000035" => "Argyll and Bute", + "N09000002" => "Armagh City, Banbridge and Craigavon", + "E07000224" => "Arun", + "E07000170" => "Ashfield", + "E07000105" => "Ashford", + "E07000200" => "Babergh", + "E09000002" => "Barking and Dagenham", + "E09000003" => "Barnet", + "E08000016" => "Barnsley", + "E07000027" => "Barrow-in-Furness", + "E07000066" => "Basildon", + "E07000084" => "Basingstoke and Deane", + "E07000171" => "Bassetlaw", + "E06000022" => "Bath and North East Somerset", + "E06000055" => "Bedford", + "N09000003" => "Belfast", + "E09000004" => "Bexley", + "E08000025" => "Birmingham", + "E07000129" => "Blaby", + "E06000008" => "Blackburn with Darwen", + "E06000009" => "Blackpool", + "W06000019" => "Blaenau Gwent", + "E07000033" => "Bolsover", + "E08000001" => "Bolton", + "E07000136" => "Boston", + "E06000058" => "Bournemouth, Christchurch and Poole", + "E06000036" => "Bracknell Forest", + "E08000032" => "Bradford", + "E07000067" => "Braintree", + "E07000143" => "Breckland", + "E09000005" => "Brent", + "E07000068" => "Brentwood", + "W06000013" => "Bridgend", + "E06000043" => "Brighton and Hove", + "E06000023" => "Bristol, City of", + "E07000144" => "Broadland", + "E09000006" => "Bromley", + "E07000234" => "Bromsgrove", + "E07000095" => "Broxbourne", + "E07000172" => "Broxtowe", + "E06000060" => "Buckinghamshire", + "E07000117" => "Burnley", + "E08000002" => "Bury", + "W06000018" => "Caerphilly", + "E08000033" => "Calderdale", + "E07000008" => "Cambridge", + "E09000007" => "Camden", + "E07000192" => "Cannock Chase", + "E07000106" => "Canterbury", + "W06000015" => "Cardiff", + "E07000028" => "Carlisle", + "W06000010" => "Carmarthenshire", + "E07000069" => "Castle Point", + "N09000004" => "Causeway Coast and Glens", + "E06000056" => "Central Bedfordshire", + "W06000008" => "Ceredigion", + "E07000130" => "Charnwood", + "E07000070" => "Chelmsford", + "E07000078" => "Cheltenham", + "E07000177" => "Cherwell", + "E06000049" => "Cheshire East", + "E06000050" => "Cheshire West and Chester", + "E07000034" => "Chesterfield", + "E07000225" => "Chichester", + "E07000118" => "Chorley", + "S12000036" => "City of Edinburgh", + "E09000001" => "City of London", + "S12000005" => "Clackmannanshire", + "E07000071" => "Colchester", + "W06000003" => "Conwy", + "E07000029" => "Copeland", + "E07000150" => "Corby", + "E06000052" => "Cornwall", + "E07000079" => "Cotswold", + "E06000047" => "County Durham", + "E08000026" => "Coventry", + "E07000163" => "Craven", + "E07000226" => "Crawley", + "E09000008" => "Croydon", + "E07000096" => "Dacorum", + "E06000005" => "Darlington", + "E07000107" => "Dartford", + "E07000151" => "Daventry", + "W06000004" => "Denbighshire", + "E06000015" => "Derby", + "E07000035" => "Derbyshire Dales", + "N09000005" => "Derry City and Strabane", + "E08000017" => "Doncaster", + "E06000059" => "Dorset", + "E07000108" => "Dover", + "E08000027" => "Dudley", + "S12000006" => "Dumfries and Galloway", + "S12000042" => "Dundee City", + "E09000009" => "Ealing", + "S12000008" => "East Ayrshire", + "E07000009" => "East Cambridgeshire", + "E07000040" => "East Devon", + "S12000045" => "East Dunbartonshire", + "E07000085" => "East Hampshire", + "E07000242" => "East Hertfordshire", + "E07000137" => "East Lindsey", + "S12000010" => "East Lothian", + "E07000152" => "East Northamptonshire", + "S12000011" => "East Renfrewshire", + "E06000011" => "East Riding of Yorkshire", + "E07000193" => "East Staffordshire", + "E07000244" => "East Suffolk", + "E07000061" => "Eastbourne", + "E07000086" => "Eastleigh", + "E07000030" => "Eden", + "E07000207" => "Elmbridge", + "E09000010" => "Enfield", + "E07000072" => "Epping Forest", + "E07000208" => "Epsom and Ewell", + "E07000036" => "Erewash", + "E07000041" => "Exeter", + "S12000014" => "Falkirk", + "E07000087" => "Fareham", + "E07000010" => "Fenland", + "N09000006" => "Fermanagh and Omagh", + "S12000047" => "Fife", + "W06000005" => "Flintshire", + "E07000112" => "Folkestone and Hythe", + "E07000080" => "Forest of Dean", + "E07000119" => "Fylde", + "E08000037" => "Gateshead", + "E07000173" => "Gedling", + "S12000049" => "Glasgow City", + "E07000081" => "Gloucester", + "E07000088" => "Gosport", + "E07000109" => "Gravesham", + "E07000145" => "Great Yarmouth", + "E09000011" => "Greenwich", + "E07000209" => "Guildford", + "W06000002" => "Gwynedd", + "E09000012" => "Hackney", + "E06000006" => "Halton", + "E07000164" => "Hambleton", + "E09000013" => "Hammersmith and Fulham", + "E07000131" => "Harborough", + "E09000014" => "Haringey", + "E07000073" => "Harlow", + "E07000165" => "Harrogate", + "E09000015" => "Harrow", + "E07000089" => "Hart", + "E06000001" => "Hartlepool", + "E07000062" => "Hastings", + "E07000090" => "Havant", + "E09000016" => "Havering", + "E06000019" => "Herefordshire, County of", + "E07000098" => "Hertsmere", + "E07000037" => "High Peak", + "S12000017" => "Highland", + "E09000017" => "Hillingdon", + "E07000132" => "Hinckley and Bosworth", + "E07000227" => "Horsham", + "E09000018" => "Hounslow", + "E07000011" => "Huntingdonshire", + "E07000120" => "Hyndburn", + "S12000018" => "Inverclyde", + "E07000202" => "Ipswich", + "W06000001" => "Isle of Anglesey", + "E06000046" => "Isle of Wight", + "E06000053" => "Isles of Scilly", + "E09000019" => "Islington", + "E09000020" => "Kensington and Chelsea", + "E07000153" => "Kettering", + "E07000146" => "King’s Lynn and West Norfolk", + "E06000010" => "Kingston upon Hull, City of", + "E09000021" => "Kingston upon Thames", + "E08000034" => "Kirklees", + "E08000011" => "Knowsley", + "E09000022" => "Lambeth", + "E07000121" => "Lancaster", + "E08000035" => "Leeds", + "E06000016" => "Leicester", + "E07000063" => "Lewes", + "E09000023" => "Lewisham", + "E07000194" => "Lichfield", + "E07000138" => "Lincoln", + "N09000007" => "Lisburn and Castlereagh", + "E08000012" => "Liverpool", + "E06000032" => "Luton", + "E07000110" => "Maidstone", + "E07000074" => "Maldon", + "E07000235" => "Malvern Hills", + "E08000003" => "Manchester", + "E07000174" => "Mansfield", + "E06000035" => "Medway", + "E07000133" => "Melton", + "E07000187" => "Mendip", + "W06000024" => "Merthyr Tydfil", + "E09000024" => "Merton", + "E07000042" => "Mid Devon", + "E07000203" => "Mid Suffolk", + "E07000228" => "Mid Sussex", + "N09000009" => "Mid Ulster", + "N09000008" => "Mid and East Antrim", + "E06000002" => "Middlesbrough", + "S12000019" => "Midlothian", + "E06000042" => "Milton Keynes", + "E07000210" => "Mole Valley", + "W06000021" => "Monmouthshire", + "S12000020" => "Moray", + "S12000013" => "Na h-Eileanan Siar", + "W06000012" => "Neath Port Talbot", + "E07000091" => "New Forest", + "E07000175" => "Newark and Sherwood", + "E08000021" => "Newcastle upon Tyne", + "E07000195" => "Newcastle-under-Lyme", + "E09000025" => "Newham", + "W06000022" => "Newport", + "N09000010" => "Newry, Mourne and Down", + "S12000021" => "North Ayrshire", + "E07000043" => "North Devon", + "E07000038" => "North East Derbyshire", + "E06000012" => "North East Lincolnshire", + "E07000099" => "North Hertfordshire", + "E07000139" => "North Kesteven", + "S12000050" => "North Lanarkshire", + "E06000013" => "North Lincolnshire", + "E07000147" => "North Norfolk", + "E06000024" => "North Somerset", + "E08000022" => "North Tyneside", + "E07000218" => "North Warwickshire", + "E07000134" => "North West Leicestershire", + "E07000154" => "Northampton", + "E06000057" => "Northumberland", + "E07000148" => "Norwich", + "E06000018" => "Nottingham", + "E07000219" => "Nuneaton and Bedworth", + "E07000135" => "Oadby and Wigston", + "E08000004" => "Oldham", + "S12000023" => "Orkney Islands", + "E07000178" => "Oxford", + "W06000009" => "Pembrokeshire", + "E07000122" => "Pendle", + "S12000048" => "Perth and Kinross", + "E06000031" => "Peterborough", + "E06000026" => "Plymouth", + "E06000044" => "Portsmouth", + "W06000023" => "Powys", + "E07000123" => "Preston", + "E06000038" => "Reading", + "E09000026" => "Redbridge", + "E06000003" => "Redcar and Cleveland", + "E07000236" => "Redditch", + "E07000211" => "Reigate and Banstead", + "S12000038" => "Renfrewshire", + "W06000016" => "Rhondda Cynon Taf", + "E07000124" => "Ribble Valley", + "E09000027" => "Richmond upon Thames", + "E07000166" => "Richmondshire", + "E08000005" => "Rochdale", + "E07000075" => "Rochford", + "E07000125" => "Rossendale", + "E07000064" => "Rother", + "E08000018" => "Rotherham", + "E07000220" => "Rugby", + "E07000212" => "Runnymede", + "E07000176" => "Rushcliffe", + "E07000092" => "Rushmoor", + "E06000017" => "Rutland", + "E07000167" => "Ryedale", + "E08000006" => "Salford", + "E08000028" => "Sandwell", + "E07000168" => "Scarborough", + "S12000026" => "Scottish Borders", + "E07000188" => "Sedgemoor", + "E08000014" => "Sefton", + "E07000169" => "Selby", + "E07000111" => "Sevenoaks", + "E08000019" => "Sheffield", + "S12000027" => "Shetland Islands", + "E06000051" => "Shropshire", + "E06000039" => "Slough", + "E08000029" => "Solihull", + "E07000246" => "Somerset West and Taunton", + "S12000028" => "South Ayrshire", + "E07000012" => "South Cambridgeshire", + "E07000039" => "South Derbyshire", + "E06000025" => "South Gloucestershire", + "E07000044" => "South Hams", + "E07000140" => "South Holland", + "E07000141" => "South Kesteven", + "E07000031" => "South Lakeland", + "S12000029" => "South Lanarkshire", + "E07000149" => "South Norfolk", + "E07000155" => "South Northamptonshire", + "E07000179" => "South Oxfordshire", + "E07000126" => "South Ribble", + "E07000189" => "South Somerset", + "E07000196" => "South Staffordshire", + "E08000023" => "South Tyneside", + "E06000045" => "Southampton", + "E06000033" => "Southend-on-Sea", + "E09000028" => "Southwark", + "E07000213" => "Spelthorne", + "E07000240" => "St Albans", + "E08000013" => "St. Helens", + "E07000197" => "Stafford", + "E07000198" => "Staffordshire Moorlands", + "E07000243" => "Stevenage", + "S12000030" => "Stirling", + "E08000007" => "Stockport", + "E06000004" => "Stockton-on-Tees", + "E06000021" => "Stoke-on-Trent", + "E07000221" => "Stratford-on-Avon", + "E07000082" => "Stroud", + "E08000024" => "Sunderland", + "E07000214" => "Surrey Heath", + "E09000029" => "Sutton", + "E07000113" => "Swale", + "W06000011" => "Swansea", + "E06000030" => "Swindon", + "E08000008" => "Tameside", + "E07000199" => "Tamworth", + "E07000215" => "Tandridge", + "E07000045" => "Teignbridge", + "E06000020" => "Telford and Wrekin", + "E07000076" => "Tendring", + "E07000093" => "Test Valley", + "E07000083" => "Tewkesbury", + "E07000114" => "Thanet", + "E07000102" => "Three Rivers", + "E06000034" => "Thurrock", + "E07000115" => "Tonbridge and Malling", + "E06000027" => "Torbay", + "W06000020" => "Torfaen", + "E07000046" => "Torridge", + "E09000030" => "Tower Hamlets", + "E08000009" => "Trafford", + "E07000116" => "Tunbridge Wells", + "E07000077" => "Uttlesford", + "W06000014" => "Vale of Glamorgan", + "E07000180" => "Vale of White Horse", + "E08000036" => "Wakefield", + "E08000030" => "Walsall", + "E09000031" => "Waltham Forest", + "E09000032" => "Wandsworth", + "E06000007" => "Warrington", + "E07000222" => "Warwick", + "E07000103" => "Watford", + "E07000216" => "Waverley", + "E07000065" => "Wealden", + "E07000156" => "Wellingborough", + "E07000241" => "Welwyn Hatfield", + "E06000037" => "West Berkshire", + "E07000047" => "West Devon", + "S12000039" => "West Dunbartonshire", + "E07000127" => "West Lancashire", + "E07000142" => "West Lindsey", + "S12000040" => "West Lothian", + "E07000181" => "West Oxfordshire", + "E07000245" => "West Suffolk", + "E09000033" => "Westminster", + "E08000010" => "Wigan", + "E06000054" => "Wiltshire", + "E07000094" => "Winchester", + "E06000040" => "Windsor and Maidenhead", + "E08000015" => "Wirral", + "E07000217" => "Woking", + "E06000041" => "Wokingham", + "E08000031" => "Wolverhampton", + "E07000237" => "Worcester", + "E07000229" => "Worthing", + "W06000006" => "Wrexham", + "E07000238" => "Wychavon", + "E07000128" => "Wyre", + "E07000239" => "Wyre Forest", + "E06000014" => "York", + "N92000002" => "Northern Ireland", + "S92000003" => "Scotland", + "W92000004" => "Wales", + "9300000XX" => "Outside UK", + }.freeze +end diff --git a/app/models/form/lettings/questions/prevten.rb b/app/models/form/lettings/questions/prevten.rb new file mode 100644 index 000000000..3d77f24bb --- /dev/null +++ b/app/models/form/lettings/questions/prevten.rb @@ -0,0 +1,87 @@ +class Form::Lettings::Questions::Prevten < ::Form::Question + def initialize(id, hsh, page) + super + @id = "prevten" + @check_answer_label = "Where was the household immediately before this letting?" + @header = "Where was the household immediately before this letting?" + @type = "radio" + @check_answers_card_number = 0 + @hint_text = "This is where the household was the night before they moved." + @answer_options = ANSWER_OPTIONS + end + + ANSWER_OPTIONS = { + "30" => { + "value" => "Fixed-term local authority general needs tenancy", + }, + "32" => { + "value" => "Fixed-term private registered provider (PRP) general needs tenancy", + }, + "31" => { + "value" => "Lifetime local authority general needs tenancy", + }, + "33" => { + "value" => "Lifetime private registered provider (PRP) general needs tenancy", + }, + "34" => { + "value" => "Specialist retirement housing", + }, + "35" => { + "value" => "Extra care housing", + }, + "6" => { + "value" => "Other supported housing", + }, + "3" => { + "value" => "Private sector tenancy", + }, + "27" => { + "value" => "Owner occupation (low-cost home ownership)", + }, + "26" => { + "value" => "Owner occupation (private)", + }, + "28" => { + "value" => "Living with friends or family", + }, + "14" => { + "value" => "Bed and breakfast", + }, + "7" => { + "value" => "Direct access hostel", + }, + "10" => { + "value" => "Hospital", + }, + "29" => { + "value" => "Prison or approved probation hostel", + }, + "19" => { + "value" => "Rough sleeping", + }, + "18" => { + "value" => "Any other temporary accommodation", + }, + "13" => { + "value" => "Children’s home or foster care", + }, + "24" => { + "value" => "Home Office Asylum Support", + }, + "23" => { + "value" => "Mobile home or caravan", + }, + "21" => { + "value" => "Refuge", + }, + "9" => { + "value" => "Residential care home", + }, + "4" => { + "value" => "Tied housing or rented with job", + }, + "25" => { + "value" => "Any other accommodation", + }, + }.freeze +end diff --git a/app/models/form/lettings/questions/prevten_renewal.rb b/app/models/form/lettings/questions/prevten_renewal.rb new file mode 100644 index 000000000..e8516e85e --- /dev/null +++ b/app/models/form/lettings/questions/prevten_renewal.rb @@ -0,0 +1,18 @@ +class Form::Lettings::Questions::PrevtenRenewal < ::Form::Question + def initialize(id, hsh, page) + super + @id = "prevten" + @check_answer_label = "Where was the household immediately before this letting?" + @header = "Where was the household immediately before this letting?" + @type = "radio" + @check_answers_card_number = 0 + @hint_text = "" + @answer_options = ANSWER_OPTIONS + end + + ANSWER_OPTIONS = { + "34" => { "value" => "Specialist retirement housing" }, + "35" => { "value" => "Extra care housing" }, + "6" => { "value" => "Other supported housing" }, + }.freeze +end diff --git a/app/models/form/lettings/questions/pscharge_4_weekly.rb b/app/models/form/lettings/questions/pscharge_4_weekly.rb new file mode 100644 index 000000000..2242cd692 --- /dev/null +++ b/app/models/form/lettings/questions/pscharge_4_weekly.rb @@ -0,0 +1,19 @@ +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?" + @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" + @hidden_in_check_answers = true + @prefix = "£" + @suffix = " every 4 weeks" + end +end diff --git a/app/models/form/lettings/questions/pscharge_bi_weekly.rb b/app/models/form/lettings/questions/pscharge_bi_weekly.rb new file mode 100644 index 000000000..7a7c89443 --- /dev/null +++ b/app/models/form/lettings/questions/pscharge_bi_weekly.rb @@ -0,0 +1,19 @@ +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?" + @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" + @hidden_in_check_answers = true + @prefix = "£" + @suffix = " every 2 weeks" + end +end diff --git a/app/models/form/lettings/questions/pscharge_monthly.rb b/app/models/form/lettings/questions/pscharge_monthly.rb new file mode 100644 index 000000000..6aa1ae911 --- /dev/null +++ b/app/models/form/lettings/questions/pscharge_monthly.rb @@ -0,0 +1,19 @@ +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?" + @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" + @hidden_in_check_answers = true + @prefix = "£" + @suffix = " every month" + end +end diff --git a/app/models/form/lettings/questions/pscharge_weekly.rb b/app/models/form/lettings/questions/pscharge_weekly.rb new file mode 100644 index 000000000..73f3d9323 --- /dev/null +++ b/app/models/form/lettings/questions/pscharge_weekly.rb @@ -0,0 +1,19 @@ +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?" + @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" + @hidden_in_check_answers = true + @prefix = "£" + @suffix = " every week" + end +end diff --git a/app/models/form/lettings/questions/reason.rb b/app/models/form/lettings/questions/reason.rb new file mode 100644 index 000000000..2f46fae35 --- /dev/null +++ b/app/models/form/lettings/questions/reason.rb @@ -0,0 +1,125 @@ +class Form::Lettings::Questions::Reason < ::Form::Question + def initialize(id, hsh, page) + super + @id = "reason" + @check_answer_label = "Reason for leaving last settled home" + @header = "What is the tenant’s main reason for the household leaving their last settled home?" + @type = "radio" + @check_answers_card_number = 0 + @hint_text = "The tenant’s ‘last settled home’ is their last long-standing home. For tenants who were in temporary accommodation or sleeping rough, their last settled home is where they were living previously." + @answer_options = ANSWER_OPTIONS + @conditional_for = { + "reasonother" => [ + 20, + ], + } + end + + ANSWER_OPTIONS = { + "40" => { + "value" => "End of assured shorthold tenancy (no fault)", + }, + "41" => { + "value" => "End of assured shorthold tenancy (eviction or tenant at fault)", + }, + "42" => { + "value" => "End of fixed term tenancy (no fault)", + }, + "43" => { + "value" => "End of fixed term tenancy (eviction or tenant at fault)", + }, + "1" => { + "value" => "Permanently decanted from another property owned by this landlord", + }, + "46" => { + "value" => "Discharged from long-stay hospital or similar institution", + }, + "45" => { + "value" => "Discharged from prison", + }, + "2" => { + "value" => "Left home country as a refugee", + }, + "4" => { + "value" => "Loss of tied accommodation", + }, + "9" => { + "value" => "Asked to leave by family or friends", + }, + "44" => { + "value" => "Death of household member in last settled accommodation", + }, + "8" => { + "value" => "Relationship breakdown (non-violent) with partner", + }, + "16" => { + "value" => "To move nearer to family, friends or school", + }, + "17" => { + "value" => "To move nearer to work", + }, + "7" => { + "value" => "Domestic abuse", + }, + "31" => { + "value" => "Hate crime", + }, + "10" => { + "value" => "Racial harassment", + }, + "11" => { + "value" => "Other problems with neighbours", + }, + "35" => { + "value" => "Couldn’t afford fees attached to renewing the tenancy", + }, + "36" => { + "value" => "Couldn’t afford increase in rent", + }, + "38" => { + "value" => "Couldn’t afford rent or mortgage (employment)", + }, + "37" => { + "value" => "Couldn’t afford rent or mortgage (welfare reforms)", + }, + "39" => { + "value" => "Couldn’t afford rent or mortgage (other)", + }, + "34" => { + "value" => "Repossession", + }, + "12" => { + "value" => "Property unsuitable because of overcrowding", + }, + "13" => { + "value" => "Property unsuitable because of ill health or disability", + }, + "14" => { + "value" => "Property unsuitable because of poor condition", + }, + "18" => { + "value" => "To move to accommodation with support", + }, + "19" => { + "value" => "To move to independent accommodation", + }, + "30" => { + "value" => "Under occupation (no incentive)", + }, + "29" => { + "value" => "Under occupation (offered incentive to downsize)", + }, + "20" => { + "value" => "Other", + }, + "47" => { + "value" => "Tenant prefers not to say", + }, + "divider" => { + "value" => true, + }, + "28" => { + "value" => "Don’t know", + }, + }.freeze +end diff --git a/app/models/form/lettings/questions/reason_renewal.rb b/app/models/form/lettings/questions/reason_renewal.rb new file mode 100644 index 000000000..c3a825c5e --- /dev/null +++ b/app/models/form/lettings/questions/reason_renewal.rb @@ -0,0 +1,17 @@ +class Form::Lettings::Questions::ReasonRenewal < ::Form::Question + def initialize(id, hsh, page) + super + @id = "reason" + @check_answer_label = "Reason for leaving last settled home" + @header = "What is the tenant’s main reason for the household leaving their last settled home?" + @type = "radio" + @check_answers_card_number = 0 + @hint_text = "" + @answer_options = ANSWER_OPTIONS + end + + ANSWER_OPTIONS = { + "40" => { "value" => "End of assured shorthold tenancy (no fault)" }, + "42" => { "value" => "End of fixed term tenancy (no fault)" }, + }.freeze +end diff --git a/app/models/form/lettings/questions/reasonable_preference_reason.rb b/app/models/form/lettings/questions/reasonable_preference_reason.rb new file mode 100644 index 000000000..f582ccadf --- /dev/null +++ b/app/models/form/lettings/questions/reasonable_preference_reason.rb @@ -0,0 +1,21 @@ +class Form::Lettings::Questions::ReasonablePreferenceReason < ::Form::Question + def initialize(id, hsh, page) + super + @id = "reasonable_preference_reason" + @check_answer_label = "Reason for reasonable preference" + @header = "Why was the household given ‘reasonable preference’?" + @type = "checkbox" + @check_answers_card_number = 0 + @hint_text = "Select all that apply." + @answer_options = ANSWER_OPTIONS + end + + ANSWER_OPTIONS = { + "rp_homeless" => { "value" => "They were homeless or about to lose their home (within 56 days)" }, + "rp_insan_unsat" => { "value" => "They were living in unsanitary, overcrowded or unsatisfactory housing" }, + "rp_medwel" => { "value" => "They needed to move due to medical and welfare reasons (including disability)" }, + "rp_hardship" => { "value" => "They needed to move to avoid hardship to themselves or others" }, + "divider" => { "value" => true }, + "rp_dontknow" => { "value" => "Don’t know" }, + }.freeze +end diff --git a/app/models/form/lettings/questions/reasonother.rb b/app/models/form/lettings/questions/reasonother.rb new file mode 100644 index 000000000..48306f7d7 --- /dev/null +++ b/app/models/form/lettings/questions/reasonother.rb @@ -0,0 +1,11 @@ +class Form::Lettings::Questions::Reasonother < ::Form::Question + def initialize(id, hsh, page) + super + @id = "reasonother" + @check_answer_label = "" + @header = "What is the reason?" + @type = "text" + @check_answers_card_number = 0 + @hint_text = "" + end +end diff --git a/app/models/form/lettings/questions/reasonpref.rb b/app/models/form/lettings/questions/reasonpref.rb new file mode 100644 index 000000000..571a7e3eb --- /dev/null +++ b/app/models/form/lettings/questions/reasonpref.rb @@ -0,0 +1,19 @@ +class Form::Lettings::Questions::Reasonpref < ::Form::Question + def initialize(id, hsh, page) + super + @id = "reasonpref" + @check_answer_label = "Household given reasonable preference" + @header = "Was the household given ‘reasonable preference’ by the local authority?" + @type = "radio" + @check_answers_card_number = 0 + @hint_text = "Households may be given ‘reasonable preference’ for social housing, also known as ‘priority need’, by the local authority." + @answer_options = ANSWER_OPTIONS + end + + ANSWER_OPTIONS = { + "1" => { "value" => "Yes" }, + "2" => { "value" => "No" }, + "divider" => { "value" => true }, + "3" => { "value" => "Don’t know" }, + }.freeze +end diff --git a/app/models/form/lettings/questions/referral.rb b/app/models/form/lettings/questions/referral.rb new file mode 100644 index 000000000..83e5d3ae2 --- /dev/null +++ b/app/models/form/lettings/questions/referral.rb @@ -0,0 +1,51 @@ +class Form::Lettings::Questions::Referral < ::Form::Question + def initialize(id, hsh, page) + super + @id = "referral" + @check_answer_label = "Source of referral for letting" + @header = "What was the source of referral for this letting?" + @type = "radio" + @check_answers_card_number = 0 + @hint_text = "" + @answer_options = ANSWER_OPTIONS + end + + ANSWER_OPTIONS = { + "1" => { + "value" => "Internal transfer", + }, + "2" => { + "value" => "Tenant applied directly (no referral or nomination)", + }, + "8" => { + "value" => "Re-located through official housing mobility scheme", + }, + "10" => { + "value" => "Other social landlord", + }, + "9" => { + "value" => "Community learning disability team", + }, + "14" => { + "value" => "Community mental health team", + }, + "15" => { + "value" => "Health service", + }, + "12" => { + "value" => "Police, probation or prison", + }, + "7" => { + "value" => "Voluntary agency", + }, + "13" => { + "value" => "Youth offending team", + }, + "17" => { + "value" => "Children’s Social Care", + }, + "16" => { + "value" => "Other", + }, + }.freeze +end diff --git a/app/models/form/lettings/questions/referral_prp.rb b/app/models/form/lettings/questions/referral_prp.rb new file mode 100644 index 000000000..5651f431f --- /dev/null +++ b/app/models/form/lettings/questions/referral_prp.rb @@ -0,0 +1,51 @@ +class Form::Lettings::Questions::ReferralPrp < ::Form::Question + def initialize(id, hsh, page) + super + @id = "referral" + @check_answer_label = "Source of referral for letting" + @header = "What was the source of referral for this letting?" + @type = "radio" + @check_answers_card_number = 0 + @hint_text = "" + @answer_options = ANSWER_OPTIONS + end + + ANSWER_OPTIONS = { + "1" => { + "value" => "Internal transfer", + }, + "2" => { + "value" => "Tenant applied directly (no nomination)", + }, + "3" => { + "value" => "Nominated by a local housing authority", + }, + "8" => { + "value" => "Re-located through official housing mobility scheme", + }, + "10" => { + "value" => "Other social landlord", + }, + "9" => { + "value" => "Community learning disability team", + }, + "14" => { + "value" => "Community mental health team", + }, + "15" => { + "value" => "Health service", + }, + "12" => { + "value" => "Police, probation or prison", + }, + "7" => { + "value" => "Voluntary agency", + }, + "13" => { + "value" => "Youth offending team", + }, + "16" => { + "value" => "Other", + }, + }.freeze +end diff --git a/app/models/form/lettings/questions/referral_supported_housing.rb b/app/models/form/lettings/questions/referral_supported_housing.rb new file mode 100644 index 000000000..5b286d94d --- /dev/null +++ b/app/models/form/lettings/questions/referral_supported_housing.rb @@ -0,0 +1,51 @@ +class Form::Lettings::Questions::ReferralSupportedHousing < ::Form::Question + def initialize(id, hsh, page) + super + @id = "referral" + @check_answer_label = "Source of referral for letting" + @header = "What was the source of referral for this letting?" + @type = "radio" + @check_answers_card_number = 0 + @hint_text = "" + @answer_options = ANSWER_OPTIONS + end + + ANSWER_OPTIONS = { + "1" => { + "value" => "Internal transfer", + }, + "2" => { + "value" => "Tenant applied directly (no referral)", + }, + "3" => { + "value" => "Referred by local authority housing department", + }, + "8" => { + "value" => "Re-located through official housing mobility scheme", + }, + "10" => { + "value" => "Other social landlord", + }, + "9" => { + "value" => "Community learning disability team", + }, + "14" => { + "value" => "Community mental health team", + }, + "15" => { + "value" => "Health service", + }, + "12" => { + "value" => "Police, probation or prison", + }, + "7" => { + "value" => "Voluntary agency", + }, + "13" => { + "value" => "Youth offending team", + }, + "16" => { + "value" => "Other", + }, + }.freeze +end diff --git a/app/models/form/lettings/questions/referral_supported_housing_prp.rb b/app/models/form/lettings/questions/referral_supported_housing_prp.rb new file mode 100644 index 000000000..051f7b90b --- /dev/null +++ b/app/models/form/lettings/questions/referral_supported_housing_prp.rb @@ -0,0 +1,28 @@ +class Form::Lettings::Questions::ReferralSupportedHousingPrp < ::Form::Question + def initialize(id, hsh, page) + super + @id = "referral" + @check_answer_label = "Source of referral for letting" + @header = "What was the source of referral for this letting?" + @type = "radio" + @check_answers_card_number = 0 + @hint_text = "" + @answer_options = ANSWER_OPTIONS + end + + ANSWER_OPTIONS = { + "1" => { "value" => "Internal transfer" }, + "2" => { "value" => "Tenant applied directly (no referral or nomination)" }, + "3" => { "value" => "Nominated by a local housing authority" }, + "4" => { "value" => "Referred by local authority housing department" }, + "8" => { "value" => "Re-located through official housing mobility scheme" }, + "10" => { "value" => "Other social landlord" }, + "9" => { "value" => "Community learning disability team" }, + "14" => { "value" => "Community mental health team" }, + "15" => { "value" => "Health service" }, + "12" => { "value" => "Police, probation or prison" }, + "7" => { "value" => "Voluntary agency" }, + "13" => { "value" => "Youth offending team" }, + "16" => { "value" => "Other" }, + }.freeze +end diff --git a/app/models/form/lettings/questions/rent_value_check.rb b/app/models/form/lettings/questions/rent_value_check.rb new file mode 100644 index 000000000..eac22908a --- /dev/null +++ b/app/models/form/lettings/questions/rent_value_check.rb @@ -0,0 +1,14 @@ +class Form::Lettings::Questions::RentValueCheck < ::Form::Question + def initialize(id, hsh, page) + super + @id = "rent_value_check" + @check_answer_label = "Total rent confirmation" + @header = "Are you sure this is correct?" + @type = "interruption_screen" + @check_answers_card_number = 0 + @answer_options = ANSWER_OPTIONS + @hidden_in_check_answers = { "depends_on" => [{ "rent_value_check" => 0 }, { "rent_value_check" => 1 }] } + end + + ANSWER_OPTIONS = { "0" => { "value" => "Yes" }, "1" => { "value" => "No" } }.freeze +end diff --git a/app/models/form/lettings/questions/reservist.rb b/app/models/form/lettings/questions/reservist.rb new file mode 100644 index 000000000..695254c05 --- /dev/null +++ b/app/models/form/lettings/questions/reservist.rb @@ -0,0 +1,19 @@ +class Form::Lettings::Questions::Reservist < ::Form::Question + def initialize(id, hsh, page) + super + @id = "reservist" + @check_answer_label = "Person seriously injured or ill as result of serving in UK armed forces" + @header = "Was the person seriously injured or ill as a result of serving in the UK armed forces?" + @type = "radio" + @check_answers_card_number = 0 + @hint_text = "" + @answer_options = ANSWER_OPTIONS + end + + ANSWER_OPTIONS = { + "1" => { "value" => "Yes" }, + "2" => { "value" => "No" }, + "divider" => { "value" => true }, + "3" => { "value" => "Person prefers not to say" }, + }.freeze +end diff --git a/app/models/form/lettings/questions/retirement_value_check.rb b/app/models/form/lettings/questions/retirement_value_check.rb new file mode 100644 index 000000000..784693616 --- /dev/null +++ b/app/models/form/lettings/questions/retirement_value_check.rb @@ -0,0 +1,19 @@ +class Form::Lettings::Questions::RetirementValueCheck < ::Form::Question + def initialize(id, hsh, page) + super + @id = "retirement_value_check" + @check_answer_label = "Retirement confirmation" + @header = "Are you sure this person isn’t retired?" + @type = "interruption_screen" + @check_answers_card_number = 8 + @answer_options = ANSWER_OPTIONS + @hidden_in_check_answers = { + "depends_on" => [ + { "retirement_value_check" => 0 }, + { "retirement_value_check" => 1 }, + ], + } + end + + ANSWER_OPTIONS = { "0" => { "value" => "Yes" }, "1" => { "value" => "No" } }.freeze +end diff --git a/app/models/form/lettings/questions/rsnvac.rb b/app/models/form/lettings/questions/rsnvac.rb new file mode 100644 index 000000000..4968ebb2d --- /dev/null +++ b/app/models/form/lettings/questions/rsnvac.rb @@ -0,0 +1,49 @@ +class Form::Lettings::Questions::Rsnvac < ::Form::Question + def initialize(id, hsh, page) + super + @id = "rsnvac" + @check_answer_label = "Vacancy reason" + @header = "What is the reason for the property being vacant?" + @type = "radio" + @check_answers_card_number = 0 + @hint_text = "" + @answer_options = ANSWER_OPTIONS + end + + ANSWER_OPTIONS = { + "13" => { + "value" => "Internal transfer", + "hint" => "Excluding renewals of a fixed-term tenancy", + }, + "5" => { + "value" => "Previous tenant died with no succession", + }, + "9" => { + "value" => "Re-let to tenant who occupied same property as temporary accommodation", + }, + "14" => { + "value" => "Renewal of fixed-term tenancy", + }, + "19" => { + "value" => "Tenant involved in a succession downsize", + }, + "8" => { + "value" => "Tenant moved to private sector or other accommodation", + }, + "12" => { + "value" => "Tenant moved to other social housing provider", + }, + "18" => { + "value" => "Tenant moved to care home", + }, + "6" => { + "value" => "Tenant abandoned property", + }, + "10" => { + "value" => "Tenant was evicted due to rent arrears", + }, + "11" => { + "value" => "Tenant was evicted due to anti-social behaviour", + }, + }.freeze +end diff --git a/app/models/form/lettings/questions/rsnvac_first_let.rb b/app/models/form/lettings/questions/rsnvac_first_let.rb new file mode 100644 index 000000000..a97e743db --- /dev/null +++ b/app/models/form/lettings/questions/rsnvac_first_let.rb @@ -0,0 +1,21 @@ +class Form::Lettings::Questions::RsnvacFirstLet < ::Form::Question + def initialize(id, hsh, page) + super + @id = "rsnvac" + @check_answer_label = "Vacancy reason" + @header = "What is the reason for the property being vacant?" + @type = "radio" + @check_answers_card_number = 0 + @hint_text = "" + @answer_options = ANSWER_OPTIONS + end + + ANSWER_OPTIONS = { + "16" => + { "value" => "First let of conversion, rehabilitation or acquired property" }, + "17" => + { "value" => "First let of leased property" }, + "15" => + { "value" => "First let of new-build property" }, + }.freeze +end diff --git a/app/models/form/lettings/questions/scharge_4_weekly.rb b/app/models/form/lettings/questions/scharge_4_weekly.rb new file mode 100644 index 000000000..418c88157 --- /dev/null +++ b/app/models/form/lettings/questions/scharge_4_weekly.rb @@ -0,0 +1,19 @@ +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?" + @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" + @hidden_in_check_answers = true + @prefix = "£" + @suffix = " every 4 weeks" + end +end diff --git a/app/models/form/lettings/questions/scharge_bi_weekly.rb b/app/models/form/lettings/questions/scharge_bi_weekly.rb new file mode 100644 index 000000000..913f49844 --- /dev/null +++ b/app/models/form/lettings/questions/scharge_bi_weekly.rb @@ -0,0 +1,19 @@ +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?" + @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" + @hidden_in_check_answers = true + @prefix = "£" + @suffix = " every 2 weeks" + end +end diff --git a/app/models/form/lettings/questions/scharge_monthly.rb b/app/models/form/lettings/questions/scharge_monthly.rb new file mode 100644 index 000000000..bec02543c --- /dev/null +++ b/app/models/form/lettings/questions/scharge_monthly.rb @@ -0,0 +1,19 @@ +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?" + @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" + @hidden_in_check_answers = true + @prefix = "£" + @suffix = " every month" + end +end diff --git a/app/models/form/lettings/questions/scharge_weekly.rb b/app/models/form/lettings/questions/scharge_weekly.rb new file mode 100644 index 000000000..11e79c111 --- /dev/null +++ b/app/models/form/lettings/questions/scharge_weekly.rb @@ -0,0 +1,19 @@ +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?" + @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" + @hidden_in_check_answers = true + @prefix = "£" + @suffix = " every week" + end +end diff --git a/app/models/form/lettings/questions/scheme_id.rb b/app/models/form/lettings/questions/scheme_id.rb index d576a3f72..3f8225caa 100644 --- a/app/models/form/lettings/questions/scheme_id.rb +++ b/app/models/form/lettings/questions/scheme_id.rb @@ -14,7 +14,8 @@ class Form::Lettings::Questions::SchemeId < ::Form::Question answer_opts = { "" => "Select an option" } return answer_opts unless ActiveRecord::Base.connected? - Scheme.select(:id, :service_name, :primary_client_group, :secondary_client_group).each_with_object(answer_opts) do |scheme, hsh| + Scheme.select(:id, :service_name, :primary_client_group, + :secondary_client_group).each_with_object(answer_opts) do |scheme, hsh| hsh[scheme.id.to_s] = scheme hsh end @@ -22,8 +23,14 @@ class Form::Lettings::Questions::SchemeId < ::Form::Question def displayed_answer_options(lettings_log, _user = nil) organisation = lettings_log.owning_organisation || lettings_log.created_by&.organisation - schemes = organisation ? Scheme.select(:id).where(owning_organisation_id: organisation.id, confirmed: true) : Scheme.select(:id).where(confirmed: true) - filtered_scheme_ids = schemes.joins(:locations).merge(Location.where("startdate <= ? or startdate IS NULL", Time.zone.today)).map(&:id) + schemes = if organisation + Scheme.select(:id).where(owning_organisation_id: organisation.id, + confirmed: true) + else + Scheme.select(:id).where(confirmed: true) + end + filtered_scheme_ids = schemes.joins(:locations).merge(Location.where("startdate <= ? or startdate IS NULL", + Time.zone.today)).map(&:id) answer_options.select do |k, _v| filtered_scheme_ids.include?(k.to_i) || k.blank? end diff --git a/app/models/form/lettings/questions/sheltered.rb b/app/models/form/lettings/questions/sheltered.rb new file mode 100644 index 000000000..47899e261 --- /dev/null +++ b/app/models/form/lettings/questions/sheltered.rb @@ -0,0 +1,20 @@ +class Form::Lettings::Questions::Sheltered < ::Form::Question + def initialize(id, hsh, page) + super + @id = "sheltered" + @check_answer_label = "Is this letting in sheltered accommodation?" + @header = "Is this letting in sheltered accommodation?" + @type = "radio" + @check_answers_card_number = 0 + @hint_text = "" + @answer_options = ANSWER_OPTIONS + end + + ANSWER_OPTIONS = { + "2" => { "value" => "Yes – extra care housing" }, + "1" => { "value" => "Yes – specialist retirement housing" }, + "3" => { "value" => "No" }, + "divider" => { "value" => true }, + "4" => { "value" => "Don’t know" }, + }.freeze +end diff --git a/app/models/form/lettings/questions/starter_tenancy.rb b/app/models/form/lettings/questions/starter_tenancy.rb new file mode 100644 index 000000000..9e489c129 --- /dev/null +++ b/app/models/form/lettings/questions/starter_tenancy.rb @@ -0,0 +1,22 @@ +class Form::Lettings::Questions::StarterTenancy < ::Form::Question + def initialize(id, hsh, page) + super + @id = "tenancy" + @check_answer_label = "Type of main tenancy after the starter period has ended?" + @header = "What is the type of tenancy after the starter period has ended?" + @type = "radio" + @check_answers_card_number = 0 + @hint_text = "This is also known as an ‘introductory period’." + @answer_options = ANSWER_OPTIONS + @conditional_for = { "tenancyother" => [3] } + end + + ANSWER_OPTIONS = { + "4" => { "value" => "Assured Shorthold Tenancy (AST) – Fixed term" }, + "6" => { "value" => "Secure – fixed term" }, + "2" => { "value" => "Assured – lifetime" }, + "7" => { "value" => "Secure – lifetime" }, + "5" => { "value" => "Licence agreement" }, + "3" => { "value" => "Other" }, + }.freeze +end diff --git a/app/models/form/lettings/questions/startertenancy.rb b/app/models/form/lettings/questions/startertenancy.rb new file mode 100644 index 000000000..8ae35bb02 --- /dev/null +++ b/app/models/form/lettings/questions/startertenancy.rb @@ -0,0 +1,14 @@ +class Form::Lettings::Questions::Startertenancy < ::Form::Question + def initialize(id, hsh, page) + super + @id = "startertenancy" + @check_answer_label = "Is this a starter or introductory tenancy?" + @header = "Is this a starter tenancy?" + @type = "radio" + @check_answers_card_number = 0 + @hint_text = "" + @answer_options = ANSWER_OPTIONS + end + + ANSWER_OPTIONS = { "1" => { "value" => "Yes" }, "2" => { "value" => "No" } }.freeze +end diff --git a/app/models/form/lettings/questions/stock_owner.rb b/app/models/form/lettings/questions/stock_owner.rb index e2d2a633d..531341739 100644 --- a/app/models/form/lettings/questions/stock_owner.rb +++ b/app/models/form/lettings/questions/stock_owner.rb @@ -1,6 +1,4 @@ class Form::Lettings::Questions::StockOwner < ::Form::Question - attr_accessor :current_user, :log - def initialize(id, hsh, page) super @id = "owning_organisation_id" @@ -9,38 +7,38 @@ class Form::Lettings::Questions::StockOwner < ::Form::Question @type = "select" end - def answer_options + def answer_options(log = nil, user = nil) answer_opts = { "" => "Select an option" } return answer_opts unless ActiveRecord::Base.connected? - return answer_opts unless current_user + return answer_opts unless user return answer_opts unless log if log.owning_organisation_id.present? answer_opts = answer_opts.merge({ log.owning_organisation.id => log.owning_organisation.name }) end - if !current_user.support? && current_user.organisation.holds_own_stock? - answer_opts[current_user.organisation.id] = "#{current_user.organisation.name} (Your organisation)" + if !user.support? && user.organisation.holds_own_stock? + answer_opts[user.organisation.id] = "#{user.organisation.name} (Your organisation)" end + stock_owners_answer_options = if user.support? + Organisation + else + user.organisation.stock_owners + end.pluck(:id, :name).to_h + answer_opts.merge(stock_owners_answer_options) end def displayed_answer_options(log, user = nil) - @current_user = user - @log = log - - answer_options + answer_options(log, user) end def label_from_value(value, log = nil, user = nil) - @log = log - @current_user = user - return unless value - answer_options[value] + answer_options(log, user)[value] end def derived? @@ -48,13 +46,11 @@ class Form::Lettings::Questions::StockOwner < ::Form::Question end def hidden_in_check_answers?(_log, user = nil) - @current_user = user + return false if user.support? - return false if current_user.support? + stock_owners = user.organisation.stock_owners - stock_owners = current_user.organisation.stock_owners - - if current_user.organisation.holds_own_stock? + if user.organisation.holds_own_stock? stock_owners.count.zero? else stock_owners.count <= 1 @@ -70,12 +66,4 @@ private def selected_answer_option_is_derived?(_log) true end - - def stock_owners_answer_options - if current_user.support? - Organisation - else - current_user.organisation.stock_owners - end.pluck(:id, :name).to_h - end end diff --git a/app/models/form/lettings/questions/supcharg_4_weekly.rb b/app/models/form/lettings/questions/supcharg_4_weekly.rb new file mode 100644 index 000000000..5540b3555 --- /dev/null +++ b/app/models/form/lettings/questions/supcharg_4_weekly.rb @@ -0,0 +1,19 @@ +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?" + @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" + @hidden_in_check_answers = true + @prefix = "£" + @suffix = " every 4 weeks" + end +end diff --git a/app/models/form/lettings/questions/supcharg_bi_weekly.rb b/app/models/form/lettings/questions/supcharg_bi_weekly.rb new file mode 100644 index 000000000..cbda5e5c9 --- /dev/null +++ b/app/models/form/lettings/questions/supcharg_bi_weekly.rb @@ -0,0 +1,19 @@ +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?" + @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" + @hidden_in_check_answers = true + @prefix = "£" + @suffix = " every 2 weeks" + end +end diff --git a/app/models/form/lettings/questions/supcharg_monthly.rb b/app/models/form/lettings/questions/supcharg_monthly.rb new file mode 100644 index 000000000..6b799f547 --- /dev/null +++ b/app/models/form/lettings/questions/supcharg_monthly.rb @@ -0,0 +1,19 @@ +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?" + @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" + @hidden_in_check_answers = true + @prefix = "£" + @suffix = " every month" + end +end diff --git a/app/models/form/lettings/questions/supcharg_weekly.rb b/app/models/form/lettings/questions/supcharg_weekly.rb new file mode 100644 index 000000000..6f843db94 --- /dev/null +++ b/app/models/form/lettings/questions/supcharg_weekly.rb @@ -0,0 +1,19 @@ +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?" + @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" + @hidden_in_check_answers = true + @prefix = "£" + @suffix = " every week" + end +end diff --git a/app/models/form/lettings/questions/tcharge_4_weekly.rb b/app/models/form/lettings/questions/tcharge_4_weekly.rb new file mode 100644 index 000000000..7438f8527 --- /dev/null +++ b/app/models/form/lettings/questions/tcharge_4_weekly.rb @@ -0,0 +1,19 @@ +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" + @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 = "£" + @suffix = " every 4 weeks" + @requires_js = true + @fields_added = %w[brent scharge pscharge supcharg] + end +end diff --git a/app/models/form/lettings/questions/tcharge_bi_weekly.rb b/app/models/form/lettings/questions/tcharge_bi_weekly.rb new file mode 100644 index 000000000..1dee6f2bb --- /dev/null +++ b/app/models/form/lettings/questions/tcharge_bi_weekly.rb @@ -0,0 +1,19 @@ +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" + @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 = "£" + @suffix = " every 2 weeks" + @requires_js = true + @fields_added = %w[brent scharge pscharge supcharg] + end +end diff --git a/app/models/form/lettings/questions/tcharge_monthly.rb b/app/models/form/lettings/questions/tcharge_monthly.rb new file mode 100644 index 000000000..dc67c3351 --- /dev/null +++ b/app/models/form/lettings/questions/tcharge_monthly.rb @@ -0,0 +1,19 @@ +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" + @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 = "£" + @suffix = " every month" + @requires_js = true + @fields_added = %w[brent scharge pscharge supcharg] + end +end diff --git a/app/models/form/lettings/questions/tcharge_weekly.rb b/app/models/form/lettings/questions/tcharge_weekly.rb new file mode 100644 index 000000000..03fb8e4e2 --- /dev/null +++ b/app/models/form/lettings/questions/tcharge_weekly.rb @@ -0,0 +1,19 @@ +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" + @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 = "£" + @suffix = " every week" + @requires_js = true + @fields_added = %w[brent scharge pscharge supcharg] + end +end diff --git a/app/models/form/lettings/questions/tenancy.rb b/app/models/form/lettings/questions/tenancy.rb new file mode 100644 index 000000000..06a8d4fce --- /dev/null +++ b/app/models/form/lettings/questions/tenancy.rb @@ -0,0 +1,22 @@ +class Form::Lettings::Questions::Tenancy < ::Form::Question + def initialize(id, hsh, page) + super + @id = "tenancy" + @check_answer_label = "Type of main tenancy" + @header = "What is the type of tenancy?" + @type = "radio" + @check_answers_card_number = 0 + @hint_text = "" + @answer_options = ANSWER_OPTIONS + @conditional_for = { "tenancyother" => [3] } + end + + ANSWER_OPTIONS = { + "4" => { "value" => "Assured Shorthold Tenancy (AST) – Fixed term" }, + "6" => { "value" => "Secure – fixed term" }, + "2" => { "value" => "Assured – lifetime" }, + "7" => { "value" => "Secure – lifetime" }, + "5" => { "value" => "Licence agreement" }, + "3" => { "value" => "Other" }, + }.freeze +end diff --git a/app/models/form/lettings/questions/tenancylength.rb b/app/models/form/lettings/questions/tenancylength.rb new file mode 100644 index 000000000..426a95669 --- /dev/null +++ b/app/models/form/lettings/questions/tenancylength.rb @@ -0,0 +1,15 @@ +class Form::Lettings::Questions::Tenancylength < ::Form::Question + def initialize(id, hsh, page) + super + @id = "tenancylength" + @check_answer_label = "Length of fixed-term tenancy" + @header = "What is the length of the fixed-term tenancy to the nearest year?" + @type = "numeric" + @width = 2 + @check_answers_card_number = 0 + @max = 150 + @min = 0 + @hint_text = "Don’t include the starter or introductory period." + @step = 1 + end +end diff --git a/app/models/form/lettings/questions/tenancyother.rb b/app/models/form/lettings/questions/tenancyother.rb new file mode 100644 index 000000000..468d592aa --- /dev/null +++ b/app/models/form/lettings/questions/tenancyother.rb @@ -0,0 +1,11 @@ +class Form::Lettings::Questions::Tenancyother < ::Form::Question + def initialize(id, hsh, page) + super + @id = "tenancyother" + @check_answer_label = "" + @header = "Please state the tenancy type" + @type = "text" + @check_answers_card_number = 0 + @hint_text = "" + end +end diff --git a/app/models/form/lettings/questions/tshortfall.rb b/app/models/form/lettings/questions/tshortfall.rb new file mode 100644 index 000000000..ca88f3e81 --- /dev/null +++ b/app/models/form/lettings/questions/tshortfall.rb @@ -0,0 +1,25 @@ +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" + @type = "numeric" + @width = 5 + @check_answers_card_number = 0 + @min = 0 + @step = 0.01 + @prefix = "£" + @suffix = [ + { "label" => " every 2 weeks", "depends_on" => { "period" => 2 } }, + { "label" => " every 4 weeks", "depends_on" => { "period" => 3 } }, + { "label" => " every calendar month", "depends_on" => { "period" => 4 } }, + { "label" => " every week for 50 weeks", "depends_on" => { "period" => 5 } }, + { "label" => " every week for 49 weeks", "depends_on" => { "period" => 6 } }, + { "label" => " every week for 48 weeks", "depends_on" => { "period" => 7 } }, + { "label" => " every week for 47 weeks", "depends_on" => { "period" => 8 } }, + { "label" => " every week for 46 weeks", "depends_on" => { "period" => 9 } }, + { "label" => " every week for 52 weeks", "depends_on" => { "period" => 1 } }, + ] + end +end diff --git a/app/models/form/lettings/questions/tshortfall_known.rb b/app/models/form/lettings/questions/tshortfall_known.rb new file mode 100644 index 000000000..4f934d75a --- /dev/null +++ b/app/models/form/lettings/questions/tshortfall_known.rb @@ -0,0 +1,15 @@ +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?" + @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] } + end + + ANSWER_OPTIONS = { "0" => { "value" => "Yes" }, "1" => { "value" => "No" } }.freeze +end diff --git a/app/models/form/lettings/questions/unitletas.rb b/app/models/form/lettings/questions/unitletas.rb new file mode 100644 index 000000000..e37a07b34 --- /dev/null +++ b/app/models/form/lettings/questions/unitletas.rb @@ -0,0 +1,20 @@ +class Form::Lettings::Questions::Unitletas < ::Form::Question + def initialize(id, hsh, page) + super + @id = "unitletas" + @check_answer_label = "Most recent let type" + @header = "What type was the property most recently let as?" + @type = "radio" + @check_answers_card_number = 0 + @hint_text = "" + @answer_options = ANSWER_OPTIONS + end + + ANSWER_OPTIONS = { + "1" => { "value" => "Social rent basis" }, + "2" => { "value" => "Affordable rent basis" }, + "4" => { "value" => "Intermediate rent basis" }, + "divider" => { "value" => true }, + "3" => { "value" => "Don’t know" }, + }.freeze +end diff --git a/app/models/form/lettings/questions/unittype_gn.rb b/app/models/form/lettings/questions/unittype_gn.rb new file mode 100644 index 000000000..82f582722 --- /dev/null +++ b/app/models/form/lettings/questions/unittype_gn.rb @@ -0,0 +1,23 @@ +class Form::Lettings::Questions::UnittypeGn < ::Form::Question + def initialize(id, hsh, page) + super + @id = "unittype_gn" + @check_answer_label = "Type of unit" + @header = "What type of unit is the property?" + @type = "radio" + @check_answers_card_number = 0 + @hint_text = "" + @answer_options = ANSWER_OPTIONS + end + + ANSWER_OPTIONS = { + "2" => { "value" => "Bedsit" }, + "8" => { "value" => "Bungalow" }, + "1" => { "value" => "Flat or maisonette" }, + "7" => { "value" => "House" }, + "10" => { "value" => "Shared bungalow" }, + "4" => { "value" => "Shared flat or maisonette" }, + "9" => { "value" => "Shared house" }, + "6" => { "value" => "Other" }, + }.freeze +end diff --git a/app/models/form/lettings/questions/void_date_value_check.rb b/app/models/form/lettings/questions/void_date_value_check.rb new file mode 100644 index 000000000..22446061f --- /dev/null +++ b/app/models/form/lettings/questions/void_date_value_check.rb @@ -0,0 +1,14 @@ +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?" + @type = "interruption_screen" + @check_answers_card_number = 0 + @answer_options = ANSWER_OPTIONS + @hidden_in_check_answers = { "depends_on" => [{ "void_date_value_check" => 0 }, { "void_date_value_check" => 1 }] } + end + + ANSWER_OPTIONS = { "0" => { "value" => "Yes" }, "1" => { "value" => "No" } }.freeze +end diff --git a/app/models/form/lettings/questions/voiddate.rb b/app/models/form/lettings/questions/voiddate.rb new file mode 100644 index 000000000..843191660 --- /dev/null +++ b/app/models/form/lettings/questions/voiddate.rb @@ -0,0 +1,11 @@ +class Form::Lettings::Questions::Voiddate < ::Form::Question + def initialize(id, hsh, page) + super + @id = "voiddate" + @check_answer_label = "Void or renewal date" + @header = "What is the void or renewal date?" + @type = "date" + @check_answers_card_number = 0 + @hint_text = "For example, 27 3 2021." + end +end diff --git a/app/models/form/lettings/questions/voiddate_new_build.rb b/app/models/form/lettings/questions/voiddate_new_build.rb new file mode 100644 index 000000000..9cda12522 --- /dev/null +++ b/app/models/form/lettings/questions/voiddate_new_build.rb @@ -0,0 +1,11 @@ +class Form::Lettings::Questions::VoiddateNewBuild < ::Form::Question + def initialize(id, hsh, page) + super + @id = "voiddate" + @check_answer_label = "New-build handover date" + @header = "What is the new-build handover date?" + @type = "date" + @check_answers_card_number = 0 + @hint_text = "" + end +end diff --git a/app/models/form/lettings/questions/waityear.rb b/app/models/form/lettings/questions/waityear.rb new file mode 100644 index 000000000..74239b775 --- /dev/null +++ b/app/models/form/lettings/questions/waityear.rb @@ -0,0 +1,23 @@ +class Form::Lettings::Questions::Waityear < ::Form::Question + def initialize(id, hsh, page) + super + @id = "waityear" + @check_answer_label = "Length of time on local authority waiting list" + @header = "How long has the household been on the local authority waiting list for the new letting?" + @type = "radio" + @check_answers_card_number = 0 + @hint_text = "" + @answer_options = ANSWER_OPTIONS + end + + ANSWER_OPTIONS = { + "2" => { "value" => "Less than 1 year" }, + "7" => { "value" => "1 year but under 2 years" }, + "8" => { "value" => "2 years but under 3 years" }, + "9" => { "value" => "3 years but under 4 years" }, + "10" => { "value" => "4 years but under 5 years" }, + "5" => { "value" => "5 years or more" }, + "divider" => { "value" => true }, + "6" => { "value" => "Don’t know" }, + }.freeze +end diff --git a/app/models/form/lettings/questions/wchair.rb b/app/models/form/lettings/questions/wchair.rb new file mode 100644 index 000000000..1acf2705d --- /dev/null +++ b/app/models/form/lettings/questions/wchair.rb @@ -0,0 +1,14 @@ +class Form::Lettings::Questions::Wchair < ::Form::Question + def initialize(id, hsh, page) + super + @id = "wchair" + @check_answer_label = "Property built or adapted to wheelchair-user standards" + @header = "Is the property built or adapted to wheelchair-user standards?" + @type = "radio" + @check_answers_card_number = 0 + @hint_text = "" + @answer_options = ANSWER_OPTIONS + end + + ANSWER_OPTIONS = { "1" => { "value" => "Yes" }, "2" => { "value" => "No" } }.freeze +end diff --git a/app/models/form/lettings/questions/working_situation1.rb b/app/models/form/lettings/questions/working_situation1.rb new file mode 100644 index 000000000..866271f4d --- /dev/null +++ b/app/models/form/lettings/questions/working_situation1.rb @@ -0,0 +1,26 @@ +class Form::Lettings::Questions::WorkingSituation1 < ::Form::Question + def initialize(id, hsh, page) + super + @id = "ecstat1" + @check_answer_label = "Lead tenant’s working situation" + @header = "Which of these best describes the lead tenant’s working situation?" + @type = "radio" + @check_answers_card_number = 1 + @hint_text = "The lead tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest." + @answer_options = ANSWER_OPTIONS + end + + ANSWER_OPTIONS = { + "2" => { "value" => "Part-time – Less than 30 hours" }, + "1" => { "value" => "Full-time – 30 hours or more" }, + "7" => { "value" => "Full-time student" }, + "3" => { "value" => "In government training into work, such as New Deal" }, + "4" => { "value" => "Jobseeker" }, + "6" => { "value" => "Not seeking work" }, + "8" => { "value" => "Unable to work because of long term sick or disability" }, + "5" => { "value" => "Retired" }, + "0" => { "value" => "Other" }, + "divider" => { "value" => true }, + "10" => { "value" => "Tenant prefers not to say" }, + }.freeze +end diff --git a/app/models/form/lettings/sections/household.rb b/app/models/form/lettings/sections/household.rb new file mode 100644 index 000000000..f0d790213 --- /dev/null +++ b/app/models/form/lettings/sections/household.rb @@ -0,0 +1,13 @@ +class Form::Lettings::Sections::Household < ::Form::Section + def initialize(id, hsh, form) + super + @id = "household" + @label = "About the household" + @form = form + @subsections = [ + Form::Lettings::Subsections::HouseholdCharacteristics.new(nil, nil, self), + Form::Lettings::Subsections::HouseholdNeeds.new(nil, nil, self), + Form::Lettings::Subsections::HouseholdSituation.new(nil, nil, self), + ] + end +end diff --git a/app/models/form/lettings/sections/rent_and_charges.rb b/app/models/form/lettings/sections/rent_and_charges.rb new file mode 100644 index 000000000..cd1b61322 --- /dev/null +++ b/app/models/form/lettings/sections/rent_and_charges.rb @@ -0,0 +1,9 @@ +class Form::Lettings::Sections::RentAndCharges < ::Form::Section + def initialize(id, hsh, form) + super + @id = "rent_and_charges" + @label = "Finances" + @form = form + @subsections = [Form::Lettings::Subsections::IncomeAndBenefits.new(nil, nil, self)] + end +end diff --git a/app/models/form/lettings/sections/tenancy_and_property.rb b/app/models/form/lettings/sections/tenancy_and_property.rb new file mode 100644 index 000000000..168532ef1 --- /dev/null +++ b/app/models/form/lettings/sections/tenancy_and_property.rb @@ -0,0 +1,12 @@ +class Form::Lettings::Sections::TenancyAndProperty < ::Form::Section + def initialize(id, hsh, form) + super + @id = "tenancy_and_property" + @label = "Property and tenancy information" + @form = form + @subsections = [ + Form::Lettings::Subsections::PropertyInformation.new(nil, nil, self), + Form::Lettings::Subsections::TenancyInformation.new(nil, nil, self), + ] + end +end diff --git a/app/models/form/lettings/subsections/household_characteristics.rb b/app/models/form/lettings/subsections/household_characteristics.rb new file mode 100644 index 000000000..8a5bdf8c1 --- /dev/null +++ b/app/models/form/lettings/subsections/household_characteristics.rb @@ -0,0 +1,131 @@ +class Form::Lettings::Subsections::HouseholdCharacteristics < ::Form::Subsection + def initialize(id, hsh, section) + super + @id = "household_characteristics" + @label = "Household characteristics" + @depends_on = [{ "non_location_setup_questions_completed?" => true }] + end + + def pages + @pages ||= [ + Form::Lettings::Pages::Declaration.new(nil, nil, self), + Form::Lettings::Pages::HouseholdMembers.new(nil, nil, self), + Form::Lettings::Pages::NoFemalesPregnantHouseholdLeadHhmembValueCheck.new(nil, nil, self), + Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdLeadHhmembValueCheck.new(nil, nil, self), + Form::Lettings::Pages::LeadTenantAge.new(nil, nil, self), + Form::Lettings::Pages::NoFemalesPregnantHouseholdLeadAgeValueCheck.new(nil, nil, self), + Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdLeadAgeValueCheck.new(nil, nil, self), + Form::Lettings::Pages::LeadTenantGenderIdentity.new(nil, nil, self), + Form::Lettings::Pages::NoFemalesPregnantHouseholdLeadValueCheck.new(nil, nil, self), + Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdLeadValueCheck.new(nil, nil, self), + Form::Lettings::Pages::LeadTenantEthnicGroup.new(nil, nil, self), + Form::Lettings::Pages::LeadTenantEthnicBackgroundArab.new(nil, nil, self), + Form::Lettings::Pages::LeadTenantEthnicBackgroundAsian.new(nil, nil, self), + Form::Lettings::Pages::LeadTenantEthnicBackgroundBlack.new(nil, nil, self), + Form::Lettings::Pages::LeadTenantEthnicBackgroundMixed.new(nil, nil, self), + Form::Lettings::Pages::LeadTenantEthnicBackgroundWhite.new(nil, nil, self), + Form::Lettings::Pages::LeadTenantNationality.new(nil, nil, self), + Form::Lettings::Pages::LeadTenantWorkingSituation.new(nil, nil, self), + Form::Lettings::Pages::LeadTenantUnderRetirementValueCheck.new(nil, nil, self), + Form::Lettings::Pages::LeadTenantOverRetirementValueCheck.new(nil, 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::PersonAge.new(nil, nil, self, person_index: 2), + Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonAgeValueCheck.new(nil, nil, self, + person_index: 2), + Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdPersonAgeValueCheck.new(nil, nil, self, + person_index: 2), + 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, + person_index: 2), + Form::Lettings::Pages::PersonWorkingSituation.new(nil, nil, self, person_index: 2), + Form::Lettings::Pages::PersonUnderRetirementValueCheck.new(nil, nil, self, person_index: 2), + Form::Lettings::Pages::PersonOverRetirementValueCheck.new(nil, 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::PersonAge.new(nil, nil, self, person_index: 3), + Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonAgeValueCheck.new(nil, nil, self, + person_index: 3), + Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdPersonAgeValueCheck.new(nil, nil, self, + person_index: 3), + 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, + person_index: 3), + Form::Lettings::Pages::PersonWorkingSituation.new(nil, nil, self, person_index: 3), + Form::Lettings::Pages::PersonUnderRetirementValueCheck.new(nil, nil, self, person_index: 3), + Form::Lettings::Pages::PersonOverRetirementValueCheck.new(nil, 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::PersonAge.new(nil, nil, self, person_index: 4), + Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonAgeValueCheck.new(nil, nil, self, + person_index: 4), + Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdPersonAgeValueCheck.new(nil, nil, self, + person_index: 4), + 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, + person_index: 4), + Form::Lettings::Pages::PersonWorkingSituation.new(nil, nil, self, person_index: 4), + Form::Lettings::Pages::PersonUnderRetirementValueCheck.new(nil, nil, self, person_index: 4), + Form::Lettings::Pages::PersonOverRetirementValueCheck.new(nil, 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::PersonAge.new(nil, nil, self, person_index: 5), + Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonAgeValueCheck.new(nil, nil, self, + person_index: 5), + Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdPersonAgeValueCheck.new(nil, nil, self, + person_index: 5), + 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, + person_index: 5), + Form::Lettings::Pages::PersonWorkingSituation.new(nil, nil, self, person_index: 5), + Form::Lettings::Pages::PersonUnderRetirementValueCheck.new(nil, nil, self, person_index: 5), + Form::Lettings::Pages::PersonOverRetirementValueCheck.new(nil, 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::PersonAge.new(nil, nil, self, person_index: 6), + Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonAgeValueCheck.new(nil, nil, self, + person_index: 6), + Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdPersonAgeValueCheck.new(nil, nil, self, + person_index: 6), + 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, + person_index: 6), + Form::Lettings::Pages::PersonWorkingSituation.new(nil, nil, self, person_index: 6), + Form::Lettings::Pages::PersonUnderRetirementValueCheck.new(nil, nil, self, person_index: 6), + Form::Lettings::Pages::PersonOverRetirementValueCheck.new(nil, 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::PersonAge.new(nil, nil, self, person_index: 7), + Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonAgeValueCheck.new(nil, nil, self, + person_index: 7), + Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdPersonAgeValueCheck.new(nil, nil, self, + person_index: 7), + 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, + person_index: 7), + Form::Lettings::Pages::PersonWorkingSituation.new(nil, nil, self, person_index: 7), + Form::Lettings::Pages::PersonUnderRetirementValueCheck.new(nil, nil, self, person_index: 7), + Form::Lettings::Pages::PersonOverRetirementValueCheck.new(nil, 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::PersonAge.new(nil, nil, self, person_index: 8), + Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonAgeValueCheck.new(nil, nil, self, + person_index: 8), + Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdPersonAgeValueCheck.new(nil, nil, self, + person_index: 8), + 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, + person_index: 8), + Form::Lettings::Pages::PersonWorkingSituation.new(nil, nil, self, person_index: 8), + Form::Lettings::Pages::PersonUnderRetirementValueCheck.new(nil, nil, self, person_index: 8), + Form::Lettings::Pages::PersonOverRetirementValueCheck.new(nil, nil, self, person_index: 8), + ].compact + end +end diff --git a/app/models/form/lettings/subsections/household_needs.rb b/app/models/form/lettings/subsections/household_needs.rb new file mode 100644 index 000000000..2f6900f4f --- /dev/null +++ b/app/models/form/lettings/subsections/household_needs.rb @@ -0,0 +1,23 @@ +class Form::Lettings::Subsections::HouseholdNeeds < ::Form::Subsection + def initialize(id, hsh, section) + super + @id = "household_needs" + @label = "Household needs" + @depends_on = [{ "non_location_setup_questions_completed?" => true }] + end + + def pages + @pages ||= [ + Form::Lettings::Pages::ArmedForces.new("armed_forces", nil, self), + Form::Lettings::Pages::ArmedForcesServing.new(nil, nil, self), + Form::Lettings::Pages::ArmedForcesInjured.new(nil, nil, self), + Form::Lettings::Pages::Pregnant.new("pregnant", nil, self), + Form::Lettings::Pages::NoFemalesPregnantHouseholdValueCheck.new(nil, nil, self), + Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdValueCheck.new(nil, nil, self), + Form::Lettings::Pages::AccessNeedsExist.new("access_needs_exist", nil, self), + Form::Lettings::Pages::TypeOfAccessNeeds.new(nil, nil, self), + Form::Lettings::Pages::HealthConditions.new("health_conditions", nil, self), + Form::Lettings::Pages::HealthConditionEffects.new(nil, nil, self), + ].compact + end +end diff --git a/app/models/form/lettings/subsections/household_situation.rb b/app/models/form/lettings/subsections/household_situation.rb new file mode 100644 index 000000000..e09033563 --- /dev/null +++ b/app/models/form/lettings/subsections/household_situation.rb @@ -0,0 +1,29 @@ +class Form::Lettings::Subsections::HouseholdSituation < ::Form::Subsection + def initialize(id, hsh, section) + super + @id = "household_situation" + @label = "Household situation" + @depends_on = [{ "non_location_setup_questions_completed?" => true }] + end + + def pages + @pages ||= [ + Form::Lettings::Pages::TimeLivedInLocalAuthority.new("time_lived_in_local_authority", nil, self), + 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::PreviousHousingSituation.new(nil, nil, self), + Form::Lettings::Pages::PreviousHousingSituationRenewal.new(nil, nil, self), + Form::Lettings::Pages::Homelessness.new("homelessness", nil, self), + Form::Lettings::Pages::PreviousPostcode.new("previous_postcode", nil, self), + Form::Lettings::Pages::PreviousLocalAuthority.new(nil, nil, self), + Form::Lettings::Pages::ReasonablePreference.new("reasonable_preference", nil, self), + Form::Lettings::Pages::ReasonablePreferenceReason.new(nil, nil, self), + Form::Lettings::Pages::AllocationSystem.new("allocation_system", nil, self), + Form::Lettings::Pages::Referral.new(nil, nil, self), + Form::Lettings::Pages::ReferralPrp.new(nil, nil, self), + Form::Lettings::Pages::ReferralSupportedHousing.new(nil, nil, self), + Form::Lettings::Pages::ReferralSupportedHousingPrp.new(nil, nil, self), + ].compact + end +end diff --git a/app/models/form/lettings/subsections/income_and_benefits.rb b/app/models/form/lettings/subsections/income_and_benefits.rb new file mode 100644 index 000000000..92adf3c5e --- /dev/null +++ b/app/models/form/lettings/subsections/income_and_benefits.rb @@ -0,0 +1,32 @@ +class Form::Lettings::Subsections::IncomeAndBenefits < ::Form::Subsection + def initialize(id, hsh, section) + super + @id = "income_and_benefits" + @label = "Income, benefits and outgoings" + @depends_on = [{ "non_location_setup_questions_completed?" => true }] + end + + def pages + @pages ||= [ + Form::Lettings::Pages::IncomeKnown.new(nil, nil, self), + Form::Lettings::Pages::IncomeAmount.new(nil, nil, self), + Form::Lettings::Pages::NetIncomeValueCheck.new(nil, nil, self), + Form::Lettings::Pages::HousingBenefit.new("housing_benefit", nil, self), + Form::Lettings::Pages::BenefitsProportion.new("benefits_proportion", nil, self), + Form::Lettings::Pages::RentOrOtherCharges.new(nil, nil, self), + Form::Lettings::Pages::RentPeriod.new(nil, nil, self), + Form::Lettings::Pages::CareHomeWeekly.new(nil, nil, self), + Form::Lettings::Pages::CareHomeBiWeekly.new(nil, nil, self), + Form::Lettings::Pages::CareHome4Weekly.new(nil, nil, self), + Form::Lettings::Pages::CareHomeMonthly.new(nil, nil, self), + Form::Lettings::Pages::RentWeekly.new(nil, nil, self), + Form::Lettings::Pages::RentBiWeekly.new(nil, nil, self), + Form::Lettings::Pages::Rent4Weekly.new(nil, nil, self), + Form::Lettings::Pages::RentMonthly.new(nil, nil, self), + Form::Lettings::Pages::MinRentValueCheck.new(nil, nil, self), + Form::Lettings::Pages::MaxRentValueCheck.new(nil, nil, self), + Form::Lettings::Pages::Outstanding.new(nil, nil, self), + Form::Lettings::Pages::OutstandingAmount.new(nil, nil, self), + ].compact + end +end diff --git a/app/models/form/lettings/subsections/property_information.rb b/app/models/form/lettings/subsections/property_information.rb new file mode 100644 index 000000000..cc07535ae --- /dev/null +++ b/app/models/form/lettings/subsections/property_information.rb @@ -0,0 +1,30 @@ +class Form::Lettings::Subsections::PropertyInformation < ::Form::Subsection + def initialize(id, hsh, section) + super + @id = "property_information" + @label = "Property information" + @depends_on = [{ "non_location_setup_questions_completed?" => true }] + end + + def pages + @pages ||= [ + Form::Lettings::Pages::PropertyPostcode.new(nil, nil, self), + Form::Lettings::Pages::PropertyLocalAuthority.new(nil, nil, self), + Form::Lettings::Pages::FirstTimePropertyLetAsSocialHousing.new(nil, nil, self), + Form::Lettings::Pages::PropertyLetType.new(nil, nil, self), + Form::Lettings::Pages::PropertyVacancyReasonNotFirstLet.new(nil, nil, self), + Form::Lettings::Pages::PropertyVacancyReasonFirstLet.new(nil, nil, self), + Form::Lettings::Pages::PropertyNumberOfTimesReletNotSocialLet.new(nil, nil, self), + Form::Lettings::Pages::PropertyNumberOfTimesReletSocialLet.new(nil, nil, self), + Form::Lettings::Pages::PropertyUnitType.new(nil, nil, self), + Form::Lettings::Pages::PropertyBuildingType.new(nil, nil, self), + Form::Lettings::Pages::PropertyWheelchairAccessible.new(nil, nil, self), + Form::Lettings::Pages::PropertyNumberOfBedrooms.new(nil, nil, self), + Form::Lettings::Pages::VoidOrRenewalDate.new(nil, nil, self), + Form::Lettings::Pages::VoidDateValueCheck.new(nil, nil, self), + Form::Lettings::Pages::NewBuildHandoverDate.new(nil, nil, self), + Form::Lettings::Pages::PropertyMajorRepairs.new(nil, nil, self), + Form::Lettings::Pages::PropertyMajorRepairsValueCheck.new(nil, nil, self), + ].compact + end +end diff --git a/app/models/form/lettings/subsections/tenancy_information.rb b/app/models/form/lettings/subsections/tenancy_information.rb new file mode 100644 index 000000000..5f2af5215 --- /dev/null +++ b/app/models/form/lettings/subsections/tenancy_information.rb @@ -0,0 +1,19 @@ +class Form::Lettings::Subsections::TenancyInformation < ::Form::Subsection + def initialize(id, hsh, section) + super + @id = "tenancy_information" + @label = "Tenancy information" + @depends_on = [{ "non_location_setup_questions_completed?" => true }] + end + + def pages + @pages ||= [ + Form::Lettings::Pages::Joint.new("joint", nil, self), + Form::Lettings::Pages::StarterTenancy.new("starter_tenancy", nil, self), + Form::Lettings::Pages::TenancyType.new(nil, nil, self), + Form::Lettings::Pages::StarterTenancyType.new(nil, nil, self), + Form::Lettings::Pages::TenancyLength.new(nil, nil, self), + Form::Lettings::Pages::Shelteredaccom.new(nil, nil, self), + ].compact + end +end diff --git a/app/models/form/sales/pages/about_price_not_rtb.rb b/app/models/form/sales/pages/about_price_not_rtb.rb index ce55d6cd8..c69b9a890 100644 --- a/app/models/form/sales/pages/about_price_not_rtb.rb +++ b/app/models/form/sales/pages/about_price_not_rtb.rb @@ -11,7 +11,7 @@ class Form::Sales::Pages::AboutPriceNotRtb < ::Form::Page def questions @questions ||= [ - Form::Sales::Questions::Value.new(nil, nil, self), + Form::Sales::Questions::PurchasePrice.new(nil, nil, self), Form::Sales::Questions::Grant.new(nil, nil, self), ] end diff --git a/app/models/form/sales/pages/about_price_rtb.rb b/app/models/form/sales/pages/about_price_rtb.rb index ff338f6f6..35696e966 100644 --- a/app/models/form/sales/pages/about_price_rtb.rb +++ b/app/models/form/sales/pages/about_price_rtb.rb @@ -10,7 +10,7 @@ class Form::Sales::Pages::AboutPriceRtb < ::Form::Page def questions @questions ||= [ - Form::Sales::Questions::Value.new(nil, nil, self), + Form::Sales::Questions::PurchasePrice.new(nil, nil, self), Form::Sales::Questions::Discount.new(nil, nil, self), ] end diff --git a/app/models/form/sales/pages/mortgage_value_check.rb b/app/models/form/sales/pages/mortgage_value_check.rb index 954b50872..b534f7fc5 100644 --- a/app/models/form/sales/pages/mortgage_value_check.rb +++ b/app/models/form/sales/pages/mortgage_value_check.rb @@ -1,12 +1,9 @@ class Form::Sales::Pages::MortgageValueCheck < ::Form::Page - def initialize(id, hsh, subsection) - super - @depends_on = [ - { - "mortgage_over_soft_max?" => true, - }, - ] + def initialize(id, hsh, subsection, person_index = nil) + super(id, hsh, subsection) + @depends_on = depends_on @informative_text = {} + @person_index = person_index end def questions @@ -14,4 +11,21 @@ class Form::Sales::Pages::MortgageValueCheck < ::Form::Page Form::Sales::Questions::MortgageValueCheck.new(nil, nil, self), ] end + + def depends_on + if @person_index == 2 + [ + { + "mortgage_over_soft_max?" => true, + "jointpur" => 1, + }, + ] + else + [ + { + "mortgage_over_soft_max?" => true, + }, + ] + end + end end diff --git a/app/models/form/sales/pages/purchase_price.rb b/app/models/form/sales/pages/purchase_price.rb index dc9f7576e..af13fc682 100644 --- a/app/models/form/sales/pages/purchase_price.rb +++ b/app/models/form/sales/pages/purchase_price.rb @@ -2,8 +2,7 @@ class Form::Sales::Pages::PurchasePrice < ::Form::Page def initialize(id, hsh, subsection) super @depends_on = [ - { "ownershipsch" => 3 }, - { "rent_to_buy_full_ownership?" => true }, + { "ownershipsch" => 2, "rent_to_buy_full_ownership?" => false }, ] end diff --git a/app/models/form/sales/pages/purchase_price_outright_ownership.rb b/app/models/form/sales/pages/purchase_price_outright_ownership.rb new file mode 100644 index 000000000..6bf044d01 --- /dev/null +++ b/app/models/form/sales/pages/purchase_price_outright_ownership.rb @@ -0,0 +1,14 @@ +class Form::Sales::Pages::PurchasePriceOutrightOwnership < ::Form::Page + def initialize(id, hsh, subsection) + super + @depends_on = [ + { "outright_sale_or_discounted_with_full_ownership?" => true }, + ] + end + + def questions + @questions ||= [ + Form::Sales::Questions::PurchasePriceOutrightOwnership.new(nil, nil, self), + ] + end +end 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 907968028..be2126482 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 @@ -8,7 +8,7 @@ class Form::Sales::Pages::SharedOwnershipDepositValueCheck < ::Form::Page ] @informative_text = {} @title_text = { - "translation" => "soft_validations.shared_owhership_deposit.title_text", + "translation" => "soft_validations.shared_ownership_deposit.title_text", "arguments" => [ { "key" => "expected_shared_ownership_deposit_value", diff --git a/app/models/form/sales/questions/number_of_others_in_property.rb b/app/models/form/sales/questions/number_of_others_in_property.rb index 3eb1f34e6..cf590291b 100644 --- a/app/models/form/sales/questions/number_of_others_in_property.rb +++ b/app/models/form/sales/questions/number_of_others_in_property.rb @@ -7,5 +7,7 @@ class Form::Sales::Questions::NumberOfOthersInProperty < ::Form::Question @type = "numeric" @hint_text = "You can provide details for a maximum of 4 other people." @width = 2 + @min = 0 + @max = 4 end end diff --git a/app/models/form/sales/questions/purchase_price.rb b/app/models/form/sales/questions/purchase_price.rb index af7e8afb9..6242e45e8 100644 --- a/app/models/form/sales/questions/purchase_price.rb +++ b/app/models/form/sales/questions/purchase_price.rb @@ -8,5 +8,6 @@ class Form::Sales::Questions::PurchasePrice < ::Form::Question @min = 0 @width = 5 @prefix = "£" + @hint_text = "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" end end diff --git a/app/models/form/sales/questions/purchase_price_outright_ownership.rb b/app/models/form/sales/questions/purchase_price_outright_ownership.rb new file mode 100644 index 000000000..9824a4629 --- /dev/null +++ b/app/models/form/sales/questions/purchase_price_outright_ownership.rb @@ -0,0 +1,12 @@ +class Form::Sales::Questions::PurchasePriceOutrightOwnership < ::Form::Question + def initialize(id, hsh, page) + super + @id = "value" + @check_answer_label = "Purchase price" + @header = "What is the full purchase price?" + @type = "numeric" + @min = 0 + @width = 5 + @prefix = "£" + end +end diff --git a/app/models/form/sales/subsections/discounted_ownership_scheme.rb b/app/models/form/sales/subsections/discounted_ownership_scheme.rb index 4bac90bde..499411ffc 100644 --- a/app/models/form/sales/subsections/discounted_ownership_scheme.rb +++ b/app/models/form/sales/subsections/discounted_ownership_scheme.rb @@ -14,9 +14,12 @@ class Form::Sales::Subsections::DiscountedOwnershipScheme < ::Form::Subsection Form::Sales::Pages::AboutPriceNotRtb.new(nil, nil, self), Form::Sales::Pages::GrantValueCheck.new(nil, nil, self), Form::Sales::Pages::PurchasePrice.new("purchase_price_discounted_ownership", nil, self), + Form::Sales::Pages::PurchasePriceOutrightOwnership.new("purchase_price_outright_ownership", nil, self), Form::Sales::Pages::DepositAndMortgageValueCheck.new("discounted_ownership_deposit_and_mortgage_value_check_after_value_and_discount", nil, self), Form::Sales::Pages::Mortgageused.new("mortgage_used_discounted_ownership", nil, self), + Form::Sales::Pages::MortgageValueCheck.new("discounted_ownership_mortgage_used_mortgage_value_check", nil, self), Form::Sales::Pages::MortgageAmount.new("mortgage_amount_discounted_ownership", nil, self), + Form::Sales::Pages::MortgageValueCheck.new("discounted_ownership_mortgage_amount_mortgage_value_check", nil, self), Form::Sales::Pages::ExtraBorrowingValueCheck.new("extra_borrowing_mortgage_value_check", nil, self), Form::Sales::Pages::DepositAndMortgageValueCheck.new("discounted_ownership_deposit_and_mortgage_value_check_after_mortgage", nil, self), Form::Sales::Pages::MortgageLender.new("mortgage_lender_discounted_ownership", nil, self), diff --git a/app/models/form/sales/subsections/income_benefits_and_savings.rb b/app/models/form/sales/subsections/income_benefits_and_savings.rb index e2eb32b08..2df8a929b 100644 --- a/app/models/form/sales/subsections/income_benefits_and_savings.rb +++ b/app/models/form/sales/subsections/income_benefits_and_savings.rb @@ -10,13 +10,13 @@ class Form::Sales::Subsections::IncomeBenefitsAndSavings < ::Form::Subsection @pages ||= [ Form::Sales::Pages::Buyer1Income.new(nil, nil, self), Form::Sales::Pages::Buyer1IncomeValueCheck.new("buyer_1_income_value_check", nil, self), - Form::Sales::Pages::MortgageValueCheck.new("buyer_1_income_mortgage_value_check", nil, self), + Form::Sales::Pages::MortgageValueCheck.new("buyer_1_income_mortgage_value_check", nil, self, 1), Form::Sales::Pages::Buyer1Mortgage.new(nil, nil, self), - Form::Sales::Pages::MortgageValueCheck.new("buyer_1_mortgage_value_check", nil, self), + Form::Sales::Pages::MortgageValueCheck.new("buyer_1_mortgage_value_check", nil, self, 1), Form::Sales::Pages::Buyer2Income.new(nil, nil, self), - Form::Sales::Pages::MortgageValueCheck.new("buyer_2_income_mortgage_value_check", nil, self), + Form::Sales::Pages::MortgageValueCheck.new("buyer_2_income_mortgage_value_check", nil, self, 2), Form::Sales::Pages::Buyer2Mortgage.new(nil, nil, self), - Form::Sales::Pages::MortgageValueCheck.new("buyer_2_mortgage_value_check", nil, self), + Form::Sales::Pages::MortgageValueCheck.new("buyer_2_mortgage_value_check", nil, self, 2), Form::Sales::Pages::HousingBenefits.new(nil, nil, self), Form::Sales::Pages::Savings.new(nil, nil, self), Form::Sales::Pages::SavingsValueCheck.new("savings_value_check", nil, self), diff --git a/app/models/form/sales/subsections/outright_sale.rb b/app/models/form/sales/subsections/outright_sale.rb index c6586a251..69f77c4b2 100644 --- a/app/models/form/sales/subsections/outright_sale.rb +++ b/app/models/form/sales/subsections/outright_sale.rb @@ -8,9 +8,11 @@ class Form::Sales::Subsections::OutrightSale < ::Form::Subsection def pages @pages ||= [ - Form::Sales::Pages::PurchasePrice.new("purchase_price_outright_sale", nil, self), + Form::Sales::Pages::PurchasePriceOutrightOwnership.new("purchase_price_outright_sale", nil, self), Form::Sales::Pages::Mortgageused.new("mortgage_used_outright_sale", nil, self), + 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), + 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), Form::Sales::Pages::MortgageLenderOther.new("mortgage_lender_other_outright_sale", nil, self), Form::Sales::Pages::MortgageLength.new("mortgage_length_outright_sale", nil, self), diff --git a/app/models/form/sales/subsections/shared_ownership_scheme.rb b/app/models/form/sales/subsections/shared_ownership_scheme.rb index ca06842d7..04ff9b56e 100644 --- a/app/models/form/sales/subsections/shared_ownership_scheme.rb +++ b/app/models/form/sales/subsections/shared_ownership_scheme.rb @@ -24,8 +24,10 @@ class Form::Sales::Subsections::SharedOwnershipScheme < ::Form::Subsection Form::Sales::Pages::AboutPriceSharedOwnership.new(nil, nil, self), Form::Sales::Pages::SharedOwnershipDepositValueCheck.new("shared_ownership_equity_value_check", nil, self), Form::Sales::Pages::Mortgageused.new("mortgage_used_shared_ownership", nil, self), + Form::Sales::Pages::MortgageValueCheck.new("mortgage_used_mortgage_value_check", nil, self), Form::Sales::Pages::MortgageAmount.new("mortgage_amount_shared_ownership", nil, self), Form::Sales::Pages::SharedOwnershipDepositValueCheck.new("shared_ownership_mortgage_amount_value_check", nil, self), + Form::Sales::Pages::MortgageValueCheck.new("mortgage_amount_mortgage_value_check", nil, self), Form::Sales::Pages::MortgageLender.new("mortgage_lender_shared_ownership", nil, self), Form::Sales::Pages::MortgageLenderOther.new("mortgage_lender_other_shared_ownership", nil, self), Form::Sales::Pages::MortgageLength.new("mortgage_length_shared_ownership", nil, self), diff --git a/app/models/form_handler.rb b/app/models/form_handler.rb index 51a0b6177..098a7b429 100644 --- a/app/models/form_handler.rb +++ b/app/models/form_handler.rb @@ -1,5 +1,6 @@ class FormHandler include Singleton + include CollectionTimeHelper attr_reader :forms def initialize @@ -44,21 +45,6 @@ class FormHandler forms end - def current_collection_start_year - today = Time.zone.now - window_end_date = Time.zone.local(today.year, 4, 1) - today < window_end_date ? today.year - 1 : today.year - end - - def collection_start_date(date) - window_end_date = Time.zone.local(date.year, 4, 1) - date < window_end_date ? Time.zone.local(date.year - 1, 4, 1) : Time.zone.local(date.year, 4, 1) - end - - def current_collection_start_date - Time.zone.local(current_collection_start_year, 4, 1) - end - def form_name_from_start_year(year, type) form_mappings = { 0 => "current_#{type}", 1 => "previous_#{type}", -1 => "next_#{type}" } form_mappings[current_collection_start_year - year] diff --git a/app/models/sales_log.rb b/app/models/sales_log.rb index 1ca6ee8a1..b217ff69c 100644 --- a/app/models/sales_log.rb +++ b/app/models/sales_log.rb @@ -132,6 +132,10 @@ class SalesLog < Log type == 29 end + def outright_sale_or_discounted_with_full_ownership? + ownershipsch == 3 || (ownershipsch == 2 && rent_to_buy_full_ownership?) + end + def is_type_discount? type == 18 end diff --git a/app/models/validations/sales/household_validations.rb b/app/models/validations/sales/household_validations.rb index 4f2290268..f9318ab0f 100644 --- a/app/models/validations/sales/household_validations.rb +++ b/app/models/validations/sales/household_validations.rb @@ -1,14 +1,6 @@ module Validations::Sales::HouseholdValidations include Validations::SharedValidations - def validate_number_of_other_people_living_in_the_property(record) - return if record.hholdcount.blank? - - unless record.hholdcount >= 0 && record.hholdcount <= 4 - record.errors.add :hholdcount, I18n.t("validations.numeric.valid", field: "Number of other people living in the property", min: 0, max: 4) - end - end - def validate_household_number_of_other_members(record) (2..6).each do |n| validate_person_age_matches_relationship(record, n) diff --git a/app/models/validations/sales/soft_validations.rb b/app/models/validations/sales/soft_validations.rb index 7ded14ef9..cba756ea3 100644 --- a/app/models/validations/sales/soft_validations.rb +++ b/app/models/validations/sales/soft_validations.rb @@ -18,7 +18,7 @@ module Validations::Sales::SoftValidations end def mortgage_over_soft_max? - return false unless mortgage && inc1mort && inc2mort + return false unless mortgage && inc1mort && (inc2mort || not_joint_purchase?) return false if income1_used_for_mortgage? && income1.blank? || income2_used_for_mortgage? && income2.blank? income_used_for_mortgage = (income1_used_for_mortgage? ? income1 : 0) + (income2_used_for_mortgage? ? income2 : 0) diff --git a/app/models/validations/shared_validations.rb b/app/models/validations/shared_validations.rb index ca01e3819..3df46bc8b 100644 --- a/app/models/validations/shared_validations.rb +++ b/app/models/validations/shared_validations.rb @@ -20,20 +20,16 @@ module Validations::SharedValidations next unless question.min || question.max next unless record[question.id] - field = question.check_answer_label || question.id - min = [question.prefix, number_with_delimiter(question.min, delimiter: ","), question.suffix].join("") - max = [question.prefix, number_with_delimiter(question.max, delimiter: ","), question.suffix].join("") - begin answer = Float(record.public_send("#{question.id}_before_type_cast")) rescue ArgumentError - record.errors.add question.id.to_sym, I18n.t("validations.numeric.valid", field:, min:, max:) + add_range_error(record, question) end next unless answer if (question.min && question.min > answer) || (question.max && question.max < answer) - record.errors.add question.id.to_sym, I18n.t("validations.numeric.valid", field:, min:, max:) + add_range_error(record, question) end end end @@ -117,4 +113,16 @@ private def person_is_partner?(relationship) relationship == "P" end + + def add_range_error(record, question) + field = question.check_answer_label || question.id + min = [question.prefix, number_with_delimiter(question.min, delimiter: ","), question.suffix].join("") if question.min + 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, I18n.t("validations.numeric.within_range", field:, min:, max:) + elsif min + record.errors.add question.id.to_sym, I18n.t("validations.numeric.above_min", field:, min:) + end + end end diff --git a/app/services/bulk_upload/processor.rb b/app/services/bulk_upload/processor.rb index c8c8398c2..0cf059da2 100644 --- a/app/services/bulk_upload/processor.rb +++ b/app/services/bulk_upload/processor.rb @@ -7,14 +7,35 @@ class BulkUpload::Processor def call download + + return send_failure_mail if validator.invalid? + validator.call create_logs if validator.create_logs? + send_success_mail + rescue StandardError => e + Sentry.capture_exception(e) + send_failure_mail ensure downloader.delete_local_file! end private + def send_success_mail + if validator.create_logs? && bulk_upload.logs.group(:status).count.keys == %w[completed] + BulkUploadMailer.send_bulk_upload_complete_mail(user:, bulk_upload:).deliver_later + end + end + + def send_failure_mail + BulkUploadMailer.send_bulk_upload_failed_service_error_mail(bulk_upload:).deliver_later + end + + def user + bulk_upload.user + end + def create_logs log_creator_class.new( bulk_upload:, diff --git a/app/services/filter_service.rb b/app/services/filter_service.rb index 4ef3a582c..affe31f02 100644 --- a/app/services/filter_service.rb +++ b/app/services/filter_service.rb @@ -27,4 +27,22 @@ class FilterService logs end end + + attr_reader :current_user, :session + + def initialize(current_user:, session:) + @current_user = current_user + @session = session + end + + def bulk_upload + id = ((logs_filters["bulk_upload_id"] || []).reject(&:blank?))[0] + @bulk_upload ||= current_user.bulk_uploads.find_by(id:) + end + +private + + def logs_filters + JSON.parse(session[:logs_filters] || "{}") || {} + end end diff --git a/app/views/form/page.html.erb b/app/views/form/page.html.erb index c7b18cdda..6d9d44baa 100644 --- a/app/views/form/page.html.erb +++ b/app/views/form/page.html.erb @@ -34,9 +34,26 @@ <%= govuk_section_break(visible: true, size: "m") %> <% end %> <% if question.type == "interruption_screen" %> - <%= render partial: "form/#{question.type}_question", locals: { question:, caption_text: @subsection.label, page_header: @page.header, lettings_log: @log, title_text: @page.title_text, informative_text: @page.informative_text, form: @form, f:, conditional: false } %> + <%= render partial: "form/#{question.type}_question", locals: { + question:, + caption_text: @subsection.label, + page_header: @page.header, + lettings_log: @log, + title_text: @page.title_text, + informative_text: @page.informative_text, + form: @form, + f:, + conditional: false, + } %> <% else %> - <%= render partial: "form/#{question.type}_question", locals: { question:, caption_text: @page.header_partial.present? ? nil : @subsection.label, page_header: @page.header, lettings_log: @log, f:, conditional: false } %> + <%= render partial: "form/#{question.type}_question", locals: { + question:, + caption_text: @page.header_partial.present? ? nil : @subsection.label, + page_header: @page.header, + lettings_log: @log, + f:, + conditional: false, + } %> <% end %>
<% end %> diff --git a/app/views/users/_user_list.html.erb b/app/views/users/_user_list.html.erb index 786e3c571..100f45929 100644 --- a/app/views/users/_user_list.html.erb +++ b/app/views/users/_user_list.html.erb @@ -9,7 +9,7 @@ <% end %> <%= table.head do |head| %> <%= head.row do |row| %> - <% row.cell(header: true, text: "Name and email adress", html_attributes: { + <% row.cell(header: true, text: "Name and email address", html_attributes: { scope: "col", }) %> <% row.cell(header: true, text: "Organisation and role", html_attributes: { diff --git a/config/forms/2021_2022.json b/config/forms/2021_2022.json index e47191f6e..49931ee05 100644 --- a/config/forms/2021_2022.json +++ b/config/forms/2021_2022.json @@ -8411,7 +8411,7 @@ } ], "title_text": { - "translation": "soft_validations.rent.min.title_text", + "translation": "soft_validations.rent.outside_range_title", "arguments": [ { "key": "brent", @@ -8421,7 +8421,7 @@ ] }, "informative_text": { - "translation": "soft_validations.rent.min.hint_text", + "translation": "soft_validations.rent.min_hint_text", "arguments": [ { "key": "soft_min_for_period", @@ -8463,7 +8463,7 @@ } ], "title_text": { - "translation": "soft_validations.rent.max.title_text", + "translation": "soft_validations.rent.outside_range_title", "arguments": [ { "key": "brent", @@ -8473,7 +8473,7 @@ ] }, "informative_text": { - "translation": "soft_validations.rent.max.hint_text", + "translation": "soft_validations.rent.max_hint_text", "arguments": [ { "key": "soft_max_for_period", diff --git a/config/forms/2022_2023.json b/config/forms/2022_2023.json index 7c54b67d4..ebd1bd594 100644 --- a/config/forms/2022_2023.json +++ b/config/forms/2022_2023.json @@ -8376,7 +8376,7 @@ } ], "title_text": { - "translation": "soft_validations.rent.min.title_text", + "translation": "soft_validations.rent.outside_range_title", "arguments": [ { "key": "brent", @@ -8385,16 +8385,7 @@ } ] }, - "informative_text": { - "translation": "soft_validations.rent.min.hint_text", - "arguments": [ - { - "key": "soft_min_for_period", - "label": false, - "i18n_template": "soft_min_for_period" - } - ] - }, + "informative_text": {}, "questions": { "rent_value_check": { "check_answer_label": "Total rent confirmation", @@ -8408,7 +8399,8 @@ } ] }, - "header": "Are you sure this is correct?", + "header": "This rent is lower than expected for this property type, in this area. Check:", + "hint_text": "

Are you sure this is correct?

", "type": "interruption_screen", "answer_options": { "0": { @@ -8428,7 +8420,7 @@ } ], "title_text": { - "translation": "soft_validations.rent.max.title_text", + "translation": "soft_validations.rent.outside_range_title", "arguments": [ { "key": "brent", @@ -8437,16 +8429,7 @@ } ] }, - "informative_text": { - "translation": "soft_validations.rent.max.hint_text", - "arguments": [ - { - "key": "soft_max_for_period", - "label": false, - "i18n_template": "soft_max_for_period" - } - ] - }, + "informative_text": {}, "questions": { "rent_value_check": { "check_answer_label": "Total rent confirmation", @@ -8460,7 +8443,8 @@ } ] }, - "header": "Are you sure this is correct?", + "header": "This rent is higher than expected for this property type, in this area. Check:", + "hint_text": "

Are you sure this is correct?

", "type": "interruption_screen", "answer_options": { "0": { diff --git a/config/locales/en.yml b/config/locales/en.yml index 874cb0446..d7a319674 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -131,7 +131,8 @@ en: other_field_missing: "If %{main_field_label} is other then %{other_field_label} must be provided" other_field_not_required: "%{other_field_label} must not be provided if %{main_field_label} was not other" numeric: - valid: "%{field} must be between %{min} and %{max}" + within_range: "%{field} must be between %{min} and %{max}" + above_min: "%{field} must be at least %{min}" date: invalid_date: "Enter a date in the correct format, for example 31 1 2022" outside_collection_window: "Enter a date within the current collection windows" @@ -148,7 +149,7 @@ en: intermediate_rent_product_name: blank: "Enter name of other intermediate rent product" saledate: - financial_year: "Date must be from 22/23 financial year" + financial_year: "Date must be from 22/23 financial year, which is between 1st April 2022 and 31st March 2023" startdate: later_than_14_days_after: "The tenancy start date must not be later than 14 days from today’s date" before_scheme_end_date: "The tenancy start date must be before the end date for this supported housing scheme" @@ -450,12 +451,9 @@ en: in_soft_max_range: message: "Net income is higher than expected based on the lead tenant’s working situation. Are you sure this is correct?" rent: - min: - title_text: "You told us the rent is %{brent}" - hint_text: "The minimum rent expected for this type of property in this local authority is £%{soft_min_for_period}." - max: - title_text: "You told us the rent is %{brent}" - hint_text: "The maximum rent expected for this type of property in this local authority is £%{soft_max_for_period}." + outside_range_title: "You told us the rent is %{brent}" + min_hint_text: "The minimum rent expected for this type of property in this local authority is £%{soft_min_for_period}." + max_hint_text: "The maximum rent expected for this type of property in this local authority is £%{soft_max_for_period}." retirement: min: title: "You told us this person is under %{age} and retired" @@ -473,9 +471,10 @@ en: title_text: "You told us the time between the start of the tenancy and the major repairs completion date is more than 2 years" void_date: title_text: "You told us the time between the start of the tenancy and the void date is more than 2 years" - shared_owhership_deposit: + shared_ownership_deposit: title_text: "Mortgage, deposit and cash discount total should equal £%{expected_shared_ownership_deposit_value}" old_persons_shared_ownership: "At least one buyer should be aged over 64 for Older persons’ shared ownership scheme" + staircase_bought_seems_high: "You said %{percentage}% was bought in this staircasing transaction, which seems high. Are you sure?" monthly_charges_over_soft_max: title_text: "The amount of monthly charges is high for this type of property and sale type" diff --git a/spec/components/check_answers_summary_list_card_component_spec.rb b/spec/components/check_answers_summary_list_card_component_spec.rb index 6e63c90cd..f9b8f6667 100644 --- a/spec/components/check_answers_summary_list_card_component_spec.rb +++ b/spec/components/check_answers_summary_list_card_component_spec.rb @@ -1,27 +1,49 @@ require "rails_helper" RSpec.describe CheckAnswersSummaryListCardComponent, type: :component do + subject(:component) { described_class.new(questions:, log:, user:) } + + let(:rendered) { render_inline(component) } + context "when given a set of questions" do - let(:user) { FactoryBot.build(:user) } - let(:log) { FactoryBot.build(:lettings_log, :completed, age2: 99, startdate: Time.zone.local(2021, 5, 1)) } + let(:user) { build(:user) } + let(:log) { build(:lettings_log, :completed, age2: 99, startdate: Time.zone.local(2021, 5, 1)) } let(:subsection_id) { "household_characteristics" } let(:subsection) { log.form.get_subsection(subsection_id) } let(:questions) { subsection.applicable_questions(log) } it "renders a summary list card for the answers to those questions" do - result = render_inline(described_class.new(questions:, log:, user:)) - expect(result).to have_content(questions.first.answer_label(log)) + expect(rendered).to have_content(questions.first.answer_label(log)) end it "applicable questions doesn't return questions that are hidden in check answers" do - summary_list = described_class.new(questions:, log:, user:) - expect(summary_list.applicable_questions.map(&:id).include?("retirement_value_check")).to eq(false) + expect(component.applicable_questions.map(&:id).include?("retirement_value_check")).to eq(false) end it "has the correct answer label for a question" do - summary_list = described_class.new(questions:, log:, user:) sex1_question = questions[2] - expect(summary_list.get_answer_label(sex1_question)).to eq("Female") + expect(component.get_answer_label(sex1_question)).to eq("Female") + end + + context "when log was created via a bulk upload and has an unanswered question" do + subject(:component) { described_class.new(questions:, log:, user:) } + + let(:bulk_upload) { build(:bulk_upload, :lettings) } + let(:log) { build(:lettings_log, :in_progress, bulk_upload:, age2: 99, startdate: Time.zone.local(2021, 5, 1)) } + + it "displays tweaked copy in red" do + expect(rendered).to have_selector("span", class: "app-!-colour-red", text: "You still need to answer this question") + end + end + + context "when log was not created via a bulk upload and has an unanswered question" do + subject(:component) { described_class.new(questions:, log:, user:) } + + let(:log) { build(:lettings_log, :in_progress, age2: 99, startdate: Time.zone.local(2021, 5, 1)) } + + it "displays normal copy with muted colour " do + expect(rendered).to have_selector("span", class: "app-!-colour-muted", text: "You didn’t answer this question") + end end end end diff --git a/spec/helpers/collection_time_helper_spec.rb b/spec/helpers/collection_time_helper_spec.rb new file mode 100644 index 000000000..3b02802f2 --- /dev/null +++ b/spec/helpers/collection_time_helper_spec.rb @@ -0,0 +1,34 @@ +require "rails_helper" + +RSpec.describe CollectionTimeHelper do + let(:current_user) { create(:user, :data_coordinator) } + let(:user) { create(:user, :data_coordinator) } + + around do |example| + Timecop.freeze(now) do + example.run + end + end + + describe "Current collection start year" do + context "when the date is after 1st of April" do + let(:now) { Time.utc(2022, 8, 3) } + + it "returns the same year as the current start year" do + expect(current_collection_start_year).to eq(2022) + end + + it "returns the correct current start date" do + expect(current_collection_start_date).to eq(Time.zone.local(2022, 4, 1)) + end + end + + context "with the date before 1st of April" do + let(:now) { Time.utc(2022, 2, 3) } + + it "returns the previous year as the current start year" do + expect(current_collection_start_year).to eq(2021) + end + end + end +end diff --git a/spec/mailers/bulk_upload_mailer_spec.rb b/spec/mailers/bulk_upload_mailer_spec.rb new file mode 100644 index 000000000..3d7c0454f --- /dev/null +++ b/spec/mailers/bulk_upload_mailer_spec.rb @@ -0,0 +1,50 @@ +require "rails_helper" + +RSpec.describe BulkUploadMailer do + subject(:mailer) { described_class.new } + + let(:notify_client) { instance_double(Notifications::Client) } + let(:user) { create(:user, email: "user@example.com") } + let(:bulk_upload) { build(:bulk_upload, :lettings, user:) } + + before do + allow(Notifications::Client).to receive(:new).and_return(notify_client) + allow(notify_client).to receive(:send_email).and_return(true) + end + + describe "#send_bulk_upload_complete_mail" do + it "sends correctly formed email" do + expect(notify_client).to receive(:send_email).with( + email_address: user.email, + template_id: described_class::BULK_UPLOAD_COMPLETE_TEMPLATE_ID, + personalisation: { + title: "You’ve successfully uploaded 0 logs", + filename: bulk_upload.filename, + upload_timestamp: bulk_upload.created_at, + success_description: "The lettings 2022/23 data you uploaded has been checked. The 0 logs you uploaded are now complete.", + logs_link: lettings_logs_url, + }, + ) + + mailer.send_bulk_upload_complete_mail(user:, bulk_upload:) + end + end + + describe "#send_bulk_upload_failed_service_error_mail" do + it "sends correctly formed email" do + expect(notify_client).to receive(:send_email).with( + email_address: user.email, + template_id: described_class::BULK_UPLOAD_FAILED_SERVICE_ERROR_TEMPLATE_ID, + personalisation: { + filename: bulk_upload.filename, + upload_timestamp: bulk_upload.created_at, + lettings_or_sales: bulk_upload.log_type, + year_combo: bulk_upload.year_combo, + bulk_upload_link: start_bulk_upload_lettings_logs_url, + }, + ) + + mailer.send_bulk_upload_failed_service_error_mail(bulk_upload:) + end + end +end diff --git a/spec/models/form/lettings/pages/females_in_soft_age_range_in_pregnant_household_person_age_value_check_spec.rb b/spec/models/form/lettings/pages/females_in_soft_age_range_in_pregnant_household_person_age_value_check_spec.rb new file mode 100644 index 000000000..b3d7054ce --- /dev/null +++ b/spec/models/form/lettings/pages/females_in_soft_age_range_in_pregnant_household_person_age_value_check_spec.rb @@ -0,0 +1,113 @@ +require "rails_helper" + +RSpec.describe Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdPersonAgeValueCheck, type: :model do + subject(:page) { described_class.new(nil, page_definition, subsection, person_index:) } + + let(:page_definition) { nil } + let(:subsection) { instance_double(Form::Subsection) } + let(:person_index) { 2 } + + it "has correct subsection" do + expect(page.subsection).to eq(subsection) + end + + it "has the correct header" do + expect(page.header).to be nil + end + + it "has the correct description" do + expect(page.description).to be nil + end + + it "has correct questions" do + expect(page.questions.map(&:id)).to eq(%w[pregnancy_value_check]) + end + + context "with person 2" do + it "has the correct id" do + expect(page.id).to eq("females_in_soft_age_range_in_pregnant_household_person_2_age_value_check") + end + + it "has correct depends_on" do + expect(page.depends_on).to eq( + [ + { + "age2_known" => 0, + "female_in_pregnant_household_in_soft_validation_range?" => true, + }, + ], + ) + end + + it "has the correct title_text" do + expect(page.title_text).to eq({ + "translation" => "soft_validations.pregnancy.title", + "arguments" => [ + { + "key" => "sex1", + "label" => true, + "i18n_template" => "sex1", + }, + ], + }) + end + + it "has the correct informative_text" do + expect(page.informative_text).to eq({ + "translation" => "soft_validations.pregnancy.females_not_in_soft_age_range", + "arguments" => [ + { + "key" => "sex1", + "label" => true, + "i18n_template" => "sex1", + }, + ], + }) + end + end + + context "with person 3" do + let(:person_index) { 3 } + + it "has the correct id" do + expect(page.id).to eq("females_in_soft_age_range_in_pregnant_household_person_3_age_value_check") + end + + it "has correct depends_on" do + expect(page.depends_on).to eq( + [ + { + "age3_known" => 0, + "female_in_pregnant_household_in_soft_validation_range?" => true, + }, + ], + ) + end + + it "has the correct title_text" do + expect(page.title_text).to eq({ + "translation" => "soft_validations.pregnancy.title", + "arguments" => [ + { + "key" => "sex1", + "label" => true, + "i18n_template" => "sex1", + }, + ], + }) + end + + it "has the correct informative_text" do + expect(page.informative_text).to eq({ + "translation" => "soft_validations.pregnancy.females_not_in_soft_age_range", + "arguments" => [ + { + "key" => "sex1", + "label" => true, + "i18n_template" => "sex1", + }, + ], + }) + end + end +end diff --git a/spec/models/form/lettings/pages/females_in_soft_age_range_in_pregnant_household_person_value_check_spec.rb b/spec/models/form/lettings/pages/females_in_soft_age_range_in_pregnant_household_person_value_check_spec.rb new file mode 100644 index 000000000..fac723aea --- /dev/null +++ b/spec/models/form/lettings/pages/females_in_soft_age_range_in_pregnant_household_person_value_check_spec.rb @@ -0,0 +1,113 @@ +require "rails_helper" + +RSpec.describe Form::Lettings::Pages::FemalesInSoftAgeRangeInPregnantHouseholdPersonValueCheck, type: :model do + subject(:page) { described_class.new(nil, page_definition, subsection, person_index:) } + + let(:page_definition) { nil } + let(:subsection) { instance_double(Form::Subsection) } + let(:person_index) { 2 } + + it "has correct subsection" do + expect(page.subsection).to eq(subsection) + end + + it "has the correct header" do + expect(page.header).to be nil + end + + it "has the correct description" do + expect(page.description).to be nil + end + + it "has correct questions" do + expect(page.questions.map(&:id)).to eq(%w[pregnancy_value_check]) + end + + context "with person 2" do + it "has the correct id" do + expect(page.id).to eq("females_in_soft_age_range_in_pregnant_household_person_2_value_check") + end + + it "has correct depends_on" do + expect(page.depends_on).to eq( + [ + { + "details_known_2" => 0, + "female_in_pregnant_household_in_soft_validation_range?" => true, + }, + ], + ) + end + + it "has the correct title_text" do + expect(page.title_text).to eq({ + "translation" => "soft_validations.pregnancy.title", + "arguments" => [ + { + "key" => "sex1", + "label" => true, + "i18n_template" => "sex1", + }, + ], + }) + end + + it "has the correct informative_text" do + expect(page.informative_text).to eq({ + "translation" => "soft_validations.pregnancy.females_not_in_soft_age_range", + "arguments" => [ + { + "key" => "sex1", + "label" => true, + "i18n_template" => "sex1", + }, + ], + }) + end + end + + context "with person 3" do + let(:person_index) { 3 } + + it "has the correct id" do + expect(page.id).to eq("females_in_soft_age_range_in_pregnant_household_person_3_value_check") + end + + it "has correct depends_on" do + expect(page.depends_on).to eq( + [ + { + "details_known_3" => 0, + "female_in_pregnant_household_in_soft_validation_range?" => true, + }, + ], + ) + end + + it "has the correct title_text" do + expect(page.title_text).to eq({ + "translation" => "soft_validations.pregnancy.title", + "arguments" => [ + { + "key" => "sex1", + "label" => true, + "i18n_template" => "sex1", + }, + ], + }) + end + + it "has the correct informative_text" do + expect(page.informative_text).to eq({ + "translation" => "soft_validations.pregnancy.females_not_in_soft_age_range", + "arguments" => [ + { + "key" => "sex1", + "label" => true, + "i18n_template" => "sex1", + }, + ], + }) + end + end +end diff --git a/spec/models/form/lettings/pages/location_spec.rb b/spec/models/form/lettings/pages/location_spec.rb index 85cfd0a21..aefcd59a9 100644 --- a/spec/models/form/lettings/pages/location_spec.rb +++ b/spec/models/form/lettings/pages/location_spec.rb @@ -28,9 +28,11 @@ RSpec.describe Form::Lettings::Pages::Location, type: :model do end it "has the correct depends_on" do - expect(page.depends_on).to eq([{ - "needstype" => 2, - "scheme_has_multiple_locations?" => true, - }]) + expect(page.depends_on).to eq([ + { + "needstype" => 2, + "scheme_has_multiple_locations?" => true, + }, + ]) end end diff --git a/spec/models/form/lettings/pages/no_females_pregnant_household_person_age_value_check_spec.rb b/spec/models/form/lettings/pages/no_females_pregnant_household_person_age_value_check_spec.rb new file mode 100644 index 000000000..5e6adf867 --- /dev/null +++ b/spec/models/form/lettings/pages/no_females_pregnant_household_person_age_value_check_spec.rb @@ -0,0 +1,113 @@ +require "rails_helper" + +RSpec.describe Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonAgeValueCheck, type: :model do + subject(:page) { described_class.new(nil, page_definition, subsection, person_index:) } + + let(:page_definition) { nil } + let(:subsection) { instance_double(Form::Subsection) } + let(:person_index) { 2 } + + it "has correct subsection" do + expect(page.subsection).to eq(subsection) + end + + it "has the correct header" do + expect(page.header).to be nil + end + + it "has the correct description" do + expect(page.description).to be nil + end + + it "has correct questions" do + expect(page.questions.map(&:id)).to eq(%w[pregnancy_value_check]) + end + + context "with person 2" do + it "has the correct id" do + expect(page.id).to eq("no_females_pregnant_household_person_2_age_value_check") + end + + it "has correct depends_on" do + expect(page.depends_on).to eq( + [ + { + "age2_known" => 0, + "no_females_in_a_pregnant_household?" => true, + }, + ], + ) + end + + it "has the correct title_text" do + expect(page.title_text).to eq({ + "translation" => "soft_validations.pregnancy.title", + "arguments" => [ + { + "key" => "sex1", + "label" => true, + "i18n_template" => "sex1", + }, + ], + }) + end + + it "has the correct informative_text" do + expect(page.informative_text).to eq({ + "translation" => "soft_validations.pregnancy.no_females", + "arguments" => [ + { + "key" => "sex1", + "label" => true, + "i18n_template" => "sex1", + }, + ], + }) + end + end + + context "with person 3" do + let(:person_index) { 3 } + + it "has the correct id" do + expect(page.id).to eq("no_females_pregnant_household_person_3_age_value_check") + end + + it "has correct depends_on" do + expect(page.depends_on).to eq( + [ + { + "age3_known" => 0, + "no_females_in_a_pregnant_household?" => true, + }, + ], + ) + end + + it "has the correct title_text" do + expect(page.title_text).to eq({ + "translation" => "soft_validations.pregnancy.title", + "arguments" => [ + { + "key" => "sex1", + "label" => true, + "i18n_template" => "sex1", + }, + ], + }) + end + + it "has the correct informative_text" do + expect(page.informative_text).to eq({ + "translation" => "soft_validations.pregnancy.no_females", + "arguments" => [ + { + "key" => "sex1", + "label" => true, + "i18n_template" => "sex1", + }, + ], + }) + end + end +end diff --git a/spec/models/form/lettings/pages/no_females_pregnant_household_person_value_check_spec.rb b/spec/models/form/lettings/pages/no_females_pregnant_household_person_value_check_spec.rb new file mode 100644 index 000000000..05691313c --- /dev/null +++ b/spec/models/form/lettings/pages/no_females_pregnant_household_person_value_check_spec.rb @@ -0,0 +1,113 @@ +require "rails_helper" + +RSpec.describe Form::Lettings::Pages::NoFemalesPregnantHouseholdPersonValueCheck, type: :model do + subject(:page) { described_class.new(nil, page_definition, subsection, person_index:) } + + let(:page_definition) { nil } + let(:subsection) { instance_double(Form::Subsection) } + let(:person_index) { 2 } + + it "has correct subsection" do + expect(page.subsection).to eq(subsection) + end + + it "has the correct header" do + expect(page.header).to be nil + end + + it "has the correct description" do + expect(page.description).to be nil + end + + it "has correct questions" do + expect(page.questions.map(&:id)).to eq(%w[pregnancy_value_check]) + end + + context "with person 2" do + it "has the correct id" do + expect(page.id).to eq("no_females_pregnant_household_person_2_value_check") + end + + it "has correct depends_on" do + expect(page.depends_on).to eq( + [ + { + "details_known_2" => 0, + "no_females_in_a_pregnant_household?" => true, + }, + ], + ) + end + + it "has the correct title_text" do + expect(page.title_text).to eq({ + "translation" => "soft_validations.pregnancy.title", + "arguments" => [ + { + "key" => "sex1", + "label" => true, + "i18n_template" => "sex1", + }, + ], + }) + end + + it "has the correct informative_text" do + expect(page.informative_text).to eq({ + "translation" => "soft_validations.pregnancy.no_females", + "arguments" => [ + { + "key" => "sex1", + "label" => true, + "i18n_template" => "sex1", + }, + ], + }) + end + end + + context "with person 3" do + let(:person_index) { 3 } + + it "has the correct id" do + expect(page.id).to eq("no_females_pregnant_household_person_3_value_check") + end + + it "has correct depends_on" do + expect(page.depends_on).to eq( + [ + { + "details_known_3" => 0, + "no_females_in_a_pregnant_household?" => true, + }, + ], + ) + end + + it "has the correct title_text" do + expect(page.title_text).to eq({ + "translation" => "soft_validations.pregnancy.title", + "arguments" => [ + { + "key" => "sex1", + "label" => true, + "i18n_template" => "sex1", + }, + ], + }) + end + + it "has the correct informative_text" do + expect(page.informative_text).to eq({ + "translation" => "soft_validations.pregnancy.no_females", + "arguments" => [ + { + "key" => "sex1", + "label" => true, + "i18n_template" => "sex1", + }, + ], + }) + end + end +end diff --git a/spec/models/form/lettings/pages/person_age_spec.rb b/spec/models/form/lettings/pages/person_age_spec.rb new file mode 100644 index 000000000..ca39ef2c9 --- /dev/null +++ b/spec/models/form/lettings/pages/person_age_spec.rb @@ -0,0 +1,55 @@ +require "rails_helper" + +RSpec.describe Form::Lettings::Pages::PersonAge, type: :model do + subject(:page) { described_class.new(nil, page_definition, subsection, person_index:) } + + let(:page_definition) { nil } + let(:subsection) { instance_double(Form::Subsection) } + let(:person_index) { 2 } + + it "has correct subsection" do + expect(page.subsection).to eq(subsection) + end + + it "has the correct header" do + expect(page.header).to be nil + end + + it "has the correct description" do + expect(page.description).to be nil + end + + context "with person 2" do + it "has correct questions" do + expect(page.questions.map(&:id)).to eq(%w[age2_known age2]) + end + + it "has the correct id" do + expect(page.id).to eq("person_2_age") + end + + it "has correct depends_on" do + expect(page.depends_on).to eq( + [{ "details_known_2" => 0 }], + ) + end + end + + context "with person 3" do + let(:person_index) { 3 } + + it "has correct questions" do + expect(page.questions.map(&:id)).to eq(%w[age3_known age3]) + end + + it "has the correct id" do + expect(page.id).to eq("person_3_age") + end + + it "has correct depends_on" do + expect(page.depends_on).to eq( + [{ "details_known_3" => 0 }], + ) + end + end +end diff --git a/spec/models/form/lettings/pages/person_gender_identity_spec.rb b/spec/models/form/lettings/pages/person_gender_identity_spec.rb new file mode 100644 index 000000000..df0e8fa12 --- /dev/null +++ b/spec/models/form/lettings/pages/person_gender_identity_spec.rb @@ -0,0 +1,55 @@ +require "rails_helper" + +RSpec.describe Form::Lettings::Pages::PersonGenderIdentity, type: :model do + subject(:page) { described_class.new(nil, page_definition, subsection, person_index:) } + + let(:page_definition) { nil } + let(:subsection) { instance_double(Form::Subsection) } + let(:person_index) { 2 } + + it "has correct subsection" do + expect(page.subsection).to eq(subsection) + end + + it "has the correct header" do + expect(page.header).to be nil + end + + it "has the correct description" do + expect(page.description).to be nil + end + + context "with person 2" do + it "has correct questions" do + expect(page.questions.map(&:id)).to eq(%w[sex2]) + end + + it "has the correct id" do + expect(page.id).to eq("person_2_gender_identity") + end + + it "has correct depends_on" do + expect(page.depends_on).to eq( + [{ "details_known_2" => 0 }], + ) + end + end + + context "with person 3" do + let(:person_index) { 3 } + + it "has correct questions" do + expect(page.questions.map(&:id)).to eq(%w[sex3]) + end + + it "has the correct id" do + expect(page.id).to eq("person_3_gender_identity") + end + + it "has correct depends_on" do + expect(page.depends_on).to eq( + [{ "details_known_3" => 0 }], + ) + end + end +end diff --git a/spec/models/form/lettings/pages/person_known_spec.rb b/spec/models/form/lettings/pages/person_known_spec.rb new file mode 100644 index 000000000..a64976ed5 --- /dev/null +++ b/spec/models/form/lettings/pages/person_known_spec.rb @@ -0,0 +1,70 @@ +require "rails_helper" + +RSpec.describe Form::Lettings::Pages::PersonKnown, type: :model do + subject(:page) { described_class.new(nil, page_definition, subsection, person_index:) } + + let(:page_definition) { nil } + let(:subsection) { instance_double(Form::Subsection) } + let(:person_index) { 2 } + + it "has correct subsection" do + expect(page.subsection).to eq(subsection) + end + + it "has the correct header" do + expect(page.header).to eq("You’ve given us the details for 1 person in the household") + end + + it "has the correct description" do + expect(page.description).to be nil + end + + context "with person 2" do + it "has correct questions" do + expect(page.questions.map(&:id)).to eq(%w[details_known_2]) + end + + it "has the correct id" do + expect(page.id).to eq("person_2_known") + end + + it "has correct depends_on" do + expect(page.depends_on).to eq( + [ + { "hhmemb" => 2 }, + { "hhmemb" => 3 }, + { "hhmemb" => 4 }, + { "hhmemb" => 5 }, + { "hhmemb" => 6 }, + { "hhmemb" => 7 }, + { "hhmemb" => 8 }, + ], + ) + end + end + + context "with person 3" do + let(:person_index) { 3 } + + it "has correct questions" do + expect(page.questions.map(&:id)).to eq(%w[details_known_3]) + end + + it "has the correct id" do + expect(page.id).to eq("person_3_known") + end + + it "has correct depends_on" do + expect(page.depends_on).to eq( + [ + { "hhmemb" => 3 }, + { "hhmemb" => 4 }, + { "hhmemb" => 5 }, + { "hhmemb" => 6 }, + { "hhmemb" => 7 }, + { "hhmemb" => 8 }, + ], + ) + end + end +end diff --git a/spec/models/form/lettings/pages/person_over_retirement_value_check_spec.rb b/spec/models/form/lettings/pages/person_over_retirement_value_check_spec.rb new file mode 100644 index 000000000..45587b4fb --- /dev/null +++ b/spec/models/form/lettings/pages/person_over_retirement_value_check_spec.rb @@ -0,0 +1,113 @@ +require "rails_helper" + +RSpec.describe Form::Lettings::Pages::PersonOverRetirementValueCheck, type: :model do + subject(:page) { described_class.new(nil, page_definition, subsection, person_index:) } + + let(:page_definition) { nil } + let(:subsection) { instance_double(Form::Subsection) } + let(:person_index) { 2 } + + it "has correct subsection" do + expect(page.subsection).to eq(subsection) + end + + it "has the correct header" do + expect(page.header).to be nil + end + + it "has the correct description" do + expect(page.description).to be nil + end + + it "has correct questions" do + expect(page.questions.map(&:id)).to eq(%w[retirement_value_check]) + end + + context "with person 2" do + it "has the correct id" do + expect(page.id).to eq("person_2_over_retirement_value_check") + end + + it "has correct depends_on" do + expect(page.depends_on).to eq( + [{ "person_2_not_retired_over_soft_max_age?" => true }], + ) + end + + it "has the correct title_text" do + expect(page.title_text).to eq({ + "translation" => "soft_validations.retirement.max.title", + "arguments" => [ + { + "key" => "retirement_age_for_person_2", + "label" => false, + "i18n_template" => "age", + }, + ], + }) + end + + it "has the correct informative_text" do + expect(page.informative_text).to eq({ + "translation" => "soft_validations.retirement.max.hint_text", + "arguments" => [ + { + "key" => "plural_gender_for_person_2", + "label" => false, + "i18n_template" => "gender", + }, + { + "key" => "retirement_age_for_person_2", + "label" => false, + "i18n_template" => "age", + }, + ], + }) + end + end + + context "with person 3" do + let(:person_index) { 3 } + + it "has the correct id" do + expect(page.id).to eq("person_3_over_retirement_value_check") + end + + it "has correct depends_on" do + expect(page.depends_on).to eq( + [{ "person_3_not_retired_over_soft_max_age?" => true }], + ) + end + + it "has the correct title_text" do + expect(page.title_text).to eq({ + "translation" => "soft_validations.retirement.max.title", + "arguments" => [ + { + "key" => "retirement_age_for_person_3", + "label" => false, + "i18n_template" => "age", + }, + ], + }) + end + + it "has the correct informative_text" do + expect(page.informative_text).to eq({ + "translation" => "soft_validations.retirement.max.hint_text", + "arguments" => [ + { + "key" => "plural_gender_for_person_3", + "label" => false, + "i18n_template" => "gender", + }, + { + "key" => "retirement_age_for_person_3", + "label" => false, + "i18n_template" => "age", + }, + ], + }) + end + end +end diff --git a/spec/models/form/lettings/pages/person_relationship_to_lead_spec.rb b/spec/models/form/lettings/pages/person_relationship_to_lead_spec.rb new file mode 100644 index 000000000..6af0a07c2 --- /dev/null +++ b/spec/models/form/lettings/pages/person_relationship_to_lead_spec.rb @@ -0,0 +1,55 @@ +require "rails_helper" + +RSpec.describe Form::Lettings::Pages::PersonRelationshipToLead, type: :model do + subject(:page) { described_class.new(nil, page_definition, subsection, person_index:) } + + let(:page_definition) { nil } + let(:subsection) { instance_double(Form::Subsection) } + let(:person_index) { 2 } + + it "has correct subsection" do + expect(page.subsection).to eq(subsection) + end + + it "has the correct header" do + expect(page.header).to be nil + end + + it "has the correct description" do + expect(page.description).to be nil + end + + context "with person 2" do + it "has correct questions" do + expect(page.questions.map(&:id)).to eq(%w[relat2]) + end + + it "has the correct id" do + expect(page.id).to eq("person_2_relationship_to_lead") + end + + it "has correct depends_on" do + expect(page.depends_on).to eq( + [{ "details_known_2" => 0 }], + ) + end + end + + context "with person 3" do + let(:person_index) { 3 } + + it "has correct questions" do + expect(page.questions.map(&:id)).to eq(%w[relat3]) + end + + it "has the correct id" do + expect(page.id).to eq("person_3_relationship_to_lead") + end + + it "has correct depends_on" do + expect(page.depends_on).to eq( + [{ "details_known_3" => 0 }], + ) + end + end +end diff --git a/spec/models/form/lettings/pages/person_under_retirement_value_check_spec.rb b/spec/models/form/lettings/pages/person_under_retirement_value_check_spec.rb new file mode 100644 index 000000000..a2a6dd20f --- /dev/null +++ b/spec/models/form/lettings/pages/person_under_retirement_value_check_spec.rb @@ -0,0 +1,113 @@ +require "rails_helper" + +RSpec.describe Form::Lettings::Pages::PersonUnderRetirementValueCheck, type: :model do + subject(:page) { described_class.new(nil, page_definition, subsection, person_index:) } + + let(:page_definition) { nil } + let(:subsection) { instance_double(Form::Subsection) } + let(:person_index) { 2 } + + it "has correct subsection" do + expect(page.subsection).to eq(subsection) + end + + it "has the correct header" do + expect(page.header).to be nil + end + + it "has the correct description" do + expect(page.description).to be nil + end + + it "has correct questions" do + expect(page.questions.map(&:id)).to eq(%w[retirement_value_check]) + end + + context "with person 2" do + it "has the correct id" do + expect(page.id).to eq("person_2_under_retirement_value_check") + end + + it "has correct depends_on" do + expect(page.depends_on).to eq( + [{ "person_2_retired_under_soft_min_age?" => true }], + ) + end + + it "has the correct title_text" do + expect(page.title_text).to eq({ + "translation" => "soft_validations.retirement.min.title", + "arguments" => [ + { + "key" => "retirement_age_for_person_2", + "label" => false, + "i18n_template" => "age", + }, + ], + }) + end + + it "has the correct informative_text" do + expect(page.informative_text).to eq({ + "translation" => "soft_validations.retirement.min.hint_text", + "arguments" => [ + { + "key" => "plural_gender_for_person_2", + "label" => false, + "i18n_template" => "gender", + }, + { + "key" => "retirement_age_for_person_2", + "label" => false, + "i18n_template" => "age", + }, + ], + }) + end + end + + context "with person 3" do + let(:person_index) { 3 } + + it "has the correct id" do + expect(page.id).to eq("person_3_under_retirement_value_check") + end + + it "has correct depends_on" do + expect(page.depends_on).to eq( + [{ "person_3_retired_under_soft_min_age?" => true }], + ) + end + + it "has the correct title_text" do + expect(page.title_text).to eq({ + "translation" => "soft_validations.retirement.min.title", + "arguments" => [ + { + "key" => "retirement_age_for_person_3", + "label" => false, + "i18n_template" => "age", + }, + ], + }) + end + + it "has the correct informative_text" do + expect(page.informative_text).to eq({ + "translation" => "soft_validations.retirement.min.hint_text", + "arguments" => [ + { + "key" => "plural_gender_for_person_3", + "label" => false, + "i18n_template" => "gender", + }, + { + "key" => "retirement_age_for_person_3", + "label" => false, + "i18n_template" => "age", + }, + ], + }) + end + end +end diff --git a/spec/models/form/lettings/pages/person_working_situation_spec.rb b/spec/models/form/lettings/pages/person_working_situation_spec.rb new file mode 100644 index 000000000..36120ec70 --- /dev/null +++ b/spec/models/form/lettings/pages/person_working_situation_spec.rb @@ -0,0 +1,61 @@ +require "rails_helper" + +RSpec.describe Form::Lettings::Pages::PersonWorkingSituation, type: :model do + subject(:page) { described_class.new(nil, page_definition, subsection, person_index:) } + + let(:page_definition) { nil } + let(:subsection) { instance_double(Form::Subsection) } + let(:person_index) { 2 } + + it "has correct subsection" do + expect(page.subsection).to eq(subsection) + end + + it "has the correct header" do + expect(page.header).to be nil + end + + it "has the correct description" do + expect(page.description).to be nil + end + + context "with person 2" do + it "has correct questions" do + expect(page.questions.map(&:id)).to eq(%w[ecstat2]) + end + + it "has the correct id" do + expect(page.id).to eq("person_2_working_situation") + end + + it "has correct depends_on" do + expect(page.depends_on).to eq( + [ + { "age2" => { "operand" => 15, "operator" => ">" }, "details_known_2" => 0 }, + { "age2" => nil, "details_known_2" => 0 }, + ], + ) + end + end + + context "with person 3" do + let(:person_index) { 3 } + + it "has correct questions" do + expect(page.questions.map(&:id)).to eq(%w[ecstat3]) + end + + it "has the correct id" do + expect(page.id).to eq("person_3_working_situation") + end + + it "has correct depends_on" do + expect(page.depends_on).to eq( + [ + { "age3" => { "operand" => 15, "operator" => ">" }, "details_known_3" => 0 }, + { "age3" => nil, "details_known_3" => 0 }, + ], + ) + end + end +end diff --git a/spec/models/form/lettings/pages/stock_owner_spec.rb b/spec/models/form/lettings/pages/stock_owner_spec.rb index b90fe966e..798a68e8c 100644 --- a/spec/models/form/lettings/pages/stock_owner_spec.rb +++ b/spec/models/form/lettings/pages/stock_owner_spec.rb @@ -131,7 +131,9 @@ RSpec.describe Form::Lettings::Pages::StockOwner, type: :model do end it "updates owning_organisation_id to user organisation" do - expect { page.routed_to?(log, user) }.to change(log.reload, :owning_organisation).from(nil).to(user.organisation) + expect { + page.routed_to?(log, user) + }.to change(log.reload, :owning_organisation).from(nil).to(user.organisation) end end diff --git a/spec/models/form/lettings/questions/age_known_spec.rb b/spec/models/form/lettings/questions/age_known_spec.rb new file mode 100644 index 000000000..a3ca5c3fb --- /dev/null +++ b/spec/models/form/lettings/questions/age_known_spec.rb @@ -0,0 +1,108 @@ +require "rails_helper" + +RSpec.describe Form::Lettings::Questions::AgeKnown, type: :model do + subject(:question) { described_class.new(nil, question_definition, page, person_index:) } + + let(:question_definition) { nil } + let(:page) { instance_double(Form::Page) } + let(:person_index) { 2 } + + it "has correct page" do + expect(question.page).to eq(page) + end + + it "has the correct type" do + expect(question.type).to eq("radio") + end + + it "is not marked as derived" do + expect(question.derived?).to be false + end + + it "has the correct answer_options" do + expect(question.answer_options).to eq({ + "0" => { "value" => "Yes" }, + "1" => { "value" => "No" }, + }) + end + + it "has the correct hint" do + expect(question.hint_text).to eq("") + end + + it "has the correct check_answer_label" do + expect(question.check_answer_label).to eq("") + end + + context "with person 2" do + it "has the correct id" do + expect(question.id).to eq("age2_known") + end + + it "has the correct header" do + expect(question.header).to eq("Do you know person 2’s age?") + end + + it "has correct conditional for" do + expect(question.conditional_for).to eq({ + "age2" => [0], + }) + end + + it "has the correct hidden_in_check_answers" do + expect(question.hidden_in_check_answers).to eq( + { + "depends_on" => [ + { + "age2_known" => 0, + }, + { + "age2_known" => 1, + }, + ], + }, + ) + end + + it "has the correct check_answers_card_number" do + expect(question.check_answers_card_number).to eq(2) + end + end + + context "with person 3" do + let(:person_index) { 3 } + + it "has the correct id" do + expect(question.id).to eq("age3_known") + end + + it "has the correct header" do + expect(question.header).to eq("Do you know person 3’s age?") + end + + it "has correct conditional for" do + expect(question.conditional_for).to eq({ + "age3" => [0], + }) + end + + it "has the correct hidden_in_check_answers" do + expect(question.hidden_in_check_answers).to eq( + { + "depends_on" => [ + { + "age3_known" => 0, + }, + { + "age3_known" => 1, + }, + ], + }, + ) + end + + it "has the correct check_answers_card_number" do + expect(question.check_answers_card_number).to eq(3) + end + end +end diff --git a/spec/models/form/lettings/questions/age_spec.rb b/spec/models/form/lettings/questions/age_spec.rb new file mode 100644 index 000000000..87c3dce22 --- /dev/null +++ b/spec/models/form/lettings/questions/age_spec.rb @@ -0,0 +1,89 @@ +require "rails_helper" + +RSpec.describe Form::Lettings::Questions::Age, type: :model do + subject(:question) { described_class.new(nil, question_definition, page, person_index:) } + + let(:question_definition) { nil } + let(:page) { instance_double(Form::Page) } + let(:person_index) { 2 } + + it "has correct page" do + expect(question.page).to eq(page) + end + + it "has the correct header" do + expect(question.header).to eq("Age") + end + + it "has the correct type" do + expect(question.type).to eq("numeric") + end + + it "is not marked as derived" do + expect(question.derived?).to be false + end + + it "has the correct hint" do + expect(question.hint_text).to be_nil + end + + it "has the correct min" do + expect(question.min).to eq(0) + end + + it "has the correct max" do + expect(question.max).to eq(120) + end + + it "has the correct width" do + expect(question.width).to eq(2) + end + + context "with person 2" do + it "has the correct id" do + expect(question.id).to eq("age2") + end + + it "has the correct check_answer_label" do + expect(question.check_answer_label).to eq("Person 2’s age") + end + + it "has the correct inferred check answers value" do + expect(question.inferred_check_answers_value).to eq([ + { + "condition" => { "age2_known" => 1 }, + "value" => "Not known", + }, + ]) + end + + it "has the correct check_answers_card_number" do + expect(question.check_answers_card_number).to eq(2) + end + end + + context "with person 3" do + let(:person_index) { 3 } + + it "has the correct id" do + expect(question.id).to eq("age3") + end + + it "has the correct check_answer_label" do + expect(question.check_answer_label).to eq("Person 3’s age") + end + + it "has the correct inferred check answers value" do + expect(question.inferred_check_answers_value).to eq([ + { + "condition" => { "age3_known" => 1 }, + "value" => "Not known", + }, + ]) + end + + it "has the correct check_answers_card_number" do + expect(question.check_answers_card_number).to eq(3) + end + end +end diff --git a/spec/models/form/lettings/questions/details_known_spec.rb b/spec/models/form/lettings/questions/details_known_spec.rb new file mode 100644 index 000000000..799b307b0 --- /dev/null +++ b/spec/models/form/lettings/questions/details_known_spec.rb @@ -0,0 +1,63 @@ +require "rails_helper" + +RSpec.describe Form::Lettings::Questions::DetailsKnown, type: :model do + subject(:question) { described_class.new(nil, question_definition, page, person_index:) } + + let(:question_definition) { nil } + let(:page) { instance_double(Form::Page) } + let(:person_index) { 2 } + + it "has correct page" do + expect(question.page).to eq(page) + end + + it "has the correct type" do + expect(question.type).to eq("radio") + end + + it "is not marked as derived" do + expect(question.derived?).to be false + end + + it "has the correct hint" do + expect(question.hint_text).to eq("You must provide details for everyone in the household if you know them.") + end + + context "with person 2" do + it "has the correct id" do + expect(question.id).to eq("details_known_2") + end + + it "has the correct check_answer_label" do + expect(question.check_answer_label).to eq("Details known for person 2") + end + + it "has the correct header" do + expect(question.header).to eq("Do you know details for person 2?") + end + + it "has the correct check_answers_card_number" do + expect(question.check_answers_card_number).to eq(2) + end + end + + context "with person 3" do + let(:person_index) { 3 } + + it "has the correct id" do + expect(question.id).to eq("details_known_3") + end + + it "has the correct check_answer_label" do + expect(question.check_answer_label).to eq("Details known for person 3") + end + + it "has the correct header" do + expect(question.header).to eq("Do you know details for person 3?") + end + + it "has the correct check_answers_card_number" do + expect(question.check_answers_card_number).to eq(3) + end + end +end diff --git a/spec/models/form/lettings/questions/location_id_spec.rb b/spec/models/form/lettings/questions/location_id_spec.rb index 57495f4e7..ca3d402a9 100644 --- a/spec/models/form/lettings/questions/location_id_spec.rb +++ b/spec/models/form/lettings/questions/location_id_spec.rb @@ -39,7 +39,9 @@ RSpec.describe Form::Lettings::Questions::LocationId, type: :model do context "when getting available locations" do let(:scheme) { FactoryBot.create(:scheme) } - let!(:lettings_log) { FactoryBot.create(:lettings_log, owning_organisation: scheme.owning_organisation, scheme:, needstype: 2) } + let!(:lettings_log) do + FactoryBot.create(:lettings_log, owning_organisation: scheme.owning_organisation, scheme:, needstype: 2) + end context "when there are no locations" do it "the displayed_answer_options is an empty hash" do diff --git a/spec/models/form/lettings/questions/managing_organisation_spec.rb b/spec/models/form/lettings/questions/managing_organisation_spec.rb index 9d289d455..1a64ee973 100644 --- a/spec/models/form/lettings/questions/managing_organisation_spec.rb +++ b/spec/models/form/lettings/questions/managing_organisation_spec.rb @@ -61,8 +61,12 @@ RSpec.describe Form::Lettings::Questions::ManagingOrganisation, type: :model do let(:managing_org3) { create(:organisation, name: "Managing org 3") } let(:log) { create(:lettings_log, managing_organisation: managing_org1) } - let!(:org_rel1) { create(:organisation_relationship, parent_organisation: user.organisation, child_organisation: managing_org2) } - let!(:org_rel2) { create(:organisation_relationship, parent_organisation: user.organisation, child_organisation: managing_org3) } + let!(:org_rel1) do + create(:organisation_relationship, parent_organisation: user.organisation, child_organisation: managing_org2) + end + let!(:org_rel2) do + create(:organisation_relationship, parent_organisation: user.organisation, child_organisation: managing_org3) + end let(:options) do { @@ -87,9 +91,16 @@ RSpec.describe Form::Lettings::Questions::ManagingOrganisation, type: :model do let(:managing_org2) { create(:organisation, name: "Managing org 2") } let(:managing_org3) { create(:organisation, name: "Managing org 3") } - let(:log) { create(:lettings_log, owning_organisation: log_owning_org, managing_organisation: managing_org1, created_by: nil) } - let!(:org_rel1) { create(:organisation_relationship, parent_organisation: log_owning_org, child_organisation: managing_org2) } - let!(:org_rel2) { create(:organisation_relationship, parent_organisation: log_owning_org, child_organisation: managing_org3) } + let(:log) do + create(:lettings_log, owning_organisation: log_owning_org, managing_organisation: managing_org1, + created_by: nil) + end + let!(:org_rel1) do + create(:organisation_relationship, parent_organisation: log_owning_org, child_organisation: managing_org2) + end + let!(:org_rel2) do + create(:organisation_relationship, parent_organisation: log_owning_org, child_organisation: managing_org3) + end context "when org owns stock" do let(:options) do @@ -130,8 +141,12 @@ RSpec.describe Form::Lettings::Questions::ManagingOrganisation, type: :model do let(:owning_org) { create(:organisation, name: "Owning org", holds_own_stock: true) } let(:managing_org) { create(:organisation, name: "Managing org", holds_own_stock: false) } - let(:org_rel) { create(:organisation_relationship, parent_organisation: owning_org, child_organisation: managing_org) } - let(:log) { create(:lettings_log, owning_organisation: owning_org, managing_organisation: managing_org, created_by: nil) } + let(:org_rel) do + create(:organisation_relationship, parent_organisation: owning_org, child_organisation: managing_org) + end + let(:log) do + create(:lettings_log, owning_organisation: owning_org, managing_organisation: managing_org, created_by: nil) + end let(:options) do { @@ -184,4 +199,36 @@ RSpec.describe Form::Lettings::Questions::ManagingOrganisation, type: :model do end end end + + describe "#answer_label" do + context "when answered" do + let(:managing_organisation) { create(:organisation) } + let(:log) { create(:lettings_log, managing_organisation:) } + + it "returns org name" do + expect(question.answer_label(log)).to eq(managing_organisation.name) + end + end + + context "when unanswered" do + let(:log) { create(:lettings_log, managing_organisation: nil) } + + it "returns nil" do + expect(question.answer_label(log)).to be_nil + end + end + + context "when org does not exist" do + let(:managing_organisation) { create(:organisation) } + let(:log) { create(:lettings_log, managing_organisation:) } + + before do + allow(Organisation).to receive(:find_by).and_return(nil) + end + + it "returns nil" do + expect(question.answer_label(log)).to be_nil + end + end + end end diff --git a/spec/models/form/lettings/questions/person_gender_identity_spec.rb b/spec/models/form/lettings/questions/person_gender_identity_spec.rb new file mode 100644 index 000000000..703ba764a --- /dev/null +++ b/spec/models/form/lettings/questions/person_gender_identity_spec.rb @@ -0,0 +1,63 @@ +require "rails_helper" + +RSpec.describe Form::Lettings::Questions::PersonGenderIdentity, type: :model do + subject(:question) { described_class.new(nil, question_definition, page, person_index:) } + + let(:question_definition) { nil } + let(:page) { instance_double(Form::Page) } + let(:person_index) { 2 } + + it "has correct page" do + expect(question.page).to eq(page) + end + + it "has the correct type" do + expect(question.type).to eq("radio") + end + + it "is not marked as derived" do + expect(question.derived?).to be false + end + + it "has the correct hint" do + expect(question.hint_text).to eq("") + end + + context "with person 2" do + it "has the correct id" do + expect(question.id).to eq("sex2") + end + + it "has the correct check_answer_label" do + expect(question.check_answer_label).to eq("Person 2’s gender identity") + end + + it "has the correct header" do + expect(question.header).to eq("Which of these best describes person 2’s gender identity?") + end + + it "has the correct check_answers_card_number" do + expect(question.check_answers_card_number).to eq(2) + end + end + + context "with person 3" do + let(:person_index) { 3 } + + it "has the correct id" do + expect(question.id).to eq("sex3") + end + + it "has the correct check_answer_label" do + expect(question.check_answer_label).to eq("Person 3’s gender identity") + end + + it "has the correct header" do + expect(question.header).to eq("Which of these best describes person 3’s gender identity?") + end + + it "has the correct check_answers_card_number" do + expect(question.check_answers_card_number).to eq(3) + end + end +end diff --git a/spec/models/form/lettings/questions/person_relationship_spec.rb b/spec/models/form/lettings/questions/person_relationship_spec.rb new file mode 100644 index 000000000..04f071b9b --- /dev/null +++ b/spec/models/form/lettings/questions/person_relationship_spec.rb @@ -0,0 +1,79 @@ +require "rails_helper" + +RSpec.describe Form::Lettings::Questions::PersonRelationship, type: :model do + subject(:question) { described_class.new(nil, question_definition, page, person_index:) } + + let(:question_definition) { nil } + let(:page) { instance_double(Form::Page) } + let(:person_index) { 2 } + + it "has correct page" do + expect(question.page).to eq(page) + end + + it "has the correct type" do + expect(question.type).to eq("radio") + end + + it "is not marked as derived" do + expect(question.derived?).to be false + end + + it "has the correct answer_options" do + expect(question.answer_options).to eq("C" => { "hint" => "Must be eligible for child benefit, aged under 16 or under 20 if still in full-time education.", "value" => "Child" }, + "P" => { "value" => "Partner" }, + "R" => { "value" => "Person prefers not to say" }, + "X" => { "value" => "Other" }, + "divider" => { "value" => true }) + end + + it "has the correct hint" do + expect(question.hint_text).to eq("") + end + + it "has correct conditional for" do + expect(question.conditional_for).to be nil + end + + it "has the correct hidden_in_check_answers" do + expect(question.hidden_in_check_answers).to be nil + end + + context "with person 2" do + it "has the correct id" do + expect(question.id).to eq("relat2") + end + + it "has the correct header" do + expect(question.header).to eq("What is person 2’s relationship to the lead tenant?") + end + + it "has the correct check_answers_card_number" do + expect(question.check_answers_card_number).to eq(2) + end + + it "has the correct check_answer_label" do + expect(question.check_answer_label).to eq("Person 2’s relationship to the lead tenant") + end + end + + context "with person 3" do + let(:person_index) { 3 } + + it "has the correct id" do + expect(question.id).to eq("relat3") + end + + it "has the correct header" do + expect(question.header).to eq("What is person 3’s relationship to the lead tenant?") + end + + it "has the correct check_answers_card_number" do + expect(question.check_answers_card_number).to eq(3) + end + + it "has the correct check_answer_label" do + expect(question.check_answer_label).to eq("Person 3’s relationship to the lead tenant") + end + end +end diff --git a/spec/models/form/lettings/questions/person_working_situation_spec.rb b/spec/models/form/lettings/questions/person_working_situation_spec.rb new file mode 100644 index 000000000..f16f0c8b7 --- /dev/null +++ b/spec/models/form/lettings/questions/person_working_situation_spec.rb @@ -0,0 +1,92 @@ +require "rails_helper" + +RSpec.describe Form::Lettings::Questions::PersonWorkingSituation, type: :model do + subject(:question) { described_class.new(nil, question_definition, page, person_index:) } + + let(:question_definition) { nil } + let(:page) { instance_double(Form::Page) } + let(:person_index) { 2 } + + it "has correct page" do + expect(question.page).to eq(page) + end + + it "has the correct type" do + expect(question.type).to eq("radio") + end + + it "is not marked as derived" do + expect(question.derived?).to be false + end + + it "has the correct answer_options" do + expect(question.answer_options).to eq("0" => { "value" => "Other" }, + "1" => { "value" => "Full-time – 30 hours or more" }, + "10" => { "value" => "Tenant prefers not to say" }, + "2" => { "value" => "Part-time – Less than 30 hours" }, + "3" => { "value" => "In government training into work, such as New Deal" }, + "4" => { "value" => "Jobseeker" }, + "5" => { "value" => "Retired" }, + "6" => { "value" => "Not seeking work" }, + "7" => { "value" => "Full-time student" }, + "8" => { "value" => "Unable to work because of long term sick or disability" }, + "9" => { + "depends_on" => [ + { "age2_known" => 1 }, + { "age2" => { "operand" => 16, "operator" => "<" } }, + ], + "value" => "Child under 16", + }, + "divider" => { "value" => true }) + end + + it "has the correct hint" do + expect(question.hint_text).to eq("") + end + + it "has correct conditional for" do + expect(question.conditional_for).to be nil + end + + it "has the correct hidden_in_check_answers" do + expect(question.hidden_in_check_answers).to be nil + end + + context "with person 2" do + it "has the correct id" do + expect(question.id).to eq("ecstat2") + end + + it "has the correct header" do + expect(question.header).to eq("Which of these best describes person 2’s working situation?") + end + + it "has the correct check_answers_card_number" do + expect(question.check_answers_card_number).to eq(2) + end + + it "has the correct check_answer_label" do + expect(question.check_answer_label).to eq("Person 2’s working situation") + end + end + + context "with person 3" do + let(:person_index) { 3 } + + it "has the correct id" do + expect(question.id).to eq("ecstat3") + end + + it "has the correct header" do + expect(question.header).to eq("Which of these best describes person 3’s working situation?") + end + + it "has the correct check_answers_card_number" do + expect(question.check_answers_card_number).to eq(3) + end + + it "has the correct check_answer_label" do + expect(question.check_answer_label).to eq("Person 3’s working situation") + end + end +end diff --git a/spec/models/form/lettings/questions/scheme_id_spec.rb b/spec/models/form/lettings/questions/scheme_id_spec.rb index 7d5705935..7e88e3139 100644 --- a/spec/models/form/lettings/questions/scheme_id_spec.rb +++ b/spec/models/form/lettings/questions/scheme_id_spec.rb @@ -70,7 +70,9 @@ RSpec.describe Form::Lettings::Questions::SchemeId, type: :model do context "when the question is not answered" do it "returns 'select an option' as selected answer" do lettings_log.update!(scheme: nil) - answers = question.displayed_answer_options(lettings_log).map { |key, value| OpenStruct.new(id: key, name: value.respond_to?(:service_name) ? value.service_name : nil, resource: value) } + answers = question.displayed_answer_options(lettings_log).map do |key, value| + OpenStruct.new(id: key, name: value.respond_to?(:service_name) ? value.service_name : nil, resource: value) + end answers.each do |answer| if answer.resource == "Select an option" expect(question.answer_selected?(lettings_log, answer)).to eq(true) @@ -84,7 +86,9 @@ RSpec.describe Form::Lettings::Questions::SchemeId, type: :model do context "when the question is answered" do it "returns 'select an option' as selected answer" do lettings_log.update!(scheme:) - answers = question.displayed_answer_options(lettings_log).map { |key, value| OpenStruct.new(id: key, name: value.respond_to?(:service_name) ? value.service_name : nil, resource: value) } + answers = question.displayed_answer_options(lettings_log).map do |key, value| + OpenStruct.new(id: key, name: value.respond_to?(:service_name) ? value.service_name : nil, resource: value) + end answers.each do |answer| if answer.id == scheme.id expect(question.answer_selected?(lettings_log, answer)).to eq(true) diff --git a/spec/models/form/lettings/questions/stock_owner_spec.rb b/spec/models/form/lettings/questions/stock_owner_spec.rb index 41aebed89..3bd6d72e2 100644 --- a/spec/models/form/lettings/questions/stock_owner_spec.rb +++ b/spec/models/form/lettings/questions/stock_owner_spec.rb @@ -48,7 +48,9 @@ RSpec.describe Form::Lettings::Questions::StockOwner, type: :model do let(:owning_org_1) { create(:organisation, name: "Owning org 1") } let(:owning_org_2) { create(:organisation, name: "Owning org 2") } - let!(:org_rel) { create(:organisation_relationship, child_organisation: user.organisation, parent_organisation: owning_org_2) } + let!(:org_rel) do + create(:organisation_relationship, child_organisation: user.organisation, parent_organisation: owning_org_2) + end let(:log) { create(:lettings_log, owning_organisation: owning_org_1) } context "when user's org owns stock" do diff --git a/spec/models/form/lettings/sections/household_spec.rb b/spec/models/form/lettings/sections/household_spec.rb new file mode 100644 index 000000000..eedf92854 --- /dev/null +++ b/spec/models/form/lettings/sections/household_spec.rb @@ -0,0 +1,29 @@ +require "rails_helper" + +RSpec.describe Form::Lettings::Sections::Household, type: :model do + subject(:household) { described_class.new(section_id, section_definition, form) } + + let(:section_id) { nil } + let(:section_definition) { nil } + let(:form) { instance_double(Form) } + + it "has correct form" do + expect(household.form).to eq(form) + end + + it "has correct subsections" do + expect(household.subsections.map(&:id)).to eq(%w[household_characteristics household_needs household_situation]) + end + + it "has the correct id" do + expect(household.id).to eq("household") + end + + it "has the correct label" do + expect(household.label).to eq("About the household") + end + + it "has the correct description" do + expect(household.description).to be nil + end +end diff --git a/spec/models/form/lettings/sections/rent_and_charges_spec.rb b/spec/models/form/lettings/sections/rent_and_charges_spec.rb new file mode 100644 index 000000000..1a523ca90 --- /dev/null +++ b/spec/models/form/lettings/sections/rent_and_charges_spec.rb @@ -0,0 +1,29 @@ +require "rails_helper" + +RSpec.describe Form::Lettings::Sections::RentAndCharges, type: :model do + subject(:rent_and_charges) { described_class.new(section_id, section_definition, form) } + + let(:section_id) { nil } + let(:section_definition) { nil } + let(:form) { instance_double(Form) } + + it "has correct form" do + expect(rent_and_charges.form).to eq(form) + end + + it "has correct subsections" do + expect(rent_and_charges.subsections.map(&:id)).to eq(%w[income_and_benefits]) + end + + it "has the correct id" do + expect(rent_and_charges.id).to eq("rent_and_charges") + end + + it "has the correct label" do + expect(rent_and_charges.label).to eq("Finances") + end + + it "has the correct description" do + expect(rent_and_charges.description).to be nil + end +end diff --git a/spec/models/form/lettings/sections/tenancy_and_property_spec.rb b/spec/models/form/lettings/sections/tenancy_and_property_spec.rb new file mode 100644 index 000000000..bc7166be1 --- /dev/null +++ b/spec/models/form/lettings/sections/tenancy_and_property_spec.rb @@ -0,0 +1,29 @@ +require "rails_helper" + +RSpec.describe Form::Lettings::Sections::TenancyAndProperty, type: :model do + subject(:tenancy_and_property) { described_class.new(section_id, section_definition, form) } + + let(:section_id) { nil } + let(:section_definition) { nil } + let(:form) { instance_double(Form) } + + it "has correct form" do + expect(tenancy_and_property.form).to eq(form) + end + + it "has correct subsections" do + expect(tenancy_and_property.subsections.map(&:id)).to eq(%w[property_information tenancy_information]) + end + + it "has the correct id" do + expect(tenancy_and_property.id).to eq("tenancy_and_property") + end + + it "has the correct label" do + expect(tenancy_and_property.label).to eq("Property and tenancy information") + end + + it "has the correct description" do + expect(tenancy_and_property.description).to be nil + end +end diff --git a/spec/models/form/lettings/subsections/household_characteristics_spec.rb b/spec/models/form/lettings/subsections/household_characteristics_spec.rb new file mode 100644 index 000000000..96d722a2b --- /dev/null +++ b/spec/models/form/lettings/subsections/household_characteristics_spec.rb @@ -0,0 +1,133 @@ +require "rails_helper" + +RSpec.describe Form::Lettings::Subsections::HouseholdCharacteristics, type: :model do + subject(:household_characteristics) { described_class.new(subsection_id, subsection_definition, section) } + + let(:subsection_id) { nil } + let(:subsection_definition) { nil } + let(:section) { instance_double(Form::Lettings::Sections::Household) } + + it "has correct section" do + expect(household_characteristics.section).to eq(section) + end + + it "has correct pages" do + expect(household_characteristics.pages.map(&:id)).to eq( + %w[ + declaration + household_members + no_females_pregnant_household_lead_hhmemb_value_check + females_in_soft_age_range_in_pregnant_household_lead_hhmemb_value_check + lead_tenant_age + no_females_pregnant_household_lead_age_value_check + females_in_soft_age_range_in_pregnant_household_lead_age_value_check + lead_tenant_gender_identity + no_females_pregnant_household_lead_value_check + females_in_soft_age_range_in_pregnant_household_lead_value_check + lead_tenant_ethnic_group + lead_tenant_ethnic_background_arab + lead_tenant_ethnic_background_asian + lead_tenant_ethnic_background_black + lead_tenant_ethnic_background_mixed + lead_tenant_ethnic_background_white + lead_tenant_nationality + lead_tenant_working_situation + lead_tenant_under_retirement_value_check + lead_tenant_over_retirement_value_check + person_2_known + person_2_relationship_to_lead + person_2_age + no_females_pregnant_household_person_2_age_value_check + females_in_soft_age_range_in_pregnant_household_person_2_age_value_check + person_2_gender_identity + no_females_pregnant_household_person_2_value_check + females_in_soft_age_range_in_pregnant_household_person_2_value_check + person_2_working_situation + person_2_under_retirement_value_check + person_2_over_retirement_value_check + person_3_known + person_3_relationship_to_lead + person_3_age + no_females_pregnant_household_person_3_age_value_check + females_in_soft_age_range_in_pregnant_household_person_3_age_value_check + person_3_gender_identity + no_females_pregnant_household_person_3_value_check + females_in_soft_age_range_in_pregnant_household_person_3_value_check + person_3_working_situation + person_3_under_retirement_value_check + person_3_over_retirement_value_check + person_4_known + person_4_relationship_to_lead + person_4_age + no_females_pregnant_household_person_4_age_value_check + females_in_soft_age_range_in_pregnant_household_person_4_age_value_check + person_4_gender_identity + no_females_pregnant_household_person_4_value_check + females_in_soft_age_range_in_pregnant_household_person_4_value_check + person_4_working_situation + person_4_under_retirement_value_check + person_4_over_retirement_value_check + person_5_known + person_5_relationship_to_lead + person_5_age + no_females_pregnant_household_person_5_age_value_check + females_in_soft_age_range_in_pregnant_household_person_5_age_value_check + person_5_gender_identity + no_females_pregnant_household_person_5_value_check + females_in_soft_age_range_in_pregnant_household_person_5_value_check + person_5_working_situation + person_5_under_retirement_value_check + person_5_over_retirement_value_check + person_6_known + person_6_relationship_to_lead + person_6_age + no_females_pregnant_household_person_6_age_value_check + females_in_soft_age_range_in_pregnant_household_person_6_age_value_check + person_6_gender_identity + no_females_pregnant_household_person_6_value_check + females_in_soft_age_range_in_pregnant_household_person_6_value_check + person_6_working_situation + person_6_under_retirement_value_check + person_6_over_retirement_value_check + person_7_known + person_7_relationship_to_lead + person_7_age + no_females_pregnant_household_person_7_age_value_check + females_in_soft_age_range_in_pregnant_household_person_7_age_value_check + person_7_gender_identity + no_females_pregnant_household_person_7_value_check + females_in_soft_age_range_in_pregnant_household_person_7_value_check + person_7_working_situation + person_7_under_retirement_value_check + person_7_over_retirement_value_check + person_8_known + person_8_relationship_to_lead + person_8_age + no_females_pregnant_household_person_8_age_value_check + females_in_soft_age_range_in_pregnant_household_person_8_age_value_check + person_8_gender_identity + no_females_pregnant_household_person_8_value_check + females_in_soft_age_range_in_pregnant_household_person_8_value_check + person_8_working_situation + person_8_under_retirement_value_check + person_8_over_retirement_value_check + ], + ) + end + + it "has the correct id" do + expect(household_characteristics.id).to eq("household_characteristics") + end + + it "has the correct label" do + expect(household_characteristics.label).to eq("Household characteristics") + end + + it "has the correct depends_on" do + expect(household_characteristics.depends_on).to eq([ + { + "non_location_setup_questions_completed?" => true, + }, + ]) + end +end diff --git a/spec/models/form/lettings/subsections/household_needs_spec.rb b/spec/models/form/lettings/subsections/household_needs_spec.rb new file mode 100644 index 000000000..6e4dd25f1 --- /dev/null +++ b/spec/models/form/lettings/subsections/household_needs_spec.rb @@ -0,0 +1,46 @@ +require "rails_helper" + +RSpec.describe Form::Lettings::Subsections::HouseholdNeeds, type: :model do + subject(:household_needs) { described_class.new(subsection_id, subsection_definition, section) } + + let(:subsection_id) { nil } + let(:subsection_definition) { nil } + let(:section) { instance_double(Form::Lettings::Sections::Household) } + + it "has correct section" do + expect(household_needs.section).to eq(section) + end + + it "has correct pages" do + expect(household_needs.pages.map(&:id)).to eq( + %w[ + armed_forces + armed_forces_serving + armed_forces_injured + pregnant + no_females_pregnant_household_value_check + females_in_soft_age_range_in_pregnant_household_value_check + access_needs_exist + type_of_access_needs + health_conditions + health_condition_effects + ], + ) + end + + it "has the correct id" do + expect(household_needs.id).to eq("household_needs") + end + + it "has the correct label" do + expect(household_needs.label).to eq("Household needs") + end + + it "has the correct depends_on" do + expect(household_needs.depends_on).to eq([ + { + "non_location_setup_questions_completed?" => true, + }, + ]) + end +end diff --git a/spec/models/form/lettings/subsections/household_situation_spec.rb b/spec/models/form/lettings/subsections/household_situation_spec.rb new file mode 100644 index 000000000..1b43a2280 --- /dev/null +++ b/spec/models/form/lettings/subsections/household_situation_spec.rb @@ -0,0 +1,52 @@ +require "rails_helper" + +RSpec.describe Form::Lettings::Subsections::HouseholdSituation, type: :model do + subject(:household_situation) { described_class.new(subsection_id, subsection_definition, section) } + + let(:subsection_id) { nil } + let(:subsection_definition) { nil } + let(:section) { instance_double(Form::Lettings::Sections::Household) } + + it "has correct section" do + expect(household_situation.section).to eq(section) + end + + it "has correct pages" do + expect(household_situation.pages.map(&:id)).to eq( + %w[ + time_lived_in_local_authority + time_on_waiting_list + reason_for_leaving_last_settled_home + reason_for_leaving_last_settled_home_renewal + previous_housing_situation + previous_housing_situation_renewal + homelessness + previous_postcode + previous_local_authority + reasonable_preference + reasonable_preference_reason + allocation_system + referral + referral_prp + referral_supported_housing + referral_supported_housing_prp + ], + ) + end + + it "has the correct id" do + expect(household_situation.id).to eq("household_situation") + end + + it "has the correct label" do + expect(household_situation.label).to eq("Household situation") + end + + it "has the correct depends_on" do + expect(household_situation.depends_on).to eq([ + { + "non_location_setup_questions_completed?" => true, + }, + ]) + end +end diff --git a/spec/models/form/lettings/subsections/income_and_benefits_spec.rb b/spec/models/form/lettings/subsections/income_and_benefits_spec.rb new file mode 100644 index 000000000..2c4310d5b --- /dev/null +++ b/spec/models/form/lettings/subsections/income_and_benefits_spec.rb @@ -0,0 +1,55 @@ +require "rails_helper" + +RSpec.describe Form::Lettings::Subsections::IncomeAndBenefits, type: :model do + subject(:income_and_benefits) { described_class.new(subsection_id, subsection_definition, section) } + + let(:subsection_id) { nil } + let(:subsection_definition) { nil } + let(:section) { instance_double(Form::Lettings::Sections::RentAndCharges) } + + it "has correct section" do + expect(income_and_benefits.section).to eq(section) + end + + it "has correct pages" do + expect(income_and_benefits.pages.map(&:id)).to eq( + %w[ + income_known + income_amount + net_income_value_check + housing_benefit + benefits_proportion + rent_or_other_charges + rent_period + care_home_weekly + care_home_bi_weekly + care_home_4_weekly + care_home_monthly + rent_weekly + rent_bi_weekly + rent_4_weekly + rent_monthly + min_rent_value_check + max_rent_value_check + outstanding + outstanding_amount + ], + ) + end + + it "has the correct id" do + expect(income_and_benefits.id).to eq("income_and_benefits") + end + + it "has the correct label" do + expect(income_and_benefits.label).to eq("Income, benefits and outgoings") + end + + it "has the correct depends_on" do + expect(income_and_benefits.depends_on).to eq([ + { + "non_location_setup_questions_completed?" => true, + }, + ]) + end +end diff --git a/spec/models/form/lettings/subsections/property_information_spec.rb b/spec/models/form/lettings/subsections/property_information_spec.rb new file mode 100644 index 000000000..227773487 --- /dev/null +++ b/spec/models/form/lettings/subsections/property_information_spec.rb @@ -0,0 +1,53 @@ +require "rails_helper" + +RSpec.describe Form::Lettings::Subsections::PropertyInformation, type: :model do + subject(:property_information) { described_class.new(subsection_id, subsection_definition, section) } + + let(:subsection_id) { nil } + let(:subsection_definition) { nil } + let(:section) { instance_double(Form::Lettings::Sections::TenancyAndProperty) } + + it "has correct section" do + expect(property_information.section).to eq(section) + end + + it "has correct pages" do + expect(property_information.pages.map(&:id)).to eq( + %w[ + property_postcode + property_local_authority + first_time_property_let_as_social_housing + property_let_type + property_vacancy_reason_not_first_let + property_vacancy_reason_first_let + property_number_of_times_relet_not_social_let + property_number_of_times_relet_social_let + property_unit_type + property_building_type + property_wheelchair_accessible + property_number_of_bedrooms + void_or_renewal_date + void_date_value_check + new_build_handover_date + property_major_repairs + property_major_repairs_value_check + ], + ) + end + + it "has the correct id" do + expect(property_information.id).to eq("property_information") + end + + it "has the correct label" do + expect(property_information.label).to eq("Property information") + end + + it "has the correct depends_on" do + expect(property_information.depends_on).to eq([ + { + "non_location_setup_questions_completed?" => true, + }, + ]) + end +end diff --git a/spec/models/form/lettings/subsections/tenancy_information_spec.rb b/spec/models/form/lettings/subsections/tenancy_information_spec.rb new file mode 100644 index 000000000..7dd3e3a10 --- /dev/null +++ b/spec/models/form/lettings/subsections/tenancy_information_spec.rb @@ -0,0 +1,35 @@ +require "rails_helper" + +RSpec.describe Form::Lettings::Subsections::TenancyInformation, type: :model do + subject(:tenancy_information) { described_class.new(subsection_id, subsection_definition, section) } + + let(:subsection_id) { nil } + let(:subsection_definition) { nil } + let(:section) { instance_double(Form::Lettings::Sections::TenancyAndProperty) } + + it "has correct section" do + expect(tenancy_information.section).to eq(section) + end + + it "has correct pages" do + expect(tenancy_information.pages.map(&:id)).to eq( + %w[joint starter_tenancy tenancy_type starter_tenancy_type tenancy_length shelteredaccom], + ) + end + + it "has the correct id" do + expect(tenancy_information.id).to eq("tenancy_information") + end + + it "has the correct label" do + expect(tenancy_information.label).to eq("Tenancy information") + end + + it "has the correct depends_on" do + expect(tenancy_information.depends_on).to eq([ + { + "non_location_setup_questions_completed?" => true, + }, + ]) + end +end diff --git a/spec/models/form/sales/pages/mortgage_value_check_spec.rb b/spec/models/form/sales/pages/mortgage_value_check_spec.rb index d54e992f1..38e7239c3 100644 --- a/spec/models/form/sales/pages/mortgage_value_check_spec.rb +++ b/spec/models/form/sales/pages/mortgage_value_check_spec.rb @@ -1,10 +1,11 @@ require "rails_helper" RSpec.describe Form::Sales::Pages::MortgageValueCheck, type: :model do - subject(:page) { described_class.new(page_id, page_definition, subsection) } + subject(:page) { described_class.new(page_id, page_definition, subsection, index) } let(:page_id) { "buyer_1_income_mortgage_value_check" } let(:page_definition) { nil } + let(:index) { 1 } let(:subsection) { instance_double(Form::Subsection) } it "has correct subsection" do @@ -34,4 +35,17 @@ RSpec.describe Form::Sales::Pages::MortgageValueCheck, type: :model do }, ]) end + + context "when checking buyer 2" do + let(:index) { 2 } + + it "has correct depends_on" do + expect(page.depends_on).to eq([ + { + "mortgage_over_soft_max?" => true, + "jointpur" => 1, + }, + ]) + end + end end diff --git a/spec/models/form/sales/pages/purchase_price_outright_ownership_spec.rb b/spec/models/form/sales/pages/purchase_price_outright_ownership_spec.rb new file mode 100644 index 000000000..88c357034 --- /dev/null +++ b/spec/models/form/sales/pages/purchase_price_outright_ownership_spec.rb @@ -0,0 +1,35 @@ +require "rails_helper" + +RSpec.describe Form::Sales::Pages::PurchasePriceOutrightOwnership, type: :model do + subject(:page) { described_class.new(page_id, page_definition, subsection) } + + let(:page_id) { "purchase_price" } + let(:page_definition) { nil } + let(:subsection) { instance_double(Form::Subsection) } + + it "has correct subsection" do + expect(page.subsection).to eq(subsection) + end + + it "has correct questions" do + expect(page.questions.map(&:id)).to eq(%w[value]) + end + + it "has the correct id" do + expect(page.id).to eq("purchase_price") + end + + it "has the correct header" do + expect(page.header).to be_nil + end + + it "has the correct description" do + expect(page.description).to be_nil + end + + it "has correct depends_on" do + expect(page.depends_on).to eq([ + { "outright_sale_or_discounted_with_full_ownership?" => true }, + ]) + end +end diff --git a/spec/models/form/sales/pages/purchase_price_spec.rb b/spec/models/form/sales/pages/purchase_price_spec.rb index 4d0be701f..6ec2b7ac0 100644 --- a/spec/models/form/sales/pages/purchase_price_spec.rb +++ b/spec/models/form/sales/pages/purchase_price_spec.rb @@ -29,8 +29,7 @@ RSpec.describe Form::Sales::Pages::PurchasePrice, type: :model do it "has correct depends_on" do expect(page.depends_on).to eq([ - { "ownershipsch" => 3 }, - { "rent_to_buy_full_ownership?" => true }, + { "ownershipsch" => 2, "rent_to_buy_full_ownership?" => false }, ]) end end diff --git a/spec/models/form/sales/pages/shared_ownership_deposit_value_check_spec.rb b/spec/models/form/sales/pages/shared_ownership_deposit_value_check_spec.rb index afe25f4d3..893a5cb5b 100644 --- a/spec/models/form/sales/pages/shared_ownership_deposit_value_check_spec.rb +++ b/spec/models/form/sales/pages/shared_ownership_deposit_value_check_spec.rb @@ -33,7 +33,7 @@ RSpec.describe Form::Sales::Pages::SharedOwnershipDepositValueCheck, type: :mode it "has the correct title_text" do expect(page.title_text).to eq({ - "translation" => "soft_validations.shared_owhership_deposit.title_text", + "translation" => "soft_validations.shared_ownership_deposit.title_text", "arguments" => [ { "key" => "expected_shared_ownership_deposit_value", diff --git a/spec/models/form/sales/questions/purchase_price_spec.rb b/spec/models/form/sales/questions/purchase_price_spec.rb index 8894a592f..ce0aaae9c 100644 --- a/spec/models/form/sales/questions/purchase_price_spec.rb +++ b/spec/models/form/sales/questions/purchase_price_spec.rb @@ -32,7 +32,9 @@ RSpec.describe Form::Sales::Questions::PurchasePrice, type: :model do end it "has the correct hint" do - expect(question.hint_text).to be_nil + expect(question.hint_text).to eq( + "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", + ) end it "has correct width" do diff --git a/spec/models/form/sales/subsections/discounted_ownership_scheme_spec.rb b/spec/models/form/sales/subsections/discounted_ownership_scheme_spec.rb index f2891e801..525ad06b4 100644 --- a/spec/models/form/sales/subsections/discounted_ownership_scheme_spec.rb +++ b/spec/models/form/sales/subsections/discounted_ownership_scheme_spec.rb @@ -12,6 +12,7 @@ RSpec.describe Form::Sales::Subsections::DiscountedOwnershipScheme, type: :model end it "has correct pages" do + puts discounted_ownership_scheme.pages.map(&:id) expect(discounted_ownership_scheme.pages.map(&:id)).to eq( %w[ living_before_purchase_discounted_ownership @@ -20,9 +21,12 @@ RSpec.describe Form::Sales::Subsections::DiscountedOwnershipScheme, type: :model about_price_not_rtb grant_value_check purchase_price_discounted_ownership + purchase_price_outright_ownership discounted_ownership_deposit_and_mortgage_value_check_after_value_and_discount mortgage_used_discounted_ownership + discounted_ownership_mortgage_used_mortgage_value_check mortgage_amount_discounted_ownership + discounted_ownership_mortgage_amount_mortgage_value_check extra_borrowing_mortgage_value_check discounted_ownership_deposit_and_mortgage_value_check_after_mortgage mortgage_lender_discounted_ownership diff --git a/spec/models/form/sales/subsections/outright_sale_spec.rb b/spec/models/form/sales/subsections/outright_sale_spec.rb index 239fbe38e..47c062478 100644 --- a/spec/models/form/sales/subsections/outright_sale_spec.rb +++ b/spec/models/form/sales/subsections/outright_sale_spec.rb @@ -16,7 +16,9 @@ RSpec.describe Form::Sales::Subsections::OutrightSale, type: :model do %w[ purchase_price_outright_sale mortgage_used_outright_sale + outright_sale_mortgage_used_mortgage_value_check mortgage_amount_outright_sale + outright_sale_mortgage_amount_mortgage_value_check mortgage_lender_outright_sale mortgage_lender_other_outright_sale mortgage_length_outright_sale diff --git a/spec/models/form/sales/subsections/shared_ownership_scheme_spec.rb b/spec/models/form/sales/subsections/shared_ownership_scheme_spec.rb index 6da1dfbcd..44c41c341 100644 --- a/spec/models/form/sales/subsections/shared_ownership_scheme_spec.rb +++ b/spec/models/form/sales/subsections/shared_ownership_scheme_spec.rb @@ -30,8 +30,10 @@ RSpec.describe Form::Sales::Subsections::SharedOwnershipScheme, type: :model do about_price_shared_ownership shared_ownership_equity_value_check mortgage_used_shared_ownership + mortgage_used_mortgage_value_check mortgage_amount_shared_ownership shared_ownership_mortgage_amount_value_check + mortgage_amount_mortgage_value_check mortgage_lender_shared_ownership mortgage_lender_other_shared_ownership mortgage_length_shared_ownership diff --git a/spec/models/form_handler_spec.rb b/spec/models/form_handler_spec.rb index 432a18740..9c02a5318 100644 --- a/spec/models/form_handler_spec.rb +++ b/spec/models/form_handler_spec.rb @@ -52,14 +52,14 @@ RSpec.describe FormHandler do it "is able to load a current sales form" do form = form_handler.get_form("current_sales") expect(form).to be_a(Form) - expect(form.pages.count).to eq(204) + expect(form.pages.count).to eq(211) expect(form.name).to eq("2022_2023_sales") end it "is able to load a previous sales form" do form = form_handler.get_form("previous_sales") expect(form).to be_a(Form) - expect(form.pages.count).to eq(204) + expect(form.pages.count).to eq(211) expect(form.name).to eq("2021_2022_sales") end end diff --git a/spec/models/validations/household_validations_spec.rb b/spec/models/validations/household_validations_spec.rb index 0d1be05ae..daa3feef1 100644 --- a/spec/models/validations/household_validations_spec.rb +++ b/spec/models/validations/household_validations_spec.rb @@ -463,14 +463,14 @@ RSpec.describe Validations::HouseholdValidations do record.hhmemb = -1 household_validator.validate_numeric_min_max(record) expect(record.errors["hhmemb"]) - .to include(match I18n.t("validations.numeric.valid", field: "Number of Household Members", min: 0, max: 8)) + .to include(match I18n.t("validations.numeric.within_range", field: "Number of Household Members", min: 0, max: 8)) end it "validates that the number of household members cannot be more than 8" do record.hhmemb = 9 household_validator.validate_numeric_min_max(record) expect(record.errors["hhmemb"]) - .to include(match I18n.t("validations.numeric.valid", field: "Number of Household Members", min: 0, max: 8)) + .to include(match I18n.t("validations.numeric.within_range", field: "Number of Household Members", min: 0, max: 8)) end it "expects that the number of other household members is between the min and max" do diff --git a/spec/models/validations/sales/household_validations_spec.rb b/spec/models/validations/sales/household_validations_spec.rb index 26d369a35..10367390e 100644 --- a/spec/models/validations/sales/household_validations_spec.rb +++ b/spec/models/validations/sales/household_validations_spec.rb @@ -5,48 +5,6 @@ RSpec.describe Validations::Sales::HouseholdValidations do let(:validator_class) { Class.new { include Validations::Sales::HouseholdValidations } } - describe "#validate_number_of_other_people_living_in_the_property" do - context "when within permitted bounds" do - let(:record) { build(:sales_log, hholdcount: 2) } - - it "does not add an error" do - household_validator.validate_number_of_other_people_living_in_the_property(record) - - expect(record.errors[:hholdcount]).not_to be_present - end - end - - context "when blank" do - let(:record) { build(:sales_log, hholdcount: nil) } - - it "does not add an error" do - household_validator.validate_number_of_other_people_living_in_the_property(record) - - expect(record.errors[:hholdcount]).not_to be_present - end - end - - context "when below lower bound" do - let(:record) { build(:sales_log, hholdcount: -1) } - - it "adds an error" do - household_validator.validate_number_of_other_people_living_in_the_property(record) - - expect(record.errors[:hholdcount]).to be_present - end - end - - context "when higher than upper bound" do - let(:record) { build(:sales_log, hholdcount: 5) } - - it "adds an error" do - household_validator.validate_number_of_other_people_living_in_the_property(record) - - expect(record.errors[:hholdcount]).to be_present - end - end - end - describe "household member validations" do let(:record) { build(:sales_log) } diff --git a/spec/models/validations/sales/soft_validations_spec.rb b/spec/models/validations/sales/soft_validations_spec.rb index 40e658c73..8124931dd 100644 --- a/spec/models/validations/sales/soft_validations_spec.rb +++ b/spec/models/validations/sales/soft_validations_spec.rb @@ -102,14 +102,26 @@ RSpec.describe Validations::Sales::SoftValidations do .not_to be_mortgage_over_soft_max end - it "returns false if no inc2mort is given" do - record.inc1mort = 2 + it "returns false if no inc2mort is given and it's a joint purchase" do + record.jointpur = 1 + record.inc1mort = 1 + record.income1 = 10 record.inc2mort = nil record.mortgage = 20_000 expect(record) .not_to be_mortgage_over_soft_max end + it "returns true if no inc2mort is given and it's not a joint purchase" do + record.jointpur = 2 + record.inc1mort = 1 + record.income1 = 10 + record.inc2mort = nil + record.mortgage = 20_000 + expect(record) + .to be_mortgage_over_soft_max + end + it "returns false if no income1 is given and inc1mort is yes" do record.inc1mort = 1 record.inc2mort = 2 diff --git a/spec/models/validations/shared_validations_spec.rb b/spec/models/validations/shared_validations_spec.rb index c1d8cb3af..151050d8b 100644 --- a/spec/models/validations/shared_validations_spec.rb +++ b/spec/models/validations/shared_validations_spec.rb @@ -18,42 +18,42 @@ RSpec.describe Validations::SharedValidations do record.age1 = "random" shared_validator.validate_numeric_min_max(record) expect(record.errors["age1"]) - .to include(match I18n.t("validations.numeric.valid", field: "Lead tenant’s age", min: 16, max: 120)) + .to include(match I18n.t("validations.numeric.within_range", field: "Lead tenant’s age", min: 16, max: 120)) end it "validates that other household member ages are a number" do record.age2 = "random" shared_validator.validate_numeric_min_max(record) expect(record.errors["age2"]) - .to include(match I18n.t("validations.numeric.valid", field: "Person 2’s age", min: 1, max: 120)) + .to include(match I18n.t("validations.numeric.within_range", field: "Person 2’s age", min: 1, max: 120)) end it "validates that person 1's age is greater than 16" do record.age1 = 15 shared_validator.validate_numeric_min_max(record) expect(record.errors["age1"]) - .to include(match I18n.t("validations.numeric.valid", field: "Lead tenant’s age", min: 16, max: 120)) + .to include(match I18n.t("validations.numeric.within_range", field: "Lead tenant’s age", min: 16, max: 120)) end it "validates that other household member ages are greater than 1" do record.age2 = 0 shared_validator.validate_numeric_min_max(record) expect(record.errors["age2"]) - .to include(match I18n.t("validations.numeric.valid", field: "Person 2’s age", min: 1, max: 120)) + .to include(match I18n.t("validations.numeric.within_range", field: "Person 2’s age", min: 1, max: 120)) end it "validates that person 1's age is less than 121" do record.age1 = 121 shared_validator.validate_numeric_min_max(record) expect(record.errors["age1"]) - .to include(match I18n.t("validations.numeric.valid", field: "Lead tenant’s age", min: 16, max: 120)) + .to include(match I18n.t("validations.numeric.within_range", field: "Lead tenant’s age", min: 16, max: 120)) end it "validates that other household member ages are greater than 121" do record.age2 = 123 shared_validator.validate_numeric_min_max(record) expect(record.errors["age2"]) - .to include(match I18n.t("validations.numeric.valid", field: "Person 2’s age", min: 1, max: 120)) + .to include(match I18n.t("validations.numeric.within_range", field: "Person 2’s age", min: 1, max: 120)) end it "validates that person 1's age is between 16 and 120" do @@ -69,21 +69,27 @@ RSpec.describe Validations::SharedValidations do end end + it "adds the correct validation text when a question has a min but not a max" do + sales_record.savings = -10 + shared_validator.validate_numeric_min_max(sales_record) + expect(sales_record.errors["savings"]).to include(match I18n.t("validations.numeric.above_min", field: "Buyer’s total savings (to nearest £10) before any deposit paid", min: "£0")) + end + context "when validating percent" do it "validates that suffixes are added in the error message" do sales_record.stairbought = 150 shared_validator.validate_numeric_min_max(sales_record) expect(sales_record.errors["stairbought"]) - .to include(match I18n.t("validations.numeric.valid", field: "Percentage bought in this staircasing transaction", min: "0%", max: "100%")) + .to include(match I18n.t("validations.numeric.within_range", field: "Percentage bought in this staircasing transaction", min: "0%", max: "100%")) end end context "when validating price" do it "validates that £ prefix and , is added in the error message" do - sales_record.income1 = "random" + sales_record.income1 = -5 shared_validator.validate_numeric_min_max(sales_record) expect(sales_record.errors["income1"]) - .to include(match I18n.t("validations.numeric.valid", field: "Buyer 1’s gross annual income", min: "£0", max: "£999,999")) + .to include(match I18n.t("validations.numeric.within_range", field: "Buyer 1’s gross annual income", min: "£0", max: "£999,999")) end end end diff --git a/spec/requests/bulk_upload_controller_spec.rb b/spec/requests/bulk_upload_controller_spec.rb index fc3afd21c..7aa0d16e0 100644 --- a/spec/requests/bulk_upload_controller_spec.rb +++ b/spec/requests/bulk_upload_controller_spec.rb @@ -13,6 +13,14 @@ RSpec.describe BulkUploadController, type: :request do end context "when a user is not signed in" do + describe "GET #start" do + before { get start_bulk_upload_lettings_logs_path, headers:, params: {} } + + it "does not let you see the bulk upload page" do + expect(response).to redirect_to("/account/sign-in") + end + end + describe "GET #show" do before { get url, headers:, params: {} } @@ -50,6 +58,40 @@ RSpec.describe BulkUploadController, type: :request do end end + describe "GET #start" do + before do + Timecop.freeze(time) + get start_bulk_upload_lettings_logs_path + end + + after do + Timecop.unfreeze + end + + context "when not crossover period" do + let(:time) { Time.utc(2022, 2, 8) } + + it "redirects to bulk upload path" do + expect(request).to redirect_to( + bulk_upload_lettings_log_path( + id: "prepare-your-file", + form: { year: 2021 }, + ), + ) + end + end + + context "when crossover period" do + let(:time) { Time.utc(2022, 6, 8) } + + it "redirects to bulk upload path" do + expect(request).to redirect_to( + bulk_upload_lettings_log_path(id: "year"), + ) + end + end + end + describe "POST #bulk upload" do context "with a valid file based on the upload template" do let(:request) { post url, params: { bulk_upload: { lettings_log_bulk_upload: valid_file } } } diff --git a/spec/requests/lettings_logs_controller_spec.rb b/spec/requests/lettings_logs_controller_spec.rb index 1bb0afbf9..57311b70d 100644 --- a/spec/requests/lettings_logs_controller_spec.rb +++ b/spec/requests/lettings_logs_controller_spec.rb @@ -82,7 +82,7 @@ RSpec.describe LettingsLogsController, type: :request do it "validates lettings log parameters" do json_response = JSON.parse(response.body) expect(response).to have_http_status(:unprocessable_entity) - expect(json_response["errors"]).to match_array([["offered", [I18n.t("validations.property.offered.relet_number")]], ["age1", [I18n.t("validations.numeric.valid", field: "Lead tenant’s age", min: 16, max: 120)]]]) + expect(json_response["errors"]).to match_array([["offered", [I18n.t("validations.property.offered.relet_number")]], ["age1", [I18n.t("validations.numeric.within_range", field: "Lead tenant’s age", min: 16, max: 120)]]]) end end diff --git a/spec/services/bulk_upload/processor_spec.rb b/spec/services/bulk_upload/processor_spec.rb index aaff12678..7c2ebaf06 100644 --- a/spec/services/bulk_upload/processor_spec.rb +++ b/spec/services/bulk_upload/processor_spec.rb @@ -6,6 +6,91 @@ RSpec.describe BulkUpload::Processor do let(:bulk_upload) { create(:bulk_upload, :lettings) } describe "#call" do + context "when the bulk upload itself is not considered valid" do + let(:mock_downloader) do + instance_double( + BulkUpload::Downloader, + call: nil, + path: file_fixture("2022_23_lettings_bulk_upload.csv"), + delete_local_file!: nil, + ) + end + + let(:mock_validator) do + instance_double( + BulkUpload::Lettings::Validator, + invalid?: true, + call: nil, + ) + end + + before do + allow(BulkUpload::Downloader).to receive(:new).with(bulk_upload:).and_return(mock_downloader) + allow(BulkUpload::Lettings::Validator).to receive(:new).and_return(mock_validator) + end + + it "sends failure email" do + mail_double = instance_double("ActionMailer::MessageDelivery", deliver_later: nil) + + allow(BulkUploadMailer).to receive(:send_bulk_upload_failed_service_error_mail).and_return(mail_double) + + processor.call + + expect(BulkUploadMailer).to have_received(:send_bulk_upload_failed_service_error_mail) + expect(mail_double).to have_received(:deliver_later) + end + + it "does not attempt to validate the contents of the file" do + processor.call + + expect(mock_validator).not_to have_received(:call) + end + end + + context "when the bulk upload processing throws an error" do + let(:mock_downloader) do + instance_double( + BulkUpload::Downloader, + call: nil, + path: file_fixture("2022_23_lettings_bulk_upload.csv"), + delete_local_file!: nil, + ) + end + + let(:mock_validator) do + instance_double( + BulkUpload::Lettings::Validator, + invalid?: false, + ) + end + + before do + allow(BulkUpload::Downloader).to receive(:new).with(bulk_upload:).and_return(mock_downloader) + allow(BulkUpload::Lettings::Validator).to receive(:new).and_return(mock_validator) + + allow(mock_validator).to receive(:call).and_raise(StandardError) + end + + it "sends failure email" do + mail_double = instance_double("ActionMailer::MessageDelivery", deliver_later: nil) + + allow(BulkUploadMailer).to receive(:send_bulk_upload_failed_service_error_mail).and_return(mail_double) + + processor.call + + expect(BulkUploadMailer).to have_received(:send_bulk_upload_failed_service_error_mail) + expect(mail_double).to have_received(:deliver_later) + end + + it "we log the failure" do + allow(Sentry).to receive(:capture_exception) + + processor.call + + expect(Sentry).to have_received(:capture_exception) + end + end + context "when processing a bulk upload with errors" do let(:mock_downloader) do instance_double( @@ -16,19 +101,27 @@ RSpec.describe BulkUpload::Processor do ) end - it "persist the validation errors" do + before do allow(BulkUpload::Downloader).to receive(:new).with(bulk_upload:).and_return(mock_downloader) + end + it "persist the validation errors" do expect { processor.call }.to change(BulkUploadError, :count) end it "deletes the local file afterwards" do - allow(BulkUpload::Downloader).to receive(:new).with(bulk_upload:).and_return(mock_downloader) - processor.call expect(mock_downloader).to have_received(:delete_local_file!) end + + it "does not send success email" do + allow(BulkUploadMailer).to receive(:send_bulk_upload_complete_mail).and_call_original + + processor.call + + expect(BulkUploadMailer).not_to have_received(:send_bulk_upload_complete_mail) + end end context "when processing a bulk with perfect data" do @@ -48,6 +141,7 @@ RSpec.describe BulkUpload::Processor do BulkUpload::Lettings::Validator, call: nil, create_logs?: true, + invalid?: false, ) end @@ -59,15 +153,30 @@ RSpec.describe BulkUpload::Processor do ) end - it "creates logs" do + before do allow(BulkUpload::Downloader).to receive(:new).with(bulk_upload:).and_return(mock_downloader) allow(BulkUpload::Lettings::Validator).to receive(:new).and_return(mock_validator) allow(BulkUpload::Lettings::LogCreator).to receive(:new).with(bulk_upload:, path:).and_return(mock_creator) + end + it "creates logs" do processor.call expect(mock_creator).to have_received(:call) end + + it "sends success email" do + mail_double = instance_double("ActionMailer::MessageDelivery", deliver_later: nil) + + allow(BulkUploadMailer).to receive(:send_bulk_upload_complete_mail).and_return(mail_double) + + create(:lettings_log, :completed, bulk_upload:) + + processor.call + + expect(BulkUploadMailer).to have_received(:send_bulk_upload_complete_mail) + expect(mail_double).to have_received(:deliver_later) + end end end end