diff --git a/app/components/bulk_upload_error_summary_table_component.html.erb b/app/components/bulk_upload_error_summary_table_component.html.erb new file mode 100644 index 000000000..f1749ee92 --- /dev/null +++ b/app/components/bulk_upload_error_summary_table_component.html.erb @@ -0,0 +1,25 @@ +<%= govuk_table do |table| %> + <% table.caption(size: "m", text: bulk_upload.filename) %> + + <% table.head do |head| %> + <% head.row do |row| %> + <% row.cell(text: "Column", header: true) %> + <% row.cell(text: "Number of rows", header: true) %> + <% row.cell(text: "Question", header: true) %> + <% row.cell(text: "Error", header: true) %> + <% row.cell(text: "Specification", header: true) %> + <% end %> + <% end %> + + <% table.body do |body| %> + <% sorted_errors.each do |error| %> + <% body.row do |row| %> + <% row.cell(text: error[0][0]) %> + <% row.cell(text: error[1]) %> + <% row.cell(text: BulkUpload::Lettings::Validator.question_for_field(error[0][1].to_sym)) %> + <% row.cell(text: error[0][2]) %> + <% row.cell(text: error[0][1]) %> + <% end %> + <% end %> + <% end %> +<% end %> diff --git a/app/components/bulk_upload_error_summary_table_component.rb b/app/components/bulk_upload_error_summary_table_component.rb new file mode 100644 index 000000000..ac236af4d --- /dev/null +++ b/app/components/bulk_upload_error_summary_table_component.rb @@ -0,0 +1,17 @@ +class BulkUploadErrorSummaryTableComponent < ViewComponent::Base + attr_reader :bulk_upload + + def initialize(bulk_upload:) + @bulk_upload = bulk_upload + + super + end + + def sorted_errors + @sorted_errors ||= bulk_upload + .bulk_upload_errors + .group(:col, :field, :error) + .count + .sort_by { |el| el[0][0].rjust(3, "0") } + end +end 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/bulk_upload_lettings_results_controller.rb b/app/controllers/bulk_upload_lettings_results_controller.rb index 1c5342cd8..6f92c0375 100644 --- a/app/controllers/bulk_upload_lettings_results_controller.rb +++ b/app/controllers/bulk_upload_lettings_results_controller.rb @@ -19,6 +19,10 @@ class BulkUploadLettingsResultsController < ApplicationController end end + def summary + @bulk_upload = current_user.bulk_uploads.lettings.find(params[:id]) + end + private def reset_logs_filters 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/mailers/bulk_upload_mailer.rb b/app/mailers/bulk_upload_mailer.rb new file mode 100644 index 000000000..b406a5c4b --- /dev/null +++ b/app/mailers/bulk_upload_mailer.rb @@ -0,0 +1,93 @@ +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:) + 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:, + filename: bulk_upload.filename, + upload_timestamp: bulk_upload.created_at, + success_description:, + logs_link: url, + }, + ) + end + + def send_bulk_upload_failed_csv_errors_mail(user, bulk_upload) + send_email( + user.email, + BULK_UPLOAD_FAILED_CSV_ERRORS_TEMPLATE_ID, + { + filename: "[#{bulk_upload} filename]", + upload_timestamp: "[#{bulk_upload} upload_timestamp]", + year_combo: "[#{bulk_upload} year_combo]", + lettings_or_sales: "[#{bulk_upload} lettings_or_sales]", + error_description: "[#{bulk_upload} error_description]", + summary_report_link: "[#{bulk_upload} summary_report_link]", + }, + ) + end + + def send_bulk_upload_failed_file_setup_error_mail(user, bulk_upload) + send_email( + user.email, + BULK_UPLOAD_FAILED_FILE_SETUP_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]", + errors_list: "[#{bulk_upload} errors_list]", + bulk_upload_link: "[#{bulk_upload} bulk_upload_link]", + }, + ) + end + + def send_bulk_upload_failed_service_error_mail(user, bulk_upload) + send_email( + 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]", + }, + ) + end + + def send_bulk_upload_with_errors_mail(user, bulk_upload) + send_email( + user.email, + BULK_UPLOAD_WITH_ERRORS_TEMPLATE_ID, + { + title: "[#{bulk_upload} title]", + filename: "[#{bulk_upload} filename]", + upload_timestamp: "[#{bulk_upload} upload_timestamp]", + error_description: "[#{bulk_upload} error_description]", + summary_report_link: "[#{bulk_upload} summary_report_link]", + }, + ) + end +end diff --git a/app/models/bulk_upload.rb b/app/models/bulk_upload.rb index 7933ac204..56e10f399 100644 --- a/app/models/bulk_upload.rb +++ b/app/models/bulk_upload.rb @@ -3,7 +3,8 @@ class BulkUpload < ApplicationRecord belongs_to :user - has_many :bulk_upload_errors + has_many :bulk_upload_errors, dependent: :destroy + has_many :lettings_logs has_many :sales_logs @@ -13,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/derived_variables/sales_log_variables.rb b/app/models/derived_variables/sales_log_variables.rb index 245361a80..16fb6ebd7 100644 --- a/app/models/derived_variables/sales_log_variables.rb +++ b/app/models/derived_variables/sales_log_variables.rb @@ -15,6 +15,9 @@ module DerivedVariables::SalesLogVariables if mscharge_known.present? && mscharge_known.zero? self.mscharge = 0 end + if mortgage_not_used? + self.mortgage = 0 + end self.pcode1, self.pcode2 = postcode_full.split(" ") if postcode_full.present? self.totchild = total_child self.totadult = total_adult + total_elder 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/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/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/question.rb b/app/models/form/question.rb index cbfc6aae2..02f9f3235 100644 --- a/app/models/form/question.rb +++ b/app/models/form/question.rb @@ -14,11 +14,11 @@ class Form::Question def initialize(id, hsh, page) @id = id @page = page + @guidance_position = GuidancePosition::TOP if hsh @check_answer_label = hsh["check_answer_label"] @header = hsh["header"] @guidance_partial = hsh["guidance_partial"] - @guidance_position = GuidancePosition::TOP @hint_text = hsh["hint_text"] @type = hsh["type"] @min = hsh["min"] @@ -206,6 +206,7 @@ class Form::Question def unanswered_error_message return I18n.t("validations.declaration.missing") if id == "declaration" + return I18n.t("validations.privacynotice.missing") if id == "privacynotice" I18n.t("validations.not_answered", question: display_label.downcase) end diff --git a/app/models/form/sales/pages/age1.rb b/app/models/form/sales/pages/age1.rb index de9b1ef8d..5aed5c4f3 100644 --- a/app/models/form/sales/pages/age1.rb +++ b/app/models/form/sales/pages/age1.rb @@ -2,6 +2,14 @@ class Form::Sales::Pages::Age1 < ::Form::Page def initialize(id, hsh, subsection) super @id = "buyer_1_age" + @depends_on = [ + { + "privacynotice" => 1, + }, + { + "noint" => 1, + }, + ] end def questions diff --git a/app/models/form/sales/pages/age2.rb b/app/models/form/sales/pages/age2.rb index d849c1465..ff0666988 100644 --- a/app/models/form/sales/pages/age2.rb +++ b/app/models/form/sales/pages/age2.rb @@ -2,9 +2,16 @@ class Form::Sales::Pages::Age2 < ::Form::Page def initialize(id, hsh, subsection) super @id = "buyer_2_age" - @depends_on = [{ - "jointpur" => 1, - }] + @depends_on = [ + { + "jointpur" => 1, + "privacynotice" => 1, + }, + { + "jointpur" => 1, + "noint" => 1, + }, + ] end def questions diff --git a/app/models/form/sales/pages/buyer1_ethnic_group.rb b/app/models/form/sales/pages/buyer1_ethnic_group.rb index af0269290..73d66b328 100644 --- a/app/models/form/sales/pages/buyer1_ethnic_group.rb +++ b/app/models/form/sales/pages/buyer1_ethnic_group.rb @@ -2,6 +2,14 @@ class Form::Sales::Pages::Buyer1EthnicGroup < ::Form::Page def initialize(id, hsh, subsection) super @id = "buyer_1_ethnic_group" + @depends_on = [ + { + "privacynotice" => 1, + }, + { + "noint" => 1, + }, + ] end def questions diff --git a/app/models/form/sales/pages/buyer1_live_in_property.rb b/app/models/form/sales/pages/buyer1_live_in_property.rb index 0d780ffed..deb6275af 100644 --- a/app/models/form/sales/pages/buyer1_live_in_property.rb +++ b/app/models/form/sales/pages/buyer1_live_in_property.rb @@ -2,6 +2,14 @@ class Form::Sales::Pages::Buyer1LiveInProperty < ::Form::Page def initialize(id, hsh, subsection) super @id = "buyer_1_live_in_property" + @depends_on = [ + { + "privacynotice" => 1, + }, + { + "noint" => 1, + }, + ] end def questions diff --git a/app/models/form/sales/pages/buyer1_working_situation.rb b/app/models/form/sales/pages/buyer1_working_situation.rb index 8d56caa47..66cf38e69 100644 --- a/app/models/form/sales/pages/buyer1_working_situation.rb +++ b/app/models/form/sales/pages/buyer1_working_situation.rb @@ -2,6 +2,14 @@ class Form::Sales::Pages::Buyer1WorkingSituation < ::Form::Page def initialize(id, hsh, subsection) super @id = "buyer_1_working_situation" + @depends_on = [ + { + "privacynotice" => 1, + }, + { + "noint" => 1, + }, + ] end def questions diff --git a/app/models/form/sales/pages/buyer2_live_in_property.rb b/app/models/form/sales/pages/buyer2_live_in_property.rb index 8904c21f2..9ba67080b 100644 --- a/app/models/form/sales/pages/buyer2_live_in_property.rb +++ b/app/models/form/sales/pages/buyer2_live_in_property.rb @@ -2,9 +2,16 @@ class Form::Sales::Pages::Buyer2LiveInProperty < ::Form::Page def initialize(id, hsh, subsection) super @id = "buyer_2_live_in_property" - @depends_on = [{ - "jointpur" => 1, - }] + @depends_on = [ + { + "jointpur" => 1, + "privacynotice" => 1, + }, + { + "jointpur" => 1, + "noint" => 1, + }, + ] end def questions diff --git a/app/models/form/sales/pages/buyer2_relationship_to_buyer1.rb b/app/models/form/sales/pages/buyer2_relationship_to_buyer1.rb index 026486883..7a1612d1f 100644 --- a/app/models/form/sales/pages/buyer2_relationship_to_buyer1.rb +++ b/app/models/form/sales/pages/buyer2_relationship_to_buyer1.rb @@ -2,9 +2,16 @@ class Form::Sales::Pages::Buyer2RelationshipToBuyer1 < ::Form::Page def initialize(id, hsh, subsection) super @id = "buyer_2_relationship_to_buyer_1" - @depends_on = [{ - "jointpur" => 1, - }] + @depends_on = [ + { + "jointpur" => 1, + "privacynotice" => 1, + }, + { + "jointpur" => 1, + "noint" => 1, + }, + ] end def questions diff --git a/app/models/form/sales/pages/buyer2_working_situation.rb b/app/models/form/sales/pages/buyer2_working_situation.rb index 4523c34cc..704fc0eac 100644 --- a/app/models/form/sales/pages/buyer2_working_situation.rb +++ b/app/models/form/sales/pages/buyer2_working_situation.rb @@ -2,9 +2,16 @@ class Form::Sales::Pages::Buyer2WorkingSituation < ::Form::Page def initialize(id, hsh, subsection) super @id = "buyer_2_working_situation" - @depends_on = [{ - "jointpur" => 1, - }] + @depends_on = [ + { + "jointpur" => 1, + "privacynotice" => 1, + }, + { + "jointpur" => 1, + "noint" => 1, + }, + ] end def questions diff --git a/app/models/form/sales/pages/deposit_and_mortgage_value_check.rb b/app/models/form/sales/pages/deposit_and_mortgage_value_check.rb new file mode 100644 index 000000000..338889030 --- /dev/null +++ b/app/models/form/sales/pages/deposit_and_mortgage_value_check.rb @@ -0,0 +1,17 @@ +class Form::Sales::Pages::DepositAndMortgageValueCheck < ::Form::Page + def initialize(id, hsh, subsection) + super + @depends_on = [ + { + "mortgage_plus_deposit_less_than_discounted_value?" => true, + }, + ] + @informative_text = {} + end + + def questions + @questions ||= [ + Form::Sales::Questions::DepositAndMortgageValueCheck.new(nil, nil, self), + ] + end +end diff --git a/app/models/form/sales/pages/gender_identity1.rb b/app/models/form/sales/pages/gender_identity1.rb index 2dadce8ba..a9d333cf4 100644 --- a/app/models/form/sales/pages/gender_identity1.rb +++ b/app/models/form/sales/pages/gender_identity1.rb @@ -2,6 +2,14 @@ class Form::Sales::Pages::GenderIdentity1 < ::Form::Page def initialize(id, hsh, subsection) super @id = "buyer_1_gender_identity" + @depends_on = [ + { + "privacynotice" => 1, + }, + { + "noint" => 1, + }, + ] end def questions diff --git a/app/models/form/sales/pages/gender_identity2.rb b/app/models/form/sales/pages/gender_identity2.rb index 3d72842c9..f79c3dc4a 100644 --- a/app/models/form/sales/pages/gender_identity2.rb +++ b/app/models/form/sales/pages/gender_identity2.rb @@ -2,9 +2,16 @@ class Form::Sales::Pages::GenderIdentity2 < ::Form::Page def initialize(id, hsh, subsection) super @id = "buyer_2_gender_identity" - @depends_on = [{ - "jointpur" => 1, - }] + @depends_on = [ + { + "jointpur" => 1, + "privacynotice" => 1, + }, + { + "jointpur" => 1, + "noint" => 1, + }, + ] end def questions diff --git a/app/models/form/sales/pages/monthly_charges_value_check.rb b/app/models/form/sales/pages/monthly_charges_value_check.rb new file mode 100644 index 000000000..909212b52 --- /dev/null +++ b/app/models/form/sales/pages/monthly_charges_value_check.rb @@ -0,0 +1,21 @@ +class Form::Sales::Pages::MonthlyChargesValueCheck < ::Form::Page + def initialize(id, hsh, subsection) + super + @depends_on = [ + { + "monthly_charges_over_soft_max?" => true, + }, + ] + @title_text = { + "translation" => "soft_validations.monthly_charges_over_soft_max.title_text", + "arguments" => [], + } + @informative_text = {} + end + + def questions + @questions ||= [ + Form::Sales::Questions::MonthlyChargesValueCheck.new(nil, nil, self), + ] + end +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/nationality1.rb b/app/models/form/sales/pages/nationality1.rb index 65bba7c6a..96723e857 100644 --- a/app/models/form/sales/pages/nationality1.rb +++ b/app/models/form/sales/pages/nationality1.rb @@ -2,6 +2,14 @@ class Form::Sales::Pages::Nationality1 < ::Form::Page def initialize(id, hsh, subsection) super @id = "buyer_1_nationality" + @depends_on = [ + { + "privacynotice" => 1, + }, + { + "noint" => 1, + }, + ] end def questions diff --git a/app/models/form/sales/pages/number_of_others_in_property.rb b/app/models/form/sales/pages/number_of_others_in_property.rb index ed82303ec..c090422fd 100644 --- a/app/models/form/sales/pages/number_of_others_in_property.rb +++ b/app/models/form/sales/pages/number_of_others_in_property.rb @@ -2,6 +2,14 @@ class Form::Sales::Pages::NumberOfOthersInProperty < ::Form::Page def initialize(id, hsh, subsection) super @id = "number_of_others_in_property" + @depends_on = [ + { + "privacynotice" => 1, + }, + { + "noint" => 1, + }, + ] end def questions diff --git a/app/models/form/sales/pages/old_persons_shared_ownership_value_check.rb b/app/models/form/sales/pages/old_persons_shared_ownership_value_check.rb new file mode 100644 index 000000000..9198af18a --- /dev/null +++ b/app/models/form/sales/pages/old_persons_shared_ownership_value_check.rb @@ -0,0 +1,21 @@ +class Form::Sales::Pages::OldPersonsSharedOwnershipValueCheck < ::Form::Page + def initialize(id, hsh, subsection) + super + @depends_on = [ + { + "buyers_age_for_old_persons_shared_ownership_invalid?" => true, + }, + ] + @title_text = { + "translation" => "soft_validations.old_persons_shared_ownership", + "arguments" => [], + } + @informative_text = {} + end + + def questions + @questions ||= [ + Form::Sales::Questions::OldPersonsSharedOwnershipValueCheck.new(nil, nil, self), + ] + end +end diff --git a/app/models/form/sales/pages/staircase_bought_value_check.rb b/app/models/form/sales/pages/staircase_bought_value_check.rb new file mode 100644 index 000000000..b7b8178ff --- /dev/null +++ b/app/models/form/sales/pages/staircase_bought_value_check.rb @@ -0,0 +1,27 @@ +class Form::Sales::Pages::StaircaseBoughtValueCheck < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "staircase_bought_value_check" + @depends_on = [ + { + "staircase_bought_above_fifty?" => true, + }, + ] + @title_text = { + "translation" => "soft_validations.staircase_bought_seems_high", + "arguments" => [ + { + "key" => "stairbought", + "i18n_template" => "percentage", + }, + ], + } + @informative_text = {} + end + + def questions + @questions ||= [ + Form::Sales::Questions::StaircaseBoughtValueCheck.new(nil, nil, self), + ] + end +end diff --git a/app/models/form/sales/questions/deposit_and_mortgage_value_check.rb b/app/models/form/sales/questions/deposit_and_mortgage_value_check.rb new file mode 100644 index 000000000..263cf4342 --- /dev/null +++ b/app/models/form/sales/questions/deposit_and_mortgage_value_check.rb @@ -0,0 +1,23 @@ +class Form::Sales::Questions::DepositAndMortgageValueCheck < ::Form::Question + def initialize(id, hsh, page) + super + @id = "deposit_and_mortgage_value_check" + @check_answer_label = "Deposit and mortgage against discount confirmation" + @header = "Are you sure? Mortgage and deposit usually equal or are more than (value - discount)" + @type = "interruption_screen" + @answer_options = { + "0" => { "value" => "Yes" }, + "1" => { "value" => "No" }, + } + @hidden_in_check_answers = { + "depends_on" => [ + { + "deposit_and_mortgage_value_check" => 0, + }, + { + "deposit_and_mortgage_value_check" => 1, + }, + ], + } + end +end diff --git a/app/models/form/sales/questions/discounted_ownership_type.rb b/app/models/form/sales/questions/discounted_ownership_type.rb index 2cbef6117..f75d83c01 100644 --- a/app/models/form/sales/questions/discounted_ownership_type.rb +++ b/app/models/form/sales/questions/discounted_ownership_type.rb @@ -9,7 +9,7 @@ class Form::Sales::Questions::DiscountedOwnershipType < ::Form::Question end ANSWER_OPTIONS = { - "8" => { "value" => "Right to Aquire (RTA)" }, + "8" => { "value" => "Right to Acquire (RTA)" }, "14" => { "value" => "Preserved Right to Buy (PRTB)" }, "27" => { "value" => "Voluntary Right to Buy (VRTB)" }, "9" => { "value" => "Right to Buy (RTB)" }, diff --git a/app/models/form/sales/questions/monthly_charges_value_check.rb b/app/models/form/sales/questions/monthly_charges_value_check.rb new file mode 100644 index 000000000..90fcf4545 --- /dev/null +++ b/app/models/form/sales/questions/monthly_charges_value_check.rb @@ -0,0 +1,23 @@ +class Form::Sales::Questions::MonthlyChargesValueCheck < ::Form::Question + def initialize(id, hsh, page) + super + @id = "monthly_charges_value_check" + @check_answer_label = "Monthly charges confirmation" + @header = "Are you sure this is correct?" + @type = "interruption_screen" + @answer_options = { + "0" => { "value" => "Yes" }, + "1" => { "value" => "No" }, + } + @hidden_in_check_answers = { + "depends_on" => [ + { + "monthly_charges_value_check" => 0, + }, + { + "monthly_charges_value_check" => 1, + }, + ], + } + end +end diff --git a/app/models/form/sales/questions/old_persons_shared_ownership_value_check.rb b/app/models/form/sales/questions/old_persons_shared_ownership_value_check.rb new file mode 100644 index 000000000..c869dd3be --- /dev/null +++ b/app/models/form/sales/questions/old_persons_shared_ownership_value_check.rb @@ -0,0 +1,23 @@ +class Form::Sales::Questions::OldPersonsSharedOwnershipValueCheck < ::Form::Question + def initialize(id, hsh, page) + super + @id = "old_persons_shared_ownership_value_check" + @check_answer_label = "Shared ownership confirmation" + @header = "Are you sure this is correct?" + @type = "interruption_screen" + @answer_options = { + "0" => { "value" => "Yes" }, + "1" => { "value" => "No" }, + } + @hidden_in_check_answers = { + "depends_on" => [ + { + "old_persons_shared_ownership_value_check" => 0, + }, + { + "old_persons_shared_ownership_value_check" => 1, + }, + ], + } + end +end diff --git a/app/models/form/sales/questions/privacy_notice.rb b/app/models/form/sales/questions/privacy_notice.rb index 5bc84bce6..4d7bb61c6 100644 --- a/app/models/form/sales/questions/privacy_notice.rb +++ b/app/models/form/sales/questions/privacy_notice.rb @@ -6,7 +6,6 @@ class Form::Sales::Questions::PrivacyNotice < ::Form::Question @header = "Declaration" @type = "checkbox" @answer_options = ANSWER_OPTIONS - @guidance_position = GuidancePosition::TOP @guidance_partial = "privacy_notice_buyer" end diff --git a/app/models/form/sales/questions/staircase_bought.rb b/app/models/form/sales/questions/staircase_bought.rb index bdb5ac965..385cfb782 100644 --- a/app/models/form/sales/questions/staircase_bought.rb +++ b/app/models/form/sales/questions/staircase_bought.rb @@ -8,6 +8,6 @@ class Form::Sales::Questions::StaircaseBought < ::Form::Question @width = 5 @min = 0 @max = 100 - @suffix = " percent" + @suffix = "%" end end diff --git a/app/models/form/sales/questions/staircase_bought_value_check.rb b/app/models/form/sales/questions/staircase_bought_value_check.rb new file mode 100644 index 000000000..65fe02e66 --- /dev/null +++ b/app/models/form/sales/questions/staircase_bought_value_check.rb @@ -0,0 +1,23 @@ +class Form::Sales::Questions::StaircaseBoughtValueCheck < ::Form::Question + def initialize(id, hsh, page) + super + @id = "staircase_bought_value_check" + @check_answer_label = "Percentage bought confirmation" + @header = "Are you sure this is correct?" + @type = "interruption_screen" + @answer_options = { + "0" => { "value" => "Yes" }, + "1" => { "value" => "No" }, + } + @hidden_in_check_answers = { + "depends_on" => [ + { + "staircase_bought_value_check" => 0, + }, + { + "staircase_bought_value_check" => 1, + }, + ], + } + end +end diff --git a/app/models/form/sales/questions/staircase_owned.rb b/app/models/form/sales/questions/staircase_owned.rb index 6f9e13b14..7e6dab5d6 100644 --- a/app/models/form/sales/questions/staircase_owned.rb +++ b/app/models/form/sales/questions/staircase_owned.rb @@ -8,6 +8,6 @@ class Form::Sales::Questions::StaircaseOwned < ::Form::Question @width = 5 @min = 0 @max = 100 - @suffix = " percent" + @suffix = "%" 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 2ab47e729..6070afda6 100644 --- a/app/models/form/sales/subsections/discounted_ownership_scheme.rb +++ b/app/models/form/sales/subsections/discounted_ownership_scheme.rb @@ -14,9 +14,13 @@ 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::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), Form::Sales::Pages::MortgageLenderOther.new("mortgage_lender_other_discounted_ownership", nil, self), Form::Sales::Pages::MortgageLength.new("mortgage_length_discounted_ownership", nil, self), @@ -25,7 +29,9 @@ class Form::Sales::Subsections::DiscountedOwnershipScheme < ::Form::Subsection Form::Sales::Pages::AboutDepositWithoutDiscount.new("about_deposit_discounted_ownership", nil, self), Form::Sales::Pages::ExtraBorrowingValueCheck.new("extra_borrowing_deposit_value_check", nil, self), Form::Sales::Pages::DepositValueCheck.new("discounted_ownership_deposit_value_check", nil, self), + Form::Sales::Pages::DepositAndMortgageValueCheck.new("discounted_ownership_deposit_and_mortgage_value_check_after_deposit", nil, self), Form::Sales::Pages::LeaseholdCharges.new("leasehold_charges_discounted_ownership", nil, self), + Form::Sales::Pages::MonthlyChargesValueCheck.new("monthly_charges_discounted_ownership_value_check", nil, self), ] end diff --git a/app/models/form/sales/subsections/household_characteristics.rb b/app/models/form/sales/subsections/household_characteristics.rb index b4c8badcf..bfccf0fa2 100644 --- a/app/models/form/sales/subsections/household_characteristics.rb +++ b/app/models/form/sales/subsections/household_characteristics.rb @@ -13,6 +13,7 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection Form::Sales::Pages::Age1.new(nil, nil, self), Form::Sales::Pages::RetirementValueCheck.new("age_1_retirement_value_check", nil, self, person_index: 1), Form::Sales::Pages::RetirementValueCheck.new("age_1_retirement_value_check_joint_purchase", nil, self, person_index: 1), + Form::Sales::Pages::OldPersonsSharedOwnershipValueCheck.new("age_1_old_persons_shared_ownership_value_check", nil, self), Form::Sales::Pages::GenderIdentity1.new(nil, nil, self), Form::Sales::Pages::RetirementValueCheck.new("gender_1_retirement_value_check", nil, self, person_index: 1), Form::Sales::Pages::RetirementValueCheck.new("gender_1_retirement_value_check_joint_purchase", nil, self, person_index: 1), @@ -31,6 +32,7 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection Form::Sales::Pages::Buyer2RelationshipToBuyer1.new(nil, nil, self), Form::Sales::Pages::Age2.new(nil, nil, self), Form::Sales::Pages::RetirementValueCheck.new("age_2_retirement_value_check_joint_purchase", nil, self, person_index: 2), + Form::Sales::Pages::OldPersonsSharedOwnershipValueCheck.new("age_2_old_persons_shared_ownership_value_check", nil, self), Form::Sales::Pages::GenderIdentity2.new(nil, nil, self), Form::Sales::Pages::RetirementValueCheck.new("gender_2_retirement_value_check_joint_purchase", nil, self, person_index: 2), Form::Sales::Pages::Buyer2WorkingSituation.new(nil, nil, self), diff --git a/app/models/form/sales/subsections/household_needs.rb b/app/models/form/sales/subsections/household_needs.rb index b5d4d528e..a419cff95 100644 --- a/app/models/form/sales/subsections/household_needs.rb +++ b/app/models/form/sales/subsections/household_needs.rb @@ -2,7 +2,7 @@ class Form::Sales::Subsections::HouseholdNeeds < ::Form::Subsection def initialize(id, hsh, section) super @id = "household_needs" - @label = "Household needs" + @label = "Other household information" @depends_on = [{ "setup_completed?" => true }] end 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 82099dab6..5d7d05d10 100644 --- a/app/models/form/sales/subsections/outright_sale.rb +++ b/app/models/form/sales/subsections/outright_sale.rb @@ -10,7 +10,9 @@ class Form::Sales::Subsections::OutrightSale < ::Form::Subsection @pages ||= [ Form::Sales::Pages::PurchasePrice.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), @@ -18,6 +20,7 @@ class Form::Sales::Subsections::OutrightSale < ::Form::Subsection Form::Sales::Pages::AboutDepositWithoutDiscount.new("about_deposit_outright_sale", nil, self), Form::Sales::Pages::DepositValueCheck.new("outright_sale_deposit_value_check", nil, self), Form::Sales::Pages::LeaseholdCharges.new("leasehold_charges_outright_sale", nil, self), + Form::Sales::Pages::MonthlyChargesValueCheck.new("monthly_charges_outright_sale_value_check", nil, self), ] end diff --git a/app/models/form/sales/subsections/property_information.rb b/app/models/form/sales/subsections/property_information.rb index 60d392874..eb057c48c 100644 --- a/app/models/form/sales/subsections/property_information.rb +++ b/app/models/form/sales/subsections/property_information.rb @@ -11,6 +11,7 @@ class Form::Sales::Subsections::PropertyInformation < ::Form::Subsection Form::Sales::Pages::PropertyNumberOfBedrooms.new(nil, nil, self), Form::Sales::Pages::AboutPriceSharedOwnershipValueCheck.new("about_price_shared_ownership_bedrooms_value_check", nil, self), Form::Sales::Pages::PropertyUnitType.new(nil, nil, self), + Form::Sales::Pages::MonthlyChargesValueCheck.new("monthly_charges_property_type_value_check", nil, self), Form::Sales::Pages::PropertyBuildingType.new(nil, nil, self), Form::Sales::Pages::Postcode.new(nil, nil, self), Form::Sales::Pages::PropertyLocalAuthority.new(nil, nil, self), diff --git a/app/models/form/sales/subsections/setup.rb b/app/models/form/sales/subsections/setup.rb index d2261a33b..22dcda8b9 100644 --- a/app/models/form/sales/subsections/setup.rb +++ b/app/models/form/sales/subsections/setup.rb @@ -15,6 +15,8 @@ class Form::Sales::Subsections::Setup < ::Form::Subsection Form::Sales::Pages::SharedOwnershipType.new(nil, nil, self), Form::Sales::Pages::DiscountedOwnershipType.new(nil, nil, self), Form::Sales::Pages::OutrightOwnershipType.new(nil, nil, self), + Form::Sales::Pages::OldPersonsSharedOwnershipValueCheck.new("ownership_type_old_persons_shared_ownership_value_check", nil, self), + Form::Sales::Pages::MonthlyChargesValueCheck.new("monthly_charges_type_value_check", nil, self), Form::Sales::Pages::BuyerCompany.new(nil, nil, self), Form::Sales::Pages::BuyerLive.new(nil, nil, self), Form::Sales::Pages::JointPurchase.new(nil, 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 b4cc071ff..d25b7b224 100644 --- a/app/models/form/sales/subsections/shared_ownership_scheme.rb +++ b/app/models/form/sales/subsections/shared_ownership_scheme.rb @@ -11,6 +11,7 @@ class Form::Sales::Subsections::SharedOwnershipScheme < ::Form::Subsection Form::Sales::Pages::LivingBeforePurchase.new("living_before_purchase_shared_ownership", nil, self), Form::Sales::Pages::Staircase.new(nil, nil, self), Form::Sales::Pages::AboutStaircase.new(nil, nil, self), + Form::Sales::Pages::StaircaseBoughtValueCheck.new(nil, nil, self), Form::Sales::Pages::Resale.new(nil, nil, self), Form::Sales::Pages::ExchangeDate.new(nil, nil, self), Form::Sales::Pages::HandoverDate.new(nil, nil, self), @@ -24,8 +25,10 @@ class Form::Sales::Subsections::SharedOwnershipScheme < ::Form::Subsection Form::Sales::Pages::AboutPriceSharedOwnershipValueCheck.new("about_price_shared_ownership_value_check", 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), @@ -36,6 +39,7 @@ class Form::Sales::Subsections::SharedOwnershipScheme < ::Form::Subsection Form::Sales::Pages::SharedOwnershipDepositValueCheck.new("shared_ownership_deposit_value_check", nil, self), Form::Sales::Pages::MonthlyRent.new(nil, nil, self), Form::Sales::Pages::LeaseholdCharges.new("leasehold_charges_shared_ownership", nil, self), + Form::Sales::Pages::MonthlyChargesValueCheck.new("monthly_charges_shared_ownership_value_check", nil, self), ] end diff --git a/app/models/log.rb b/app/models/log.rb index 57940b93d..1b43fd1cb 100644 --- a/app/models/log.rb +++ b/app/models/log.rb @@ -109,7 +109,6 @@ private return unless form form.reset_not_routed_questions(self) - reset_created_by! end diff --git a/app/models/sales_log.rb b/app/models/sales_log.rb index 16e122958..57fd95d3b 100644 --- a/app/models/sales_log.rb +++ b/app/models/sales_log.rb @@ -1,4 +1,5 @@ class SalesLogValidator < ActiveModel::Validator + include Validations::Sales::SetupValidations include Validations::Sales::HouseholdValidations include Validations::Sales::PropertyValidations include Validations::SharedValidations @@ -23,18 +24,18 @@ class SalesLog < Log has_paper_trail validates_with SalesLogValidator - before_validation :set_derived_fields! before_validation :reset_invalidated_dependent_fields! before_validation :process_postcode_changes!, if: :postcode_full_changed? before_validation :process_previous_postcode_changes!, if: :ppostcode_full_changed? before_validation :reset_location_fields!, unless: :postcode_known? before_validation :reset_previous_location_fields!, unless: :previous_postcode_known? + before_validation :set_derived_fields! scope :filter_by_year, ->(year) { where(saledate: Time.zone.local(year.to_i, 4, 1)...Time.zone.local(year.to_i + 1, 4, 1)) } scope :search_by, ->(param) { filter_by_id(param) } scope :filter_by_organisation, ->(org, _user = nil) { where(owning_organisation: org) } - OPTIONAL_FIELDS = %w[purchid].freeze + OPTIONAL_FIELDS = %w[purchid monthly_charges_value_check old_persons_shared_ownership_value_check].freeze RETIREMENT_AGES = { "M" => 65, "F" => 60, "X" => 65 }.freeze def startdate @@ -222,6 +223,16 @@ class SalesLog < Log ownershipsch == 1 end + def buyers_age_for_old_persons_shared_ownership_invalid? + return unless old_persons_shared_ownership? + + (joint_purchase? && ages_unknown_or_under_64?([1, 2])) || (not_joint_purchase? && ages_unknown_or_under_64?([1])) + end + + def ages_unknown_or_under_64?(person_indexes) + person_indexes.all? { |person_num| self["age#{person_num}"].present? && self["age#{person_num}"] < 64 || self["age#{person_num}_known"] == 1 } + end + def purchase_price_soft_min LaSaleRange.find_by(start_year: collection_start_year, la:, bedrooms: beds).soft_min end diff --git a/app/models/validations/sales/financial_validations.rb b/app/models/validations/sales/financial_validations.rb index 233f32b6b..df7dc8df5 100644 --- a/app/models/validations/sales/financial_validations.rb +++ b/app/models/validations/sales/financial_validations.rb @@ -27,4 +27,21 @@ module Validations::Sales::FinancialValidations record.errors.add :cashdis, I18n.t("validations.financial.cash_discount_invalid") end end + + def validate_percentage_bought_not_greater_than_percentage_owned(record) + return unless record.stairbought && record.stairowned + + if record.stairbought > record.stairowned + record.errors.add :stairowned, I18n.t("validations.financial.staircasing.percentage_bought_must_be_greater_than_percentage_owned") + end + end + + def validate_percentage_owned_not_too_much_if_older_person(record) + return unless record.old_persons_shared_ownership? && record.stairowned + + if record.stairowned > 75 + record.errors.add :stairowned, I18n.t("validations.financial.staircasing.older_person_percentage_owned_maximum_75") + record.errors.add :type, I18n.t("validations.financial.staircasing.older_person_percentage_owned_maximum_75") + end + end end diff --git a/app/models/validations/sales/household_validations.rb b/app/models/validations/sales/household_validations.rb index 8c03d9db9..4f2290268 100644 --- a/app/models/validations/sales/household_validations.rb +++ b/app/models/validations/sales/household_validations.rb @@ -18,20 +18,6 @@ module Validations::Sales::HouseholdValidations shared_validate_partner_count(record, 6) end - def validate_buyers_age_for_old_persons_shared_ownership(record) - if record.old_persons_shared_ownership? - if record.joint_purchase? && ages_unknown_or_under_64?(record, [1, 2]) - record.errors.add :age1, I18n.t("validations.household.old_persons_shared_ownership") - record.errors.add :age2, I18n.t("validations.household.old_persons_shared_ownership") - record.errors.add :type, I18n.t("validations.household.old_persons_shared_ownership") - end - if record.not_joint_purchase? && ages_unknown_or_under_64?(record, [1]) - record.errors.add :age1, I18n.t("validations.household.old_persons_shared_ownership") - record.errors.add :type, I18n.t("validations.household.old_persons_shared_ownership") - end - end - end - def validate_previous_postcode(record) return unless record.postcode_full && record.ppostcode_full && record.discounted_ownership_sale? @@ -116,8 +102,4 @@ private def tenant_is_economic_child?(economic_status) economic_status == 9 end - - def ages_unknown_or_under_64?(record, person_indexes) - person_indexes.all? { |person_num| record["age#{person_num}"].present? && record["age#{person_num}"] < 64 || record["age#{person_num}_known"] == 1 } - end end diff --git a/app/models/validations/sales/sale_information_validations.rb b/app/models/validations/sales/sale_information_validations.rb index d6f992c51..18306000e 100644 --- a/app/models/validations/sales/sale_information_validations.rb +++ b/app/models/validations/sales/sale_information_validations.rb @@ -1,18 +1,11 @@ module Validations::Sales::SaleInformationValidations - def validate_deposit_range(record) - return if record.deposit.blank? - unless record.deposit >= 0 && record.deposit <= 999_999 - record.errors.add :deposit, "Cash deposit must be £0 - £999,999" - end - end - - def validate_practical_completion_date_before_exdate(record) - return if record.exdate.blank? || record.hodate.blank? + def validate_practical_completion_date_before_saledate(record) + return if record.saledate.blank? || record.hodate.blank? - unless record.exdate > record.hodate - record.errors.add :exdate, I18n.t("validations.sale_information.handover_exchange.exchange_after_handover") - record.errors.add :hodate, I18n.t("validations.sale_information.handover_exchange.exchange_after_handover") + unless record.saledate > record.hodate + record.errors.add :hodate, I18n.t("validations.sale_information.hodate.must_be_before_saledate") + record.errors.add :saledate, I18n.t("validations.sale_information.saledate.must_be_after_hodate") end end @@ -32,11 +25,15 @@ module Validations::Sales::SaleInformationValidations def validate_exchange_date(record) return unless record.exdate && record.saledate - record.errors.add(:exdate, I18n.t("validations.sale_information.exdate.must_be_before_saledate")) if record.exdate > record.saledate - - return if (record.saledate.to_date - record.exdate.to_date).to_i / 365 < 1 + if record.exdate > record.saledate + record.errors.add :exdate, I18n.t("validations.sale_information.exdate.must_be_before_saledate") + record.errors.add :saledate, I18n.t("validations.sale_information.saledate.must_be_after_exdate") + end - record.errors.add(:exdate, I18n.t("validations.sale_information.exdate.must_be_less_than_1_year_from_saledate")) + if record.saledate - record.exdate >= 1.year + record.errors.add :exdate, I18n.t("validations.sale_information.exdate.must_be_less_than_1_year_from_saledate") + record.errors.add :saledate, I18n.t("validations.sale_information.saledate.must_be_less_than_1_year_from_exdate") + end end def validate_previous_property_unit_type(record) diff --git a/app/models/validations/sales/setup_validations.rb b/app/models/validations/sales/setup_validations.rb new file mode 100644 index 000000000..0e7a759ee --- /dev/null +++ b/app/models/validations/sales/setup_validations.rb @@ -0,0 +1,9 @@ +module Validations::Sales::SetupValidations + def validate_saledate(record) + return unless record.saledate + + unless Time.zone.local(2022, 4, 1) <= record.saledate && record.saledate < Time.zone.local(2023, 4, 1) + record.errors.add :saledate, I18n.t("validations.setup.saledate.financial_year") + end + end +end diff --git a/app/models/validations/sales/soft_validations.rb b/app/models/validations/sales/soft_validations.rb index c958dcdcd..1849b4ea0 100644 --- a/app/models/validations/sales/soft_validations.rb +++ b/app/models/validations/sales/soft_validations.rb @@ -13,8 +13,12 @@ module Validations::Sales::SoftValidations income1 < ALLOWED_INCOME_RANGES[ecstat1][:soft_min] end + def staircase_bought_above_fifty? + stairbought && stairbought > 50 + 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) @@ -65,6 +69,13 @@ module Validations::Sales::SoftValidations mortgage_value + deposit + cash_discount != value * equity / 100 end + def mortgage_plus_deposit_less_than_discounted_value? + return unless mortgage && deposit && value && discount + + discounted_value = value * (100 - discount) / 100 + mortgage + deposit < discounted_value + end + def hodate_3_years_or_more_saledate? return unless hodate && saledate end @@ -83,6 +94,13 @@ module Validations::Sales::SoftValidations !grant.between?(9_000, 16_000) end + def monthly_charges_over_soft_max? + return unless type && mscharge && proptype + + soft_max = old_persons_shared_ownership? ? 550 : 300 + mscharge > soft_max + end + private def sale_range diff --git a/app/services/bulk_upload/lettings/validator.rb b/app/services/bulk_upload/lettings/validator.rb index b96739836..90da6efb3 100644 --- a/app/services/bulk_upload/lettings/validator.rb +++ b/app/services/bulk_upload/lettings/validator.rb @@ -1,6 +1,9 @@ require "csv" class BulkUpload::Lettings::Validator + COLUMN_PERCENTAGE_ERROR_THRESHOLD = 0.6 + COLUMN_ABSOLUTE_ERROR_THRESHOLD = 16 + include ActiveModel::Validations QUESTIONS = { @@ -171,7 +174,10 @@ class BulkUpload::Lettings::Validator end def create_logs? - row_parsers.all?(&:valid?) + return false if any_setup_sections_incomplete? + return false if over_column_error_threshold? + + row_parsers.all? { |row_parser| row_parser.log.valid? } end def self.question_for_field(field) @@ -180,6 +186,23 @@ class BulkUpload::Lettings::Validator private + def any_setup_sections_incomplete? + row_parsers.any? { |row_parser| row_parser.log.form.setup_sections[0].subsections[0].is_incomplete?(row_parser.log) } + end + + def over_column_error_threshold? + fields = ("field_1".."field_134").to_a + percentage_threshold = (row_parsers.size * COLUMN_PERCENTAGE_ERROR_THRESHOLD).ceil + + fields.any? do |field| + count = row_parsers.count { |row_parser| row_parser.errors[field].present? } + + next if count < COLUMN_ABSOLUTE_ERROR_THRESHOLD + + count > percentage_threshold + end + end + def csv_parser @csv_parser ||= BulkUpload::Lettings::CsvParser.new(path:) end diff --git a/app/services/bulk_upload/processor.rb b/app/services/bulk_upload/processor.rb index c8c8398c2..6b444a205 100644 --- a/app/services/bulk_upload/processor.rb +++ b/app/services/bulk_upload/processor.rb @@ -9,12 +9,23 @@ class BulkUpload::Processor download validator.call create_logs if validator.create_logs? + send_success_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 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/bulk_upload_lettings_results/show.html.erb b/app/views/bulk_upload_lettings_results/show.html.erb index 452926787..84374e26a 100644 --- a/app/views/bulk_upload_lettings_results/show.html.erb +++ b/app/views/bulk_upload_lettings_results/show.html.erb @@ -1,6 +1,10 @@ +<% content_for :before_content do %> + <%= govuk_back_link(text: "Back", href: summary_bulk_upload_lettings_result_path(@bulk_upload)) %> +<% end %> +
- Bulk Upload for lettings (<%= @bulk_upload.year_combo %>) + Bulk upload for lettings (<%= @bulk_upload.year_combo %>)

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

diff --git a/app/views/bulk_upload_lettings_results/summary.html.erb b/app/views/bulk_upload_lettings_results/summary.html.erb new file mode 100644 index 000000000..04d8bdb92 --- /dev/null +++ b/app/views/bulk_upload_lettings_results/summary.html.erb @@ -0,0 +1,22 @@ +
+
+ Bulk upload for lettings (<%= @bulk_upload.year_combo %>) +

Correct data export and reupload

+ +

+ We noticed that you have a lot of similar errors for some questions. You can download the specification which we reference below to understand how to correct the data. Once you have fixed these errors you can upload again. +

+
+
+ +<%= render BulkUploadErrorSummaryTableComponent.new(bulk_upload: @bulk_upload) %> + +
+
+

+ You also have other errors in your file which you can either fix them in the CSV file or you can reupload and fix on CORE. <%= govuk_link_to "View the full report", bulk_upload_lettings_result_path(@bulk_upload) %> +

+
+
+ +<%= govuk_button_link_to "Upload your file again", start_bulk_upload_lettings_logs_path %> 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/locales/en.yml b/config/locales/en.yml index 1ca83fd3c..7139223cf 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -147,6 +147,8 @@ en: setup: intermediate_rent_product_name: blank: "Enter name of other intermediate rent product" + saledate: + financial_year: "Date must be from 22/23 financial year" 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" @@ -275,6 +277,10 @@ en: out_of_range: "Household rent and other charges must be between %{min_chcharge} and %{max_chcharge} if paying %{period}" not_provided: "Enter how much rent and other charges the household pays %{period}" cash_discount_invalid: "Cash discount must be £0 - £999,999" + staircasing: + percentage_bought_must_be_greater_than_percentage_owned: "Total percentage buyer now owns must be more than percentage bought in this transaction" + older_person_percentage_owned_maximum_75: "Percentage cannot be above 75% under Older Person's Shared Ownership" + household: reasonpref: not_homeless: "Answer cannot be ‘homeless or about to lose their home’ as the tenant was not homeless immediately prior to this letting" @@ -368,7 +374,6 @@ en: not_internal_transfer: "Answer cannot be ‘permanently decanted from another property owned by this landlord’ as you told us the source of referral for this tenancy was not an internal transfer" condition_effects: no_choices: "You cannot answer this question as you told us nobody in the household has a physical or mental health condition (or other illness) expected to last 12 months or more" - old_persons_shared_ownership: "Are you sure? At least one buyer should be aged over 64 for Older persons‘ shared ownership scheme" postcode: discounted_ownership: "Last settled accommodation and discounted ownership property postcodes must match" @@ -385,6 +390,9 @@ en: declaration: missing: "You must show the DLUHC privacy notice to the tenant before you can submit this log." + privacynotice: + missing: "You must show the DLUHC privacy notice to the buyer before you can submit this log." + scheme: toggle_date: not_selected: "Select one of the options" @@ -416,18 +424,16 @@ en: proplen: social_homebuy: "Social HomeBuy buyers should not have lived here before" rent_to_buy: "Rent to Buy buyers should not have lived here before" + hodate: + must_be_before_exdate: "Practical completion or handover date must be before exchange date" exdate: - must_be_before_saledate: - Contract exchange date must be less than 1 year before completion date - must_be_less_than_1_year_from_saledate: - Contract exchange date must be less than 1 year before completion date - previous_property_beds: - property_type_bedsit: "Bedsit bedroom maximum 1" + must_be_before_saledate: "Contract exchange date must be less than 1 year before completion date" + must_be_less_than_1_year_from_saledate: "Contract exchange date must be less than 1 year before completion date" + saledate: + must_be_after_exdate: "Completion date must be less than 1 year after contract exchange date" + must_be_less_than_1_year_from_exdate: "Completion date must be less than 1 year after contract exchange date" previous_property_type: property_type_bedsit: "A bedsit can not have more than 1 bedroom" - handover_exchange: - handover_before_exchange: "Practical completion or handover date must be before exchange date" - exchange_after_handover: "Exchange date must be after practical completion or handover date" discounted_ownership_value: "Mortgage, deposit, and grant total must equal £%{value_with_discount}" monthly_rent: higher_than_expected: "Basic monthly rent must be between £0 and £9,999" @@ -469,6 +475,9 @@ en: title_text: "You told us the time between the start of the tenancy and the void date is more than 2 years" 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" + monthly_charges_over_soft_max: + title_text: "The amount of monthly charges is high for this type of property and sale type" devise: two_factor_authentication: diff --git a/config/routes.rb b/config/routes.rb index 913212dd2..be765c8c0 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -137,6 +137,7 @@ Rails.application.routes.draw do resources :bulk_upload_lettings_results, path: "bulk-upload-results", only: [:show] do member do get :resume + get :summary end end diff --git a/db/migrate/20230120163049_add_deposit_and_mortgage_value_check_to_sales_logs.rb b/db/migrate/20230120163049_add_deposit_and_mortgage_value_check_to_sales_logs.rb new file mode 100644 index 000000000..a9a80a4bb --- /dev/null +++ b/db/migrate/20230120163049_add_deposit_and_mortgage_value_check_to_sales_logs.rb @@ -0,0 +1,5 @@ +class AddDepositAndMortgageValueCheckToSalesLogs < ActiveRecord::Migration[7.0] + def change + add_column :sales_logs, :deposit_and_mortgage_value_check, :integer + end +end diff --git a/db/migrate/20230124105247_add_old_persons_shared_ownership_value_check.rb b/db/migrate/20230124105247_add_old_persons_shared_ownership_value_check.rb new file mode 100644 index 000000000..ad5a0c70f --- /dev/null +++ b/db/migrate/20230124105247_add_old_persons_shared_ownership_value_check.rb @@ -0,0 +1,7 @@ +class AddOldPersonsSharedOwnershipValueCheck < ActiveRecord::Migration[7.0] + def change + change_table :sales_logs, bulk: true do |t| + t.column :old_persons_shared_ownership_value_check, :integer + end + end +end diff --git a/db/migrate/20230125152916_add_staircase_bought_value_check_to_sales_log.rb b/db/migrate/20230125152916_add_staircase_bought_value_check_to_sales_log.rb new file mode 100644 index 000000000..d7e227afa --- /dev/null +++ b/db/migrate/20230125152916_add_staircase_bought_value_check_to_sales_log.rb @@ -0,0 +1,5 @@ +class AddStaircaseBoughtValueCheckToSalesLog < ActiveRecord::Migration[7.0] + def change + add_column :sales_logs, :staircase_bought_value_check, :integer + end +end diff --git a/db/migrate/20230127102334_add_monthly_charges_value_check.rb b/db/migrate/20230127102334_add_monthly_charges_value_check.rb new file mode 100644 index 000000000..a8b118022 --- /dev/null +++ b/db/migrate/20230127102334_add_monthly_charges_value_check.rb @@ -0,0 +1,7 @@ +class AddMonthlyChargesValueCheck < ActiveRecord::Migration[7.0] + def change + change_table :sales_logs, bulk: true do |t| + t.column :monthly_charges_value_check, :integer + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 9dee823b9..95e7799a1 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -70,17 +70,6 @@ ActiveRecord::Schema[7.0].define(version: 2023_01_27_102334) do t.index ["start_year", "lettype", "beds", "la"], name: "index_la_rent_ranges_on_start_year_and_lettype_and_beds_and_la", unique: true end - create_table "la_sale_ranges", force: :cascade do |t| - t.string "la" - t.integer "bedrooms" - t.decimal "soft_min", precision: 10, scale: 2 - t.decimal "soft_max", precision: 10, scale: 2 - t.integer "start_year" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.index ["start_year", "bedrooms", "la"], name: "index_la_sale_ranges_on_start_year_bedrooms_la", unique: true - end - create_table "legacy_users", force: :cascade do |t| t.string "old_user_id" t.integer "user_id" @@ -515,13 +504,12 @@ ActiveRecord::Schema[7.0].define(version: 2023_01_27_102334) do t.integer "retirement_value_check" t.integer "hodate_check" t.integer "extrabor_value_check" + t.integer "grant_value_check" + t.integer "staircase_bought_value_check" t.integer "deposit_and_mortgage_value_check" t.integer "shared_ownership_deposit_value_check" - t.integer "grant_value_check" t.integer "old_persons_shared_ownership_value_check" - t.integer "staircase_bought_value_check" t.integer "monthly_charges_value_check" - t.integer "value_value_check" t.index ["bulk_upload_id"], name: "index_sales_logs_on_bulk_upload_id" t.index ["created_by_id"], name: "index_sales_logs_on_created_by_id" t.index ["owning_organisation_id"], name: "index_sales_logs_on_owning_organisation_id" diff --git a/db/seeds.rb b/db/seeds.rb index 54efda1a8..6eabe7d41 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -148,7 +148,7 @@ unless Rails.env.test? if (Rails.env.development? || Rails.env.review?) && SalesLog.count.zero? SalesLog.find_or_create_by!( - saledate: Date.new(1, 1, 1), + saledate: Date.new(2023, 1, 1), purchid: "1", ownershipsch: 1, type: 2, @@ -157,7 +157,7 @@ unless Rails.env.test? ) SalesLog.find_or_create_by!( - saledate: Date.new(1, 1, 1), + saledate: Date.new(2023, 1, 1), purchid: "1", ownershipsch: 2, type: 9, @@ -166,7 +166,7 @@ unless Rails.env.test? ) SalesLog.find_or_create_by!( - saledate: Date.new(1, 1, 1), + saledate: Date.new(2023, 1, 1), purchid: "1", ownershipsch: 3, type: 10, diff --git a/spec/components/bulk_upload_error_summary_table_component_spec.rb b/spec/components/bulk_upload_error_summary_table_component_spec.rb new file mode 100644 index 000000000..cdb0b58bf --- /dev/null +++ b/spec/components/bulk_upload_error_summary_table_component_spec.rb @@ -0,0 +1,81 @@ +require "rails_helper" + +RSpec.describe BulkUploadErrorSummaryTableComponent, type: :component do + subject(:component) { described_class.new(bulk_upload:) } + + let(:bulk_upload) { create(:bulk_upload) } + + context "when no errors" do + it "does not renders any rows" do + result = render_inline(component) + expect(result).not_to have_selector("tbody tr") + end + end + + context "when there are 2 independent errors" do + let!(:error_2) { create(:bulk_upload_error, bulk_upload:, col: "B", row: 2) } + let!(:error_1) { create(:bulk_upload_error, bulk_upload:, col: "A", row: 1) } + + it "renders rows for each error" do + result = render_inline(component) + expect(result).to have_selector("tbody tr", count: 2) + end + + it "renders rows by col order" do + result = render_inline(component) + order = result.css("tbody tr td:nth-of-type(1)").map(&:content) + expect(order).to eql(%w[A B]) + end + + it "render correct data" do + result = render_inline(component) + + row_1 = result.css("tbody tr:nth-of-type(1) td").map(&:content) + + expect(row_1).to eql([ + "A", + "1", + BulkUpload::Lettings::Validator.question_for_field(error_1.field.to_sym), + error_1.error, + error_1.field, + ]) + + row_2 = result.css("tbody tr:nth-of-type(2) td").map(&:content) + + expect(row_2).to eql([ + "B", + "1", + BulkUpload::Lettings::Validator.question_for_field(error_2.field.to_sym), + error_2.error, + error_2.field, + ]) + end + end + + context "when there are 2 grouped errors" do + let!(:error_1) { create(:bulk_upload_error, bulk_upload:, col: "A", row: 1, field: "field_1") } + + before do + create(:bulk_upload_error, bulk_upload:, col: "A", row: 2, field: "field_1") + end + + it "renders 1 row combining the errors" do + result = render_inline(component) + expect(result).to have_selector("tbody tr", count: 1) + end + + it "render correct data" do + result = render_inline(component) + + row_1 = result.css("tbody tr:nth-of-type(1) td").map(&:content) + + expect(row_1).to eql([ + "A", + "2", + BulkUpload::Lettings::Validator.question_for_field(error_1.field.to_sym), + error_1.error, + error_1.field, + ]) + end + end +end 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/factories/bulk_upload_error.rb b/spec/factories/bulk_upload_error.rb index 1f42f763d..885f27d9d 100644 --- a/spec/factories/bulk_upload_error.rb +++ b/spec/factories/bulk_upload_error.rb @@ -4,7 +4,8 @@ FactoryBot.define do factory :bulk_upload_error do bulk_upload row { rand(9_999) } - cell { "#{('A'..'Z').to_a.sample}#{row}" } + col { ("A".."Z").to_a.sample } + cell { "#{col}#{row}" } tenant_code { SecureRandom.hex(4) } property_ref { SecureRandom.hex(4) } purchaser_code { SecureRandom.hex(4) } diff --git a/spec/factories/sales_log.rb b/spec/factories/sales_log.rb index f83d102d3..085d4ca03 100644 --- a/spec/factories/sales_log.rb +++ b/spec/factories/sales_log.rb @@ -2,18 +2,18 @@ FactoryBot.define do factory :sales_log do created_by { FactoryBot.create(:user) } owning_organisation { created_by.organisation } - created_at { Time.utc(2022, 2, 8, 16, 52, 15) } - updated_at { Time.utc(2022, 2, 8, 16, 52, 15) } + created_at { Time.utc(2023, 2, 8, 16, 52, 15) } + updated_at { Time.utc(2023, 2, 8, 16, 52, 15) } trait :in_progress do purchid { "PC123" } ownershipsch { 2 } type { 8 } - saledate { Time.utc(2022, 2, 2, 10, 36, 49) } + saledate { Time.utc(2023, 2, 2, 10, 36, 49) } end trait :completed do ownershipsch { 2 } type { 8 } - saledate { Time.utc(2022, 2, 2, 10, 36, 49) } + saledate { Time.utc(2023, 2, 2, 10, 36, 49) } companybuy { 1 } jointpur { 1 } beds { 2 } diff --git a/spec/mailers/bulk_upload_mailer_spec.rb b/spec/mailers/bulk_upload_mailer_spec.rb new file mode 100644 index 000000000..526f3584a --- /dev/null +++ b/spec/mailers/bulk_upload_mailer_spec.rb @@ -0,0 +1,32 @@ +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) } + + 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 +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..47cd30458 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 { 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/age1_spec.rb b/spec/models/form/sales/pages/age1_spec.rb index 0c8130bad..6205610a0 100644 --- a/spec/models/form/sales/pages/age1_spec.rb +++ b/spec/models/form/sales/pages/age1_spec.rb @@ -28,6 +28,6 @@ RSpec.describe Form::Sales::Pages::Age1, type: :model do end it "has correct depends_on" do - expect(page.depends_on).to be_nil + expect(page.depends_on).to eq([{ "privacynotice" => 1 }, { "noint" => 1 }]) end end diff --git a/spec/models/form/sales/pages/age2_spec.rb b/spec/models/form/sales/pages/age2_spec.rb index eabb6a2e8..2645b3724 100644 --- a/spec/models/form/sales/pages/age2_spec.rb +++ b/spec/models/form/sales/pages/age2_spec.rb @@ -28,8 +28,15 @@ RSpec.describe Form::Sales::Pages::Age2, type: :model do end it "has correct depends_on" do - expect(page.depends_on).to eq([{ - "jointpur" => 1, - }]) + expect(page.depends_on).to eq([ + { + "jointpur" => 1, + "privacynotice" => 1, + }, + { + "jointpur" => 1, + "noint" => 1, + }, + ]) end end diff --git a/spec/models/form/sales/pages/buyer1_ethnic_group_spec.rb b/spec/models/form/sales/pages/buyer1_ethnic_group_spec.rb index e6e6798f5..52bbaff53 100644 --- a/spec/models/form/sales/pages/buyer1_ethnic_group_spec.rb +++ b/spec/models/form/sales/pages/buyer1_ethnic_group_spec.rb @@ -28,6 +28,6 @@ RSpec.describe Form::Sales::Pages::Buyer1EthnicGroup, type: :model do end it "has correct depends_on" do - expect(page.depends_on).to be_nil + expect(page.depends_on).to eq([{ "privacynotice" => 1 }, { "noint" => 1 }]) end end diff --git a/spec/models/form/sales/pages/buyer1_live_in_property_spec.rb b/spec/models/form/sales/pages/buyer1_live_in_property_spec.rb index 444f14909..6bdd4f5e2 100644 --- a/spec/models/form/sales/pages/buyer1_live_in_property_spec.rb +++ b/spec/models/form/sales/pages/buyer1_live_in_property_spec.rb @@ -28,6 +28,6 @@ RSpec.describe Form::Sales::Pages::Buyer1LiveInProperty, type: :model do end it "has correct depends_on" do - expect(page.depends_on).to be_nil + expect(page.depends_on).to eq([{ "privacynotice" => 1 }, { "noint" => 1 }]) end end diff --git a/spec/models/form/sales/pages/buyer2_live_in_property_spec.rb b/spec/models/form/sales/pages/buyer2_live_in_property_spec.rb index 34644241f..258e37462 100644 --- a/spec/models/form/sales/pages/buyer2_live_in_property_spec.rb +++ b/spec/models/form/sales/pages/buyer2_live_in_property_spec.rb @@ -28,6 +28,15 @@ RSpec.describe Form::Sales::Pages::Buyer2LiveInProperty, type: :model do end it "has correct depends_on" do - expect(page.depends_on).to eq([{ "jointpur" => 1 }]) + expect(page.depends_on).to eq([ + { + "jointpur" => 1, + "privacynotice" => 1, + }, + { + "jointpur" => 1, + "noint" => 1, + }, + ]) end end diff --git a/spec/models/form/sales/pages/buyer2_relationship_to_buyer1_spec.rb b/spec/models/form/sales/pages/buyer2_relationship_to_buyer1_spec.rb index eef011089..a518a1dc4 100644 --- a/spec/models/form/sales/pages/buyer2_relationship_to_buyer1_spec.rb +++ b/spec/models/form/sales/pages/buyer2_relationship_to_buyer1_spec.rb @@ -28,6 +28,15 @@ RSpec.describe Form::Sales::Pages::Buyer2RelationshipToBuyer1, type: :model do end it "has correct depends_on" do - expect(page.depends_on).to eq([{ "jointpur" => 1 }]) + expect(page.depends_on).to eq([ + { + "jointpur" => 1, + "privacynotice" => 1, + }, + { + "jointpur" => 1, + "noint" => 1, + }, + ]) end end diff --git a/spec/models/form/sales/pages/buyer2_working_situation_spec.rb b/spec/models/form/sales/pages/buyer2_working_situation_spec.rb index fe339091b..59c16c583 100644 --- a/spec/models/form/sales/pages/buyer2_working_situation_spec.rb +++ b/spec/models/form/sales/pages/buyer2_working_situation_spec.rb @@ -28,6 +28,15 @@ RSpec.describe Form::Sales::Pages::Buyer2WorkingSituation, type: :model do end it "has correct depends_on" do - expect(page.depends_on).to eq([{ "jointpur" => 1 }]) + expect(page.depends_on).to eq([ + { + "jointpur" => 1, + "privacynotice" => 1, + }, + { + "jointpur" => 1, + "noint" => 1, + }, + ]) end end diff --git a/spec/models/form/sales/pages/gender_identity1_spec.rb b/spec/models/form/sales/pages/gender_identity1_spec.rb index 2b06f2349..5188bb4ae 100644 --- a/spec/models/form/sales/pages/gender_identity1_spec.rb +++ b/spec/models/form/sales/pages/gender_identity1_spec.rb @@ -28,6 +28,6 @@ RSpec.describe Form::Sales::Pages::GenderIdentity1, type: :model do end it "has correct depends_on" do - expect(page.depends_on).to be_nil + expect(page.depends_on).to eq([{ "privacynotice" => 1 }, { "noint" => 1 }]) end end diff --git a/spec/models/form/sales/pages/gender_identity2_spec.rb b/spec/models/form/sales/pages/gender_identity2_spec.rb index 7698f151c..54e7ab565 100644 --- a/spec/models/form/sales/pages/gender_identity2_spec.rb +++ b/spec/models/form/sales/pages/gender_identity2_spec.rb @@ -28,8 +28,15 @@ RSpec.describe Form::Sales::Pages::GenderIdentity2, type: :model do end it "has correct depends_on" do - expect(page.depends_on).to eq([{ - "jointpur" => 1, - }]) + expect(page.depends_on).to eq([ + { + "jointpur" => 1, + "privacynotice" => 1, + }, + { + "jointpur" => 1, + "noint" => 1, + }, + ]) end end diff --git a/spec/models/form/sales/pages/monthly_charges_value_check_spec.rb b/spec/models/form/sales/pages/monthly_charges_value_check_spec.rb new file mode 100644 index 000000000..ac378dc82 --- /dev/null +++ b/spec/models/form/sales/pages/monthly_charges_value_check_spec.rb @@ -0,0 +1,48 @@ +require "rails_helper" + +RSpec.describe Form::Sales::Pages::MonthlyChargesValueCheck, type: :model do + subject(:page) { described_class.new(page_id, page_definition, subsection) } + + let(:page_id) { "monthly_charges_value_check" } + 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[monthly_charges_value_check]) + end + + it "has the correct id" do + expect(page.id).to eq("monthly_charges_value_check") + end + + it "has the correct header" do + expect(page.header).to be_nil + end + + it "has correct depends_on" do + expect(page.depends_on).to eq([ + { + "monthly_charges_over_soft_max?" => true, + }, + ]) + end + + it "is interruption screen page" do + expect(page.interruption_screen?).to eq(true) + end + + it "has correct title_text" do + expect(page.title_text).to eq({ + "translation" => "soft_validations.monthly_charges_over_soft_max.title_text", + "arguments" => [], + }) + end + + it "has correct informative_text" do + expect(page.informative_text).to eq({}) + 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/nationality1_spec.rb b/spec/models/form/sales/pages/nationality1_spec.rb index c39fecdd2..da5a5f802 100644 --- a/spec/models/form/sales/pages/nationality1_spec.rb +++ b/spec/models/form/sales/pages/nationality1_spec.rb @@ -28,6 +28,6 @@ RSpec.describe Form::Sales::Pages::Nationality1, type: :model do end it "has correct depends_on" do - expect(page.depends_on).to be_nil + expect(page.depends_on).to eq([{ "privacynotice" => 1 }, { "noint" => 1 }]) end end diff --git a/spec/models/form/sales/pages/old_persons_shared_ownership_value_check_spec.rb b/spec/models/form/sales/pages/old_persons_shared_ownership_value_check_spec.rb new file mode 100644 index 000000000..05b6f7734 --- /dev/null +++ b/spec/models/form/sales/pages/old_persons_shared_ownership_value_check_spec.rb @@ -0,0 +1,44 @@ +require "rails_helper" + +RSpec.describe Form::Sales::Pages::OldPersonsSharedOwnershipValueCheck, type: :model do + subject(:page) { described_class.new(page_id, page_definition, subsection) } + + let(:page_id) { "old_persons_shared_ownership_value_check" } + 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[old_persons_shared_ownership_value_check]) + end + + it "has the correct id" do + expect(page.id).to eq("old_persons_shared_ownership_value_check") + end + + it "has the correct header" do + expect(page.header).to be_nil + end + + it "has correct depends_on" do + expect(page.depends_on).to eq([ + { + "buyers_age_for_old_persons_shared_ownership_invalid?" => true, + }, + ]) + end + + it "has the correct title_text" do + expect(page.title_text).to eq({ + "translation" => "soft_validations.old_persons_shared_ownership", + "arguments" => [], + }) + end + + it "has the correct informative_text" do + expect(page.informative_text).to eq({}) + end +end diff --git a/spec/models/form/sales/questions/discounted_ownership_type_spec.rb b/spec/models/form/sales/questions/discounted_ownership_type_spec.rb index 51acd2fb5..d1c074023 100644 --- a/spec/models/form/sales/questions/discounted_ownership_type_spec.rb +++ b/spec/models/form/sales/questions/discounted_ownership_type_spec.rb @@ -33,7 +33,7 @@ RSpec.describe Form::Sales::Questions::DiscountedOwnershipType, type: :model do it "has the correct answer_options" do expect(question.answer_options).to eq({ - "8" => { "value" => "Right to Aquire (RTA)" }, + "8" => { "value" => "Right to Acquire (RTA)" }, "14" => { "value" => "Preserved Right to Buy (PRTB)" }, "27" => { "value" => "Voluntary Right to Buy (VRTB)" }, "9" => { "value" => "Right to Buy (RTB)" }, diff --git a/spec/models/form/sales/questions/monthly_charges_value_check_spec.rb b/spec/models/form/sales/questions/monthly_charges_value_check_spec.rb new file mode 100644 index 000000000..a62bac569 --- /dev/null +++ b/spec/models/form/sales/questions/monthly_charges_value_check_spec.rb @@ -0,0 +1,57 @@ +require "rails_helper" + +RSpec.describe Form::Sales::Questions::MonthlyChargesValueCheck, type: :model do + subject(:question) { described_class.new(question_id, question_definition, page) } + + let(:question_id) { "monthly_charges_value_check" } + let(:question_definition) { nil } + let(:page) { instance_double(Form::Page) } + + it "has correct page" do + expect(question.page).to eq(page) + end + + it "has the correct id" do + expect(question.id).to eq("monthly_charges_value_check") + end + + it "has the correct header" do + expect(question.header).to eq("Are you sure this is correct?") + end + + it "has the correct check_answer_label" do + expect(question.check_answer_label).to eq("Monthly charges confirmation") + end + + it "has the correct type" do + expect(question.type).to eq("interruption_screen") + 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 answer_options" do + expect(question.answer_options).to eq({ + "0" => { "value" => "Yes" }, + "1" => { "value" => "No" }, + }) + end + + it "has the correct hidden_in_check_answers" do + expect(question.hidden_in_check_answers).to eq({ + "depends_on" => [ + { + "monthly_charges_value_check" => 0, + }, + { + "monthly_charges_value_check" => 1, + }, + ], + }) + end +end diff --git a/spec/models/form/sales/questions/old_persons_shared_ownership_value_check_spec.rb b/spec/models/form/sales/questions/old_persons_shared_ownership_value_check_spec.rb new file mode 100644 index 000000000..5ac066e31 --- /dev/null +++ b/spec/models/form/sales/questions/old_persons_shared_ownership_value_check_spec.rb @@ -0,0 +1,57 @@ +require "rails_helper" + +RSpec.describe Form::Sales::Questions::OldPersonsSharedOwnershipValueCheck, type: :model do + subject(:question) { described_class.new(question_id, question_definition, page) } + + let(:question_id) { nil } + let(:question_definition) { nil } + let(:page) { instance_double(Form::Page) } + + it "has correct page" do + expect(question.page).to eq(page) + end + + it "has the correct id" do + expect(question.id).to eq("old_persons_shared_ownership_value_check") + end + + it "has the correct header" do + expect(question.header).to eq("Are you sure this is correct?") + end + + it "has the correct check_answer_label" do + expect(question.check_answer_label).to eq("Shared ownership confirmation") + end + + it "has the correct type" do + expect(question.type).to eq("interruption_screen") + 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 answer_options" do + expect(question.answer_options).to eq({ + "0" => { "value" => "Yes" }, + "1" => { "value" => "No" }, + }) + end + + it "has the correct hidden_in_check_answers" do + expect(question.hidden_in_check_answers).to eq({ + "depends_on" => [ + { + "old_persons_shared_ownership_value_check" => 0, + }, + { + "old_persons_shared_ownership_value_check" => 1, + }, + ], + }) + end +end diff --git a/spec/models/form/sales/questions/privacy_notice_spec.rb b/spec/models/form/sales/questions/privacy_notice_spec.rb index fc1df796c..1fec22b6e 100644 --- a/spec/models/form/sales/questions/privacy_notice_spec.rb +++ b/spec/models/form/sales/questions/privacy_notice_spec.rb @@ -40,4 +40,8 @@ RSpec.describe Form::Sales::Questions::PrivacyNotice, type: :model do "privacynotice" => { "value" => "The buyer has seen the DLUHC privacy notice" }, }) end + + it "returns correct unanswered_error_message" do + expect(question.unanswered_error_message).to eq("You must show the DLUHC privacy notice to the buyer before you can submit this log.") + end end diff --git a/spec/models/form/sales/questions/staircase_bought_spec.rb b/spec/models/form/sales/questions/staircase_bought_spec.rb index 96716dbd3..7b877cc26 100644 --- a/spec/models/form/sales/questions/staircase_bought_spec.rb +++ b/spec/models/form/sales/questions/staircase_bought_spec.rb @@ -44,7 +44,7 @@ RSpec.describe Form::Sales::Questions::StaircaseBought, type: :model do end it "has correct suffix" do - expect(question.suffix).to eq(" percent") + expect(question.suffix).to eq("%") end it "has correct min" do diff --git a/spec/models/form/sales/questions/staircase_owned_spec.rb b/spec/models/form/sales/questions/staircase_owned_spec.rb index 56b563990..cbd577784 100644 --- a/spec/models/form/sales/questions/staircase_owned_spec.rb +++ b/spec/models/form/sales/questions/staircase_owned_spec.rb @@ -44,7 +44,7 @@ RSpec.describe Form::Sales::Questions::StaircaseOwned, type: :model do end it "has correct suffix" do - expect(question.suffix).to eq(" percent") + expect(question.suffix).to eq("%") end it "has correct min" 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 7df741091..5702f7783 100644 --- a/spec/models/form/sales/subsections/discounted_ownership_scheme_spec.rb +++ b/spec/models/form/sales/subsections/discounted_ownership_scheme_spec.rb @@ -20,9 +20,13 @@ RSpec.describe Form::Sales::Subsections::DiscountedOwnershipScheme, type: :model about_price_not_rtb grant_value_check purchase_price_discounted_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 mortgage_lender_other_discounted_ownership mortgage_length_discounted_ownership @@ -31,7 +35,9 @@ RSpec.describe Form::Sales::Subsections::DiscountedOwnershipScheme, type: :model about_deposit_discounted_ownership extra_borrowing_deposit_value_check discounted_ownership_deposit_value_check + discounted_ownership_deposit_and_mortgage_value_check_after_deposit leasehold_charges_discounted_ownership + monthly_charges_discounted_ownership_value_check ], ) end diff --git a/spec/models/form/sales/subsections/household_characteristics_spec.rb b/spec/models/form/sales/subsections/household_characteristics_spec.rb index 34b1a7536..f99ebe0aa 100644 --- a/spec/models/form/sales/subsections/household_characteristics_spec.rb +++ b/spec/models/form/sales/subsections/household_characteristics_spec.rb @@ -19,6 +19,7 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model buyer_1_age age_1_retirement_value_check age_1_retirement_value_check_joint_purchase + age_1_old_persons_shared_ownership_value_check buyer_1_gender_identity gender_1_retirement_value_check gender_1_retirement_value_check_joint_purchase @@ -37,6 +38,7 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model buyer_2_relationship_to_buyer_1 buyer_2_age age_2_retirement_value_check_joint_purchase + age_2_old_persons_shared_ownership_value_check buyer_2_gender_identity gender_2_retirement_value_check_joint_purchase buyer_2_working_situation diff --git a/spec/models/form/sales/subsections/household_needs_spec.rb b/spec/models/form/sales/subsections/household_needs_spec.rb index 5395da095..d65f5513e 100644 --- a/spec/models/form/sales/subsections/household_needs_spec.rb +++ b/spec/models/form/sales/subsections/household_needs_spec.rb @@ -30,7 +30,7 @@ RSpec.describe Form::Sales::Subsections::HouseholdNeeds, type: :model do end it "has the correct label" do - expect(household_characteristics.label).to eq("Household needs") + expect(household_characteristics.label).to eq("Other household information") end it "has correct depends on" do diff --git a/spec/models/form/sales/subsections/outright_sale_spec.rb b/spec/models/form/sales/subsections/outright_sale_spec.rb index 45a9f4ca0..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 @@ -24,6 +26,7 @@ RSpec.describe Form::Sales::Subsections::OutrightSale, type: :model do about_deposit_outright_sale outright_sale_deposit_value_check leasehold_charges_outright_sale + monthly_charges_outright_sale_value_check ], ) end diff --git a/spec/models/form/sales/subsections/property_information_spec.rb b/spec/models/form/sales/subsections/property_information_spec.rb index 51b72c605..c9ab36136 100644 --- a/spec/models/form/sales/subsections/property_information_spec.rb +++ b/spec/models/form/sales/subsections/property_information_spec.rb @@ -17,6 +17,7 @@ RSpec.describe Form::Sales::Subsections::PropertyInformation, type: :model do property_number_of_bedrooms about_price_shared_ownership_bedrooms_value_check property_unit_type + monthly_charges_property_type_value_check property_building_type property_postcode property_local_authority diff --git a/spec/models/form/sales/subsections/setup_spec.rb b/spec/models/form/sales/subsections/setup_spec.rb index 36fbf247a..ac4f0246c 100644 --- a/spec/models/form/sales/subsections/setup_spec.rb +++ b/spec/models/form/sales/subsections/setup_spec.rb @@ -22,6 +22,8 @@ RSpec.describe Form::Sales::Subsections::Setup, type: :model do shared_ownership_type discounted_ownership_type outright_ownership_type + ownership_type_old_persons_shared_ownership_value_check + monthly_charges_type_value_check buyer_company buyer_live joint_purchase 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 a4e236051..ee9f624aa 100644 --- a/spec/models/form/sales/subsections/shared_ownership_scheme_spec.rb +++ b/spec/models/form/sales/subsections/shared_ownership_scheme_spec.rb @@ -17,6 +17,7 @@ RSpec.describe Form::Sales::Subsections::SharedOwnershipScheme, type: :model do living_before_purchase_shared_ownership staircasing about_staircasing + staircase_bought_value_check resale exchange_contracts handover_date @@ -30,8 +31,10 @@ RSpec.describe Form::Sales::Subsections::SharedOwnershipScheme, type: :model do about_price_shared_ownership_value_check 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 @@ -42,6 +45,7 @@ RSpec.describe Form::Sales::Subsections::SharedOwnershipScheme, type: :model do shared_ownership_deposit_value_check monthly_rent leasehold_charges_shared_ownership + monthly_charges_shared_ownership_value_check ], ) end diff --git a/spec/models/form_handler_spec.rb b/spec/models/form_handler_spec.rb index 81c332757..6f569d717 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(192) + expect(form.pages.count).to eq(210) 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(192) + expect(form.pages.count).to eq(210) expect(form.name).to eq("2021_2022_sales") end end diff --git a/spec/models/form_spec.rb b/spec/models/form_spec.rb index 110a521e2..71dfd4b60 100644 --- a/spec/models/form_spec.rb +++ b/spec/models/form_spec.rb @@ -218,9 +218,9 @@ RSpec.describe Form, type: :model do expect(form.sections[0].class).to eq(Form::Sales::Sections::Setup) expect(form.subsections.count).to eq(1) expect(form.subsections.first.id).to eq("setup") - expect(form.pages.count).to eq(12) + expect(form.pages.count).to eq(14) expect(form.pages.first.id).to eq("organisation") - expect(form.questions.count).to eq(13) + expect(form.questions.count).to eq(15) expect(form.questions.first.id).to eq("owning_organisation_id") expect(form.start_date).to eq(Time.zone.parse("2022-04-01")) expect(form.end_date).to eq(Time.zone.parse("2023-07-01")) diff --git a/spec/models/sales_log_spec.rb b/spec/models/sales_log_spec.rb index e49e56e01..0b4fa4459 100644 --- a/spec/models/sales_log_spec.rb +++ b/spec/models/sales_log_spec.rb @@ -47,7 +47,7 @@ RSpec.describe SalesLog, type: :model do let(:sales_log) { build(:sales_log) } it "returns optional fields" do - expect(sales_log.optional_fields).to eq(%w[purchid]) + expect(sales_log.optional_fields).to eq(%w[purchid monthly_charges_value_check old_persons_shared_ownership_value_check]) end end @@ -109,7 +109,7 @@ RSpec.describe SalesLog, type: :model do let(:sales_log) { FactoryBot.create(:sales_log, :completed) } it "correctly derives and saves exday, exmonth and exyear" do - sales_log.update!(exdate: Time.gm(2022, 5, 4)) + sales_log.update!(exdate: Time.gm(2022, 5, 4), saledate: Time.gm(2022, 7, 4), ownershipsch: 1, staircase: 2, resale: 2) record_from_db = ActiveRecord::Base.connection.execute("select exday, exmonth, exyear from sales_logs where id=#{sales_log.id}").to_a[0] expect(record_from_db["exday"]).to eq(4) expect(record_from_db["exmonth"]).to eq(5) @@ -140,6 +140,14 @@ RSpec.describe SalesLog, type: :model do expect(record_from_db["pcode1"]).to eq("W6") expect(record_from_db["pcode2"]).to eq("0SP") end + + it "derives a mortgage value of 0 when mortgage is not used" do + # to avoid log failing validations when mortgage value is removed: + new_grant_value = sales_log.grant + sales_log.mortgage + sales_log.update!(mortgageused: 2, grant: new_grant_value) + record_from_db = ActiveRecord::Base.connection.execute("select mortgage from sales_logs where id=#{sales_log.id}").to_a[0] + expect(record_from_db["mortgage"]).to eq(0.0) + end end context "when saving addresses" do @@ -238,39 +246,49 @@ RSpec.describe SalesLog, type: :model do end context "when deriving household variables" do - let!(:household_lettings_log) do - described_class.create!({ + let!(:sales_log) do + FactoryBot.create( + :sales_log, + :completed, jointpur: 1, - hholdcount: 3, + hholdcount: 4, + details_known_1: 1, + details_known_2: 1, + details_known_3: 1, + details_known_4: 1, relat2: "C", relat3: "C", relat4: "X", relat5: "X", - age1: 22, - age2: 40, - age3: 19, + relat6: "P", + ecstat2: 9, + ecstat3: 7, + age1: 47, + age2: 14, + age3: 17, age4: 88, - age5: 14, - }) + age5: 19, + age6: 46, + ) end it "correctly derives and saves hhmemb" do - record_from_db = ActiveRecord::Base.connection.execute("select hhmemb from sales_logs where id=#{household_lettings_log.id}").to_a[0] - expect(record_from_db["hhmemb"]).to eq(5) + record_from_db = ActiveRecord::Base.connection.execute("select hhmemb from sales_logs where id=#{sales_log.id}").to_a[0] + expect(record_from_db["hhmemb"]).to eq(6) end it "correctly derives and saves totchild" do - record_from_db = ActiveRecord::Base.connection.execute("select totchild from sales_logs where id=#{household_lettings_log.id}").to_a[0] + record_from_db = ActiveRecord::Base.connection.execute("select totchild from sales_logs where id=#{sales_log.id}").to_a[0] expect(record_from_db["totchild"]).to eq(2) end it "correctly derives and saves totadult" do - record_from_db = ActiveRecord::Base.connection.execute("select totadult from sales_logs where id=#{household_lettings_log.id}").to_a[0] - expect(record_from_db["totadult"]).to eq(3) + record_from_db = ActiveRecord::Base.connection.execute("select totadult from sales_logs where id=#{sales_log.id}").to_a[0] + expect(record_from_db["totadult"]).to eq(4) end it "correctly derives and saves hhtype" do - record_from_db = ActiveRecord::Base.connection.execute("select hhtype from sales_logs where id=#{household_lettings_log.id}").to_a[0] + record_from_db = ActiveRecord::Base.connection.execute("select hhtype from sales_logs where id=#{sales_log.id}").to_a[0] expect(record_from_db["hhtype"]).to eq(9) end end diff --git a/spec/models/validations/sales/financial_validations_spec.rb b/spec/models/validations/sales/financial_validations_spec.rb index 4bc19afbe..88f36943f 100644 --- a/spec/models/validations/sales/financial_validations_spec.rb +++ b/spec/models/validations/sales/financial_validations_spec.rb @@ -99,4 +99,63 @@ RSpec.describe Validations::Sales::FinancialValidations do expect(record.errors["cashdis"]).to be_empty end end + + describe "#validate_percentage_bought_not_greater_than_percentage_owned" do + let(:record) { FactoryBot.create(:sales_log) } + + it "does not add an error if the percentage bought is less than the percentage owned" do + record.stairbought = 20 + record.stairowned = 40 + financial_validator.validate_percentage_bought_not_greater_than_percentage_owned(record) + expect(record.errors["stairbought"]).to be_empty + expect(record.errors["stairowned"]).to be_empty + end + + it "does not add an error if the percentage bought is equal to the percentage owned" do + record.stairbought = 30 + record.stairowned = 30 + financial_validator.validate_percentage_bought_not_greater_than_percentage_owned(record) + expect(record.errors["stairbought"]).to be_empty + expect(record.errors["stairowned"]).to be_empty + end + + it "adds an error to stairowned and not stairbought if the percentage bought is more than the percentage owned" do + record.stairbought = 50 + record.stairowned = 40 + financial_validator.validate_percentage_bought_not_greater_than_percentage_owned(record) + expect(record.errors["stairowned"]).to include(match I18n.t("validations.financial.staircasing.percentage_bought_must_be_greater_than_percentage_owned")) + end + end + + describe "#validate_percentage_owned_not_too_much_if_older_person" do + let(:record) { FactoryBot.create(:sales_log) } + + context "when log type is not older persons shared ownership" do + it "does not add an error when percentage owned after staircasing transaction exceeds 75%" do + record.type = 2 + record.stairowned = 80 + financial_validator.validate_percentage_owned_not_too_much_if_older_person(record) + expect(record.errors["stairowned"]).to be_empty + expect(record.errors["type"]).to be_empty + end + end + + context "when log type is older persons shared ownership" do + it "does not add an error when percentage owned after staircasing transaction is less than 75%" do + record.type = 24 + record.stairowned = 50 + financial_validator.validate_percentage_owned_not_too_much_if_older_person(record) + expect(record.errors["stairowned"]).to be_empty + expect(record.errors["type"]).to be_empty + end + + it "adds an error when percentage owned after staircasing transaction exceeds 75%" do + record.type = 24 + record.stairowned = 90 + financial_validator.validate_percentage_owned_not_too_much_if_older_person(record) + expect(record.errors["stairowned"]).to include(match I18n.t("validations.financial.staircasing.older_person_percentage_owned_maximum_75")) + expect(record.errors["type"]).to include(match I18n.t("validations.financial.staircasing.older_person_percentage_owned_maximum_75")) + end + end + end end diff --git a/spec/models/validations/sales/household_validations_spec.rb b/spec/models/validations/sales/household_validations_spec.rb index 5b227c36d..26d369a35 100644 --- a/spec/models/validations/sales/household_validations_spec.rb +++ b/spec/models/validations/sales/household_validations_spec.rb @@ -164,121 +164,6 @@ RSpec.describe Validations::Sales::HouseholdValidations do expect(record.errors["ecstat2"]) .to include(match I18n.t("validations.household.ecstat.student_16_19.cannot_be_student.child_not_16_19")) end - - context "when it is a joint purchase and both buyers are over 64" do - let(:record) { FactoryBot.build(:sales_log, jointpur: 1, age1: 65, age2: 66, type: 24) } - - it "does not add an error" do - household_validator.validate_buyers_age_for_old_persons_shared_ownership(record) - - expect(record.errors).not_to be_present - end - end - - context "when it is a joint purchase and first buyer is over 64" do - let(:record) { FactoryBot.build(:sales_log, jointpur: 1, age1: 65, age2: 40, type: 24) } - - it "does not add an error" do - household_validator.validate_buyers_age_for_old_persons_shared_ownership(record) - - expect(record.errors).not_to be_present - end - end - - context "when it is a joint purchase and second buyer is over 64" do - let(:record) { FactoryBot.build(:sales_log, jointpur: 1, age1: 43, age2: 64, type: 24) } - - it "does not add an error" do - household_validator.validate_buyers_age_for_old_persons_shared_ownership(record) - - expect(record.errors).not_to be_present - end - end - - context "when it is a joint purchase and neither of the buyers are over 64" do - let(:record) { FactoryBot.build(:sales_log, jointpur: 1, age1: 43, age2: 33, type: 24) } - - it "adds an error" do - household_validator.validate_buyers_age_for_old_persons_shared_ownership(record) - - expect(record.errors["age1"]) - .to include(match I18n.t("validations.household.old_persons_shared_ownership")) - expect(record.errors["age2"]) - .to include(match I18n.t("validations.household.old_persons_shared_ownership")) - expect(record.errors["type"]) - .to include(match I18n.t("validations.household.old_persons_shared_ownership")) - end - end - - context "when it is a joint purchase and first buyer is under 64 and the second buyers' age is unknown" do - let(:record) { FactoryBot.build(:sales_log, jointpur: 1, age1: 43, age2_known: 1, type: 24) } - - it "adds an error" do - household_validator.validate_buyers_age_for_old_persons_shared_ownership(record) - - expect(record.errors["age1"]) - .to include(match I18n.t("validations.household.old_persons_shared_ownership")) - expect(record.errors["age2"]) - .to include(match I18n.t("validations.household.old_persons_shared_ownership")) - expect(record.errors["type"]) - .to include(match I18n.t("validations.household.old_persons_shared_ownership")) - end - end - - context "when it is a joint purchase and neither of the buyers ages are known" do - let(:record) { FactoryBot.build(:sales_log, jointpur: 1, age1_known: 1, age2_known: 1, type: 24) } - - it "adds an error" do - household_validator.validate_buyers_age_for_old_persons_shared_ownership(record) - - expect(record.errors["age1"]) - .to include(match I18n.t("validations.household.old_persons_shared_ownership")) - expect(record.errors["age2"]) - .to include(match I18n.t("validations.household.old_persons_shared_ownership")) - expect(record.errors["type"]) - .to include(match I18n.t("validations.household.old_persons_shared_ownership")) - end - end - - context "when it is not a joint purchase and the buyer is over 64" do - let(:record) { FactoryBot.build(:sales_log, jointpur: 2, age1: 70, type: 24) } - - it "does not add an error" do - household_validator.validate_buyers_age_for_old_persons_shared_ownership(record) - - expect(record.errors).not_to be_present - end - end - - context "when it is not a joint purchase and the buyer is under 64" do - let(:record) { FactoryBot.build(:sales_log, jointpur: 2, age1: 20, type: 24) } - - it "adds an error" do - household_validator.validate_buyers_age_for_old_persons_shared_ownership(record) - - expect(record.errors["age1"]) - .to include(match I18n.t("validations.household.old_persons_shared_ownership")) - expect(record.errors["age2"]) - .to be_empty - expect(record.errors["type"]) - .to include(match I18n.t("validations.household.old_persons_shared_ownership")) - end - end - - context "when it is not a joint purchase and the buyers age is not known" do - let(:record) { FactoryBot.build(:sales_log, jointpur: 2, age1_known: 1, type: 24) } - - it "adds an error" do - household_validator.validate_buyers_age_for_old_persons_shared_ownership(record) - - expect(record.errors["age1"]) - .to include(match I18n.t("validations.household.old_persons_shared_ownership")) - expect(record.errors["age2"]) - .to be_empty - expect(record.errors["type"]) - .to include(match I18n.t("validations.household.old_persons_shared_ownership")) - end - end end describe "previous postcode validations" do diff --git a/spec/models/validations/sales/sale_information_validations_spec.rb b/spec/models/validations/sales/sale_information_validations_spec.rb index e796300cf..f9efced05 100644 --- a/spec/models/validations/sales/sale_information_validations_spec.rb +++ b/spec/models/validations/sales/sale_information_validations_spec.rb @@ -111,12 +111,15 @@ RSpec.describe Validations::Sales::SaleInformationValidations do context "when exdate more than 1 year before saledate" do let(:record) { build(:sales_log, exdate: 2.years.ago, saledate: 1.month.ago) } - it "does not add the error" do + it "adds error" do sale_information_validator.validate_exchange_date(record) expect(record.errors[:exdate]).to eq( ["Contract exchange date must be less than 1 year before completion date"], ) + expect(record.errors[:saledate]).to eq( + ["Completion date must be less than 1 year after contract exchange date"], + ) end end @@ -129,6 +132,9 @@ RSpec.describe Validations::Sales::SaleInformationValidations do expect(record.errors[:exdate]).to eq( ["Contract exchange date must be less than 1 year before completion date"], ) + expect(record.errors[:saledate]).to eq( + ["Completion date must be less than 1 year after contract exchange date"], + ) end end diff --git a/spec/models/validations/sales/setup_validations_spec.rb b/spec/models/validations/sales/setup_validations_spec.rb new file mode 100644 index 000000000..74b7834ab --- /dev/null +++ b/spec/models/validations/sales/setup_validations_spec.rb @@ -0,0 +1,49 @@ +require "rails_helper" + +RSpec.describe Validations::Sales::SetupValidations do + subject(:setup_validator) { validator_class.new } + + let(:validator_class) { Class.new { include Validations::Sales::SetupValidations } } + + describe "#validate_saledate" do + context "when saledate is blank" do + let(:record) { FactoryBot.build(:sales_log, saledate: nil) } + + it "does not add an error" do + setup_validator.validate_saledate(record) + + expect(record.errors).to be_empty + end + end + + context "when saledate is in the 22/23 financial year" do + let(:record) { FactoryBot.build(:sales_log, saledate: Time.zone.local(2023, 1, 1)) } + + it "does not add an error" do + setup_validator.validate_saledate(record) + + expect(record.errors).to be_empty + end + end + + context "when saledate is before the 22/23 financial year" do + let(:record) { FactoryBot.build(:sales_log, saledate: Time.zone.local(2022, 1, 1)) } + + it "adds error" do + setup_validator.validate_saledate(record) + + expect(record.errors[:saledate]).to include(I18n.t("validations.setup.saledate.financial_year")) + end + end + + context "when saledate is after the 22/23 financial year" do + let(:record) { FactoryBot.build(:sales_log, saledate: Time.zone.local(2023, 4, 1)) } + + it "adds error" do + setup_validator.validate_saledate(record) + + expect(record.errors[:saledate]).to include(I18n.t("validations.setup.saledate.financial_year")) + end + end + end +end diff --git a/spec/models/validations/sales/soft_validations_spec.rb b/spec/models/validations/sales/soft_validations_spec.rb index 7d0dd3b59..a5821d121 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 @@ -201,6 +213,59 @@ RSpec.describe Validations::Sales::SoftValidations do end end + context "when validating mortgage and deposit against discounted value" do + [ + { + nil_field: "mortgage", + value: 500_000, + deposit: 10_000, + discount: 10, + }, + { + nil_field: "value", + mortgage: 100_000, + deposit: 10_000, + discount: 10, + }, + { + nil_field: "deposit", + value: 500_000, + mortgage: 100_000, + discount: 10, + }, + { + nil_field: "discount", + value: 500_000, + mortgage: 100_000, + deposit: 10_000, + }, + ].each do |test_case| + it "returns false if #{test_case[:nil_field]} is not present" do + record.value = test_case[:value] + record.mortgage = test_case[:mortgage] + record.deposit = test_case[:deposit] + record.discount = test_case[:discount] + expect(record).not_to be_mortgage_plus_deposit_less_than_discounted_value + end + end + + it "returns false if the deposit and mortgage add up to the discounted value or more" do + record.value = 500_000 + record.discount = 20 + record.mortgage = 200_000 + record.deposit = 200_000 + expect(record).not_to be_mortgage_plus_deposit_less_than_discounted_value + end + + it "returns true if the deposit and mortgage add up to less than the discounted value" do + record.value = 500_000 + record.discount = 10 + record.mortgage = 200_000 + record.deposit = 200_000 + expect(record).to be_mortgage_plus_deposit_less_than_discounted_value + end + end + context "when validating extra borrowing" do it "returns false if extrabor not present" do record.mortgage = 50_000 @@ -314,7 +379,7 @@ RSpec.describe Validations::Sales::SoftValidations do .to be_deposit_over_soft_max end - it "returns fals if deposit is less than 4/3 of savings" do + it "returns false if deposit is less than 4/3 of savings" do record.deposit = 7_999 record.savings = 6_000 expect(record) @@ -583,4 +648,86 @@ RSpec.describe Validations::Sales::SoftValidations do expect(record).not_to be_grant_outside_common_range end end + + describe "#staircase_bought_above_fifty" do + it "returns false when stairbought is not set" do + record.stairbought = nil + + expect(record).not_to be_staircase_bought_above_fifty + end + + it "returns false when stairbought is below fifty" do + record.stairbought = 40 + + expect(record).not_to be_staircase_bought_above_fifty + end + + it "returns true when stairbought is above fifty" do + record.stairbought = 70 + + expect(record).to be_staircase_bought_above_fifty + end + end + + describe "#monthly_charges_over_soft_max?" do + it "returns false if mscharge is not given" do + record.mscharge = nil + record.proptype = 4 + record.type = 2 + + expect(record).not_to be_monthly_charges_over_soft_max + end + + it "returns false if proptype is not given" do + record.mscharge = 999 + record.proptype = nil + record.type = 2 + + expect(record).not_to be_monthly_charges_over_soft_max + end + + it "returns false if type is not given" do + record.mscharge = 999 + record.proptype = 4 + record.type = nil + + expect(record).not_to be_monthly_charges_over_soft_max + end + + context "with old persons shared ownership" do + it "returns false if the monthly charge is under 550" do + record.mscharge = 540 + record.proptype = 4 + record.type = 24 + + expect(record).not_to be_monthly_charges_over_soft_max + end + + it "returns true if the monthly charge is over 550" do + record.mscharge = 999 + record.proptype = 4 + record.type = 24 + + expect(record).to be_monthly_charges_over_soft_max + end + end + + context "with non old persons type of ownership" do + it "returns false if the monthly charge is under 300" do + record.mscharge = 280 + record.proptype = 4 + record.type = 18 + + expect(record).not_to be_monthly_charges_over_soft_max + end + + it "returns true if the monthly charge is over 300" do + record.mscharge = 400 + record.proptype = 4 + record.type = 18 + + expect(record).to be_monthly_charges_over_soft_max + end + end + end end diff --git a/spec/models/validations/shared_validations_spec.rb b/spec/models/validations/shared_validations_spec.rb index abdde5f45..c1d8cb3af 100644 --- a/spec/models/validations/shared_validations_spec.rb +++ b/spec/models/validations/shared_validations_spec.rb @@ -70,11 +70,11 @@ RSpec.describe Validations::SharedValidations do end context "when validating percent" do - it "validates that % suffix is added in the error message" do - sales_record.stairbought = "random" + 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 percent", max: "100 percent")) + .to include(match I18n.t("validations.numeric.valid", field: "Percentage bought in this staircasing transaction", min: "0%", max: "100%")) end end diff --git a/spec/models/validations/soft_validations_spec.rb b/spec/models/validations/soft_validations_spec.rb index 93ed01a20..9ca9436fb 100644 --- a/spec/models/validations/soft_validations_spec.rb +++ b/spec/models/validations/soft_validations_spec.rb @@ -237,4 +237,78 @@ RSpec.describe Validations::SoftValidations do end end end + + describe "old persons shared ownership soft validations" do + context "when it is a joint purchase and both buyers are over 64" do + let(:record) { FactoryBot.build(:sales_log, jointpur: 1, age1: 65, age2: 66, type: 24) } + + it "returns false" do + expect(record.buyers_age_for_old_persons_shared_ownership_invalid?).to be false + end + end + + context "when it is a joint purchase and first buyer is over 64" do + let(:record) { FactoryBot.build(:sales_log, jointpur: 1, age1: 65, age2: 40, type: 24) } + + it "returns false" do + expect(record.buyers_age_for_old_persons_shared_ownership_invalid?).to be false + end + end + + context "when it is a joint purchase and second buyer is over 64" do + let(:record) { FactoryBot.build(:sales_log, jointpur: 1, age1: 43, age2: 64, type: 24) } + + it "returns false" do + expect(record.buyers_age_for_old_persons_shared_ownership_invalid?).to be false + end + end + + context "when it is a joint purchase and neither of the buyers are over 64" do + let(:record) { FactoryBot.build(:sales_log, jointpur: 1, age1: 43, age2: 33, type: 24) } + + it "returns true" do + expect(record.buyers_age_for_old_persons_shared_ownership_invalid?).to be true + end + end + + context "when it is a joint purchase and first buyer is under 64 and the second buyers' age is unknown" do + let(:record) { FactoryBot.build(:sales_log, jointpur: 1, age1: 43, age2_known: 1, type: 24) } + + it "returns true" do + expect(record.buyers_age_for_old_persons_shared_ownership_invalid?).to be true + end + end + + context "when it is a joint purchase and neither of the buyers ages are known" do + let(:record) { FactoryBot.build(:sales_log, jointpur: 1, age1_known: 1, age2_known: 1, type: 24) } + + it "returns true" do + expect(record.buyers_age_for_old_persons_shared_ownership_invalid?).to be true + end + end + + context "when it is not a joint purchase and the buyer is over 64" do + let(:record) { FactoryBot.build(:sales_log, jointpur: 2, age1: 70, type: 24) } + + it "returns false" do + expect(record.buyers_age_for_old_persons_shared_ownership_invalid?).to be false + end + end + + context "when it is not a joint purchase and the buyer is under 64" do + let(:record) { FactoryBot.build(:sales_log, jointpur: 2, age1: 20, type: 24) } + + it "returns true" do + expect(record.buyers_age_for_old_persons_shared_ownership_invalid?).to be true + end + end + + context "when it is not a joint purchase and the buyers age is not known" do + let(:record) { FactoryBot.build(:sales_log, jointpur: 2, age1_known: 1, type: 24) } + + it "returns true" do + expect(record.buyers_age_for_old_persons_shared_ownership_invalid?).to be true + end + end + end end diff --git a/spec/requests/bulk_upload_lettings_results_controller_spec.rb b/spec/requests/bulk_upload_lettings_results_controller_spec.rb index 15ba0b7bb..c15fef5b9 100644 --- a/spec/requests/bulk_upload_lettings_results_controller_spec.rb +++ b/spec/requests/bulk_upload_lettings_results_controller_spec.rb @@ -9,12 +9,27 @@ RSpec.describe BulkUploadLettingsResultsController, type: :request do sign_in user end + describe "GET /lettings-logs/bulk-upload-results/:ID/summary" do + it "renders year combo" do + get "/lettings-logs/bulk-upload-results/#{bulk_upload.id}/summary" + + expect(response).to be_successful + expect(response.body).to include("Bulk upload for lettings (2022/23)") + end + + it "renders the bulk upload filename" do + get "/lettings-logs/bulk-upload-results/#{bulk_upload.id}/summary" + + expect(response.body).to include(bulk_upload.filename) + end + end + describe "GET /lettings-logs/bulk-upload-results/:ID" do it "renders correct year" do get "/lettings-logs/bulk-upload-results/#{bulk_upload.id}" expect(response).to be_successful - expect(response.body).to include("Bulk Upload for lettings (2022/23)") + expect(response.body).to include("Bulk upload for lettings (2022/23)") end it "renders correct number of errors" do diff --git a/spec/requests/sales_logs_controller_spec.rb b/spec/requests/sales_logs_controller_spec.rb index f8690a71b..925e3f1f3 100644 --- a/spec/requests/sales_logs_controller_spec.rb +++ b/spec/requests/sales_logs_controller_spec.rb @@ -179,29 +179,29 @@ RSpec.describe SalesLogsController, type: :request do end context "with year filter" do - let!(:sales_log_2021) do + let!(:sales_log_2022) do FactoryBot.create(:sales_log, :in_progress, owning_organisation: organisation, - saledate: Time.zone.local(2022, 3, 1)) + saledate: Time.zone.local(2022, 4, 1)) end - let!(:sales_log_2022) do + let!(:sales_log_2023) do sales_log = FactoryBot.build(:sales_log, :completed, owning_organisation: organisation, - saledate: Time.zone.local(2022, 12, 1)) + saledate: Time.zone.local(2023, 1, 1)) sales_log.save!(validate: false) sales_log end it "shows sales logs for multiple selected years" do get "/sales-logs?years[]=2021&years[]=2022", headers: headers, params: {} - expect(page).to have_link(sales_log_2021.id.to_s) expect(page).to have_link(sales_log_2022.id.to_s) + expect(page).to have_link(sales_log_2023.id.to_s) end it "shows sales logs for one selected year" do - get "/sales-logs?years[]=2021", headers: headers, params: {} - expect(page).to have_link(sales_log_2021.id.to_s) - expect(page).not_to have_link(sales_log_2022.id.to_s) + get "/sales-logs?years[]=2022", headers: headers, params: {} + expect(page).to have_link(sales_log_2022.id.to_s) + expect(page).to have_link(sales_log_2023.id.to_s) end end @@ -214,23 +214,23 @@ RSpec.describe SalesLogsController, type: :request do Timecop.unfreeze end - let!(:sales_log_2021) do + let!(:sales_log_2022) do FactoryBot.create(:sales_log, :completed, owning_organisation: organisation, - saledate: Time.zone.local(2022, 3, 1), + saledate: Time.zone.local(2022, 4, 1), created_by: user) end - let!(:sales_log_2022) do + let!(:sales_log_2023) do FactoryBot.create(:sales_log, owning_organisation: organisation, - saledate: Time.zone.local(2022, 12, 1), + saledate: Time.zone.local(2023, 1, 1), created_by: user) end it "shows sales logs for multiple selected statuses and years" do get "/sales-logs?years[]=2021&years[]=2022&status[]=in_progress&status[]=completed", headers: headers, params: {} - expect(page).to have_link(sales_log_2021.id.to_s) expect(page).to have_link(sales_log_2022.id.to_s) + expect(page).to have_link(sales_log_2023.id.to_s) end end end diff --git a/spec/services/bulk_upload/lettings/validator_spec.rb b/spec/services/bulk_upload/lettings/validator_spec.rb index 661119448..ec9b3b7f7 100644 --- a/spec/services/bulk_upload/lettings/validator_spec.rb +++ b/spec/services/bulk_upload/lettings/validator_spec.rb @@ -78,7 +78,7 @@ RSpec.describe BulkUpload::Lettings::Validator do before do file.write(BulkUpload::LogToCsv.new(log:, line_ending: "\r\n", col_offset: 0).to_csv_row) - file.rewind + file.close end it "creates validation errors" do @@ -112,4 +112,148 @@ RSpec.describe BulkUpload::Lettings::Validator do end end end + + describe "#create_logs?" do + context "when a log is not valid?" do + let(:log_1) { build(:lettings_log, :completed, created_by: user) } + let(:log_2) { build(:lettings_log, :completed, created_by: user) } + + before do + file.write(BulkUpload::LogToCsv.new(log: log_1, line_ending: "\r\n", col_offset: 0).to_csv_row) + file.write(BulkUpload::LogToCsv.new(log: log_2, line_ending: "\r\n", col_offset: 0, overrides: { illness: 100 }).to_csv_row) + file.close + end + + it "returns false" do + validator.call + expect(validator).not_to be_create_logs + end + end + + context "when all logs valid?" do + let(:log_1) { build(:lettings_log, :completed, renttype: 1, created_by: user) } + let(:log_2) { build(:lettings_log, :completed, renttype: 1, created_by: user) } + + before do + file.write(BulkUpload::LogToCsv.new(log: log_1, line_ending: "\r\n", col_offset: 0).to_csv_row) + file.write(BulkUpload::LogToCsv.new(log: log_2, line_ending: "\r\n", col_offset: 0).to_csv_row) + file.close + end + + it "returns true" do + validator.call + expect(validator).to be_create_logs + end + end + + context "when a log has incomplete setup secion" do + let(:log) { build(:lettings_log, :in_progress, created_by: user, startdate: Time.zone.local(2022, 5, 1)) } + + before do + file.write(BulkUpload::LogToCsv.new(log:, line_ending: "\r\n", col_offset: 0).to_csv_row) + file.close + end + + it "returns false" do + validator.call + expect(validator).not_to be_create_logs + end + end + + context "when a column has error rate below absolute threshold" do + context "when a column is over 60% error threshold" do + let(:log_1) { build(:lettings_log, :completed, renttype: 1, created_by: user) } + let(:log_2) { build(:lettings_log, renttype: 2, created_by: user, builtype: nil, startdate: Time.zone.local(2022, 5, 1)) } + let(:log_3) { build(:lettings_log, renttype: 2, created_by: user, builtype: nil, startdate: Time.zone.local(2022, 5, 1)) } + let(:log_4) { build(:lettings_log, renttype: 2, created_by: user, builtype: nil, startdate: Time.zone.local(2022, 5, 1)) } + let(:log_5) { build(:lettings_log, renttype: 2, created_by: user, builtype: nil, startdate: Time.zone.local(2022, 5, 1)) } + + before do + file.write(BulkUpload::LogToCsv.new(log: log_1, line_ending: "\r\n", col_offset: 0).to_csv_row) + file.write(BulkUpload::LogToCsv.new(log: log_2, line_ending: "\r\n", col_offset: 0).to_csv_row) + file.write(BulkUpload::LogToCsv.new(log: log_3, line_ending: "\r\n", col_offset: 0).to_csv_row) + file.write(BulkUpload::LogToCsv.new(log: log_4, line_ending: "\r\n", col_offset: 0).to_csv_row) + file.write(BulkUpload::LogToCsv.new(log: log_5, line_ending: "\r\n", col_offset: 0).to_csv_row) + file.close + end + + it "returns true" do + validator.call + expect(validator).to be_create_logs + end + end + + context "when a column is under 60% error threshold" do + let(:log_1) { build(:lettings_log, :completed, renttype: 1, created_by: user) } + let(:log_2) { build(:lettings_log, :completed, renttype: 1, created_by: user) } + let(:log_3) { build(:lettings_log, renttype: 2, created_by: user, builtype: nil, startdate: Time.zone.local(2022, 5, 1)) } + let(:log_4) { build(:lettings_log, renttype: 2, created_by: user, builtype: nil, startdate: Time.zone.local(2022, 5, 1)) } + let(:log_5) { build(:lettings_log, renttype: 2, created_by: user, builtype: nil, startdate: Time.zone.local(2022, 5, 1)) } + + before do + file.write(BulkUpload::LogToCsv.new(log: log_1, line_ending: "\r\n", col_offset: 0).to_csv_row) + file.write(BulkUpload::LogToCsv.new(log: log_2, line_ending: "\r\n", col_offset: 0).to_csv_row) + file.write(BulkUpload::LogToCsv.new(log: log_3, line_ending: "\r\n", col_offset: 0).to_csv_row) + file.write(BulkUpload::LogToCsv.new(log: log_4, line_ending: "\r\n", col_offset: 0).to_csv_row) + file.write(BulkUpload::LogToCsv.new(log: log_5, line_ending: "\r\n", col_offset: 0).to_csv_row) + file.close + end + + it "returns true" do + validator.call + expect(validator).to be_create_logs + end + end + end + + context "when a column has error rate above absolute threshold" do + before do + stub_const("BulkUpload::Lettings::Validator::COLUMN_ABSOLUTE_ERROR_THRESHOLD", 1) + end + + context "when a column is over 60% error threshold" do + let(:log_1) { build(:lettings_log, :completed, renttype: 1, created_by: user) } + let(:log_2) { build(:lettings_log, renttype: 2, created_by: user, builtype: nil, startdate: Time.zone.local(2022, 5, 1)) } + let(:log_3) { build(:lettings_log, renttype: 2, created_by: user, builtype: nil, startdate: Time.zone.local(2022, 5, 1)) } + let(:log_4) { build(:lettings_log, renttype: 2, created_by: user, builtype: nil, startdate: Time.zone.local(2022, 5, 1)) } + let(:log_5) { build(:lettings_log, renttype: 2, created_by: user, builtype: nil, startdate: Time.zone.local(2022, 5, 1)) } + + before do + file.write(BulkUpload::LogToCsv.new(log: log_1, line_ending: "\r\n", col_offset: 0).to_csv_row) + file.write(BulkUpload::LogToCsv.new(log: log_2, line_ending: "\r\n", col_offset: 0).to_csv_row) + file.write(BulkUpload::LogToCsv.new(log: log_3, line_ending: "\r\n", col_offset: 0).to_csv_row) + file.write(BulkUpload::LogToCsv.new(log: log_4, line_ending: "\r\n", col_offset: 0).to_csv_row) + file.write(BulkUpload::LogToCsv.new(log: log_5, line_ending: "\r\n", col_offset: 0).to_csv_row) + file.close + end + + it "returns false" do + validator.call + expect(validator).not_to be_create_logs + end + end + + context "when a column is under 60% error threshold" do + let(:log_1) { build(:lettings_log, :completed, renttype: 1, created_by: user) } + let(:log_2) { build(:lettings_log, :completed, renttype: 1, created_by: user) } + let(:log_3) { build(:lettings_log, renttype: 2, created_by: user, builtype: nil, startdate: Time.zone.local(2022, 5, 1)) } + let(:log_4) { build(:lettings_log, renttype: 2, created_by: user, builtype: nil, startdate: Time.zone.local(2022, 5, 1)) } + let(:log_5) { build(:lettings_log, renttype: 2, created_by: user, builtype: nil, startdate: Time.zone.local(2022, 5, 1)) } + + before do + file.write(BulkUpload::LogToCsv.new(log: log_1, line_ending: "\r\n", col_offset: 0).to_csv_row) + file.write(BulkUpload::LogToCsv.new(log: log_2, line_ending: "\r\n", col_offset: 0).to_csv_row) + file.write(BulkUpload::LogToCsv.new(log: log_3, line_ending: "\r\n", col_offset: 0).to_csv_row) + file.write(BulkUpload::LogToCsv.new(log: log_4, line_ending: "\r\n", col_offset: 0).to_csv_row) + file.write(BulkUpload::LogToCsv.new(log: log_5, line_ending: "\r\n", col_offset: 0).to_csv_row) + file.close + end + + it "returns true" do + validator.call + expect(validator).to be_create_logs + end + end + end + end end diff --git a/spec/services/bulk_upload/processor_spec.rb b/spec/services/bulk_upload/processor_spec.rb index aaff12678..27fd9edd3 100644 --- a/spec/services/bulk_upload/processor_spec.rb +++ b/spec/services/bulk_upload/processor_spec.rb @@ -16,19 +16,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 @@ -59,15 +67,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 diff --git a/spec/support/bulk_upload/log_to_csv.rb b/spec/support/bulk_upload/log_to_csv.rb index 7734d9fe2..628ee14b8 100644 --- a/spec/support/bulk_upload/log_to_csv.rb +++ b/spec/support/bulk_upload/log_to_csv.rb @@ -1,10 +1,11 @@ class BulkUpload::LogToCsv - attr_reader :log, :line_ending, :col_offset + attr_reader :log, :line_ending, :col_offset, :overrides - def initialize(log:, line_ending: "\n", col_offset: 1) + def initialize(log:, line_ending: "\n", col_offset: 1, overrides: {}) @log = log @line_ending = line_ending @col_offset = col_offset + @overrides = overrides end def to_csv_row @@ -135,7 +136,7 @@ class BulkUpload::LogToCsv nil, log.incfreq, log.sheltered, - log.illness, + overrides[:illness] || log.illness, log.illness_type_1, log.illness_type_2, # 120