Browse Source

Merge branch 'main' into SalesFinancialValidationsCopy

pull/2716/head
Rachael Booth 8 months ago
parent
commit
6956db34bd
  1. 4
      Gemfile.lock
  2. 30
      app/components/bulk_upload_error_row_component.html.erb
  3. 13
      app/components/bulk_upload_error_row_component.rb
  4. 2
      app/components/bulk_upload_summary_component.html.erb
  5. 4
      app/components/document_list_component.html.erb
  6. 2
      app/constants/global_constants.rb
  7. 153
      app/controllers/collection_resources_controller.rb
  8. 2
      app/controllers/lettings_logs_controller.rb
  9. 2
      app/controllers/sales_logs_controller.rb
  10. 2
      app/controllers/start_controller.rb
  11. 17
      app/controllers/users_controller.rb
  12. 5
      app/frontend/styles/_bulk-uploads.scss
  13. 1
      app/frontend/styles/_document-list.scss
  14. 2
      app/helpers/collection_resources_helper.rb
  15. 2
      app/helpers/filters_helper.rb
  16. 3
      app/helpers/formatting_helper.rb
  17. 8
      app/helpers/log_actions_helper.rb
  18. 2
      app/helpers/merge_requests_helper.rb
  19. 2
      app/helpers/review_helper.rb
  20. 2
      app/helpers/tasklist_helper.rb
  21. 2
      app/models/bulk_upload.rb
  22. 38
      app/models/collection_resource.rb
  23. 2
      app/models/form/lettings/pages/address.rb
  24. 2
      app/models/form/lettings/pages/address_fallback.rb
  25. 2
      app/models/form/lettings/pages/address_matcher.rb
  26. 1
      app/models/form/lettings/pages/declaration.rb
  27. 1
      app/models/form/lettings/pages/lead_tenant_age.rb
  28. 1
      app/models/form/lettings/pages/lead_tenant_ethnic_background_arab.rb
  29. 1
      app/models/form/lettings/pages/lead_tenant_ethnic_background_asian.rb
  30. 1
      app/models/form/lettings/pages/lead_tenant_ethnic_background_black.rb
  31. 1
      app/models/form/lettings/pages/lead_tenant_ethnic_background_mixed.rb
  32. 1
      app/models/form/lettings/pages/lead_tenant_ethnic_background_white.rb
  33. 1
      app/models/form/lettings/pages/lead_tenant_nationality.rb
  34. 2
      app/models/form/lettings/pages/location.rb
  35. 2
      app/models/form/lettings/pages/location_search.rb
  36. 24
      app/models/form/lettings/pages/max_rent_value_check.rb
  37. 24
      app/models/form/lettings/pages/min_rent_value_check.rb
  38. 9
      app/models/form/lettings/pages/person_age.rb
  39. 1
      app/models/form/lettings/pages/person_known.rb
  40. 1
      app/models/form/lettings/pages/previous_housing_situation.rb
  41. 1
      app/models/form/lettings/pages/previous_housing_situation_renewal.rb
  42. 1
      app/models/form/lettings/pages/previous_local_authority.rb
  43. 1
      app/models/form/lettings/pages/previous_postcode.rb
  44. 1
      app/models/form/lettings/pages/property_major_repairs.rb
  45. 14
      app/models/form/lettings/pages/property_postcode.rb
  46. 1
      app/models/form/lettings/pages/reason_for_leaving_last_settled_home.rb
  47. 1
      app/models/form/lettings/pages/reason_for_leaving_last_settled_home_renewal.rb
  48. 1
      app/models/form/lettings/pages/referral.rb
  49. 1
      app/models/form/lettings/pages/referral_prp.rb
  50. 1
      app/models/form/lettings/pages/referral_supported_housing.rb
  51. 1
      app/models/form/lettings/pages/referral_supported_housing_prp.rb
  52. 2
      app/models/form/lettings/pages/rent_type.rb
  53. 35
      app/models/form/lettings/pages/rent_value_check.rb
  54. 1
      app/models/form/lettings/pages/scheme.rb
  55. 1
      app/models/form/lettings/pages/starter_tenancy_type.rb
  56. 1
      app/models/form/lettings/pages/tenancy_length.rb
  57. 1
      app/models/form/lettings/pages/tenancy_length_affordable_rent.rb
  58. 1
      app/models/form/lettings/pages/tenancy_length_intermediate_rent.rb
  59. 1
      app/models/form/lettings/pages/tenancy_length_periodic.rb
  60. 1
      app/models/form/lettings/pages/tenancy_type.rb
  61. 2
      app/models/form/lettings/pages/type_of_access_needs.rb
  62. 1
      app/models/form/lettings/pages/uprn.rb
  63. 1
      app/models/form/lettings/pages/uprn_selection.rb
  64. 1
      app/models/form/lettings/pages/void_date.rb
  65. 3
      app/models/form/lettings/questions/address_line1.rb
  66. 3
      app/models/form/lettings/questions/address_line1_for_address_matcher.rb
  67. 2
      app/models/form/lettings/questions/address_line2.rb
  68. 8
      app/models/form/lettings/questions/age.rb
  69. 3
      app/models/form/lettings/questions/age1.rb
  70. 11
      app/models/form/lettings/questions/age1_known.rb
  71. 4
      app/models/form/lettings/questions/age_known.rb
  72. 3
      app/models/form/lettings/questions/armedforces.rb
  73. 6
      app/models/form/lettings/questions/beds.rb
  74. 3
      app/models/form/lettings/questions/builtype.rb
  75. 3
      app/models/form/lettings/questions/condition_effects.rb
  76. 3
      app/models/form/lettings/questions/county.rb
  77. 2
      app/models/form/lettings/questions/created_by_id.rb
  78. 4
      app/models/form/lettings/questions/declaration.rb
  79. 3
      app/models/form/lettings/questions/details_known.rb
  80. 4
      app/models/form/lettings/questions/ethnic_arab.rb
  81. 4
      app/models/form/lettings/questions/ethnic_asian.rb
  82. 4
      app/models/form/lettings/questions/ethnic_black.rb
  83. 3
      app/models/form/lettings/questions/ethnic_group.rb
  84. 4
      app/models/form/lettings/questions/ethnic_mixed.rb
  85. 4
      app/models/form/lettings/questions/ethnic_white.rb
  86. 3
      app/models/form/lettings/questions/first_time_property_let_as_social_housing.rb
  87. 10
      app/models/form/lettings/questions/gender_identity1.rb
  88. 3
      app/models/form/lettings/questions/hhmemb.rb
  89. 3
      app/models/form/lettings/questions/homeless.rb
  90. 3
      app/models/form/lettings/questions/housingneeds.rb
  91. 4
      app/models/form/lettings/questions/housingneeds_other.rb
  92. 4
      app/models/form/lettings/questions/housingneeds_type.rb
  93. 3
      app/models/form/lettings/questions/illness.rb
  94. 3
      app/models/form/lettings/questions/irproduct_other.rb
  95. 3
      app/models/form/lettings/questions/joint.rb
  96. 2
      app/models/form/lettings/questions/la.rb
  97. 3
      app/models/form/lettings/questions/layear.rb
  98. 3
      app/models/form/lettings/questions/leftreg.rb
  99. 3
      app/models/form/lettings/questions/letting_allocation.rb
  100. 11
      app/models/form/lettings/questions/location_id.rb
  101. Some files were not shown because too many files have changed in this diff Show More

4
Gemfile.lock

@ -377,8 +377,7 @@ GEM
responders (3.1.1) responders (3.1.1)
actionpack (>= 5.2) actionpack (>= 5.2)
railties (>= 5.2) railties (>= 5.2)
rexml (3.3.6) rexml (3.3.9)
strscan
roo (2.10.1) roo (2.10.1)
nokogiri (~> 1) nokogiri (~> 1)
rubyzip (>= 1.3.0, < 3.0.0) rubyzip (>= 1.3.0, < 3.0.0)
@ -463,7 +462,6 @@ GEM
smart_properties (1.17.0) smart_properties (1.17.0)
stimulus-rails (1.3.3) stimulus-rails (1.3.3)
railties (>= 6.0.0) railties (>= 6.0.0)
strscan (3.1.0)
thor (1.3.2) thor (1.3.2)
thread_safe (0.3.6) thread_safe (0.3.6)
timecop (0.9.8) timecop (0.9.8)

30
app/components/bulk_upload_error_row_component.html.erb

@ -13,7 +13,7 @@
<% if critical_errors.any? %> <% if critical_errors.any? %>
<h2 class="govuk-heading-m">Critical errors</h2> <h2 class="govuk-heading-m">Critical errors</h2>
<p class="govuk-body">These errors must be fixed to complete your logs.</p> <p class="govuk-body">These errors must be fixed to complete your logs.</p>
<%= govuk_table do |table| %> <%= govuk_table(html_attributes: { class: potential_errors.any? ? "" : "no-bottom-border" }) do |table| %>
<%= table.with_head do |head| %> <%= table.with_head do |head| %>
<% head.with_row do |row| %> <% head.with_row do |row| %>
<% row.with_cell(header: true, text: "Cell") %> <% row.with_cell(header: true, text: "Cell") %>
@ -39,7 +39,7 @@
<% if potential_errors.any? %> <% if potential_errors.any? %>
<h2 class="govuk-heading-m">Potential errors</h2> <h2 class="govuk-heading-m">Potential errors</h2>
<p class="govuk-body">The following groups of cells might have conflicting data. Check the answers and fix any incorrect data.<br><br>If the answers are correct, fix the critical errors and reupload the file. You'll need to confirm that the following data is correct when the file only contains potential errors.</p> <p class="govuk-body">The following groups of cells might have conflicting data. Check the answers and fix any incorrect data.<br><br>If the answers are correct, fix the critical errors and reupload the file. You'll need to confirm that the following data is correct when the file only contains potential errors.</p>
<%= govuk_table do |table| %> <%= govuk_table(html_attributes: { class: "no-bottom-border" }) do |table| %>
<%= table.with_head do |head| %> <%= table.with_head do |head| %>
<% head.with_row do |row| %> <% head.with_row do |row| %>
<% row.with_cell(header: true, text: "Cell") %> <% row.with_cell(header: true, text: "Cell") %>
@ -49,24 +49,24 @@
<% end %> <% end %>
<% end %> <% end %>
<%= table.with_body do |body| %> <%= table.with_body do |body| %>
<% potential_errors.group_by(&:error).each do |error_message, errors| %> <% potential_errors.group_by(&:error).each_with_index do |(error_message, errors), group_index| %>
<% errors.each_with_index do |error, index| %> <% total_groups = potential_errors.group_by(&:error).size %>
<% row_class = "grouped-rows" %> <% errors.each_with_index do |error, index| %>
<% row_class += " first-row" if index.zero? %> <% row_class = row_classes(index, errors.size) %>
<% row_class += " last-row" if index == errors.size - 1 %> <% body.with_row(html_attributes: { class: row_class }) do |row| %>
<% body.with_row(html_attributes: { class: row_class }) do |row| %> <% row.with_cell(text: error.cell) %>
<% row.with_cell(text: error.cell) %> <% row.with_cell(text: question_for_field(error.field), html_attributes: { class: "govuk-!-width-one-half" }) %>
<% row.with_cell(text: question_for_field(error.field), html_attributes: { class: "govuk-!-width-one-half" }) %> <% if index == 0 %>
<% if index == 0 %> <% cell_class = cell_classes(group_index, total_groups) %>
<% row.with_cell(text: error_message.html_safe, rowspan: errors.size, html_attributes: { class: "govuk-!-font-weight-bold govuk-!-width-one-half grouped-multirow-cell" }) %> <% row.with_cell(text: error_message.html_safe, rowspan: errors.size, html_attributes: { class: cell_class }) %>
<% end %>
<% row.with_cell(text: error.field.humanize) %>
<% end %> <% end %>
<% row.with_cell(text: error.field.humanize) %>
<% end %> <% end %>
<% end %> <% end %>
<% end %> <% end %>
<% end %> <% end %>
<% end %>
<% end %> <% end %>
</div> </div>
</div> </div>

13
app/components/bulk_upload_error_row_component.rb

@ -62,4 +62,17 @@ class BulkUploadErrorRowComponent < ViewComponent::Base
def sales? def sales?
bulk_upload.log_type == "sales" bulk_upload.log_type == "sales"
end end
def row_classes(index, errors_size)
row_class = "grouped-rows"
row_class += " first-row" if index.zero?
row_class += " last-row" if index == errors_size - 1
row_class
end
def cell_classes(group_index, total_groups)
cell_class = "govuk-!-font-weight-bold govuk-!-width-one-half"
cell_class += " grouped-multirow-cell" unless group_index == total_groups - 1
cell_class
end
end end

2
app/components/bulk_upload_summary_component.html.erb

@ -4,7 +4,7 @@
<header class="app-log-summary__header"> <header class="app-log-summary__header">
<h2 class="govuk-heading-m govuk-!-font-weight-regular govuk-!-margin-bottom-0 text-normal-break "> <h2 class="govuk-heading-m govuk-!-font-weight-regular govuk-!-margin-bottom-0 text-normal-break ">
<span class="govuk-!-margin-right-1"><%= bulk_upload.filename %></span> <span class="govuk-!-margin-right-1"><%= bulk_upload.filename %></span>
<span class="app-metadata app-log-summary__details" style="white-space: nowrap;"><%= bulk_upload.year %>/<%= bulk_upload.year + 1 %></span> <span class="app-metadata app-log-summary__details" style="white-space: nowrap;"><%= bulk_upload.year %> to <%= bulk_upload.year + 1 %></span>
</h2> </h2>
</header> </header>
<div class="govuk-!-margin-bottom-2"> <div class="govuk-!-margin-bottom-2">

4
app/components/document_list_component.html.erb

@ -1,4 +1,6 @@
<h3 class="govuk-heading-m"><%= label %></h3> <% unless label.blank? %>
<h3 class="govuk-heading-m"><%= label %></h3>
<% end %>
<dl class="app-document-list"> <dl class="app-document-list">
<% items.each do |item| %> <% items.each do |item| %>
<div class="app-document-list__item"> <div class="app-document-list__item">

2
app/constants/global_constants.rb

@ -1,5 +1,5 @@
module GlobalConstants module GlobalConstants
HELPDESK_URL = "https://dluhcdigital.atlassian.net/servicedesk/customer/portal/6/group/11".freeze HELPDESK_URL = "https://mhclgdigital.atlassian.net/servicedesk/customer/portal/6/group/11".freeze
COUNTRIES_ANSWER_OPTIONS = { COUNTRIES_ANSWER_OPTIONS = {
"" => "Select an option", "" => "Select an option",

153
app/controllers/collection_resources_controller.rb

@ -1,13 +1,15 @@
class CollectionResourcesController < ApplicationController class CollectionResourcesController < ApplicationController
include CollectionResourcesHelper include CollectionResourcesHelper
before_action :authenticate_user!, except: %i[download_mandatory_collection_resource] before_action :authenticate_user!, except: %i[download_mandatory_collection_resource download_additional_collection_resource]
def index def index
render_not_found unless current_user.support? render_not_found unless current_user.support?
@mandatory_lettings_collection_resources_per_year = MandatoryCollectionResourcesService.generate_resources("lettings", editable_collection_resource_years) @mandatory_lettings_collection_resources_per_year = MandatoryCollectionResourcesService.generate_resources("lettings", editable_collection_resource_years)
@mandatory_sales_collection_resources_per_year = MandatoryCollectionResourcesService.generate_resources("sales", editable_collection_resource_years) @mandatory_sales_collection_resources_per_year = MandatoryCollectionResourcesService.generate_resources("sales", editable_collection_resource_years)
@additional_lettings_collection_resources_per_year = CollectionResource.visible.where(log_type: "lettings", mandatory: false).group_by(&:year)
@additional_sales_collection_resources_per_year = CollectionResource.visible.where(log_type: "sales", mandatory: false).group_by(&:year)
end end
def download_mandatory_collection_resource def download_mandatory_collection_resource
@ -23,8 +25,17 @@ class CollectionResourcesController < ApplicationController
download_resource(resource.download_filename) download_resource(resource.download_filename)
end end
def edit def download_additional_collection_resource
return render_not_found unless current_user.support? resource = CollectionResource.find_by(id: params[:collection_resource_id])
return render_not_found unless resource
return render_not_found unless resource_for_year_can_be_downloaded?(resource.year)
download_resource(resource.download_filename)
end
def edit_mandatory_collection_resource
return render_not_authorized unless current_user.support?
year = params[:year].to_i year = params[:year].to_i
resource_type = params[:resource_type] resource_type = params[:resource_type]
@ -39,8 +50,19 @@ class CollectionResourcesController < ApplicationController
render "collection_resources/edit" render "collection_resources/edit"
end end
def update def edit_additional_collection_resource
return render_not_found unless current_user.support? return render_not_authorized unless current_user.support?
@collection_resource = CollectionResource.find_by(id: params[:collection_resource_id])
return render_not_found unless @collection_resource
return render_not_found unless resource_for_year_can_be_updated?(@collection_resource.year)
render "collection_resources/edit"
end
def update_mandatory_collection_resource
return render_not_authorized unless current_user.support?
year = resource_params[:year].to_i year = resource_params[:year].to_i
resource_type = resource_params[:resource_type] resource_type = resource_params[:resource_type]
@ -52,7 +74,8 @@ class CollectionResourcesController < ApplicationController
@collection_resource = MandatoryCollectionResourcesService.generate_resource(log_type, year, resource_type) @collection_resource = MandatoryCollectionResourcesService.generate_resource(log_type, year, resource_type)
render_not_found unless @collection_resource render_not_found unless @collection_resource
validate_file(file) @collection_resource.file = file
@collection_resource.validate_attached_file
return render "collection_resources/edit" if @collection_resource.errors.any? return render "collection_resources/edit" if @collection_resource.errors.any?
@ -68,8 +91,38 @@ class CollectionResourcesController < ApplicationController
redirect_to collection_resources_path redirect_to collection_resources_path
end end
def update_additional_collection_resource
return render_not_authorized unless current_user.support?
@collection_resource = CollectionResource.find_by(id: params[:collection_resource_id])
return render_not_found unless @collection_resource
return render_not_found unless resource_for_year_can_be_updated?(@collection_resource.year)
@collection_resource.file = resource_params[:file]
@collection_resource.validate_attached_file
@collection_resource.validate_short_display_name
return render "collection_resources/edit" if @collection_resource.errors.any?
@collection_resource.short_display_name = resource_params[:short_display_name]
@collection_resource.download_filename = @collection_resource.file&.original_filename
@collection_resource.display_name = "#{@collection_resource.log_type} #{@collection_resource.short_display_name} (#{text_year_range_format(@collection_resource.year)})"
if @collection_resource.save
begin
CollectionResourcesService.new.upload_collection_resource(@collection_resource.download_filename, @collection_resource.file)
flash[:notice] = "The #{@collection_resource.log_type} #{text_year_range_format(@collection_resource.year)} #{@collection_resource.short_display_name.downcase} has been updated."
redirect_to collection_resources_path
rescue StandardError
@collection_resource.errors.add(:file, :error_uploading)
render "collection_resources/edit"
end
else
render "collection_resources/edit"
end
end
def confirm_mandatory_collection_resources_release def confirm_mandatory_collection_resources_release
return render_not_found unless current_user.support? return render_not_authorized unless current_user.support?
@year = params[:year].to_i @year = params[:year].to_i
@ -79,7 +132,7 @@ class CollectionResourcesController < ApplicationController
end end
def release_mandatory_collection_resources def release_mandatory_collection_resources
return render_not_found unless current_user.support? return render_not_authorized unless current_user.support?
year = params[:year].to_i year = params[:year].to_i
@ -91,10 +144,73 @@ class CollectionResourcesController < ApplicationController
redirect_to collection_resources_path redirect_to collection_resources_path
end end
def new
return render_not_authorized unless current_user.support?
year = params[:year].to_i
log_type = params[:log_type]
return render_not_found unless editable_collection_resource_years.include?(year)
@collection_resource = CollectionResource.new(year:, log_type:)
end
def create
return render_not_authorized unless current_user.support? && editable_collection_resource_years.include?(resource_params[:year].to_i)
@collection_resource = CollectionResource.new(resource_params)
@collection_resource.download_filename ||= @collection_resource.file&.original_filename
@collection_resource.display_name = "#{@collection_resource.log_type} #{@collection_resource.short_display_name} (#{text_year_range_format(@collection_resource.year)})"
@collection_resource.validate_attached_file
@collection_resource.validate_short_display_name
return render "collection_resources/new" if @collection_resource.errors.any?
if @collection_resource.save
begin
CollectionResourcesService.new.upload_collection_resource(@collection_resource.download_filename, @collection_resource.file)
flash[:notice] = if displayed_collection_resource_years.include?(@collection_resource.year)
"The #{@collection_resource.log_type} #{text_year_range_format(@collection_resource.year)} #{@collection_resource.short_display_name} is now available to users."
else
"The #{@collection_resource.log_type} #{text_year_range_format(@collection_resource.year)} #{@collection_resource.short_display_name} has been uploaded."
end
redirect_to collection_resources_path
rescue StandardError
@collection_resource.errors.add(:file, :error_uploading)
render "collection_resources/new"
end
else
render "collection_resources/new"
end
end
def delete_confirmation
return render_not_authorized unless current_user.support?
@collection_resource = CollectionResource.find_by(id: params[:collection_resource_id])
return render_not_found unless @collection_resource
render "collection_resources/delete_confirmation"
end
def delete
return render_not_authorized unless current_user.support?
@collection_resource = CollectionResource.find_by(id: params[:collection_resource_id])
return render_not_found unless @collection_resource
@collection_resource.discard!
flash[:notice] = "The #{@collection_resource.log_type} #{text_year_range_format(@collection_resource.year)} #{@collection_resource.short_display_name.downcase} has been deleted."
redirect_to collection_resources_path
end
private private
def resource_params def resource_params
params.require(:collection_resource).permit(:year, :log_type, :resource_type, :file) params.require(:collection_resource).permit(:year, :log_type, :resource_type, :file, :mandatory, :short_display_name)
end end
def download_resource(filename) def download_resource(filename)
@ -113,23 +229,4 @@ private
def resource_for_year_can_be_updated?(year) def resource_for_year_can_be_updated?(year)
editable_collection_resource_years.include?(year) editable_collection_resource_years.include?(year)
end end
def validate_file(file)
return @collection_resource.errors.add(:file, :blank) unless file
return @collection_resource.errors.add(:file, :above_100_mb) if file.size > 100.megabytes
argv = %W[file --brief --mime-type -- #{file.path}]
output = `#{argv.shelljoin}`
case @collection_resource.resource_type
when "paper_form"
unless output.match?(/application\/pdf/)
@collection_resource.errors.add(:file, :must_be_pdf)
end
when "bulk_upload_template", "bulk_upload_specification"
unless output.match?(/application\/vnd\.ms-excel|application\/vnd\.openxmlformats-officedocument\.spreadsheetml\.sheet/)
@collection_resource.errors.add(:file, :must_be_xlsx, resource: @collection_resource.short_display_name.downcase)
end
end
end
end end

2
app/controllers/lettings_logs_controller.rb

@ -65,7 +65,7 @@ class LettingsLogsController < LogsController
elsif @log.collection_closed_for_editing? elsif @log.collection_closed_for_editing?
redirect_to review_lettings_log_path(@log) redirect_to review_lettings_log_path(@log)
else else
render("logs/edit", locals: { current_user: }) render("logs/edit", locals: { current_user:, bulk_upload_filter_applied: session_filters["bulk_upload_id"].present? })
end end
end end

2
app/controllers/sales_logs_controller.rb

@ -39,7 +39,7 @@ class SalesLogsController < LogsController
if @log.collection_closed_for_editing? if @log.collection_closed_for_editing?
redirect_to review_sales_log_path(@log, sales_log: true) redirect_to review_sales_log_path(@log, sales_log: true)
else else
render "logs/edit", locals: { current_user: } render "logs/edit", locals: { current_user:, bulk_upload_filter_applied: session_filters["bulk_upload_id"].present? }
end end
end end

2
app/controllers/start_controller.rb

@ -4,6 +4,8 @@ class StartController < ApplicationController
def index def index
@mandatory_lettings_collection_resources_per_year = MandatoryCollectionResourcesService.generate_resources("lettings", displayed_collection_resource_years) @mandatory_lettings_collection_resources_per_year = MandatoryCollectionResourcesService.generate_resources("lettings", displayed_collection_resource_years)
@mandatory_sales_collection_resources_per_year = MandatoryCollectionResourcesService.generate_resources("sales", displayed_collection_resource_years) @mandatory_sales_collection_resources_per_year = MandatoryCollectionResourcesService.generate_resources("sales", displayed_collection_resource_years)
@additional_lettings_collection_resources_per_year = CollectionResource.visible.where(log_type: "lettings", mandatory: false, year: displayed_collection_resource_years).group_by(&:year)
@additional_sales_collection_resources_per_year = CollectionResource.visible.where(log_type: "sales", mandatory: false, year: displayed_collection_resource_years).group_by(&:year)
if current_user if current_user
@homepage_presenter = HomepagePresenter.new(current_user) @homepage_presenter = HomepagePresenter.new(current_user)
render "home/index" render "home/index"

17
app/controllers/users_controller.rb

@ -257,13 +257,7 @@ private
def user_params def user_params
if @user == current_user if @user == current_user
if current_user.data_coordinator? current_user_params
params.require(:user).permit(:email, :phone, :phone_extension, :name, :password, :password_confirmation, :role, :is_dpo, :is_key_contact, :initial_confirmation_sent)
elsif current_user.support?
params.require(:user).permit(:email, :phone, :phone_extension, :name, :password, :password_confirmation, :role, :is_dpo, :is_key_contact, :initial_confirmation_sent, :organisation_id)
else
params.require(:user).permit(:email, :phone, :phone_extension, :name, :password, :password_confirmation, :initial_confirmation_sent)
end
elsif current_user.data_coordinator? elsif current_user.data_coordinator?
params.require(:user).permit(:email, :phone, :phone_extension, :name, :role, :is_dpo, :is_key_contact, :active, :initial_confirmation_sent) params.require(:user).permit(:email, :phone, :phone_extension, :name, :role, :is_dpo, :is_key_contact, :active, :initial_confirmation_sent)
elsif current_user.support? elsif current_user.support?
@ -271,6 +265,15 @@ private
end end
end end
def current_user_params
base_params = %i[email phone phone_extension name password password_confirmation initial_confirmation_sent]
return params.require(:user).permit(*(base_params + %i[role is_dpo is_key_contact])) if current_user.data_coordinator?
return params.require(:user).permit(*(base_params + %i[role is_dpo is_key_contact organisation_id])) if current_user.support?
return params.require(:user).permit(*(base_params + [:role])) if Rails.env.staging? && current_user.in_staging_role_update_email_allowlist?
params.require(:user).permit(*base_params)
end
def user_params_without_org def user_params_without_org
user_params.except(:organisation_id) user_params.except(:organisation_id)
end end

5
app/frontend/styles/_bulk-uploads.scss

@ -12,6 +12,11 @@
border-bottom: 1px solid #b1b4b6; border-bottom: 1px solid #b1b4b6;
} }
.no-bottom-border,
.no-bottom-border > tbody > tr:last-of-type td {
border-bottom: none;
}
.text-normal-break { .text-normal-break {
white-space: normal; white-space: normal;
word-break: break-all; word-break: break-all;

1
app/frontend/styles/_document-list.scss

@ -1,5 +1,4 @@
.app-document-list { .app-document-list {
margin-top: govuk-spacing(3);
margin-bottom: govuk-spacing(6); margin-bottom: govuk-spacing(6);
} }

2
app/helpers/collection_resources_helper.rb

@ -49,7 +49,7 @@ module CollectionResourcesHelper
def document_list_component_items(resources) def document_list_component_items(resources)
resources.map do |resource| resources.map do |resource|
{ {
name: "Download the #{resource.display_name}", name: "Download the #{resource.display_name.downcase}",
href: resource.download_path, href: resource.download_path,
metadata: file_type_size_and_pages(resource.download_filename), metadata: file_type_size_and_pages(resource.download_filename),
} }

2
app/helpers/filters_helper.rb

@ -287,7 +287,7 @@ private
end end
def year_combo(year) def year_combo(year)
"#{year}/#{year - 2000 + 1}" "#{year} to #{year + 1}"
end end
def formatted_years_filter(session_filters) def formatted_years_filter(session_filters)

3
app/helpers/formatting_helper.rb

@ -2,7 +2,8 @@ module FormattingHelper
def format_ending(text) def format_ending(text)
return text if text.blank? return text if text.blank?
modified_text = lowercase_first_letter(text) first_word = text.split.first
modified_text = first_word == first_word.upcase ? text : lowercase_first_letter(text)
ensure_sentence_ending(modified_text) ensure_sentence_ending(modified_text)
end end

8
app/helpers/log_actions_helper.rb

@ -2,8 +2,8 @@ module LogActionsHelper
include GovukLinkHelper include GovukLinkHelper
include GovukVisuallyHiddenHelper include GovukVisuallyHiddenHelper
def edit_actions_for_log(log) def edit_actions_for_log(log, bulk_upload_filter_applied)
back = back_button_for(log) back = back_button_for(log, bulk_upload_filter_applied)
delete = delete_button_for_log(log) delete = delete_button_for_log(log)
return if back.nil? && delete.nil? return if back.nil? && delete.nil?
@ -15,9 +15,9 @@ module LogActionsHelper
private private
def back_button_for(log) def back_button_for(log, bulk_upload_filter_applied)
if log.completed? if log.completed?
if log.creation_method_bulk_upload? && log.bulk_upload.present? if log.creation_method_bulk_upload? && log.bulk_upload.present? && bulk_upload_filter_applied
if log.lettings? if log.lettings?
govuk_button_link_to "Back to uploaded logs", resume_bulk_upload_lettings_result_path(log.bulk_upload) govuk_button_link_to "Back to uploaded logs", resume_bulk_upload_lettings_result_path(log.bulk_upload)
else else

2
app/helpers/merge_requests_helper.rb

@ -9,7 +9,7 @@ module MergeRequestsHelper
def request_details(merge_request) def request_details(merge_request)
[ [
{ label: "Requester", value: display_value_or_placeholder(merge_request.requester&.name) }, { label: "Requester", value: display_value_or_placeholder(merge_request.requester&.name) },
{ label: "Helpdesk ticket", value: merge_request.helpdesk_ticket.present? ? link_to("#{merge_request.helpdesk_ticket} (opens in a new tab)", "https://dluhcdigital.atlassian.net/browse/#{merge_request.helpdesk_ticket}", target: "_blank", rel: "noopener noreferrer") : display_value_or_placeholder(nil), action: merge_request_action(merge_request, "helpdesk_ticket") }, { label: "Helpdesk ticket", value: merge_request.helpdesk_ticket.present? ? link_to("#{merge_request.helpdesk_ticket} (opens in a new tab)", "https://mhclgdigital.atlassian.net/browse/#{merge_request.helpdesk_ticket}", target: "_blank", rel: "noopener noreferrer") : display_value_or_placeholder(nil), action: merge_request_action(merge_request, "helpdesk_ticket") },
{ label: "Status", value: status_tag(merge_request.status) }, { label: "Status", value: status_tag(merge_request.status) },
] ]
end end

2
app/helpers/review_helper.rb

@ -6,7 +6,7 @@ module ReviewHelper
"You can review and make changes to this log until #{log.form.submission_deadline.to_formatted_s(:govuk_date)}.".html_safe "You can review and make changes to this log until #{log.form.submission_deadline.to_formatted_s(:govuk_date)}.".html_safe
else else
start_year = log.startdate ? collection_start_year_for_date(log.startdate) : log.form.start_date.year start_year = log.startdate ? collection_start_year_for_date(log.startdate) : log.form.start_date.year
"This log is from the #{start_year}/#{start_year + 1} collection window, which is now closed." "This log is from the #{start_year} to #{start_year + 1} collection window, which is now closed."
end end
end end

2
app/helpers/tasklist_helper.rb

@ -55,7 +55,7 @@ module TasklistHelper
else else
start_year = log.startdate ? collection_start_year_for_date(log.startdate) : log.form.start_date.year start_year = log.startdate ? collection_start_year_for_date(log.startdate) : log.form.start_date.year
"This log is from the #{start_year}/#{start_year + 1} collection window, which is now closed." "This log is from the #{start_year} to #{start_year + 1} collection window, which is now closed."
end end
end end

2
app/models/bulk_upload.rb

@ -59,7 +59,7 @@ class BulkUpload < ApplicationRecord
end end
def year_combo def year_combo
"#{year}/#{year - 2000 + 1}" "#{year} to #{year + 1}"
end end
def end_year def end_year

38
app/models/collection_resource.rb

@ -1,9 +1,45 @@
class CollectionResource < ApplicationRecord class CollectionResource < ApplicationRecord
include Rails.application.routes.url_helpers include Rails.application.routes.url_helpers
has_paper_trail
attr_accessor :file attr_accessor :file
scope :visible, -> { where(discarded_at: nil) }
validates :short_display_name, presence: true
def download_path def download_path
download_mandatory_collection_resource_path(log_type:, year:, resource_type:) if mandatory
download_mandatory_collection_resource_path(log_type:, year:, resource_type:)
else
collection_resource_download_path(self)
end
end
def validate_attached_file
return errors.add(:file, :blank) unless file
return errors.add(:file, :above_100_mb) if file.size > 100.megabytes
argv = %W[file --brief --mime-type -- #{file.path}]
output = `#{argv.shelljoin}`
case resource_type
when "paper_form"
unless output.match?(/application\/pdf/)
errors.add(:file, :must_be_pdf)
end
when "bulk_upload_template", "bulk_upload_specification"
unless output.match?(/application\/vnd\.ms-excel|application\/vnd\.openxmlformats-officedocument\.spreadsheetml\.sheet/)
errors.add(:file, :must_be_xlsx, resource: short_display_name.downcase)
end
end
end
def validate_short_display_name
errors.add(:short_display_name, :blank) if short_display_name.blank?
end
def discard!
CollectionResourcesService.new.delete_collection_resource(download_filename)
update!(discarded_at: Time.zone.now)
end end
end end

2
app/models/form/lettings/pages/address.rb

@ -2,7 +2,7 @@ class Form::Lettings::Pages::Address < ::Form::Page
def initialize(id, hsh, subsection) def initialize(id, hsh, subsection)
super super
@id = "address" @id = "address"
@header = "Q#{QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]} - What is the property's address?" @copy_key = "lettings.property_information.address"
@depends_on = [ @depends_on = [
{ "is_supported_housing?" => false, "uprn_known" => nil }, { "is_supported_housing?" => false, "uprn_known" => nil },
{ "is_supported_housing?" => false, "uprn_known" => 0 }, { "is_supported_housing?" => false, "uprn_known" => 0 },

2
app/models/form/lettings/pages/address_fallback.rb

@ -2,7 +2,7 @@ class Form::Lettings::Pages::AddressFallback < ::Form::Page
def initialize(id, hsh, subsection) def initialize(id, hsh, subsection)
super super
@id = "address" @id = "address"
@header = "Q12 - What is the property's address?" @copy_key = "lettings.property_information.address"
@depends_on = [ @depends_on = [
{ "is_supported_housing?" => false, "uprn_known" => nil, "uprn_selection" => "uprn_not_listed" }, { "is_supported_housing?" => false, "uprn_known" => nil, "uprn_selection" => "uprn_not_listed" },
{ "is_supported_housing?" => false, "uprn_known" => 0, "uprn_selection" => "uprn_not_listed" }, { "is_supported_housing?" => false, "uprn_known" => 0, "uprn_selection" => "uprn_not_listed" },

2
app/models/form/lettings/pages/address_matcher.rb

@ -2,7 +2,7 @@ class Form::Lettings::Pages::AddressMatcher < ::Form::Page
def initialize(id, hsh, subsection) def initialize(id, hsh, subsection)
super super
@id = "address_matcher" @id = "address_matcher"
@header = "Find an address" @copy_key = "lettings.property_information.address_matcher"
@depends_on = [ @depends_on = [
{ "is_supported_housing?" => false, "uprn_known" => nil }, { "is_supported_housing?" => false, "uprn_known" => nil },
{ "is_supported_housing?" => false, "uprn_known" => 0 }, { "is_supported_housing?" => false, "uprn_known" => 0 },

1
app/models/form/lettings/pages/declaration.rb

@ -2,7 +2,6 @@ class Form::Lettings::Pages::Declaration < ::Form::Page
def initialize(id, hsh, subsection) def initialize(id, hsh, subsection)
super super
@id = "declaration" @id = "declaration"
@header = "Ministry of Housing, Communities and Local Government privacy notice"
end end
def questions def questions

1
app/models/form/lettings/pages/lead_tenant_age.rb

@ -2,6 +2,7 @@ class Form::Lettings::Pages::LeadTenantAge < ::Form::Page
def initialize(id, hsh, subsection) def initialize(id, hsh, subsection)
super super
@id = "lead_tenant_age" @id = "lead_tenant_age"
@copy_key = "lettings.household_characteristics.age1"
@depends_on = [{ "declaration" => 1 }] @depends_on = [{ "declaration" => 1 }]
end end

1
app/models/form/lettings/pages/lead_tenant_ethnic_background_arab.rb

@ -2,6 +2,7 @@ class Form::Lettings::Pages::LeadTenantEthnicBackgroundArab < ::Form::Page
def initialize(id, hsh, subsection) def initialize(id, hsh, subsection)
super super
@id = "lead_tenant_ethnic_background_arab" @id = "lead_tenant_ethnic_background_arab"
@copy_key = "lettings.household_characteristics.ethnic.ethnic_background_arab"
@depends_on = [{ "ethnic_group" => 4 }] @depends_on = [{ "ethnic_group" => 4 }]
end end

1
app/models/form/lettings/pages/lead_tenant_ethnic_background_asian.rb

@ -2,6 +2,7 @@ class Form::Lettings::Pages::LeadTenantEthnicBackgroundAsian < ::Form::Page
def initialize(id, hsh, subsection) def initialize(id, hsh, subsection)
super super
@id = "lead_tenant_ethnic_background_asian" @id = "lead_tenant_ethnic_background_asian"
@copy_key = "lettings.household_characteristics.ethnic.ethnic_background_asian"
@depends_on = [{ "ethnic_group" => 2 }] @depends_on = [{ "ethnic_group" => 2 }]
end end

1
app/models/form/lettings/pages/lead_tenant_ethnic_background_black.rb

@ -2,6 +2,7 @@ class Form::Lettings::Pages::LeadTenantEthnicBackgroundBlack < ::Form::Page
def initialize(id, hsh, subsection) def initialize(id, hsh, subsection)
super super
@id = "lead_tenant_ethnic_background_black" @id = "lead_tenant_ethnic_background_black"
@copy_key = "lettings.household_characteristics.ethnic.ethnic_background_black"
@depends_on = [{ "ethnic_group" => 3 }] @depends_on = [{ "ethnic_group" => 3 }]
end end

1
app/models/form/lettings/pages/lead_tenant_ethnic_background_mixed.rb

@ -2,6 +2,7 @@ class Form::Lettings::Pages::LeadTenantEthnicBackgroundMixed < ::Form::Page
def initialize(id, hsh, subsection) def initialize(id, hsh, subsection)
super super
@id = "lead_tenant_ethnic_background_mixed" @id = "lead_tenant_ethnic_background_mixed"
@copy_key = "lettings.household_characteristics.ethnic.ethnic_background_mixed"
@depends_on = [{ "ethnic_group" => 1 }] @depends_on = [{ "ethnic_group" => 1 }]
end end

1
app/models/form/lettings/pages/lead_tenant_ethnic_background_white.rb

@ -2,6 +2,7 @@ class Form::Lettings::Pages::LeadTenantEthnicBackgroundWhite < ::Form::Page
def initialize(id, hsh, subsection) def initialize(id, hsh, subsection)
super super
@id = "lead_tenant_ethnic_background_white" @id = "lead_tenant_ethnic_background_white"
@copy_key = "lettings.household_characteristics.ethnic.ethnic_background_white"
@depends_on = [{ "ethnic_group" => 0 }] @depends_on = [{ "ethnic_group" => 0 }]
end end

1
app/models/form/lettings/pages/lead_tenant_nationality.rb

@ -2,6 +2,7 @@ class Form::Lettings::Pages::LeadTenantNationality < ::Form::Page
def initialize(id, hsh, subsection) def initialize(id, hsh, subsection)
super super
@id = "lead_tenant_nationality" @id = "lead_tenant_nationality"
@copy_key = "lettings.household_characteristics.#{form.start_year_after_2024? ? 'nationality_all' : 'national'}"
@depends_on = [{ "declaration" => 1 }] @depends_on = [{ "declaration" => 1 }]
end end

2
app/models/form/lettings/pages/location.rb

@ -8,7 +8,7 @@ class Form::Lettings::Pages::Location < ::Form::Page
"scheme_has_large_number_of_locations?" => false, "scheme_has_large_number_of_locations?" => false,
}, },
] ]
@header = "Location" @copy_key = "lettings.setup.location_id.less_than_twenty"
@next_unresolved_page_id = :check_answers @next_unresolved_page_id = :check_answers
end end

2
app/models/form/lettings/pages/location_search.rb

@ -8,7 +8,7 @@ class Form::Lettings::Pages::LocationSearch < ::Form::Page
"scheme_has_large_number_of_locations?" => true, "scheme_has_large_number_of_locations?" => true,
}, },
] ]
@header = "Location" @copy_key = "lettings.setup.location_id.twenty_or_more"
@next_unresolved_page_id = :check_answers @next_unresolved_page_id = :check_answers
end end

24
app/models/form/lettings/pages/max_rent_value_check.rb

@ -1,24 +0,0 @@
class Form::Lettings::Pages::MaxRentValueCheck < ::Form::Page
def initialize(id, hsh, subsection, check_answers_card_number: nil)
super(id, hsh, subsection)
@depends_on = [{ "rent_in_soft_max_range?" => true }]
@title_text = {
"translation" => "soft_validations.rent.outside_range_title",
"arguments" => [{
"key" => "brent",
"label" => true,
"i18n_template" => "brent",
}],
}
@informative_text = I18n.t("soft_validations.rent.informative_text", higher_or_lower: "higher")
@check_answers_card_number = check_answers_card_number
end
def questions
@questions ||= [Form::Lettings::Questions::MaxRentValueCheck.new(nil, nil, self, check_answers_card_number: @check_answers_card_number)]
end
def interruption_screen_question_ids
%w[brent period startdate uprn postcode_full la beds rent_type needstype]
end
end

24
app/models/form/lettings/pages/min_rent_value_check.rb

@ -1,24 +0,0 @@
class Form::Lettings::Pages::MinRentValueCheck < ::Form::Page
def initialize(id, hsh, subsection, check_answers_card_number: nil)
super(id, hsh, subsection)
@depends_on = [{ "rent_in_soft_min_range?" => true }]
@title_text = {
"translation" => "soft_validations.rent.outside_range_title",
"arguments" => [{
"key" => "brent",
"label" => true,
"i18n_template" => "brent",
}],
}
@informative_text = I18n.t("soft_validations.rent.informative_text", higher_or_lower: "lower")
@check_answers_card_number = check_answers_card_number
end
def questions
@questions ||= [Form::Lettings::Questions::MinRentValueCheck.new(nil, nil, self, check_answers_card_number: @check_answers_card_number)]
end
def interruption_screen_question_ids
%w[brent period startdate uprn postcode_full la beds rent_type needstype]
end
end

9
app/models/form/lettings/pages/person_age.rb

@ -1,13 +1,12 @@
class Form::Lettings::Pages::PersonAge < ::Form::Page class Form::Lettings::Pages::PersonAge < ::Form::Page
def initialize(id, hsh, subsection, person_index:, person_type: "non_child") def initialize(id, hsh, subsection, person_index:)
super(id, hsh, subsection) super(id, hsh, subsection)
@id = "person_#{person_index}_age_#{person_type}" @id = "person_#{person_index}_age"
@copy_key = "lettings.household_characteristics.age#{person_index}"
@person_index = person_index @person_index = person_index
@person_type = person_type
@depends_on = [ @depends_on = [
{ {
"details_known_#{person_index}" => 0, "details_known_#{person_index}" => 0,
"person_#{person_index}_child_relation?" => (person_type == "child"),
}, },
] ]
end end
@ -15,7 +14,7 @@ class Form::Lettings::Pages::PersonAge < ::Form::Page
def questions def questions
@questions ||= [ @questions ||= [
Form::Lettings::Questions::AgeKnown.new(nil, nil, self, person_index: @person_index), Form::Lettings::Questions::AgeKnown.new(nil, nil, self, person_index: @person_index),
Form::Lettings::Questions::Age.new(nil, nil, self, person_index: @person_index, person_type: @person_type), Form::Lettings::Questions::Age.new(nil, nil, self, person_index: @person_index),
] ]
end end
end end

1
app/models/form/lettings/pages/person_known.rb

@ -2,7 +2,6 @@ class Form::Lettings::Pages::PersonKnown < ::Form::Page
def initialize(id, hsh, subsection, person_index:) def initialize(id, hsh, subsection, person_index:)
super(id, hsh, subsection) super(id, hsh, subsection)
@id = "person_#{person_index}_known" @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 } } @depends_on = (person_index..8).map { |index| { "hhmemb" => index } }
@person_index = person_index @person_index = person_index
end end

1
app/models/form/lettings/pages/previous_housing_situation.rb

@ -2,6 +2,7 @@ class Form::Lettings::Pages::PreviousHousingSituation < ::Form::Page
def initialize(id, hsh, subsection) def initialize(id, hsh, subsection)
super super
@id = "previous_housing_situation" @id = "previous_housing_situation"
@copy_key = "lettings.household_situation.prevten.not_renewal"
@depends_on = [{ "is_renewal?" => false }] @depends_on = [{ "is_renewal?" => false }]
end end

1
app/models/form/lettings/pages/previous_housing_situation_renewal.rb

@ -2,6 +2,7 @@ class Form::Lettings::Pages::PreviousHousingSituationRenewal < ::Form::Page
def initialize(id, hsh, subsection) def initialize(id, hsh, subsection)
super super
@id = "previous_housing_situation_renewal" @id = "previous_housing_situation_renewal"
@copy_key = "lettings.household_situation.prevten.renewal"
@depends_on = [{ "is_renewal?" => true, "is_supported_housing?" => true }] @depends_on = [{ "is_renewal?" => true, "is_supported_housing?" => true }]
end end

1
app/models/form/lettings/pages/previous_local_authority.rb

@ -2,6 +2,7 @@ class Form::Lettings::Pages::PreviousLocalAuthority < ::Form::Page
def initialize(id, hsh, subsection) def initialize(id, hsh, subsection)
super super
@id = "previous_local_authority" @id = "previous_local_authority"
@copy_key = "lettings.household_situation.previous_local_authority"
@depends_on = [{ "is_previous_la_inferred" => false, "renewal" => 0 }] @depends_on = [{ "is_previous_la_inferred" => false, "renewal" => 0 }]
end end

1
app/models/form/lettings/pages/previous_postcode.rb

@ -2,6 +2,7 @@ class Form::Lettings::Pages::PreviousPostcode < ::Form::Page
def initialize(id, hsh, page) def initialize(id, hsh, page)
super super
@depends_on = [{ "renewal" => 0 }] @depends_on = [{ "renewal" => 0 }]
@copy_key = "lettings.household_situation.previous_postcode"
end end
def questions def questions

1
app/models/form/lettings/pages/property_major_repairs.rb

@ -2,6 +2,7 @@ class Form::Lettings::Pages::PropertyMajorRepairs < ::Form::Page
def initialize(id, hsh, subsection) def initialize(id, hsh, subsection)
super super
@id = "property_major_repairs" @id = "property_major_repairs"
@copy_key = "lettings.property_information.property_major_repairs"
@depends_on = [{ "is_renewal?" => false, "vacancy_reason_not_renewal_or_first_let?" => true }] @depends_on = [{ "is_renewal?" => false, "vacancy_reason_not_renewal_or_first_let?" => true }]
end end

14
app/models/form/lettings/pages/property_postcode.rb

@ -1,14 +0,0 @@
class Form::Lettings::Pages::PropertyPostcode < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "property_postcode"
@depends_on = [{ "is_general_needs?" => true }]
end
def questions
@questions ||= [
Form::Lettings::Questions::PostcodeKnown.new(nil, nil, self),
Form::Lettings::Questions::PostcodeFull.new(nil, nil, self),
]
end
end

1
app/models/form/lettings/pages/reason_for_leaving_last_settled_home.rb

@ -2,6 +2,7 @@ class Form::Lettings::Pages::ReasonForLeavingLastSettledHome < ::Form::Page
def initialize(id, hsh, subsection) def initialize(id, hsh, subsection)
super super
@id = "reason_for_leaving_last_settled_home" @id = "reason_for_leaving_last_settled_home"
@copy_key = "lettings.household_situation.reason.reason_for_leaving_last_settled_home"
@depends_on = [{ "renewal" => 0 }] @depends_on = [{ "renewal" => 0 }]
end end

1
app/models/form/lettings/pages/reason_for_leaving_last_settled_home_renewal.rb

@ -2,6 +2,7 @@ class Form::Lettings::Pages::ReasonForLeavingLastSettledHomeRenewal < ::Form::Pa
def initialize(id, hsh, subsection) def initialize(id, hsh, subsection)
super super
@id = "reason_for_leaving_last_settled_home_renewal" @id = "reason_for_leaving_last_settled_home_renewal"
@copy_key = "lettings.household_situation.reason.reason_for_leaving_last_settled_home_renewal"
@depends_on = [{ "renewal" => 1 }] @depends_on = [{ "renewal" => 1 }]
end end

1
app/models/form/lettings/pages/referral.rb

@ -2,6 +2,7 @@ class Form::Lettings::Pages::Referral < ::Form::Page
def initialize(id, hsh, subsection) def initialize(id, hsh, subsection)
super super
@id = "referral" @id = "referral"
@copy_key = "lettings.household_situation.referral.general_needs.la"
@depends_on = [{ "owning_organisation_provider_type" => "LA", "needstype" => 1, "renewal" => 0 }] @depends_on = [{ "owning_organisation_provider_type" => "LA", "needstype" => 1, "renewal" => 0 }]
end end

1
app/models/form/lettings/pages/referral_prp.rb

@ -2,6 +2,7 @@ class Form::Lettings::Pages::ReferralPrp < ::Form::Page
def initialize(id, hsh, subsection) def initialize(id, hsh, subsection)
super super
@id = "referral_prp" @id = "referral_prp"
@copy_key = "lettings.household_situation.referral.general_needs.prp"
@depends_on = [{ "owning_organisation_provider_type" => "PRP", "needstype" => 1, "renewal" => 0 }] @depends_on = [{ "owning_organisation_provider_type" => "PRP", "needstype" => 1, "renewal" => 0 }]
end end

1
app/models/form/lettings/pages/referral_supported_housing.rb

@ -2,6 +2,7 @@ class Form::Lettings::Pages::ReferralSupportedHousing < ::Form::Page
def initialize(id, hsh, subsection) def initialize(id, hsh, subsection)
super super
@id = "referral_supported_housing" @id = "referral_supported_housing"
@copy_key = "lettings.household_situation.referral.supported_housing.la"
@depends_on = [{ "owning_organisation_provider_type" => "LA", "needstype" => 2, "renewal" => 0 }] @depends_on = [{ "owning_organisation_provider_type" => "LA", "needstype" => 2, "renewal" => 0 }]
end end

1
app/models/form/lettings/pages/referral_supported_housing_prp.rb

@ -2,6 +2,7 @@ class Form::Lettings::Pages::ReferralSupportedHousingPrp < ::Form::Page
def initialize(id, hsh, subsection) def initialize(id, hsh, subsection)
super super
@id = "referral_supported_housing_prp" @id = "referral_supported_housing_prp"
@copy_key = "lettings.household_situation.referral.supported_housing.prp"
@depends_on = [{ "owning_organisation_provider_type" => "PRP", "needstype" => 2, "renewal" => 0 }] @depends_on = [{ "owning_organisation_provider_type" => "PRP", "needstype" => 2, "renewal" => 0 }]
end end

2
app/models/form/lettings/pages/rent_type.rb

@ -2,7 +2,7 @@ class Form::Lettings::Pages::RentType < ::Form::Page
def initialize(_id, hsh, subsection) def initialize(_id, hsh, subsection)
super("rent_type", hsh, subsection) super("rent_type", hsh, subsection)
@derived = true @derived = true
@header = "Rent Type" @copy_key = "lettings.setup.rent_type"
end end
def questions def questions

35
app/models/form/lettings/pages/rent_value_check.rb

@ -0,0 +1,35 @@
class Form::Lettings::Pages::RentValueCheck < ::Form::Page
def initialize(id, hsh, subsection, check_answers_card_number: nil)
super(id, hsh, subsection)
@depends_on = [{ "rent_soft_validation_triggered?" => true }]
@title_text = {
"translation" => "soft_validations.rent.outside_range_title",
"arguments" => [
{
"key" => "brent",
"label" => true,
"i18n_template" => "brent",
},
],
}
@informative_text = {
"translation" => "soft_validations.rent.informative_text",
"arguments" => [
{
"key" => "rent_soft_validation_higher_or_lower_text",
"label" => false,
"i18n_template" => "higher_or_lower",
},
],
}
@check_answers_card_number = check_answers_card_number
end
def questions
@questions ||= [Form::Lettings::Questions::RentValueCheck.new(nil, nil, self, check_answers_card_number: @check_answers_card_number)]
end
def interruption_screen_question_ids
%w[brent period startdate uprn postcode_full la beds rent_type needstype]
end
end

1
app/models/form/lettings/pages/scheme.rb

@ -6,7 +6,6 @@ class Form::Lettings::Pages::Scheme < ::Form::Page
"needstype" => 2, "needstype" => 2,
}, },
] ]
@header = "Scheme"
@next_unresolved_page_id = "location" @next_unresolved_page_id = "location"
end end

1
app/models/form/lettings/pages/starter_tenancy_type.rb

@ -2,6 +2,7 @@ class Form::Lettings::Pages::StarterTenancyType < ::Form::Page
def initialize(id, hsh, subsection) def initialize(id, hsh, subsection)
super super
@id = "starter_tenancy_type" @id = "starter_tenancy_type"
@copy_key = "lettings.tenancy_information.tenancy.starter_tenancy_type"
@depends_on = [{ "starter_tenancy?" => true }] @depends_on = [{ "starter_tenancy?" => true }]
end end

1
app/models/form/lettings/pages/tenancy_length.rb

@ -2,6 +2,7 @@ class Form::Lettings::Pages::TenancyLength < ::Form::Page
def initialize(id, hsh, subsection) def initialize(id, hsh, subsection)
super super
@id = "tenancy_length" @id = "tenancy_length"
@copy_key = "lettings.tenancy_information.tenancylength.tenancy_length"
@depends_on = [{ "tenancy_type_fixed_term?" => true, "needstype" => 2 }] @depends_on = [{ "tenancy_type_fixed_term?" => true, "needstype" => 2 }]
end end

1
app/models/form/lettings/pages/tenancy_length_affordable_rent.rb

@ -2,6 +2,7 @@ class Form::Lettings::Pages::TenancyLengthAffordableRent < ::Form::Page
def initialize(id, hsh, subsection) def initialize(id, hsh, subsection)
super super
@id = "tenancy_length_affordable_rent" @id = "tenancy_length_affordable_rent"
@copy_key = "lettings.tenancy_information.tenancylength.tenancy_length_affordable_rent"
@depends_on = [{ "tenancy_type_fixed_term?" => true, "affordable_or_social_rent?" => true, "needstype" => 1 }] @depends_on = [{ "tenancy_type_fixed_term?" => true, "affordable_or_social_rent?" => true, "needstype" => 1 }]
end end

1
app/models/form/lettings/pages/tenancy_length_intermediate_rent.rb

@ -2,6 +2,7 @@ class Form::Lettings::Pages::TenancyLengthIntermediateRent < ::Form::Page
def initialize(id, hsh, subsection) def initialize(id, hsh, subsection)
super super
@id = "tenancy_length_intermediate_rent" @id = "tenancy_length_intermediate_rent"
@copy_key = "lettings.tenancy_information.tenancylength.tenancy_length_intermediate_rent"
@depends_on = [{ "tenancy_type_fixed_term?" => true, "affordable_or_social_rent?" => false, "needstype" => 1 }] @depends_on = [{ "tenancy_type_fixed_term?" => true, "affordable_or_social_rent?" => false, "needstype" => 1 }]
end end

1
app/models/form/lettings/pages/tenancy_length_periodic.rb

@ -2,6 +2,7 @@ class Form::Lettings::Pages::TenancyLengthPeriodic < ::Form::Page
def initialize(id, hsh, subsection) def initialize(id, hsh, subsection)
super super
@id = "tenancy_length_periodic" @id = "tenancy_length_periodic"
@copy_key = "lettings.tenancy_information.tenancylength.tenancy_length_periodic"
@depends_on = [{ "tenancy_type_periodic?" => true }] @depends_on = [{ "tenancy_type_periodic?" => true }]
end end

1
app/models/form/lettings/pages/tenancy_type.rb

@ -2,6 +2,7 @@ class Form::Lettings::Pages::TenancyType < ::Form::Page
def initialize(id, hsh, subsection) def initialize(id, hsh, subsection)
super super
@id = "tenancy_type" @id = "tenancy_type"
@copy_key = "lettings.tenancy_information.tenancy.tenancy_type"
@depends_on = [{ "starter_tenancy?" => false }] @depends_on = [{ "starter_tenancy?" => false }]
end end

2
app/models/form/lettings/pages/type_of_access_needs.rb

@ -2,7 +2,7 @@ class Form::Lettings::Pages::TypeOfAccessNeeds < ::Form::Page
def initialize(id, hsh, subsection) def initialize(id, hsh, subsection)
super super
@id = "type_of_access_needs" @id = "type_of_access_needs"
@header = "Disabled access needs" @copy_key = "lettings.household_needs.housingneeds_type"
@depends_on = [{ "housingneeds" => 1 }] @depends_on = [{ "housingneeds" => 1 }]
end end

1
app/models/form/lettings/pages/uprn.rb

@ -2,6 +2,7 @@ class Form::Lettings::Pages::Uprn < ::Form::Page
def initialize(id, hsh, subsection) def initialize(id, hsh, subsection)
super super
@id = "uprn" @id = "uprn"
@copy_key = "lettings.property_information.uprn"
@depends_on = [{ "is_supported_housing?" => false }] @depends_on = [{ "is_supported_housing?" => false }]
end end

1
app/models/form/lettings/pages/uprn_selection.rb

@ -2,7 +2,6 @@ class Form::Lettings::Pages::UprnSelection < ::Form::Page
def initialize(id, hsh, subsection) def initialize(id, hsh, subsection)
super super
@id = "uprn_selection" @id = "uprn_selection"
@header = "We found some addresses that might be this property"
@depends_on = [ @depends_on = [
{ "is_supported_housing?" => false, "uprn_known" => nil, "address_options_present?" => true }, { "is_supported_housing?" => false, "uprn_known" => nil, "address_options_present?" => true },
{ "is_supported_housing?" => false, "uprn_known" => 0, "address_options_present?" => true }, { "is_supported_housing?" => false, "uprn_known" => 0, "address_options_present?" => true },

1
app/models/form/lettings/pages/void_date.rb

@ -2,7 +2,6 @@ class Form::Lettings::Pages::VoidDate < ::Form::Page
def initialize(id, hsh, subsection) def initialize(id, hsh, subsection)
super super
@id = "void_date" @id = "void_date"
@header = "Void date"
@depends_on = [{ "is_renewal?" => false }] @depends_on = [{ "is_renewal?" => false }]
end end

3
app/models/form/lettings/questions/address_line1.rb

@ -2,11 +2,10 @@ class Form::Lettings::Questions::AddressLine1 < ::Form::Question
def initialize(id, hsh, page) def initialize(id, hsh, page)
super super
@id = "address_line1" @id = "address_line1"
@header = "Address line 1" @copy_key = "lettings.property_information.address.address_line1"
@error_label = "Address line 1" @error_label = "Address line 1"
@type = "text" @type = "text"
@plain_label = true @plain_label = true
@check_answer_label = "Address lines 1 and 2"
@disable_clearing_if_not_routed_or_dynamic_answer_options = true @disable_clearing_if_not_routed_or_dynamic_answer_options = true
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
@hide_question_number_on_page = true @hide_question_number_on_page = true

3
app/models/form/lettings/questions/address_line1_for_address_matcher.rb

@ -2,11 +2,10 @@ class Form::Lettings::Questions::AddressLine1ForAddressMatcher < ::Form::Questio
def initialize(id, hsh, page) def initialize(id, hsh, page)
super super
@id = "address_line1_input" @id = "address_line1_input"
@header = "Address line 1" @copy_key = "lettings.property_information.address_matcher.address_line1_input"
@error_label = "Address line 1" @error_label = "Address line 1"
@type = "text" @type = "text"
@plain_label = true @plain_label = true
@check_answer_label = "Find address"
@disable_clearing_if_not_routed_or_dynamic_answer_options = true @disable_clearing_if_not_routed_or_dynamic_answer_options = true
@hide_question_number_on_page = true @hide_question_number_on_page = true
end end

2
app/models/form/lettings/questions/address_line2.rb

@ -2,7 +2,7 @@ class Form::Lettings::Questions::AddressLine2 < ::Form::Question
def initialize(id, hsh, page) def initialize(id, hsh, page)
super super
@id = "address_line2" @id = "address_line2"
@header = "Address line 2 (optional)" @copy_key = "lettings.property_information.address.address_line2"
@type = "text" @type = "text"
@plain_label = true @plain_label = true
@disable_clearing_if_not_routed_or_dynamic_answer_options = true @disable_clearing_if_not_routed_or_dynamic_answer_options = true

8
app/models/form/lettings/questions/age.rb

@ -1,9 +1,8 @@
class Form::Lettings::Questions::Age < ::Form::Question class Form::Lettings::Questions::Age < ::Form::Question
def initialize(id, hsh, page, person_index:, person_type:) def initialize(id, hsh, page, person_index:)
super(id, hsh, page) super(id, hsh, page)
@id = "age#{person_index}" @id = "age#{person_index}"
@check_answer_label = "Person #{person_index}’s age" @copy_key = "lettings.household_characteristics.age#{person_index}.age#{person_index}"
@header = "Age"
@type = "numeric" @type = "numeric"
@width = 2 @width = 2
@inferred_check_answers_value = [{ "condition" => { "age#{person_index}_known" => 1 }, "value" => "Not known" }] @inferred_check_answers_value = [{ "condition" => { "age#{person_index}_known" => 1 }, "value" => "Not known" }]
@ -13,7 +12,6 @@ class Form::Lettings::Questions::Age < ::Form::Question
@step = 1 @step = 1
@person_index = person_index @person_index = person_index
@question_number = question_number @question_number = question_number
@person_type = person_type
@hint_text = hint_text @hint_text = hint_text
end end
@ -31,8 +29,6 @@ class Form::Lettings::Questions::Age < ::Form::Question
def hint_text def hint_text
if form.start_year_after_2024? if form.start_year_after_2024?
"Answer 1 for children aged under 1 year old" "Answer 1 for children aged under 1 year old"
elsif @person_type == "child"
"For a child under 1, enter 1"
end end
end end
end end

3
app/models/form/lettings/questions/age1.rb

@ -2,8 +2,7 @@ class Form::Lettings::Questions::Age1 < ::Form::Question
def initialize(id, hsh, page) def initialize(id, hsh, page)
super super
@id = "age1" @id = "age1"
@check_answer_label = "Lead tenant’s age" @copy_key = "lettings.household_characteristics.age1.age1"
@header = "Age"
@type = "numeric" @type = "numeric"
@width = 2 @width = 2
@inferred_check_answers_value = [{ "condition" => { "age1_known" => 1 }, "value" => "Not known" }] @inferred_check_answers_value = [{ "condition" => { "age1_known" => 1 }, "value" => "Not known" }]

11
app/models/form/lettings/questions/age1_known.rb

@ -2,8 +2,7 @@ class Form::Lettings::Questions::Age1Known < ::Form::Question
def initialize(id, hsh, page) def initialize(id, hsh, page)
super super
@id = "age1_known" @id = "age1_known"
@check_answer_label = "" @copy_key = "lettings.household_characteristics.age1.age1_known"
@header = "Do you know the lead tenant’s age?"
@type = "radio" @type = "radio"
@check_answers_card_number = 1 @check_answers_card_number = 1
@answer_options = ANSWER_OPTIONS @answer_options = ANSWER_OPTIONS
@ -14,13 +13,5 @@ class Form::Lettings::Questions::Age1Known < ::Form::Question
ANSWER_OPTIONS = { "0" => { "value" => "Yes" }, "1" => { "value" => "No" } }.freeze ANSWER_OPTIONS = { "0" => { "value" => "Yes" }, "1" => { "value" => "No" } }.freeze
def hint_text
if form.start_year_after_2024?
"The ’lead’ or ’main’ tenant is the person in the household who does the most paid work. If several people do the same amount of paid work, the lead tenant is whoever is the oldest."
else
"The ’lead’ or ’main’ tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest."
end
end
QUESTION_NUMBER_FROM_YEAR = { 2023 => 32, 2024 => 31 }.freeze QUESTION_NUMBER_FROM_YEAR = { 2023 => 32, 2024 => 31 }.freeze
end end

4
app/models/form/lettings/questions/age_known.rb

@ -2,11 +2,9 @@ class Form::Lettings::Questions::AgeKnown < ::Form::Question
def initialize(id, hsh, page, person_index:) def initialize(id, hsh, page, person_index:)
super(id, hsh, page) super(id, hsh, page)
@id = "age#{person_index}_known" @id = "age#{person_index}_known"
@check_answer_label = "" @copy_key = "lettings.household_characteristics.age#{person_index}.age#{person_index}_known"
@header = "Do you know person #{person_index}’s age?"
@type = "radio" @type = "radio"
@check_answers_card_number = person_index @check_answers_card_number = person_index
@hint_text = ""
@answer_options = ANSWER_OPTIONS @answer_options = ANSWER_OPTIONS
@conditional_for = { "age#{person_index}" => [0] } @conditional_for = { "age#{person_index}" => [0] }
@hidden_in_check_answers = { @hidden_in_check_answers = {

3
app/models/form/lettings/questions/armedforces.rb

@ -2,11 +2,8 @@ class Form::Lettings::Questions::Armedforces < ::Form::Question
def initialize(id, hsh, page) def initialize(id, hsh, page)
super super
@id = "armedforces" @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" @type = "radio"
@check_answers_card_number = 0 @check_answers_card_number = 0
@hint_text = "This excludes national service.<br><br>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 @answer_options = ANSWER_OPTIONS
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
end end

6
app/models/form/lettings/questions/beds.rb

@ -2,8 +2,6 @@ class Form::Lettings::Questions::Beds < ::Form::Question
def initialize(id, hsh, page) def initialize(id, hsh, page)
super super
@id = "beds" @id = "beds"
@check_answer_label = "Number of bedrooms"
@header = "How many bedrooms does the property have?"
@type = "numeric" @type = "numeric"
@width = 2 @width = 2
@check_answers_card_number = 0 @check_answers_card_number = 0
@ -17,9 +15,5 @@ class Form::Lettings::Questions::Beds < ::Form::Question
log.is_bedsit? log.is_bedsit?
end end
def hint_text
form.start_year_after_2024? ? "If shared accommodation, enter the number of bedrooms occupied by this household." : "If shared accommodation, enter the number of bedrooms occupied by this household. A bedsit has 1 bedroom."
end
QUESTION_NUMBER_FROM_YEAR = { 2023 => 22 }.freeze QUESTION_NUMBER_FROM_YEAR = { 2023 => 22 }.freeze
end end

3
app/models/form/lettings/questions/builtype.rb

@ -2,11 +2,8 @@ class Form::Lettings::Questions::Builtype < ::Form::Question
def initialize(id, hsh, page) def initialize(id, hsh, page)
super super
@id = "builtype" @id = "builtype"
@check_answer_label = "Type of building"
@header = "What type of building is the property?"
@type = "radio" @type = "radio"
@check_answers_card_number = 0 @check_answers_card_number = 0
@hint_text = ""
@answer_options = ANSWER_OPTIONS @answer_options = ANSWER_OPTIONS
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
end end

3
app/models/form/lettings/questions/condition_effects.rb

@ -2,11 +2,8 @@ class Form::Lettings::Questions::ConditionEffects < ::Form::Question
def initialize(id, hsh, page) def initialize(id, hsh, page)
super super
@id = "condition_effects" @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" @type = "checkbox"
@check_answers_card_number = 0 @check_answers_card_number = 0
@hint_text = "Select all that apply."
@answer_options = ANSWER_OPTIONS @answer_options = ANSWER_OPTIONS
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
end end

3
app/models/form/lettings/questions/county.rb

@ -2,10 +2,9 @@ class Form::Lettings::Questions::County < ::Form::Question
def initialize(id, hsh, page) def initialize(id, hsh, page)
super super
@id = "county" @id = "county"
@header = "County (optional)" @copy_key = "lettings.property_information.address.county"
@type = "text" @type = "text"
@plain_label = true @plain_label = true
@check_answer_label = "County"
@disable_clearing_if_not_routed_or_dynamic_answer_options = true @disable_clearing_if_not_routed_or_dynamic_answer_options = true
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
@hide_question_number_on_page = true @hide_question_number_on_page = true

2
app/models/form/lettings/questions/created_by_id.rb

@ -4,8 +4,6 @@ class Form::Lettings::Questions::CreatedById < ::Form::Question
def initialize(id, hsh, page) def initialize(id, hsh, page)
super super
@id = "assigned_to_id" @id = "assigned_to_id"
@check_answer_label = "Log owner"
@header = "Which user are you creating this log for?"
@derived = true @derived = true
@type = "select" @type = "select"
end end

4
app/models/form/lettings/questions/declaration.rb

@ -2,11 +2,9 @@ class Form::Lettings::Questions::Declaration < ::Form::Question
def initialize(id, hsh, page) def initialize(id, hsh, page)
super super
@id = "declaration" @id = "declaration"
@check_answer_label = "Tenant has seen the privacy notice"
@header = "Declaration"
@type = "checkbox" @type = "checkbox"
@check_answers_card_number = 0 unless form.start_year_after_2024? @check_answers_card_number = 0 unless form.start_year_after_2024?
@top_guidance_partial = form.start_year_after_2024? ? "privacy_notice_tenant_2024" : "privacy_notice_tenant" @top_guidance_partial = "privacy_notice_tenant"
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
end end

3
app/models/form/lettings/questions/details_known.rb

@ -2,11 +2,8 @@ class Form::Lettings::Questions::DetailsKnown < ::Form::Question
def initialize(id, hsh, page, person_index:) def initialize(id, hsh, page, person_index:)
super(id, hsh, page) super(id, hsh, page)
@id = "details_known_#{person_index}" @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" @type = "radio"
@check_answers_card_number = person_index @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 @answer_options = ANSWER_OPTIONS
end end

4
app/models/form/lettings/questions/ethnic_arab.rb

@ -2,11 +2,9 @@ class Form::Lettings::Questions::EthnicArab < ::Form::Question
def initialize(id, hsh, page) def initialize(id, hsh, page)
super super
@id = "ethnic" @id = "ethnic"
@check_answer_label = "Lead tenant’s ethnic background" @copy_key = "lettings.household_characteristics.ethnic.ethnic_background_arab"
@header = "Which of the following best describes the lead tenant’s Arab background?"
@type = "radio" @type = "radio"
@check_answers_card_number = 1 @check_answers_card_number = 1
@hint_text = form.start_year_after_2024? ? "" : "The lead tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest."
@answer_options = ANSWER_OPTIONS @answer_options = ANSWER_OPTIONS
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
end end

4
app/models/form/lettings/questions/ethnic_asian.rb

@ -2,11 +2,9 @@ class Form::Lettings::Questions::EthnicAsian < ::Form::Question
def initialize(id, hsh, page) def initialize(id, hsh, page)
super super
@id = "ethnic" @id = "ethnic"
@check_answer_label = "Lead tenant’s ethnic background" @copy_key = "lettings.household_characteristics.ethnic.ethnic_background_asian"
@header = "Which of the following best describes the lead tenant’s Asian or Asian British background?"
@type = "radio" @type = "radio"
@check_answers_card_number = 1 @check_answers_card_number = 1
@hint_text = form.start_year_after_2024? ? "" : "The lead tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest."
@answer_options = ANSWER_OPTIONS @answer_options = ANSWER_OPTIONS
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
end end

4
app/models/form/lettings/questions/ethnic_black.rb

@ -2,11 +2,9 @@ class Form::Lettings::Questions::EthnicBlack < ::Form::Question
def initialize(id, hsh, page) def initialize(id, hsh, page)
super super
@id = "ethnic" @id = "ethnic"
@check_answer_label = "Lead tenant’s ethnic background" @copy_key = "lettings.household_characteristics.ethnic.ethnic_background_black"
@header = "Which of the following best describes the lead tenant’s Black, African, Caribbean or Black British background?"
@type = "radio" @type = "radio"
@check_answers_card_number = 1 @check_answers_card_number = 1
@hint_text = form.start_year_after_2024? ? "" : "The lead tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest."
@answer_options = ANSWER_OPTIONS @answer_options = ANSWER_OPTIONS
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
end end

3
app/models/form/lettings/questions/ethnic_group.rb

@ -2,11 +2,8 @@ class Form::Lettings::Questions::EthnicGroup < ::Form::Question
def initialize(id, hsh, page) def initialize(id, hsh, page)
super super
@id = "ethnic_group" @id = "ethnic_group"
@check_answer_label = "Lead tenant’s ethnic group"
@header = "What is the lead tenant’s ethnic group?"
@type = "radio" @type = "radio"
@check_answers_card_number = 1 @check_answers_card_number = 1
@hint_text = form.start_year_after_2024? ? "" : "The lead tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest."
@answer_options = ANSWER_OPTIONS @answer_options = ANSWER_OPTIONS
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
end end

4
app/models/form/lettings/questions/ethnic_mixed.rb

@ -2,11 +2,9 @@ class Form::Lettings::Questions::EthnicMixed < ::Form::Question
def initialize(id, hsh, page) def initialize(id, hsh, page)
super super
@id = "ethnic" @id = "ethnic"
@check_answer_label = "Lead tenant’s ethnic background" @copy_key = "lettings.household_characteristics.ethnic.ethnic_background_mixed"
@header = "Which of the following best describes the lead tenant’s Mixed or Multiple ethnic groups background?"
@type = "radio" @type = "radio"
@check_answers_card_number = 1 @check_answers_card_number = 1
@hint_text = form.start_year_after_2024? ? "" : "The lead tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest."
@answer_options = ANSWER_OPTIONS @answer_options = ANSWER_OPTIONS
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
end end

4
app/models/form/lettings/questions/ethnic_white.rb

@ -2,11 +2,9 @@ class Form::Lettings::Questions::EthnicWhite < ::Form::Question
def initialize(id, hsh, page) def initialize(id, hsh, page)
super super
@id = "ethnic" @id = "ethnic"
@check_answer_label = "Lead tenant’s ethnic background" @copy_key = "lettings.household_characteristics.ethnic.ethnic_background_white"
@header = "Which of the following best describes the lead tenant’s White background?"
@type = "radio" @type = "radio"
@check_answers_card_number = 1 @check_answers_card_number = 1
@hint_text = form.start_year_after_2024? ? "" : "The lead tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest."
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
end end

3
app/models/form/lettings/questions/first_time_property_let_as_social_housing.rb

@ -2,11 +2,8 @@ class Form::Lettings::Questions::FirstTimePropertyLetAsSocialHousing < ::Form::Q
def initialize(id, hsh, page) def initialize(id, hsh, page)
super super
@id = "first_time_property_let_as_social_housing" @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" @type = "radio"
@check_answers_card_number = 0 @check_answers_card_number = 0
@hint_text = ""
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
end end

10
app/models/form/lettings/questions/gender_identity1.rb

@ -2,8 +2,6 @@ class Form::Lettings::Questions::GenderIdentity1 < ::Form::Question
def initialize(id, hsh, page) def initialize(id, hsh, page)
super super
@id = "sex1" @id = "sex1"
@check_answer_label = "Lead tenant’s gender identity"
@header = "Which of these best describes the lead tenant’s gender identity?"
@type = "radio" @type = "radio"
@check_answers_card_number = 1 @check_answers_card_number = 1
@answer_options = ANSWER_OPTIONS @answer_options = ANSWER_OPTIONS
@ -18,13 +16,5 @@ class Form::Lettings::Questions::GenderIdentity1 < ::Form::Question
"R" => { "value" => "Tenant prefers not to say" }, "R" => { "value" => "Tenant prefers not to say" },
}.freeze }.freeze
def hint_text
if form.start_year_after_2024?
"This should be however they personally choose to identify from the options below. This may or may not be the same as their biological sex or the sex they were assigned at birth."
else
"The lead tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest."
end
end
QUESTION_NUMBER_FROM_YEAR = { 2023 => 33, 2024 => 32 }.freeze QUESTION_NUMBER_FROM_YEAR = { 2023 => 33, 2024 => 32 }.freeze
end end

3
app/models/form/lettings/questions/hhmemb.rb

@ -2,14 +2,11 @@ class Form::Lettings::Questions::Hhmemb < ::Form::Question
def initialize(id, hsh, page) def initialize(id, hsh, page)
super super
@id = "hhmemb" @id = "hhmemb"
@check_answer_label = "Number of household members"
@header = "How many people live in the household for this letting?"
@type = "numeric" @type = "numeric"
@width = 2 @width = 2
@check_answers_card_number = 0 @check_answers_card_number = 0
@max = 8 @max = 8
@min = 1 @min = 1
@hint_text = "You can provide details for a maximum of 8 people."
@step = 1 @step = 1
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
end end

3
app/models/form/lettings/questions/homeless.rb

@ -2,11 +2,8 @@ class Form::Lettings::Questions::Homeless < ::Form::Question
def initialize(id, hsh, page) def initialize(id, hsh, page)
super super
@id = "homeless" @id = "homeless"
@check_answer_label = "Household homeless immediately before letting"
@header = "Did the household experience homelessness immediately before this letting?"
@type = "radio" @type = "radio"
@check_answers_card_number = 0 @check_answers_card_number = 0
@hint_text = ""
@answer_options = ANSWER_OPTIONS @answer_options = ANSWER_OPTIONS
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
end end

3
app/models/form/lettings/questions/housingneeds.rb

@ -2,11 +2,8 @@ class Form::Lettings::Questions::Housingneeds < ::Form::Question
def initialize(id, hsh, page) def initialize(id, hsh, page)
super super
@id = "housingneeds" @id = "housingneeds"
@check_answer_label = "Anybody with disabled access needs"
@header = "Does anybody in the household have any disabled access needs?"
@type = "radio" @type = "radio"
@check_answers_card_number = 0 @check_answers_card_number = 0
@hint_text = ""
@answer_options = ANSWER_OPTIONS @answer_options = ANSWER_OPTIONS
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
end end

4
app/models/form/lettings/questions/housingneeds_other.rb

@ -2,11 +2,9 @@ class Form::Lettings::Questions::HousingneedsOther < ::Form::Question
def initialize(id, hsh, page) def initialize(id, hsh, page)
super super
@id = "housingneeds_other" @id = "housingneeds_other"
@check_answer_label = "Other disabled access needs" @copy_key = "lettings.household_needs.housingneeds_type.housingneeds_other"
@header = "Do they have any other disabled access needs?"
@type = "radio" @type = "radio"
@check_answers_card_number = 0 @check_answers_card_number = 0
@hint_text = ""
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
end end

4
app/models/form/lettings/questions/housingneeds_type.rb

@ -2,11 +2,9 @@ class Form::Lettings::Questions::HousingneedsType < ::Form::Question
def initialize(id, hsh, page) def initialize(id, hsh, page)
super super
@id = "housingneeds_type" @id = "housingneeds_type"
@check_answer_label = "Disabled access needs" @copy_key = "lettings.household_needs.housingneeds_type.housingneeds_type"
@header = "What type of access needs do they have?"
@type = "radio" @type = "radio"
@check_answers_card_number = 0 @check_answers_card_number = 0
@hint_text = ""
@answer_options = ANSWER_OPTIONS @answer_options = ANSWER_OPTIONS
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
end end

3
app/models/form/lettings/questions/illness.rb

@ -2,11 +2,8 @@ class Form::Lettings::Questions::Illness < ::Form::Question
def initialize(id, hsh, page) def initialize(id, hsh, page)
super super
@id = "illness" @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" @type = "radio"
@check_answers_card_number = 0 @check_answers_card_number = 0
@hint_text = ""
@answer_options = ANSWER_OPTIONS @answer_options = ANSWER_OPTIONS
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
end end

3
app/models/form/lettings/questions/irproduct_other.rb

@ -2,8 +2,7 @@ class Form::Lettings::Questions::IrproductOther < ::Form::Question
def initialize(id, hsh, page) def initialize(id, hsh, page)
super super
@id = "irproduct_other" @id = "irproduct_other"
@check_answer_label = "Product name" @copy_key = "lettings.setup.rent_type.irproduct_other"
@header = "Name of rent product"
@type = "text" @type = "text"
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] if form.start_date.present? @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] if form.start_date.present?
end end

3
app/models/form/lettings/questions/joint.rb

@ -2,11 +2,8 @@ class Form::Lettings::Questions::Joint < ::Form::Question
def initialize(id, hsh, page) def initialize(id, hsh, page)
super super
@id = "joint" @id = "joint"
@check_answer_label = "Is this a joint tenancy?"
@header = "Is this a joint tenancy?"
@type = "radio" @type = "radio"
@check_answers_card_number = 0 @check_answers_card_number = 0
@hint_text = form.start_year_after_2024? ? "This is where two or more people are named on the tenancy agreement" : ""
@answer_options = ANSWER_OPTIONS @answer_options = ANSWER_OPTIONS
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
end end

2
app/models/form/lettings/questions/la.rb

@ -2,8 +2,6 @@ class Form::Lettings::Questions::La < ::Form::Question
def initialize(id, hsh, page) def initialize(id, hsh, page)
super super
@id = "la" @id = "la"
@check_answer_label = "Local Authority"
@header = "What is the property’s local authority?"
@type = "select" @type = "select"
@check_answers_card_number = nil @check_answers_card_number = nil
@hint_text = "" @hint_text = ""

3
app/models/form/lettings/questions/layear.rb

@ -2,11 +2,8 @@ class Form::Lettings::Questions::Layear < ::Form::Question
def initialize(id, hsh, page) def initialize(id, hsh, page)
super super
@id = "layear" @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" @type = "radio"
@check_answers_card_number = 0 @check_answers_card_number = 0
@hint_text = ""
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
end end

3
app/models/form/lettings/questions/leftreg.rb

@ -2,11 +2,8 @@ class Form::Lettings::Questions::Leftreg < ::Form::Question
def initialize(id, hsh, page) def initialize(id, hsh, page)
super super
@id = "leftreg" @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" @type = "radio"
@check_answers_card_number = 0 @check_answers_card_number = 0
@hint_text = ""
@answer_options = ANSWER_OPTIONS @answer_options = ANSWER_OPTIONS
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
end end

3
app/models/form/lettings/questions/letting_allocation.rb

@ -2,11 +2,8 @@ class Form::Lettings::Questions::LettingAllocation < ::Form::Question
def initialize(id, hsh, page) def initialize(id, hsh, page)
super super
@id = "letting_allocation" @id = "letting_allocation"
@check_answer_label = "Allocation system"
@header = "How was this letting allocated?"
@type = "checkbox" @type = "checkbox"
@check_answers_card_number = 0 @check_answers_card_number = 0
@hint_text = "Select all that apply."
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
end end

11
app/models/form/lettings/questions/location_id.rb

@ -2,8 +2,7 @@ class Form::Lettings::Questions::LocationId < ::Form::Question
def initialize(id, hsh, page) def initialize(id, hsh, page)
super super
@id = "location_id" @id = "location_id"
@check_answer_label = "Location" @copy_key = "lettings.setup.location_id.less_than_twenty"
@header = header_text
@type = "radio" @type = "radio"
@answer_options = answer_options @answer_options = answer_options
@inferred_answers = { @inferred_answers = {
@ -56,13 +55,5 @@ private
false false
end end
def header_text
if form.start_date && form.start_date.year >= 2023
"Which location is this letting for?"
else
"Which location is this log for?"
end
end
QUESTION_NUMBER_FROM_YEAR = { 2023 => 10, 2024 => 5 }.freeze QUESTION_NUMBER_FROM_YEAR = { 2023 => 10, 2024 => 5 }.freeze
end end

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save