Browse Source

Merge branch 'main' into CLDC-3667-extract-sale-information-errors

pull/2699/head
kosiakkatrina 2 years ago committed by GitHub
parent
commit
80ce4ef868
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      Gemfile
  2. 132
      Gemfile.lock
  3. 30
      app/components/bulk_upload_error_row_component.html.erb
  4. 13
      app/components/bulk_upload_error_row_component.rb
  5. 2
      app/components/bulk_upload_summary_component.html.erb
  6. 4
      app/components/document_list_component.html.erb
  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. 8
      app/helpers/log_actions_helper.rb
  17. 2
      app/helpers/review_helper.rb
  18. 2
      app/helpers/tasklist_helper.rb
  19. 2
      app/models/bulk_upload.rb
  20. 38
      app/models/collection_resource.rb
  21. 1
      app/models/form/lettings/pages/declaration.rb
  22. 2
      app/models/form/lettings/pages/location.rb
  23. 2
      app/models/form/lettings/pages/location_search.rb
  24. 2
      app/models/form/lettings/pages/rent_type.rb
  25. 1
      app/models/form/lettings/pages/scheme.rb
  26. 2
      app/models/form/lettings/questions/created_by_id.rb
  27. 3
      app/models/form/lettings/questions/irproduct_other.rb
  28. 11
      app/models/form/lettings/questions/location_id.rb
  29. 12
      app/models/form/lettings/questions/location_id_search.rb
  30. 2
      app/models/form/lettings/questions/managing_organisation.rb
  31. 3
      app/models/form/lettings/questions/needs_type.rb
  32. 3
      app/models/form/lettings/questions/property_reference.rb
  33. 19
      app/models/form/lettings/questions/renewal.rb
  34. 3
      app/models/form/lettings/questions/rent_type.rb
  35. 11
      app/models/form/lettings/questions/scheme_id.rb
  36. 2
      app/models/form/lettings/questions/stock_owner.rb
  37. 2
      app/models/form/lettings/questions/tenancy_start_date.rb
  38. 3
      app/models/form/lettings/questions/tenant_code.rb
  39. 1
      app/models/form/sales/pages/age1.rb
  40. 1
      app/models/form/sales/pages/age2.rb
  41. 1
      app/models/form/sales/pages/buyer1_ethnic_background_arab.rb
  42. 1
      app/models/form/sales/pages/buyer1_ethnic_background_asian.rb
  43. 1
      app/models/form/sales/pages/buyer1_ethnic_background_black.rb
  44. 1
      app/models/form/sales/pages/buyer1_ethnic_background_mixed.rb
  45. 1
      app/models/form/sales/pages/buyer1_ethnic_background_white.rb
  46. 1
      app/models/form/sales/pages/buyer1_income.rb
  47. 3
      app/models/form/sales/pages/buyer1_income_max_value_check.rb
  48. 5
      app/models/form/sales/pages/buyer1_income_min_value_check.rb
  49. 1
      app/models/form/sales/pages/buyer2_ethnic_background_arab.rb
  50. 1
      app/models/form/sales/pages/buyer2_ethnic_background_asian.rb
  51. 1
      app/models/form/sales/pages/buyer2_ethnic_background_black.rb
  52. 1
      app/models/form/sales/pages/buyer2_ethnic_background_mixed.rb
  53. 1
      app/models/form/sales/pages/buyer2_ethnic_background_white.rb
  54. 1
      app/models/form/sales/pages/buyer2_income.rb
  55. 3
      app/models/form/sales/pages/buyer2_income_max_value_check.rb
  56. 5
      app/models/form/sales/pages/buyer2_income_min_value_check.rb
  57. 1
      app/models/form/sales/pages/buyer2_relationship_to_buyer1.rb
  58. 1
      app/models/form/sales/pages/buyer2_working_situation.rb
  59. 2
      app/models/form/sales/pages/buyer_interview.rb
  60. 5
      app/models/form/sales/pages/buyer_live_in_value_check.rb
  61. 3
      app/models/form/sales/pages/combined_income_max_value_check.rb
  62. 5
      app/models/form/sales/pages/deposit_value_check.rb
  63. 1
      app/models/form/sales/pages/gender_identity2.rb
  64. 4
      app/models/form/sales/pages/household_wheelchair_check.rb
  65. 1
      app/models/form/sales/pages/housing_benefits.rb
  66. 6
      app/models/form/sales/pages/mortgage_value_check.rb
  67. 8
      app/models/form/sales/pages/multiple_partners_value_check.rb
  68. 6
      app/models/form/sales/pages/not_retired_value_check.rb
  69. 5
      app/models/form/sales/pages/old_persons_shared_ownership_value_check.rb
  70. 8
      app/models/form/sales/pages/partner_under_16_value_check.rb
  71. 1
      app/models/form/sales/pages/person_age.rb
  72. 1
      app/models/form/sales/pages/person_gender_identity.rb
  73. 1
      app/models/form/sales/pages/person_relationship_to_buyer_1.rb
  74. 5
      app/models/form/sales/pages/person_student_not_child_value_check.rb
  75. 1
      app/models/form/sales/pages/person_working_situation.rb
  76. 1
      app/models/form/sales/pages/previous_ownership.rb
  77. 2
      app/models/form/sales/pages/privacy_notice.rb
  78. 8
      app/models/form/sales/pages/retirement_value_check.rb
  79. 1
      app/models/form/sales/pages/savings.rb
  80. 5
      app/models/form/sales/pages/savings_value_check.rb
  81. 3
      app/models/form/sales/questions/age1.rb
  82. 3
      app/models/form/sales/questions/age2.rb
  83. 3
      app/models/form/sales/questions/armed_forces.rb
  84. 2
      app/models/form/sales/questions/armed_forces_spouse.rb
  85. 4
      app/models/form/sales/questions/buyer1_age_known.rb
  86. 4
      app/models/form/sales/questions/buyer1_ethnic_background_arab.rb
  87. 4
      app/models/form/sales/questions/buyer1_ethnic_background_asian.rb
  88. 4
      app/models/form/sales/questions/buyer1_ethnic_background_black.rb
  89. 4
      app/models/form/sales/questions/buyer1_ethnic_background_mixed.rb
  90. 4
      app/models/form/sales/questions/buyer1_ethnic_background_white.rb
  91. 3
      app/models/form/sales/questions/buyer1_ethnic_group.rb
  92. 4
      app/models/form/sales/questions/buyer1_income.rb
  93. 3
      app/models/form/sales/questions/buyer1_income_known.rb
  94. 3
      app/models/form/sales/questions/buyer1_income_value_check.rb
  95. 3
      app/models/form/sales/questions/buyer1_live_in_property.rb
  96. 2
      app/models/form/sales/questions/buyer1_mortgage.rb
  97. 3
      app/models/form/sales/questions/buyer1_nationality.rb
  98. 3
      app/models/form/sales/questions/buyer1_working_situation.rb
  99. 3
      app/models/form/sales/questions/buyer2_age_known.rb
  100. 3
      app/models/form/sales/questions/buyer2_ethnic_background_arab.rb
  101. Some files were not shown because too many files have changed in this diff Show More

2
Gemfile

@ -6,7 +6,7 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby "3.1.4"
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails', branch: 'main'
gem "rails", "~> 7.0.8.3"
gem "rails", "~> 7.0.8.5"
# Use postgresql as the database for Active Record
gem "pg", "~> 1.1"
# Use Puma as the app server

132
Gemfile.lock

@ -1,71 +1,71 @@
GEM
remote: https://rubygems.org/
specs:
actioncable (7.0.8.4)
actionpack (= 7.0.8.4)
activesupport (= 7.0.8.4)
actioncable (7.0.8.5)
actionpack (= 7.0.8.5)
activesupport (= 7.0.8.5)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailbox (7.0.8.4)
actionpack (= 7.0.8.4)
activejob (= 7.0.8.4)
activerecord (= 7.0.8.4)
activestorage (= 7.0.8.4)
activesupport (= 7.0.8.4)
actionmailbox (7.0.8.5)
actionpack (= 7.0.8.5)
activejob (= 7.0.8.5)
activerecord (= 7.0.8.5)
activestorage (= 7.0.8.5)
activesupport (= 7.0.8.5)
mail (>= 2.7.1)
net-imap
net-pop
net-smtp
actionmailer (7.0.8.4)
actionpack (= 7.0.8.4)
actionview (= 7.0.8.4)
activejob (= 7.0.8.4)
activesupport (= 7.0.8.4)
actionmailer (7.0.8.5)
actionpack (= 7.0.8.5)
actionview (= 7.0.8.5)
activejob (= 7.0.8.5)
activesupport (= 7.0.8.5)
mail (~> 2.5, >= 2.5.4)
net-imap
net-pop
net-smtp
rails-dom-testing (~> 2.0)
actionpack (7.0.8.4)
actionview (= 7.0.8.4)
activesupport (= 7.0.8.4)
actionpack (7.0.8.5)
actionview (= 7.0.8.5)
activesupport (= 7.0.8.5)
rack (~> 2.0, >= 2.2.4)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.2.0)
actiontext (7.0.8.4)
actionpack (= 7.0.8.4)
activerecord (= 7.0.8.4)
activestorage (= 7.0.8.4)
activesupport (= 7.0.8.4)
actiontext (7.0.8.5)
actionpack (= 7.0.8.5)
activerecord (= 7.0.8.5)
activestorage (= 7.0.8.5)
activesupport (= 7.0.8.5)
globalid (>= 0.6.0)
nokogiri (>= 1.8.5)
actionview (7.0.8.4)
activesupport (= 7.0.8.4)
actionview (7.0.8.5)
activesupport (= 7.0.8.5)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.1, >= 1.2.0)
activejob (7.0.8.4)
activesupport (= 7.0.8.4)
activejob (7.0.8.5)
activesupport (= 7.0.8.5)
globalid (>= 0.3.6)
activemodel (7.0.8.4)
activesupport (= 7.0.8.4)
activemodel (7.0.8.5)
activesupport (= 7.0.8.5)
activemodel-serializers-xml (1.0.2)
activemodel (> 5.x)
activesupport (> 5.x)
builder (~> 3.1)
activerecord (7.0.8.4)
activemodel (= 7.0.8.4)
activesupport (= 7.0.8.4)
activestorage (7.0.8.4)
actionpack (= 7.0.8.4)
activejob (= 7.0.8.4)
activerecord (= 7.0.8.4)
activesupport (= 7.0.8.4)
activerecord (7.0.8.5)
activemodel (= 7.0.8.5)
activesupport (= 7.0.8.5)
activestorage (7.0.8.5)
actionpack (= 7.0.8.5)
activejob (= 7.0.8.5)
activerecord (= 7.0.8.5)
activesupport (= 7.0.8.5)
marcel (~> 1.0)
mini_mime (>= 1.1.0)
activesupport (7.0.8.4)
activesupport (7.0.8.5)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
@ -218,7 +218,7 @@ GEM
hashdiff (1.1.0)
html-attributes-utils (1.0.2)
activesupport (>= 6.1.4.4)
i18n (1.14.5)
i18n (1.14.6)
concurrent-ruby (~> 1.0)
ice_nine (0.11.2)
iniparse (1.5.0)
@ -258,13 +258,13 @@ GEM
matrix (0.4.2)
method_source (1.1.0)
mini_mime (1.1.5)
minitest (5.24.1)
minitest (5.25.1)
msgpack (1.7.2)
multipart-post (2.4.1)
nested_form (0.3.2)
net-http (0.4.1)
uri
net-imap (0.4.14)
net-imap (0.4.17)
date
net-protocol
net-pop (0.1.2)
@ -274,11 +274,11 @@ GEM
net-smtp (0.5.0)
net-protocol
nio4r (2.7.3)
nokogiri (1.16.6-arm64-darwin)
nokogiri (1.16.7-arm64-darwin)
racc (~> 1.4)
nokogiri (1.16.6-x86_64-darwin)
nokogiri (1.16.7-x86_64-darwin)
racc (~> 1.4)
nokogiri (1.16.6-x86_64-linux)
nokogiri (1.16.7-x86_64-linux)
racc (~> 1.4)
notifications-ruby-client (6.0.0)
jwt (>= 1.5, < 3)
@ -319,28 +319,28 @@ GEM
pundit (2.3.1)
activesupport (>= 3.0.0)
raabro (1.4.0)
racc (1.8.0)
rack (2.2.9)
racc (1.8.1)
rack (2.2.10)
rack-attack (6.7.0)
rack (>= 1.0, < 4)
rack-mini-profiler (2.3.4)
rack (>= 1.2.0)
rack-test (2.1.0)
rack (>= 1.3)
rails (7.0.8.4)
actioncable (= 7.0.8.4)
actionmailbox (= 7.0.8.4)
actionmailer (= 7.0.8.4)
actionpack (= 7.0.8.4)
actiontext (= 7.0.8.4)
actionview (= 7.0.8.4)
activejob (= 7.0.8.4)
activemodel (= 7.0.8.4)
activerecord (= 7.0.8.4)
activestorage (= 7.0.8.4)
activesupport (= 7.0.8.4)
rails (7.0.8.5)
actioncable (= 7.0.8.5)
actionmailbox (= 7.0.8.5)
actionmailer (= 7.0.8.5)
actionpack (= 7.0.8.5)
actiontext (= 7.0.8.5)
actionview (= 7.0.8.5)
activejob (= 7.0.8.5)
activemodel (= 7.0.8.5)
activerecord (= 7.0.8.5)
activestorage (= 7.0.8.5)
activesupport (= 7.0.8.5)
bundler (>= 1.15.0)
railties (= 7.0.8.4)
railties (= 7.0.8.5)
rails-dom-testing (2.2.0)
activesupport (>= 5.0.0)
minitest
@ -354,9 +354,9 @@ GEM
nested_form (~> 0.3)
rails (>= 6.0, < 8)
turbo-rails (~> 1.0)
railties (7.0.8.4)
actionpack (= 7.0.8.4)
activesupport (= 7.0.8.4)
railties (7.0.8.5)
actionpack (= 7.0.8.5)
activesupport (= 7.0.8.5)
method_source
rake (>= 12.2)
thor (~> 1.0)
@ -377,8 +377,7 @@ GEM
responders (3.1.1)
actionpack (>= 5.2)
railties (>= 5.2)
rexml (3.3.6)
strscan
rexml (3.3.9)
roo (2.10.1)
nokogiri (~> 1)
rubyzip (>= 1.3.0, < 3.0.0)
@ -463,8 +462,7 @@ GEM
smart_properties (1.17.0)
stimulus-rails (1.3.3)
railties (>= 6.0.0)
strscan (3.1.0)
thor (1.3.1)
thor (1.3.2)
thread_safe (0.3.6)
timecop (0.9.8)
timeout (0.4.1)
@ -504,7 +502,7 @@ GEM
websocket-extensions (0.1.5)
xpath (3.2.0)
nokogiri (~> 1.8)
zeitwerk (2.6.16)
zeitwerk (2.6.18)
PLATFORMS
arm64-darwin-21
@ -555,7 +553,7 @@ DEPENDENCIES
rack (>= 2.2.6.3)
rack-attack
rack-mini-profiler (~> 2.0)
rails (~> 7.0.8.3)
rails (~> 7.0.8.5)
rails_admin (~> 3.1)
redcarpet (~> 3.6)
redis (~> 4.8)

30
app/components/bulk_upload_error_row_component.html.erb

@ -13,7 +13,7 @@
<% if critical_errors.any? %>
<h2 class="govuk-heading-m">Critical errors</h2>
<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| %>
<% head.with_row do |row| %>
<% row.with_cell(header: true, text: "Cell") %>
@ -39,7 +39,7 @@
<% if potential_errors.any? %>
<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>
<%= govuk_table do |table| %>
<%= govuk_table(html_attributes: { class: "no-bottom-border" }) do |table| %>
<%= table.with_head do |head| %>
<% head.with_row do |row| %>
<% row.with_cell(header: true, text: "Cell") %>
@ -49,24 +49,24 @@
<% end %>
<% end %>
<%= table.with_body do |body| %>
<% potential_errors.group_by(&:error).each do |error_message, errors| %>
<% errors.each_with_index do |error, index| %>
<% row_class = "grouped-rows" %>
<% row_class += " first-row" if index.zero? %>
<% row_class += " last-row" if index == errors.size - 1 %>
<% body.with_row(html_attributes: { class: row_class }) do |row| %>
<% row.with_cell(text: error.cell) %>
<% row.with_cell(text: question_for_field(error.field), html_attributes: { class: "govuk-!-width-one-half" }) %>
<% if index == 0 %>
<% row.with_cell(text: error_message.html_safe, rowspan: errors.size, html_attributes: { class: "govuk-!-font-weight-bold govuk-!-width-one-half grouped-multirow-cell" }) %>
<% end %>
<% row.with_cell(text: error.field.humanize) %>
<%= table.with_body do |body| %>
<% potential_errors.group_by(&:error).each_with_index do |(error_message, errors), group_index| %>
<% total_groups = potential_errors.group_by(&:error).size %>
<% errors.each_with_index do |error, index| %>
<% row_class = row_classes(index, errors.size) %>
<% body.with_row(html_attributes: { class: row_class }) do |row| %>
<% row.with_cell(text: error.cell) %>
<% row.with_cell(text: question_for_field(error.field), html_attributes: { class: "govuk-!-width-one-half" }) %>
<% if index == 0 %>
<% cell_class = cell_classes(group_index, total_groups) %>
<% row.with_cell(text: error_message.html_safe, rowspan: errors.size, html_attributes: { class: cell_class }) %>
<% end %>
<% row.with_cell(text: error.field.humanize) %>
<% end %>
<% end %>
<% end %>
<% end %>
<% end %>
<% end %>
</div>
</div>

13
app/components/bulk_upload_error_row_component.rb

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

2
app/components/bulk_upload_summary_component.html.erb

@ -4,7 +4,7 @@
<header class="app-log-summary__header">
<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="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>
</header>
<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">
<% items.each do |item| %>
<div class="app-document-list__item">

153
app/controllers/collection_resources_controller.rb

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

2
app/controllers/lettings_logs_controller.rb

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

2
app/controllers/sales_logs_controller.rb

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

2
app/controllers/start_controller.rb

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

17
app/controllers/users_controller.rb

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

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

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

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

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

2
app/helpers/collection_resources_helper.rb

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

2
app/helpers/filters_helper.rb

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

8
app/helpers/log_actions_helper.rb

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

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
else
start_year = log.startdate ? collection_start_year_for_date(log.startdate) : log.form.start_date.year
"This log is from the #{start_year}/#{start_year + 1} collection window, which is now closed."
"This log is from the #{start_year} to #{start_year + 1} collection window, which is now closed."
end
end

2
app/helpers/tasklist_helper.rb

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

2
app/models/bulk_upload.rb

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

38
app/models/collection_resource.rb

@ -1,9 +1,45 @@
class CollectionResource < ApplicationRecord
include Rails.application.routes.url_helpers
has_paper_trail
attr_accessor :file
scope :visible, -> { where(discarded_at: nil) }
validates :short_display_name, presence: true
def download_path
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

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

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

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,
},
]
@header = "Location"
@copy_key = "lettings.setup.location_id.less_than_twenty"
@next_unresolved_page_id = :check_answers
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,
},
]
@header = "Location"
@copy_key = "lettings.setup.location_id.twenty_or_more"
@next_unresolved_page_id = :check_answers
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)
super("rent_type", hsh, subsection)
@derived = true
@header = "Rent Type"
@copy_key = "lettings.setup.rent_type"
end
def questions

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

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

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)
super
@id = "assigned_to_id"
@check_answer_label = "Log owner"
@header = "Which user are you creating this log for?"
@derived = true
@type = "select"
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)
super
@id = "irproduct_other"
@check_answer_label = "Product name"
@header = "Name of rent product"
@copy_key = "lettings.setup.rent_type.irproduct_other"
@type = "text"
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] if form.start_date.present?
end

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)
super
@id = "location_id"
@check_answer_label = "Location"
@header = header_text
@copy_key = "lettings.setup.location_id.less_than_twenty"
@type = "radio"
@answer_options = answer_options
@inferred_answers = {
@ -56,13 +55,5 @@ private
false
end
def header_text
if form.start_date && form.start_date.year >= 2023
"Which location is this letting for?"
else
"Which location is this log for?"
end
end
QUESTION_NUMBER_FROM_YEAR = { 2023 => 10, 2024 => 5 }.freeze
end

12
app/models/form/lettings/questions/location_id_search.rb

@ -2,10 +2,8 @@ class Form::Lettings::Questions::LocationIdSearch < ::Form::Question
def initialize(id, hsh, page)
super
@id = "location_id"
@check_answer_label = "Location"
@header = header_text
@hint_text = '<div class="govuk-inset-text">This scheme has 20 or more locations.</div>Enter postcode or address.'
@type = "select"
@copy_key = "lettings.setup.location_id.twenty_or_more"
@answer_options = answer_options
@inferred_answers = {
"location.name": {
@ -52,13 +50,5 @@ private
false
end
def header_text
if form.start_date && form.start_date.year >= 2023
"Which location is this letting for?"
else
"Which location is this log for?"
end
end
QUESTION_NUMBER_FROM_YEAR = { 2023 => 10, 2024 => 5 }.freeze
end

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

@ -2,8 +2,6 @@ class Form::Lettings::Questions::ManagingOrganisation < ::Form::Question
def initialize(id, hsh, page)
super
@id = "managing_organisation_id"
@check_answer_label = "Managing agent"
@header = "Which organisation manages this letting?"
@derived = true
@type = "select"
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] if form.start_date.present?

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

@ -2,9 +2,6 @@ class Form::Lettings::Questions::NeedsType < ::Form::Question
def initialize(id, hsh, page)
super
@id = "needstype"
@check_answer_label = "Needs type"
@header = "What is the needs type?"
@hint_text = "General needs housing includes both self-contained and shared housing without support or specific adaptations. Supported housing can include direct access hostels, group homes, residential care and nursing homes."
@type = "radio"
@answer_options = ANSWER_OPTIONS
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] if form.start_date.present?

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

@ -2,9 +2,6 @@ class Form::Lettings::Questions::PropertyReference < ::Form::Question
def initialize(id, hsh, page)
super
@id = "propcode"
@check_answer_label = "Property reference"
@header = "What is the property reference?"
@hint_text = "This is how you usually refer to this property on your own systems."
@type = "text"
@width = 10
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] if form.start_date.present?

19
app/models/form/lettings/questions/renewal.rb

@ -2,11 +2,8 @@ class Form::Lettings::Questions::Renewal < ::Form::Question
def initialize(id, hsh, page)
super
@id = "renewal"
@check_answer_label = "Property renewal"
@header = header_text
@type = "radio"
@answer_options = ANSWER_OPTIONS
@hint_text = hint_text
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] if form.start_date.present?
end
@ -16,21 +13,5 @@ class Form::Lettings::Questions::Renewal < ::Form::Question
}
.freeze
def header_text
if form.start_year_after_2024?
"Is this letting a renewal of social housing to the same tenant in the same property?"
else
"Is this letting a renewal?"
end
end
def hint_text
if form.start_year_after_2024?
"If the property was previously being used as temporary accommodation, then answer 'no'"
else
"A renewal is a letting to the same tenant in the same property. If the property was previously being used as temporary accommodation, then answer 'no'"
end
end
QUESTION_NUMBER_FROM_YEAR = { 2023 => 4, 2024 => 6 }.freeze
end

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

@ -2,8 +2,7 @@ class Form::Lettings::Questions::RentType < ::Form::Question
def initialize(id, hsh, page)
super
@id = "rent_type"
@check_answer_label = "Rent type"
@header = "What is the rent type?"
@copy_key = "lettings.setup.rent_type.rent_type"
@type = "radio"
@top_guidance_partial = form.start_year_after_2024? ? "rent_type_definitions_2024" : "rent_type_definitions"
@answer_options = form.start_year_after_2024? ? ANSWER_OPTIONS_2024 : ANSWER_OPTIONS

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

@ -1,8 +1,6 @@
class Form::Lettings::Questions::SchemeId < ::Form::Question
def initialize(_id, hsh, page)
super("scheme_id", hsh, page)
@check_answer_label = "Scheme name"
@header = "What scheme is this log for?"
@type = "select"
@answer_options = answer_options
@top_guidance_partial = "finding_scheme"
@ -48,15 +46,6 @@ class Form::Lettings::Questions::SchemeId < ::Form::Question
lettings_log.form.get_question("postcode_full", nil).label_from_value(lettings_log.postcode_full) unless lettings_log.scheme_has_multiple_locations?
end
def hint_text
if form.start_year_after_2024?
"Enter postcode or scheme name.<br><br>
A supported housing scheme provides shared or self-contained housing for a particular client group, for example younger or vulnerable people."
else
"Enter postcode or scheme name"
end
end
private
def supported_housing_selected?(lettings_log)

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

@ -2,8 +2,6 @@ class Form::Lettings::Questions::StockOwner < ::Form::Question
def initialize(id, hsh, page)
super
@id = "owning_organisation_id"
@check_answer_label = "Stock owner"
@header = "Which organisation owns this property?"
@derived = true
@type = "select"
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] if form.start_date.present?

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

@ -2,8 +2,6 @@ class Form::Lettings::Questions::TenancyStartDate < ::Form::Question
def initialize(id, hsh, page)
super
@id = "startdate"
@check_answer_label = "Tenancy start date"
@header = "What is the tenancy start date?"
@type = "date"
@unresolved_hint_text = "Some scheme details have changed, and now this log needs updating. Check that the tenancy start date is correct."
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] if form.start_date.present?

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

@ -2,9 +2,6 @@ class Form::Lettings::Questions::TenantCode < ::Form::Question
def initialize(id, hsh, page)
super
@id = "tenancycode"
@check_answer_label = "Tenant code"
@header = "What is the tenant code?"
@hint_text = "This is how you usually refer to this tenancy on your own systems."
@type = "text"
@width = 10
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] if form.start_date.present?

1
app/models/form/sales/pages/age1.rb

@ -2,6 +2,7 @@ class Form::Sales::Pages::Age1 < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "buyer_1_age"
@copy_key = "sales.household_characteristics.age1"
@depends_on = [
{
"buyer_has_seen_privacy_notice?" => true,

1
app/models/form/sales/pages/age2.rb

@ -2,6 +2,7 @@ class Form::Sales::Pages::Age2 < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "buyer_2_age"
@copy_key = "sales.household_characteristics.age2.buyer"
@depends_on = [
{
"joint_purchase?" => true,

1
app/models/form/sales/pages/buyer1_ethnic_background_arab.rb

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

1
app/models/form/sales/pages/buyer1_ethnic_background_asian.rb

@ -2,6 +2,7 @@ class Form::Sales::Pages::Buyer1EthnicBackgroundAsian < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "buyer_1_ethnic_background_asian"
@copy_key = "sales.household_characteristics.ethnic.ethnic_background_asian"
@depends_on = [{
"ethnic_group" => 2,
}]

1
app/models/form/sales/pages/buyer1_ethnic_background_black.rb

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

1
app/models/form/sales/pages/buyer1_ethnic_background_mixed.rb

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

1
app/models/form/sales/pages/buyer1_ethnic_background_white.rb

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

1
app/models/form/sales/pages/buyer1_income.rb

@ -2,6 +2,7 @@ class Form::Sales::Pages::Buyer1Income < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "buyer_1_income"
@copy_key = "sales.income_benefits_and_savings.buyer_1_income"
end
def questions

3
app/models/form/sales/pages/buyer1_income_max_value_check.rb

@ -6,8 +6,9 @@ class Form::Sales::Pages::Buyer1IncomeMaxValueCheck < ::Form::Page
"income1_over_soft_max?" => true,
},
]
@copy_key = "sales.soft_validations.income1_value_check.max"
@title_text = {
"translation" => "soft_validations.income.over_soft_max_for_la_buyer_1",
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text",
"arguments" => [
{
"key" => "field_formatted_as_currency",

5
app/models/form/sales/pages/buyer1_income_min_value_check.rb

@ -6,8 +6,9 @@ class Form::Sales::Pages::Buyer1IncomeMinValueCheck < ::Form::Page
"income1_under_soft_min?" => true,
},
]
@copy_key = "sales.soft_validations.income1_value_check.min"
@title_text = {
"translation" => "soft_validations.income.under_soft_min_for_economic_status.title_text",
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text",
"arguments" => [
{
"key" => "field_formatted_as_currency",
@ -22,7 +23,7 @@ class Form::Sales::Pages::Buyer1IncomeMinValueCheck < ::Form::Page
],
}
@informative_text = {
"translation" => "soft_validations.income.under_soft_min_for_economic_status.hint_text",
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text",
"arguments" => [],
}
end

1
app/models/form/sales/pages/buyer2_ethnic_background_arab.rb

@ -2,6 +2,7 @@ class Form::Sales::Pages::Buyer2EthnicBackgroundArab < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "buyer_2_ethnic_background_arab"
@copy_key = "sales.household_characteristics.ethnicbuy2.ethnic_background_arab"
@depends_on = [{
"ethnic_group2" => 4,
}]

1
app/models/form/sales/pages/buyer2_ethnic_background_asian.rb

@ -2,6 +2,7 @@ class Form::Sales::Pages::Buyer2EthnicBackgroundAsian < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "buyer_2_ethnic_background_asian"
@copy_key = "sales.household_characteristics.ethnicbuy2.ethnic_background_asian"
@depends_on = [{
"ethnic_group2" => 2,
}]

1
app/models/form/sales/pages/buyer2_ethnic_background_black.rb

@ -2,6 +2,7 @@ class Form::Sales::Pages::Buyer2EthnicBackgroundBlack < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "buyer_2_ethnic_background_black"
@copy_key = "sales.household_characteristics.ethnicbuy2.ethnic_background_black"
@depends_on = [{
"ethnic_group2" => 3,
}]

1
app/models/form/sales/pages/buyer2_ethnic_background_mixed.rb

@ -2,6 +2,7 @@ class Form::Sales::Pages::Buyer2EthnicBackgroundMixed < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "buyer_2_ethnic_background_mixed"
@copy_key = "sales.household_characteristics.ethnicbuy2.ethnic_background_black"
@depends_on = [{
"ethnic_group2" => 1,
}]

1
app/models/form/sales/pages/buyer2_ethnic_background_white.rb

@ -2,6 +2,7 @@ class Form::Sales::Pages::Buyer2EthnicBackgroundWhite < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "buyer_2_ethnic_background_white"
@copy_key = "sales.household_characteristics.ethnicbuy2.ethnic_background_white"
@depends_on = [{
"ethnic_group2" => 0,
}]

1
app/models/form/sales/pages/buyer2_income.rb

@ -2,6 +2,7 @@ class Form::Sales::Pages::Buyer2Income < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "buyer_2_income"
@copy_key = "sales.income_benefits_and_savings.buyer_2_income"
@depends_on = [{
"joint_purchase?" => true,
}]

3
app/models/form/sales/pages/buyer2_income_max_value_check.rb

@ -6,8 +6,9 @@ class Form::Sales::Pages::Buyer2IncomeMaxValueCheck < ::Form::Page
"income2_over_soft_max?" => true,
},
]
@copy_key = "sales.soft_validations.income2_value_check.max"
@title_text = {
"translation" => "soft_validations.income.over_soft_max_for_la_buyer_2",
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text",
"arguments" => [
{
"key" => "field_formatted_as_currency",

5
app/models/form/sales/pages/buyer2_income_min_value_check.rb

@ -6,8 +6,9 @@ class Form::Sales::Pages::Buyer2IncomeMinValueCheck < ::Form::Page
"income2_under_soft_min?" => true,
},
]
@copy_key = "sales.soft_validations.income2_value_check.min"
@title_text = {
"translation" => "soft_validations.income.under_soft_min_for_economic_status.title_text",
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text",
"arguments" => [
{
"key" => "field_formatted_as_currency",
@ -22,7 +23,7 @@ class Form::Sales::Pages::Buyer2IncomeMinValueCheck < ::Form::Page
],
}
@informative_text = {
"translation" => "soft_validations.income.under_soft_min_for_economic_status.hint_text",
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text",
"arguments" => [],
}
end

1
app/models/form/sales/pages/buyer2_relationship_to_buyer1.rb

@ -2,6 +2,7 @@ class Form::Sales::Pages::Buyer2RelationshipToBuyer1 < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "buyer_2_relationship_to_buyer_1"
@copy_key = "sales.household_characteristics.relat2.buyer"
@depends_on = [
{
"joint_purchase?" => true,

1
app/models/form/sales/pages/buyer2_working_situation.rb

@ -2,6 +2,7 @@ class Form::Sales::Pages::Buyer2WorkingSituation < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "buyer_2_working_situation"
@copy_key = "sales.household_characteristics.ecstat2.buyer"
@depends_on = [
{
"joint_purchase?" => true,

2
app/models/form/sales/pages/buyer_interview.rb

@ -2,7 +2,7 @@ class Form::Sales::Pages::BuyerInterview < ::Form::Page
def initialize(id, hsh, subsection, joint_purchase:)
super(id, hsh, subsection)
@joint_purchase = joint_purchase
@copy_key = "sales.setup.noint.#{joint_purchase ? 'joint_purchase' : 'not_joint_purchase'}"
@copy_key = "sales.#{subsection.id}.noint.#{joint_purchase ? 'joint_purchase' : 'not_joint_purchase'}"
end
def questions

5
app/models/form/sales/pages/buyer_live_in_value_check.rb

@ -6,12 +6,13 @@ class Form::Sales::Pages::BuyerLiveInValueCheck < Form::Sales::Pages::Person
"buyer#{person_index}_livein_wrong_for_ownership_type?" => true,
},
]
@copy_key = "sales.soft_validations.buyer_livein_value_check.buyer#{person_index}"
@title_text = {
"translation" => "soft_validations.buyer#{person_index}_livein_wrong_for_ownership_type.title_text",
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text",
"arguments" => [{ "key" => "ownership_scheme", "label" => false, "i18n_template" => "ownership_scheme" }],
}
@informative_text = {
"translation" => "soft_validations.buyer#{person_index}_livein_wrong_for_ownership_type.hint_text",
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text",
"arguments" => [{ "key" => "ownership_scheme", "label" => false, "i18n_template" => "ownership_scheme" }],
}
end

3
app/models/form/sales/pages/combined_income_max_value_check.rb

@ -6,8 +6,9 @@ class Form::Sales::Pages::CombinedIncomeMaxValueCheck < ::Form::Page
"combined_income_over_soft_max?" => true,
},
]
@copy_key = "sales.soft_validations.combined_income_value_check"
@title_text = {
"translation" => "soft_validations.income.over_soft_max_for_la_combined",
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text",
"arguments" => [
{
"key" => "field_formatted_as_currency",

5
app/models/form/sales/pages/deposit_value_check.rb

@ -1,12 +1,13 @@
class Form::Sales::Pages::DepositValueCheck < ::Form::Page
def initialize(id, hsh, subsection, joint_purchase:)
super(id, hsh, subsection)
@copy_key = "sales.soft_validations.deposit_value_check.#{joint_purchase ? 'joint_purchase' : 'not_joint_purchase'}"
@informative_text = {
"translation" => "soft_validations.deposit.hint_text",
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text",
"arguments" => [],
}
@title_text = {
"translation" => "soft_validations.deposit.title_text.#{joint_purchase ? 'two' : 'one'}",
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text",
"arguments" => [
{
"key" => "field_formatted_as_currency",

1
app/models/form/sales/pages/gender_identity2.rb

@ -2,6 +2,7 @@ class Form::Sales::Pages::GenderIdentity2 < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "buyer_2_gender_identity"
@copy_key = "sales.household_characteristics.sex2.buyer"
@depends_on = [
{
"joint_purchase?" => true,

4
app/models/form/sales/pages/household_wheelchair_check.rb

@ -6,8 +6,8 @@ class Form::Sales::Pages::HouseholdWheelchairCheck < ::Form::Page
"wheelchair_when_not_disabled?" => true,
},
]
@informative_text = {}
@title_text = { "translation" => "soft_validations.wheelchair.title_text" }
@copy_key = "sales.soft_validations.wheel_value_check"
@title_text = { "translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text" }
end
def questions

1
app/models/form/sales/pages/housing_benefits.rb

@ -2,6 +2,7 @@ class Form::Sales::Pages::HousingBenefits < ::Form::Page
def initialize(id, hsh, subsection, joint_purchase:)
super(id, hsh, subsection)
@joint_purchase = joint_purchase
@copy_key = "sales.income_benefits_and_savings.housing_benefits.#{joint_purchase ? 'joint_purchase' : 'not_joint_purchase'}"
end
def questions

6
app/models/form/sales/pages/mortgage_value_check.rb

@ -2,10 +2,10 @@ class Form::Sales::Pages::MortgageValueCheck < ::Form::Page
def initialize(id, hsh, subsection, person_index = nil)
super(id, hsh, subsection)
@depends_on = depends_on
@informative_text = {}
@person_index = person_index
@copy_key = "sales.soft_validations.mortgage_value_check"
@title_text = {
"translation" => "soft_validations.mortgage.title_text",
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text",
"arguments" => [
{
"key" => "field_formatted_as_currency",
@ -15,7 +15,7 @@ class Form::Sales::Pages::MortgageValueCheck < ::Form::Page
],
}
@informative_text = {
"translation" => "soft_validations.mortgage.hint_text",
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text",
"arguments" => [],
}
end

8
app/models/form/sales/pages/multiple_partners_value_check.rb

@ -6,12 +6,16 @@ class Form::Sales::Pages::MultiplePartnersValueCheck < Form::Sales::Pages::Perso
"multiple_partners?" => true,
},
]
@copy_key = "sales.soft_validations.multiple_partners_value_check"
@person_index = person_index
@title_text = {
"translation" => "soft_validations.multiple_partners_sales.title",
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text",
"arguments" => [],
}
@informative_text = {
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text",
"arguments" => [],
}
@informative_text = {}
end
def questions

6
app/models/form/sales/pages/not_retired_value_check.rb

@ -7,11 +7,13 @@ class Form::Sales::Pages::NotRetiredValueCheck < Form::Sales::Pages::Person
},
]
@person_index = person_index
@copy_key = "sales.soft_validations.retirement_value_check.max"
@title_text = {
"translation" => "soft_validations.retirement.max.title",
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text",
}
@informative_text = {
"translation" => "soft_validations.retirement.max.hint_text",
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text",
"arguments" => [],
}
end

5
app/models/form/sales/pages/old_persons_shared_ownership_value_check.rb

@ -1,12 +1,13 @@
class Form::Sales::Pages::OldPersonsSharedOwnershipValueCheck < ::Form::Page
def initialize(id, hsh, subsection, joint_purchase:)
super(id, hsh, subsection)
@copy_key = "sales.soft_validations.old_persons_shared_ownership_value_check"
@title_text = {
"translation" => "soft_validations.old_persons_shared_ownership.title_text.#{joint_purchase ? 'two' : 'one'}",
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text.#{joint_purchase ? 'joint_purchase' : 'not_joint_purchase'}",
"arguments" => [],
}
@informative_text = {
"translation" => "soft_validations.old_persons_shared_ownership.hint_text",
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text",
"arguments" => [],
}
@joint_purchase = joint_purchase

8
app/models/form/sales/pages/partner_under_16_value_check.rb

@ -6,9 +6,10 @@ class Form::Sales::Pages::PartnerUnder16ValueCheck < Form::Sales::Pages::Person
"person_#{person_index}_partner_under_16?" => true,
},
]
@copy_key = "sales.soft_validations.partner_under_16_value_check"
@person_index = person_index
@title_text = {
"translation" => "soft_validations.partner_under_16_sales.title",
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text",
"arguments" => [
{
"key" => "age#{person_index}",
@ -17,7 +18,10 @@ class Form::Sales::Pages::PartnerUnder16ValueCheck < Form::Sales::Pages::Person
},
],
}
@informative_text = {}
@informative_text = {
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text",
"arguments" => [],
}
end
def questions

1
app/models/form/sales/pages/person_age.rb

@ -1,6 +1,7 @@
class Form::Sales::Pages::PersonAge < Form::Sales::Pages::Person
def initialize(id, hsh, subsection, person_index:)
super
@copy_key = person_index == 2 ? "sales.household_characteristics.age2.person" : "sales.household_characteristics.age#{person_index}"
@depends_on = [{ "details_known_#{person_index}" => 1 }]
end

1
app/models/form/sales/pages/person_gender_identity.rb

@ -1,6 +1,7 @@
class Form::Sales::Pages::PersonGenderIdentity < Form::Sales::Pages::Person
def initialize(id, hsh, subsection, person_index:)
super
@copy_key = "sales.household_characteristics.sex2.person" if person_index == 2
@depends_on = [
{ "details_known_#{person_index}" => 1 },
]

1
app/models/form/sales/pages/person_relationship_to_buyer_1.rb

@ -1,6 +1,7 @@
class Form::Sales::Pages::PersonRelationshipToBuyer1 < ::Form::Sales::Pages::Person
def initialize(id, hsh, subsection, person_index:)
super
@copy_key = "sales.household_characteristics.relat2.person" if person_index == 2
@depends_on = [
{ "details_known_#{person_index}" => 1 },
]

5
app/models/form/sales/pages/person_student_not_child_value_check.rb

@ -6,11 +6,12 @@ class Form::Sales::Pages::PersonStudentNotChildValueCheck < Form::Sales::Pages::
"person_#{person_index}_student_not_child?" => true,
},
]
@copy_key = "sales.soft_validations.student_not_child_value_check"
@person_index = person_index
@title_text = {
"translation" => "soft_validations.student_not_child.title_text",
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text",
}
@informative_text = {}
@informative_text = { "translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text", "arguments" => [] }
end
def questions

1
app/models/form/sales/pages/person_working_situation.rb

@ -1,6 +1,7 @@
class Form::Sales::Pages::PersonWorkingSituation < Form::Sales::Pages::Person
def initialize(id, hsh, subsection, person_index:)
super
@copy_key = "sales.household_characteristics.ecstat2.person" if person_index == 2
@depends_on = [
{
"details_known_#{person_index}" => 1,

1
app/models/form/sales/pages/previous_ownership.rb

@ -3,6 +3,7 @@ class Form::Sales::Pages::PreviousOwnership < ::Form::Page
super(id, hsh, subsection)
@joint_purchase = joint_purchase
@depends_on = [{ "joint_purchase?" => @joint_purchase }]
@copy_key = "sales.income_benefits_and_savings.prevown.#{joint_purchase ? 'joint_purchase' : 'not_joint_purchase'}"
end
def questions

2
app/models/form/sales/pages/privacy_notice.rb

@ -1,7 +1,7 @@
class Form::Sales::Pages::PrivacyNotice < ::Form::Page
def initialize(id, hsh, subsection, joint_purchase:)
super(id, hsh, subsection)
@copy_key = "sales.setup.privacynotice.#{joint_purchase ? 'joint_purchase' : 'not_joint_purchase'}"
@copy_key = "sales.#{subsection.id}.privacynotice.#{joint_purchase ? 'joint_purchase' : 'not_joint_purchase'}"
@joint_purchase = joint_purchase
end

8
app/models/form/sales/pages/retirement_value_check.rb

@ -7,8 +7,9 @@ class Form::Sales::Pages::RetirementValueCheck < Form::Sales::Pages::Person
},
]
@person_index = person_index
@copy_key = "sales.soft_validations.retirement_value_check.min"
@title_text = {
"translation" => "soft_validations.retirement.min.title",
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text",
"arguments" => [
{
"key" => "age#{person_index}",
@ -17,7 +18,10 @@ class Form::Sales::Pages::RetirementValueCheck < Form::Sales::Pages::Person
},
],
}
@informative_text = {}
@informative_text = {
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text",
"arguments" => [],
}
end
def questions

1
app/models/form/sales/pages/savings.rb

@ -2,6 +2,7 @@ class Form::Sales::Pages::Savings < ::Form::Page
def initialize(id, hsh, subsection, joint_purchase:)
super(id, hsh, subsection)
@joint_purchase = joint_purchase
@copy_key = "sales.income_benefits_and_savings.savings.#{joint_purchase ? 'joint_purchase' : 'not_joint_purchase'}"
end
def questions

5
app/models/form/sales/pages/savings_value_check.rb

@ -1,8 +1,9 @@
class Form::Sales::Pages::SavingsValueCheck < ::Form::Page
def initialize(id, hsh, subsection, joint_purchase:)
super(id, hsh, subsection)
@copy_key = "sales.soft_validations.savings_value_check.#{joint_purchase ? 'joint_purchase' : 'not_joint_purchase'}"
@title_text = {
"translation" => "soft_validations.savings.title_text.#{joint_purchase ? 'two' : 'one'}",
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text",
"arguments" => [
{
"key" => "field_formatted_as_currency",
@ -12,7 +13,7 @@ class Form::Sales::Pages::SavingsValueCheck < ::Form::Page
],
}
@informative_text = {
"translation" => "soft_validations.savings.hint_text",
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.informative_text",
"arguments" => [],
}
@joint_purchase = joint_purchase

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

@ -2,10 +2,9 @@ class Form::Sales::Questions::Age1 < ::Form::Question
def initialize(id, hsh, page)
super
@id = "age1"
@check_answer_label = "Buyer 1’s age"
@header = "Age"
@type = "numeric"
@width = 2
@copy_key = "sales.household_characteristics.age1.age1"
@inferred_check_answers_value = [
{
"condition" => { "age1_known" => 1 },

3
app/models/form/sales/questions/age2.rb

@ -2,8 +2,7 @@ class Form::Sales::Questions::Age2 < ::Form::Question
def initialize(id, hsh, page)
super
@id = "age2"
@check_answer_label = "Buyer 2’s age"
@header = "Age"
@copy_key = "sales.household_characteristics.age2.buyer.age2"
@type = "numeric"
@width = 2
@inferred_check_answers_value = [{

3
app/models/form/sales/questions/armed_forces.rb

@ -2,10 +2,7 @@ class Form::Sales::Questions::ArmedForces < ::Form::Question
def initialize(id, hsh, page)
super
@id = "hhregres"
@check_answer_label = "Have any of the buyers ever served as a regular in the UK armed forces?"
@header = "Have any of the buyers ever served as a regular in the UK armed forces?"
@type = "radio"
@hint_text = "A regular is somebody who has served in the Royal Navy, the Royal Marines, the Royal Airforce or Army full time and does not include reserve forces"
@answer_options = ANSWER_OPTIONS
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
end

2
app/models/form/sales/questions/armed_forces_spouse.rb

@ -2,8 +2,6 @@ class Form::Sales::Questions::ArmedForcesSpouse < ::Form::Question
def initialize(id, hsh, page)
super
@id = "armedforcesspouse"
@check_answer_label = "Are any of the buyers a spouse or civil partner of a UK armed forces regular who died in service within the last 2 years?"
@header = "Are any of the buyers a spouse or civil partner of a UK armed forces regular who died in service within the last 2 years?"
@type = "radio"
@answer_options = ANSWER_OPTIONS
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]

4
app/models/form/sales/questions/buyer1_age_known.rb

@ -2,11 +2,9 @@ class Form::Sales::Questions::Buyer1AgeKnown < ::Form::Question
def initialize(id, hsh, page)
super
@id = "age1_known"
@check_answer_label = "Buyer 1’s age"
@header = "Do you know buyer 1’s age?"
@type = "radio"
@copy_key = "sales.household_characteristics.age1.age1_known"
@answer_options = ANSWER_OPTIONS
@hint_text = "Buyer 1 is the person in the household who does the most paid work. If it’s a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest."
@conditional_for = {
"age1" => [0],
}

4
app/models/form/sales/questions/buyer1_ethnic_background_arab.rb

@ -2,11 +2,9 @@ class Form::Sales::Questions::Buyer1EthnicBackgroundArab < ::Form::Question
def initialize(id, hsh, page)
super
@id = "ethnic"
@check_answer_label = "Buyer 1’s ethnic background"
@header = "Which of the following best describes buyer 1’s Arab background?"
@copy_key = "sales.household_characteristics.ethnic.ethnic_background_arab"
@type = "radio"
@answer_options = ANSWER_OPTIONS
@hint_text = form.start_year_after_2024? ? "" : "Buyer 1 is the person in the household who does the most paid work. If it’s a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest."
@check_answers_card_number = 1
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
end

4
app/models/form/sales/questions/buyer1_ethnic_background_asian.rb

@ -2,11 +2,9 @@ class Form::Sales::Questions::Buyer1EthnicBackgroundAsian < ::Form::Question
def initialize(id, hsh, page)
super
@id = "ethnic"
@check_answer_label = "Buyer 1’s ethnic background"
@header = "Which of the following best describes buyer 1’s Asian or Asian British background?"
@copy_key = "sales.household_characteristics.ethnic.ethnic_background_asian"
@type = "radio"
@answer_options = ANSWER_OPTIONS
@hint_text = form.start_year_after_2024? ? "" : "Buyer 1 is the person in the household who does the most paid work. If it’s a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest."
@check_answers_card_number = 1
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
end

4
app/models/form/sales/questions/buyer1_ethnic_background_black.rb

@ -2,11 +2,9 @@ class Form::Sales::Questions::Buyer1EthnicBackgroundBlack < ::Form::Question
def initialize(id, hsh, page)
super
@id = "ethnic"
@check_answer_label = "Buyer 1’s ethnic background"
@header = "Which of the following best describes buyer 1’s Black, African, Caribbean or Black British background?"
@copy_key = "sales.household_characteristics.ethnic.ethnic_background_black"
@type = "radio"
@answer_options = ANSWER_OPTIONS
@hint_text = form.start_year_after_2024? ? "" : "Buyer 1 is the person in the household who does the most paid work. If it’s a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest."
@check_answers_card_number = 1
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
end

4
app/models/form/sales/questions/buyer1_ethnic_background_mixed.rb

@ -2,11 +2,9 @@ class Form::Sales::Questions::Buyer1EthnicBackgroundMixed < ::Form::Question
def initialize(id, hsh, page)
super
@id = "ethnic"
@check_answer_label = "Buyer 1’s ethnic background"
@header = "Which of the following best describes buyer 1’s Mixed or Multiple ethnic groups background?"
@copy_key = "sales.household_characteristics.ethnic.ethnic_background_mixed"
@type = "radio"
@answer_options = ANSWER_OPTIONS
@hint_text = form.start_year_after_2024? ? "" : "Buyer 1 is the person in the household who does the most paid work. If it’s a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest."
@check_answers_card_number = 1
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
end

4
app/models/form/sales/questions/buyer1_ethnic_background_white.rb

@ -2,10 +2,8 @@ class Form::Sales::Questions::Buyer1EthnicBackgroundWhite < ::Form::Question
def initialize(id, hsh, page)
super
@id = "ethnic"
@check_answer_label = "Buyer 1’s ethnic background"
@header = "Which of the following best describes buyer 1’s White background?"
@copy_key = "sales.household_characteristics.ethnic.ethnic_background_white"
@type = "radio"
@hint_text = form.start_year_after_2024? ? "" : "Buyer 1 is the person in the household who does the most paid work. If it’s a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest."
@check_answers_card_number = 1
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
end

3
app/models/form/sales/questions/buyer1_ethnic_group.rb

@ -2,11 +2,8 @@ class Form::Sales::Questions::Buyer1EthnicGroup < ::Form::Question
def initialize(id, hsh, page)
super
@id = "ethnic_group"
@check_answer_label = "Buyer 1’s ethnic group"
@header = "What is buyer 1’s ethnic group?"
@type = "radio"
@answer_options = ANSWER_OPTIONS
@hint_text = form.start_year_after_2024? ? "" : "Buyer 1 is the person in the household who does the most paid work. If it’s a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest."
@check_answers_card_number = 1
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
end

4
app/models/form/sales/questions/buyer1_income.rb

@ -2,9 +2,7 @@ class Form::Sales::Questions::Buyer1Income < ::Form::Question
def initialize(id, hsh, page)
super
@id = "income1"
@check_answer_label = "Buyer 1’s gross annual income"
@header = "Buyer 1’s gross annual income"
@hint_text = "Provide the gross annual income (i.e. salary before tax) plus the annual amount of benefits, Universal Credit or pensions, and income from investments."
@copy_key = "sales.income_benefits_and_savings.buyer_1_income.income1"
@type = "numeric"
@min = 0
@max = 999_999

3
app/models/form/sales/questions/buyer1_income_known.rb

@ -2,8 +2,7 @@ class Form::Sales::Questions::Buyer1IncomeKnown < ::Form::Question
def initialize(id, hsh, page)
super
@id = "income1nk"
@check_answer_label = "Buyer 1’s gross annual income known?"
@header = "Do you know buyer 1’s annual income?"
@copy_key = "sales.income_benefits_and_savings.buyer_1_income.income1nk"
@type = "radio"
@answer_options = ANSWER_OPTIONS
@conditional_for = {

3
app/models/form/sales/questions/buyer1_income_value_check.rb

@ -2,8 +2,7 @@ class Form::Sales::Questions::Buyer1IncomeValueCheck < ::Form::Question
def initialize(id, hsh, page, check_answers_card_number:)
super(id, hsh, page)
@id = "income1_value_check"
@check_answer_label = "Buyer 1 income confirmation"
@header = "Are you sure this is correct?"
@copy_key = "sales.soft_validations.income1_value_check"
@type = "interruption_screen"
@answer_options = {
"0" => { "value" => "Yes" },

3
app/models/form/sales/questions/buyer1_live_in_property.rb

@ -2,11 +2,8 @@ class Form::Sales::Questions::Buyer1LiveInProperty < ::Form::Question
def initialize(id, hsh, page)
super
@id = "buy1livein"
@check_answer_label = "Will buyer 1 live in the property?"
@header = "Will buyer 1 live in the property?"
@type = "radio"
@answer_options = ANSWER_OPTIONS
@hint_text = form.start_year_after_2024? ? "" : "Buyer 1 is the person in the household who does the most paid work. If it’s a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest."
@check_answers_card_number = 1
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
end

2
app/models/form/sales/questions/buyer1_mortgage.rb

@ -2,8 +2,6 @@ class Form::Sales::Questions::Buyer1Mortgage < ::Form::Question
def initialize(id, hsh, page)
super
@id = "inc1mort"
@check_answer_label = "Buyer 1’s income used for mortgage application"
@header = "Was buyer 1’s income used for a mortgage application?"
@type = "radio"
@answer_options = ANSWER_OPTIONS
@check_answers_card_number = 1

3
app/models/form/sales/questions/buyer1_nationality.rb

@ -2,10 +2,7 @@ class Form::Sales::Questions::Buyer1Nationality < ::Form::Question
def initialize(id, hsh, page)
super
@id = "national"
@check_answer_label = "Buyer 1’s nationality"
@header = "What is buyer 1’s nationality?"
@type = "radio"
@hint_text = "Buyer 1 is the person in the household who does the most paid work. If it’s a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest."
@answer_options = ANSWER_OPTIONS
@check_answers_card_number = 1
@inferred_check_answers_value = [{

3
app/models/form/sales/questions/buyer1_working_situation.rb

@ -2,11 +2,8 @@ class Form::Sales::Questions::Buyer1WorkingSituation < ::Form::Question
def initialize(id, hsh, page)
super
@id = "ecstat1"
@check_answer_label = "Buyer 1's working situation"
@header = "Which of these best describes buyer 1's working situation?"
@type = "radio"
@answer_options = ANSWER_OPTIONS
@hint_text = form.start_year_after_2024? ? "" : "Buyer 1 is the person in the household who does the most paid work. If it’s a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest."
@check_answers_card_number = 1
@inferred_check_answers_value = [{
"condition" => {

3
app/models/form/sales/questions/buyer2_age_known.rb

@ -2,8 +2,7 @@ class Form::Sales::Questions::Buyer2AgeKnown < ::Form::Question
def initialize(id, hsh, page)
super
@id = "age2_known"
@check_answer_label = "Buyer 2’s age"
@header = "Do you know buyer 2’s age?"
@copy_key = "sales.household_characteristics.age2.buyer.age2_known"
@type = "radio"
@answer_options = ANSWER_OPTIONS
@conditional_for = {

3
app/models/form/sales/questions/buyer2_ethnic_background_arab.rb

@ -2,8 +2,7 @@ class Form::Sales::Questions::Buyer2EthnicBackgroundArab < ::Form::Question
def initialize(id, hsh, page)
super
@id = "ethnicbuy2"
@check_answer_label = "Buyer 2’s ethnic background"
@header = "Which of the following best describes buyer 2’s Arab background?"
@copy_key = "sales.household_characteristics.ethnicbuy2.ethnic_background_arab"
@type = "radio"
@answer_options = ANSWER_OPTIONS
@check_answers_card_number = 2

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

Loading…
Cancel
Save