diff --git a/app/controllers/bulk_upload_lettings_results_controller.rb b/app/controllers/bulk_upload_lettings_results_controller.rb
new file mode 100644
index 000000000..a0a962b3e
--- /dev/null
+++ b/app/controllers/bulk_upload_lettings_results_controller.rb
@@ -0,0 +1,9 @@
+class BulkUploadLettingsResultsController < ApplicationController
+ before_action :authenticate_user!
+
+ rescue_from ActiveRecord::RecordNotFound, with: :render_not_found
+
+ def show
+ @bulk_upload = current_user.bulk_uploads.lettings.find(params[:id])
+ end
+end
diff --git a/app/controllers/bulk_upload_sales_results_controller.rb b/app/controllers/bulk_upload_sales_results_controller.rb
new file mode 100644
index 000000000..6af8cb659
--- /dev/null
+++ b/app/controllers/bulk_upload_sales_results_controller.rb
@@ -0,0 +1,9 @@
+class BulkUploadSalesResultsController < ApplicationController
+ before_action :authenticate_user!
+
+ rescue_from ActiveRecord::RecordNotFound, with: :render_not_found
+
+ def show
+ @bulk_upload = current_user.bulk_uploads.sales.find(params[:id])
+ end
+end
diff --git a/app/controllers/organisations_controller.rb b/app/controllers/organisations_controller.rb
index 0121b5e34..0c8c4a172 100644
--- a/app/controllers/organisations_controller.rb
+++ b/app/controllers/organisations_controller.rb
@@ -6,8 +6,8 @@ class OrganisationsController < ApplicationController
before_action :authenticate_user!
before_action :find_resource, except: %i[index new create]
before_action :authenticate_scope!, except: [:index]
- before_action -> { session_filters(specific_org: true) }, if: -> { current_user.support? }
- before_action :set_session_filters, if: -> { current_user.support? }
+ before_action -> { session_filters(specific_org: true) }, if: -> { current_user.support? || current_user.organisation.has_managing_agents? }
+ before_action :set_session_filters, if: -> { current_user.support? || current_user.organisation.has_managing_agents? }
def index
redirect_to organisation_path(current_user.organisation) unless current_user.support?
diff --git a/app/helpers/filters_helper.rb b/app/helpers/filters_helper.rb
index 507274be0..a1875081c 100644
--- a/app/helpers/filters_helper.rb
+++ b/app/helpers/filters_helper.rb
@@ -22,4 +22,9 @@ module FiltersHelper
JSON.parse(session[:logs_filters])[filter] || ""
end
+
+ def organisations_filter_options(user)
+ organisation_options = user.support? ? Organisation.all : [user.organisation] + user.organisation.managing_agents
+ [OpenStruct.new(id: "", name: "Select an option")] + organisation_options.map { |org| OpenStruct.new(id: org.id, name: org.name) }
+ end
end
diff --git a/app/jobs/process_bulk_upload_job.rb b/app/jobs/process_bulk_upload_job.rb
new file mode 100644
index 000000000..59be3ec9e
--- /dev/null
+++ b/app/jobs/process_bulk_upload_job.rb
@@ -0,0 +1,7 @@
+class ProcessBulkUploadJob < ApplicationJob
+ queue_as :default
+
+ def perform(bulk_upload:)
+ BulkUpload::Processor.new(bulk_upload:).call
+ end
+end
diff --git a/app/models/bulk_upload.rb b/app/models/bulk_upload.rb
index 8b007f450..3cab1fe23 100644
--- a/app/models/bulk_upload.rb
+++ b/app/models/bulk_upload.rb
@@ -2,9 +2,14 @@ class BulkUpload < ApplicationRecord
enum log_type: { lettings: "lettings", sales: "sales" }
belongs_to :user
+ has_many :bulk_upload_errors
after_initialize :generate_identifier, unless: :identifier
+ def year_combo
+ "#{year}/#{year - 2000 + 1}"
+ end
+
private
def generate_identifier
diff --git a/app/models/bulk_upload_error.rb b/app/models/bulk_upload_error.rb
new file mode 100644
index 000000000..df584b63e
--- /dev/null
+++ b/app/models/bulk_upload_error.rb
@@ -0,0 +1,3 @@
+class BulkUploadError < ApplicationRecord
+ belongs_to :bulk_upload
+end
diff --git a/app/models/derived_variables/sales_log_variables.rb b/app/models/derived_variables/sales_log_variables.rb
index 034816090..a527ed3f0 100644
--- a/app/models/derived_variables/sales_log_variables.rb
+++ b/app/models/derived_variables/sales_log_variables.rb
@@ -15,5 +15,6 @@ module DerivedVariables::SalesLogVariables
if mscharge_known.present? && mscharge_known.zero?
self.mscharge = 0
end
+ self.pcode1, self.pcode2 = postcode_full.split(" ") if postcode_full.present?
end
end
diff --git a/app/models/form.rb b/app/models/form.rb
index fceb48b65..5f6544086 100644
--- a/app/models/form.rb
+++ b/app/models/form.rb
@@ -167,10 +167,12 @@ class Form
if %w[radio checkbox].include?(question.type)
enabled_answer_options = enabled_question_ids.include?(question.id) ? enabled_questions.find { |q| q.id == question.id }.answer_options : {}
current_answer_option_valid = enabled_answer_options.present? ? enabled_answer_options.key?(log.public_send(question.id).to_s) : false
+
if !current_answer_option_valid && log.respond_to?(question.id.to_s)
Rails.logger.debug("Cleared #{question.id} value")
log.public_send("#{question.id}=", nil)
else
+
(question.answer_options.keys - enabled_answer_options.keys).map do |invalid_answer_option|
Rails.logger.debug("Cleared #{invalid_answer_option} value")
log.public_send("#{invalid_answer_option}=", nil) if log.respond_to?(invalid_answer_option)
diff --git a/app/models/form/common/pages/created_by.rb b/app/models/form/common/pages/created_by.rb
index e02f97740..94c7dc587 100644
--- a/app/models/form/common/pages/created_by.rb
+++ b/app/models/form/common/pages/created_by.rb
@@ -2,9 +2,6 @@ class Form::Common::Pages::CreatedBy < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "created_by"
- @header = ""
- @description = ""
- @subsection = subsection
end
def questions
diff --git a/app/models/form/common/pages/organisation.rb b/app/models/form/common/pages/organisation.rb
index 48b157a56..eb799d1e9 100644
--- a/app/models/form/common/pages/organisation.rb
+++ b/app/models/form/common/pages/organisation.rb
@@ -2,9 +2,6 @@ class Form::Common::Pages::Organisation < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "organisation"
- @header = ""
- @description = ""
- @subsection = subsection
end
def questions
diff --git a/app/models/form/common/questions/created_by_id.rb b/app/models/form/common/questions/created_by_id.rb
index b8409d99c..5b6631868 100644
--- a/app/models/form/common/questions/created_by_id.rb
+++ b/app/models/form/common/questions/created_by_id.rb
@@ -4,9 +4,7 @@ class Form::Common::Questions::CreatedById < ::Form::Question
@id = "created_by_id"
@check_answer_label = "User"
@header = "Which user are you creating this log for?"
- @hint_text = ""
@type = "select"
- @page = page
end
def answer_options
diff --git a/app/models/form/common/questions/owning_organisation_id.rb b/app/models/form/common/questions/owning_organisation_id.rb
index 9adb0bf64..c09968ef9 100644
--- a/app/models/form/common/questions/owning_organisation_id.rb
+++ b/app/models/form/common/questions/owning_organisation_id.rb
@@ -4,9 +4,7 @@ class Form::Common::Questions::OwningOrganisationId < ::Form::Question
@id = "owning_organisation_id"
@check_answer_label = "Owning organisation"
@header = "Which organisation owns this log?"
- @hint_text = ""
@type = "select"
- @page = page
end
def answer_options
diff --git a/app/models/form/lettings/pages/created_by.rb b/app/models/form/lettings/pages/created_by.rb
index 42289befa..8a30428e0 100644
--- a/app/models/form/lettings/pages/created_by.rb
+++ b/app/models/form/lettings/pages/created_by.rb
@@ -2,9 +2,6 @@ class Form::Lettings::Pages::CreatedBy < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "created_by"
- @header = ""
- @description = ""
- @subsection = subsection
end
def questions
diff --git a/app/models/form/lettings/pages/location.rb b/app/models/form/lettings/pages/location.rb
index d15091cb5..9641d0e1a 100644
--- a/app/models/form/lettings/pages/location.rb
+++ b/app/models/form/lettings/pages/location.rb
@@ -1,8 +1,6 @@
class Form::Lettings::Pages::Location < ::Form::Page
def initialize(_id, hsh, subsection)
super("location", hsh, subsection)
- @header = ""
- @description = ""
@depends_on = [{
"needstype" => 2,
"scheme_has_multiple_locations?" => true,
diff --git a/app/models/form/lettings/pages/managing_organisation.rb b/app/models/form/lettings/pages/managing_organisation.rb
index bc8534999..1be4e3daa 100644
--- a/app/models/form/lettings/pages/managing_organisation.rb
+++ b/app/models/form/lettings/pages/managing_organisation.rb
@@ -2,9 +2,6 @@ class Form::Lettings::Pages::ManagingOrganisation < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "managing_organisation"
- @header = ""
- @description = ""
- @subsection = subsection
end
def questions
diff --git a/app/models/form/lettings/pages/needs_type.rb b/app/models/form/lettings/pages/needs_type.rb
index 0a67d831b..11f36fa4e 100644
--- a/app/models/form/lettings/pages/needs_type.rb
+++ b/app/models/form/lettings/pages/needs_type.rb
@@ -2,9 +2,6 @@ class Form::Lettings::Pages::NeedsType < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "needs_type"
- @header = ""
- @description = ""
- @subsection = subsection
end
def questions
diff --git a/app/models/form/lettings/pages/property_reference.rb b/app/models/form/lettings/pages/property_reference.rb
index 150974ee8..d8cc09b79 100644
--- a/app/models/form/lettings/pages/property_reference.rb
+++ b/app/models/form/lettings/pages/property_reference.rb
@@ -2,9 +2,6 @@ class Form::Lettings::Pages::PropertyReference < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "property_reference"
- @header = ""
- @description = ""
- @subsection = subsection
end
def questions
diff --git a/app/models/form/lettings/pages/renewal.rb b/app/models/form/lettings/pages/renewal.rb
index 873ff8822..01cc81426 100644
--- a/app/models/form/lettings/pages/renewal.rb
+++ b/app/models/form/lettings/pages/renewal.rb
@@ -2,9 +2,6 @@ class Form::Lettings::Pages::Renewal < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "renewal"
- @header = ""
- @description = ""
- @subsection = subsection
end
def questions
diff --git a/app/models/form/lettings/pages/rent_type.rb b/app/models/form/lettings/pages/rent_type.rb
index d1ac4de99..faf3dfefc 100644
--- a/app/models/form/lettings/pages/rent_type.rb
+++ b/app/models/form/lettings/pages/rent_type.rb
@@ -1,8 +1,6 @@
class Form::Lettings::Pages::RentType < ::Form::Page
def initialize(_id, hsh, subsection)
super("rent_type", hsh, subsection)
- @header = ""
- @description = ""
@derived = true
end
diff --git a/app/models/form/lettings/pages/scheme.rb b/app/models/form/lettings/pages/scheme.rb
index 77828e1cf..afa436864 100644
--- a/app/models/form/lettings/pages/scheme.rb
+++ b/app/models/form/lettings/pages/scheme.rb
@@ -1,8 +1,6 @@
class Form::Lettings::Pages::Scheme < ::Form::Page
def initialize(_id, hsh, subsection)
super("scheme", hsh, subsection)
- @header = ""
- @description = ""
@depends_on = [{
"needstype" => 2,
}]
diff --git a/app/models/form/lettings/pages/stock_owner.rb b/app/models/form/lettings/pages/stock_owner.rb
index d142214c5..d92824f0e 100644
--- a/app/models/form/lettings/pages/stock_owner.rb
+++ b/app/models/form/lettings/pages/stock_owner.rb
@@ -2,9 +2,6 @@ class Form::Lettings::Pages::StockOwner < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "stock_owner"
- @header = ""
- @description = ""
- @subsection = subsection
end
def questions
diff --git a/app/models/form/lettings/pages/tenancy_start_date.rb b/app/models/form/lettings/pages/tenancy_start_date.rb
index fd0810893..bd9bbbb5d 100644
--- a/app/models/form/lettings/pages/tenancy_start_date.rb
+++ b/app/models/form/lettings/pages/tenancy_start_date.rb
@@ -2,8 +2,6 @@ class Form::Lettings::Pages::TenancyStartDate < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "tenancy_start_date"
- @description = ""
- @subsection = subsection
@next_unresolved_page_id = "scheme"
end
diff --git a/app/models/form/lettings/pages/tenant_code.rb b/app/models/form/lettings/pages/tenant_code.rb
index 67771514a..eaf7a9f8a 100644
--- a/app/models/form/lettings/pages/tenant_code.rb
+++ b/app/models/form/lettings/pages/tenant_code.rb
@@ -2,9 +2,6 @@ class Form::Lettings::Pages::TenantCode < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "tenant_code"
- @header = ""
- @description = ""
- @subsection = subsection
end
def questions
diff --git a/app/models/form/lettings/questions/created_by_id.rb b/app/models/form/lettings/questions/created_by_id.rb
index a120e72a8..d61be8882 100644
--- a/app/models/form/lettings/questions/created_by_id.rb
+++ b/app/models/form/lettings/questions/created_by_id.rb
@@ -4,9 +4,7 @@ class Form::Lettings::Questions::CreatedById < ::Form::Question
@id = "created_by_id"
@check_answer_label = "Log owner"
@header = "Which user are you creating this log for?"
- @hint_text = ""
@type = "select"
- @page = page
end
def answer_options
diff --git a/app/models/form/lettings/questions/irproduct_other.rb b/app/models/form/lettings/questions/irproduct_other.rb
index 7607d6d9c..99945ceea 100644
--- a/app/models/form/lettings/questions/irproduct_other.rb
+++ b/app/models/form/lettings/questions/irproduct_other.rb
@@ -5,6 +5,5 @@ class Form::Lettings::Questions::IrproductOther < ::Form::Question
@check_answer_label = "Product name"
@header = "Name of rent product"
@type = "text"
- @page = page
end
end
diff --git a/app/models/form/lettings/questions/location_id.rb b/app/models/form/lettings/questions/location_id.rb
index 84b37ec50..07ed61318 100644
--- a/app/models/form/lettings/questions/location_id.rb
+++ b/app/models/form/lettings/questions/location_id.rb
@@ -3,7 +3,6 @@ class Form::Lettings::Questions::LocationId < ::Form::Question
super("location_id", hsh, page)
@check_answer_label = "Location"
@header = "Which location is this log for?"
- @hint_text = ""
@type = "radio"
@answer_options = answer_options
@inferred_answers = {
diff --git a/app/models/form/lettings/questions/managing_organisation.rb b/app/models/form/lettings/questions/managing_organisation.rb
index 3f33c8617..bd4f57fe8 100644
--- a/app/models/form/lettings/questions/managing_organisation.rb
+++ b/app/models/form/lettings/questions/managing_organisation.rb
@@ -8,7 +8,6 @@ class Form::Lettings::Questions::ManagingOrganisation < ::Form::Question
@header = "Which organisation manages this letting?"
@type = "select"
@answer_options = answer_options
- @page = page
end
def answer_options
diff --git a/app/models/form/lettings/questions/needs_type.rb b/app/models/form/lettings/questions/needs_type.rb
index 46949a2bf..331899821 100644
--- a/app/models/form/lettings/questions/needs_type.rb
+++ b/app/models/form/lettings/questions/needs_type.rb
@@ -7,7 +7,6 @@ class Form::Lettings::Questions::NeedsType < ::Form::Question
@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
- @page = page
end
ANSWER_OPTIONS = {
diff --git a/app/models/form/lettings/questions/property_reference.rb b/app/models/form/lettings/questions/property_reference.rb
index 40517b9d3..75168f1bd 100644
--- a/app/models/form/lettings/questions/property_reference.rb
+++ b/app/models/form/lettings/questions/property_reference.rb
@@ -7,6 +7,5 @@ class Form::Lettings::Questions::PropertyReference < ::Form::Question
@hint_text = "This is how you usually refer to this property on your own systems."
@type = "text"
@width = 10
- @page = page
end
end
diff --git a/app/models/form/lettings/questions/renewal.rb b/app/models/form/lettings/questions/renewal.rb
index 06b5f0ff4..1282984cc 100644
--- a/app/models/form/lettings/questions/renewal.rb
+++ b/app/models/form/lettings/questions/renewal.rb
@@ -4,10 +4,8 @@ class Form::Lettings::Questions::Renewal < ::Form::Question
@id = "renewal"
@check_answer_label = "Property renewal"
@header = "Is this letting a renewal?"
- @hint_text = ""
@type = "radio"
@answer_options = ANSWER_OPTIONS
- @page = page
end
ANSWER_OPTIONS = {
diff --git a/app/models/form/lettings/questions/rent_type.rb b/app/models/form/lettings/questions/rent_type.rb
index c7c23c74b..64e2839e2 100644
--- a/app/models/form/lettings/questions/rent_type.rb
+++ b/app/models/form/lettings/questions/rent_type.rb
@@ -4,11 +4,9 @@ class Form::Lettings::Questions::RentType < ::Form::Question
@id = "rent_type"
@check_answer_label = "Rent type"
@header = "What is the rent type?"
- @hint_text = ""
@type = "radio"
@answer_options = ANSWER_OPTIONS
@conditional_for = { "irproduct_other" => [5] }
- @page = page
end
ANSWER_OPTIONS = {
diff --git a/app/models/form/lettings/questions/stock_owner.rb b/app/models/form/lettings/questions/stock_owner.rb
index 1f4323531..de82258a6 100644
--- a/app/models/form/lettings/questions/stock_owner.rb
+++ b/app/models/form/lettings/questions/stock_owner.rb
@@ -7,7 +7,6 @@ class Form::Lettings::Questions::StockOwner < ::Form::Question
@check_answer_label = "Stock owner"
@header = "Which organisation owns this property?"
@type = "select"
- @page = page
end
def answer_options
diff --git a/app/models/form/lettings/questions/tenancy_start_date.rb b/app/models/form/lettings/questions/tenancy_start_date.rb
index 925eb00bc..b50021597 100644
--- a/app/models/form/lettings/questions/tenancy_start_date.rb
+++ b/app/models/form/lettings/questions/tenancy_start_date.rb
@@ -6,6 +6,5 @@ class Form::Lettings::Questions::TenancyStartDate < ::Form::Question
@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."
- @page = page
end
end
diff --git a/app/models/form/lettings/questions/tenant_code.rb b/app/models/form/lettings/questions/tenant_code.rb
index dcbbb72a8..1872ebe8e 100644
--- a/app/models/form/lettings/questions/tenant_code.rb
+++ b/app/models/form/lettings/questions/tenant_code.rb
@@ -7,6 +7,5 @@ class Form::Lettings::Questions::TenantCode < ::Form::Question
@hint_text = "This is how you usually refer to this tenancy on your own systems."
@type = "text"
@width = 10
- @page = page
end
end
diff --git a/app/models/form/sales/pages/about_deposit_with_discount.rb b/app/models/form/sales/pages/about_deposit_with_discount.rb
index 1de5365aa..6a4a54071 100644
--- a/app/models/form/sales/pages/about_deposit_with_discount.rb
+++ b/app/models/form/sales/pages/about_deposit_with_discount.rb
@@ -3,8 +3,6 @@ class Form::Sales::Pages::AboutDepositWithDiscount < ::Form::Page
super
@id = "about_deposit_with_discount"
@header = "About the deposit"
- @description = ""
- @subsection = subsection
@depends_on = [{ "is_type_discount?" => true }]
end
diff --git a/app/models/form/sales/pages/about_deposit_without_discount.rb b/app/models/form/sales/pages/about_deposit_without_discount.rb
index 00f306208..65a59e6c0 100644
--- a/app/models/form/sales/pages/about_deposit_without_discount.rb
+++ b/app/models/form/sales/pages/about_deposit_without_discount.rb
@@ -2,8 +2,6 @@ class Form::Sales::Pages::AboutDepositWithoutDiscount < ::Form::Page
def initialize(id, hsh, subsection)
super
@header = "About the deposit"
- @description = ""
- @subsection = subsection
@depends_on = [{ "is_type_discount?" => false }]
end
diff --git a/app/models/form/sales/pages/about_price_not_rtb.rb b/app/models/form/sales/pages/about_price_not_rtb.rb
index 795ed9226..6e1011a28 100644
--- a/app/models/form/sales/pages/about_price_not_rtb.rb
+++ b/app/models/form/sales/pages/about_price_not_rtb.rb
@@ -3,8 +3,6 @@ class Form::Sales::Pages::AboutPriceNotRtb < ::Form::Page
super
@id = "about_price_not_rtb"
@header = "About the price of the property"
- @description = ""
- @subsection = subsection
@depends_on = [{
"right_to_buy?" => false,
}]
diff --git a/app/models/form/sales/pages/about_price_rtb.rb b/app/models/form/sales/pages/about_price_rtb.rb
index ec90afa01..ff338f6f6 100644
--- a/app/models/form/sales/pages/about_price_rtb.rb
+++ b/app/models/form/sales/pages/about_price_rtb.rb
@@ -3,8 +3,6 @@ class Form::Sales::Pages::AboutPriceRtb < ::Form::Page
super
@id = "about_price_rtb"
@header = "About the price of the property"
- @description = ""
- @subsection = subsection
@depends_on = [{
"right_to_buy?" => true,
}]
diff --git a/app/models/form/sales/pages/about_price_shared_ownership.rb b/app/models/form/sales/pages/about_price_shared_ownership.rb
index b3f34c121..1f65a7d19 100644
--- a/app/models/form/sales/pages/about_price_shared_ownership.rb
+++ b/app/models/form/sales/pages/about_price_shared_ownership.rb
@@ -3,8 +3,6 @@ class Form::Sales::Pages::AboutPriceSharedOwnership < ::Form::Page
super
@id = "about_price_shared_ownership"
@header = "About the price of the property"
- @description = ""
- @subsection = subsection
end
def questions
diff --git a/app/models/form/sales/pages/about_staircase.rb b/app/models/form/sales/pages/about_staircase.rb
index 03ea570f7..fd740c10e 100644
--- a/app/models/form/sales/pages/about_staircase.rb
+++ b/app/models/form/sales/pages/about_staircase.rb
@@ -3,8 +3,6 @@ class Form::Sales::Pages::AboutStaircase < ::Form::Page
super
@id = "about_staircasing"
@header = "About the staircasing transaction"
- @description = ""
- @subsection = subsection
@depends_on = [{
"staircase" => 1,
}]
diff --git a/app/models/form/sales/pages/age1.rb b/app/models/form/sales/pages/age1.rb
index 833758056..de9b1ef8d 100644
--- a/app/models/form/sales/pages/age1.rb
+++ b/app/models/form/sales/pages/age1.rb
@@ -2,9 +2,6 @@ class Form::Sales::Pages::Age1 < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "buyer_1_age"
- @header = ""
- @description = ""
- @subsection = subsection
end
def questions
diff --git a/app/models/form/sales/pages/age2.rb b/app/models/form/sales/pages/age2.rb
index b744935c6..d849c1465 100644
--- a/app/models/form/sales/pages/age2.rb
+++ b/app/models/form/sales/pages/age2.rb
@@ -2,9 +2,6 @@ class Form::Sales::Pages::Age2 < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "buyer_2_age"
- @header = ""
- @description = ""
- @subsection = subsection
@depends_on = [{
"jointpur" => 1,
}]
diff --git a/app/models/form/sales/pages/armed_forces.rb b/app/models/form/sales/pages/armed_forces.rb
index 006380f02..d96f6a832 100644
--- a/app/models/form/sales/pages/armed_forces.rb
+++ b/app/models/form/sales/pages/armed_forces.rb
@@ -2,9 +2,6 @@ class Form::Sales::Pages::ArmedForces < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "armed_forces"
- @header = ""
- @description = ""
- @subsection = subsection
end
def questions
diff --git a/app/models/form/sales/pages/armed_forces_spouse.rb b/app/models/form/sales/pages/armed_forces_spouse.rb
index 7c4128b87..9dcc393fd 100644
--- a/app/models/form/sales/pages/armed_forces_spouse.rb
+++ b/app/models/form/sales/pages/armed_forces_spouse.rb
@@ -2,9 +2,6 @@ class Form::Sales::Pages::ArmedForcesSpouse < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "armed_forces_spouse"
- @header = ""
- @description = ""
- @subsection = subsection
end
def questions
diff --git a/app/models/form/sales/pages/buyer1_ethnic_background_arab.rb b/app/models/form/sales/pages/buyer1_ethnic_background_arab.rb
index 93fb1afe0..e0e74e129 100644
--- a/app/models/form/sales/pages/buyer1_ethnic_background_arab.rb
+++ b/app/models/form/sales/pages/buyer1_ethnic_background_arab.rb
@@ -2,9 +2,6 @@ class Form::Sales::Pages::Buyer1EthnicBackgroundArab < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "buyer_1_ethnic_background_arab"
- @header = ""
- @description = ""
- @subsection = subsection
@depends_on = [{
"ethnic_group" => 4,
}]
diff --git a/app/models/form/sales/pages/buyer1_ethnic_background_asian.rb b/app/models/form/sales/pages/buyer1_ethnic_background_asian.rb
index dd6802a99..599a48f91 100644
--- a/app/models/form/sales/pages/buyer1_ethnic_background_asian.rb
+++ b/app/models/form/sales/pages/buyer1_ethnic_background_asian.rb
@@ -2,9 +2,6 @@ class Form::Sales::Pages::Buyer1EthnicBackgroundAsian < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "buyer_1_ethnic_background_asian"
- @header = ""
- @description = ""
- @subsection = subsection
@depends_on = [{
"ethnic_group" => 2,
}]
diff --git a/app/models/form/sales/pages/buyer1_ethnic_background_black.rb b/app/models/form/sales/pages/buyer1_ethnic_background_black.rb
index ce6cf3a0b..73e17d912 100644
--- a/app/models/form/sales/pages/buyer1_ethnic_background_black.rb
+++ b/app/models/form/sales/pages/buyer1_ethnic_background_black.rb
@@ -2,9 +2,6 @@ class Form::Sales::Pages::Buyer1EthnicBackgroundBlack < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "buyer_1_ethnic_background_black"
- @header = ""
- @description = ""
- @subsection = subsection
@depends_on = [{
"ethnic_group" => 3,
}]
diff --git a/app/models/form/sales/pages/buyer1_ethnic_background_mixed.rb b/app/models/form/sales/pages/buyer1_ethnic_background_mixed.rb
index 5225feed1..13fea19a7 100644
--- a/app/models/form/sales/pages/buyer1_ethnic_background_mixed.rb
+++ b/app/models/form/sales/pages/buyer1_ethnic_background_mixed.rb
@@ -2,9 +2,6 @@ class Form::Sales::Pages::Buyer1EthnicBackgroundMixed < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "buyer_1_ethnic_background_mixed"
- @header = ""
- @description = ""
- @subsection = subsection
@depends_on = [{
"ethnic_group" => 1,
}]
diff --git a/app/models/form/sales/pages/buyer1_ethnic_background_white.rb b/app/models/form/sales/pages/buyer1_ethnic_background_white.rb
index 6351e50d7..2e4bd3097 100644
--- a/app/models/form/sales/pages/buyer1_ethnic_background_white.rb
+++ b/app/models/form/sales/pages/buyer1_ethnic_background_white.rb
@@ -2,9 +2,6 @@ class Form::Sales::Pages::Buyer1EthnicBackgroundWhite < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "buyer_1_ethnic_background_white"
- @header = ""
- @description = ""
- @subsection = subsection
@depends_on = [{
"ethnic_group" => 0,
}]
diff --git a/app/models/form/sales/pages/buyer1_ethnic_group.rb b/app/models/form/sales/pages/buyer1_ethnic_group.rb
index 4daad4f1d..af0269290 100644
--- a/app/models/form/sales/pages/buyer1_ethnic_group.rb
+++ b/app/models/form/sales/pages/buyer1_ethnic_group.rb
@@ -2,9 +2,6 @@ class Form::Sales::Pages::Buyer1EthnicGroup < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "buyer_1_ethnic_group"
- @header = ""
- @description = ""
- @subsection = subsection
end
def questions
diff --git a/app/models/form/sales/pages/buyer1_income.rb b/app/models/form/sales/pages/buyer1_income.rb
index e4f88be81..943296d2b 100644
--- a/app/models/form/sales/pages/buyer1_income.rb
+++ b/app/models/form/sales/pages/buyer1_income.rb
@@ -2,9 +2,6 @@ class Form::Sales::Pages::Buyer1Income < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "buyer_1_income"
- @header = ""
- @description = ""
- @subsection = subsection
end
def questions
diff --git a/app/models/form/sales/pages/buyer1_income_value_check.rb b/app/models/form/sales/pages/buyer1_income_value_check.rb
index 51170702e..04540c47f 100644
--- a/app/models/form/sales/pages/buyer1_income_value_check.rb
+++ b/app/models/form/sales/pages/buyer1_income_value_check.rb
@@ -1,9 +1,6 @@
class Form::Sales::Pages::Buyer1IncomeValueCheck < ::Form::Page
def initialize(id, hsh, subsection)
super
- @header = ""
- @description = ""
- @subsection = subsection
@depends_on = [
{
"income1_under_soft_min?" => true,
diff --git a/app/models/form/sales/pages/buyer1_live_in_property.rb b/app/models/form/sales/pages/buyer1_live_in_property.rb
index 6146f6782..0d780ffed 100644
--- a/app/models/form/sales/pages/buyer1_live_in_property.rb
+++ b/app/models/form/sales/pages/buyer1_live_in_property.rb
@@ -2,9 +2,6 @@ class Form::Sales::Pages::Buyer1LiveInProperty < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "buyer_1_live_in_property"
- @header = ""
- @description = ""
- @subsection = subsection
end
def questions
diff --git a/app/models/form/sales/pages/buyer1_mortgage.rb b/app/models/form/sales/pages/buyer1_mortgage.rb
index e17e9124b..583d1e0b6 100644
--- a/app/models/form/sales/pages/buyer1_mortgage.rb
+++ b/app/models/form/sales/pages/buyer1_mortgage.rb
@@ -2,9 +2,6 @@ class Form::Sales::Pages::Buyer1Mortgage < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "buyer_1_mortgage"
- @header = ""
- @description = ""
- @subsection = subsection
end
def questions
diff --git a/app/models/form/sales/pages/buyer1_previous_tenure.rb b/app/models/form/sales/pages/buyer1_previous_tenure.rb
index 1379fbd30..d353320ec 100644
--- a/app/models/form/sales/pages/buyer1_previous_tenure.rb
+++ b/app/models/form/sales/pages/buyer1_previous_tenure.rb
@@ -2,9 +2,6 @@ class Form::Sales::Pages::Buyer1PreviousTenure < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "buyer1_previous_tenure"
- @header = "What was buyer 1's previous tenure?"
- @description = ""
- @subsection = subsection
end
def questions
diff --git a/app/models/form/sales/pages/buyer1_working_situation.rb b/app/models/form/sales/pages/buyer1_working_situation.rb
index bde1dba09..8d56caa47 100644
--- a/app/models/form/sales/pages/buyer1_working_situation.rb
+++ b/app/models/form/sales/pages/buyer1_working_situation.rb
@@ -2,9 +2,6 @@ class Form::Sales::Pages::Buyer1WorkingSituation < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "buyer_1_working_situation"
- @header = ""
- @description = ""
- @subsection = subsection
end
def questions
diff --git a/app/models/form/sales/pages/buyer2_income.rb b/app/models/form/sales/pages/buyer2_income.rb
index 207b6ec46..65b88077d 100644
--- a/app/models/form/sales/pages/buyer2_income.rb
+++ b/app/models/form/sales/pages/buyer2_income.rb
@@ -2,9 +2,6 @@ class Form::Sales::Pages::Buyer2Income < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "buyer_2_income"
- @header = ""
- @description = ""
- @subsection = subsection
@depends_on = [{
"jointpur" => 1,
}]
diff --git a/app/models/form/sales/pages/buyer2_live_in_property.rb b/app/models/form/sales/pages/buyer2_live_in_property.rb
index 03b13536f..8904c21f2 100644
--- a/app/models/form/sales/pages/buyer2_live_in_property.rb
+++ b/app/models/form/sales/pages/buyer2_live_in_property.rb
@@ -2,9 +2,6 @@ class Form::Sales::Pages::Buyer2LiveInProperty < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "buyer_2_live_in_property"
- @header = ""
- @description = ""
- @subsection = subsection
@depends_on = [{
"jointpur" => 1,
}]
diff --git a/app/models/form/sales/pages/buyer2_mortgage.rb b/app/models/form/sales/pages/buyer2_mortgage.rb
index bcac72218..e8b0c3718 100644
--- a/app/models/form/sales/pages/buyer2_mortgage.rb
+++ b/app/models/form/sales/pages/buyer2_mortgage.rb
@@ -2,9 +2,6 @@ class Form::Sales::Pages::Buyer2Mortgage < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "buyer_2_mortgage"
- @header = ""
- @description = ""
- @subsection = subsection
@depends_on = [{ "jointpur" => 1 }]
end
diff --git a/app/models/form/sales/pages/buyer2_relationship_to_buyer1.rb b/app/models/form/sales/pages/buyer2_relationship_to_buyer1.rb
index 8927ddd5a..026486883 100644
--- a/app/models/form/sales/pages/buyer2_relationship_to_buyer1.rb
+++ b/app/models/form/sales/pages/buyer2_relationship_to_buyer1.rb
@@ -2,9 +2,6 @@ class Form::Sales::Pages::Buyer2RelationshipToBuyer1 < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "buyer_2_relationship_to_buyer_1"
- @header = ""
- @description = ""
- @subsection = subsection
@depends_on = [{
"jointpur" => 1,
}]
diff --git a/app/models/form/sales/pages/buyer2_working_situation.rb b/app/models/form/sales/pages/buyer2_working_situation.rb
index 83e4468db..4523c34cc 100644
--- a/app/models/form/sales/pages/buyer2_working_situation.rb
+++ b/app/models/form/sales/pages/buyer2_working_situation.rb
@@ -2,9 +2,6 @@ class Form::Sales::Pages::Buyer2WorkingSituation < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "buyer_2_working_situation"
- @header = ""
- @description = ""
- @subsection = subsection
@depends_on = [{
"jointpur" => 1,
}]
diff --git a/app/models/form/sales/pages/buyer_company.rb b/app/models/form/sales/pages/buyer_company.rb
index dae1fecb9..b9f628f31 100644
--- a/app/models/form/sales/pages/buyer_company.rb
+++ b/app/models/form/sales/pages/buyer_company.rb
@@ -2,9 +2,6 @@ class Form::Sales::Pages::BuyerCompany < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "buyer_company"
- @header = ""
- @description = ""
- @subsection = subsection
@depends_on = [{
"ownershipsch" => 3,
}]
diff --git a/app/models/form/sales/pages/buyer_interview.rb b/app/models/form/sales/pages/buyer_interview.rb
index a781d8a07..ebd2e387a 100644
--- a/app/models/form/sales/pages/buyer_interview.rb
+++ b/app/models/form/sales/pages/buyer_interview.rb
@@ -2,9 +2,6 @@ class Form::Sales::Pages::BuyerInterview < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "buyer_interview"
- @header = ""
- @description = ""
- @subsection = subsection
end
def questions
diff --git a/app/models/form/sales/pages/buyer_live.rb b/app/models/form/sales/pages/buyer_live.rb
index bf1302058..d0b772355 100644
--- a/app/models/form/sales/pages/buyer_live.rb
+++ b/app/models/form/sales/pages/buyer_live.rb
@@ -2,9 +2,6 @@ class Form::Sales::Pages::BuyerLive < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "buyer_live"
- @header = ""
- @description = ""
- @subsection = subsection
@depends_on = [{
"companybuy" => 2,
}]
diff --git a/app/models/form/sales/pages/buyer_previous.rb b/app/models/form/sales/pages/buyer_previous.rb
index 5a75787c8..361b3ba47 100644
--- a/app/models/form/sales/pages/buyer_previous.rb
+++ b/app/models/form/sales/pages/buyer_previous.rb
@@ -2,9 +2,6 @@ class Form::Sales::Pages::BuyerPrevious < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "buyer_previous"
- @header = ""
- @description = ""
- @subsection = subsection
end
def questions
diff --git a/app/models/form/sales/pages/buyer_still_serving.rb b/app/models/form/sales/pages/buyer_still_serving.rb
index 08d2d951b..8bbcf7ff1 100644
--- a/app/models/form/sales/pages/buyer_still_serving.rb
+++ b/app/models/form/sales/pages/buyer_still_serving.rb
@@ -2,9 +2,6 @@ class Form::Sales::Pages::BuyerStillServing < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "buyer_still_serving"
- @header = ""
- @description = ""
- @subsection = subsection
@depends_on = [{
"hhregres" => 1,
}]
diff --git a/app/models/form/sales/pages/buyers_organisations.rb b/app/models/form/sales/pages/buyers_organisations.rb
index cc6f82984..95bd65c91 100644
--- a/app/models/form/sales/pages/buyers_organisations.rb
+++ b/app/models/form/sales/pages/buyers_organisations.rb
@@ -2,9 +2,6 @@ class Form::Sales::Pages::BuyersOrganisations < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "buyers_organisations"
- @header = ""
- @description = ""
- @subsection = subsection
end
def questions
diff --git a/app/models/form/sales/pages/deposit_value_check.rb b/app/models/form/sales/pages/deposit_value_check.rb
index 7c0fc9fef..8fa76ce1a 100644
--- a/app/models/form/sales/pages/deposit_value_check.rb
+++ b/app/models/form/sales/pages/deposit_value_check.rb
@@ -1,9 +1,6 @@
class Form::Sales::Pages::DepositValueCheck < ::Form::Page
def initialize(id, hsh, subsection)
super
- @header = ""
- @description = ""
- @subsection = subsection
@depends_on = [
{
"deposit_over_soft_max?" => true,
diff --git a/app/models/form/sales/pages/discounted_ownership_type.rb b/app/models/form/sales/pages/discounted_ownership_type.rb
index 031c5c620..4c7ae2464 100644
--- a/app/models/form/sales/pages/discounted_ownership_type.rb
+++ b/app/models/form/sales/pages/discounted_ownership_type.rb
@@ -2,9 +2,6 @@ class Form::Sales::Pages::DiscountedOwnershipType < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "discounted_ownership_type"
- @header = ""
- @description = ""
- @subsection = subsection
@depends_on = [{
"ownershipsch" => 2,
}]
diff --git a/app/models/form/sales/pages/exchange_date.rb b/app/models/form/sales/pages/exchange_date.rb
index 59e23ab01..ec71b0647 100644
--- a/app/models/form/sales/pages/exchange_date.rb
+++ b/app/models/form/sales/pages/exchange_date.rb
@@ -2,9 +2,6 @@ class Form::Sales::Pages::ExchangeDate < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "exchange_contracts"
- @header = ""
- @description = ""
- @subsection = subsection
@depends_on = [{
"resale" => 2,
}]
diff --git a/app/models/form/sales/pages/gender_identity1.rb b/app/models/form/sales/pages/gender_identity1.rb
index 9a92a16e9..2dadce8ba 100644
--- a/app/models/form/sales/pages/gender_identity1.rb
+++ b/app/models/form/sales/pages/gender_identity1.rb
@@ -2,9 +2,6 @@ class Form::Sales::Pages::GenderIdentity1 < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "buyer_1_gender_identity"
- @header = ""
- @description = ""
- @subsection = subsection
end
def questions
diff --git a/app/models/form/sales/pages/gender_identity2.rb b/app/models/form/sales/pages/gender_identity2.rb
index f5db5aecb..3d72842c9 100644
--- a/app/models/form/sales/pages/gender_identity2.rb
+++ b/app/models/form/sales/pages/gender_identity2.rb
@@ -2,9 +2,6 @@ class Form::Sales::Pages::GenderIdentity2 < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "buyer_2_gender_identity"
- @header = ""
- @description = ""
- @subsection = subsection
@depends_on = [{
"jointpur" => 1,
}]
diff --git a/app/models/form/sales/pages/handover_date.rb b/app/models/form/sales/pages/handover_date.rb
index a4216da40..eeeb48333 100644
--- a/app/models/form/sales/pages/handover_date.rb
+++ b/app/models/form/sales/pages/handover_date.rb
@@ -2,9 +2,6 @@ class Form::Sales::Pages::HandoverDate < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "handover_date"
- @header = ""
- @description = ""
- @subsection = subsection
@depends_on = [{
"ownershipsch" => 1,
}]
diff --git a/app/models/form/sales/pages/household_disability.rb b/app/models/form/sales/pages/household_disability.rb
index 23902773f..c9e4a8e2b 100644
--- a/app/models/form/sales/pages/household_disability.rb
+++ b/app/models/form/sales/pages/household_disability.rb
@@ -2,9 +2,6 @@ class Form::Sales::Pages::HouseholdDisability < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "household_disability"
- @header = ""
- @description = ""
- @subsection = subsection
end
def questions
diff --git a/app/models/form/sales/pages/household_wheelchair.rb b/app/models/form/sales/pages/household_wheelchair.rb
index 97d4abc52..81d98e1ee 100644
--- a/app/models/form/sales/pages/household_wheelchair.rb
+++ b/app/models/form/sales/pages/household_wheelchair.rb
@@ -2,9 +2,6 @@ class Form::Sales::Pages::HouseholdWheelchair < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "household_wheelchair"
- @header = ""
- @description = ""
- @subsection = subsection
end
def questions
diff --git a/app/models/form/sales/pages/household_wheelchair_check.rb b/app/models/form/sales/pages/household_wheelchair_check.rb
index b4f4c06ae..0cd457444 100644
--- a/app/models/form/sales/pages/household_wheelchair_check.rb
+++ b/app/models/form/sales/pages/household_wheelchair_check.rb
@@ -1,9 +1,6 @@
class Form::Sales::Pages::HouseholdWheelchairCheck < ::Form::Page
def initialize(id, hsh, subsection)
super
- @header = ""
- @description = ""
- @subsection = subsection
@depends_on = [
{
"wheelchair_when_not_disabled?" => true,
diff --git a/app/models/form/sales/pages/housing_benefits.rb b/app/models/form/sales/pages/housing_benefits.rb
index da67f7bf3..5de83cbfd 100644
--- a/app/models/form/sales/pages/housing_benefits.rb
+++ b/app/models/form/sales/pages/housing_benefits.rb
@@ -2,9 +2,6 @@ class Form::Sales::Pages::HousingBenefits < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "housing_benefits"
- @header = ""
- @description = ""
- @subsection = subsection
end
def questions
diff --git a/app/models/form/sales/pages/joint_purchase.rb b/app/models/form/sales/pages/joint_purchase.rb
index d863531ea..bec7c88c1 100644
--- a/app/models/form/sales/pages/joint_purchase.rb
+++ b/app/models/form/sales/pages/joint_purchase.rb
@@ -2,9 +2,6 @@ class Form::Sales::Pages::JointPurchase < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "joint_purchase"
- @header = ""
- @description = ""
- @subsection = subsection
@depends_on = [
{ "ownershipsch" => 1 },
{ "ownershipsch" => 2 },
diff --git a/app/models/form/sales/pages/la_nominations.rb b/app/models/form/sales/pages/la_nominations.rb
index c5c775e9f..e756e3071 100644
--- a/app/models/form/sales/pages/la_nominations.rb
+++ b/app/models/form/sales/pages/la_nominations.rb
@@ -2,9 +2,6 @@ class Form::Sales::Pages::LaNominations < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "la_nominations"
- @header = ""
- @description = ""
- @subsection = subsection
end
def questions
diff --git a/app/models/form/sales/pages/last_accommodation.rb b/app/models/form/sales/pages/last_accommodation.rb
index 43ccd276e..373a20511 100644
--- a/app/models/form/sales/pages/last_accommodation.rb
+++ b/app/models/form/sales/pages/last_accommodation.rb
@@ -2,9 +2,6 @@ class Form::Sales::Pages::LastAccommodation < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "last_accommodation"
- @header = ""
- @description = ""
- @subsection = subsection
end
def questions
diff --git a/app/models/form/sales/pages/last_accommodation_la.rb b/app/models/form/sales/pages/last_accommodation_la.rb
index d8a5fb972..6e4211e12 100644
--- a/app/models/form/sales/pages/last_accommodation_la.rb
+++ b/app/models/form/sales/pages/last_accommodation_la.rb
@@ -2,9 +2,6 @@ class Form::Sales::Pages::LastAccommodationLa < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "last_accommodation_la"
- @header = ""
- @description = ""
- @subsection = subsection
@depends_on = [{
"is_previous_la_inferred" => false,
}]
diff --git a/app/models/form/sales/pages/leasehold_charges.rb b/app/models/form/sales/pages/leasehold_charges.rb
index 7aed92db9..93382cf18 100644
--- a/app/models/form/sales/pages/leasehold_charges.rb
+++ b/app/models/form/sales/pages/leasehold_charges.rb
@@ -1,11 +1,4 @@
class Form::Sales::Pages::LeaseholdCharges < ::Form::Page
- def initialize(id, hsh, subsection)
- super
- @header = ""
- @description = ""
- @subsection = subsection
- end
-
def questions
@questions ||= [
Form::Sales::Questions::LeaseholdChargesKnown.new(nil, nil, self),
diff --git a/app/models/form/sales/pages/living_before_purchase.rb b/app/models/form/sales/pages/living_before_purchase.rb
index e76b8fd63..5fa695bbc 100644
--- a/app/models/form/sales/pages/living_before_purchase.rb
+++ b/app/models/form/sales/pages/living_before_purchase.rb
@@ -1,11 +1,4 @@
class Form::Sales::Pages::LivingBeforePurchase < ::Form::Page
- def initialize(id, hsh, subsection)
- super
- @header = ""
- @description = ""
- @subsection = subsection
- end
-
def questions
@questions ||= [
Form::Sales::Questions::LivingBeforePurchase.new(nil, nil, self),
diff --git a/app/models/form/sales/pages/monthly_rent.rb b/app/models/form/sales/pages/monthly_rent.rb
index 826314edf..29f0d895f 100644
--- a/app/models/form/sales/pages/monthly_rent.rb
+++ b/app/models/form/sales/pages/monthly_rent.rb
@@ -2,9 +2,6 @@ class Form::Sales::Pages::MonthlyRent < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "monthly_rent"
- @header = ""
- @description = ""
- @subsection = subsection
end
def questions
diff --git a/app/models/form/sales/pages/mortgage_amount.rb b/app/models/form/sales/pages/mortgage_amount.rb
index 88f642042..153c3bbe6 100644
--- a/app/models/form/sales/pages/mortgage_amount.rb
+++ b/app/models/form/sales/pages/mortgage_amount.rb
@@ -2,8 +2,6 @@ class Form::Sales::Pages::MortgageAmount < ::Form::Page
def initialize(id, hsh, subsection)
super
@header = "Mortgage Amount"
- @description = ""
- @subsection = subsection
@depends_on = [{
"mortgageused" => 1,
}]
diff --git a/app/models/form/sales/pages/mortgage_lender.rb b/app/models/form/sales/pages/mortgage_lender.rb
new file mode 100644
index 000000000..96ebd0733
--- /dev/null
+++ b/app/models/form/sales/pages/mortgage_lender.rb
@@ -0,0 +1,14 @@
+class Form::Sales::Pages::MortgageLender < ::Form::Page
+ def initialize(id, hsh, subsection)
+ super
+ @header = ""
+ @description = ""
+ @subsection = subsection
+ end
+
+ def questions
+ @questions ||= [
+ Form::Sales::Questions::MortgageLender.new(nil, nil, self),
+ ]
+ end
+end
diff --git a/app/models/form/sales/pages/mortgage_lender_other.rb b/app/models/form/sales/pages/mortgage_lender_other.rb
new file mode 100644
index 000000000..a4f6aaf90
--- /dev/null
+++ b/app/models/form/sales/pages/mortgage_lender_other.rb
@@ -0,0 +1,17 @@
+class Form::Sales::Pages::MortgageLenderOther < ::Form::Page
+ def initialize(id, hsh, subsection)
+ super
+ @header = ""
+ @description = ""
+ @subsection = subsection
+ @depends_on = [{
+ "mortgagelender" => 40,
+ }]
+ end
+
+ def questions
+ @questions ||= [
+ Form::Sales::Questions::MortgageLenderOther.new(nil, nil, self),
+ ]
+ end
+end
diff --git a/app/models/form/sales/pages/mortgage_length.rb b/app/models/form/sales/pages/mortgage_length.rb
index edc005c21..2877cffd8 100644
--- a/app/models/form/sales/pages/mortgage_length.rb
+++ b/app/models/form/sales/pages/mortgage_length.rb
@@ -1,11 +1,4 @@
class Form::Sales::Pages::MortgageLength < ::Form::Page
- def initialize(id, hsh, subsection)
- super
- @header = ""
- @description = ""
- @subsection = subsection
- end
-
def questions
@questions ||= [
Form::Sales::Questions::MortgageLength.new(nil, nil, self),
diff --git a/app/models/form/sales/pages/mortgage_value_check.rb b/app/models/form/sales/pages/mortgage_value_check.rb
index 7bbd62cf8..954b50872 100644
--- a/app/models/form/sales/pages/mortgage_value_check.rb
+++ b/app/models/form/sales/pages/mortgage_value_check.rb
@@ -1,9 +1,6 @@
class Form::Sales::Pages::MortgageValueCheck < ::Form::Page
def initialize(id, hsh, subsection)
super
- @header = ""
- @description = ""
- @subsection = subsection
@depends_on = [
{
"mortgage_over_soft_max?" => true,
diff --git a/app/models/form/sales/pages/mortgageused.rb b/app/models/form/sales/pages/mortgageused.rb
index cc320f145..4a22c480e 100644
--- a/app/models/form/sales/pages/mortgageused.rb
+++ b/app/models/form/sales/pages/mortgageused.rb
@@ -1,11 +1,4 @@
class Form::Sales::Pages::Mortgageused < ::Form::Page
- def initialize(id, hsh, subsection)
- super
- @header = ""
- @description = ""
- @subsection = subsection
- end
-
def questions
@questions ||= [
Form::Sales::Questions::Mortgageused.new(nil, nil, self),
diff --git a/app/models/form/sales/pages/nationality1.rb b/app/models/form/sales/pages/nationality1.rb
index 740aa694f..65bba7c6a 100644
--- a/app/models/form/sales/pages/nationality1.rb
+++ b/app/models/form/sales/pages/nationality1.rb
@@ -2,9 +2,6 @@ class Form::Sales::Pages::Nationality1 < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "buyer_1_nationality"
- @header = ""
- @description = ""
- @subsection = subsection
end
def questions
diff --git a/app/models/form/sales/pages/number_joint_buyers.rb b/app/models/form/sales/pages/number_joint_buyers.rb
index 2d57326e1..890280386 100644
--- a/app/models/form/sales/pages/number_joint_buyers.rb
+++ b/app/models/form/sales/pages/number_joint_buyers.rb
@@ -2,9 +2,6 @@ class Form::Sales::Pages::NumberJointBuyers < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "number_joint_buyers"
- @header = ""
- @description = ""
- @subsection = subsection
@depends_on = [{
"jointpur" => 1,
}]
diff --git a/app/models/form/sales/pages/number_of_others_in_property.rb b/app/models/form/sales/pages/number_of_others_in_property.rb
index b97c70775..ed82303ec 100644
--- a/app/models/form/sales/pages/number_of_others_in_property.rb
+++ b/app/models/form/sales/pages/number_of_others_in_property.rb
@@ -2,9 +2,6 @@ class Form::Sales::Pages::NumberOfOthersInProperty < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "number_of_others_in_property"
- @header = ""
- @description = ""
- @subsection = subsection
end
def questions
diff --git a/app/models/form/sales/pages/outright_ownership_type.rb b/app/models/form/sales/pages/outright_ownership_type.rb
index 6c48e7107..3fc5ff115 100644
--- a/app/models/form/sales/pages/outright_ownership_type.rb
+++ b/app/models/form/sales/pages/outright_ownership_type.rb
@@ -2,9 +2,6 @@ class Form::Sales::Pages::OutrightOwnershipType < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "outright_ownership_type"
- @header = ""
- @description = ""
- @subsection = subsection
@depends_on = [{
"ownershipsch" => 3,
}]
diff --git a/app/models/form/sales/pages/ownership_scheme.rb b/app/models/form/sales/pages/ownership_scheme.rb
index 224bc52a2..d92e56600 100644
--- a/app/models/form/sales/pages/ownership_scheme.rb
+++ b/app/models/form/sales/pages/ownership_scheme.rb
@@ -2,9 +2,6 @@ class Form::Sales::Pages::OwnershipScheme < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "ownership_scheme"
- @header = ""
- @description = ""
- @subsection = subsection
end
def questions
diff --git a/app/models/form/sales/pages/person_age.rb b/app/models/form/sales/pages/person_age.rb
index f0f86a251..983486847 100644
--- a/app/models/form/sales/pages/person_age.rb
+++ b/app/models/form/sales/pages/person_age.rb
@@ -1,9 +1,6 @@
class Form::Sales::Pages::PersonAge < Form::Sales::Pages::Person
def initialize(id, hsh, subsection, person_index:)
super
- @header = ""
- @description = ""
- @subsection = subsection
@depends_on = [{ details_known_question_id => 1, "jointpur" => joint_purchase? ? 1 : 2 }]
end
diff --git a/app/models/form/sales/pages/person_gender_identity.rb b/app/models/form/sales/pages/person_gender_identity.rb
index 11ff0ac98..db1016144 100644
--- a/app/models/form/sales/pages/person_gender_identity.rb
+++ b/app/models/form/sales/pages/person_gender_identity.rb
@@ -1,9 +1,6 @@
class Form::Sales::Pages::PersonGenderIdentity < Form::Sales::Pages::Person
def initialize(id, hsh, subsection, person_index:)
super
- @header = ""
- @description = ""
- @subsection = subsection
@depends_on = [
{ details_known_question_id => 1, "jointpur" => joint_purchase? ? 1 : 2 },
]
diff --git a/app/models/form/sales/pages/person_known.rb b/app/models/form/sales/pages/person_known.rb
index df82ff41d..9f09c6b56 100644
--- a/app/models/form/sales/pages/person_known.rb
+++ b/app/models/form/sales/pages/person_known.rb
@@ -2,9 +2,6 @@ class Form::Sales::Pages::PersonKnown < Form::Sales::Pages::Person
def initialize(id, hsh, subsection, person_index:)
super
@header_partial = "person_#{person_display_number}_known_page"
- @header = ""
- @description = ""
- @subsection = subsection
@depends_on = (person_display_number..4).map { |index| { "hholdcount" => index, "jointpur" => joint_purchase? ? 1 : 2 } }
end
diff --git a/app/models/form/sales/pages/person_relationship_to_buyer_1.rb b/app/models/form/sales/pages/person_relationship_to_buyer_1.rb
index f4a625528..d3d379c8a 100644
--- a/app/models/form/sales/pages/person_relationship_to_buyer_1.rb
+++ b/app/models/form/sales/pages/person_relationship_to_buyer_1.rb
@@ -1,9 +1,6 @@
class Form::Sales::Pages::PersonRelationshipToBuyer1 < ::Form::Sales::Pages::Person
def initialize(id, hsh, subsection, person_index:)
super
- @header = ""
- @description = ""
- @subsection = subsection
@depends_on = [
{ details_known_question_id => 1, "jointpur" => joint_purchase? ? 1 : 2 },
]
diff --git a/app/models/form/sales/pages/person_working_situation.rb b/app/models/form/sales/pages/person_working_situation.rb
index a78e90be3..7d1a1254d 100644
--- a/app/models/form/sales/pages/person_working_situation.rb
+++ b/app/models/form/sales/pages/person_working_situation.rb
@@ -1,9 +1,6 @@
class Form::Sales::Pages::PersonWorkingSituation < Form::Sales::Pages::Person
def initialize(id, hsh, subsection, person_index:)
super
- @header = ""
- @description = ""
- @subsection = subsection
@depends_on = [{ details_known_question_id => 1, "jointpur" => joint_purchase? ? 1 : 2 }]
end
diff --git a/app/models/form/sales/pages/postcode.rb b/app/models/form/sales/pages/postcode.rb
new file mode 100644
index 000000000..c40a18845
--- /dev/null
+++ b/app/models/form/sales/pages/postcode.rb
@@ -0,0 +1,13 @@
+class Form::Sales::Pages::Postcode < ::Form::Page
+ def initialize(id, hsh, subsection)
+ super
+ @id = "property_postcode"
+ end
+
+ def questions
+ @questions ||= [
+ Form::Sales::Questions::PostcodeKnown.new(nil, nil, self),
+ Form::Sales::Questions::Postcode.new(nil, nil, self),
+ ]
+ end
+end
diff --git a/app/models/form/sales/pages/previous_bedrooms.rb b/app/models/form/sales/pages/previous_bedrooms.rb
index 3c6eb26b1..87632e305 100644
--- a/app/models/form/sales/pages/previous_bedrooms.rb
+++ b/app/models/form/sales/pages/previous_bedrooms.rb
@@ -3,8 +3,6 @@ class Form::Sales::Pages::PreviousBedrooms < ::Form::Page
super
@id = "previous_bedrooms"
@header = "About the buyers’ previous property"
- @description = ""
- @subsection = subsection
@depends_on = [{
"soctenant" => 1,
}]
diff --git a/app/models/form/sales/pages/previous_ownership.rb b/app/models/form/sales/pages/previous_ownership.rb
index 17fb00a6b..88b438e07 100644
--- a/app/models/form/sales/pages/previous_ownership.rb
+++ b/app/models/form/sales/pages/previous_ownership.rb
@@ -2,9 +2,6 @@ class Form::Sales::Pages::PreviousOwnership < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "previous_ownership"
- @header = ""
- @description = ""
- @subsection = subsection
end
def questions
diff --git a/app/models/form/sales/pages/previous_property_type.rb b/app/models/form/sales/pages/previous_property_type.rb
new file mode 100644
index 000000000..8555fdc79
--- /dev/null
+++ b/app/models/form/sales/pages/previous_property_type.rb
@@ -0,0 +1,18 @@
+class Form::Sales::Pages::PreviousPropertyType < ::Form::Page
+ def initialize(id, hsh, subsection)
+ super
+ @id = "previous_property_type"
+ @header = ""
+ @description = ""
+ @subsection = subsection
+ @depends_on = [{
+ "soctenant" => 1,
+ }]
+ end
+
+ def questions
+ @questions ||= [
+ Form::Sales::Questions::Fromprop.new(nil, nil, self),
+ ]
+ end
+end
diff --git a/app/models/form/sales/pages/previous_tenure.rb b/app/models/form/sales/pages/previous_tenure.rb
new file mode 100644
index 000000000..a830898a0
--- /dev/null
+++ b/app/models/form/sales/pages/previous_tenure.rb
@@ -0,0 +1,18 @@
+class Form::Sales::Pages::PreviousTenure < ::Form::Page
+ def initialize(id, hsh, subsection)
+ super
+ @id = "shared_ownership_previous_tenure"
+ @header = ""
+ @description = ""
+ @subsection = subsection
+ @depends_on = [{
+ "soctenant" => 1,
+ }]
+ end
+
+ def questions
+ @questions ||= [
+ Form::Sales::Questions::PreviousTenure.new(nil, nil, self),
+ ]
+ end
+end
diff --git a/app/models/form/sales/pages/privacy_notice.rb b/app/models/form/sales/pages/privacy_notice.rb
index 7c1056ccb..a41800194 100644
--- a/app/models/form/sales/pages/privacy_notice.rb
+++ b/app/models/form/sales/pages/privacy_notice.rb
@@ -3,8 +3,6 @@ class Form::Sales::Pages::PrivacyNotice < ::Form::Page
super
@id = "privacy_notice"
@header = "Department for Levelling Up, Housing and Communities privacy notice"
- @description = ""
- @subsection = subsection
@depends_on = [{
"noint" => 2,
}]
diff --git a/app/models/form/sales/pages/property_building_type.rb b/app/models/form/sales/pages/property_building_type.rb
index 8f93b305c..40c8f3738 100644
--- a/app/models/form/sales/pages/property_building_type.rb
+++ b/app/models/form/sales/pages/property_building_type.rb
@@ -2,9 +2,6 @@ class Form::Sales::Pages::PropertyBuildingType < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "property_building_type"
- @header = ""
- @description = ""
- @subsection = subsection
end
def questions
diff --git a/app/models/form/sales/pages/property_local_authority.rb b/app/models/form/sales/pages/property_local_authority.rb
index 1698ace47..7e63b2f6c 100644
--- a/app/models/form/sales/pages/property_local_authority.rb
+++ b/app/models/form/sales/pages/property_local_authority.rb
@@ -2,9 +2,9 @@ class Form::Sales::Pages::PropertyLocalAuthority < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "property_local_authority"
- @header = ""
- @description = ""
- @subsection = subsection
+ @depends_on = [{
+ "is_la_inferred" => false,
+ }]
end
def questions
diff --git a/app/models/form/sales/pages/property_number_of_bedrooms.rb b/app/models/form/sales/pages/property_number_of_bedrooms.rb
index 5efb6b0f4..796a617d5 100644
--- a/app/models/form/sales/pages/property_number_of_bedrooms.rb
+++ b/app/models/form/sales/pages/property_number_of_bedrooms.rb
@@ -2,9 +2,6 @@ class Form::Sales::Pages::PropertyNumberOfBedrooms < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "property_number_of_bedrooms"
- @header = ""
- @description = ""
- @subsection = subsection
end
def questions
diff --git a/app/models/form/sales/pages/property_unit_type.rb b/app/models/form/sales/pages/property_unit_type.rb
index 9ee5506ca..c9bcb661f 100644
--- a/app/models/form/sales/pages/property_unit_type.rb
+++ b/app/models/form/sales/pages/property_unit_type.rb
@@ -2,9 +2,6 @@ class Form::Sales::Pages::PropertyUnitType < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "property_unit_type"
- @header = ""
- @description = ""
- @subsection = subsection
end
def questions
diff --git a/app/models/form/sales/pages/property_wheelchair_accessible.rb b/app/models/form/sales/pages/property_wheelchair_accessible.rb
index d587d61a7..a63964059 100644
--- a/app/models/form/sales/pages/property_wheelchair_accessible.rb
+++ b/app/models/form/sales/pages/property_wheelchair_accessible.rb
@@ -2,9 +2,6 @@ class Form::Sales::Pages::PropertyWheelchairAccessible < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "property_wheelchair_accessible"
- @header = ""
- @description = ""
- @subsection = subsection
end
def questions
diff --git a/app/models/form/sales/pages/purchase_price.rb b/app/models/form/sales/pages/purchase_price.rb
index 5eeb84138..22277dc5a 100644
--- a/app/models/form/sales/pages/purchase_price.rb
+++ b/app/models/form/sales/pages/purchase_price.rb
@@ -2,9 +2,6 @@ class Form::Sales::Pages::PurchasePrice < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "purchase_price"
- @header = ""
- @description = ""
- @subsection = subsection
end
def questions
diff --git a/app/models/form/sales/pages/purchaser_code.rb b/app/models/form/sales/pages/purchaser_code.rb
index 79723e0b0..8282453ad 100644
--- a/app/models/form/sales/pages/purchaser_code.rb
+++ b/app/models/form/sales/pages/purchaser_code.rb
@@ -2,9 +2,6 @@ class Form::Sales::Pages::PurchaserCode < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "purchaser_code"
- @header = ""
- @description = ""
- @subsection = subsection
end
def questions
diff --git a/app/models/form/sales/pages/resale.rb b/app/models/form/sales/pages/resale.rb
index 031efd3d6..ffdbbc046 100644
--- a/app/models/form/sales/pages/resale.rb
+++ b/app/models/form/sales/pages/resale.rb
@@ -2,9 +2,6 @@ class Form::Sales::Pages::Resale < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "resale"
- @header = ""
- @description = ""
- @subsection = subsection
@depends_on = [
{
"staircase" => 2,
diff --git a/app/models/form/sales/pages/sale_date.rb b/app/models/form/sales/pages/sale_date.rb
index 518e9b5ff..036e04907 100644
--- a/app/models/form/sales/pages/sale_date.rb
+++ b/app/models/form/sales/pages/sale_date.rb
@@ -2,9 +2,6 @@ class Form::Sales::Pages::SaleDate < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "completion_date"
- @header = ""
- @description = ""
- @subsection = subsection
end
def questions
diff --git a/app/models/form/sales/pages/savings.rb b/app/models/form/sales/pages/savings.rb
index 42f2c1bb4..969ff414c 100644
--- a/app/models/form/sales/pages/savings.rb
+++ b/app/models/form/sales/pages/savings.rb
@@ -2,9 +2,6 @@ class Form::Sales::Pages::Savings < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "savings"
- @header = ""
- @description = ""
- @subsection = subsection
end
def questions
diff --git a/app/models/form/sales/pages/savings_value_check.rb b/app/models/form/sales/pages/savings_value_check.rb
index 7f31097f9..779bdae30 100644
--- a/app/models/form/sales/pages/savings_value_check.rb
+++ b/app/models/form/sales/pages/savings_value_check.rb
@@ -1,9 +1,6 @@
class Form::Sales::Pages::SavingsValueCheck < ::Form::Page
def initialize(id, hsh, subsection)
super
- @header = ""
- @description = ""
- @subsection = subsection
@depends_on = [
{
"savings_over_soft_max?" => true,
diff --git a/app/models/form/sales/pages/shared_ownership_type.rb b/app/models/form/sales/pages/shared_ownership_type.rb
index c90074bae..3bc5dbdf7 100644
--- a/app/models/form/sales/pages/shared_ownership_type.rb
+++ b/app/models/form/sales/pages/shared_ownership_type.rb
@@ -2,9 +2,6 @@ class Form::Sales::Pages::SharedOwnershipType < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "shared_ownership_type"
- @header = ""
- @description = ""
- @subsection = subsection
@depends_on = [{
"ownershipsch" => 1,
}]
diff --git a/app/models/form/sales/pages/staircase.rb b/app/models/form/sales/pages/staircase.rb
index 139bd7e40..6ab76e2bf 100644
--- a/app/models/form/sales/pages/staircase.rb
+++ b/app/models/form/sales/pages/staircase.rb
@@ -2,9 +2,6 @@ class Form::Sales::Pages::Staircase < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "staircasing"
- @header = ""
- @description = ""
- @subsection = subsection
end
def questions
diff --git a/app/models/form/sales/questions/age1.rb b/app/models/form/sales/questions/age1.rb
index 48dfa7446..e38224b17 100644
--- a/app/models/form/sales/questions/age1.rb
+++ b/app/models/form/sales/questions/age1.rb
@@ -5,7 +5,6 @@ class Form::Sales::Questions::Age1 < ::Form::Question
@check_answer_label = "Lead buyer’s age"
@header = "Age"
@type = "numeric"
- @page = page
@width = 2
@inferred_check_answers_value = {
"condition" => {
diff --git a/app/models/form/sales/questions/age2.rb b/app/models/form/sales/questions/age2.rb
index ade402eb6..9696679a8 100644
--- a/app/models/form/sales/questions/age2.rb
+++ b/app/models/form/sales/questions/age2.rb
@@ -5,7 +5,6 @@ class Form::Sales::Questions::Age2 < ::Form::Question
@check_answer_label = "Buyer 2’s age"
@header = "Age"
@type = "numeric"
- @page = page
@width = 2
@inferred_check_answers_value = {
"condition" => { "age2_known" => 1 },
diff --git a/app/models/form/sales/questions/armed_forces.rb b/app/models/form/sales/questions/armed_forces.rb
index 6822e712a..af003c5b2 100644
--- a/app/models/form/sales/questions/armed_forces.rb
+++ b/app/models/form/sales/questions/armed_forces.rb
@@ -7,7 +7,6 @@ class Form::Sales::Questions::ArmedForces < ::Form::Question
@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
- @page = page
end
ANSWER_OPTIONS = {
diff --git a/app/models/form/sales/questions/armed_forces_spouse.rb b/app/models/form/sales/questions/armed_forces_spouse.rb
index cd9a3aca1..cf38bd434 100644
--- a/app/models/form/sales/questions/armed_forces_spouse.rb
+++ b/app/models/form/sales/questions/armed_forces_spouse.rb
@@ -5,9 +5,7 @@ class Form::Sales::Questions::ArmedForcesSpouse < ::Form::Question
@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"
- @hint_text = ""
@answer_options = ANSWER_OPTIONS
- @page = page
end
ANSWER_OPTIONS = {
diff --git a/app/models/form/sales/questions/buyer1_age_known.rb b/app/models/form/sales/questions/buyer1_age_known.rb
index f3b0c0938..74d9a122b 100644
--- a/app/models/form/sales/questions/buyer1_age_known.rb
+++ b/app/models/form/sales/questions/buyer1_age_known.rb
@@ -6,7 +6,6 @@ class Form::Sales::Questions::Buyer1AgeKnown < ::Form::Question
@header = "Do you know buyer 1’s age?"
@type = "radio"
@answer_options = ANSWER_OPTIONS
- @page = page
@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],
diff --git a/app/models/form/sales/questions/buyer1_ethnic_background_arab.rb b/app/models/form/sales/questions/buyer1_ethnic_background_arab.rb
index 2006eec92..19526f5b7 100644
--- a/app/models/form/sales/questions/buyer1_ethnic_background_arab.rb
+++ b/app/models/form/sales/questions/buyer1_ethnic_background_arab.rb
@@ -6,7 +6,6 @@ class Form::Sales::Questions::Buyer1EthnicBackgroundArab < ::Form::Question
@header = "Which of the following best describes the buyer 1’s Arab background?"
@type = "radio"
@answer_options = ANSWER_OPTIONS
- @page = page
@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."
@check_answers_card_number = 1
end
diff --git a/app/models/form/sales/questions/buyer1_ethnic_background_asian.rb b/app/models/form/sales/questions/buyer1_ethnic_background_asian.rb
index 9e61ed0a6..ee910c054 100644
--- a/app/models/form/sales/questions/buyer1_ethnic_background_asian.rb
+++ b/app/models/form/sales/questions/buyer1_ethnic_background_asian.rb
@@ -6,7 +6,6 @@ class Form::Sales::Questions::Buyer1EthnicBackgroundAsian < ::Form::Question
@header = "Which of the following best describes the buyer 1’s Asian or Asian British background?"
@type = "radio"
@answer_options = ANSWER_OPTIONS
- @page = page
@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."
@check_answers_card_number = 1
end
diff --git a/app/models/form/sales/questions/buyer1_ethnic_background_black.rb b/app/models/form/sales/questions/buyer1_ethnic_background_black.rb
index bc9f16dde..4c24f1433 100644
--- a/app/models/form/sales/questions/buyer1_ethnic_background_black.rb
+++ b/app/models/form/sales/questions/buyer1_ethnic_background_black.rb
@@ -6,7 +6,6 @@ class Form::Sales::Questions::Buyer1EthnicBackgroundBlack < ::Form::Question
@header = "Which of the following best describes the buyer 1’s Black, African, Caribbean or Black British background?"
@type = "radio"
@answer_options = ANSWER_OPTIONS
- @page = page
@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."
@check_answers_card_number = 1
end
diff --git a/app/models/form/sales/questions/buyer1_ethnic_background_mixed.rb b/app/models/form/sales/questions/buyer1_ethnic_background_mixed.rb
index c264459c7..8fa879949 100644
--- a/app/models/form/sales/questions/buyer1_ethnic_background_mixed.rb
+++ b/app/models/form/sales/questions/buyer1_ethnic_background_mixed.rb
@@ -6,7 +6,6 @@ class Form::Sales::Questions::Buyer1EthnicBackgroundMixed < ::Form::Question
@header = "Which of the following best describes the buyer 1’s Mixed or Multiple ethnic groups background?"
@type = "radio"
@answer_options = ANSWER_OPTIONS
- @page = page
@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."
@check_answers_card_number = 1
end
diff --git a/app/models/form/sales/questions/buyer1_ethnic_background_white.rb b/app/models/form/sales/questions/buyer1_ethnic_background_white.rb
index 52e771191..4b7ec9182 100644
--- a/app/models/form/sales/questions/buyer1_ethnic_background_white.rb
+++ b/app/models/form/sales/questions/buyer1_ethnic_background_white.rb
@@ -6,7 +6,6 @@ class Form::Sales::Questions::Buyer1EthnicBackgroundWhite < ::Form::Question
@header = "Which of the following best describes the buyer 1’s White background?"
@type = "radio"
@answer_options = ANSWER_OPTIONS
- @page = page
@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."
@check_answers_card_number = 1
end
diff --git a/app/models/form/sales/questions/buyer1_ethnic_group.rb b/app/models/form/sales/questions/buyer1_ethnic_group.rb
index 85a809aae..a9c52dbed 100644
--- a/app/models/form/sales/questions/buyer1_ethnic_group.rb
+++ b/app/models/form/sales/questions/buyer1_ethnic_group.rb
@@ -6,7 +6,6 @@ class Form::Sales::Questions::Buyer1EthnicGroup < ::Form::Question
@header = "What is buyer 1’s ethnic group?"
@type = "radio"
@answer_options = ANSWER_OPTIONS
- @page = page
@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."
@inferred_check_answers_value = {
"condition" => {
diff --git a/app/models/form/sales/questions/buyer1_income.rb b/app/models/form/sales/questions/buyer1_income.rb
index aa4a9df09..4a7e43e55 100644
--- a/app/models/form/sales/questions/buyer1_income.rb
+++ b/app/models/form/sales/questions/buyer1_income.rb
@@ -5,7 +5,6 @@ class Form::Sales::Questions::Buyer1Income < ::Form::Question
@check_answer_label = "Buyer 1’s gross annual income"
@header = "Buyer 1’s gross annual income"
@type = "numeric"
- @page = page
@min = 0
@max = 999_999
@step = 1
diff --git a/app/models/form/sales/questions/buyer1_income_known.rb b/app/models/form/sales/questions/buyer1_income_known.rb
index 4e7ef182e..36b5ec3f4 100644
--- a/app/models/form/sales/questions/buyer1_income_known.rb
+++ b/app/models/form/sales/questions/buyer1_income_known.rb
@@ -6,7 +6,6 @@ class Form::Sales::Questions::Buyer1IncomeKnown < ::Form::Question
@header = "Do you know buyer 1’s annual income?"
@type = "radio"
@answer_options = ANSWER_OPTIONS
- @page = page
@guidance_position = GuidancePosition::BOTTOM
@guidance_partial = "what_counts_as_income_sales"
@conditional_for = {
diff --git a/app/models/form/sales/questions/buyer1_income_value_check.rb b/app/models/form/sales/questions/buyer1_income_value_check.rb
index 9b0f21660..0913dd788 100644
--- a/app/models/form/sales/questions/buyer1_income_value_check.rb
+++ b/app/models/form/sales/questions/buyer1_income_value_check.rb
@@ -20,6 +20,5 @@ class Form::Sales::Questions::Buyer1IncomeValueCheck < ::Form::Question
],
}
@check_answers_card_number = 1
- @page = page
end
end
diff --git a/app/models/form/sales/questions/buyer1_live_in_property.rb b/app/models/form/sales/questions/buyer1_live_in_property.rb
index 31111ce81..4f18f60df 100644
--- a/app/models/form/sales/questions/buyer1_live_in_property.rb
+++ b/app/models/form/sales/questions/buyer1_live_in_property.rb
@@ -6,7 +6,6 @@ class Form::Sales::Questions::Buyer1LiveInProperty < ::Form::Question
@header = "Will buyer 1 live in the property?"
@type = "radio"
@answer_options = ANSWER_OPTIONS
- @page = page
@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."
@check_answers_card_number = 1
end
diff --git a/app/models/form/sales/questions/buyer1_mortgage.rb b/app/models/form/sales/questions/buyer1_mortgage.rb
index 76f25085c..f226f956c 100644
--- a/app/models/form/sales/questions/buyer1_mortgage.rb
+++ b/app/models/form/sales/questions/buyer1_mortgage.rb
@@ -6,7 +6,6 @@ class Form::Sales::Questions::Buyer1Mortgage < ::Form::Question
@header = "Was buyer 1's income used for a mortgage application?"
@type = "radio"
@answer_options = ANSWER_OPTIONS
- @page = page
@check_answers_card_number = 1
end
diff --git a/app/models/form/sales/questions/buyer1_previous_tenure.rb b/app/models/form/sales/questions/buyer1_previous_tenure.rb
index b2d3e01c4..f075e615c 100644
--- a/app/models/form/sales/questions/buyer1_previous_tenure.rb
+++ b/app/models/form/sales/questions/buyer1_previous_tenure.rb
@@ -6,7 +6,6 @@ class Form::Sales::Questions::Buyer1PreviousTenure < ::Form::Question
@header = "What was buyer 1's previous tenure?"
@type = "radio"
@answer_options = ANSWER_OPTIONS
- @page = page
end
ANSWER_OPTIONS = {
diff --git a/app/models/form/sales/questions/buyer1_working_situation.rb b/app/models/form/sales/questions/buyer1_working_situation.rb
index 5b933d794..d9c22ea03 100644
--- a/app/models/form/sales/questions/buyer1_working_situation.rb
+++ b/app/models/form/sales/questions/buyer1_working_situation.rb
@@ -6,7 +6,6 @@ class Form::Sales::Questions::Buyer1WorkingSituation < ::Form::Question
@header = "Which of these best describes buyer 1's working situation?"
@type = "radio"
@answer_options = ANSWER_OPTIONS
- @page = page
@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."
@check_answers_card_number = 1
end
diff --git a/app/models/form/sales/questions/buyer2_age_known.rb b/app/models/form/sales/questions/buyer2_age_known.rb
index d4cd6a777..c100d0b67 100644
--- a/app/models/form/sales/questions/buyer2_age_known.rb
+++ b/app/models/form/sales/questions/buyer2_age_known.rb
@@ -6,7 +6,6 @@ class Form::Sales::Questions::Buyer2AgeKnown < ::Form::Question
@header = "Do you know buyer 2’s age?"
@type = "radio"
@answer_options = ANSWER_OPTIONS
- @page = page
@conditional_for = {
"age2" => [0],
}
diff --git a/app/models/form/sales/questions/buyer2_income.rb b/app/models/form/sales/questions/buyer2_income.rb
index 8e4d66278..2bda83544 100644
--- a/app/models/form/sales/questions/buyer2_income.rb
+++ b/app/models/form/sales/questions/buyer2_income.rb
@@ -5,7 +5,6 @@ class Form::Sales::Questions::Buyer2Income < ::Form::Question
@check_answer_label = "Buyer 2’s gross annual income"
@header = "Buyer 2’s gross annual income"
@type = "numeric"
- @page = page
@min = 0
@step = 1
@width = 5
diff --git a/app/models/form/sales/questions/buyer2_income_known.rb b/app/models/form/sales/questions/buyer2_income_known.rb
index fd312776b..385bd9562 100644
--- a/app/models/form/sales/questions/buyer2_income_known.rb
+++ b/app/models/form/sales/questions/buyer2_income_known.rb
@@ -6,7 +6,6 @@ class Form::Sales::Questions::Buyer2IncomeKnown < ::Form::Question
@header = "Do you know buyer 2’s annual income?"
@type = "radio"
@answer_options = ANSWER_OPTIONS
- @page = page
@guidance_position = GuidancePosition::BOTTOM
@guidance_partial = "what_counts_as_income_sales"
@conditional_for = {
diff --git a/app/models/form/sales/questions/buyer2_live_in_property.rb b/app/models/form/sales/questions/buyer2_live_in_property.rb
index 654832cfb..162627905 100644
--- a/app/models/form/sales/questions/buyer2_live_in_property.rb
+++ b/app/models/form/sales/questions/buyer2_live_in_property.rb
@@ -5,9 +5,7 @@ class Form::Sales::Questions::Buyer2LiveInProperty < ::Form::Question
@check_answer_label = "Will buyer 2 live in the property?"
@header = "Will buyer 2 live in the property?"
@type = "radio"
- @hint_text = ""
@answer_options = ANSWER_OPTIONS
- @page = page
@check_answers_card_number = 2
end
diff --git a/app/models/form/sales/questions/buyer2_mortgage.rb b/app/models/form/sales/questions/buyer2_mortgage.rb
index 329567d3c..5697aea15 100644
--- a/app/models/form/sales/questions/buyer2_mortgage.rb
+++ b/app/models/form/sales/questions/buyer2_mortgage.rb
@@ -6,7 +6,6 @@ class Form::Sales::Questions::Buyer2Mortgage < ::Form::Question
@header = "Was buyer 2's income used for a mortgage application?"
@type = "radio"
@answer_options = ANSWER_OPTIONS
- @page = page
@check_answers_card_number = 2
end
diff --git a/app/models/form/sales/questions/buyer2_relationship_to_buyer1.rb b/app/models/form/sales/questions/buyer2_relationship_to_buyer1.rb
index 4564a2381..a37605332 100644
--- a/app/models/form/sales/questions/buyer2_relationship_to_buyer1.rb
+++ b/app/models/form/sales/questions/buyer2_relationship_to_buyer1.rb
@@ -5,8 +5,6 @@ class Form::Sales::Questions::Buyer2RelationshipToBuyer1 < ::Form::Question
@check_answer_label = "Buyer 2's relationship to buyer 1"
@header = "What is buyer 2's relationship to buyer 1?"
@type = "radio"
- @hint_text = ""
- @page = page
@answer_options = ANSWER_OPTIONS
@check_answers_card_number = 2
end
diff --git a/app/models/form/sales/questions/buyer2_working_situation.rb b/app/models/form/sales/questions/buyer2_working_situation.rb
index bc9bcbe1a..cf1ca3940 100644
--- a/app/models/form/sales/questions/buyer2_working_situation.rb
+++ b/app/models/form/sales/questions/buyer2_working_situation.rb
@@ -5,8 +5,6 @@ class Form::Sales::Questions::Buyer2WorkingSituation < ::Form::Question
@check_answer_label = "Buyer 2's working situation"
@header = "Which of these best describes buyer 2's working situation?"
@type = "radio"
- @hint_text = ""
- @page = page
@answer_options = ANSWER_OPTIONS
@check_answers_card_number = 2
end
diff --git a/app/models/form/sales/questions/buyer_company.rb b/app/models/form/sales/questions/buyer_company.rb
index 70c732866..1dac995b0 100644
--- a/app/models/form/sales/questions/buyer_company.rb
+++ b/app/models/form/sales/questions/buyer_company.rb
@@ -4,10 +4,8 @@ class Form::Sales::Questions::BuyerCompany < ::Form::Question
@id = "companybuy"
@check_answer_label = "Company buyer"
@header = "Is the buyer a company?"
- @hint_text = ""
@type = "radio"
@answer_options = ANSWER_OPTIONS
- @page = page
end
ANSWER_OPTIONS = {
diff --git a/app/models/form/sales/questions/buyer_interview.rb b/app/models/form/sales/questions/buyer_interview.rb
index 1b354b1d5..b157c05cc 100644
--- a/app/models/form/sales/questions/buyer_interview.rb
+++ b/app/models/form/sales/questions/buyer_interview.rb
@@ -6,7 +6,6 @@ class Form::Sales::Questions::BuyerInterview < ::Form::Question
@header = "Was the buyer interviewed for any of the answers you will provide on this log?"
@type = "radio"
@hint_text = "You should still try to answer all questions even if the buyer wasn't interviewed in person"
- @page = page
@answer_options = ANSWER_OPTIONS
end
diff --git a/app/models/form/sales/questions/buyer_live.rb b/app/models/form/sales/questions/buyer_live.rb
index ad5ec7f22..a8aeb0401 100644
--- a/app/models/form/sales/questions/buyer_live.rb
+++ b/app/models/form/sales/questions/buyer_live.rb
@@ -6,7 +6,6 @@ class Form::Sales::Questions::BuyerLive < ::Form::Question
@header = "Will the buyers live in the property?"
@type = "radio"
@answer_options = ANSWER_OPTIONS
- @page = page
end
ANSWER_OPTIONS = {
diff --git a/app/models/form/sales/questions/buyer_previous.rb b/app/models/form/sales/questions/buyer_previous.rb
index ae9ac22ea..18ac019cb 100644
--- a/app/models/form/sales/questions/buyer_previous.rb
+++ b/app/models/form/sales/questions/buyer_previous.rb
@@ -6,7 +6,6 @@ class Form::Sales::Questions::BuyerPrevious < ::Form::Question
@header = "Was the buyer a private registered provider, housing association or local authority tenant immediately before this sale?"
@type = "radio"
@answer_options = ANSWER_OPTIONS
- @page = page
end
ANSWER_OPTIONS = {
diff --git a/app/models/form/sales/questions/buyer_still_serving.rb b/app/models/form/sales/questions/buyer_still_serving.rb
index a15994e19..04929fb42 100644
--- a/app/models/form/sales/questions/buyer_still_serving.rb
+++ b/app/models/form/sales/questions/buyer_still_serving.rb
@@ -5,9 +5,7 @@ class Form::Sales::Questions::BuyerStillServing < ::Form::Question
@check_answer_label = "Are they still serving in the UK armed forces?"
@header = "Is the buyer still serving in the UK armed forces?"
@type = "radio"
- @hint_text = ""
@answer_options = ANSWER_OPTIONS
- @page = page
end
ANSWER_OPTIONS = {
diff --git a/app/models/form/sales/questions/buyers_organisations.rb b/app/models/form/sales/questions/buyers_organisations.rb
index dd3d87bd0..6457b6866 100644
--- a/app/models/form/sales/questions/buyers_organisations.rb
+++ b/app/models/form/sales/questions/buyers_organisations.rb
@@ -6,7 +6,6 @@ class Form::Sales::Questions::BuyersOrganisations < ::Form::Question
@header = "What organisations were the buyers registered with?"
@type = "checkbox"
@hint_text = "Select all that apply"
- @page = page
@answer_options = ANSWER_OPTIONS
end
diff --git a/app/models/form/sales/questions/deposit_amount.rb b/app/models/form/sales/questions/deposit_amount.rb
index 8252ad8d7..b054f76f2 100644
--- a/app/models/form/sales/questions/deposit_amount.rb
+++ b/app/models/form/sales/questions/deposit_amount.rb
@@ -5,7 +5,6 @@ class Form::Sales::Questions::DepositAmount < ::Form::Question
@check_answer_label = "Cash deposit"
@header = "How much cash deposit was paid on the property?"
@type = "numeric"
- @page = page
@min = 0
@width = 5
@prefix = "£"
diff --git a/app/models/form/sales/questions/deposit_discount.rb b/app/models/form/sales/questions/deposit_discount.rb
index 9496f90fd..dd3f98939 100644
--- a/app/models/form/sales/questions/deposit_discount.rb
+++ b/app/models/form/sales/questions/deposit_discount.rb
@@ -5,7 +5,6 @@ class Form::Sales::Questions::DepositDiscount < ::Form::Question
@check_answer_label = "Cash discount through SocialHomeBuy"
@header = "How much cash discount was given through Social HomeBuy?"
@type = "numeric"
- @page = page
@min = 0
@width = 5
@prefix = "£"
diff --git a/app/models/form/sales/questions/deposit_value_check.rb b/app/models/form/sales/questions/deposit_value_check.rb
index 86bc0d226..f3cd27e3a 100644
--- a/app/models/form/sales/questions/deposit_value_check.rb
+++ b/app/models/form/sales/questions/deposit_value_check.rb
@@ -20,6 +20,5 @@ class Form::Sales::Questions::DepositValueCheck < ::Form::Question
],
}
@check_answers_card_number = 0
- @page = page
end
end
diff --git a/app/models/form/sales/questions/discount.rb b/app/models/form/sales/questions/discount.rb
index d7b9fa33b..01ae38fd5 100644
--- a/app/models/form/sales/questions/discount.rb
+++ b/app/models/form/sales/questions/discount.rb
@@ -5,7 +5,6 @@ class Form::Sales::Questions::Discount < ::Form::Question
@check_answer_label = "Percentage discount"
@header = "What was the percentage discount?"
@type = "numeric"
- @page = page
@min = 0
@max = 100
@width = 5
diff --git a/app/models/form/sales/questions/discounted_ownership_type.rb b/app/models/form/sales/questions/discounted_ownership_type.rb
index b04e76c1e..2cbef6117 100644
--- a/app/models/form/sales/questions/discounted_ownership_type.rb
+++ b/app/models/form/sales/questions/discounted_ownership_type.rb
@@ -6,7 +6,6 @@ class Form::Sales::Questions::DiscountedOwnershipType < ::Form::Question
@header = "What is the type of discounted ownership sale?"
@type = "radio"
@answer_options = ANSWER_OPTIONS
- @page = page
end
ANSWER_OPTIONS = {
diff --git a/app/models/form/sales/questions/equity.rb b/app/models/form/sales/questions/equity.rb
index 585a14c36..7dec2ac37 100644
--- a/app/models/form/sales/questions/equity.rb
+++ b/app/models/form/sales/questions/equity.rb
@@ -5,7 +5,6 @@ class Form::Sales::Questions::Equity < ::Form::Question
@check_answer_label = "Initial percentage equity stake"
@header = "What was the initial percentage equity stake purchased?"
@type = "numeric"
- @page = page
@min = 0
@max = 100
@width = 5
diff --git a/app/models/form/sales/questions/exchange_date.rb b/app/models/form/sales/questions/exchange_date.rb
index 2c726e441..69b8ec39f 100644
--- a/app/models/form/sales/questions/exchange_date.rb
+++ b/app/models/form/sales/questions/exchange_date.rb
@@ -5,6 +5,5 @@ class Form::Sales::Questions::ExchangeDate < ::Form::Question
@check_answer_label = "Exchange of contracts date"
@header = "What is the exchange of contracts date?"
@type = "date"
- @page = page
end
end
diff --git a/app/models/form/sales/questions/fromprop.rb b/app/models/form/sales/questions/fromprop.rb
new file mode 100644
index 000000000..af33c67ea
--- /dev/null
+++ b/app/models/form/sales/questions/fromprop.rb
@@ -0,0 +1,20 @@
+class Form::Sales::Questions::Fromprop < ::Form::Question
+ def initialize(id, hsh, page)
+ super
+ @id = "fromprop"
+ @check_answer_label = "Previous property type"
+ @header = "What was the previous property type?"
+ @type = "radio"
+ @hint_text = ""
+ @page = page
+ @answer_options = ANSWER_OPTIONS
+ end
+
+ ANSWER_OPTIONS = {
+ "1" => { "value" => "Flat or maisonette" },
+ "2" => { "value" => "Bedsit" },
+ "3" => { "value" => "House" },
+ "4" => { "value" => "Bungalow" },
+ "9" => { "value" => "Other" },
+ }.freeze
+end
diff --git a/app/models/form/sales/questions/gender_identity1.rb b/app/models/form/sales/questions/gender_identity1.rb
index bfc98f3a0..c31a9cc0b 100644
--- a/app/models/form/sales/questions/gender_identity1.rb
+++ b/app/models/form/sales/questions/gender_identity1.rb
@@ -6,7 +6,6 @@ class Form::Sales::Questions::GenderIdentity1 < ::Form::Question
@header = "Which of these best describes buyer 1’s gender identity?"
@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."
- @page = page
@answer_options = ANSWER_OPTIONS
@check_answers_card_number = 1
end
@@ -15,6 +14,6 @@ class Form::Sales::Questions::GenderIdentity1 < ::Form::Question
"F" => { "value" => "Female" },
"M" => { "value" => "Male" },
"X" => { "value" => "Non-binary" },
- "R" => { "value" => "Prefers not to say " },
+ "R" => { "value" => "Prefers not to say" },
}.freeze
end
diff --git a/app/models/form/sales/questions/gender_identity2.rb b/app/models/form/sales/questions/gender_identity2.rb
index 8e27c0cb5..8783cc76c 100644
--- a/app/models/form/sales/questions/gender_identity2.rb
+++ b/app/models/form/sales/questions/gender_identity2.rb
@@ -5,7 +5,6 @@ class Form::Sales::Questions::GenderIdentity2 < ::Form::Question
@check_answer_label = "Buyer 2’s gender identity"
@header = "Which of these best describes buyer 2’s gender identity?"
@type = "radio"
- @page = page
@answer_options = ANSWER_OPTIONS
@check_answers_card_number = 2
end
diff --git a/app/models/form/sales/questions/grant.rb b/app/models/form/sales/questions/grant.rb
index edab388ac..181e2281d 100644
--- a/app/models/form/sales/questions/grant.rb
+++ b/app/models/form/sales/questions/grant.rb
@@ -5,7 +5,6 @@ class Form::Sales::Questions::Grant < ::Form::Question
@check_answer_label = "Amount of any loan, grant or subsidy"
@header = "What was the amount of any loan, grant, discount or subsidy given?"
@type = "numeric"
- @page = page
@min = 0
@width = 5
@prefix = "£"
diff --git a/app/models/form/sales/questions/handover_date.rb b/app/models/form/sales/questions/handover_date.rb
index b00f39601..06a89eb04 100644
--- a/app/models/form/sales/questions/handover_date.rb
+++ b/app/models/form/sales/questions/handover_date.rb
@@ -5,7 +5,6 @@ class Form::Sales::Questions::HandoverDate < ::Form::Question
@check_answer_label = "Practical completion or handover date"
@header = "What is the practical completion or handover date?"
@type = "date"
- @page = page
@hint_text = "This is the date on which the building contractor hands over responsibility for the completed property to the private registered provider (PRP)"
end
end
diff --git a/app/models/form/sales/questions/household_disability.rb b/app/models/form/sales/questions/household_disability.rb
index d0990f17a..c0edef69c 100644
--- a/app/models/form/sales/questions/household_disability.rb
+++ b/app/models/form/sales/questions/household_disability.rb
@@ -6,7 +6,6 @@ class Form::Sales::Questions::HouseholdDisability < ::Form::Question
@check_answer_label = "Does anyone in the household have a disability?"
@type = "radio"
@answer_options = ANSWER_OPTIONS
- @page = page
@hint_text = "This includes any long-term health condition that has an impact on the person's day-to-day life"
end
diff --git a/app/models/form/sales/questions/household_wheelchair.rb b/app/models/form/sales/questions/household_wheelchair.rb
index 43acfcc24..9266909dc 100644
--- a/app/models/form/sales/questions/household_wheelchair.rb
+++ b/app/models/form/sales/questions/household_wheelchair.rb
@@ -5,7 +5,6 @@ class Form::Sales::Questions::HouseholdWheelchair < ::Form::Question
@header = "Does anyone in the household use a wheelchair?"
@type = "radio"
@answer_options = ANSWER_OPTIONS
- @page = page
@hint_text = "This can be inside or outside the home"
end
diff --git a/app/models/form/sales/questions/household_wheelchair_check.rb b/app/models/form/sales/questions/household_wheelchair_check.rb
index 71cfcc23e..1a9db3f3a 100644
--- a/app/models/form/sales/questions/household_wheelchair_check.rb
+++ b/app/models/form/sales/questions/household_wheelchair_check.rb
@@ -5,7 +5,6 @@ class Form::Sales::Questions::HouseholdWheelchairCheck < ::Form::Question
@check_answer_label = "Does anyone in the household use a wheelchair?"
@header = "Are you sure? You said previously that somebody in household uses a wheelchair"
@type = "interruption_screen"
- @page = page
@answer_options = {
"0" => { "value" => "Yes" },
"1" => { "value" => "No" },
@@ -20,6 +19,5 @@ class Form::Sales::Questions::HouseholdWheelchairCheck < ::Form::Question
},
],
}
- @page = page
end
end
diff --git a/app/models/form/sales/questions/housing_benefits.rb b/app/models/form/sales/questions/housing_benefits.rb
index 7b19473ab..db3e14c88 100644
--- a/app/models/form/sales/questions/housing_benefits.rb
+++ b/app/models/form/sales/questions/housing_benefits.rb
@@ -5,8 +5,6 @@ class Form::Sales::Questions::HousingBenefits < ::Form::Question
@check_answer_label = "Housing-related benefits buyer received before buying this property"
@header = "Was the buyer receiving any of these housing-related benefits immediately before buying this property?"
@type = "radio"
- @page = page
- @hint_text = ""
@answer_options = ANSWER_OPTIONS
end
diff --git a/app/models/form/sales/questions/joint_purchase.rb b/app/models/form/sales/questions/joint_purchase.rb
index 893398399..e2bf0f754 100644
--- a/app/models/form/sales/questions/joint_purchase.rb
+++ b/app/models/form/sales/questions/joint_purchase.rb
@@ -4,10 +4,8 @@ class Form::Sales::Questions::JointPurchase < ::Form::Question
@id = "jointpur"
@check_answer_label = "Joint purchase"
@header = "Is this a joint purchase?"
- @hint_text = ""
@type = "radio"
@answer_options = ANSWER_OPTIONS
- @page = page
end
ANSWER_OPTIONS = {
diff --git a/app/models/form/sales/questions/la_nominations.rb b/app/models/form/sales/questions/la_nominations.rb
index 5db0178b6..806f7cfdd 100644
--- a/app/models/form/sales/questions/la_nominations.rb
+++ b/app/models/form/sales/questions/la_nominations.rb
@@ -6,7 +6,6 @@ class Form::Sales::Questions::LaNominations < ::Form::Question
@header = "Was the household rehoused under a 'local authority nominations agreement'?"
@type = "radio"
@answer_options = ANSWER_OPTIONS
- @page = page
@hint_text = "A local authority nominations agreement is a written agreement between a local authority and private registered provider (PRP) that some or all of its sales vacancies are offered to local authorities for rehousing"
end
diff --git a/app/models/form/sales/questions/leasehold_charges.rb b/app/models/form/sales/questions/leasehold_charges.rb
index eb19a7377..ef9260c56 100644
--- a/app/models/form/sales/questions/leasehold_charges.rb
+++ b/app/models/form/sales/questions/leasehold_charges.rb
@@ -5,7 +5,6 @@ class Form::Sales::Questions::LeaseholdCharges < ::Form::Question
@check_answer_label = "Monthly leasehold charges"
@header = "Enter the total monthly charge"
@type = "numeric"
- @page = page
@min = 0
@width = 5
@prefix = "£"
diff --git a/app/models/form/sales/questions/leasehold_charges_known.rb b/app/models/form/sales/questions/leasehold_charges_known.rb
index a94e7f63e..2c28e1814 100644
--- a/app/models/form/sales/questions/leasehold_charges_known.rb
+++ b/app/models/form/sales/questions/leasehold_charges_known.rb
@@ -7,7 +7,6 @@ class Form::Sales::Questions::LeaseholdChargesKnown < ::Form::Question
@hint_text = "For example, service and management charges"
@type = "radio"
@answer_options = ANSWER_OPTIONS
- @page = page
@conditional_for = {
"mscharge" => [1],
}
diff --git a/app/models/form/sales/questions/living_before_purchase.rb b/app/models/form/sales/questions/living_before_purchase.rb
index 0486fa4d7..feedaac63 100644
--- a/app/models/form/sales/questions/living_before_purchase.rb
+++ b/app/models/form/sales/questions/living_before_purchase.rb
@@ -6,7 +6,6 @@ class Form::Sales::Questions::LivingBeforePurchase < ::Form::Question
@header = "How long did the buyer(s) live in the property before purchase?"
@hint_text = "You should round this up to the nearest year. If the buyers haven't been living in the property, enter '0'"
@type = "numeric"
- @page = page
@min = 0
@max = 80
@step = 1
diff --git a/app/models/form/sales/questions/monthly_rent.rb b/app/models/form/sales/questions/monthly_rent.rb
index 4195b1238..34ac1bed9 100644
--- a/app/models/form/sales/questions/monthly_rent.rb
+++ b/app/models/form/sales/questions/monthly_rent.rb
@@ -5,7 +5,6 @@ class Form::Sales::Questions::MonthlyRent < ::Form::Question
@check_answer_label = "Monthly rent"
@header = "What is the basic monthly rent?"
@type = "numeric"
- @page = page
@min = 0
@width = 5
@prefix = "£"
diff --git a/app/models/form/sales/questions/mortgage_amount.rb b/app/models/form/sales/questions/mortgage_amount.rb
index c385563c5..5ad85bd31 100644
--- a/app/models/form/sales/questions/mortgage_amount.rb
+++ b/app/models/form/sales/questions/mortgage_amount.rb
@@ -5,10 +5,8 @@ class Form::Sales::Questions::MortgageAmount < ::Form::Question
@check_answer_label = "Mortgage amount"
@header = "What is the mortgage amount?"
@type = "numeric"
- @page = page
@min = 0
@width = 5
@prefix = "£"
- @hint_text = ""
end
end
diff --git a/app/models/form/sales/questions/mortgage_lender.rb b/app/models/form/sales/questions/mortgage_lender.rb
new file mode 100644
index 000000000..54c9a66c6
--- /dev/null
+++ b/app/models/form/sales/questions/mortgage_lender.rb
@@ -0,0 +1,58 @@
+class Form::Sales::Questions::MortgageLender < ::Form::Question
+ def initialize(id, hsh, page)
+ super
+ @id = "mortgagelender"
+ @check_answer_label = "Mortgage Lender"
+ @header = "What is the name of the mortgage lender?"
+ @type = "select"
+ @hint_text = ""
+ @page = page
+ @answer_options = ANSWER_OPTIONS
+ @guidance_position = GuidancePosition::BOTTOM
+ @guidance_partial = "mortgage_lender"
+ end
+
+ ANSWER_OPTIONS = {
+ "" => "Select an option",
+ "1" => "Atom Bank",
+ "2" => "Barclays Bank PLC",
+ "3" => "Bath Building Society",
+ "4" => "Buckinghamshire Building Society",
+ "5" => "Cambridge Building Society",
+ "6" => "Coventry Building Society",
+ "7" => "Cumberland Building Society",
+ "8" => "Darlington Building Society",
+ "9" => "Dudley Building Society",
+ "10" => "Ecology Building Society",
+ "11" => "Halifax",
+ "12" => "Hanley Economic Building Society",
+ "13" => "Hinckley and Rugby Building Society",
+ "14" => "Holmesdale Building Society",
+ "15" => "Ipswich Building Society",
+ "16" => "Leeds Building Society",
+ "17" => "Lloyds Bank",
+ "18" => "Mansfield Building Society",
+ "19" => "Market Harborough Building Society",
+ "20" => "Melton Mowbray Building Society",
+ "21" => "Nationwide Building Society",
+ "22" => "Natwest",
+ "23" => "Nedbank Private Wealth",
+ "24" => "Newbury Building Society",
+ "25" => "OneSavings Bank",
+ "26" => "Parity Trust",
+ "27" => "Penrith Building Society",
+ "28" => "Pepper Homeloans",
+ "29" => "Royal Bank of Scotland",
+ "30" => "Santander",
+ "31" => "Skipton Building Society",
+ "32" => "Teachers Building Society",
+ "33" => "The Co-operative Bank",
+ "34" => "Tipton & Coseley Building Society",
+ "35" => "TSB",
+ "36" => "Ulster Bank",
+ "37" => "Virgin Money",
+ "38" => "West Bromwich Building Society",
+ "39" => "Yorkshire Building Society",
+ "40" => "Other",
+ }.freeze
+end
diff --git a/app/models/form/sales/questions/mortgage_lender_other.rb b/app/models/form/sales/questions/mortgage_lender_other.rb
new file mode 100644
index 000000000..fa1fefa49
--- /dev/null
+++ b/app/models/form/sales/questions/mortgage_lender_other.rb
@@ -0,0 +1,10 @@
+class Form::Sales::Questions::MortgageLenderOther < ::Form::Question
+ def initialize(id, hsh, page)
+ super
+ @id = "mortgagelenderother"
+ @check_answer_label = "Other Mortgage Lender"
+ @header = "What is the other mortgage lender?"
+ @type = "text"
+ @page = page
+ end
+end
diff --git a/app/models/form/sales/questions/mortgage_length.rb b/app/models/form/sales/questions/mortgage_length.rb
index 3c06e6e12..317489763 100644
--- a/app/models/form/sales/questions/mortgage_length.rb
+++ b/app/models/form/sales/questions/mortgage_length.rb
@@ -5,10 +5,8 @@ class Form::Sales::Questions::MortgageLength < ::Form::Question
@check_answer_label = "Length of mortgage"
@header = "What is the length of the mortgage?"
@type = "numeric"
- @page = page
@min = 0
@width = 5
@suffix = " years"
- @hint_text = ""
end
end
diff --git a/app/models/form/sales/questions/mortgage_value_check.rb b/app/models/form/sales/questions/mortgage_value_check.rb
index 9d063f428..39079d40e 100644
--- a/app/models/form/sales/questions/mortgage_value_check.rb
+++ b/app/models/form/sales/questions/mortgage_value_check.rb
@@ -20,6 +20,5 @@ class Form::Sales::Questions::MortgageValueCheck < ::Form::Question
],
}
@check_answers_card_number = 1
- @page = page
end
end
diff --git a/app/models/form/sales/questions/mortgageused.rb b/app/models/form/sales/questions/mortgageused.rb
index 2374056a8..8c75750d8 100644
--- a/app/models/form/sales/questions/mortgageused.rb
+++ b/app/models/form/sales/questions/mortgageused.rb
@@ -6,8 +6,6 @@ class Form::Sales::Questions::Mortgageused < ::Form::Question
@header = "Was a mortgage used for the purchase of this property?"
@type = "radio"
@answer_options = ANSWER_OPTIONS
- @page = page
- @hint_text = ""
end
ANSWER_OPTIONS = {
diff --git a/app/models/form/sales/questions/nationality1.rb b/app/models/form/sales/questions/nationality1.rb
index 4d3dabb01..82a40df4e 100644
--- a/app/models/form/sales/questions/nationality1.rb
+++ b/app/models/form/sales/questions/nationality1.rb
@@ -6,7 +6,6 @@ class Form::Sales::Questions::Nationality1 < ::Form::Question
@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."
- @page = page
@answer_options = ANSWER_OPTIONS
@conditional_for = {
"othernational" => [12],
diff --git a/app/models/form/sales/questions/number_joint_buyers.rb b/app/models/form/sales/questions/number_joint_buyers.rb
index 2370d03c6..b9c2fc2e2 100644
--- a/app/models/form/sales/questions/number_joint_buyers.rb
+++ b/app/models/form/sales/questions/number_joint_buyers.rb
@@ -7,7 +7,6 @@ class Form::Sales::Questions::NumberJointBuyers < ::Form::Question
@hint_text = "You should still try to answer all questions even if the buyer wasn't interviewed in person"
@type = "radio"
@answer_options = ANSWER_OPTIONS
- @page = page
end
ANSWER_OPTIONS = {
diff --git a/app/models/form/sales/questions/number_of_others_in_property.rb b/app/models/form/sales/questions/number_of_others_in_property.rb
index ddf2adb31..136cabcfb 100644
--- a/app/models/form/sales/questions/number_of_others_in_property.rb
+++ b/app/models/form/sales/questions/number_of_others_in_property.rb
@@ -6,7 +6,6 @@ class Form::Sales::Questions::NumberOfOthersInProperty < ::Form::Question
@header = "Besides the buyers, how many other people live in the property?"
@type = "numeric"
@hint_text = "You can provide details for a maximum of 4 other people."
- @page = page
@width = 2
end
end
diff --git a/app/models/form/sales/questions/other_nationality1.rb b/app/models/form/sales/questions/other_nationality1.rb
index 293d4a2f3..3eb6a48d7 100644
--- a/app/models/form/sales/questions/other_nationality1.rb
+++ b/app/models/form/sales/questions/other_nationality1.rb
@@ -5,7 +5,6 @@ class Form::Sales::Questions::OtherNationality1 < ::Form::Question
@check_answer_label = "Buyer 1’s nationality"
@header = "Nationality"
@type = "text"
- @page = page
@check_answers_card_number = 1
end
end
diff --git a/app/models/form/sales/questions/other_ownership_type.rb b/app/models/form/sales/questions/other_ownership_type.rb
index 23995bb9e..428691381 100644
--- a/app/models/form/sales/questions/other_ownership_type.rb
+++ b/app/models/form/sales/questions/other_ownership_type.rb
@@ -6,6 +6,5 @@ class Form::Sales::Questions::OtherOwnershipType < ::Form::Question
@header = "What type of sale is it?"
@type = "text"
@width = 10
- @page = page
end
end
diff --git a/app/models/form/sales/questions/outright_ownership_type.rb b/app/models/form/sales/questions/outright_ownership_type.rb
index 494722031..baead7f5a 100644
--- a/app/models/form/sales/questions/outright_ownership_type.rb
+++ b/app/models/form/sales/questions/outright_ownership_type.rb
@@ -6,7 +6,6 @@ class Form::Sales::Questions::OutrightOwnershipType < ::Form::Question
@header = "What is the type of outright sale?"
@type = "radio"
@answer_options = ANSWER_OPTIONS
- @page = page
@conditional_for = {
"othtype" => [12],
}
diff --git a/app/models/form/sales/questions/ownership_scheme.rb b/app/models/form/sales/questions/ownership_scheme.rb
index 6db17550a..fc30ce3b4 100644
--- a/app/models/form/sales/questions/ownership_scheme.rb
+++ b/app/models/form/sales/questions/ownership_scheme.rb
@@ -6,7 +6,6 @@ class Form::Sales::Questions::OwnershipScheme < ::Form::Question
@header = "Was this purchase made through an ownership scheme?"
@type = "radio"
@answer_options = ANSWER_OPTIONS
- @page = page
end
ANSWER_OPTIONS = {
diff --git a/app/models/form/sales/questions/person_age.rb b/app/models/form/sales/questions/person_age.rb
index 73dcce914..74e140f32 100644
--- a/app/models/form/sales/questions/person_age.rb
+++ b/app/models/form/sales/questions/person_age.rb
@@ -4,7 +4,6 @@ class Form::Sales::Questions::PersonAge < Form::Sales::Questions::Person
@check_answer_label = "Person #{person_display_number}’s age"
@header = "Age"
@type = "numeric"
- @page = page
@width = 3
@inferred_check_answers_value = {
"condition" => { field_for_person("age", "_known") => 1 },
diff --git a/app/models/form/sales/questions/person_age_known.rb b/app/models/form/sales/questions/person_age_known.rb
index 1b0643f7f..a7e145739 100644
--- a/app/models/form/sales/questions/person_age_known.rb
+++ b/app/models/form/sales/questions/person_age_known.rb
@@ -5,8 +5,6 @@ class Form::Sales::Questions::PersonAgeKnown < ::Form::Sales::Questions::Person
@header = "Do you know person #{person_display_number}’s age?"
@type = "radio"
@answer_options = ANSWER_OPTIONS
- @page = page
- @hint_text = ""
@conditional_for = {
field_for_person("age") => [0],
}
diff --git a/app/models/form/sales/questions/person_gender_identity.rb b/app/models/form/sales/questions/person_gender_identity.rb
index db1f44f0f..71bebd818 100644
--- a/app/models/form/sales/questions/person_gender_identity.rb
+++ b/app/models/form/sales/questions/person_gender_identity.rb
@@ -4,7 +4,6 @@ class Form::Sales::Questions::PersonGenderIdentity < ::Form::Sales::Questions::P
@check_answer_label = "Person #{person_display_number}’s gender identity"
@header = "Which of these best describes Person #{person_display_number}’s gender identity?"
@type = "radio"
- @page = page
@answer_options = ANSWER_OPTIONS
@check_answers_card_number = person_index
end
diff --git a/app/models/form/sales/questions/person_known.rb b/app/models/form/sales/questions/person_known.rb
index 487b3f6d9..d03456989 100644
--- a/app/models/form/sales/questions/person_known.rb
+++ b/app/models/form/sales/questions/person_known.rb
@@ -5,8 +5,6 @@ class Form::Sales::Questions::PersonKnown < Form::Sales::Questions::Person
@header = "Do you know the details for person #{person_display_number}?"
@type = "radio"
@answer_options = ANSWER_OPTIONS
- @page = page
- @hint_text = ""
@hidden_in_check_answers = {
"depends_on" => [
{
diff --git a/app/models/form/sales/questions/person_relationship_to_buyer_1.rb b/app/models/form/sales/questions/person_relationship_to_buyer_1.rb
index a6c898796..72ee945f5 100644
--- a/app/models/form/sales/questions/person_relationship_to_buyer_1.rb
+++ b/app/models/form/sales/questions/person_relationship_to_buyer_1.rb
@@ -4,8 +4,6 @@ class Form::Sales::Questions::PersonRelationshipToBuyer1 < ::Form::Sales::Questi
@check_answer_label = "Person #{person_display_number}’s relationship to Buyer 1"
@header = "What is Person #{person_display_number}’s relationship to Buyer 1?"
@type = "radio"
- @hint_text = ""
- @page = page
@answer_options = ANSWER_OPTIONS
@check_answers_card_number = person_index
end
diff --git a/app/models/form/sales/questions/person_working_situation.rb b/app/models/form/sales/questions/person_working_situation.rb
index 6c48d1844..5393ce80d 100644
--- a/app/models/form/sales/questions/person_working_situation.rb
+++ b/app/models/form/sales/questions/person_working_situation.rb
@@ -4,7 +4,6 @@ class Form::Sales::Questions::PersonWorkingSituation < ::Form::Sales::Questions:
@check_answer_label = "Person #{person_display_number}’s working situation"
@header = "Which of these best describes Person #{person_display_number}’s working situation?"
@type = "radio"
- @page = page
@answer_options = ANSWER_OPTIONS
@check_answers_card_number = person_index
end
diff --git a/app/models/form/sales/questions/postcode.rb b/app/models/form/sales/questions/postcode.rb
new file mode 100644
index 000000000..bae59637c
--- /dev/null
+++ b/app/models/form/sales/questions/postcode.rb
@@ -0,0 +1,21 @@
+class Form::Sales::Questions::Postcode < ::Form::Question
+ def initialize(id, hsh, page)
+ super
+ @id = "postcode_full"
+ @check_answer_label = "Property’s postcode"
+ @header = "Postcode"
+ @type = "text"
+ @width = 5
+ @inferred_check_answers_value = {
+ "condition" => {
+ "pcodenk" => 1,
+ },
+ "value" => "Not known",
+ }
+ @inferred_answers = {
+ "la" => {
+ "is_la_inferred" => true,
+ },
+ }
+ end
+end
diff --git a/app/models/form/sales/questions/postcode_known.rb b/app/models/form/sales/questions/postcode_known.rb
new file mode 100644
index 000000000..208f8df22
--- /dev/null
+++ b/app/models/form/sales/questions/postcode_known.rb
@@ -0,0 +1,28 @@
+class Form::Sales::Questions::PostcodeKnown < ::Form::Question
+ def initialize(id, hsh, page)
+ super
+ @id = "pcodenk"
+ @check_answer_label = "Property’s postcode"
+ @header = "Do you know the property’s postcode?"
+ @type = "radio"
+ @answer_options = ANSWER_OPTIONS
+ @conditional_for = {
+ "postcode_full" => [0],
+ }
+ @hidden_in_check_answers = {
+ "depends_on" => [
+ {
+ "pcodenk" => 0,
+ },
+ {
+ "pcodenk" => 1,
+ },
+ ],
+ }
+ end
+
+ ANSWER_OPTIONS = {
+ "0" => { "value" => "Yes" },
+ "1" => { "value" => "No" },
+ }.freeze
+end
diff --git a/app/models/form/sales/questions/previous_bedrooms.rb b/app/models/form/sales/questions/previous_bedrooms.rb
index 60f361499..e63a1b3cf 100644
--- a/app/models/form/sales/questions/previous_bedrooms.rb
+++ b/app/models/form/sales/questions/previous_bedrooms.rb
@@ -5,7 +5,6 @@ class Form::Sales::Questions::PreviousBedrooms < ::Form::Question
@check_answer_label = "Number of bedrooms in previous property"
@header = "How many bedrooms did the property have?"
@type = "numeric"
- @page = page
@width = 5
@min = 0
@hint_text = "For bedsits enter 1"
diff --git a/app/models/form/sales/questions/previous_la_known.rb b/app/models/form/sales/questions/previous_la_known.rb
index 686a60e58..b38f5c560 100644
--- a/app/models/form/sales/questions/previous_la_known.rb
+++ b/app/models/form/sales/questions/previous_la_known.rb
@@ -6,7 +6,6 @@ class Form::Sales::Questions::PreviousLaKnown < ::Form::Question
@header = "Do you know the local authority of buyer 1’s last settled accommodation?"
@type = "radio"
@answer_options = ANSWER_OPTIONS
- @page = page
@hint_text = "This is also known as the household’s 'last settled home'"
@hidden_in_check_answers = {
"depends_on" => [
diff --git a/app/models/form/sales/questions/previous_postcode.rb b/app/models/form/sales/questions/previous_postcode.rb
index a5bb7c54a..039450102 100644
--- a/app/models/form/sales/questions/previous_postcode.rb
+++ b/app/models/form/sales/questions/previous_postcode.rb
@@ -4,10 +4,8 @@ class Form::Sales::Questions::PreviousPostcode < ::Form::Question
@id = "ppostcode_full"
@check_answer_label = "Postcode of buyer 1’s last settled accommodation"
@header = "Postcode"
- @page = page
@type = "text"
@width = 5
- @hint_text = ""
@inferred_check_answers_value = {
"condition" => {
"ppcodenk" => 1,
diff --git a/app/models/form/sales/questions/previous_postcode_known.rb b/app/models/form/sales/questions/previous_postcode_known.rb
index 7c85aabe5..25ee906f8 100644
--- a/app/models/form/sales/questions/previous_postcode_known.rb
+++ b/app/models/form/sales/questions/previous_postcode_known.rb
@@ -6,7 +6,6 @@ class Form::Sales::Questions::PreviousPostcodeKnown < ::Form::Question
@header = "Do you know the postcode of buyer 1’s last settled accommodation?"
@type = "radio"
@answer_options = ANSWER_OPTIONS
- @page = page
@conditional_for = {
"ppostcode_full" => [0],
}
diff --git a/app/models/form/sales/questions/previous_tenure.rb b/app/models/form/sales/questions/previous_tenure.rb
new file mode 100644
index 000000000..e570ec90c
--- /dev/null
+++ b/app/models/form/sales/questions/previous_tenure.rb
@@ -0,0 +1,20 @@
+class Form::Sales::Questions::PreviousTenure < ::Form::Question
+ def initialize(id, hsh, page)
+ super
+ @id = "socprevten"
+ @check_answer_label = "Previous property tenure"
+ @header = "What was the previous tenure of the buyer?"
+ @type = "radio"
+ @hint_text = ""
+ @page = page
+ @answer_options = ANSWER_OPTIONS
+ end
+
+ ANSWER_OPTIONS = {
+ "1" => { "value" => "Social Rent" },
+ "2" => { "value" => "Affordable Rent" },
+ "3" => { "value" => "London Affordable Rent" },
+ "9" => { "value" => "Other" },
+ "10" => { "value" => "Don’t know" },
+ }.freeze
+end
diff --git a/app/models/form/sales/questions/prevloc.rb b/app/models/form/sales/questions/prevloc.rb
index ea7b9cf3b..53f5e5090 100644
--- a/app/models/form/sales/questions/prevloc.rb
+++ b/app/models/form/sales/questions/prevloc.rb
@@ -6,8 +6,6 @@ class Form::Sales::Questions::Prevloc < ::Form::Question
@header = "Select a local authority"
@type = "select"
@answer_options = ANSWER_OPTIONS
- @page = page
- @hint_text = ""
@inferred_check_answers_value = {
"condition" => {
"previous_la_known" => 0,
diff --git a/app/models/form/sales/questions/prevown.rb b/app/models/form/sales/questions/prevown.rb
index 9127a84c1..a9a3b086b 100644
--- a/app/models/form/sales/questions/prevown.rb
+++ b/app/models/form/sales/questions/prevown.rb
@@ -6,8 +6,6 @@ class Form::Sales::Questions::Prevown < ::Form::Question
@header = "Has the buyer previously owned a property?"
@type = "radio"
@answer_options = ANSWER_OPTIONS
- @page = page
- @hint_text = ""
end
ANSWER_OPTIONS = {
diff --git a/app/models/form/sales/questions/privacy_notice.rb b/app/models/form/sales/questions/privacy_notice.rb
index e853b38de..5bc84bce6 100644
--- a/app/models/form/sales/questions/privacy_notice.rb
+++ b/app/models/form/sales/questions/privacy_notice.rb
@@ -5,8 +5,6 @@ class Form::Sales::Questions::PrivacyNotice < ::Form::Question
@check_answer_label = "Buyer has seen the privacy notice?"
@header = "Declaration"
@type = "checkbox"
- @hint_text = ""
- @page = page
@answer_options = ANSWER_OPTIONS
@guidance_position = GuidancePosition::TOP
@guidance_partial = "privacy_notice_buyer"
diff --git a/app/models/form/sales/questions/property_building_type.rb b/app/models/form/sales/questions/property_building_type.rb
index 416c9928e..80102cc7a 100644
--- a/app/models/form/sales/questions/property_building_type.rb
+++ b/app/models/form/sales/questions/property_building_type.rb
@@ -6,8 +6,6 @@ class Form::Sales::Questions::PropertyBuildingType < ::Form::Question
@header = "What type of building is the property?"
@type = "radio"
@answer_options = ANSWER_OPTIONS
- @page = page
- @hint_text = ""
end
ANSWER_OPTIONS = {
diff --git a/app/models/form/sales/questions/property_local_authority.rb b/app/models/form/sales/questions/property_local_authority.rb
index 462956eeb..8def2d9f3 100644
--- a/app/models/form/sales/questions/property_local_authority.rb
+++ b/app/models/form/sales/questions/property_local_authority.rb
@@ -6,7 +6,6 @@ class Form::Sales::Questions::PropertyLocalAuthority < ::Form::Question
@header = "What is the local authority of the property?"
@type = "select"
@answer_options = ANSWER_OPTIONS
- @page = page
end
ANSWER_OPTIONS = {
diff --git a/app/models/form/sales/questions/property_local_authority_known.rb b/app/models/form/sales/questions/property_local_authority_known.rb
index 11ebeca6a..cbb534a06 100644
--- a/app/models/form/sales/questions/property_local_authority_known.rb
+++ b/app/models/form/sales/questions/property_local_authority_known.rb
@@ -14,7 +14,6 @@ class Form::Sales::Questions::PropertyLocalAuthorityKnown < ::Form::Question
},
],
}
- @page = page
end
ANSWER_OPTIONS = {
diff --git a/app/models/form/sales/questions/property_number_of_bedrooms.rb b/app/models/form/sales/questions/property_number_of_bedrooms.rb
index 34b319240..d06d943cf 100644
--- a/app/models/form/sales/questions/property_number_of_bedrooms.rb
+++ b/app/models/form/sales/questions/property_number_of_bedrooms.rb
@@ -7,6 +7,5 @@ class Form::Sales::Questions::PropertyNumberOfBedrooms < ::Form::Question
@hint_text = "A bedsit has 1 bedroom"
@type = "text"
@width = 10
- @page = page
end
end
diff --git a/app/models/form/sales/questions/property_unit_type.rb b/app/models/form/sales/questions/property_unit_type.rb
index 2ebc1a8c2..afa4f0f38 100644
--- a/app/models/form/sales/questions/property_unit_type.rb
+++ b/app/models/form/sales/questions/property_unit_type.rb
@@ -6,7 +6,6 @@ class Form::Sales::Questions::PropertyUnitType < ::Form::Question
@header = "What type of unit is the property?"
@type = "radio"
@answer_options = ANSWER_OPTIONS
- @page = page
end
ANSWER_OPTIONS = {
diff --git a/app/models/form/sales/questions/property_wheelchair_accessible.rb b/app/models/form/sales/questions/property_wheelchair_accessible.rb
index 0290815ef..bfdd133c2 100644
--- a/app/models/form/sales/questions/property_wheelchair_accessible.rb
+++ b/app/models/form/sales/questions/property_wheelchair_accessible.rb
@@ -6,7 +6,6 @@ class Form::Sales::Questions::PropertyWheelchairAccessible < ::Form::Question
@header = "Is the property build or adapted to wheelchair-user standards?"
@type = "radio"
@answer_options = ANSWER_OPTIONS
- @page = page
end
ANSWER_OPTIONS = {
diff --git a/app/models/form/sales/questions/purchase_price.rb b/app/models/form/sales/questions/purchase_price.rb
index da714d9df..af7e8afb9 100644
--- a/app/models/form/sales/questions/purchase_price.rb
+++ b/app/models/form/sales/questions/purchase_price.rb
@@ -5,10 +5,8 @@ class Form::Sales::Questions::PurchasePrice < ::Form::Question
@check_answer_label = "Purchase price"
@header = "What is the full purchase price?"
@type = "numeric"
- @page = page
@min = 0
@width = 5
@prefix = "£"
- @hint_text = ""
end
end
diff --git a/app/models/form/sales/questions/purchaser_code.rb b/app/models/form/sales/questions/purchaser_code.rb
index 1f9551d05..7a5cc4bf7 100644
--- a/app/models/form/sales/questions/purchaser_code.rb
+++ b/app/models/form/sales/questions/purchaser_code.rb
@@ -7,6 +7,5 @@ class Form::Sales::Questions::PurchaserCode < ::Form::Question
@hint_text = "This is how you usually refer to the purchaser on your own systems."
@type = "text"
@width = 10
- @page = page
end
end
diff --git a/app/models/form/sales/questions/resale.rb b/app/models/form/sales/questions/resale.rb
index 8da7d8abd..e67491d65 100644
--- a/app/models/form/sales/questions/resale.rb
+++ b/app/models/form/sales/questions/resale.rb
@@ -6,7 +6,6 @@ class Form::Sales::Questions::Resale < ::Form::Question
@header = "Is this a resale?"
@type = "radio"
@answer_options = ANSWER_OPTIONS
- @page = page
@hint_text = "If the social landlord has previously sold the property to another buyer and is now reselling the property, select 'yes'. If this is the first time the property has been sold, select 'no'."
end
diff --git a/app/models/form/sales/questions/sale_date.rb b/app/models/form/sales/questions/sale_date.rb
index 2b0a3d171..ce085b646 100644
--- a/app/models/form/sales/questions/sale_date.rb
+++ b/app/models/form/sales/questions/sale_date.rb
@@ -5,6 +5,5 @@ class Form::Sales::Questions::SaleDate < ::Form::Question
@check_answer_label = "Sale completion date"
@header = "What is the sale completion date?"
@type = "date"
- @page = page
end
end
diff --git a/app/models/form/sales/questions/savings.rb b/app/models/form/sales/questions/savings.rb
index d605b4a47..920b87d4f 100644
--- a/app/models/form/sales/questions/savings.rb
+++ b/app/models/form/sales/questions/savings.rb
@@ -5,7 +5,6 @@ class Form::Sales::Questions::Savings < ::Form::Question
@check_answer_label = "Buyer’s total savings (to nearest £10) before any deposit paid"
@header = "Enter their total savings to the nearest £10"
@type = "numeric"
- @page = page
@width = 5
@prefix = "£"
@step = 1
diff --git a/app/models/form/sales/questions/savings_nk.rb b/app/models/form/sales/questions/savings_nk.rb
index bce9d849d..f68b45560 100644
--- a/app/models/form/sales/questions/savings_nk.rb
+++ b/app/models/form/sales/questions/savings_nk.rb
@@ -6,8 +6,6 @@ class Form::Sales::Questions::SavingsNk < ::Form::Question
@header = "Do you know how much the buyer had in savings before they paid any deposit for the property?"
@type = "radio"
@answer_options = ANSWER_OPTIONS
- @page = page
- @hint_text = ""
@conditional_for = {
"savings" => [0],
}
diff --git a/app/models/form/sales/questions/savings_value_check.rb b/app/models/form/sales/questions/savings_value_check.rb
index 6af93ee03..bcd16827a 100644
--- a/app/models/form/sales/questions/savings_value_check.rb
+++ b/app/models/form/sales/questions/savings_value_check.rb
@@ -20,6 +20,5 @@ class Form::Sales::Questions::SavingsValueCheck < ::Form::Question
],
}
@check_answers_card_number = 0
- @page = page
end
end
diff --git a/app/models/form/sales/questions/shared_ownership_type.rb b/app/models/form/sales/questions/shared_ownership_type.rb
index 27d6ea074..6351cc185 100644
--- a/app/models/form/sales/questions/shared_ownership_type.rb
+++ b/app/models/form/sales/questions/shared_ownership_type.rb
@@ -7,7 +7,6 @@ class Form::Sales::Questions::SharedOwnershipType < ::Form::Question
@hint_text = "A shared ownership sale is when the purchaser buys up to 75% of the property value and pays rent to the Private Registered Provider (PRP) on the remaining portion"
@type = "radio"
@answer_options = ANSWER_OPTIONS
- @page = page
end
ANSWER_OPTIONS = {
diff --git a/app/models/form/sales/questions/staircase.rb b/app/models/form/sales/questions/staircase.rb
index e204414b9..c03c24089 100644
--- a/app/models/form/sales/questions/staircase.rb
+++ b/app/models/form/sales/questions/staircase.rb
@@ -6,7 +6,6 @@ class Form::Sales::Questions::Staircase < ::Form::Question
@header = "Is this a staircasing transaction?"
@type = "radio"
@answer_options = ANSWER_OPTIONS
- @page = page
@hint_text = "A staircasing transaction is when the household purchases more shares in their property, increasing the proportion they own and decreasing the proportion the housing association owns. Once the household purchases 100% of the shares, they own the property"
end
diff --git a/app/models/form/sales/questions/staircase_bought.rb b/app/models/form/sales/questions/staircase_bought.rb
index 5afca794d..bdb5ac965 100644
--- a/app/models/form/sales/questions/staircase_bought.rb
+++ b/app/models/form/sales/questions/staircase_bought.rb
@@ -5,7 +5,6 @@ class Form::Sales::Questions::StaircaseBought < ::Form::Question
@check_answer_label = "Percentage bought in this staircasing transaction"
@header = "What percentage of the property has been bought in this staircasing transaction?"
@type = "numeric"
- @page = page
@width = 5
@min = 0
@max = 100
diff --git a/app/models/form/sales/questions/staircase_owned.rb b/app/models/form/sales/questions/staircase_owned.rb
index 0fa37ec7a..6f9e13b14 100644
--- a/app/models/form/sales/questions/staircase_owned.rb
+++ b/app/models/form/sales/questions/staircase_owned.rb
@@ -5,7 +5,6 @@ class Form::Sales::Questions::StaircaseOwned < ::Form::Question
@check_answer_label = "Percentage the buyer now owns in total"
@header = "What percentage of the property does the buyer now own in total?"
@type = "numeric"
- @page = page
@width = 5
@min = 0
@max = 100
diff --git a/app/models/form/sales/questions/value.rb b/app/models/form/sales/questions/value.rb
index 0686d6610..24e20e5ca 100644
--- a/app/models/form/sales/questions/value.rb
+++ b/app/models/form/sales/questions/value.rb
@@ -5,7 +5,6 @@ class Form::Sales::Questions::Value < ::Form::Question
@check_answer_label = "Full purchase price"
@header = "What was the full purchase price?"
@type = "numeric"
- @page = page
@min = 0
@width = 5
@prefix = "£"
diff --git a/app/models/form/sales/sections/finances.rb b/app/models/form/sales/sections/finances.rb
index eb5c1a7f5..fb12e9923 100644
--- a/app/models/form/sales/sections/finances.rb
+++ b/app/models/form/sales/sections/finances.rb
@@ -4,7 +4,6 @@ class Form::Sales::Sections::Finances < ::Form::Section
@id = "finances"
@label = "Finances"
@description = ""
- @form = form
@subsections = [
Form::Sales::Subsections::IncomeBenefitsAndSavings.new(nil, nil, self),
]
diff --git a/app/models/form/sales/sections/household.rb b/app/models/form/sales/sections/household.rb
index 3c7eae085..e8bcc1451 100644
--- a/app/models/form/sales/sections/household.rb
+++ b/app/models/form/sales/sections/household.rb
@@ -4,7 +4,6 @@ class Form::Sales::Sections::Household < ::Form::Section
@id = "household"
@label = "About the household"
@description = ""
- @form = form
@subsections = [
Form::Sales::Subsections::HouseholdCharacteristics.new(nil, nil, self),
Form::Sales::Subsections::HouseholdSituation.new(nil, nil, self),
diff --git a/app/models/form/sales/sections/property_information.rb b/app/models/form/sales/sections/property_information.rb
index 39f6609ae..f098cafa6 100644
--- a/app/models/form/sales/sections/property_information.rb
+++ b/app/models/form/sales/sections/property_information.rb
@@ -4,7 +4,6 @@ class Form::Sales::Sections::PropertyInformation < ::Form::Section
@id = "property_information"
@label = "Property information"
@description = ""
- @form = form
@subsections = [Form::Sales::Subsections::PropertyInformation.new(nil, nil, self)] || []
end
end
diff --git a/app/models/form/sales/sections/sale_information.rb b/app/models/form/sales/sections/sale_information.rb
index 941abad3a..b57eb70a6 100644
--- a/app/models/form/sales/sections/sale_information.rb
+++ b/app/models/form/sales/sections/sale_information.rb
@@ -4,7 +4,6 @@ class Form::Sales::Sections::SaleInformation < ::Form::Section
@id = "sale_information"
@label = "Sale information"
@description = ""
- @form = form
@subsections = [
Form::Sales::Subsections::SharedOwnershipScheme.new(nil, nil, self),
Form::Sales::Subsections::DiscountedOwnershipScheme.new(nil, nil, self),
diff --git a/app/models/form/sales/sections/setup.rb b/app/models/form/sales/sections/setup.rb
index d90c72036..c2c105a60 100644
--- a/app/models/form/sales/sections/setup.rb
+++ b/app/models/form/sales/sections/setup.rb
@@ -4,7 +4,6 @@ class Form::Sales::Sections::Setup < ::Form::Section
@id = "setup"
@label = "Before you start"
@description = ""
- @form = form
@subsections = [Form::Sales::Subsections::Setup.new(nil, nil, self)] || []
end
end
diff --git a/app/models/form/sales/subsections/discounted_ownership_scheme.rb b/app/models/form/sales/subsections/discounted_ownership_scheme.rb
index d948aadd5..1d9e339f3 100644
--- a/app/models/form/sales/subsections/discounted_ownership_scheme.rb
+++ b/app/models/form/sales/subsections/discounted_ownership_scheme.rb
@@ -3,7 +3,6 @@ class Form::Sales::Subsections::DiscountedOwnershipScheme < ::Form::Subsection
super
@id = "discounted_ownership_scheme"
@label = "Discounted ownership scheme"
- @section = section
@depends_on = [{ "ownershipsch" => 2, "setup_completed?" => true }]
end
@@ -14,6 +13,8 @@ class Form::Sales::Subsections::DiscountedOwnershipScheme < ::Form::Subsection
Form::Sales::Pages::AboutPriceNotRtb.new(nil, nil, self),
Form::Sales::Pages::Mortgageused.new("mortgage_used_discounted_ownership", nil, self),
Form::Sales::Pages::MortgageAmount.new("mortgage_amount_discounted_ownership", nil, self),
+ Form::Sales::Pages::MortgageLender.new("mortgage_lender_discounted_ownership", nil, self),
+ Form::Sales::Pages::MortgageLenderOther.new("mortgage_lender_other_discounted_ownership", nil, self),
Form::Sales::Pages::MortgageLength.new("mortgage_length_discounted_ownership", nil, self),
Form::Sales::Pages::ExtraBorrowing.new("extra_borrowing_discounted_ownership", nil, self),
Form::Sales::Pages::AboutDepositWithoutDiscount.new("about_deposit_discounted_ownership", nil, self),
diff --git a/app/models/form/sales/subsections/household_characteristics.rb b/app/models/form/sales/subsections/household_characteristics.rb
index 5fe1175e3..38a71cf41 100644
--- a/app/models/form/sales/subsections/household_characteristics.rb
+++ b/app/models/form/sales/subsections/household_characteristics.rb
@@ -3,7 +3,6 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection
super
@id = "household_characteristics"
@label = "Household characteristics"
- @section = section
@depends_on = [{ "setup_completed?" => true }]
end
diff --git a/app/models/form/sales/subsections/household_needs.rb b/app/models/form/sales/subsections/household_needs.rb
index 4e9cab5f5..d411d5101 100644
--- a/app/models/form/sales/subsections/household_needs.rb
+++ b/app/models/form/sales/subsections/household_needs.rb
@@ -3,7 +3,6 @@ class Form::Sales::Subsections::HouseholdNeeds < ::Form::Subsection
super
@id = "household_needs"
@label = "Household needs"
- @section = section
@depends_on = [{ "setup_completed?" => true }]
end
diff --git a/app/models/form/sales/subsections/household_situation.rb b/app/models/form/sales/subsections/household_situation.rb
index afc782028..a9d9306d6 100644
--- a/app/models/form/sales/subsections/household_situation.rb
+++ b/app/models/form/sales/subsections/household_situation.rb
@@ -3,7 +3,6 @@ class Form::Sales::Subsections::HouseholdSituation < ::Form::Subsection
super
@id = "household_situation"
@label = "Household situation"
- @section = section
@depends_on = [{ "setup_completed?" => true }]
end
diff --git a/app/models/form/sales/subsections/income_benefits_and_savings.rb b/app/models/form/sales/subsections/income_benefits_and_savings.rb
index 409d50270..e2eb32b08 100644
--- a/app/models/form/sales/subsections/income_benefits_and_savings.rb
+++ b/app/models/form/sales/subsections/income_benefits_and_savings.rb
@@ -3,7 +3,6 @@ class Form::Sales::Subsections::IncomeBenefitsAndSavings < ::Form::Subsection
super
@id = "income_benefits_and_savings"
@label = "Income, benefits and savings"
- @section = section
@depends_on = [{ "setup_completed?" => true }]
end
diff --git a/app/models/form/sales/subsections/outright_sale.rb b/app/models/form/sales/subsections/outright_sale.rb
index da1261b6d..48dcfa4da 100644
--- a/app/models/form/sales/subsections/outright_sale.rb
+++ b/app/models/form/sales/subsections/outright_sale.rb
@@ -3,7 +3,6 @@ class Form::Sales::Subsections::OutrightSale < ::Form::Subsection
super
@id = "outright_sale"
@label = "Outright sale"
- @section = section
@depends_on = [{ "ownershipsch" => 3, "setup_completed?" => true }]
end
@@ -12,6 +11,8 @@ class Form::Sales::Subsections::OutrightSale < ::Form::Subsection
Form::Sales::Pages::PurchasePrice.new(nil, nil, self),
Form::Sales::Pages::Mortgageused.new("mortgage_used_outright_sale", nil, self),
Form::Sales::Pages::MortgageAmount.new("mortgage_amount_outright_sale", nil, self),
+ Form::Sales::Pages::MortgageLender.new("mortgage_lender_outright_sale", nil, self),
+ Form::Sales::Pages::MortgageLenderOther.new("mortgage_lender_other_outright_sale", nil, self),
Form::Sales::Pages::MortgageLength.new("mortgage_length_outright_sale", nil, self),
Form::Sales::Pages::ExtraBorrowing.new("extra_borrowing_outright_sale", nil, self),
Form::Sales::Pages::AboutDepositWithoutDiscount.new("about_deposit_outright_sale", nil, self),
diff --git a/app/models/form/sales/subsections/property_information.rb b/app/models/form/sales/subsections/property_information.rb
index 02d7b4037..c1c150b9f 100644
--- a/app/models/form/sales/subsections/property_information.rb
+++ b/app/models/form/sales/subsections/property_information.rb
@@ -3,15 +3,15 @@ class Form::Sales::Subsections::PropertyInformation < ::Form::Subsection
super
@id = "property_information"
@label = "Property information"
- @section = section
@depends_on = [{ "setup_completed?" => true }]
end
def pages
@pages ||= [
Form::Sales::Pages::PropertyNumberOfBedrooms.new(nil, nil, self),
- Form::Sales::Pages::PropertyBuildingType.new(nil, nil, self),
Form::Sales::Pages::PropertyUnitType.new(nil, nil, self),
+ Form::Sales::Pages::PropertyBuildingType.new(nil, nil, self),
+ Form::Sales::Pages::Postcode.new(nil, nil, self),
Form::Sales::Pages::PropertyLocalAuthority.new(nil, nil, self),
Form::Sales::Pages::PropertyWheelchairAccessible.new(nil, nil, self),
]
diff --git a/app/models/form/sales/subsections/setup.rb b/app/models/form/sales/subsections/setup.rb
index f39926db3..d2261a33b 100644
--- a/app/models/form/sales/subsections/setup.rb
+++ b/app/models/form/sales/subsections/setup.rb
@@ -3,7 +3,6 @@ class Form::Sales::Subsections::Setup < ::Form::Subsection
super
@id = "setup"
@label = "Set up this sales log"
- @section = section
end
def pages
diff --git a/app/models/form/sales/subsections/shared_ownership_scheme.rb b/app/models/form/sales/subsections/shared_ownership_scheme.rb
index 6a1c75c30..8b5ff0902 100644
--- a/app/models/form/sales/subsections/shared_ownership_scheme.rb
+++ b/app/models/form/sales/subsections/shared_ownership_scheme.rb
@@ -3,7 +3,6 @@ class Form::Sales::Subsections::SharedOwnershipScheme < ::Form::Subsection
super
@id = "shared_ownership_scheme"
@label = "Shared ownership scheme"
- @section = section
@depends_on = [{ "ownershipsch" => 1, "setup_completed?" => true }]
end
@@ -18,9 +17,13 @@ class Form::Sales::Subsections::SharedOwnershipScheme < ::Form::Subsection
Form::Sales::Pages::LaNominations.new(nil, nil, self),
Form::Sales::Pages::BuyerPrevious.new(nil, nil, self),
Form::Sales::Pages::PreviousBedrooms.new(nil, nil, self),
+ Form::Sales::Pages::PreviousPropertyType.new(nil, nil, self),
+ Form::Sales::Pages::PreviousTenure.new(nil, nil, self),
Form::Sales::Pages::AboutPriceSharedOwnership.new(nil, nil, self),
Form::Sales::Pages::Mortgageused.new("mortgage_used_shared_ownership", nil, self),
Form::Sales::Pages::MortgageAmount.new("mortgage_amount_shared_ownership", nil, self),
+ Form::Sales::Pages::MortgageLender.new("mortgage_lender_shared_ownership", nil, self),
+ Form::Sales::Pages::MortgageLenderOther.new("mortgage_lender_other_shared_ownership", nil, self),
Form::Sales::Pages::MortgageLength.new("mortgage_length_shared_ownership", nil, self),
Form::Sales::Pages::ExtraBorrowing.new("extra_borrowing_shared_ownership", nil, self),
Form::Sales::Pages::AboutDepositWithDiscount.new(nil, nil, self),
diff --git a/app/models/form_handler.rb b/app/models/form_handler.rb
index 1afa1d15f..51a0b6177 100644
--- a/app/models/form_handler.rb
+++ b/app/models/form_handler.rb
@@ -78,6 +78,16 @@ class FormHandler
forms.count { |form| form.start_date < now && now < form.end_date } > 1
end
+ def use_fake_forms!
+ @directories = ["spec/fixtures/forms"]
+ @forms = get_all_forms
+ end
+
+ def use_real_forms!
+ @directories = ["config/forms"]
+ @forms = get_all_forms
+ end
+
private
def get_all_forms
@@ -85,6 +95,6 @@ private
end
def directories
- Rails.env.test? ? ["spec/fixtures/forms"] : ["config/forms"]
+ @directories ||= Rails.env.test? ? ["spec/fixtures/forms"] : ["config/forms"]
end
end
diff --git a/app/models/forms/bulk_upload_lettings/upload_your_file.rb b/app/models/forms/bulk_upload_lettings/upload_your_file.rb
index da2947f53..57ac017a3 100644
--- a/app/models/forms/bulk_upload_lettings/upload_your_file.rb
+++ b/app/models/forms/bulk_upload_lettings/upload_your_file.rb
@@ -41,9 +41,9 @@ module Forms
filename: file.original_filename,
)
- if upload_enabled?
- storage_service.write_file(bulk_upload.identifier, File.read(file.path))
- end
+ storage_service.write_file(bulk_upload.identifier, File.read(file.path))
+
+ ProcessBulkUploadJob.perform_later(bulk_upload:)
true
end
@@ -55,7 +55,14 @@ module Forms
end
def storage_service
- @storage_service ||= Storage::S3Service.new(Configuration::PaasConfigurationService.new, ENV["CSV_DOWNLOAD_PAAS_INSTANCE"])
+ @storage_service ||= if upload_enabled?
+ Storage::S3Service.new(
+ Configuration::PaasConfigurationService.new,
+ ENV["CSV_DOWNLOAD_PAAS_INSTANCE"],
+ )
+ else
+ Storage::LocalDiskService.new
+ end
end
def validate_file_is_csv
diff --git a/app/models/forms/bulk_upload_sales/upload_your_file.rb b/app/models/forms/bulk_upload_sales/upload_your_file.rb
index b8454000b..117e612b1 100644
--- a/app/models/forms/bulk_upload_sales/upload_your_file.rb
+++ b/app/models/forms/bulk_upload_sales/upload_your_file.rb
@@ -38,21 +38,24 @@ module Forms
filename: file.original_filename,
)
- if upload_enabled?
- storage_service.write_file(bulk_upload.identifier, File.read(file.path))
- end
+ storage_service.write_file(bulk_upload.identifier, File.read(file.path))
+
+ ProcessBulkUploadJob.perform_later(bulk_upload:)
true
end
private
- def upload_enabled?
- !Rails.env.development?
- end
-
def storage_service
- @storage_service ||= Storage::S3Service.new(Configuration::PaasConfigurationService.new, ENV["CSV_DOWNLOAD_PAAS_INSTANCE"])
+ @storage_service ||= if FeatureToggle.upload_enabled?
+ Storage::S3Service.new(
+ Configuration::PaasConfigurationService.new,
+ ENV["CSV_DOWNLOAD_PAAS_INSTANCE"],
+ )
+ else
+ Storage::LocalDiskService.new
+ end
end
def validate_file_is_csv
diff --git a/app/models/lettings_log.rb b/app/models/lettings_log.rb
index 0041f3200..2584f95ae 100644
--- a/app/models/lettings_log.rb
+++ b/app/models/lettings_log.rb
@@ -8,6 +8,7 @@ class LettingsLogValidator < ActiveModel::Validator
include Validations::TenancyValidations
include Validations::DateValidations
include Validations::LocalAuthorityValidations
+
def validate(record)
validation_methods = public_methods.select { |method| method.starts_with?("validate_") }
validation_methods.each { |meth| public_send(meth, record) }
@@ -607,10 +608,6 @@ private
self[la_key] = inferred_la if inferred_la.present?
end
- def reset_location_fields!
- reset_location(is_la_inferred, "la", "is_la_inferred", "postcode_full", 1)
- end
-
def get_has_benefits
HAS_BENEFITS_OPTIONS.include?(hb) ? 1 : 0
end
diff --git a/app/models/log.rb b/app/models/log.rb
index 798b78af7..0d0df6451 100644
--- a/app/models/log.rb
+++ b/app/models/log.rb
@@ -105,6 +105,10 @@ private
string.present? ? string.upcase.gsub(/\s+/, "") : string
end
+ def reset_location_fields!
+ reset_location(is_la_inferred, "la", "is_la_inferred", "postcode_full", 1)
+ end
+
def reset_previous_location_fields!
reset_location(is_previous_la_inferred, "prevloc", "is_previous_la_inferred", "ppostcode_full", previous_la_known)
end
diff --git a/app/models/organisation.rb b/app/models/organisation.rb
index 0bf47eb76..fa675b36c 100644
--- a/app/models/organisation.rb
+++ b/app/models/organisation.rb
@@ -92,4 +92,8 @@ class Organisation < ApplicationRecord
{ name: "Data protection agreement", value: data_protection_agreement_string, editable: false },
].compact
end
+
+ def has_managing_agents?
+ managing_agents.count.positive?
+ end
end
diff --git a/app/models/sales_log.rb b/app/models/sales_log.rb
index 22f750148..c5c51578b 100644
--- a/app/models/sales_log.rb
+++ b/app/models/sales_log.rb
@@ -21,7 +21,9 @@ class SalesLog < Log
validates_with SalesLogValidator
before_validation :set_derived_fields!
before_validation :reset_invalidated_dependent_fields!
+ before_validation :process_postcode_changes!, if: :postcode_full_changed?
before_validation :process_previous_postcode_changes!, if: :ppostcode_full_changed?
+ before_validation :reset_location_fields!, unless: :postcode_known?
before_validation :reset_previous_location_fields!, unless: :previous_postcode_known?
scope :filter_by_year, ->(year) { where(saledate: Time.zone.local(year.to_i, 4, 1)...Time.zone.local(year.to_i + 1, 4, 1)) }
@@ -135,6 +137,18 @@ class SalesLog < Log
ppcodenk&.zero?
end
+ def postcode_known?
+ pcodenk&.zero?
+ end
+
+ def postcode_full=(postcode)
+ if postcode
+ super UKPostcode.parse(postcode).to_s
+ else
+ super nil
+ end
+ end
+
def process_postcode(postcode, postcode_known_key, la_inferred_key, la_key)
return if postcode.blank?
@@ -151,4 +165,9 @@ class SalesLog < Log
def mortgage_not_used?
mortgageused == 2
end
+
+ def process_postcode_changes!
+ self.postcode_full = upcase_and_remove_whitespace(postcode_full)
+ process_postcode(postcode_full, "pcodenk", "is_la_inferred", "la")
+ end
end
diff --git a/app/models/user.rb b/app/models/user.rb
index 6126e7004..66e3e806f 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -12,6 +12,7 @@ class User < ApplicationRecord
has_many :owned_sales_logs, through: :organisation
has_many :managed_sales_logs, through: :organisation
has_many :legacy_users
+ has_many :bulk_uploads
validates :name, presence: true
validates :email, presence: true
@@ -144,7 +145,7 @@ class User < ApplicationRecord
end
def logs_filters(specific_org: false)
- if support? && !specific_org
+ if (support? && !specific_org) || organisation.has_managing_agents?
%w[status years user organisation]
else
%w[status years user]
diff --git a/app/models/validations/financial_validations.rb b/app/models/validations/financial_validations.rb
index 87c506b4d..a5430bbea 100644
--- a/app/models/validations/financial_validations.rb
+++ b/app/models/validations/financial_validations.rb
@@ -98,11 +98,11 @@ module Validations::FinancialValidations
end
def validate_rent_period(record)
- if record.owning_organisation.present? && record.owning_organisation.rent_periods.present? &&
- record.period && !record.owning_organisation.rent_periods.include?(record.period)
+ if record.managing_organisation.present? && record.managing_organisation.rent_periods.present? &&
+ record.period && !record.managing_organisation.rent_periods.include?(record.period)
record.errors.add :period, I18n.t(
"validations.financial.rent_period.invalid_for_org",
- org_name: record.owning_organisation.name,
+ org_name: record.managing_organisation.name,
rent_period: record.form.get_question("period", record).label_from_value(record.period).downcase,
)
end
diff --git a/app/models/validations/property_validations.rb b/app/models/validations/property_validations.rb
index c655d8c85..8b0988dd9 100644
--- a/app/models/validations/property_validations.rb
+++ b/app/models/validations/property_validations.rb
@@ -50,14 +50,6 @@ module Validations::PropertyValidations
end
end
- def validate_property_postcode(record)
- postcode = record.postcode_full
- if record.postcode_known? && (postcode.blank? || !postcode.match(POSTCODE_REGEXP))
- error_message = I18n.t("validations.postcode")
- record.errors.add :postcode_full, error_message
- end
- end
-
def validate_shared_housing_rooms(record)
if record.beds.present? && record.beds <= 0
record.errors.add :beds, I18n.t("validations.property.beds.non_positive")
diff --git a/app/models/validations/shared_validations.rb b/app/models/validations/shared_validations.rb
index 2694fd743..d8d4e2059 100644
--- a/app/models/validations/shared_validations.rb
+++ b/app/models/validations/shared_validations.rb
@@ -34,6 +34,14 @@ module Validations::SharedValidations
end
end
+ def validate_property_postcode(record)
+ postcode = record.postcode_full
+ if record.postcode_known? && (postcode.blank? || !postcode.match(POSTCODE_REGEXP))
+ error_message = I18n.t("validations.postcode")
+ record.errors.add :postcode_full, error_message
+ end
+ end
+
def location_during_startdate_validation(record, field)
location_inactive_status = inactive_status(record.startdate, record.location)
@@ -68,4 +76,17 @@ module Validations::SharedValidations
{ scope: status, date: date&.to_formatted_s(:govuk_date), deactivation_date: closest_reactivation&.deactivation_date&.to_formatted_s(:govuk_date) }
end
+
+ def validate_valid_radio_option(record)
+ return unless FeatureToggle.validate_valid_radio_options?
+
+ record.attributes.each do |question_id, _v|
+ question = record.form.get_question(question_id, record)
+
+ next unless question&.type == "radio"
+ next unless record[question_id].present? && !question.answer_options.key?(record[question_id].to_s) && question.page.routed_to?(record, nil)
+
+ record.errors.add(question_id, I18n.t("validations.invalid_option", question: question.check_answer_label&.downcase))
+ end
+ end
end
diff --git a/app/services/bulk_upload/downloader.rb b/app/services/bulk_upload/downloader.rb
index 9d40ef5b9..8fcd9ccca 100644
--- a/app/services/bulk_upload/downloader.rb
+++ b/app/services/bulk_upload/downloader.rb
@@ -11,6 +11,10 @@ class BulkUpload::Downloader
download
end
+ def delete_local_file!
+ file.unlink
+ end
+
private
def download
@@ -25,9 +29,21 @@ private
end
def storage_service
- @storage_service ||= Storage::S3Service.new(
+ @storage_service ||= if FeatureToggle.upload_enabled?
+ s3_storage_service
+ else
+ local_disk_storage_service
+ end
+ end
+
+ def s3_storage_service
+ Storage::S3Service.new(
Configuration::PaasConfigurationService.new,
ENV["CSV_DOWNLOAD_PAAS_INSTANCE"],
)
end
+
+ def local_disk_storage_service
+ Storage::LocalDiskService.new
+ end
end
diff --git a/app/services/bulk_upload/lettings/row_parser.rb b/app/services/bulk_upload/lettings/row_parser.rb
new file mode 100644
index 000000000..c59409144
--- /dev/null
+++ b/app/services/bulk_upload/lettings/row_parser.rb
@@ -0,0 +1,785 @@
+class BulkUpload::Lettings::RowParser
+ include ActiveModel::Model
+ include ActiveModel::Attributes
+
+ attribute :bulk_upload
+
+ attribute :field_1, :integer
+ attribute :field_2
+ attribute :field_3
+ attribute :field_4, :integer
+ attribute :field_5, :integer
+ attribute :field_6
+ attribute :field_7, :string
+ attribute :field_8, :integer
+ attribute :field_9, :integer
+ attribute :field_10, :string
+ attribute :field_11, :integer
+ attribute :field_12, :string
+ attribute :field_13, :string
+ attribute :field_14, :string
+ attribute :field_15, :string
+ attribute :field_16, :string
+ attribute :field_17, :string
+ attribute :field_18, :string
+ attribute :field_19, :string
+ attribute :field_20, :string
+ attribute :field_21, :string
+ attribute :field_22, :string
+ attribute :field_23, :string
+ attribute :field_24, :string
+ attribute :field_25, :string
+ attribute :field_26, :string
+ attribute :field_27, :string
+ attribute :field_28, :string
+ attribute :field_29, :string
+ attribute :field_30, :string
+ attribute :field_31, :string
+ attribute :field_32, :string
+ attribute :field_33, :string
+ attribute :field_34, :string
+ attribute :field_35, :integer
+ attribute :field_36, :integer
+ attribute :field_37, :integer
+ attribute :field_38, :integer
+ attribute :field_39, :integer
+ attribute :field_40, :integer
+ attribute :field_41, :integer
+ attribute :field_42, :integer
+ attribute :field_43, :integer
+ attribute :field_44, :integer
+ attribute :field_45, :integer
+ attribute :field_46, :integer
+ attribute :field_47, :integer
+ attribute :field_48, :integer
+ attribute :field_49, :integer
+ attribute :field_50, :decimal
+ attribute :field_51, :integer
+ attribute :field_52, :integer
+ attribute :field_53, :string
+ attribute :field_54
+ attribute :field_55, :integer
+ attribute :field_56, :integer
+ attribute :field_57, :integer
+ attribute :field_58, :integer
+ attribute :field_59, :integer
+ attribute :field_60, :integer
+ attribute :field_61, :integer
+ attribute :field_62, :string
+ attribute :field_63, :string
+ attribute :field_64, :string
+ attribute :field_65, :integer
+ attribute :field_66, :integer
+ attribute :field_67, :integer
+ attribute :field_68, :integer
+ attribute :field_69, :integer
+ attribute :field_70, :integer
+ attribute :field_71, :integer
+ attribute :field_72, :integer
+ attribute :field_73, :integer
+ attribute :field_74, :integer
+ attribute :field_75, :integer
+ attribute :field_76, :integer
+ attribute :field_77, :integer
+ attribute :field_78, :integer
+ attribute :field_79, :integer
+ attribute :field_80, :decimal
+ attribute :field_81, :decimal
+ attribute :field_82, :decimal
+ attribute :field_83, :decimal
+ attribute :field_84, :decimal
+ attribute :field_85, :decimal
+ attribute :field_86, :integer
+ attribute :field_87, :integer
+ attribute :field_88, :decimal
+ attribute :field_89, :integer
+ attribute :field_90, :integer
+ attribute :field_91, :integer
+ attribute :field_92, :integer
+ attribute :field_93, :integer
+ attribute :field_94, :integer
+ attribute :field_95
+ attribute :field_96, :integer
+ attribute :field_97, :integer
+ attribute :field_98, :integer
+ attribute :field_99, :integer
+ attribute :field_100, :string
+ attribute :field_101, :integer
+ attribute :field_102, :integer
+ attribute :field_103, :integer
+ attribute :field_104, :integer
+ attribute :field_105, :integer
+ attribute :field_106, :integer
+ attribute :field_107, :string
+ attribute :field_108, :string
+ attribute :field_109, :string
+ attribute :field_110
+ attribute :field_111, :integer
+ attribute :field_112, :string
+ attribute :field_113, :integer
+ attribute :field_114, :integer
+ attribute :field_115
+ attribute :field_116, :integer
+ attribute :field_117, :integer
+ attribute :field_118, :integer
+ attribute :field_119, :integer
+ attribute :field_120, :integer
+ attribute :field_121, :integer
+ attribute :field_122, :integer
+ attribute :field_123, :integer
+ attribute :field_124, :integer
+ attribute :field_125, :integer
+ attribute :field_126, :integer
+ attribute :field_127, :integer
+ attribute :field_128, :integer
+ attribute :field_129, :integer
+ attribute :field_130, :integer
+ attribute :field_131, :string
+ attribute :field_132, :integer
+ attribute :field_133, :integer
+ attribute :field_134, :integer
+
+ validates :field_1, presence: true, inclusion: { in: (1..12).to_a }
+ validates :field_4, presence: { if: proc { [2, 4, 6, 8, 10, 12].include?(field_1) } }
+
+ validates :field_96, presence: true
+ validates :field_97, presence: true
+ validates :field_98, presence: true
+
+ def valid?
+ errors.clear
+
+ super
+
+ validate_data_types
+ validate_nulls
+
+ log.valid?
+
+ log.errors.each do |error|
+ fields = field_mapping_for_errors[error.attribute] || []
+ fields.each { |field| errors.add(field, error.type) }
+ end
+
+ errors.blank?
+ end
+
+ def log
+ @log ||= LettingsLog.new(attributes_for_log)
+ end
+
+private
+
+ def attribute_set
+ @attribute_set ||= instance_variable_get(:@attributes)
+ end
+
+ def validate_data_types
+ unless attribute_set["field_1"].value_before_type_cast&.match?(/\A\d+\z/)
+ errors.add(:field_1, :invalid)
+ end
+ end
+
+ def postcode_full
+ "#{field_108} #{field_109}" if field_108 && field_109
+ end
+
+ def postcode_known
+ if postcode_full.present?
+ 1
+ elsif field_107.present?
+ 0
+ end
+ end
+
+ def questions
+ log.form.subsections.flat_map { |ss| ss.applicable_questions(log) }
+ end
+
+ def validate_nulls
+ field_mapping_for_errors.each do |error_key, fields|
+ question_id = error_key.to_s
+ question = questions.find { |q| q.id == question_id }
+
+ next unless question
+ next if log.optional_fields.include?(question.id)
+ next if question.completed?(log)
+
+ fields.each { |field| errors.add(field, :blank) }
+ end
+ end
+
+ def field_mapping_for_errors
+ {
+ lettype: [:field_1],
+ tenancycode: [:field_7],
+ postcode_known: %i[field_107 field_108 field_109],
+ postcode_full: %i[field_107 field_108 field_109],
+ la: %i[field_107],
+ owning_organisation_id: [:field_111],
+ managing_organisation_id: [:field_113],
+ renewal: [:field_134],
+ scheme: %i[field_4 field_5],
+ created_by: [],
+ needstype: [],
+ rent_type: %i[field_1 field_129 field_130],
+ startdate: %i[field_98 field_97 field_96],
+ unittype_gn: %i[field_102],
+ builtype: %i[field_103],
+ wchair: %i[field_104],
+ beds: %i[field_101],
+ joint: %i[field_133],
+ startertenancy: %i[field_8],
+ tenancy: %i[field_9],
+ tenancyother: %i[field_10],
+ tenancylength: %i[field_11],
+ declaration: %i[field_132],
+
+ age1_known: %i[field_12],
+ age1: %i[field_12],
+ age2_known: %i[field_13],
+ age2: %i[field_13],
+ age3_known: %i[field_14],
+ age3: %i[field_14],
+ age4_known: %i[field_15],
+ age4: %i[field_15],
+ age5_known: %i[field_16],
+ age5: %i[field_16],
+ age6_known: %i[field_17],
+ age6: %i[field_17],
+ age7_known: %i[field_18],
+ age7: %i[field_18],
+ age8_known: %i[field_19],
+ age8: %i[field_19],
+
+ sex1: %i[field_20],
+ sex2: %i[field_21],
+ sex3: %i[field_22],
+ sex4: %i[field_23],
+ sex5: %i[field_24],
+ sex6: %i[field_25],
+ sex7: %i[field_26],
+ sex8: %i[field_27],
+
+ ethnic_group: %i[field_43],
+ ethnic: %i[field_43],
+ national: %i[field_44],
+
+ relat2: %i[field_28],
+ relat3: %i[field_29],
+ relat4: %i[field_30],
+ relat5: %i[field_31],
+ relat6: %i[field_32],
+ relat7: %i[field_33],
+ relat8: %i[field_34],
+
+ ecstat1: %i[field_35],
+ ecstat2: %i[field_36],
+ ecstat3: %i[field_37],
+ ecstat4: %i[field_38],
+ ecstat5: %i[field_39],
+ ecstat6: %i[field_40],
+ ecstat7: %i[field_41],
+ ecstat8: %i[field_42],
+
+ armedforces: %i[field_45],
+ leftreg: %i[field_114],
+ reservist: %i[field_46],
+
+ preg_occ: %i[field_47],
+
+ housingneeds: %i[field_47],
+
+ illness: %i[field_118],
+
+ layear: %i[field_66],
+ waityear: %i[field_67],
+ reason: %i[field_52],
+ reasonother: %i[field_53],
+ prevten: %i[field_61],
+ homeless: %i[field_68],
+
+ prevloc: %i[field_62],
+ previous_la_known: %i[field_62],
+ ppcodenk: %i[field_65],
+ ppostcode_full: %i[field_63 field_64],
+
+ reasonpref: %i[field_69],
+ rp_homeless: %i[field_70],
+ rp_insan_unsat: %i[field_71],
+ rp_medwel: %i[field_72],
+ rp_hardship: %i[field_73],
+ rp_dontknow: %i[field_74],
+
+ cbl: %i[field_75],
+ chr: %i[field_76],
+ cap: %i[field_77],
+
+ referral: %i[field_78],
+
+ net_income_known: %i[field_51],
+ earnings: %i[field_50],
+ incfreq: %i[field_116],
+ hb: %i[field_48],
+ benefits: %i[field_49],
+
+ period: %i[field_79],
+ brent: %i[field_80],
+ scharge: %i[field_81],
+ pscharge: %i[field_82],
+ supcharg: %i[field_83],
+ tcharge: %i[field_84],
+ chcharge: %i[field_85],
+ household_charge: %i[field_86],
+ hbrentshortfall: %i[field_87],
+ tshortfall: %i[field_88],
+
+ unitletas: %i[field_105],
+ rsnvac: %i[field_106],
+ sheltered: %i[field_117],
+
+ illness_type_1: %i[field_119],
+ illness_type_2: %i[field_120],
+ illness_type_3: %i[field_121],
+ illness_type_4: %i[field_122],
+ illness_type_5: %i[field_123],
+ illness_type_6: %i[field_124],
+ illness_type_7: %i[field_125],
+ illness_type_8: %i[field_126],
+ illness_type_9: %i[field_127],
+ illness_type_10: %i[field_128],
+
+ irproduct_other: %i[field_131],
+
+ offered: %i[field_99],
+
+ propcode: %i[field_100],
+
+ majorrepairs: %i[field_92 field_93 field_94],
+ mrcdate: %i[field_92 field_93 field_94],
+
+ voiddate: %i[field_89 field_90 field_91],
+ }
+ end
+
+ def startdate
+ Date.new(field_98 + 2000, field_97, field_96) if field_98.present? && field_97.present? && field_96.present?
+ end
+
+ def renttype
+ case field_1
+ when 1, 2, 3, 4
+ :social
+ when 5, 6, 7, 8
+ :affordable
+ when 9, 10, 11, 12
+ :intermediate
+ end
+ end
+
+ def rent_type
+ case renttype
+ when :social
+ Imports::LettingsLogsImportService::RENT_TYPE[:social_rent]
+ when :affordable
+ if field_129 == 1
+ Imports::LettingsLogsImportService::RENT_TYPE[:london_affordable_rent]
+ else
+ Imports::LettingsLogsImportService::RENT_TYPE[:affordable_rent]
+ end
+ when :intermediate
+ case field_130
+ when 1
+ Imports::LettingsLogsImportService::RENT_TYPE[:rent_to_buy]
+ when 2
+ Imports::LettingsLogsImportService::RENT_TYPE[:london_living_rent]
+ when 3
+ Imports::LettingsLogsImportService::RENT_TYPE[:other_intermediate_rent_product]
+ end
+ end
+ end
+
+ def owning_organisation_id
+ Organisation.find_by(old_visible_id: field_111)&.id
+ end
+
+ def managing_organisation_id
+ Organisation.find_by(old_visible_id: field_113)&.id
+ end
+
+ def attributes_for_log
+ attributes = {}
+
+ attributes["lettype"] = field_1
+ attributes["tenancycode"] = field_7
+ attributes["la"] = field_107
+ attributes["postcode_known"] = postcode_known
+ attributes["postcode_full"] = postcode_full
+ attributes["owning_organisation_id"] = owning_organisation_id
+ attributes["managing_organisation_id"] = managing_organisation_id
+ attributes["renewal"] = renewal
+ attributes["scheme"] = scheme
+ attributes["created_by"] = bulk_upload.user
+ attributes["needstype"] = bulk_upload.needstype
+ attributes["rent_type"] = rent_type
+ attributes["startdate"] = startdate
+ attributes["unittype_gn"] = field_102
+ attributes["builtype"] = field_103
+ attributes["wchair"] = field_104
+ attributes["beds"] = field_101
+ attributes["joint"] = field_133
+ attributes["startertenancy"] = field_8
+ attributes["tenancy"] = field_9
+ attributes["tenancyother"] = field_10
+ attributes["tenancylength"] = field_11
+ attributes["declaration"] = field_132
+
+ attributes["age1_known"] = field_12.present? ? 0 : 1
+ attributes["age1"] = field_12
+ attributes["age2_known"] = field_13.present? ? 0 : 1
+ attributes["age2"] = field_13
+ attributes["age3_known"] = field_14.present? ? 0 : 1
+ attributes["age3"] = field_14
+ attributes["age4_known"] = field_15.present? ? 0 : 1
+ attributes["age4"] = field_15
+ attributes["age5_known"] = field_16.present? ? 0 : 1
+ attributes["age5"] = field_16
+ attributes["age6_known"] = field_17.present? ? 0 : 1
+ attributes["age6"] = field_17
+ attributes["age7_known"] = field_18.present? ? 0 : 1
+ attributes["age7"] = field_18
+ attributes["age8_known"] = field_19.present? ? 0 : 1
+ attributes["age8"] = field_19
+
+ attributes["sex1"] = field_20
+ attributes["sex2"] = field_21
+ attributes["sex3"] = field_22
+ attributes["sex4"] = field_23
+ attributes["sex5"] = field_24
+ attributes["sex6"] = field_25
+ attributes["sex7"] = field_26
+ attributes["sex8"] = field_27
+
+ attributes["ethnic_group"] = ethnic_group_from_ethnic
+ attributes["ethnic"] = field_43
+ attributes["national"] = field_44
+
+ attributes["relat2"] = field_28
+ attributes["relat3"] = field_29
+ attributes["relat4"] = field_30
+ attributes["relat5"] = field_31
+ attributes["relat6"] = field_32
+ attributes["relat7"] = field_33
+ attributes["relat8"] = field_34
+
+ attributes["ecstat1"] = field_35
+ attributes["ecstat2"] = field_36
+ attributes["ecstat3"] = field_37
+ attributes["ecstat4"] = field_38
+ attributes["ecstat5"] = field_39
+ attributes["ecstat6"] = field_40
+ attributes["ecstat7"] = field_41
+ attributes["ecstat8"] = field_42
+
+ attributes["details_known_2"] = details_known(2)
+ attributes["details_known_3"] = details_known(3)
+ attributes["details_known_4"] = details_known(4)
+ attributes["details_known_5"] = details_known(5)
+ attributes["details_known_6"] = details_known(6)
+ attributes["details_known_7"] = details_known(7)
+ attributes["details_known_8"] = details_known(8)
+
+ attributes["armedforces"] = field_45
+ attributes["leftreg"] = leftreg
+ attributes["reservist"] = field_46
+
+ attributes["preg_occ"] = field_47
+
+ attributes["housingneeds"] = housingneeds
+
+ attributes["illness"] = field_118
+
+ attributes["layear"] = field_66
+ attributes["waityear"] = field_67
+ attributes["reason"] = field_52
+ attributes["reasonother"] = field_53
+ attributes["prevten"] = field_61
+ attributes["homeless"] = homeless
+
+ attributes["prevloc"] = prevloc
+ attributes["previous_la_known"] = previous_la_known
+ attributes["ppcodenk"] = ppcodenk
+ attributes["ppostcode_full"] = ppostcode_full
+
+ attributes["reasonpref"] = field_69
+ attributes["rp_homeless"] = field_70
+ attributes["rp_insan_unsat"] = field_71
+ attributes["rp_medwel"] = field_72
+ attributes["rp_hardship"] = field_73
+ attributes["rp_dontknow"] = field_74
+
+ attributes["cbl"] = cbl
+ attributes["chr"] = chr
+ attributes["cap"] = cap
+ attributes["letting_allocation_unknown"] = letting_allocation_unknown
+
+ attributes["referral"] = field_78
+
+ attributes["net_income_known"] = net_income_known
+ attributes["earnings"] = earnings
+ attributes["incfreq"] = field_116
+ attributes["hb"] = field_48
+ attributes["benefits"] = field_49
+
+ attributes["period"] = field_79
+ attributes["brent"] = field_80
+ attributes["scharge"] = field_81
+ attributes["pscharge"] = field_82
+ attributes["supcharg"] = field_83
+ attributes["tcharge"] = field_84
+ attributes["chcharge"] = field_85
+ attributes["household_charge"] = field_86
+ attributes["hbrentshortfall"] = field_87
+ attributes["tshortfall_known"] = tshortfall_known
+ attributes["tshortfall"] = field_88
+
+ attributes["hhmemb"] = hhmemb
+
+ attributes["unitletas"] = field_105
+ attributes["rsnvac"] = rsnvac
+ attributes["sheltered"] = field_117
+
+ attributes["illness_type_1"] = field_119
+ attributes["illness_type_2"] = field_120
+ attributes["illness_type_3"] = field_121
+ attributes["illness_type_4"] = field_122
+ attributes["illness_type_5"] = field_123
+ attributes["illness_type_6"] = field_124
+ attributes["illness_type_7"] = field_125
+ attributes["illness_type_8"] = field_126
+ attributes["illness_type_9"] = field_127
+ attributes["illness_type_10"] = field_128
+
+ attributes["irproduct_other"] = field_131
+
+ attributes["offered"] = field_99
+
+ attributes["propcode"] = field_100
+
+ attributes["majorrepairs"] = majorrepairs
+
+ attributes["mrcdate"] = mrcdate
+
+ attributes["voiddate"] = voiddate
+
+ attributes["first_time_property_let_as_social_housing"] = first_time_property_let_as_social_housing
+
+ attributes
+ end
+
+ def first_time_property_let_as_social_housing
+ case rsnvac
+ when 15, 16, 17
+ 1
+ end
+ end
+
+ def rsnvac
+ field_106
+ end
+
+ def voiddate
+ Date.new(field_91 + 2000, field_90, field_89) if field_91.present? && field_90.present? && field_89.present?
+ end
+
+ def majorrepairs
+ mrcdate.present? ? 1 : 0
+ end
+
+ def mrcdate
+ Date.new(field_94 + 2000, field_93, field_92) if field_94.present? && field_93.present? && field_92.present?
+ end
+
+ def prevloc
+ field_62
+ end
+
+ def previous_la_known
+ prevloc.present? ? 1 : 0
+ end
+
+ def ppcodenk
+ case field_65
+ when 1
+ 1
+ when 2
+ 0
+ end
+ end
+
+ def earnings
+ field_50.round if field_50.present?
+ end
+
+ def net_income_known
+ case field_51
+ when 1
+ 0
+ when 2
+ 1
+ when 3
+ 1
+ when 4
+ 2
+ end
+ end
+
+ def leftreg
+ case field_114
+ when 3
+ 3
+ when 4
+ 1
+ when 5
+ 2
+ when 6
+ 0
+ end
+ end
+
+ def homeless
+ case field_68
+ when 1
+ 1
+ when 12
+ 11
+ end
+ end
+
+ def renewal
+ case field_134
+ when 1
+ 1
+ when 2
+ 0
+ when nil
+ field_116 == 14 ? 1 : 0
+ end
+ end
+
+ def details_known(person_n)
+ send("person_#{person_n}_present?") ? 0 : 1
+ end
+
+ def hhmemb
+ [
+ person_2_present?,
+ person_3_present?,
+ person_4_present?,
+ person_5_present?,
+ person_6_present?,
+ person_7_present?,
+ person_8_present?,
+ ].count(true) + 1
+ end
+
+ def person_2_present?
+ field_13.present? && field_21.present? && field_28.present?
+ end
+
+ def person_3_present?
+ field_14.present? && field_22.present? && field_29.present?
+ end
+
+ def person_4_present?
+ field_15.present? && field_23.present? && field_30.present?
+ end
+
+ def person_5_present?
+ field_16.present? && field_24.present? && field_31.present?
+ end
+
+ def person_6_present?
+ field_17.present? && field_25.present? && field_32.present?
+ end
+
+ def person_7_present?
+ field_18.present? && field_26.present? && field_33.present?
+ end
+
+ def person_8_present?
+ field_19.present? && field_27.present? && field_34.present?
+ end
+
+ def tshortfall_known
+ field_87 == 1 ? 0 : 1
+ end
+
+ def letting_allocation_unknown
+ [cbl, chr, cap].all?(0) ? 1 : 0
+ end
+
+ def cbl
+ case field_75
+ when 2
+ 0
+ when 1
+ 1
+ end
+ end
+
+ def chr
+ case field_76
+ when 2
+ 0
+ when 1
+ 1
+ end
+ end
+
+ def cap
+ case field_77
+ when 2
+ 0
+ when 1
+ 1
+ end
+ end
+
+ def ppostcode_full
+ "#{field_63} #{field_64}".strip.gsub(/\s+/, " ")
+ end
+
+ def housingneeds
+ if field_59 == 1
+ 1
+ elsif field_60 == 1
+ 3
+ else
+ 2
+ end
+ end
+
+ def ethnic_group_from_ethnic
+ return nil if field_43.blank?
+
+ case field_43
+ when 1, 2, 3, 18
+ 0
+ when 4, 5, 6, 7
+ 1
+ when 8, 9, 10, 11, 15
+ 2
+ when 12, 13, 14
+ 3
+ when 16, 19
+ 4
+ when 17
+ 17
+ end
+ end
+
+ def scheme
+ @scheme ||= Scheme.find_by(old_visible_id: field_4)
+ end
+end
diff --git a/app/services/bulk_upload/lettings/validator.rb b/app/services/bulk_upload/lettings/validator.rb
new file mode 100644
index 000000000..43fd17b7d
--- /dev/null
+++ b/app/services/bulk_upload/lettings/validator.rb
@@ -0,0 +1,256 @@
+require "csv"
+
+class BulkUpload::Lettings::Validator
+ include ActiveModel::Validations
+
+ QUESTIONS = {
+ field_1: "What is the letting type?",
+ field_2: "This question has been removed",
+ field_3: "This question has been removed",
+ field_4: "Management group code",
+ field_5: "Scheme code",
+ field_6: "This question has been removed",
+ field_7: "What is the tenant code?",
+ field_8: "Is this a starter tenancy?",
+ field_9: "What is the tenancy type?",
+ field_10: "If 'Other', what is the tenancy type?",
+ field_11: "What is the length of the fixed-term tenancy to the nearest year?",
+ field_12: "Age of Person 1",
+ field_13: "Age of Person 2",
+ field_14: "Age of Person 3",
+ field_15: "Age of Person 4",
+ field_16: "Age of Person 5",
+ field_17: "Age of Person 6",
+ field_18: "Age of Person 7",
+ field_19: "Age of Person 8",
+ field_20: "Gender identity of Person 1",
+ field_21: "Gender identity of Person 2",
+ field_22: "Gender identity of Person 3",
+ field_23: "Gender identity of Person 4",
+ field_24: "Gender identity of Person 5",
+ field_25: "Gender identity of Person 6",
+ field_26: "Gender identity of Person 7",
+ field_27: "Gender identity of Person 8",
+ field_28: "Relationship to Person 1 for Person 2",
+ field_29: "Relationship to Person 1 for Person 3",
+ field_30: "Relationship to Person 1 for Person 4",
+ field_31: "Relationship to Person 1 for Person 5",
+ field_32: "Relationship to Person 1 for Person 6",
+ field_33: "Relationship to Person 1 for Person 7",
+ field_34: "Relationship to Person 1 for Person 8",
+ field_35: "Working situation of Person 1",
+ field_36: "Working situation of Person 2",
+ field_37: "Working situation of Person 3",
+ field_38: "Working situation of Person 4",
+ field_39: "Working situation of Person 5",
+ field_40: "Working situation of Person 6",
+ field_41: "Working situation of Person 7",
+ field_42: "Working situation of Person 8",
+ field_43: "What is the lead tenant's ethnic group?",
+ field_44: "What is the lead tenant's nationality?",
+ field_45: "Does anybody in the household have links to the UK armed forces?",
+ field_46: "Was the person seriously injured or ill as a result of serving in the UK armed forces?",
+ field_47: "Is anybody in the household pregnant?",
+ field_48: "Is the tenant likely to be receiving benefits related to housing?",
+ field_49: "How much of the household's income is from Universal Credit, state pensions or benefits?",
+ field_50: "How much income does the household have in total?",
+ field_51: "Do you know the household's income?",
+ field_52: "What is the tenant's main reason for the household leaving their last settled home?",
+ field_53: "If 'Other', what was the main reason for leaving their last settled home?",
+ field_54: "This question has been removed",
+ field_55: "Does anybody in the household have any disabled access needs?",
+ field_56: "Does anybody in the household have any disabled access needs?",
+ field_57: "Does anybody in the household have any disabled access needs?",
+ field_58: "Does anybody in the household have any disabled access needs?",
+ field_59: "Does anybody in the household have any disabled access needs?",
+ field_60: "Does anybody in the household have any disabled access needs?",
+ field_61: "Where was the household immediately before this letting?",
+ field_62: "What is the local authority of the household's last settled home?",
+ field_63: "Part 1 of postcode of last settled home",
+ field_64: "Part 2 of postcode of last settled home",
+ field_65: "Do you know the postcode of last settled home?",
+ field_66: "How long has the household continuously lived in the local authority area of the new letting?",
+ field_67: "How long has the household been on the waiting list for the new letting?",
+ field_68: "Was the tenant homeless directly before this tenancy?",
+ field_69: "Was the household given 'reasonable preference' by the local authority?",
+ field_70: "Reasonable preference. They were homeless or about to lose their home (within 56 days)",
+ field_71: "Reasonable preference. They were living in insanitary, overcrowded or unsatisfactory housing",
+ field_72: "Reasonable preference. They needed to move on medical and welfare grounds (including a disability)",
+ field_73: "Reasonable preference. They needed to move to avoid hardship to themselves or others",
+ field_74: "Reasonable preference. Don't know",
+ field_75: "Was the letting made under any of the following allocations systems?",
+ field_76: "Was the letting made under any of the following allocations systems?",
+ field_77: "Was the letting made under any of the following allocations systems?",
+ field_78: "What was the source of referral for this letting?",
+ field_79: "How often does the household pay rent and other charges?",
+ field_80: "What is the basic rent?",
+ field_81: "What is the service charge?",
+ field_82: "What is the personal service charge?",
+ field_83: "What is the support charge?",
+ field_84: "Total Charge",
+ field_85: "If this is a care home, how much does the household pay every [time period]?",
+ field_86: "Does the household pay rent or other charges for the accommodation?",
+ field_87: "After the household has received any housing-related benefits, will they still need to pay basic rent and other charges?",
+ field_88: "What do you expect the outstanding amount to be?",
+ field_89: "What is the void or renewal date?",
+ field_90: "What is the void or renewal date?",
+ field_91: "What is the void or renewal date?",
+ field_92: "What date were major repairs completed on?",
+ field_93: "What date were major repairs completed on?",
+ field_94: "What date were major repairs completed on?",
+ field_95: "This question has been removed",
+ field_96: "What date did the tenancy start?",
+ field_97: "What date did the tenancy start?",
+ field_98: "What date did the tenancy start?",
+ field_99: "Since becoming available, how many times has the property been previously offered?",
+ field_100: "What is the property reference?",
+ field_101: "How many bedrooms does the property have?",
+ field_102: "What type of unit is the property?",
+ field_103: "Which type of building is the property?",
+ field_104: "Is the property built or adapted to wheelchair-user standards?",
+ field_105: "What type was the property most recently let as?",
+ field_106: "What is the reason for the property being vacant?",
+ field_107: "What is the local authority of the property?",
+ field_108: "Part 1 of postcode of the property",
+ field_109: "Part 2 of postcode of the property",
+ field_110: "This question has been removed",
+ field_111: "Which organisation owns this property?",
+ field_112: "Username field",
+ field_113: "Which organisation manages this property?",
+ field_114: "Is the person still serving in the UK armed forces?",
+ field_115: "This question has been removed",
+ field_116: "How often does the household receive income?",
+ field_117: "Is this letting sheltered accommodation?",
+ field_118: "Does anybody in the household have a physical or mental health condition (or other illness) expected to last for 12 months or more?",
+ field_119: "Vision, for example blindness or partial sight",
+ field_120: "Hearing, for example deafness or partial hearing",
+ field_121: "Mobility, for example walking short distances or climbing stairs",
+ field_122: "Dexterity, for example lifting and carrying objects, using a keyboard",
+ field_123: "Learning or understanding or concentrating",
+ field_124: "Memory",
+ field_125: "Mental health",
+ field_126: "Stamina or breathing or fatigue",
+ field_127: "Socially or behaviourally, for example associated with autism spectral disorder (ASD) which includes Aspergers' or attention deficit hyperactivity disorder (ADHD)",
+ field_128: "Other",
+ field_129: "Is this letting a London Affordable Rent letting?",
+ field_130: "Which type of Intermediate Rent is this letting?",
+ field_131: "Which 'Other' type of Intermediate Rent is this letting?",
+ field_132: "Data Protection",
+ field_133: "Is this a joint tenancy?",
+ field_134: "Is this letting a renewal?",
+ }.freeze
+
+ attr_reader :bulk_upload, :path
+
+ validate :validate_file_not_empty
+ validate :validate_max_columns
+
+ def initialize(bulk_upload:, path:)
+ @bulk_upload = bulk_upload
+ @path = path
+ end
+
+ def call
+ row_parsers.each_with_index do |row_parser, index|
+ row_parser.valid?
+
+ row = index + row_offset + 1
+
+ row_parser.errors.each do |error|
+ bulk_upload.bulk_upload_errors.create!(
+ field: error.attribute,
+ error: error.type,
+ tenant_code: row_parser.field_7,
+ property_ref: row_parser.field_100,
+ row:,
+ cell: "#{cols[field_number_for_attribute(error.attribute) - col_offset + 1]}#{row}",
+ )
+ end
+ end
+ end
+
+ def self.question_for_field(field)
+ QUESTIONS[field]
+ end
+
+private
+
+ def row_offset
+ 5
+ end
+
+ def col_offset
+ 1
+ end
+
+ def field_number_for_attribute(attribute)
+ attribute.to_s.split("_").last.to_i
+ end
+
+ def cols
+ @cols ||= ("A".."EE").to_a
+ end
+
+ def row_parsers
+ @row_parsers ||= body_rows.map do |row|
+ stripped_row = row[1..]
+ headers = ("field_1".."field_134").to_a
+ hash = Hash[headers.zip(stripped_row)]
+ hash[:bulk_upload] = bulk_upload
+
+ BulkUpload::Lettings::RowParser.new(hash)
+ end
+ end
+
+ # determine the row seperator from CSV
+ # Windows will use \r\n
+ def row_sep
+ contents = ""
+
+ File.open(path, "r") do |f|
+ f.seek(9900)
+ contents = f.read
+ end
+
+ rn_count = contents.scan("\r\n").count
+ n_count = contents.scan(/[^\r]\n/).count
+
+ if rn_count > n_count
+ "\r\n"
+ else
+ "\n"
+ end
+ end
+
+ def rows
+ @rows ||= CSV.read(path, row_sep:)
+ end
+
+ def body_rows
+ rows[row_offset..]
+ end
+
+ def validate_file_not_empty
+ if File.size(path).zero?
+ errors.add(:file, :blank)
+
+ halt_validations!
+ end
+ end
+
+ def validate_max_columns
+ return if halt_validations?
+
+ max_row_size = rows.map(&:size).max
+
+ errors.add(:file, :max_row_size) if max_row_size > 136
+ end
+
+ def halt_validations!
+ @halt_validations = true
+ end
+
+ def halt_validations?
+ @halt_validations ||= false
+ end
+end
diff --git a/app/services/bulk_upload/processor.rb b/app/services/bulk_upload/processor.rb
new file mode 100644
index 000000000..93d3fd3e7
--- /dev/null
+++ b/app/services/bulk_upload/processor.rb
@@ -0,0 +1,42 @@
+class BulkUpload::Processor
+ attr_reader :bulk_upload
+
+ def initialize(bulk_upload:)
+ @bulk_upload = bulk_upload
+ end
+
+ def call
+ download
+ validator.call
+ ensure
+ downloader.delete_local_file!
+ end
+
+private
+
+ def downloader
+ @downloader ||= BulkUpload::Downloader.new(bulk_upload:)
+ end
+
+ def download
+ downloader.call
+ end
+
+ def validator
+ @validator ||= validator_class.new(
+ bulk_upload:,
+ path: downloader.path,
+ )
+ end
+
+ def validator_class
+ case bulk_upload.log_type
+ when "lettings"
+ BulkUpload::Lettings::Validator
+ when "sales"
+ BulkUpload::Sales::Validator
+ else
+ raise "Validator not found for #{bulk_upload.log_type}"
+ end
+ end
+end
diff --git a/app/services/bulk_upload/sales/row_parser.rb b/app/services/bulk_upload/sales/row_parser.rb
new file mode 100644
index 000000000..f7b74dfe1
--- /dev/null
+++ b/app/services/bulk_upload/sales/row_parser.rb
@@ -0,0 +1,176 @@
+class BulkUpload::Sales::RowParser
+ include ActiveModel::Model
+ include ActiveModel::Attributes
+
+ attribute :field_1, :string
+ attribute :field_2, :integer
+ attribute :field_3, :integer
+ attribute :field_4, :integer
+ attribute :field_5
+ attribute :field_6, :integer
+ attribute :field_7, :integer
+ attribute :field_8, :integer
+ attribute :field_9, :integer
+ attribute :field_10, :integer
+ attribute :field_11, :integer
+ attribute :field_12, :integer
+ attribute :field_13, :string
+ attribute :field_14, :string
+ attribute :field_15, :string
+ attribute :field_16, :string
+ attribute :field_17, :string
+ attribute :field_18, :string
+ attribute :field_19, :string
+ attribute :field_20, :integer
+ attribute :field_21, :integer
+ attribute :field_22, :integer
+ attribute :field_23, :integer
+ attribute :field_24, :integer
+ attribute :field_25, :integer
+ attribute :field_26, :integer
+ attribute :field_27, :integer
+ attribute :field_28, :integer
+ attribute :field_29, :integer
+ attribute :field_30, :integer
+ attribute :field_31, :integer
+ attribute :field_32, :integer
+ attribute :field_33, :integer
+ attribute :field_34, :integer
+ attribute :field_35, :integer
+ attribute :field_36, :integer
+ attribute :field_37, :integer
+ attribute :field_38
+ attribute :field_39, :integer
+ attribute :field_40, :string
+ attribute :field_41, :string
+ attribute :field_42, :string
+ attribute :field_43, :integer
+ attribute :field_44, :integer
+ attribute :field_45, :integer
+ attribute :field_46, :integer
+ attribute :field_47, :integer
+ attribute :field_48, :integer
+ attribute :field_49, :integer
+ attribute :field_50, :integer
+ attribute :field_51, :integer
+ attribute :field_52, :integer
+ attribute :field_53, :string
+ attribute :field_54, :string
+ attribute :field_55, :string
+ attribute :field_56, :integer
+ attribute :field_57, :integer
+ attribute :field_58, :integer
+ attribute :field_59, :integer
+ attribute :field_60, :integer
+ attribute :field_61, :integer
+ attribute :field_62, :integer
+ attribute :field_63, :integer
+ attribute :field_64, :integer
+ attribute :field_65, :integer
+ attribute :field_66, :integer
+ attribute :field_67, :integer
+ attribute :field_68, :integer
+ attribute :field_69, :integer
+ attribute :field_70, :integer
+ attribute :field_71, :integer
+ attribute :field_72, :integer
+ attribute :field_73, :integer
+ attribute :field_74, :decimal
+ attribute :field_75, :decimal
+ attribute :field_76, :integer
+ attribute :field_77, :integer
+ attribute :field_78, :integer
+ attribute :field_79, :integer
+ attribute :field_80, :integer
+ attribute :field_81, :integer
+ attribute :field_82, :integer
+ attribute :field_83, :integer
+ attribute :field_84, :integer
+ attribute :field_85, :string
+ attribute :field_86
+ attribute :field_87, :integer
+ attribute :field_88, :integer
+ attribute :field_89, :integer
+ attribute :field_90, :integer
+ attribute :field_91, :integer
+ attribute :field_92, :integer
+ attribute :field_93, :string
+ attribute :field_94
+ attribute :field_95, :integer
+ attribute :field_96
+ attribute :field_97, :integer
+ attribute :field_98, :integer
+ attribute :field_99, :string
+ attribute :field_100, :integer
+ attribute :field_101, :string
+ attribute :field_102, :integer
+ attribute :field_103, :string
+ attribute :field_104, :integer
+ attribute :field_105, :integer
+ attribute :field_106, :integer
+ attribute :field_107, :integer
+ attribute :field_108, :integer
+ attribute :field_109, :integer
+ attribute :field_110, :integer
+ attribute :field_111, :integer
+ attribute :field_112, :integer
+ attribute :field_113, :integer
+ attribute :field_114, :integer
+ attribute :field_115, :integer
+ attribute :field_116, :integer
+ attribute :field_117, :integer
+ attribute :field_118, :integer
+ attribute :field_119, :integer
+ attribute :field_120, :integer
+ attribute :field_121, :integer
+ attribute :field_122, :integer
+ attribute :field_123, :integer
+ attribute :field_124, :integer
+ attribute :field_125, :integer
+
+ # validates :field_1, presence: true, numericality: { in: (1..12) }
+ # validates :field_4, numericality: { in: (1..999), allow_blank: true }
+ # validates :field_4, presence: true, if: :field_4_presence_check
+
+ validate :validate_possible_answers
+
+# delegate :valid?, to: :native_object
+# delegate :errors, to: :native_object
+
+private
+
+ def native_object
+ @native_object ||= SalesLog.new(attributes_for_log)
+ end
+
+ def field_mapping
+ {
+ field_117: :buy1livein,
+ }
+ end
+
+ def validate_possible_answers
+ field_mapping.each do |field, attribute|
+ possible_answers = FormHandler.instance.current_sales_form.questions.find { |q| q.id == attribute.to_s }.answer_options.keys
+
+ unless possible_answers.include?(public_send(field))
+ errors.add(field, "Value supplied is not one of the permitted values")
+ end
+ end
+ end
+
+ def attributes_for_log
+ hash = field_mapping.invert
+ attributes = {}
+
+ hash.map do |k, v|
+ attributes[k] = public_send(v)
+ end
+
+ attributes
+ end
+
+ # def field_4_presence_check
+ # [1, 3, 5, 7, 9, 11].include?(field_1)
+ # end
+end
diff --git a/app/services/bulk_upload/sales/validator.rb b/app/services/bulk_upload/sales/validator.rb
new file mode 100644
index 000000000..43b8c001d
--- /dev/null
+++ b/app/services/bulk_upload/sales/validator.rb
@@ -0,0 +1,228 @@
+class BulkUpload::Sales::Validator
+ include ActiveModel::Validations
+
+ QUESTIONS = {
+ field_1: "What is the purchaser code?",
+ field_2: "What is the day of the sale completion date? - DD",
+ field_3: "What is the month of the sale completion date? - MM",
+ field_4: "What is the year of the sale completion date? - YY",
+ field_5: "This question has been removed",
+ field_6: "Was the buyer interviewed for any of the answers you will provide on this log?",
+ field_7: "Age of Buyer 1",
+ field_8: "Age of Person 2",
+ field_9: "Age of Person 3",
+ field_10: "Age of Person 4",
+ field_11: "Age of Person 5",
+ field_12: "Age of Person 6",
+ field_13: "Gender identity of Buyer 1",
+ field_14: "Gender identity of Person 2",
+ field_15: "Gender identity of Person 3",
+ field_16: "Gender identity of Person 4",
+ field_17: "Gender identity of Person 5",
+ field_18: "Gender identity of Person 6",
+ field_19: "Relationship to Buyer 1 for Person 2",
+ field_20: "Relationship to Buyer 1 for Person 3",
+ field_21: "Relationship to Buyer 1 for Person 4",
+ field_22: "Relationship to Buyer 1 for Person 5",
+ field_23: "Relationship to Buyer 1 for Person 6",
+ field_24: "Working situation of Buyer 1",
+ field_25: "Working situation of Person 2",
+ field_26: "Working situation of Person 3",
+ field_27: "Working situation of Person 4",
+ field_28: "Working situation of Person 5",
+ field_29: "Working situation of Person 6",
+ field_30: "What is buyer 1's ethnic group?",
+ field_31: "What is buyer 1's nationality?",
+ field_32: "What is buyer 1's gross annual income?",
+ field_33: "What is buyer 2's gross annual income?",
+ field_34: "Was buyer 1's income used for a mortgage application?",
+ field_35: "Was buyer 2's income used for a mortgage application?",
+ field_36: "What is the total amount the buyers had in savings before they paid any deposit for the property?",
+ field_37: "Have any of the purchasers previously owned a property?",
+ field_38: "This question has been removed",
+ field_39: "What was buyer 1's previous tenure?",
+ field_40: "What is the local authority of buyer 1's last settled home?",
+ field_41: "Part 1 of postcode of buyer 1's last settled home",
+ field_42: "Part 2 of postcode of buyer 1's last settled home",
+ field_43: "Do you know the postcode of buyer 1's last settled home?",
+ field_44: "Was the buyer registered with their PRP (HA)?",
+ field_45: "Was the buyer registered with the local authority?",
+ field_46: "Was the buyer registered with a Help to Buy agent?",
+ field_47: "Was the buyer registered with another PRP (HA)?",
+ field_48: "Does anyone in the household consider themselves to have a disability?",
+ field_49: "Does anyone in the household use a wheelchair?",
+ field_50: "How many bedrooms does the property have?",
+ field_51: "What type of unit is the property?",
+ field_52: "Which type of bulding is the property?",
+ field_53: "What is the local authority of the property?",
+ field_54: "Part 1 of postcode of property",
+ field_55: "Part 2 of postcode of property",
+ field_56: "Is the property built or adapted to wheelchair user standards?",
+ field_57: "What is the type of shared ownership sale?",
+ field_58: "Is this a resale?",
+ field_59: "What is the day of the practical completion or handover date?",
+ field_60: "What is the month of the practical completion or handover date?",
+ field_61: "What is the day of the exchange of contracts date?",
+ field_62: "What is the day of the practical completion or handover date?",
+ field_63: "What is the month of the practical completion or handover date?",
+ field_64: "What is the year of the practical completion or handover date?",
+ field_65: "Was the household re-housed under a local authority nominations agreement?",
+ field_66: "How many bedrooms did the buyer's previous property have?",
+ field_67: "What was the type of the buyer's previous property?",
+ field_68: "What was the full purchase price?",
+ field_69: "What was the initial percentage equity stake purchased?",
+ field_70: "What is the mortgage amount?",
+ field_71: "Does this include any extra borrowing?",
+ field_72: "How much was the cash deposit paid on the property?",
+ field_73: "How much cash discount was given through Social Homebuy?",
+ field_74: "What is the basic monthly rent?",
+ field_75: "What are the total monthly leasehold charges for the property?",
+ field_76: "What is the type of discounted ownership sale?",
+ field_77: "What was the full purchase price?",
+ field_78: "What was the amount of any loan, grant, discount or subsidy given?",
+ field_79: "What was the percentage discount?",
+ field_80: "What is the mortgage amount?",
+ field_81: "Does this include any extra borrowing?",
+ field_82: "How much was the cash deposit paid on the property?",
+ field_83: "What are the total monthly leasehold charges for the property?",
+ field_84: "What is the type of outright sale?",
+ field_85: "If 'other', what is the 'other' type?",
+ field_86: "This question has been removed",
+ field_87: "What is the full purchase price?",
+ field_88: "What is the mortgage amount?",
+ field_89: "Does this include any extra borrowing?",
+ field_90: "How much was the cash deposit paid on the property?",
+ field_91: "What are the total monthly leasehold charges for the property?",
+ field_92: "Which organisation owned this property before the sale?",
+ field_93: "Username",
+ field_94: "This question has been removed",
+ field_95: "Has the buyer ever served in the UK Armed Forces and for how long?",
+ field_96: "This question has been removed",
+ field_97: "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?",
+ field_98: "What is the name of the mortgage lender? - Shared ownership",
+ field_99: "If 'other', what is the name of the mortgage lender?",
+ field_100: "What is the name of the mortgage lender? - Discounted ownership",
+ field_101: "If 'other', what is the name of the mortgage lender?",
+ field_102: "What is the name of the mortgage lender? - Outright sale",
+ field_103: "If 'other', what is the name of the mortgage lender?",
+ field_104: "Were the buyers receiving any of these housing-related benefits immediately before buying this property?",
+ field_105: "What is the length of the mortgage in years? - Shared ownership",
+ field_106: "What is the length of the mortgage in years? - Discounted ownership",
+ field_107: "What is the length of the mortgage in years? - Outright sale",
+ field_108: "How long have the buyers been living in the property before the purchase? - Discounted ownership",
+ field_109: "Are there more than two joint purchasers of this property?",
+ field_110: "How long have the buyers been living in the property before the purchase? - Shared ownership",
+ field_111: "Is this a staircasing transaction?",
+ field_112: "Data Protection question",
+ field_113: "Was this purchase made through an ownership scheme?",
+ field_114: "Is the buyer a company?",
+ field_115: "Will the buyers live in the property?",
+ field_116: "Is this a joint purchase?",
+ field_117: "Will buyer 1 live in the property?",
+ field_118: "Will buyer 2 live in the property?",
+ field_119: "Besides the buyers, how many people will live in the property?",
+ field_120: "What percentage of the property has been bought in this staircasing transaction?",
+ field_121: "What percentage of the property does the buyer now own in total?",
+ field_122: "What was the rent type of the buyer's previous property?",
+ field_123: "Was a mortgage used for the purchase of this property? - Shared ownership",
+ field_124: "Was a mortgage used for the purchase of this property? - Discounted ownership",
+ field_125: "Was a mortgage used for the purchase of this property? - Outright sale",
+ }.freeze
+
+ def self.question_for_field(field)
+ QUESTIONS[field]
+ end
+
+ attr_reader :bulk_upload, :path
+
+ validate :validate_file_not_empty
+ validate :validate_max_columns
+
+ def initialize(bulk_upload:, path:)
+ @bulk_upload = bulk_upload
+ @path = path
+ end
+
+ def call
+ row_parsers.each_with_index do |row_parser, index|
+ row_parser.valid?
+
+ row = index + row_offset + 1
+
+ row_parser.errors.each do |error|
+ bulk_upload.bulk_upload_errors.create!(
+ field: error.attribute,
+ error: error.type,
+ purchaser_code: row_parser.field_1,
+ row:,
+ cell: "#{cols[field_number_for_attribute(error.attribute) + col_offset - 1]}#{row}",
+ )
+ end
+ end
+ end
+
+private
+
+ def field_number_for_attribute(attribute)
+ attribute.to_s.split("_").last.to_i
+ end
+
+ def rows
+ @rows ||= CSV.read(path, row_sep:)
+ end
+
+ def body_rows
+ rows[row_offset..]
+ end
+
+ def row_offset
+ 5
+ end
+
+ def col_offset
+ 1
+ end
+
+ def cols
+ @cols ||= ("A".."DV").to_a
+ end
+
+ def row_parsers
+ @row_parsers ||= body_rows.map do |row|
+ stripped_row = row[col_offset..]
+ headers = ("field_1".."field_125").to_a
+ hash = Hash[headers.zip(stripped_row)]
+
+ BulkUpload::Sales::RowParser.new(hash)
+ end
+ end
+
+ def row_sep
+ "\r\n"
+ # "\n"
+ end
+
+ def validate_file_not_empty
+ if File.size(path).zero?
+ errors.add(:file, :blank)
+
+ halt_validations!
+ end
+ end
+
+ def validate_max_columns
+ return if halt_validations?
+
+ max_row_size = rows.map(&:size).max
+
+ errors.add(:file, :max_row_size) if max_row_size > 126
+ end
+
+ def halt_validations!
+ @halt_validations = true
+ end
+
+ def halt_validations?
+ @halt_validations ||= false
+ end
+end
diff --git a/app/services/imports/lettings_logs_import_service.rb b/app/services/imports/lettings_logs_import_service.rb
index 1d5ddfca3..8fe71d3dc 100644
--- a/app/services/imports/lettings_logs_import_service.rb
+++ b/app/services/imports/lettings_logs_import_service.rb
@@ -126,7 +126,6 @@ module Imports
(1..10).each do |index|
attributes["illness_type_#{index}"] = illness_type(xml_doc, index, attributes["illness"])
end
- attributes["illness_type_0"] = 1 if (1..10).all? { |idx| attributes["illness_type_#{idx}"].nil? || attributes["illness_type_#{idx}"].zero? }
attributes["prevten"] = unsafe_string_as_integer(xml_doc, "Q11")
attributes["prevloc"] = string_or_nil(xml_doc, "Q12aONS")
diff --git a/app/services/storage/local_disk_service.rb b/app/services/storage/local_disk_service.rb
new file mode 100644
index 000000000..f0cc358d1
--- /dev/null
+++ b/app/services/storage/local_disk_service.rb
@@ -0,0 +1,26 @@
+require "fileutils"
+
+module Storage
+ class LocalDiskService < StorageService
+ def list_files(folder = "/")
+ path = Rails.root.join("tmp/storage", folder)
+ Dir.entries(path)
+ end
+
+ def get_file_io(filename)
+ path = Rails.root.join("tmp/storage", filename)
+
+ File.open(path, "r")
+ end
+
+ def write_file(filename, data)
+ path = Rails.root.join("tmp/storage", filename)
+
+ FileUtils.mkdir_p(path.dirname)
+
+ File.open(path, "w") do |f|
+ f.write data
+ end
+ end
+ end
+end
diff --git a/app/views/bulk_upload_lettings_results/show.html.erb b/app/views/bulk_upload_lettings_results/show.html.erb
new file mode 100644
index 000000000..452926787
--- /dev/null
+++ b/app/views/bulk_upload_lettings_results/show.html.erb
@@ -0,0 +1,20 @@
+
+
+
Bulk Upload for lettings (<%= @bulk_upload.year_combo %>)
+
We found <%= pluralize(@bulk_upload.bulk_upload_errors.count, "error") %> in your file
+
+
+ Here’s a list of everything that you need to fix your spreadsheet. You can download the specification to help you fix the cells in your CSV file.
+
+
+
<%= @bulk_upload.filename %>
+
+
+
+
+
+ <% @bulk_upload.bulk_upload_errors.group_by(&:row).each do |_row, errors_for_row| %>
+ <%= render BulkUploadErrorRowComponent.new(bulk_upload_errors: errors_for_row) %>
+ <% end %>
+
+
diff --git a/app/views/bulk_upload_sales_results/show.html.erb b/app/views/bulk_upload_sales_results/show.html.erb
new file mode 100644
index 000000000..aacc80f9c
--- /dev/null
+++ b/app/views/bulk_upload_sales_results/show.html.erb
@@ -0,0 +1,20 @@
+
+
+
Bulk Upload for sales (<%= @bulk_upload.year_combo %>)
+
We found <%= pluralize(@bulk_upload.bulk_upload_errors.count, "error") %> in your file
+
+
+ Here’s a list of everything that you need to fix your spreadsheet. You can download the specification to help you fix the cells in your CSV file.
+
+
+
<%= @bulk_upload.filename %>
+
+
+
+
+
+ <% @bulk_upload.bulk_upload_errors.group_by(&:row).each do |_row, errors_for_row| %>
+ <%= render BulkUploadErrorRowComponent.new(bulk_upload_errors: errors_for_row) %>
+ <% end %>
+
+
diff --git a/app/views/form/guidance/_mortgage_lender.html.erb b/app/views/form/guidance/_mortgage_lender.html.erb
new file mode 100644
index 000000000..7991182ed
--- /dev/null
+++ b/app/views/form/guidance/_mortgage_lender.html.erb
@@ -0,0 +1,7 @@
+<%= govuk_details(summary_text: "Can’t find the mortgage lender you’re looking for?") do %>
+
+ - Double check the spelling and try again
+ - Type the first few letters to see the suggestions
+ - Type Other and continue - we’ll ask you to type in your answer in the next question
+
+<% end %>
diff --git a/app/views/logs/_log_filters.erb b/app/views/logs/_log_filters.erb
index 9defa0c84..d2a327d99 100644
--- a/app/views/logs/_log_filters.erb
+++ b/app/views/logs/_log_filters.erb
@@ -10,7 +10,7 @@
<%= render partial: "filters/checkbox_filter", locals: { f: f, options: years, label: "Collection year", category: "years" } %>
<%= render partial: "filters/checkbox_filter", locals: { f: f, options: status_filters, label: "Status", category: "status" } %>
<%= render partial: "filters/radio_filter", locals: { f: f, options: all_or_yours, label: "Logs", category: "user", } %>
- <% if @current_user.support? && request.path == "/lettings-logs" %>
+ <% if (@current_user.support? || @current_user.organisation.has_managing_agents?) && request.path == "/lettings-logs" %>
<%= render partial: "filters/radio_filter", locals: {
f: f,
options: {
@@ -21,7 +21,7 @@
type: "select",
label: "Organisation",
category: "organisation",
- options: [OpenStruct.new(id: "", name: "Select an option")] + Organisation.all.map { |org| OpenStruct.new(id: org.id, name: org.name) }
+ options: organisations_filter_options(@current_user)
}
}
},
diff --git a/config/environments/development.rb b/config/environments/development.rb
index f39f4d5be..24155edfa 100644
--- a/config/environments/development.rb
+++ b/config/environments/development.rb
@@ -83,4 +83,6 @@ Rails.application.configure do
# see https://discuss.rubyonrails.org/t/cve-2022-32224-possible-rce-escalation-bug-with-serialized-columns-in-active-record/81017
config.active_record.yaml_column_permitted_classes = [Time]
+
+ config.active_job.queue_adapter = :inline
end
diff --git a/config/environments/test.rb b/config/environments/test.rb
index 2af4affe7..dca19f3d1 100644
--- a/config/environments/test.rb
+++ b/config/environments/test.rb
@@ -65,4 +65,6 @@ Rails.application.configure do
# see https://discuss.rubyonrails.org/t/cve-2022-32224-possible-rce-escalation-bug-with-serialized-columns-in-active-record/81017
config.active_record.yaml_column_permitted_classes = [Time]
+
+ config.active_job.queue_adapter = :test
end
diff --git a/config/forms/2021_2022.json b/config/forms/2021_2022.json
index 92d495f24..3e009fb64 100644
--- a/config/forms/2021_2022.json
+++ b/config/forms/2021_2022.json
@@ -758,14 +758,6 @@
"renewal": 0,
"rsnvac": 13
},
- {
- "renewal": 0,
- "rsnvac": 16
- },
- {
- "renewal": 0,
- "rsnvac": 17
- },
{
"renewal": 0,
"rsnvac": 18
@@ -827,6 +819,14 @@
{
"renewal": 0,
"rsnvac": 15
+ },
+ {
+ "renewal": 0,
+ "rsnvac": 16
+ },
+ {
+ "renewal": 0,
+ "rsnvac": 17
}
]
},
@@ -893,14 +893,6 @@
"renewal": 0,
"rsnvac": 13
},
- {
- "renewal": 0,
- "rsnvac": 16
- },
- {
- "renewal": 0,
- "rsnvac": 17
- },
{
"renewal": 0,
"rsnvac": 18
@@ -6047,9 +6039,6 @@
},
"illness_type_10": {
"value": "Other"
- },
- "illness_type_0": {
- "value": "Tenant prefers not to say"
}
}
}
@@ -6258,6 +6247,9 @@
"20": {
"value": "Other"
},
+ "47": {
+ "value":"Tenant prefers not to say"
+ },
"divider": {
"value": true
},
diff --git a/config/forms/2022_2023.json b/config/forms/2022_2023.json
index f49070bbf..2edc3e58f 100644
--- a/config/forms/2022_2023.json
+++ b/config/forms/2022_2023.json
@@ -758,14 +758,6 @@
"renewal": 0,
"rsnvac": 13
},
- {
- "renewal": 0,
- "rsnvac": 16
- },
- {
- "renewal": 0,
- "rsnvac": 17
- },
{
"renewal": 0,
"rsnvac": 18
@@ -827,6 +819,14 @@
{
"renewal": 0,
"rsnvac": 15
+ },
+ {
+ "renewal": 0,
+ "rsnvac": 16
+ },
+ {
+ "renewal": 0,
+ "rsnvac": 17
}
]
},
@@ -893,14 +893,6 @@
"renewal": 0,
"rsnvac": 13
},
- {
- "renewal": 0,
- "rsnvac": 16
- },
- {
- "renewal": 0,
- "rsnvac": 17
- },
{
"renewal": 0,
"rsnvac": 18
@@ -6049,9 +6041,6 @@
},
"illness_type_10": {
"value": "Other"
- },
- "illness_type_0": {
- "value": "Tenant prefers not to say"
}
}
}
@@ -6257,6 +6246,9 @@
"20": {
"value": "Other"
},
+ "47": {
+ "value":"Tenant prefers not to say"
+ },
"divider": {
"value": true
},
@@ -6329,11 +6321,14 @@
"33": {
"value": "Lifetime private registered provider (PRP) general needs tenancy"
},
- "8": {
- "value": "Sheltered accommodation"
+ "34": {
+ "value": "Specialist retirement housing"
+ },
+ "35": {
+ "value": "Extra care housing"
},
"6": {
- "value": "Supported housing"
+ "value": "Other supported housing"
},
"3": {
"value": "Private sector tenancy"
@@ -6405,11 +6400,14 @@
"hint_text": "",
"type": "radio",
"answer_options": {
- "8": {
- "value": "Sheltered accommodation"
+ "34": {
+ "value": "Specialist retirement housing"
+ },
+ "35": {
+ "value": "Extra care housing"
},
"6": {
- "value": "Supported housing"
+ "value": "Other supported housing"
}
}
}
diff --git a/config/initializers/feature_toggle.rb b/config/initializers/feature_toggle.rb
index 6097caeb5..7a1d8ae23 100644
--- a/config/initializers/feature_toggle.rb
+++ b/config/initializers/feature_toggle.rb
@@ -30,4 +30,8 @@ class FeatureToggle
def self.upload_enabled?
!Rails.env.development?
end
+
+ def self.validate_valid_radio_options?
+ !(Rails.env.production? || Rails.env.staging?)
+ end
end
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 2c1b64791..2bc894b0d 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -128,6 +128,7 @@ en:
blank: "You must choose a managing agent"
already_added: "You have already added this managing agent"
not_answered: "You must answer %{question}"
+ invalid_option: "Enter a valid value for %{question}"
other_field_missing: "If %{main_field_label} is other then %{other_field_label} must be provided"
other_field_not_required: "%{other_field_label} must not be provided if %{main_field_label} was not other"
@@ -373,8 +374,6 @@ en:
owning_organisation:
does_not_own_stock: "Enter an organisation that owns housing stock"
-
-
location:
postcode_blank: "Enter a postcode"
units: "The units at this location must be a number"
diff --git a/config/routes.rb b/config/routes.rb
index eef759e92..4e5b224c1 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -123,15 +123,19 @@ Rails.application.routes.draw do
collection do
post "bulk-upload", to: "bulk_upload#bulk_upload"
get "bulk-upload", to: "bulk_upload#show"
+
get "csv-download", to: "lettings_logs#download_csv"
post "email-csv", to: "lettings_logs#email_csv"
get "csv-confirmation", to: "lettings_logs#csv_confirmation"
- resources :bulk_upload_lettings_logs, path: "bulk-upload-logs" do
+ resources :bulk_upload_lettings_logs, path: "bulk-upload-logs", only: %i[show update] do
collection do
get :start
end
end
+
+ resources :bulk_upload_lettings_results, path: "bulk-upload-results", only: [:show]
+
get "update-logs", to: "lettings_logs#update_logs"
end
@@ -158,6 +162,8 @@ Rails.application.routes.draw do
get :start
end
end
+
+ resources :bulk_upload_sales_results, path: "bulk-upload-results", only: [:show]
end
FormHandler.instance.sales_forms.each do |_key, form|
diff --git a/db/migrate/20221209161927_create_bulk_upload_errors.rb b/db/migrate/20221209161927_create_bulk_upload_errors.rb
new file mode 100644
index 000000000..ae72298e9
--- /dev/null
+++ b/db/migrate/20221209161927_create_bulk_upload_errors.rb
@@ -0,0 +1,19 @@
+class CreateBulkUploadErrors < ActiveRecord::Migration[7.0]
+ def change
+ create_table :bulk_upload_errors do |t|
+ t.references :bulk_upload
+
+ t.text :cell
+ t.text :row
+
+ t.text :tenant_code
+ t.text :property_ref
+ t.text :purchase_code
+
+ t.text :field
+ t.text :error
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20230103100531_rename_purchaser_code.rb b/db/migrate/20230103100531_rename_purchaser_code.rb
new file mode 100644
index 000000000..d6da4b67c
--- /dev/null
+++ b/db/migrate/20230103100531_rename_purchaser_code.rb
@@ -0,0 +1,5 @@
+class RenamePurchaserCode < ActiveRecord::Migration[7.0]
+ def change
+ rename_column :bulk_upload_errors, :purchase_code, :purchaser_code
+ end
+end
diff --git a/db/migrate/20230109124623_add_fromprop_to_sales.rb b/db/migrate/20230109124623_add_fromprop_to_sales.rb
new file mode 100644
index 000000000..db18b5e12
--- /dev/null
+++ b/db/migrate/20230109124623_add_fromprop_to_sales.rb
@@ -0,0 +1,7 @@
+class AddFrompropToSales < ActiveRecord::Migration[7.0]
+ def change
+ change_table :sales_logs, bulk: true do |t|
+ t.column :fromprop, :integer
+ end
+ end
+end
diff --git a/db/migrate/20230109140532_add_previous_tenure_to_sales.rb b/db/migrate/20230109140532_add_previous_tenure_to_sales.rb
new file mode 100644
index 000000000..bf02a9efc
--- /dev/null
+++ b/db/migrate/20230109140532_add_previous_tenure_to_sales.rb
@@ -0,0 +1,7 @@
+class AddPreviousTenureToSales < ActiveRecord::Migration[7.0]
+ def change
+ change_table :sales_logs, bulk: true do |t|
+ t.column :socprevten, :integer
+ end
+ end
+end
diff --git a/db/migrate/20230109144039_add_mortgage_lender.rb b/db/migrate/20230109144039_add_mortgage_lender.rb
new file mode 100644
index 000000000..7e5b63d92
--- /dev/null
+++ b/db/migrate/20230109144039_add_mortgage_lender.rb
@@ -0,0 +1,8 @@
+class AddMortgageLender < ActiveRecord::Migration[7.0]
+ def change
+ change_table :sales_logs, bulk: true do |t|
+ t.column :mortgagelender, :integer
+ t.column :mortgagelenderother, :string
+ end
+ end
+end
diff --git a/db/migrate/20230112093524_remove_illness_type0.rb b/db/migrate/20230112093524_remove_illness_type0.rb
new file mode 100644
index 000000000..bf8d981f7
--- /dev/null
+++ b/db/migrate/20230112093524_remove_illness_type0.rb
@@ -0,0 +1,5 @@
+class RemoveIllnessType0 < ActiveRecord::Migration[7.0]
+ def change
+ remove_column :lettings_logs, :illness_type_0, :integer
+ end
+end
diff --git a/db/migrate/20230113125117_add_postcode_fields_to_sales.rb b/db/migrate/20230113125117_add_postcode_fields_to_sales.rb
new file mode 100644
index 000000000..0de137326
--- /dev/null
+++ b/db/migrate/20230113125117_add_postcode_fields_to_sales.rb
@@ -0,0 +1,11 @@
+class AddPostcodeFieldsToSales < ActiveRecord::Migration[7.0]
+ def change
+ change_table :sales_logs, bulk: true do |t|
+ t.column :pcode1, :string
+ t.column :pcode2, :string
+ t.column :pcodenk, :integer
+ t.column :postcode_full, :string
+ t.column :is_la_inferred, :boolean
+ end
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 8659c061c..87f656bc7 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -10,10 +10,24 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema[7.0].define(version: 2023_01_09_170748) do
+ActiveRecord::Schema[7.0].define(version: 2023_01_13_125117) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
+ create_table "bulk_upload_errors", force: :cascade do |t|
+ t.bigint "bulk_upload_id"
+ t.text "cell"
+ t.text "row"
+ t.text "tenant_code"
+ t.text "property_ref"
+ t.text "purchaser_code"
+ t.text "field"
+ t.text "error"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.index ["bulk_upload_id"], name: "index_bulk_upload_errors_on_bulk_upload_id"
+ end
+
create_table "bulk_uploads", force: :cascade do |t|
t.bigint "user_id"
t.text "log_type", null: false
@@ -236,7 +250,6 @@ ActiveRecord::Schema[7.0].define(version: 2023_01_09_170748) do
t.string "old_id"
t.integer "joint"
t.bigint "created_by_id"
- t.integer "illness_type_0"
t.integer "retirement_value_check"
t.integer "tshortfall_known"
t.integer "sheltered"
@@ -421,6 +434,9 @@ ActiveRecord::Schema[7.0].define(version: 2023_01_09_170748) do
t.string "relat5"
t.string "relat6"
t.integer "hb"
+ t.string "sex4"
+ t.string "sex5"
+ t.string "sex6"
t.integer "savings_value_check"
t.integer "deposit_value_check"
t.integer "frombeds"
@@ -457,21 +473,26 @@ ActiveRecord::Schema[7.0].define(version: 2023_01_09_170748) do
t.integer "hhregres"
t.integer "hhregresstill"
t.integer "proplen"
+ t.integer "mscharge_known"
+ t.decimal "mscharge", precision: 10, scale: 2
t.integer "prevten"
t.integer "mortgageused"
t.integer "wchair"
t.integer "armedforcesspouse"
- t.integer "mscharge_known"
- t.decimal "mscharge", precision: 10, scale: 2
- t.string "sex4"
- t.string "sex5"
- t.string "sex6"
- t.integer "mortlen"
t.datetime "hodate", precision: nil
t.integer "hoday"
t.integer "homonth"
t.integer "hoyear"
- t.integer "extrabor"
+ t.integer "fromprop"
+ t.integer "socprevten"
+ t.integer "mortlen"
+ t.string "pcode1"
+ t.string "pcode2"
+ t.integer "pcodenk"
+ t.string "postcode_full"
+ t.boolean "is_la_inferred"
+ t.integer "mortgagelender"
+ t.string "mortgagelenderother"
t.index ["created_by_id"], name: "index_sales_logs_on_created_by_id"
t.index ["managing_organisation_id"], name: "index_sales_logs_on_managing_organisation_id"
t.index ["owning_organisation_id"], name: "index_sales_logs_on_owning_organisation_id"
diff --git a/lib/tasks/data_export.rake b/lib/tasks/data_export.rake
index 82433756c..5bf9649af 100644
--- a/lib/tasks/data_export.rake
+++ b/lib/tasks/data_export.rake
@@ -14,3 +14,21 @@ namespace :core do
end
end
end
+
+namespace :illness_type_0 do
+ desc "Export log data where illness_type_0 == 1"
+ task export: :environment do |_task|
+ logs = LettingsLog.where(illness_type_0: 1, status: "completed").includes(created_by: :organisation)
+ puts "log_id,created_by_id,organisation_id,organisation_name,startdate"
+
+ logs.each do |log|
+ puts [
+ log.id,
+ log.created_by_id,
+ log.created_by.organisation.id,
+ log.created_by.organisation.name,
+ log.startdate&.strftime("%d/%m/%Y"),
+ ].join(",")
+ end
+ end
+end
diff --git a/spec/components/bulk_upload_error_row_component_spec.rb b/spec/components/bulk_upload_error_row_component_spec.rb
new file mode 100644
index 000000000..86222acf4
--- /dev/null
+++ b/spec/components/bulk_upload_error_row_component_spec.rb
@@ -0,0 +1,75 @@
+require "rails_helper"
+
+RSpec.describe BulkUploadErrorRowComponent, type: :component do
+ context "when a single error" do
+ let(:row) { rand(9_999) }
+ let(:tenant_code) { SecureRandom.hex(4) }
+ let(:property_ref) { SecureRandom.hex(4) }
+ let(:field) { :field_134 }
+ let(:error) { "some error" }
+ let(:bulk_upload) { create(:bulk_upload, :lettings) }
+ let(:bulk_upload_errors) do
+ [
+ FactoryBot.build(
+ :bulk_upload_error,
+ bulk_upload:,
+ row:,
+ tenant_code:,
+ property_ref:,
+ field:,
+ error:,
+ ),
+ ]
+ end
+
+ it "renders the row number" do
+ result = render_inline(described_class.new(bulk_upload_errors:))
+ expect(result).to have_content("Row #{row}")
+ end
+
+ it "renders the tenant_code" do
+ result = render_inline(described_class.new(bulk_upload_errors:))
+ expect(result).to have_content("Tenant code: #{tenant_code}")
+ end
+
+ it "renders the property_ref" do
+ result = render_inline(described_class.new(bulk_upload_errors:))
+ expect(result).to have_content("Property reference: #{property_ref}")
+ end
+
+ it "renders the cell of error" do
+ expected = bulk_upload_errors.first.cell
+ result = render_inline(described_class.new(bulk_upload_errors:))
+ expect(result).to have_content(expected)
+ end
+
+ it "renders the question for lettings" do
+ expected = "Is this letting a renewal?"
+ result = render_inline(described_class.new(bulk_upload_errors:))
+ expect(result).to have_content(expected)
+ end
+
+ context "when a sales bulk upload" do
+ let(:bulk_upload) { create(:bulk_upload, :sales) }
+ let(:field) { :field_87 }
+
+ it "renders the question for sales" do
+ expected = "What is the full purchase price?"
+ result = render_inline(described_class.new(bulk_upload_errors:))
+ expect(result).to have_content(expected)
+ end
+ end
+
+ it "renders the error" do
+ expected = error
+ result = render_inline(described_class.new(bulk_upload_errors:))
+ expect(result).to have_content(expected)
+ end
+
+ it "renders the field number" do
+ expected = bulk_upload_errors.first.field.humanize
+ result = render_inline(described_class.new(bulk_upload_errors:))
+ expect(result).to have_content(expected)
+ end
+ end
+end
diff --git a/spec/factories/bulk_upload.rb b/spec/factories/bulk_upload.rb
index 26b80c172..afa96db15 100644
--- a/spec/factories/bulk_upload.rb
+++ b/spec/factories/bulk_upload.rb
@@ -6,5 +6,15 @@ FactoryBot.define do
log_type { BulkUpload.log_types.values.sample }
year { 2022 }
identifier { SecureRandom.uuid }
+ sequence(:filename) { |n| "bulk-upload-#{n}.csv" }
+ needstype { 1 }
+
+ trait(:sales) do
+ log_type { BulkUpload.log_types[:sales] }
+ end
+
+ trait(:lettings) do
+ log_type { BulkUpload.log_types[:lettings] }
+ end
end
end
diff --git a/spec/factories/bulk_upload_error.rb b/spec/factories/bulk_upload_error.rb
new file mode 100644
index 000000000..1f42f763d
--- /dev/null
+++ b/spec/factories/bulk_upload_error.rb
@@ -0,0 +1,14 @@
+require "securerandom"
+
+FactoryBot.define do
+ factory :bulk_upload_error do
+ bulk_upload
+ row { rand(9_999) }
+ cell { "#{('A'..'Z').to_a.sample}#{row}" }
+ tenant_code { SecureRandom.hex(4) }
+ property_ref { SecureRandom.hex(4) }
+ purchaser_code { SecureRandom.hex(4) }
+ field { "field_#{rand(134)}" }
+ error { "some error" }
+ end
+end
diff --git a/spec/factories/lettings_log.rb b/spec/factories/lettings_log.rb
index 217e8a605..cb97eed68 100644
--- a/spec/factories/lettings_log.rb
+++ b/spec/factories/lettings_log.rb
@@ -83,7 +83,7 @@ FactoryBot.define do
postcode_known { 1 }
postcode_full { Faker::Address.postcode }
reasonpref { 1 }
- cbl { 1 }
+ cbl { 0 }
chr { 1 }
cap { 0 }
reasonother { nil }
diff --git a/spec/factories/organisation.rb b/spec/factories/organisation.rb
index fa40663ac..147f847d6 100644
--- a/spec/factories/organisation.rb
+++ b/spec/factories/organisation.rb
@@ -9,6 +9,10 @@ FactoryBot.define do
created_at { Time.zone.now }
updated_at { Time.zone.now }
holds_own_stock { true }
+
+ trait :with_old_visible_id do
+ old_visible_id { rand(9_999_999).to_s }
+ end
end
factory :organisation_rent_period do
diff --git a/spec/factories/sales_log.rb b/spec/factories/sales_log.rb
index 70b44445d..cac259bc3 100644
--- a/spec/factories/sales_log.rb
+++ b/spec/factories/sales_log.rb
@@ -32,7 +32,7 @@ FactoryBot.define do
age2 { 35 }
builtype { 1 }
ethnic { 3 }
- ethnic_group { 12 }
+ ethnic_group { 17 }
sex2 { "X" }
buy2livein { "1" }
ecstat1 { "1" }
@@ -57,7 +57,7 @@ FactoryBot.define do
income2nk { 0 }
income2 { 10_000 }
inc2mort { 1 }
- la_known { "1" }
+ la_known { 1 }
la { "E09000003" }
savingsnk { 1 }
prevown { 1 }
@@ -96,6 +96,9 @@ FactoryBot.define do
mscharge_known { 1 }
mscharge { 100 }
mortlen { 10 }
+ pcodenk { 1 }
+ is_la_inferred { false }
+ mortgagelender { 5 }
extrabor { 1 }
end
end
diff --git a/spec/features/form/checkboxes_spec.rb b/spec/features/form/checkboxes_spec.rb
index 8f3f4ad65..056ff93cf 100644
--- a/spec/features/form/checkboxes_spec.rb
+++ b/spec/features/form/checkboxes_spec.rb
@@ -41,7 +41,8 @@ RSpec.describe "Checkboxes" do
context "when a checkbox question is submitted with invalid answers" do
before do
- lettings_log.update!(illness: 100)
+ lettings_log.illness = 100
+ lettings_log.save!(validate: false)
allow(lettings_log).to receive(:update).and_return(false)
end
diff --git a/spec/fixtures/complete_lettings_log.json b/spec/fixtures/complete_lettings_log.json
index 805e65a3d..f97d2f37f 100644
--- a/spec/fixtures/complete_lettings_log.json
+++ b/spec/fixtures/complete_lettings_log.json
@@ -1,180 +1,179 @@
{
"lettings_log": {
- "tenancycode":"T1245",
- "age1":34,
- "sex1":"M",
- "ethnic":1,
- "national":1,
- "prevten":3,
- "ecstat1":1,
- "hhmemb":3,
- "age2":29,
- "sex2":"F",
- "ecstat2":2,
- "age3":11,
- "sex3":"R",
- "ecstat3":9,
- "age4":null,
- "sex4":null,
- "ecstat4":null,
- "age5":null,
- "sex5":null,
- "ecstat5":null,
- "age6":null,
- "sex6":null,
- "ecstat6":null,
- "age7":null,
- "sex7":null,
- "ecstat7":null,
- "age8":null,
- "sex8":null,
- "ecstat8":null,
- "homeless":1,
- "underoccupation_benefitcap":2,
- "leftreg":null,
- "reservist":null,
- "illness":2,
- "preg_occ":2,
- "startertenancy":2,
- "tenancylength":null,
- "tenancy":2,
- "ppostcode_full":"NW18TR",
- "rsnvac":5,
- "unittype_gn":7,
- "beds":2,
- "offered":0,
- "wchair":1,
- "earnings":190,
- "incfreq":1,
- "benefits":3,
- "period":3,
- "layear":7,
- "waityear":2,
- "postcode_full":"NW18EE",
- "reasonpref":2,
- "cbl":1,
- "chr":0,
- "cap":0,
- "reasonother":"",
+ "tenancycode": "T1245",
+ "age1": 34,
+ "sex1": "M",
+ "ethnic": 1,
+ "national": 1,
+ "prevten": 3,
+ "ecstat1": 1,
+ "hhmemb": 3,
+ "age2": 29,
+ "sex2": "F",
+ "ecstat2": 2,
+ "age3": 11,
+ "sex3": "R",
+ "ecstat3": 9,
+ "age4": null,
+ "sex4": null,
+ "ecstat4": null,
+ "age5": null,
+ "sex5": null,
+ "ecstat5": null,
+ "age6": null,
+ "sex6": null,
+ "ecstat6": null,
+ "age7": null,
+ "sex7": null,
+ "ecstat7": null,
+ "age8": null,
+ "sex8": null,
+ "ecstat8": null,
+ "homeless": 1,
+ "underoccupation_benefitcap": 2,
+ "leftreg": null,
+ "reservist": null,
+ "illness": 2,
+ "preg_occ": 2,
+ "startertenancy": 2,
+ "tenancylength": null,
+ "tenancy": 2,
+ "ppostcode_full": "NW18TR",
+ "rsnvac": 5,
+ "unittype_gn": 7,
+ "beds": 2,
+ "offered": 0,
+ "wchair": 1,
+ "earnings": 190,
+ "incfreq": 1,
+ "benefits": 3,
+ "period": 3,
+ "layear": 7,
+ "waityear": 2,
+ "postcode_full": "NW18EE",
+ "reasonpref": 2,
+ "cbl": 1,
+ "chr": 0,
+ "cap": 0,
+ "reasonother": "",
"housingneeds": 1,
"housingneeds_type": 2,
"housingneeds_other": 0,
"housingneeds_c": 1,
- "illness_type_1":null,
- "illness_type_2":null,
- "illness_type_3":null,
- "illness_type_4":null,
- "illness_type_8":null,
- "illness_type_5":null,
- "illness_type_6":null,
- "illness_type_7":null,
- "illness_type_9":null,
- "illness_type_10":null,
- "rp_homeless":null,
- "rp_insan_unsat":null,
- "rp_medwel":null,
- "rp_hardship":null,
- "rp_dontknow":null,
- "tenancyother":"",
- "net_income_value_check":null,
- "property_owner_organisation":null,
- "property_manager_organisation":null,
- "irproduct_other":"",
- "purchaser_code":null,
- "reason":42,
- "propcode":"PT562",
- "majorrepairs":1,
- "la":"E09000007",
- "prevloc":"E09000007",
- "hb":9,
- "hbrentshortfall":null,
- "property_relet":null,
- "mrcdate":"2021-05-07T00:00:00.000+01:00",
- "incref":null,
- "startdate":"2021-06-06T00:00:00.000+01:00",
- "armedforces":2,
- "first_time_property_let_as_social_housing":0,
- "unitletas":1,
- "builtype":1,
- "voiddate":"2021-05-05T00:00:00.000+01:00",
- "owning_organisation_id":1,
- "managing_organisation_id":1,
- "renttype":2,
- "needstype":1,
- "lettype":7,
- "postcode_known":1,
- "is_la_inferred":true,
- "totchild":1,
- "totelder":0,
- "totadult":2,
- "net_income_known":0,
- "nocharge":0,
- "is_carehome":null,
- "household_charge":null,
- "referral":2,
- "brent":"350.0",
- "scharge":"11.0",
- "pscharge":"11.0",
- "supcharg":"0.0",
- "tcharge":"372.0",
- "tshortfall":null,
- "chcharge":null,
- "declaration":1,
- "ppcodenk":1,
- "previous_la_known":null,
- "is_previous_la_inferred":true,
- "age1_known":0,
- "age2_known":0,
- "age3_known":0,
- "age4_known":null,
- "age5_known":null,
- "age6_known":null,
- "age7_known":null,
- "age8_known":null,
- "ethnic_group":0,
- "letting_allocation_unknown":0,
- "details_known_2":0,
- "details_known_3":0,
- "details_known_4":null,
- "details_known_5":null,
- "details_known_6":null,
- "details_known_7":null,
- "details_known_8":null,
- "rent_type":1,
- "has_benefits":0,
- "renewal":0,
- "wrent":"87.5",
- "wscharge":"2.75",
- "wpschrge":"2.75",
- "wsupchrg":"0.0",
- "wtcharge":"93.0",
- "wtshortfall":null,
- "refused":1,
- "wchchrg":null,
- "newprop":2,
- "relat2":"P",
- "relat3":"C",
- "relat4":null,
- "relat5":null,
- "relat6":null,
- "relat7":null,
- "relat8":null,
- "rent_value_check":null,
- "old_form_id":null,
- "lar":null,
- "irproduct":null,
- "old_id":null,
- "joint":null,
- "created_by_id":2,
- "illness_type_0":null,
- "retirement_value_check":null,
- "tshortfall_known":null,
- "sheltered":null,
- "pregnancy_value_check":null,
- "hhtype":6,
- "new_old":1,
- "vacdays":30,
- "scheme_id":null,
- "location_id":null
+ "illness_type_1": null,
+ "illness_type_2": null,
+ "illness_type_3": null,
+ "illness_type_4": null,
+ "illness_type_8": null,
+ "illness_type_5": null,
+ "illness_type_6": null,
+ "illness_type_7": null,
+ "illness_type_9": null,
+ "illness_type_10": null,
+ "rp_homeless": null,
+ "rp_insan_unsat": null,
+ "rp_medwel": null,
+ "rp_hardship": null,
+ "rp_dontknow": null,
+ "tenancyother": "",
+ "net_income_value_check": null,
+ "property_owner_organisation": null,
+ "property_manager_organisation": null,
+ "irproduct_other": "",
+ "purchaser_code": null,
+ "reason": 42,
+ "propcode": "PT562",
+ "majorrepairs": 1,
+ "la": "E09000007",
+ "prevloc": "E09000007",
+ "hb": 9,
+ "hbrentshortfall": null,
+ "property_relet": null,
+ "mrcdate": "2021-05-07T00:00:00.000+01:00",
+ "incref": null,
+ "startdate": "2021-06-06T00:00:00.000+01:00",
+ "armedforces": 2,
+ "first_time_property_let_as_social_housing": 0,
+ "unitletas": 1,
+ "builtype": 1,
+ "voiddate": "2021-05-05T00:00:00.000+01:00",
+ "owning_organisation_id": 1,
+ "managing_organisation_id": 1,
+ "renttype": 2,
+ "needstype": 1,
+ "lettype": 7,
+ "postcode_known": 1,
+ "is_la_inferred": true,
+ "totchild": 1,
+ "totelder": 0,
+ "totadult": 2,
+ "net_income_known": 0,
+ "nocharge": 0,
+ "is_carehome": null,
+ "household_charge": null,
+ "referral": 2,
+ "brent": "350.0",
+ "scharge": "11.0",
+ "pscharge": "11.0",
+ "supcharg": "0.0",
+ "tcharge": "372.0",
+ "tshortfall": null,
+ "chcharge": null,
+ "declaration": 1,
+ "ppcodenk": 1,
+ "previous_la_known": null,
+ "is_previous_la_inferred": true,
+ "age1_known": 0,
+ "age2_known": 0,
+ "age3_known": 0,
+ "age4_known": null,
+ "age5_known": null,
+ "age6_known": null,
+ "age7_known": null,
+ "age8_known": null,
+ "ethnic_group": 0,
+ "letting_allocation_unknown": 0,
+ "details_known_2": 0,
+ "details_known_3": 0,
+ "details_known_4": null,
+ "details_known_5": null,
+ "details_known_6": null,
+ "details_known_7": null,
+ "details_known_8": null,
+ "rent_type": 1,
+ "has_benefits": 0,
+ "renewal": 0,
+ "wrent": "87.5",
+ "wscharge": "2.75",
+ "wpschrge": "2.75",
+ "wsupchrg": "0.0",
+ "wtcharge": "93.0",
+ "wtshortfall": null,
+ "refused": 1,
+ "wchchrg": null,
+ "newprop": 2,
+ "relat2": "P",
+ "relat3": "C",
+ "relat4": null,
+ "relat5": null,
+ "relat6": null,
+ "relat7": null,
+ "relat8": null,
+ "rent_value_check": null,
+ "old_form_id": null,
+ "lar": null,
+ "irproduct": null,
+ "old_id": null,
+ "joint": null,
+ "created_by_id": 2,
+ "retirement_value_check": null,
+ "tshortfall_known": null,
+ "sheltered": null,
+ "pregnancy_value_check": null,
+ "hhtype": 6,
+ "new_old": 1,
+ "vacdays": 30,
+ "scheme_id": null,
+ "location_id": null
}
}
diff --git a/spec/fixtures/exports/general_needs_log.csv b/spec/fixtures/exports/general_needs_log.csv
index d93f66ab0..afaa9e745 100644
--- a/spec/fixtures/exports/general_needs_log.csv
+++ b/spec/fixtures/exports/general_needs_log.csv
@@ -1,2 +1,2 @@
status,tenancycode,age1,sex1,ethnic,national,prevten,ecstat1,hhmemb,age2,sex2,ecstat2,age3,sex3,ecstat3,age4,sex4,ecstat4,age5,sex5,ecstat5,age6,sex6,ecstat6,age7,sex7,ecstat7,age8,sex8,ecstat8,homeless,underoccupation_benefitcap,leftreg,reservist,illness,preg_occ,startertenancy,tenancylength,tenancy,ppostcode_full,rsnvac,unittype_gn,beds,offered,wchair,earnings,incfreq,benefits,period,layear,waityear,postcode_full,reasonpref,cbl,chr,cap,reasonother,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_f,housingneeds_g,housingneeds_h,illness_type_1,illness_type_2,illness_type_3,illness_type_4,illness_type_8,illness_type_5,illness_type_6,illness_type_7,illness_type_9,illness_type_10,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,tenancyother,irproduct_other,reason,propcode,la,prevloc,hb,hbrentshortfall,mrcdate,incref,startdate,armedforces,unitletas,builtype,voiddate,renttype,needstype,lettype,totchild,totelder,totadult,nocharge,referral,brent,scharge,pscharge,supcharg,tcharge,tshortfall,chcharge,ppcodenk,has_benefits,renewal,wrent,wscharge,wpschrge,wsupchrg,wtcharge,wtshortfall,refused,housingneeds,wchchrg,newprop,relat2,relat3,relat4,relat5,relat6,relat7,relat8,lar,irproduct,joint,sheltered,hhtype,new_old,vacdays,form,owningorgid,owningorgname,hcnum,maningorgid,maningorgname,manhcnum,createddate,uploaddate
-2,BZ737,35,F,2,4,6,0,2,32,M,6,,,,,,,,,,,,,,,,,,,1,0,1,1,1,2,1,5,1,SE2 6RT,6,7,3,2,1,68,1,1,2,2,1,NW1 5TY,1,1,1,2,,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,,,4,123,E09000003,E07000105,6,1,2020-05-05T10:36:49+01:00,0,2022-02-02T10:36:49+00:00,1,2,1,2019-11-03T00:00:00+00:00,2,1,7,0,0,2,0,2,200.0,50.0,40.0,35.0,325.0,12.0,,1,1,0,100.0,25.0,20.0,17.5,162.5,6.0,0,1,,2,P,,,,,,,,,,,4,2,638,{id},{owning_org_id},DLUHC,1234,{managing_org_id},DLUHC,1234,2022-02-08T16:52:15+00:00,2022-02-08T16:52:15+00:00
+2,BZ737,35,F,2,4,6,0,2,32,M,6,,,,,,,,,,,,,,,,,,,1,4,1,1,1,2,1,5,1,SE2 6RT,6,7,3,2,1,68,1,1,2,2,1,NW1 5TY,1,2,1,2,,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,,,4,123,E09000003,E07000105,6,1,2020-05-05T10:36:49+01:00,0,2022-02-02T10:36:49+00:00,1,2,1,2019-11-03T00:00:00+00:00,2,1,7,0,0,2,0,2,200.0,50.0,40.0,35.0,325.0,12.0,,1,1,0,100.0,25.0,20.0,17.5,162.5,6.0,0,1,,2,P,,,,,,,,,,,4,2,638,{id},{owning_org_id},DLUHC,1234,{managing_org_id},DLUHC,1234,2022-02-08T16:52:15+00:00,2022-02-08T16:52:15+00:00
diff --git a/spec/fixtures/exports/general_needs_log.xml b/spec/fixtures/exports/general_needs_log.xml
index 8e72e23de..1e60333dc 100644
--- a/spec/fixtures/exports/general_needs_log.xml
+++ b/spec/fixtures/exports/general_needs_log.xml
@@ -32,7 +32,7 @@
1
-
0
+
4
1
1
1
@@ -54,7 +54,7 @@
1
NW1 5TY
1
-
1
+
2
1
2
diff --git a/spec/fixtures/exports/supported_housing_logs.xml b/spec/fixtures/exports/supported_housing_logs.xml
index bd5b1d209..7674984b4 100644
--- a/spec/fixtures/exports/supported_housing_logs.xml
+++ b/spec/fixtures/exports/supported_housing_logs.xml
@@ -32,7 +32,7 @@
1
-
0
+
4
1
1
1
@@ -53,7 +53,7 @@
1
SW1A 2AA
1
-
1
+
2
1
2
@@ -130,7 +130,7 @@
-
0
+
1
4
2
638
diff --git a/spec/fixtures/files/2021_22_lettings_bulk_upload.csv b/spec/fixtures/files/2021_22_lettings_bulk_upload.csv
new file mode 100644
index 000000000..f1f947596
--- /dev/null
+++ b/spec/fixtures/files/2021_22_lettings_bulk_upload.csv
@@ -0,0 +1,20 @@
+Question,Type of letting,Who is the landlord?,Registration no/LA CORE code,Management group,Scheme code,First letting?,Tenant code,"Starter/
+Introductory Tenancy?",Type of tenancy,"If you responded 'Other' in Q2b, please state tenancy type",Tenancy Duration,Age of Person 1,Age of Person 2,Age of Person 3,Age of Person 4,Age of Person 5,Age of Person 6,Age of Person 7,Age of Person 8,Gender of Person 1,Gender of Person 2,Gender of Person 3,Gender of Person 4,Gender of Person 5,Gender of Person 6,Gender of Person 7,Gender of Person 8,Relationship (of Person 2) to Person 1,Relationship (of Person 3) to Person 1,Relationship (of Person 4) to Person 1,Relationship (of Person 5) to Person 1,Relationship (of Person 6) to Person 1,Relationship (of Person 7) to Person 1,Relationship (of Person 8) to Person 1,Economic Status of Person 1,Economic Status of Person 2,Economic Status of Person 3,Economic Status of Person 4,Economic Status of Person 5,Economic Status of Person 6,Economic Status of Person 7,Economic Status of Person 8,Ethnic group of person 1 as defined by applicant,Nationality of person 1 as defined by applicant,Is anyone in the household…?,Has anyone in the household been seriously injured or ill as a direct result of their time and activities serving as a regular or a reserve?,Does the household contain a pregnant person?,Is the tenant in receipt of or likely to be in receipt of the following:,"How much of your income comes from universal credit, state pensions or benefits (excluding child and housing benefit, UC housing element, and council tax support or tax credit)?","Tenant’s or tenant and partner’s net income (after tax deductions). For those receiving Universal Credit, enter net weekly income from employment, pensions and Universal Credit. Exclude child benefit, housing element of universal credit and council tax support. For those not receiving Universal Credit, please enter net weekly income from employment, pensions and other benefits. Exclude housing benefit, child benefit and council tax support.",Income refused,In the tenant's view what was the main reason the household left their last settled home?,"If you responded 'Other' in 9a, please state main reason",Was the reason for leaving a direct result of the removal of the spare room subsidy or benefit cap introduced from 2013?,a) Fully wheelchair accessible,b) Wheelchair access to essential rooms,c) Requires level access housing,f) Other disability,g) No disability,H) Don't know,The housing situation for this household immediately before this letting,Enter LA in which household lived immediately before this letting,Part 1 of postcode of previous accommodation,Part 2 of postcode of previous accommodation,If postcode of previous accommodation is unknown or if the previous accommodation was temporary,How long has the household continuously lived in the local authority area where the new letting is located?,How long has the household been on the waiting list of the local authority district where the new letting is located?,"Immediately prior to this letting, was this household...?",Was the household given Reasonable Preference (i.e. priority) for housing by the local authority?,Homeless or about to lose their home (within 56 days),"Living in insanitary, overcrowded or unsatisfactory housing",A need to move on medical and welfare grounds (including a disability),A need to move to avoid hardship to themselves or others,Don't know,Was the letting made under any of the following allocations systems? (CBL),Was the letting made under any of the following allocations systems? (CHR),Was the letting made under any of the following allocations systems? (CAP),Source of referral for this letting?,Rent and other charges period,Basic rent,Service charge,Personal Service Charge,Support charge,Total charge,total charge for care homes,Please tick if there is neither rent nor charge to the occupant for the accommodation,"After housing benefit and/or housing element of Universal Credit payment is received, will there be an outstanding amount for basic rent (18i) and/or benefit eligible charges (18ii)?","After housing benefit and/or other housing support payments are received, will there be an outstanding amount for basic rent and/or benefit eligible charges?",void date,void date,void date,Major repairs completion date,Major repairs completion date,Major repairs completion date,if the unit is in a supported scheme for stays of one month or less….,tenancy start date,tenancy start date,tenancy start date,"How many times has the unit been previously offered since becoming available for relet since the last tenancy ended or as a first let? For an Affordable Rent or Intermediate Rent Letting, only include number of offers as that type. (For a property let at the firsty attempt enter '0').",RP property reference (if applicable),Number of bedrooms,Type of unit,Type of building,Is property built or adapted to wheelchair users standards,"If this is a relet, was the property most recently let on",Reason for vacancy,Enter LA of property,Part 1 of postcode of property,Part 2 of postcode of property,If previous postcode and new postcode are the same,Managed (owning) organisation CORE ID,Username Field,Managing (Data providing) Organisation CORE ID ,"If they've ever served as a regular, did they leave…",Enter the Unique Property Reference Number if known,Is the income…?,Is this letting sheltered accommodation?,Does anyone in the household have any physical or mental health conditions or illness lasting or expected to last for 12 months or more?,Vision (e.g. blindness or partial sight),Hearing (e.g. deatness or partial hearing),Mobility (e.g. walking short distances or climbing stairs),"Dexterity (e.g. lifting and carrying objects, using a keyboard)",Learning or understanding or concentrating,Memory,Mental health,Stamina or breathing or fatigue,"Socially or behaviourally (e.g. associated with autism spectral disorder (ASD) which includes Aspergers', or attention deficit hyperactivity disorder (ADHD))",Other,Is this letting a London Affordable Rent letting?,Is this letting…?,"If you responded 'Other' in 0bi, please state product",Data Protection question,,,
+Values,1 - 12,1 - 2,6 or 7 digits,1 - 999,,1 - 2,max 13 digits,1 - 2,1 - 5,Text ,1 - 99,15 - 120 or R,,,,,,,,"F, M, X or R",,,,,,,,"P,C,X or R",,,,,,,0 - 10,,,,,,,,1 - 19,1 - 17,1 - 5,1 - 3,,"1, 3 or 6 - 9",1 - 4,0 - 9999,1 or Null,"1 - 2, 4, 7 - 14, 16 - 20, 28 - 31 or 34 - 46",Text,2 - 6,1 or null ,,,,,,"3- 4, 6 - 10, 13, 14, 18, 19, 21 or 23 - 33",ONS CODE - 4 or 9 Digits,XXX(X),XXX,1 or null,"1, 2 or 5 - 10",,"1, 7 or 11",1 - 3,1 or null,,,,,1 or 2,,,"1 - 16 (not 5, 6 or 11)",1 - 10,xxxx.xx,,,,,,1 or null,1 - 3,0 - 9999,1 - 31,1 - 12,10 - 20,1 - 31,1 - 12,13 - 20,1 or null,1 - 31,1 - 12,19 or 20,0+,12 Digits,1 - 7,"1, 2, 4 or 6 - 10",1 or 2,,1 - 4,"5, 6 or 8 - 19",ONS CODE 9 digits,,,1 or null,up to 7,username (name for signing into CORE) of person this log should be assigned to.,up to 7,3 - 6,"Numeric, up to 12 digits",1 - 3,1 - 4,1 - 3,1 or null,,,,,,,,,,1 - 3,,Text,1,,,
+Can Be Null?,No,"only if 1 = 2, 4, 6, 8, 10 or 12","only if field 1 = 2, 4, 6, 8, 10 or 12 or field 2 = 1","only if field 1 = 1, 3, 5, 7, 9 or 11",,"only if 1 = 1, 3, 5, 7, 9 or 11",No,,,"Yes, if 9 is not 3","only if 9 = 1, 2, 3 or 5",No,"Yes, if field 21, 28 and 36 are null","Yes, if 22, 29 and 37 are null","Yes, if 23, 30 and 38 are null","Yes, if 24, 31 and 39 are null","Yes, if 25, 32 and 40 are null","Yes, if 26, 33 and 41 are null","Yes, if 27, 34 and 42 are null", No,"Yes, if 13, 28 and 36 are null","Yes, if 14, 29 and 37 are null","Yes, if 15, 30 and 38 are null","Yes, if 16, 31 and 39 are null","Yes, if 17, 32 and 40 are null","Yes, if 18, 33 and 41 are null","Yes, if 19, 34 and 42 are null","Yes, if 13, 21 and 36 are null","Yes, if 14, 22 and 37 are null","Yes, if 15, 23 and 38 are null","Yes, if 16, 24 and 39 are null","Yes, if 17, 25 and 40 are null","Yes, if 18, 26 and 41 are null","Yes, if 19, 27 and 42 are null",No,"Yes, if 13, 21 and 28 are null","Yes, if 14, 22 and 29 are null","Yes, if 15, 23 and 30 are null","Yes, if 16, 24 and 31 are null","Yes, if 17, 25 and 32 are null","Yes, if 18, 26 and 33 are null","Yes, if 19, 27 and 34 are null",No,,,"Yes, must be null if 45 = 2 or 3;
+no, if 45 = 1, 4 or 5",No,,,If 51 = 1,Yes,No,"Yes, if 52 is not 20",No,"Selections are ((A or B or C)) - ((A, or B or C and F)) - ((F)) - ((G)) - ((H))",,,,,,No,,"Yes, if 65 = 1",,"Yes, if 63 and 64 contain full and valid entries",No,,,," If 69 = 1, select at least one of the 5 categories;
+If 69 = 2 or 3, then Null.",,,,,No,,,,,if 85 or 86 = 1,Yes,,,if 85 or 86 = 1,Only if fields 80 - 84 and 86 are not null,Only if fields 80 - 85 are not null,"Only if field 48 = 3, 6, 7 or 8 ","If 87 = 2 or 3;
+if 87 = 1, then a value must be entered",No,,,Yes,,,,No,,,,"Only if 1 = 2, 4, 6, 8, 10 or 12",,,,No,"Only if 1 = 2, 4, 6, 8, 10 or 12;
+or 106 = 15 - 17",No,"Only if 1 = 2, 4, 6, 8, 10 or 12",,,Yes,No,,Yes: DCLG Admin only,"Only if 45 = 2, 3 or 4",Yes,"Yes, if 51 = 1","Only if 1 = 1, 3, 5, 7, 9 or 11",No,Yes,,,,,,,,,,Only if 1 = 1 - 4 or 9 - 12.,Only if 1 = 1 - 8.,,No,,,
+eCORE Format and Duplicate check,Incorrect GN/SH combination check fields,,,,,Question Removed from 2020/21,,,,,,Duplicate check field,,,,,,,,Duplicate check field,,,,,,,,,,,,,,,Duplicate check field,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,Duplicate check field,,,,,,,,,,,,Duplicate check fields,,,,Duplicate check field,General Needs lettings only,,,All lettings,General Needs lettings only,All lettings,General Needs lettings only,,,Question Removed from 2020/21,Duplicate check field, “Username does not exist”. ,,,Question removed from 21/22 onwards,,Supported Housing lettings only.,,,,,,,,,,,,Affordable Rent Lettings only,Intermediate Rent Lettings only,,,,,
+Question Number,1a,1b,,1c,,1d,1b,2a,2b,2ba,2c,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,4ai,4b,5,6,7,8,,9a,9aa,9b,10,,,,,,11,12a,12b,,,12c,12d,13,14a,14b,,,,,15,,,16,17, 18ai, 18aii, 18aiii, 18aiv, 18av, 18b, 18c,18d,,19,,,,,,,1,,,20,21a,22,23,24,25,26,27,28,,,28,,,,4aii,21b,8a,1e,10ia,10ib,10ib,10ib,10ib,10ib,10ib,10ib,10ib,10ib,10ib,0a,0bi,0bii,,,,
+Field Number,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,,,
+,2,,,1,1,,4626,2,5,,,47,,,,,,,,M,,,,,,,,,,,,,,,4,,,,,,,,13,1,2,,3,1,4,,1,34,,3,,,,,,1,33,E09000028,,,1,6,6,7,2,,,,,,2,2,2,4,1,90,141,5,43,279,,,3,,10,8,20,,,,,17,9,21,0,439JOE005A,,,,2,,12,,,,,107242,mt.data.gary.meyler@communities.gov.uk,107242,,439JOE005A,1,1,1,,,,,,,,,,,,,,,,,
+,2,,,1,1,,4173,2,5,,,R,,,,,,,,R,,,,,,,,,,,,,,,0,,,,,,,,17,13,3,,3,3,4,,1,28,,3,,,,,,1,25,E09000030,,,1,6,6,1,3,,,,,,2,2,2,4,1,90,141,5,43,279,,,3,,2,3,20,,,,,22,4,21,0,439JOE001D,,,,2,,12,,,,,107242,mt.data.gary.meyler@communities.gov.uk,107242,,439JOE001D,1,1,1,,,,,,,,,,,,,,,,,
+,2,,,1,1,,4196,2,5,,,46,,,,,,,,F,,,,,,,,,,,,,,,6,,,,,,,,7,1,2,,3,3,4,,1,28,,3,,,,,,1,28,E09000028,,,1,6,6,7,3,,,,,,2,2,2,4,1,90,141,5,43,279,,,3,,14,4,20,,,,,29,4,21,0,439JOE006F,,,,2,,12,,,,,107242,mt.data.gary.meyler@communities.gov.uk,107242,,439JOE006F,1,1,1,,,,,,,,,,,,,,,,,
+,2,,,1,1,,4198,2,5,,,41,,,,,,,,M,,,,,,,,,,,,,,,8,,,,,,,,1,1,3,,3,3,4,,1,28,,3,,,,,,1,28,E09000028,,,1,6,6,7,3,,,,,,2,2,2,4,1,90,141,5,43,279,,,3,,26,3,20,,,,,30,4,21,0,439JOE001A,,,,2,,12,,,,,107242,mt.data.gary.meyler@communities.gov.uk,107242,,439JOE001A,1,1,1,,,,,,,,,,,,,,,,,
+,2,,,1,1,,4220,2,5,,,R,,,,,,,,R,,,,,,,,,,,,,,,0,,,,,,,,17,13,3,,3,3,4,,1,28,,3,,,,,,1,25,E09000030,,,1,6,6,1,3,,,,,,2,2,2,4,1,90,141,5,43,279,,,3,,13,4,20,,,,,8,5,21,0,439JOE008A,,,,2,,12,,,,,107242,mt.data.gary.meyler@communities.gov.uk,107242,,439JOE008A,1,1,1,,,,,,,,,,,,,,,,,
+,2,,,1,1,,4285,2,5,,,R,,,,,,,,R,,,,,,,,,,,,,,,0,,,,,,,,17,13,3,,3,3,4,,1,28,,3,,,,,,1,25,E09000030,,,1,6,6,1,3,,,,,,2,2,2,4,1,90,141,5,43,279,,,3,,7,5,20,,,,,1,6,21,0,439JOE006B,,,,2,,8,,,,,107242,mt.data.gary.meyler@communities.gov.uk,107242,,439JOE006B,1,1,1,,,,,,,,,,,,,,,,,
+,2,,,1,1,,4189,2,5,,,27,,,,,,,,F,,,,,,,,,,,,,,,4,,,,,,,,12,1,2,,3,1,4,,1,18,,3,,,,,,1,18,E09000028,,,1,6,6,7,2,,,,,,2,2,2,4,1,90,141,5,43,279,,,3,,17,4,20,,,,,26,4,21,0,439JOE008F,,,,2,,11,,,,,107242,mt.data.gary.meyler@communities.gov.uk,107242,,439JOE008F,1,1,1,,,,,,,,,,,,,,,,,
+,2,,,1,1,,4533,2,5,,,30,,,,,,,,F,,,,,,,,,,,,,,,4,,,,,,,,1,1,3,,3,1,4,,1,7,,3,,,,,,1,7,E09000028,,,1,6,6,7,2,,,,,,2,2,2,4,1,90,141,5,43,279,,,3,,22,7,20,,,,,14,8,21,0,439KOE007F,,,,2,,6,,,,,107242,mt.data.gary.meyler@communities.gov.uk,107242,,439KOE007F,1,1,1,,,,,,,,,,,,,,,,,
+,2,,,1,1,,4366,2,5,,,34,,,,,,,,M,,,,,,,,,,,,,,,4,,,,,,,,3,7,2,,3,1,4,,1,18,,3,,,,,,1,18,E09000028,,,1,6,6,7,1,,,,,1,2,2,2,4,1,90,141,5,43,279,,,3,,30,5,20,,,,,22,6,21,0,439JOE001C,,,,2,,12,,,,,107242,mt.data.gary.meyler@communities.gov.uk,107242,,439JOE001C,1,1,1,,,,,,,,,,,,,,,,,
diff --git a/spec/fixtures/files/2022_23_lettings_bulk_upload.csv b/spec/fixtures/files/2022_23_lettings_bulk_upload.csv
new file mode 100644
index 000000000..b767b6e64
--- /dev/null
+++ b/spec/fixtures/files/2022_23_lettings_bulk_upload.csv
@@ -0,0 +1,72 @@
+Question,What is the letting type?,[BLANK],[BLANK],"Management group code
+
+If supported housing","Scheme code
+
+If supported housing",[BLANK],"What is the tenant code?
+
+This is how you usually refer to this tenancy on your own systems",Is this a starter tenancy? ,What is the tenancy type? ,If 'Other' what is the tenancy type?,"What is the length of the fixed-term tenancy to the nearest year?
+
+If fixed-term tenancy",Age of Person 1,Age of Person 2,Age of Person 3,Age of Person 4,Age of Person 5,Age of Person 6,Age of Person 7,Age of Person 8,Gender identity of Person 1,Gender identity of Person 2,Gender identity of Person 3,Gender identity of Person 4,Gender identity of Person 5,Gender identity of Person 6,Gender identity of Person 7,Gender identity of Person 8,Person 2's relationship to lead tenant,Person 3's relationship to lead tenant,Person 4's relationship to lead tenant,Person 5's relationship to lead tenant,Person 6's relationship to lead tenant,Person 7's relationship to lead tenant,Person 8's relationship to lead tenant,Working situation of Person 1,Working situation of Person 2,Working situation of Person 3,Working situation of Person 4,Working situation of Person 5,Working situation of Person 6,Working situation of Person 7,Working situation of Person 8,What is the lead tenant’s ethnic group? ,What is the lead tenant’s nationality? ,Does anybody in the household have links to the UK armed forces? ,Was the person seriously injured or ill as a result of serving in the UK armed forces? ,Is anybody in the household pregnant? ,Is the tenant likely to be receiving benefits related to housing? ,"How much of the household's income is from Universal Credit, state pensions or benefits? ","How much income does the household have in total?
+
+Include any income after tax from employment, pensions, and Universal Credit
+
+Don't include National Insurance (NI) contributions and tax, housing benefit, child benefit, or council tax support ",Do you know the household's income?,What is the tenant's main reason for the household leaving their last settled home? ,"If 'other', what was the main reason for leaving their last settled home?",[BLANK],"Disabled access needs
+
+a) Fully wheelchair-accessible housing ","Disabled access needs
+
+b) Wheelchair access to essential rooms ","Disabled access needs
+
+c) Level access housing ","Disabled access needs
+
+f) Other disabled access needs ","Disabled access needs
+
+g) No disabled access needs ","Disabled access needs
+
+h) Don’t know",Where was the household immediately before this letting? ,What is the local authority of the household's last settled home?,Part 1 of postcode of last settled home,Part 2 of postcode of last settled home ,Do you know the postcode of the last settled home?,How long has the household continuously lived in the local authority area of the new letting? ,How long has the household been on the local authority waiting list for the new letting? ,Was the tenant homeless directly before this tenancy?,Was the household given 'reasonable preference' by the local authority? ,"Reasonable Preference
+
+They were homeless or about to lose their home (within 56 days) ","Reasonable Preference
+
+They were living in unsanitary, overcrowded or unsatisfactory housing ","Reasonable Preference
+
+They needed to move due to medical and welfare reasons (including disability) ","Reasonable Preference
+
+They needed to move to avoid hardship to themselves or others ","Reasonable Preference
+
+Don't know ",Was the letting made under Choice-Based Lettings (CBL)? ,Was the letting made under the Common Housing Register (CHR)? ,Was the letting made under the Common Allocation Policy (CAP)? ,What was the source of referral for this letting? ,How often does the household pay rent and other charges? ,What is the basic rent? ,What is the service charge? ,What is the personal service charge? ,What is the support charge? ,Total charge,"
+If this is a care home,
+how much does the household pay every [time period]?","Does the household pay rent or other charges for the accommodation?
+
+If supported housing ","After the household has received any housing-related benefits, will they still need to pay basic rent and other charges? ",What do you expect the outstanding amount to be? ,What is the void or renewal day? - DD,What is the void or renewal month? - MM,What is the void or renewal year? - YYYY,What day were Major Repairs completed on? - DD,What month were Major Repairs completed on? - MM,What year were Major Repairs completed on? - YY,[BLANK],What day did the tenancy start? - DD,What month did the tenancy start? - MM,What year did the tenancy start? - YY,"Since becoming available, how many times has the property been previously offered? ","What is the property reference?
+
+This is how you usually refer to this property on your own systems","How many bedrooms does the property have?
+
+If general needs","What type of unit is the property?
+
+If general needs","Which type of building is the property?
+
+If general needs","Is the property built or adapted to wheelchair-user standards?
+
+If general needs","What type was the property most recently let as?
+
+If re-let",What is the reason for the property being vacant? ,"What is the local authority of the property?
+
+If general needs","Part 1 of postcode of property
+
+If general needs","Part 2 of postcode of property
+
+If general needs",[BLANK],"Which organisation owns this property?
+
+Organisation's CORE ID",Username Field,"Which organisation manages this property?
+
+Organisation's CORE ID",Is the person still serving in the UK armed forces? ,[BLANK],How often does the household receive income? ,"Is this letting in sheltered accommodation?
+
+If supported housing",Does anybody in the household have a physical or mental health condition (or other illness) expected to last 12 months or more? ,"Vision, for example blindness or partial sight","Hearing, for example deatness or partial hearing","Mobility, for example walking short distances or climbing stairs","Dexterity, for example lifting and carrying objects, using a keyboard",Learning or understanding or concentrating,Memory,"Mental health, for example depression or anxiety",Stamina or breathing or fatigue,"Socially or behaviourally (e.g. associated with autism spectrum disorder (ASD) which includes Aspergers', or attention deficit hyperactivity disorder (ADHD))",Other illness or condition,Is this letting a London Affordable Rent letting?,Which type of Intermediate Rent is this letting?,Which 'Other' type of Intermediate Rent is this letting?,Has the tenant seen the DLUHC privacy notice? ,Is this a joint tenancy? ,Is this a renewal to the same tenant in the same property?,
+Values,1 - 12,,,1 - 999,,,max 13 digits,1 - 2,2 - 7,Text ,1 - 99,15 - 120 or R,1 - 120 or R,,,,,,,"M, F, X or R",,,,,,,,"P,C,X or R",,,,,,,0 - 11,,,,,,,,1 - 19,"12 - 13, 17 - 19",1 - 6,1 - 3,,"1, 3, 6, 9",1 - 4,0 - 99999,1 - 4,"1 - 2, 4, 7 - 14, 16 - 20, 28 - 31 or 34 - 47",Text,,1 or null ,,,,,,"3- 4, 6 - 7, 9 - 10, 13 - 14, 18 - 19, 21 or 23 - 35",ONS CODE - E + 8 Digits,XXX(X),XXX,1 - 2,1 - 2 or 5 - 10,2 or 5 - 11,1 or 12,1 - 3,1 or null,,,,,1 or 2,,,"1 - 4, 7 - 10, 12 - 17",1 - 9,xxxx.xx,,,,,,1 or null,1 - 3,0 - 9999,1 - 31,1 - 12,19 - 23,1 - 31,1 - 12,13 - 23,,1 - 31,1 - 12,22-23,0+,12 Digits,1 - 7,"1, 2, 4 or 6 - 10",1 or 2,,1 - 4,"5, 6, 8 - 14, ",ONS CODE E + 9 digits,XXX(X),XXX,,Up to 7 digits,Username of CORE account this letting log should be assigned to,Up to 7 digits,3 - 6,,1 - 3,1 - 4,1 - 3,1 or null,,,,,,,,,,1 - 3,,Text,1,1 - 3,1 - 2,
+Can be null?,No,,,"only if field 1 = 1, 3, 5, 7, 9 or 11",,,No,,,"Yes, if 9 is not 3","Yes, if 9 = 2, 3, 5 or 7",No,"Yes, if field 21, 28 and 36 are null","Yes, if 22, 29 and 37 are null","Yes, if 23, 30 and 38 are null","Yes, if 24, 31 and 39 are null","Yes, if 25, 32 and 40 are null","Yes, if 26, 33 and 41 are null","Yes, if 27, 34 and 42 are null", No,"Yes, if 13, 28 and 36 are null","Yes, if 14, 29 and 37 are null","Yes, if 15, 30 and 38 are null","Yes, if 16, 31 and 39 are null","Yes, if 17, 32 and 40 are null","Yes, if 18, 33 and 41 are null","Yes, if 19, 34 and 42 are null","Yes, if 13, 21 and 36 are null","Yes, if 14, 22 and 37 are null","Yes, if 15, 23 and 38 are null","Yes, if 16, 24 and 39 are null","Yes, if 17, 25 and 40 are null","Yes, if 18, 26 and 41 are null","Yes, if 19, 27 and 42 are null",No,"Yes, if 13, 21 and 28 are null","Yes, if 14, 22 and 29 are null","Yes, if 15, 23 and 30 are null","Yes, if 16, 24 and 31 are null","Yes, if 17, 25 and 32 are null","Yes, if 18, 26 and 33 are null","Yes, if 19, 27 and 34 are null",No,,,"Yes, must be null if 45 = 2 or 3;
+no, if 45 = 1, 4 or 5",No,,,If 51 = 4,No,No,"Yes, if 52 is not 20",,"Selections are ((A or B or C)) - ((A, or B or C and F)) - ((F)) - ((G)) - ((H))",,,,,,No,,"Yes, if 65 = 1",,"Yes, if 63 and 64 contain full and valid entries",No,,,," If 69 = 1, select at least one of the 5 categories;
+If 69 = 2 or 3, then Null.",,,,,No,,,,,Only if 85 or 86 = 1,Yes,,,Only if 85 or 86 = 1,Only if fields 80 - 84 and 86 are not null,Only if fields 80 - 85 are not null,Only if field 48 = 3 or 9 ,"If 87 = 2 or 3;
+if 87 = 1, then a value must be entered",No,,,Yes,,,,No,,,"If the property is being let for the first time, enter 0.","Only if 1 = 2, 4, 6, 8, 10 or 12",,,,No,"Only if 1 = 2, 4, 6, 8, 10 or 12;
+or 106 = 15 - 17",No,"Only if 1 = 2, 4, 6, 8, 10 or 12",,,,No,,No,"Yes, if 45 = 2, 3 or 6",,"Yes, if 50 = 1","Only if 1 = 1, 3, 5, 7, 9 or 11",No,Yes,,,,,,,,,,Only if 1 = 1 - 4 or 9 - 12.,Only if 1 = 1 - 8.,Only if 130 is not 3,No,No,Yes,
+Bulk upload format and duplicate check,All lettings,Question removed from 22/23 onwards,,Supported housing only,,Question Removed from 2020/21,,,,,,Duplicate check field,,,,,,,,Duplicate check field,,,,,,,,,,,,,,,Duplicate check field,,,,,,,,,,,,,,,,,,,Question removed from 22/23 onwards,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,Duplicate check field,,,,,,,,,,,Question removed from 22/23 onwards,Duplicate check fields,,,,Duplicate check field,General Needs lettings only,,,All lettings,General Needs lettings only,All lettings,General Needs lettings only,,,Question removed from 2020/21,Duplicate check field, “Username does not exist”. ,,,Question removed from 21/22 onwards,,Supported Housing lettings only.,,,,,,,,,,,,Affordable Rent Lettings only,Intermediate Rent Lettings only,,All lettings,All lettings,,
+Bulk upload field number,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,
+,1,,,,,,123,1,2,,6,55,54,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
diff --git a/spec/fixtures/files/2022_23_sales_bulk_upload.csv b/spec/fixtures/files/2022_23_sales_bulk_upload.csv
new file mode 100644
index 000000000..b7ae570f7
--- /dev/null
+++ b/spec/fixtures/files/2022_23_sales_bulk_upload.csv
@@ -0,0 +1,119 @@
+Question,What is the purchaser code?,What is the day of the sale completion date? - DD,What is the month of the sale completion date? - MM,What is the year of the sale completion date? - YY,[BLANK],Was the buyer interviewed for any of the answers you will provide on this log?,Age of Buyer 1,Age of Buyer 2 or Person 2,Age of Person 3,Age of Person 4,Age of Person 5,Age of Person 6,Gender identity of Buyer 1,Gender identity of Buyer 2 or Person 2,Gender identity of Person 3,Gender identity of Person 4,Gender identity of Person 5,Gender identity of Person 6,Person 2's relationship to lead tenant,Person 3's relationship to lead tenant,Person 4's relationship to lead tenant,Person 5's relationship to lead tenant,Person 6's relationship to lead tenant,Working situation of Buyer 1,Working situation of Buyer 2 or Person 2,Working situation of Person 3,Working situation of Person 4,Working situation of Person 5,Working situation of Person 6,What is the buyer 1's ethnic group?,What is buyer 1's nationality?,What is buyer 1's gross annual income?,What is buyer 2's gross annual income?,Was buyer 1's income used for a mortgage application?,Was buyer 2's income used for a mortgage application?,"What is the total amount the buyers had in savings before they paid any deposit for the property?
+
+To the nearest £10",Have any of the buyers previously owned a property?,[BLANK],What was buyer 1's previous tenure?,What is the local authority of buyer 1's last settled home,Part 1 of postcode of buyer 1's last settled home,Part 2 of postcode of buyer 1's last settled home,Do you know the postcode of buyer 1's last settled home?,Was the buyer registered with their PRP (HA)?,Was the buyer registered with the local authority?,Was the buyer registered with a Help to Buy agent?,Was the buyer registered with another PRP (HA)?,Does anyone in the household consider themselves to have a disability?,Does anyone in the household use a wheelchair?,How many bedrooms does the property have?,What type of unit is the property?,Which type of building is the property?,What is the local authority of the property?,Part 1 of postcode of property,Part 2 of postcode of property,Is the property built or adapted to wheelchair-user standards?,What is the type of shared ownership sale?,"Is this a resale?
+
+Shared ownership","What is the day of the practical completion or handover date? - DD
+
+Shared ownership","What is the month of the practical completion or handover date? - MM
+
+Shared ownership","What is the year of the practical completion or handover date? - YY
+
+Shared ownership","What is the day of the exchange of contracts date? - DD
+
+Shared ownership","What is the month of the exchange of contracts date? - MM
+
+Shared ownership","What is the year of the exchange of contracts date? - YY
+
+Shared ownership","Was the household re-housed under a local authority nominations agreement?
+
+Shared ownership","How many bedrooms did the buyer's previous property have?
+
+Shared ownership","What was the type of the buyer's previous property?
+
+Shared ownership","What was the full purchase price?
+
+Shared ownership","What was the initial percentage equity stake purchased?
+
+Shared ownership","What is the mortgage amount?
+
+Shared ownership","Does this include any extra borrowing?
+
+Shared ownership","How much was the cash deposit paid on the property?
+
+Shared ownership","How much cash discount was given through Social Homebuy?
+
+Shared ownership","What is the basic monthly rent?
+
+Shared ownership","What are the total monthly leasehold charges for the property?
+
+Shared ownership",What is the type of discounted ownership sale?,"What was the full purchase price?
+
+Discounted ownership","What was the amount of any loan, grant, discount or subsidy given?
+
+Discounted ownership","What was the percentage discount?
+
+Discounted ownership","What is the mortgage amount?
+
+Discounted ownership","Does this include any extra borrowing?
+
+Discounted ownership","How much was the cash deposit paid on the property?
+
+Discounted ownership","What are the total monthly leasehold charges for the property?
+
+Discounted ownership",What is the type of outright sale?,"What is the 'other' type of outright sale?
+
+Outright sale",[BLANK],"What is the full purchase price?
+
+Outright sale","What is the mortgage amount?
+
+Outright sale","Does this include any extra borrowing?
+
+Outright sale","How much was the cash deposit paid on the property?
+
+Outright sale","What are the total monthly leasehold charges for the property?
+
+Outright sale","Which organisation owned this property before the sale?
+
+Organisation's CORE ID",Username,BLANK,Has the buyer ever served in the UK Armed Forces and for how long?,[BLANK],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?,"What is the name of the mortgage lender?
+
+Shared ownership","What is the name of the 'other' mortgage lender?
+
+Shared ownership","What is the name of the mortgage lender?
+
+Discounted ownership","What is the name of the 'other' mortgage lender?
+
+Discounted ownership","What is the name of the mortgage lender?
+
+Outright sale","What is the name of the 'other' mortgage lender?
+
+Outright sale",Were the buyers receiving any of these housing-related benefits immediately before buying this property?,"What is the length of the mortgage in years?
+
+Shared ownership","What is the length of the mortgage in years?
+
+Discounted ownership","What is the length of the mortgage in years?
+
+Outright sale","How long have the buyers been living in the property before the purchase?
+
+Discounted ownership",Are there more than two joint purchasers of this property?,"How long have the buyers been living in the property before the purchase?
+
+Shared ownership",Is this a staircasing transaction?,Data Protection question,Was this purchase made through an ownership scheme?,"Is the buyer a company?
+
+Outright sale",Will the buyers live in the property?,Is this a joint purchase?,Will buyer 1 live in the property?,Will buyer 2 live in the property?,"Besides the buyers, how many people live in the property?","What percentage of the property has been bought in this staircasing transaction?
+
+Shared ownership","What percentage of the property does the buyer now own in total?
+
+Shared ownership","What was the rent type of the buyer's previous property?
+
+Shared ownership","Was a mortgage used for the purchase of this property?
+
+Shared ownership","Was a mortgage used for the purchase of this property?
+
+Discounted ownership","Was a mortgage used for the purchase of this property?
+
+Outright sale"
+Values,Max 9 digits,1 - 31,1 - 12,19 - 23,,1 or null,"15 - 110
+or R",1 - 110 or R,,,,,"M, F, X or R",,,,,,"P, C, X or R",,,,,0 - 10,,,,,,1 - 19,"12 -13, 17 -19",0 - 99999,,1 or 2,1 or 2,0 - 999990,1 - 3,,1 - 7 or 9,ONS CODE - E + 9 digits,XXX(X),XXX,1 or null,,,,,1 - 3,1 - 3,1 - 9,1 - 4 or 9,1 or 2,ONS CODE E + 9 digits,XXX(X),XXX,1 - 3,"2, 16, 18, 24, 28 or 30-31",1 or 2,1 - 31,1 - 12,19 - 23,1 - 31,1 - 12,19 - 23,1 - 3,1 - 9,1 - 4 or 9,0 - 999999,0 - 100,0 - 999999,1 - 3,0 - 999999,,0 - 999.99,,"8, 9, 14, 21, 22, 27 or 29",0 - 999999,,0 - 100,0 - 999999,1 - 3,0 - 999999,0 - 999.99,10 or 12,,,0 - 999999,,1-3,0 - 999999,0-999.99,Up to 7 digits,Username of CORE account this sales log should be assigned to,,3 - 8,,4 - 7,1 - 40,,1 - 40,,1 - 40,,1 - 4, Integer <=60, Integer <=60, Integer <=60, Integer <=80,1 - 3, Integer <=80,1 - 3,1,1 - 3,1 - 2,1 - 2,1 - 2,1 - 2,1 - 2,0 - 5,1 - 100,1 - 100,1-3 or 9-10,1 - 2,1 - 2,1 - 2
+Can be Null?,No,,,,,No,No,"If fields 14, 19 and 25 are all also null","If fields 15, 20 and 26 are all also null","If fields 16, 21 and 27 are all also null","If fields 17, 22 and 28 are all also null","If fields 18, 23 and 29 are all also null",No,"If fields 8, 19 and 25 are all also null","If fields 9, 20 and 26 are also null","If fields 10, 21 and 27 are all also null","If fields 11, 22 and 28 are all also null","If fields 12, 23 and 29 are all also null","If fields 8, 14 and 25 are all also null","If fields 9, 15 and 26 are all also null","If fields 10, 16 and 27 are all also null","If fields 11, 17 and 28 are all also null","If fields 12, 18 and 29 are all also null",If field 6 = 1,"If fields 8, 14 and 19 are all also null","If fields 9, 15 and 20 are all also null","If fields 10, 16 and 21 are all also null","If fields 11, 17 and 22 are all also null","If fields 12, 18 and 23 are all also null",If field 6 = 1,,,If field 116 = 2,If field 32 is null,If field 116 = 2,If field 6 = 1,,,If field 6 = 1,No,If field 43 = 1,,If fields 41 and 42 BOTH have valid entries,Yes,,,,If field 6 = 1,,No,,,,,,,If field 113 = 2 or 3,,,,,,,,,"If field 113 = 2 or 3
+OR
+field 39 = 3 - 7 or 9",,If field 113 = 2 or 3,,,,,"If field 57 is null, 2, 16, 24 or 28",If field 113 = 2 or 3,,If field 113 = 1 or 3,If field 76 is null,"If field 76 is null, 9 or 14","If field 76 is null, 8, 21 or 22",If field 113 = 1 or 3,,,,If field 113 = 1 or 2,If field 84 is null or 10,,If field 113 = 1 or 2,,,,,No,Yes,,No,,No,If field 113 = 2 or 3,"If field 113 = 2 or 3
+OR
+If field 98 is not 40",If field 113 = 1 or 3,"If field 113 = 1 or 3
+OR
+If field 100 is not 40",If field 113 = 1 or 2,"If field 113 = 1 or 2
+OR
+If field 102 is not 40",No,If field 113 = 2 or 3,If field 113 = 1 or 3,If field 113 = 1 or 2,If field 113 = 1 or 3,If field 116 = 2,If field 113 = 2 or 3,If field 113 = 2 or 3,No,No,If field 113 = 1 or 2,If field 113 = 1 or 2,No,No,If field 116 = 2,No,If field 113 = 2 or 3,If field 113 = 2 or 3,"If field 113 = 1 or 2
+OR
+If field 39 = 3 - 9",If field 113 = 2 or 3,If field 113 = 1 or 3,If field 113 = 1 or 2
+Bulk upload format and duplicate check,Yes,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+Field number,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125
+,1,1,1,23,,1,30,,,,,,M,,,,,,,,,,,1,,,,,,1,18,20000,,1,,10000,2,,3,,EC1N,2TD,2,2,2,2,2,2,2,2,1,1,,,,2,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
diff --git a/spec/fixtures/files/lettings_logs_download.csv b/spec/fixtures/files/lettings_logs_download.csv
index 7600f0aad..5881f15ad 100644
--- a/spec/fixtures/files/lettings_logs_download.csv
+++ b/spec/fixtures/files/lettings_logs_download.csv
@@ -1,2 +1,2 @@
-id,status,created_at,updated_at,created_by_name,is_dpo,owning_organisation_name,managing_organisation_name,collection_start_year,needstype,renewal,startdate,rent_type_detail,irproduct_other,tenancycode,propcode,age1,sex1,ecstat1,hhmemb,relat2,age2,sex2,retirement_value_check,ecstat2,armedforces,leftreg,illness,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_h,is_previous_la_inferred,prevloc_label,prevloc,illness_type_1,illness_type_2,is_la_inferred,la_label,la,postcode_known,postcode_full,previous_la_known,wchair,preg_occ,cbl,earnings,incfreq,net_income_value_check,benefits,hb,period,brent,scharge,pscharge,supcharg,tcharge,offered,layear,ppostcode_full,mrcdate,declaration,ethnic,national,prevten,age3,sex3,ecstat3,age4,sex4,ecstat4,age5,sex5,ecstat5,age6,sex6,ecstat6,age7,sex7,ecstat7,age8,sex8,ecstat8,homeless,underoccupation_benefitcap,reservist,startertenancy,tenancylength,tenancy,rsnvac,unittype_gn,beds,waityear,reasonpref,chr,cap,reasonother,housingneeds_f,housingneeds_g,illness_type_3,illness_type_4,illness_type_8,illness_type_5,illness_type_6,illness_type_7,illness_type_9,illness_type_10,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,tenancyother,property_owner_organisation,property_manager_organisation,purchaser_code,reason,majorrepairs,hbrentshortfall,property_relet,incref,first_time_property_let_as_social_housing,unitletas,builtype,voiddate,renttype,lettype,totchild,totelder,totadult,net_income_known,nocharge,is_carehome,household_charge,referral,tshortfall,chcharge,ppcodenk,age1_known,age2_known,age3_known,age4_known,age5_known,age6_known,age7_known,age8_known,ethnic_group,letting_allocation_unknown,details_known_2,details_known_3,details_known_4,details_known_5,details_known_6,details_known_7,details_known_8,has_benefits,wrent,wscharge,wpschrge,wsupchrg,wtcharge,wtshortfall,refused,housingneeds,wchchrg,newprop,relat3,relat4,relat5,relat6,relat7,relat8,rent_value_check,old_form_id,lar,irproduct,old_id,joint,illness_type_0,tshortfall_known,sheltered,pregnancy_value_check,hhtype,new_old,vacdays,major_repairs_date_value_check,void_date_value_check,housingneeds_type,housingneeds_other,unresolved,updated_by_id,unittype_sh,scheme_code,scheme_service_name,scheme_sensitive,scheme_type,scheme_registered_under_care_act,scheme_owning_organisation_name,scheme_managing_organisation_name,scheme_primary_client_group,scheme_has_other_client_group,scheme_secondary_client_group,scheme_support_type,scheme_intended_stay,scheme_created_at,location_code,location_postcode,location_name,location_units,location_type_of_unit,location_mobility_type,location_admin_district,location_startdate
-{id},in_progress,2022-02-08 16:52:15 +0000,2022-02-08 16:52:15 +0000,Danny Rojas,No,DLUHC,DLUHC,2021,Supported housing,,2 October 2021,London Affordable Rent,,,,,,,,,,,,,,,,,,,,No,,,,,No,Westminster,E09000033,,SE1 1TE,,2,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,2,8,0,0,0,,0,,,,,,,,,,,,,,,,,,,,,,,,0,,,,,,,0,,,,,,,,,,,,,,,,,,,,9,1,,,,,,,,6,{scheme_code},{scheme_service_name},{scheme_sensitive},Missing,No,DLUHC,DLUHC,{scheme_primary_client_group},,{scheme_secondary_client_group},{scheme_support_type},{scheme_intended_stay},2021-04-01 00:00:00 +0100,{location_code},SE1 1TE,Downing Street,20,Bungalow,Fitted with equipment and adaptations,Westminster,{location_startdate}
+id,status,created_at,updated_at,created_by_name,is_dpo,owning_organisation_name,managing_organisation_name,collection_start_year,needstype,renewal,startdate,rent_type_detail,irproduct_other,tenancycode,propcode,age1,sex1,ecstat1,hhmemb,relat2,age2,sex2,retirement_value_check,ecstat2,armedforces,leftreg,illness,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_h,is_previous_la_inferred,prevloc_label,prevloc,illness_type_1,illness_type_2,is_la_inferred,la_label,la,postcode_known,postcode_full,previous_la_known,wchair,preg_occ,cbl,earnings,incfreq,net_income_value_check,benefits,hb,period,brent,scharge,pscharge,supcharg,tcharge,offered,layear,ppostcode_full,mrcdate,declaration,ethnic,national,prevten,age3,sex3,ecstat3,age4,sex4,ecstat4,age5,sex5,ecstat5,age6,sex6,ecstat6,age7,sex7,ecstat7,age8,sex8,ecstat8,homeless,underoccupation_benefitcap,reservist,startertenancy,tenancylength,tenancy,rsnvac,unittype_gn,beds,waityear,reasonpref,chr,cap,reasonother,housingneeds_f,housingneeds_g,illness_type_3,illness_type_4,illness_type_8,illness_type_5,illness_type_6,illness_type_7,illness_type_9,illness_type_10,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,tenancyother,property_owner_organisation,property_manager_organisation,purchaser_code,reason,majorrepairs,hbrentshortfall,property_relet,incref,first_time_property_let_as_social_housing,unitletas,builtype,voiddate,renttype,lettype,totchild,totelder,totadult,net_income_known,nocharge,is_carehome,household_charge,referral,tshortfall,chcharge,ppcodenk,age1_known,age2_known,age3_known,age4_known,age5_known,age6_known,age7_known,age8_known,ethnic_group,letting_allocation_unknown,details_known_2,details_known_3,details_known_4,details_known_5,details_known_6,details_known_7,details_known_8,has_benefits,wrent,wscharge,wpschrge,wsupchrg,wtcharge,wtshortfall,refused,housingneeds,wchchrg,newprop,relat3,relat4,relat5,relat6,relat7,relat8,rent_value_check,old_form_id,lar,irproduct,old_id,joint,tshortfall_known,sheltered,pregnancy_value_check,hhtype,new_old,vacdays,major_repairs_date_value_check,void_date_value_check,housingneeds_type,housingneeds_other,unresolved,updated_by_id,unittype_sh,scheme_code,scheme_service_name,scheme_sensitive,scheme_type,scheme_registered_under_care_act,scheme_owning_organisation_name,scheme_managing_organisation_name,scheme_primary_client_group,scheme_has_other_client_group,scheme_secondary_client_group,scheme_support_type,scheme_intended_stay,scheme_created_at,location_code,location_postcode,location_name,location_units,location_type_of_unit,location_mobility_type,location_admin_district,location_startdate
+{id},in_progress,2022-02-08 16:52:15 +0000,2022-02-08 16:52:15 +0000,Danny Rojas,No,DLUHC,DLUHC,2021,Supported housing,,2 October 2021,London Affordable Rent,,,,,,,,,,,,,,,,,,,,No,,,,,No,Westminster,E09000033,,SE1 1TE,,No,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,2,8,0,0,0,,0,,,,,,,,,,,,,,,,,,,,,,,,0,,,,,,,0,,,,,,,,,,,,,,,,,,,9,1,,,,,,,,6,{scheme_code},{scheme_service_name},{scheme_sensitive},Missing,No,DLUHC,DLUHC,{scheme_primary_client_group},,{scheme_secondary_client_group},{scheme_support_type},{scheme_intended_stay},2021-04-01 00:00:00 +0100,{location_code},SE1 1TE,Downing Street,20,Bungalow,Fitted with equipment and adaptations,Westminster,{location_startdate}
diff --git a/spec/fixtures/files/lettings_logs_download_non_support.csv b/spec/fixtures/files/lettings_logs_download_non_support.csv
index 0687c536e..c5bfb861e 100644
--- a/spec/fixtures/files/lettings_logs_download_non_support.csv
+++ b/spec/fixtures/files/lettings_logs_download_non_support.csv
@@ -1,2 +1,2 @@
-id,status,created_at,updated_at,created_by_name,is_dpo,owning_organisation_name,managing_organisation_name,collection_start_year,renewal,startdate,irproduct_other,tenancycode,propcode,age1,sex1,ecstat1,relat2,age2,sex2,ecstat2,armedforces,leftreg,illness,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_h,prevloc_label,illness_type_1,illness_type_2,la_label,postcode_full,wchair,preg_occ,cbl,earnings,incfreq,benefits,hb,period,brent,scharge,pscharge,supcharg,tcharge,offered,layear,ppostcode_full,mrcdate,declaration,ethnic,national,prevten,age3,sex3,ecstat3,age4,sex4,ecstat4,age5,sex5,ecstat5,age6,sex6,ecstat6,age7,sex7,ecstat7,age8,sex8,ecstat8,homeless,underoccupation_benefitcap,reservist,startertenancy,tenancylength,tenancy,rsnvac,unittype_gn,beds,waityear,reasonpref,chr,cap,reasonother,housingneeds_f,housingneeds_g,illness_type_3,illness_type_4,illness_type_8,illness_type_5,illness_type_6,illness_type_7,illness_type_9,illness_type_10,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,tenancyother,property_owner_organisation,property_manager_organisation,purchaser_code,reason,majorrepairs,hbrentshortfall,property_relet,incref,unitletas,builtype,voiddate,lettype,nocharge,household_charge,referral,tshortfall,chcharge,ppcodenk,ethnic_group,has_benefits,refused,housingneeds,wchchrg,newprop,relat3,relat4,relat5,relat6,relat7,relat8,lar,irproduct,joint,illness_type_0,sheltered,major_repairs_date_value_check,void_date_value_check,housingneeds_type,housingneeds_other,unittype_sh,scheme_code,scheme_service_name,scheme_sensitive,scheme_type,scheme_registered_under_care_act,scheme_owning_organisation_name,scheme_managing_organisation_name,scheme_primary_client_group,scheme_has_other_client_group,scheme_secondary_client_group,scheme_support_type,scheme_intended_stay,scheme_created_at,location_code,location_postcode,location_name,location_units,location_type_of_unit,location_mobility_type,location_admin_district,location_startdate
-{id},in_progress,2022-02-08 16:52:15 +0000,2022-02-08 16:52:15 +0000,Danny Rojas,No,DLUHC,DLUHC,2021,,2 October 2021,,,,,,,,,,,,,,,,,,,,,Westminster,SE1 1TE,2,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,8,0,,,,,,,0,0,,,,,,,,,,,,,,,,,,,6,{scheme_code},{scheme_service_name},{scheme_sensitive},Missing,No,DLUHC,DLUHC,{scheme_primary_client_group},,{scheme_secondary_client_group},{scheme_support_type},{scheme_intended_stay},2021-04-01 00:00:00 +0100,{location_code},SE1 1TE,Downing Street,20,Bungalow,Fitted with equipment and adaptations,Westminster,{location_startdate}
+id,status,created_at,updated_at,created_by_name,is_dpo,owning_organisation_name,managing_organisation_name,collection_start_year,renewal,startdate,irproduct_other,tenancycode,propcode,age1,sex1,ecstat1,relat2,age2,sex2,ecstat2,armedforces,leftreg,illness,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_h,prevloc_label,illness_type_1,illness_type_2,la_label,postcode_full,wchair,preg_occ,cbl,earnings,incfreq,benefits,hb,period,brent,scharge,pscharge,supcharg,tcharge,offered,layear,ppostcode_full,mrcdate,declaration,ethnic,national,prevten,age3,sex3,ecstat3,age4,sex4,ecstat4,age5,sex5,ecstat5,age6,sex6,ecstat6,age7,sex7,ecstat7,age8,sex8,ecstat8,homeless,underoccupation_benefitcap,reservist,startertenancy,tenancylength,tenancy,rsnvac,unittype_gn,beds,waityear,reasonpref,chr,cap,reasonother,housingneeds_f,housingneeds_g,illness_type_3,illness_type_4,illness_type_8,illness_type_5,illness_type_6,illness_type_7,illness_type_9,illness_type_10,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,tenancyother,property_owner_organisation,property_manager_organisation,purchaser_code,reason,majorrepairs,hbrentshortfall,property_relet,incref,unitletas,builtype,voiddate,lettype,nocharge,household_charge,referral,tshortfall,chcharge,ppcodenk,ethnic_group,has_benefits,refused,housingneeds,wchchrg,newprop,relat3,relat4,relat5,relat6,relat7,relat8,lar,irproduct,joint,sheltered,major_repairs_date_value_check,void_date_value_check,housingneeds_type,housingneeds_other,unittype_sh,scheme_code,scheme_service_name,scheme_sensitive,scheme_type,scheme_registered_under_care_act,scheme_owning_organisation_name,scheme_managing_organisation_name,scheme_primary_client_group,scheme_has_other_client_group,scheme_secondary_client_group,scheme_support_type,scheme_intended_stay,scheme_created_at,location_code,location_postcode,location_name,location_units,location_type_of_unit,location_mobility_type,location_admin_district,location_startdate
+{id},in_progress,2022-02-08 16:52:15 +0000,2022-02-08 16:52:15 +0000,Danny Rojas,No,DLUHC,DLUHC,2021,,2 October 2021,,,,,,,,,,,,,,,,,,,,,Westminster,SE1 1TE,No,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,8,0,,,,,,,0,0,,,,,,,,,,,,,,,,,,6,{scheme_code},{scheme_service_name},{scheme_sensitive},Missing,No,DLUHC,DLUHC,{scheme_primary_client_group},,{scheme_secondary_client_group},{scheme_support_type},{scheme_intended_stay},2021-04-01 00:00:00 +0100,{location_code},SE1 1TE,Downing Street,20,Bungalow,Fitted with equipment and adaptations,Westminster,{location_startdate}
diff --git a/spec/fixtures/forms/2021_2022.json b/spec/fixtures/forms/2021_2022.json
index 7b169e80a..ce01a82aa 100644
--- a/spec/fixtures/forms/2021_2022.json
+++ b/spec/fixtures/forms/2021_2022.json
@@ -152,11 +152,21 @@
"header": "What is person 2’s relationship to lead tenant",
"type": "radio",
"answer_options": {
+ "P": {
+ "value": "Partner"
+ },
+ "C": {
+ "value": "Child",
+ "hint": "Must be eligible for child benefit, aged under 16 or under 20 if still in full-time education."
+ },
"X": {
"value": "Other"
},
+ "divider": {
+ "value": true
+ },
"R": {
- "value": "Prefer not to say"
+ "value": "Person prefers not to say"
}
}
},
@@ -228,8 +238,29 @@
"header": "Which of these best describes person 2’s working situation?",
"type": "radio",
"answer_options": {
- "0": {
- "value": "Other"
+ "2": {
+ "value": "Part-time – Less than 30 hours"
+ },
+ "1": {
+ "value": "Full-time – 30 hours or more"
+ },
+ "7": {
+ "value": "Full-time student"
+ },
+ "3": {
+ "value": "In government training into work, such as New Deal"
+ },
+ "4": {
+ "value": "Jobseeker"
+ },
+ "6": {
+ "value": "Not seeking work"
+ },
+ "8": {
+ "value": "Unable to work because of long term sick or disability"
+ },
+ "5": {
+ "value": "Retired"
},
"9": {
"value": "Child under 16",
@@ -245,8 +276,14 @@
}
]
},
- "1": {
- "value": "Prefer not to say"
+ "0": {
+ "value": "Other"
+ },
+ "divider": {
+ "value": true
+ },
+ "10": {
+ "value": "Tenant prefers not to say"
}
}
}
@@ -530,10 +567,10 @@
"header": "Is the property built or adapted to wheelchair-user standards?",
"type": "radio",
"answer_options": {
- "0": {
+ "1": {
"value": "Yes"
},
- "1": {
+ "2": {
"value": "No"
}
}
@@ -756,11 +793,26 @@
"header": "Is the tenant likely to be in receipt of any of these housing-related benefits?",
"type": "radio",
"answer_options": {
- "0": {
+ "1": {
"value": "Housing benefit"
},
- "1": {
- "value": "Tenant prefers not to say"
+ "6": {
+ "value": "Universal Credit with housing element (excluding housing benefit)"
+ },
+ "8": {
+ "value": "Housing benefit and Universal Credit (without housing element)"
+ },
+ "7": {
+ "value": "Universal Credit (without housing element)"
+ },
+ "9": {
+ "value": "None"
+ },
+ "divider": {
+ "value": true
+ },
+ "3": {
+ "value": "Don’t know"
}
},
"conditional_for": {
@@ -818,11 +870,32 @@
"header": "Which period are rent and other charges due?",
"type": "radio",
"answer_options": {
- "1": {
- "value": "Weekly for 52 weeks"
+ "2": {
+ "value": "Every 2 weeks"
},
"3": {
"value": "Every 4 weeks"
+ },
+ "4": {
+ "value": "Every calendar month"
+ },
+ "5": {
+ "value": "Weekly for 50 weeks"
+ },
+ "6": {
+ "value": "Weekly for 49 weeks"
+ },
+ "7": {
+ "value": "Weekly for 48 weeks"
+ },
+ "8": {
+ "value": "Weekly for 47 weeks"
+ },
+ "9": {
+ "value": "Weekly for 46 weeks"
+ },
+ "1": {
+ "value": "Weekly for 52 weeks"
}
}
},
diff --git a/spec/helpers/filters_helper_spec.rb b/spec/helpers/filters_helper_spec.rb
index b19f044be..656578326 100644
--- a/spec/helpers/filters_helper_spec.rb
+++ b/spec/helpers/filters_helper_spec.rb
@@ -81,4 +81,39 @@ RSpec.describe FiltersHelper do
end
end
end
+
+ describe "#organisations_filter_options" do
+ let(:parent_organisation) { FactoryBot.create(:organisation, name: "Parent organisation") }
+ let(:child_organisation) { FactoryBot.create(:organisation, name: "Child organisation") }
+
+ before do
+ FactoryBot.create(:organisation_relationship, parent_organisation:, child_organisation:)
+ FactoryBot.create(:organisation, name: "Other organisation", id: 99)
+ end
+
+ context "with a support user" do
+ let(:user) { FactoryBot.create(:user, :support, organisation: parent_organisation) }
+
+ it "returns a list of all organisations" do
+ expect(organisations_filter_options(user)).to eq([
+ OpenStruct.new(id: "", name: "Select an option"),
+ OpenStruct.new(id: parent_organisation.id, name: "Parent organisation"),
+ OpenStruct.new(id: child_organisation.id, name: "Child organisation"),
+ OpenStruct.new(id: 99, name: "Other organisation"),
+ ])
+ end
+ end
+
+ context "with a data coordinator user" do
+ let(:user) { FactoryBot.create(:user, :data_coordinator, organisation: parent_organisation) }
+
+ it "returns a list of managing agents and your own organisation" do
+ expect(organisations_filter_options(user)).to eq([
+ OpenStruct.new(id: "", name: "Select an option"),
+ OpenStruct.new(id: parent_organisation.id, name: "Parent organisation"),
+ OpenStruct.new(id: child_organisation.id, name: "Child organisation"),
+ ])
+ end
+ end
+ end
end
diff --git a/spec/models/form/common/pages/created_by_spec.rb b/spec/models/form/common/pages/created_by_spec.rb
index 1f11a5889..db9561ac2 100644
--- a/spec/models/form/common/pages/created_by_spec.rb
+++ b/spec/models/form/common/pages/created_by_spec.rb
@@ -22,11 +22,11 @@ RSpec.describe Form::Common::Pages::CreatedBy, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
it "has the correct depends_on" do
diff --git a/spec/models/form/common/pages/organisation_spec.rb b/spec/models/form/common/pages/organisation_spec.rb
index ae7a1027c..bc56adbd7 100644
--- a/spec/models/form/common/pages/organisation_spec.rb
+++ b/spec/models/form/common/pages/organisation_spec.rb
@@ -22,11 +22,11 @@ RSpec.describe Form::Common::Pages::Organisation, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
it "has the correct depends_on" do
diff --git a/spec/models/form/common/questions/created_by_id_spec.rb b/spec/models/form/common/questions/created_by_id_spec.rb
index b00e21f90..dde117f43 100644
--- a/spec/models/form/common/questions/created_by_id_spec.rb
+++ b/spec/models/form/common/questions/created_by_id_spec.rb
@@ -39,7 +39,7 @@ RSpec.describe Form::Common::Questions::CreatedById, type: :model do
end
it "has the correct hint_text" do
- expect(question.hint_text).to eq("")
+ expect(question.hint_text).to be_nil
end
it "has the correct answer options" do
diff --git a/spec/models/form/common/questions/owning_organisation_id_spec.rb b/spec/models/form/common/questions/owning_organisation_id_spec.rb
index 9ee32e342..8b57bebe1 100644
--- a/spec/models/form/common/questions/owning_organisation_id_spec.rb
+++ b/spec/models/form/common/questions/owning_organisation_id_spec.rb
@@ -40,7 +40,7 @@ RSpec.describe Form::Common::Questions::OwningOrganisationId, type: :model do
end
it "has the correct hint_text" do
- expect(question.hint_text).to eq("")
+ expect(question.hint_text).to be_nil
end
it "has the correct answer options" do
diff --git a/spec/models/form/lettings/pages/created_by_spec.rb b/spec/models/form/lettings/pages/created_by_spec.rb
index c4fd460cb..b1ac0853e 100644
--- a/spec/models/form/lettings/pages/created_by_spec.rb
+++ b/spec/models/form/lettings/pages/created_by_spec.rb
@@ -42,11 +42,11 @@ RSpec.describe Form::Lettings::Pages::CreatedBy, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
it "has the correct depends_on" do
diff --git a/spec/models/form/lettings/pages/location_spec.rb b/spec/models/form/lettings/pages/location_spec.rb
index bdf08c244..85cfd0a21 100644
--- a/spec/models/form/lettings/pages/location_spec.rb
+++ b/spec/models/form/lettings/pages/location_spec.rb
@@ -20,11 +20,11 @@ RSpec.describe Form::Lettings::Pages::Location, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
it "has the correct depends_on" do
diff --git a/spec/models/form/lettings/pages/managing_organisation_spec.rb b/spec/models/form/lettings/pages/managing_organisation_spec.rb
index 01d6ba9b2..e6b2b95ee 100644
--- a/spec/models/form/lettings/pages/managing_organisation_spec.rb
+++ b/spec/models/form/lettings/pages/managing_organisation_spec.rb
@@ -21,11 +21,11 @@ RSpec.describe Form::Lettings::Pages::ManagingOrganisation, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
it "has the correct depends_on" do
diff --git a/spec/models/form/lettings/pages/needs_type_spec.rb b/spec/models/form/lettings/pages/needs_type_spec.rb
index 37978fdf8..1f0cabdfa 100644
--- a/spec/models/form/lettings/pages/needs_type_spec.rb
+++ b/spec/models/form/lettings/pages/needs_type_spec.rb
@@ -20,10 +20,10 @@ RSpec.describe Form::Lettings::Pages::NeedsType, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
end
diff --git a/spec/models/form/lettings/pages/property_reference_spec.rb b/spec/models/form/lettings/pages/property_reference_spec.rb
index cb2f2c76a..d412f9b8a 100644
--- a/spec/models/form/lettings/pages/property_reference_spec.rb
+++ b/spec/models/form/lettings/pages/property_reference_spec.rb
@@ -20,11 +20,11 @@ RSpec.describe Form::Lettings::Pages::PropertyReference, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
it "has the correct depends_on" do
diff --git a/spec/models/form/lettings/pages/renewal_spec.rb b/spec/models/form/lettings/pages/renewal_spec.rb
index 0fceb1a99..b4bfb213b 100644
--- a/spec/models/form/lettings/pages/renewal_spec.rb
+++ b/spec/models/form/lettings/pages/renewal_spec.rb
@@ -20,11 +20,11 @@ RSpec.describe Form::Lettings::Pages::Renewal, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
it "has the correct depends_on" do
diff --git a/spec/models/form/lettings/pages/rent_type_spec.rb b/spec/models/form/lettings/pages/rent_type_spec.rb
index 6541d542d..ffe9bf15f 100644
--- a/spec/models/form/lettings/pages/rent_type_spec.rb
+++ b/spec/models/form/lettings/pages/rent_type_spec.rb
@@ -20,10 +20,10 @@ RSpec.describe Form::Lettings::Pages::RentType, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
end
diff --git a/spec/models/form/lettings/pages/scheme_spec.rb b/spec/models/form/lettings/pages/scheme_spec.rb
index d369caf72..764ff34f0 100644
--- a/spec/models/form/lettings/pages/scheme_spec.rb
+++ b/spec/models/form/lettings/pages/scheme_spec.rb
@@ -20,10 +20,10 @@ RSpec.describe Form::Lettings::Pages::Scheme, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
end
diff --git a/spec/models/form/lettings/pages/stock_owner_spec.rb b/spec/models/form/lettings/pages/stock_owner_spec.rb
index ae66c829e..b90fe966e 100644
--- a/spec/models/form/lettings/pages/stock_owner_spec.rb
+++ b/spec/models/form/lettings/pages/stock_owner_spec.rb
@@ -21,11 +21,11 @@ RSpec.describe Form::Lettings::Pages::StockOwner, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
it "has the correct depends_on" do
diff --git a/spec/models/form/lettings/pages/tenancy_start_date_spec.rb b/spec/models/form/lettings/pages/tenancy_start_date_spec.rb
index 99597e428..8f8330395 100644
--- a/spec/models/form/lettings/pages/tenancy_start_date_spec.rb
+++ b/spec/models/form/lettings/pages/tenancy_start_date_spec.rb
@@ -24,7 +24,7 @@ RSpec.describe Form::Lettings::Pages::TenancyStartDate, type: :model do
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
it "has the correct depends_on" do
diff --git a/spec/models/form/lettings/pages/tenant_code_spec.rb b/spec/models/form/lettings/pages/tenant_code_spec.rb
index e91303bc3..724b93ad0 100644
--- a/spec/models/form/lettings/pages/tenant_code_spec.rb
+++ b/spec/models/form/lettings/pages/tenant_code_spec.rb
@@ -20,11 +20,11 @@ RSpec.describe Form::Lettings::Pages::TenantCode, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
it "has the correct depends_on" do
diff --git a/spec/models/form/lettings/questions/created_by_id_spec.rb b/spec/models/form/lettings/questions/created_by_id_spec.rb
index b1ee1de49..c82ec13e1 100644
--- a/spec/models/form/lettings/questions/created_by_id_spec.rb
+++ b/spec/models/form/lettings/questions/created_by_id_spec.rb
@@ -40,7 +40,7 @@ RSpec.describe Form::Lettings::Questions::CreatedById, type: :model do
end
it "has the correct hint_text" do
- expect(question.hint_text).to eq("")
+ expect(question.hint_text).to be_nil
end
it "has the correct answer options" do
diff --git a/spec/models/form/lettings/questions/location_id_spec.rb b/spec/models/form/lettings/questions/location_id_spec.rb
index ce723ce38..57495f4e7 100644
--- a/spec/models/form/lettings/questions/location_id_spec.rb
+++ b/spec/models/form/lettings/questions/location_id_spec.rb
@@ -39,7 +39,7 @@ RSpec.describe Form::Lettings::Questions::LocationId, type: :model do
context "when getting available locations" do
let(:scheme) { FactoryBot.create(:scheme) }
- let(:lettings_log) { FactoryBot.create(:lettings_log, owning_organisation: scheme.owning_organisation, scheme:, needstype: 2) }
+ let!(:lettings_log) { FactoryBot.create(:lettings_log, owning_organisation: scheme.owning_organisation, scheme:, needstype: 2) }
context "when there are no locations" do
it "the displayed_answer_options is an empty hash" do
diff --git a/spec/models/form/lettings/questions/renewal_spec.rb b/spec/models/form/lettings/questions/renewal_spec.rb
index 961d65153..820ff7c98 100644
--- a/spec/models/form/lettings/questions/renewal_spec.rb
+++ b/spec/models/form/lettings/questions/renewal_spec.rb
@@ -28,7 +28,7 @@ RSpec.describe Form::Lettings::Questions::Renewal, type: :model do
end
it "has the correct hint_text" do
- expect(question.hint_text).to eq("")
+ expect(question.hint_text).to be_nil
end
it "has the correct answer_options" do
diff --git a/spec/models/form/lettings/questions/rent_type_spec.rb b/spec/models/form/lettings/questions/rent_type_spec.rb
index 45906ec81..4609b0568 100644
--- a/spec/models/form/lettings/questions/rent_type_spec.rb
+++ b/spec/models/form/lettings/questions/rent_type_spec.rb
@@ -28,7 +28,7 @@ RSpec.describe Form::Lettings::Questions::RentType, type: :model do
end
it "has the correct hint_text" do
- expect(question.hint_text).to eq("")
+ expect(question.hint_text).to be_nil
end
it "has the correct conditional_for" do
diff --git a/spec/models/form/question_spec.rb b/spec/models/form/question_spec.rb
index 637407bc1..9d289bcb4 100644
--- a/spec/models/form/question_spec.rb
+++ b/spec/models/form/question_spec.rb
@@ -133,7 +133,19 @@ RSpec.describe Form::Question, type: :model do
let(:page_id) { "person_2_working_situation" }
let(:question_id) { "ecstat2" }
let(:expected_answer_options) do
- { "0" => { "value" => "Other" }, "1" => { "value" => "Prefer not to say" } }
+ {
+ "0" => { "value" => "Other" },
+ "1" => { "value" => "Full-time – 30 hours or more" },
+ "10" => { "value" => "Tenant prefers not to say" },
+ "2" => { "value" => "Part-time – Less than 30 hours" },
+ "3" => { "value" => "In government training into work, such as New Deal" },
+ "4" => { "value" => "Jobseeker" },
+ "5" => { "value" => "Retired" },
+ "6" => { "value" => "Not seeking work" },
+ "7" => { "value" => "Full-time student" },
+ "8" => { "value" => "Unable to work because of long term sick or disability" },
+ "divider" => { "value" => true },
+ }
end
it "does not include those options in the displayed options" do
diff --git a/spec/models/form/sales/pages/about_deposit_with_discount_spec.rb b/spec/models/form/sales/pages/about_deposit_with_discount_spec.rb
index 692f17a75..cc33a9641 100644
--- a/spec/models/form/sales/pages/about_deposit_with_discount_spec.rb
+++ b/spec/models/form/sales/pages/about_deposit_with_discount_spec.rb
@@ -24,7 +24,7 @@ RSpec.describe Form::Sales::Pages::AboutDepositWithDiscount, type: :model do
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
it "has correct depends_on" do
diff --git a/spec/models/form/sales/pages/about_deposit_without_discount_spec.rb b/spec/models/form/sales/pages/about_deposit_without_discount_spec.rb
index 07f9c983d..8d5bd84f2 100644
--- a/spec/models/form/sales/pages/about_deposit_without_discount_spec.rb
+++ b/spec/models/form/sales/pages/about_deposit_without_discount_spec.rb
@@ -24,7 +24,7 @@ RSpec.describe Form::Sales::Pages::AboutDepositWithoutDiscount, type: :model do
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
it "has correct depends_on" do
diff --git a/spec/models/form/sales/pages/about_price_not_rtb_spec.rb b/spec/models/form/sales/pages/about_price_not_rtb_spec.rb
index 584455d25..07d168368 100644
--- a/spec/models/form/sales/pages/about_price_not_rtb_spec.rb
+++ b/spec/models/form/sales/pages/about_price_not_rtb_spec.rb
@@ -24,7 +24,7 @@ RSpec.describe Form::Sales::Pages::AboutPriceNotRtb, type: :model do
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
it "has correct depends_on" do
diff --git a/spec/models/form/sales/pages/about_price_rtb_spec.rb b/spec/models/form/sales/pages/about_price_rtb_spec.rb
index 29e59f52c..c73a83b61 100644
--- a/spec/models/form/sales/pages/about_price_rtb_spec.rb
+++ b/spec/models/form/sales/pages/about_price_rtb_spec.rb
@@ -24,7 +24,7 @@ RSpec.describe Form::Sales::Pages::AboutPriceRtb, type: :model do
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
it "has correct depends_on" do
diff --git a/spec/models/form/sales/pages/about_price_shared_ownership_spec.rb b/spec/models/form/sales/pages/about_price_shared_ownership_spec.rb
index c4e8d6ccc..097a45298 100644
--- a/spec/models/form/sales/pages/about_price_shared_ownership_spec.rb
+++ b/spec/models/form/sales/pages/about_price_shared_ownership_spec.rb
@@ -24,7 +24,7 @@ RSpec.describe Form::Sales::Pages::AboutPriceSharedOwnership, type: :model do
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
it "has correct depends_on" do
diff --git a/spec/models/form/sales/pages/about_staircase_spec.rb b/spec/models/form/sales/pages/about_staircase_spec.rb
index 9fe34ba86..a2fba103e 100644
--- a/spec/models/form/sales/pages/about_staircase_spec.rb
+++ b/spec/models/form/sales/pages/about_staircase_spec.rb
@@ -24,7 +24,7 @@ RSpec.describe Form::Sales::Pages::AboutStaircase, type: :model do
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
it "has correct depends_on" do
diff --git a/spec/models/form/sales/pages/age1_spec.rb b/spec/models/form/sales/pages/age1_spec.rb
index c70143a68..0c8130bad 100644
--- a/spec/models/form/sales/pages/age1_spec.rb
+++ b/spec/models/form/sales/pages/age1_spec.rb
@@ -20,11 +20,11 @@ RSpec.describe Form::Sales::Pages::Age1, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
it "has correct depends_on" do
diff --git a/spec/models/form/sales/pages/age2_spec.rb b/spec/models/form/sales/pages/age2_spec.rb
index cc3e99189..eabb6a2e8 100644
--- a/spec/models/form/sales/pages/age2_spec.rb
+++ b/spec/models/form/sales/pages/age2_spec.rb
@@ -20,11 +20,11 @@ RSpec.describe Form::Sales::Pages::Age2, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
it "has correct depends_on" do
diff --git a/spec/models/form/sales/pages/armed_forces_spec.rb b/spec/models/form/sales/pages/armed_forces_spec.rb
index ac9c38e5d..542c94475 100644
--- a/spec/models/form/sales/pages/armed_forces_spec.rb
+++ b/spec/models/form/sales/pages/armed_forces_spec.rb
@@ -20,10 +20,10 @@ RSpec.describe Form::Sales::Pages::ArmedForces, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
end
diff --git a/spec/models/form/sales/pages/armed_forces_spouse_spec.rb b/spec/models/form/sales/pages/armed_forces_spouse_spec.rb
index 75be2b3f3..bf72a573c 100644
--- a/spec/models/form/sales/pages/armed_forces_spouse_spec.rb
+++ b/spec/models/form/sales/pages/armed_forces_spouse_spec.rb
@@ -20,10 +20,10 @@ RSpec.describe Form::Sales::Pages::ArmedForcesSpouse, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
end
diff --git a/spec/models/form/sales/pages/buyer1_ethnic_background_arab_spec.rb b/spec/models/form/sales/pages/buyer1_ethnic_background_arab_spec.rb
index 821874a0f..823c07592 100644
--- a/spec/models/form/sales/pages/buyer1_ethnic_background_arab_spec.rb
+++ b/spec/models/form/sales/pages/buyer1_ethnic_background_arab_spec.rb
@@ -20,11 +20,11 @@ RSpec.describe Form::Sales::Pages::Buyer1EthnicBackgroundArab, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
it "has correct depends_on" do
diff --git a/spec/models/form/sales/pages/buyer1_ethnic_background_asian_spec.rb b/spec/models/form/sales/pages/buyer1_ethnic_background_asian_spec.rb
index ad8b47846..dbb9e8478 100644
--- a/spec/models/form/sales/pages/buyer1_ethnic_background_asian_spec.rb
+++ b/spec/models/form/sales/pages/buyer1_ethnic_background_asian_spec.rb
@@ -20,11 +20,11 @@ RSpec.describe Form::Sales::Pages::Buyer1EthnicBackgroundAsian, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
it "has correct depends_on" do
diff --git a/spec/models/form/sales/pages/buyer1_ethnic_background_black_spec.rb b/spec/models/form/sales/pages/buyer1_ethnic_background_black_spec.rb
index 1f5618a0b..1b84a60d5 100644
--- a/spec/models/form/sales/pages/buyer1_ethnic_background_black_spec.rb
+++ b/spec/models/form/sales/pages/buyer1_ethnic_background_black_spec.rb
@@ -20,11 +20,11 @@ RSpec.describe Form::Sales::Pages::Buyer1EthnicBackgroundBlack, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
it "has correct depends_on" do
diff --git a/spec/models/form/sales/pages/buyer1_ethnic_background_mixed_spec.rb b/spec/models/form/sales/pages/buyer1_ethnic_background_mixed_spec.rb
index 648734242..9112ff4ac 100644
--- a/spec/models/form/sales/pages/buyer1_ethnic_background_mixed_spec.rb
+++ b/spec/models/form/sales/pages/buyer1_ethnic_background_mixed_spec.rb
@@ -20,11 +20,11 @@ RSpec.describe Form::Sales::Pages::Buyer1EthnicBackgroundMixed, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
it "has correct depends_on" do
diff --git a/spec/models/form/sales/pages/buyer1_ethnic_background_white_spec.rb b/spec/models/form/sales/pages/buyer1_ethnic_background_white_spec.rb
index 620918b0e..8a3796025 100644
--- a/spec/models/form/sales/pages/buyer1_ethnic_background_white_spec.rb
+++ b/spec/models/form/sales/pages/buyer1_ethnic_background_white_spec.rb
@@ -20,10 +20,10 @@ RSpec.describe Form::Sales::Pages::Buyer1EthnicBackgroundWhite, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
end
diff --git a/spec/models/form/sales/pages/buyer1_ethnic_group_spec.rb b/spec/models/form/sales/pages/buyer1_ethnic_group_spec.rb
index 406f78676..e6e6798f5 100644
--- a/spec/models/form/sales/pages/buyer1_ethnic_group_spec.rb
+++ b/spec/models/form/sales/pages/buyer1_ethnic_group_spec.rb
@@ -20,11 +20,11 @@ RSpec.describe Form::Sales::Pages::Buyer1EthnicGroup, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
it "has correct depends_on" do
diff --git a/spec/models/form/sales/pages/buyer1_income_spec.rb b/spec/models/form/sales/pages/buyer1_income_spec.rb
index a95a8ee5f..c56bbabaa 100644
--- a/spec/models/form/sales/pages/buyer1_income_spec.rb
+++ b/spec/models/form/sales/pages/buyer1_income_spec.rb
@@ -20,11 +20,11 @@ RSpec.describe Form::Sales::Pages::Buyer1Income, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
it "has correct depends_on" do
diff --git a/spec/models/form/sales/pages/buyer1_income_value_check_spec.rb b/spec/models/form/sales/pages/buyer1_income_value_check_spec.rb
index 18281533e..313708aaf 100644
--- a/spec/models/form/sales/pages/buyer1_income_value_check_spec.rb
+++ b/spec/models/form/sales/pages/buyer1_income_value_check_spec.rb
@@ -20,7 +20,7 @@ RSpec.describe Form::Sales::Pages::Buyer1IncomeValueCheck, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has correct depends_on" do
diff --git a/spec/models/form/sales/pages/buyer1_live_in_property_spec.rb b/spec/models/form/sales/pages/buyer1_live_in_property_spec.rb
index 2d3995d6b..444f14909 100644
--- a/spec/models/form/sales/pages/buyer1_live_in_property_spec.rb
+++ b/spec/models/form/sales/pages/buyer1_live_in_property_spec.rb
@@ -20,11 +20,11 @@ RSpec.describe Form::Sales::Pages::Buyer1LiveInProperty, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
it "has correct depends_on" do
diff --git a/spec/models/form/sales/pages/buyer1_mortgage_spec.rb b/spec/models/form/sales/pages/buyer1_mortgage_spec.rb
index d3aa2e1bb..dc19a16e2 100644
--- a/spec/models/form/sales/pages/buyer1_mortgage_spec.rb
+++ b/spec/models/form/sales/pages/buyer1_mortgage_spec.rb
@@ -20,11 +20,11 @@ RSpec.describe Form::Sales::Pages::Buyer1Mortgage, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
it "has correct depends_on" do
diff --git a/spec/models/form/sales/pages/buyer1_previous_tenure_spec.rb b/spec/models/form/sales/pages/buyer1_previous_tenure_spec.rb
index 462d72b00..e38f287f5 100644
--- a/spec/models/form/sales/pages/buyer1_previous_tenure_spec.rb
+++ b/spec/models/form/sales/pages/buyer1_previous_tenure_spec.rb
@@ -20,6 +20,6 @@ RSpec.describe Form::Sales::Pages::Buyer1PreviousTenure, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("What was buyer 1's previous tenure?")
+ expect(page.header).to be_nil
end
end
diff --git a/spec/models/form/sales/pages/buyer1_working_situation_spec.rb b/spec/models/form/sales/pages/buyer1_working_situation_spec.rb
index 4b432ed03..c8d911e18 100644
--- a/spec/models/form/sales/pages/buyer1_working_situation_spec.rb
+++ b/spec/models/form/sales/pages/buyer1_working_situation_spec.rb
@@ -20,6 +20,6 @@ RSpec.describe Form::Sales::Pages::Buyer1WorkingSituation, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
end
diff --git a/spec/models/form/sales/pages/buyer2_income_spec.rb b/spec/models/form/sales/pages/buyer2_income_spec.rb
index 0450ceed1..91f8b4014 100644
--- a/spec/models/form/sales/pages/buyer2_income_spec.rb
+++ b/spec/models/form/sales/pages/buyer2_income_spec.rb
@@ -20,11 +20,11 @@ RSpec.describe Form::Sales::Pages::Buyer2Income, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
it "has correct depends_on" do
diff --git a/spec/models/form/sales/pages/buyer2_live_in_property_spec.rb b/spec/models/form/sales/pages/buyer2_live_in_property_spec.rb
index 48b003d3c..34644241f 100644
--- a/spec/models/form/sales/pages/buyer2_live_in_property_spec.rb
+++ b/spec/models/form/sales/pages/buyer2_live_in_property_spec.rb
@@ -20,11 +20,11 @@ RSpec.describe Form::Sales::Pages::Buyer2LiveInProperty, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
it "has correct depends_on" do
diff --git a/spec/models/form/sales/pages/buyer2_mortgage_spec.rb b/spec/models/form/sales/pages/buyer2_mortgage_spec.rb
index ed51c0ae1..b71dc5c59 100644
--- a/spec/models/form/sales/pages/buyer2_mortgage_spec.rb
+++ b/spec/models/form/sales/pages/buyer2_mortgage_spec.rb
@@ -20,11 +20,11 @@ RSpec.describe Form::Sales::Pages::Buyer2Mortgage, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
it "has correct depends_on" do
diff --git a/spec/models/form/sales/pages/buyer2_relationship_to_buyer1_spec.rb b/spec/models/form/sales/pages/buyer2_relationship_to_buyer1_spec.rb
index 2e87764d6..eef011089 100644
--- a/spec/models/form/sales/pages/buyer2_relationship_to_buyer1_spec.rb
+++ b/spec/models/form/sales/pages/buyer2_relationship_to_buyer1_spec.rb
@@ -20,11 +20,11 @@ RSpec.describe Form::Sales::Pages::Buyer2RelationshipToBuyer1, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
it "has correct depends_on" do
diff --git a/spec/models/form/sales/pages/buyer2_working_situation_spec.rb b/spec/models/form/sales/pages/buyer2_working_situation_spec.rb
index ce001117a..fe339091b 100644
--- a/spec/models/form/sales/pages/buyer2_working_situation_spec.rb
+++ b/spec/models/form/sales/pages/buyer2_working_situation_spec.rb
@@ -20,11 +20,11 @@ RSpec.describe Form::Sales::Pages::Buyer2WorkingSituation, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
it "has correct depends_on" do
diff --git a/spec/models/form/sales/pages/buyer_company_spec.rb b/spec/models/form/sales/pages/buyer_company_spec.rb
index 7f7683e02..2551f8700 100644
--- a/spec/models/form/sales/pages/buyer_company_spec.rb
+++ b/spec/models/form/sales/pages/buyer_company_spec.rb
@@ -20,11 +20,11 @@ RSpec.describe Form::Sales::Pages::BuyerCompany, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
it "has correct depends_on" do
diff --git a/spec/models/form/sales/pages/buyer_interview_spec.rb b/spec/models/form/sales/pages/buyer_interview_spec.rb
index 1347fb782..ffc4c9a3a 100644
--- a/spec/models/form/sales/pages/buyer_interview_spec.rb
+++ b/spec/models/form/sales/pages/buyer_interview_spec.rb
@@ -20,10 +20,10 @@ RSpec.describe Form::Sales::Pages::BuyerInterview, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
end
diff --git a/spec/models/form/sales/pages/buyer_live_spec.rb b/spec/models/form/sales/pages/buyer_live_spec.rb
index 70bab20bd..685798f59 100644
--- a/spec/models/form/sales/pages/buyer_live_spec.rb
+++ b/spec/models/form/sales/pages/buyer_live_spec.rb
@@ -20,11 +20,11 @@ RSpec.describe Form::Sales::Pages::BuyerLive, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
it "has correct depends_on" do
diff --git a/spec/models/form/sales/pages/buyer_previous_spec.rb b/spec/models/form/sales/pages/buyer_previous_spec.rb
index 2954d54ae..a3355c137 100644
--- a/spec/models/form/sales/pages/buyer_previous_spec.rb
+++ b/spec/models/form/sales/pages/buyer_previous_spec.rb
@@ -20,10 +20,10 @@ RSpec.describe Form::Sales::Pages::BuyerPrevious, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
end
diff --git a/spec/models/form/sales/pages/buyer_still_serving_spec.rb b/spec/models/form/sales/pages/buyer_still_serving_spec.rb
index e5b26a52e..55a312119 100644
--- a/spec/models/form/sales/pages/buyer_still_serving_spec.rb
+++ b/spec/models/form/sales/pages/buyer_still_serving_spec.rb
@@ -20,11 +20,11 @@ RSpec.describe Form::Sales::Pages::BuyerStillServing, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
it "has correct depends_on" do
diff --git a/spec/models/form/sales/pages/buyers_organisations_spec.rb b/spec/models/form/sales/pages/buyers_organisations_spec.rb
index f245fe7f5..fb3e568de 100644
--- a/spec/models/form/sales/pages/buyers_organisations_spec.rb
+++ b/spec/models/form/sales/pages/buyers_organisations_spec.rb
@@ -20,11 +20,11 @@ RSpec.describe Form::Sales::Pages::BuyersOrganisations, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
it "has correct depends_on" do
diff --git a/spec/models/form/sales/pages/deposit_value_check_spec.rb b/spec/models/form/sales/pages/deposit_value_check_spec.rb
index 909215f2c..961a3b6ec 100644
--- a/spec/models/form/sales/pages/deposit_value_check_spec.rb
+++ b/spec/models/form/sales/pages/deposit_value_check_spec.rb
@@ -20,7 +20,7 @@ RSpec.describe Form::Sales::Pages::DepositValueCheck, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has correct depends_on" do
diff --git a/spec/models/form/sales/pages/discounted_ownership_type_spec.rb b/spec/models/form/sales/pages/discounted_ownership_type_spec.rb
index 4c44f7ac1..8951e3323 100644
--- a/spec/models/form/sales/pages/discounted_ownership_type_spec.rb
+++ b/spec/models/form/sales/pages/discounted_ownership_type_spec.rb
@@ -20,11 +20,11 @@ RSpec.describe Form::Sales::Pages::DiscountedOwnershipType, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
it "has correct depends_on" do
diff --git a/spec/models/form/sales/pages/exchange_date_spec.rb b/spec/models/form/sales/pages/exchange_date_spec.rb
index 21c4c3aab..8d3cc3d27 100644
--- a/spec/models/form/sales/pages/exchange_date_spec.rb
+++ b/spec/models/form/sales/pages/exchange_date_spec.rb
@@ -20,11 +20,11 @@ RSpec.describe Form::Sales::Pages::ExchangeDate, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
it "has the correct depends_on" do
diff --git a/spec/models/form/sales/pages/gender_identity1_spec.rb b/spec/models/form/sales/pages/gender_identity1_spec.rb
index fe4e4ff87..2b06f2349 100644
--- a/spec/models/form/sales/pages/gender_identity1_spec.rb
+++ b/spec/models/form/sales/pages/gender_identity1_spec.rb
@@ -20,11 +20,11 @@ RSpec.describe Form::Sales::Pages::GenderIdentity1, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
it "has correct depends_on" do
diff --git a/spec/models/form/sales/pages/gender_identity2_spec.rb b/spec/models/form/sales/pages/gender_identity2_spec.rb
index 0fdd96e27..7698f151c 100644
--- a/spec/models/form/sales/pages/gender_identity2_spec.rb
+++ b/spec/models/form/sales/pages/gender_identity2_spec.rb
@@ -20,11 +20,11 @@ RSpec.describe Form::Sales::Pages::GenderIdentity2, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
it "has correct depends_on" do
diff --git a/spec/models/form/sales/pages/handover_date_spec.rb b/spec/models/form/sales/pages/handover_date_spec.rb
index fed507969..fa2156cf7 100644
--- a/spec/models/form/sales/pages/handover_date_spec.rb
+++ b/spec/models/form/sales/pages/handover_date_spec.rb
@@ -20,11 +20,11 @@ RSpec.describe Form::Sales::Pages::HandoverDate, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
it "has the correct depends_on" do
diff --git a/spec/models/form/sales/pages/household_disability_spec.rb b/spec/models/form/sales/pages/household_disability_spec.rb
index 982bd797f..1838c7417 100644
--- a/spec/models/form/sales/pages/household_disability_spec.rb
+++ b/spec/models/form/sales/pages/household_disability_spec.rb
@@ -20,11 +20,11 @@ RSpec.describe Form::Sales::Pages::HouseholdDisability, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
it "has correct depends_on" do
diff --git a/spec/models/form/sales/pages/household_wheelchair_check_spec.rb b/spec/models/form/sales/pages/household_wheelchair_check_spec.rb
index c1388c7d3..5a6cb34f9 100644
--- a/spec/models/form/sales/pages/household_wheelchair_check_spec.rb
+++ b/spec/models/form/sales/pages/household_wheelchair_check_spec.rb
@@ -20,7 +20,7 @@ RSpec.describe Form::Sales::Pages::HouseholdWheelchairCheck, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has correct depends_on" do
diff --git a/spec/models/form/sales/pages/household_wheelchair_spec.rb b/spec/models/form/sales/pages/household_wheelchair_spec.rb
index f727bcbac..70a103507 100644
--- a/spec/models/form/sales/pages/household_wheelchair_spec.rb
+++ b/spec/models/form/sales/pages/household_wheelchair_spec.rb
@@ -20,11 +20,11 @@ RSpec.describe Form::Sales::Pages::HouseholdWheelchair, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
it "has correct depends_on" do
diff --git a/spec/models/form/sales/pages/housing_benefits_spec.rb b/spec/models/form/sales/pages/housing_benefits_spec.rb
index 477490c6e..9cf017bdc 100644
--- a/spec/models/form/sales/pages/housing_benefits_spec.rb
+++ b/spec/models/form/sales/pages/housing_benefits_spec.rb
@@ -20,11 +20,11 @@ RSpec.describe Form::Sales::Pages::HousingBenefits, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
it "has correct depends_on" do
diff --git a/spec/models/form/sales/pages/joint_purchase_spec.rb b/spec/models/form/sales/pages/joint_purchase_spec.rb
index 9140b19de..bd827d7f8 100644
--- a/spec/models/form/sales/pages/joint_purchase_spec.rb
+++ b/spec/models/form/sales/pages/joint_purchase_spec.rb
@@ -20,11 +20,11 @@ RSpec.describe Form::Sales::Pages::JointPurchase, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
it "has correct depends_on" do
diff --git a/spec/models/form/sales/pages/la_nominations_spec.rb b/spec/models/form/sales/pages/la_nominations_spec.rb
index 02b44ccb5..b7b40c2dd 100644
--- a/spec/models/form/sales/pages/la_nominations_spec.rb
+++ b/spec/models/form/sales/pages/la_nominations_spec.rb
@@ -20,10 +20,10 @@ RSpec.describe Form::Sales::Pages::LaNominations, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
end
diff --git a/spec/models/form/sales/pages/last_accommodation_la_spec.rb b/spec/models/form/sales/pages/last_accommodation_la_spec.rb
index 5b11779ad..fb3890cc6 100644
--- a/spec/models/form/sales/pages/last_accommodation_la_spec.rb
+++ b/spec/models/form/sales/pages/last_accommodation_la_spec.rb
@@ -20,11 +20,11 @@ RSpec.describe Form::Sales::Pages::LastAccommodationLa, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
it "has correct depends_on" do
diff --git a/spec/models/form/sales/pages/last_accommodation_spec.rb b/spec/models/form/sales/pages/last_accommodation_spec.rb
index 6e4a6468c..753aa7dc8 100644
--- a/spec/models/form/sales/pages/last_accommodation_spec.rb
+++ b/spec/models/form/sales/pages/last_accommodation_spec.rb
@@ -20,11 +20,11 @@ RSpec.describe Form::Sales::Pages::LastAccommodation, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
it "has correct depends_on" do
diff --git a/spec/models/form/sales/pages/leasehold_charges_spec.rb b/spec/models/form/sales/pages/leasehold_charges_spec.rb
index d35d1076b..c729bc82e 100644
--- a/spec/models/form/sales/pages/leasehold_charges_spec.rb
+++ b/spec/models/form/sales/pages/leasehold_charges_spec.rb
@@ -20,11 +20,11 @@ RSpec.describe Form::Sales::Pages::LeaseholdCharges, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
it "has correct depends_on" do
diff --git a/spec/models/form/sales/pages/living_before_purchase_spec.rb b/spec/models/form/sales/pages/living_before_purchase_spec.rb
index b01e381e8..435229831 100644
--- a/spec/models/form/sales/pages/living_before_purchase_spec.rb
+++ b/spec/models/form/sales/pages/living_before_purchase_spec.rb
@@ -20,11 +20,11 @@ RSpec.describe Form::Sales::Pages::LivingBeforePurchase, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
it "has correct depends_on" do
diff --git a/spec/models/form/sales/pages/monthly_rent_spec.rb b/spec/models/form/sales/pages/monthly_rent_spec.rb
index 8d953e248..b1cddac37 100644
--- a/spec/models/form/sales/pages/monthly_rent_spec.rb
+++ b/spec/models/form/sales/pages/monthly_rent_spec.rb
@@ -20,11 +20,11 @@ RSpec.describe Form::Sales::Pages::MonthlyRent, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
it "has correct depends_on" do
diff --git a/spec/models/form/sales/pages/mortgage_amount_spec.rb b/spec/models/form/sales/pages/mortgage_amount_spec.rb
index 4df02d1af..1aa563d9b 100644
--- a/spec/models/form/sales/pages/mortgage_amount_spec.rb
+++ b/spec/models/form/sales/pages/mortgage_amount_spec.rb
@@ -24,7 +24,7 @@ RSpec.describe Form::Sales::Pages::MortgageAmount, type: :model do
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
it "has correct depends_on" do
diff --git a/spec/models/form/sales/pages/mortgage_lender_other_spec.rb b/spec/models/form/sales/pages/mortgage_lender_other_spec.rb
new file mode 100644
index 000000000..32ad5bb6b
--- /dev/null
+++ b/spec/models/form/sales/pages/mortgage_lender_other_spec.rb
@@ -0,0 +1,35 @@
+require "rails_helper"
+
+RSpec.describe Form::Sales::Pages::MortgageLenderOther, type: :model do
+ subject(:page) { described_class.new(page_id, page_definition, subsection) }
+
+ let(:page_id) { "mortgage_lender_other" }
+ let(:page_definition) { nil }
+ let(:subsection) { instance_double(Form::Subsection) }
+
+ it "has correct subsection" do
+ expect(page.subsection).to eq(subsection)
+ end
+
+ it "has correct questions" do
+ expect(page.questions.map(&:id)).to eq(%w[mortgagelenderother])
+ end
+
+ it "has the correct id" do
+ expect(page.id).to eq("mortgage_lender_other")
+ end
+
+ it "has the correct header" do
+ expect(page.header).to eq("")
+ end
+
+ it "has the correct description" do
+ expect(page.description).to eq("")
+ end
+
+ it "has correct depends_on" do
+ expect(page.depends_on).to eq([{
+ "mortgagelender" => 40,
+ }])
+ end
+end
diff --git a/spec/models/form/sales/pages/mortgage_lender_spec.rb b/spec/models/form/sales/pages/mortgage_lender_spec.rb
new file mode 100644
index 000000000..430e7ea1c
--- /dev/null
+++ b/spec/models/form/sales/pages/mortgage_lender_spec.rb
@@ -0,0 +1,33 @@
+require "rails_helper"
+
+RSpec.describe Form::Sales::Pages::MortgageLender, type: :model do
+ subject(:page) { described_class.new(page_id, page_definition, subsection) }
+
+ let(:page_id) { "mortgage_lender" }
+ let(:page_definition) { nil }
+ let(:subsection) { instance_double(Form::Subsection) }
+
+ it "has correct subsection" do
+ expect(page.subsection).to eq(subsection)
+ end
+
+ it "has correct questions" do
+ expect(page.questions.map(&:id)).to eq(%w[mortgagelender])
+ end
+
+ it "has the correct id" do
+ expect(page.id).to eq("mortgage_lender")
+ end
+
+ it "has the correct header" do
+ expect(page.header).to eq("")
+ end
+
+ it "has the correct description" do
+ expect(page.description).to eq("")
+ end
+
+ it "has correct depends_on" do
+ expect(page.depends_on).to be_nil
+ end
+end
diff --git a/spec/models/form/sales/pages/mortgage_length_spec.rb b/spec/models/form/sales/pages/mortgage_length_spec.rb
index 002fb49cf..bc63bc178 100644
--- a/spec/models/form/sales/pages/mortgage_length_spec.rb
+++ b/spec/models/form/sales/pages/mortgage_length_spec.rb
@@ -20,11 +20,11 @@ RSpec.describe Form::Sales::Pages::MortgageLength, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
it "has correct depends_on" do
diff --git a/spec/models/form/sales/pages/mortgage_value_check_spec.rb b/spec/models/form/sales/pages/mortgage_value_check_spec.rb
index b39daa468..bd6c0bdf5 100644
--- a/spec/models/form/sales/pages/mortgage_value_check_spec.rb
+++ b/spec/models/form/sales/pages/mortgage_value_check_spec.rb
@@ -20,7 +20,7 @@ RSpec.describe Form::Sales::Pages::MortgageValueCheck, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has correct depends_on" do
diff --git a/spec/models/form/sales/pages/mortgageused_spec.rb b/spec/models/form/sales/pages/mortgageused_spec.rb
index bbeadd301..963814074 100644
--- a/spec/models/form/sales/pages/mortgageused_spec.rb
+++ b/spec/models/form/sales/pages/mortgageused_spec.rb
@@ -20,10 +20,10 @@ RSpec.describe Form::Sales::Pages::Mortgageused, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
end
diff --git a/spec/models/form/sales/pages/nationality1_spec.rb b/spec/models/form/sales/pages/nationality1_spec.rb
index 5d156e041..c39fecdd2 100644
--- a/spec/models/form/sales/pages/nationality1_spec.rb
+++ b/spec/models/form/sales/pages/nationality1_spec.rb
@@ -20,11 +20,11 @@ RSpec.describe Form::Sales::Pages::Nationality1, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
it "has correct depends_on" do
diff --git a/spec/models/form/sales/pages/number_joint_buyers_spec.rb b/spec/models/form/sales/pages/number_joint_buyers_spec.rb
index 149f081c4..674bf2883 100644
--- a/spec/models/form/sales/pages/number_joint_buyers_spec.rb
+++ b/spec/models/form/sales/pages/number_joint_buyers_spec.rb
@@ -20,11 +20,11 @@ RSpec.describe Form::Sales::Pages::NumberJointBuyers, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
it "has correct depends_on" do
diff --git a/spec/models/form/sales/pages/number_of_others_in_property_spec.rb b/spec/models/form/sales/pages/number_of_others_in_property_spec.rb
index 4d7f6862b..c2efdcb21 100644
--- a/spec/models/form/sales/pages/number_of_others_in_property_spec.rb
+++ b/spec/models/form/sales/pages/number_of_others_in_property_spec.rb
@@ -20,10 +20,10 @@ RSpec.describe Form::Sales::Pages::NumberOfOthersInProperty, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
end
diff --git a/spec/models/form/sales/pages/outright_ownership_type_spec.rb b/spec/models/form/sales/pages/outright_ownership_type_spec.rb
index e7629bbf8..5ca515cc9 100644
--- a/spec/models/form/sales/pages/outright_ownership_type_spec.rb
+++ b/spec/models/form/sales/pages/outright_ownership_type_spec.rb
@@ -20,11 +20,11 @@ RSpec.describe Form::Sales::Pages::OutrightOwnershipType, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
it "has correct depends_on" do
diff --git a/spec/models/form/sales/pages/ownership_scheme_spec.rb b/spec/models/form/sales/pages/ownership_scheme_spec.rb
index 7199c618b..4b27c9279 100644
--- a/spec/models/form/sales/pages/ownership_scheme_spec.rb
+++ b/spec/models/form/sales/pages/ownership_scheme_spec.rb
@@ -20,10 +20,10 @@ RSpec.describe Form::Sales::Pages::OwnershipScheme, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
end
diff --git a/spec/models/form/sales/pages/person_age_spec.rb b/spec/models/form/sales/pages/person_age_spec.rb
index f8bc96692..1a7d9087a 100644
--- a/spec/models/form/sales/pages/person_age_spec.rb
+++ b/spec/models/form/sales/pages/person_age_spec.rb
@@ -13,11 +13,11 @@ RSpec.describe Form::Sales::Pages::PersonAge, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
context "with a non joint purchase" do
diff --git a/spec/models/form/sales/pages/person_gender_identity_spec.rb b/spec/models/form/sales/pages/person_gender_identity_spec.rb
index 0aefdd3f4..4161832cf 100644
--- a/spec/models/form/sales/pages/person_gender_identity_spec.rb
+++ b/spec/models/form/sales/pages/person_gender_identity_spec.rb
@@ -15,11 +15,11 @@ RSpec.describe Form::Sales::Pages::PersonGenderIdentity, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
context "with person 1" do
@@ -99,11 +99,11 @@ RSpec.describe Form::Sales::Pages::PersonGenderIdentity, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
context "with person 1" do
diff --git a/spec/models/form/sales/pages/person_known_spec.rb b/spec/models/form/sales/pages/person_known_spec.rb
index bb73d6b63..a5afafb7e 100644
--- a/spec/models/form/sales/pages/person_known_spec.rb
+++ b/spec/models/form/sales/pages/person_known_spec.rb
@@ -14,11 +14,11 @@ RSpec.describe Form::Sales::Pages::PersonKnown, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
context "with person 1" do
@@ -127,11 +127,11 @@ RSpec.describe Form::Sales::Pages::PersonKnown, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
context "with person 1" do
diff --git a/spec/models/form/sales/pages/person_relationship_to_buyer1_spec.rb b/spec/models/form/sales/pages/person_relationship_to_buyer1_spec.rb
index 419e5a92d..f3a4896bc 100644
--- a/spec/models/form/sales/pages/person_relationship_to_buyer1_spec.rb
+++ b/spec/models/form/sales/pages/person_relationship_to_buyer1_spec.rb
@@ -15,11 +15,11 @@ RSpec.describe Form::Sales::Pages::PersonRelationshipToBuyer1, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
context "with person 1" do
@@ -99,11 +99,11 @@ RSpec.describe Form::Sales::Pages::PersonRelationshipToBuyer1, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
context "with person 1" do
diff --git a/spec/models/form/sales/pages/person_working_situation_spec.rb b/spec/models/form/sales/pages/person_working_situation_spec.rb
index 65bdb42d0..baad4b69b 100644
--- a/spec/models/form/sales/pages/person_working_situation_spec.rb
+++ b/spec/models/form/sales/pages/person_working_situation_spec.rb
@@ -15,11 +15,11 @@ RSpec.describe Form::Sales::Pages::PersonWorkingSituation, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
context "with person 1" do
@@ -99,11 +99,11 @@ RSpec.describe Form::Sales::Pages::PersonWorkingSituation, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
context "with person 1" do
diff --git a/spec/models/form/sales/pages/postcode_spec.rb b/spec/models/form/sales/pages/postcode_spec.rb
new file mode 100644
index 000000000..485411414
--- /dev/null
+++ b/spec/models/form/sales/pages/postcode_spec.rb
@@ -0,0 +1,33 @@
+require "rails_helper"
+
+RSpec.describe Form::Sales::Pages::Postcode, type: :model do
+ subject(:page) { described_class.new(page_id, page_definition, subsection) }
+
+ let(:page_id) { nil }
+ let(:page_definition) { nil }
+ let(:subsection) { instance_double(Form::Subsection) }
+
+ it "has correct subsection" do
+ expect(page.subsection).to eq(subsection)
+ end
+
+ it "has correct questions" do
+ expect(page.questions.map(&:id)).to eq(%w[pcodenk postcode_full])
+ end
+
+ it "has the correct id" do
+ expect(page.id).to eq("property_postcode")
+ end
+
+ it "has the correct header" do
+ expect(page.header).to be_nil
+ end
+
+ it "has the correct description" do
+ expect(page.description).to be_nil
+ end
+
+ it "has correct depends_on" do
+ expect(page.depends_on).to be_nil
+ end
+end
diff --git a/spec/models/form/sales/pages/previous_bedrooms_spec.rb b/spec/models/form/sales/pages/previous_bedrooms_spec.rb
index 6fb8c3c5b..5e1e18a52 100644
--- a/spec/models/form/sales/pages/previous_bedrooms_spec.rb
+++ b/spec/models/form/sales/pages/previous_bedrooms_spec.rb
@@ -24,7 +24,7 @@ RSpec.describe Form::Sales::Pages::PreviousBedrooms, type: :model do
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
it "has correct depends_on" do
diff --git a/spec/models/form/sales/pages/previous_ownership_spec.rb b/spec/models/form/sales/pages/previous_ownership_spec.rb
index 59d8611da..7fe0d2795 100644
--- a/spec/models/form/sales/pages/previous_ownership_spec.rb
+++ b/spec/models/form/sales/pages/previous_ownership_spec.rb
@@ -20,10 +20,10 @@ RSpec.describe Form::Sales::Pages::PreviousOwnership, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
end
diff --git a/spec/models/form/sales/pages/previous_property_type_spec.rb b/spec/models/form/sales/pages/previous_property_type_spec.rb
new file mode 100644
index 000000000..4cfae3b1c
--- /dev/null
+++ b/spec/models/form/sales/pages/previous_property_type_spec.rb
@@ -0,0 +1,35 @@
+require "rails_helper"
+
+RSpec.describe Form::Sales::Pages::PreviousPropertyType, type: :model do
+ subject(:page) { described_class.new(page_id, page_definition, subsection) }
+
+ let(:page_id) { nil }
+ let(:page_definition) { nil }
+ let(:subsection) { instance_double(Form::Subsection) }
+
+ it "has correct subsection" do
+ expect(page.subsection).to eq(subsection)
+ end
+
+ it "has correct questions" do
+ expect(page.questions.map(&:id)).to eq(%w[fromprop])
+ end
+
+ it "has the correct id" do
+ expect(page.id).to eq("previous_property_type")
+ end
+
+ it "has the correct header" do
+ expect(page.header).to eq("")
+ end
+
+ it "has the correct description" do
+ expect(page.description).to eq("")
+ end
+
+ it "has correct depends_on" do
+ expect(page.depends_on).to eq([{
+ "soctenant" => 1,
+ }])
+ end
+end
diff --git a/spec/models/form/sales/pages/previous_tenure_spec.rb b/spec/models/form/sales/pages/previous_tenure_spec.rb
new file mode 100644
index 000000000..a4892d567
--- /dev/null
+++ b/spec/models/form/sales/pages/previous_tenure_spec.rb
@@ -0,0 +1,35 @@
+require "rails_helper"
+
+RSpec.describe Form::Sales::Pages::PreviousTenure, type: :model do
+ subject(:page) { described_class.new(page_id, page_definition, subsection) }
+
+ let(:page_id) { nil }
+ let(:page_definition) { nil }
+ let(:subsection) { instance_double(Form::Subsection) }
+
+ it "has correct subsection" do
+ expect(page.subsection).to eq(subsection)
+ end
+
+ it "has correct questions" do
+ expect(page.questions.map(&:id)).to eq(%w[socprevten])
+ end
+
+ it "has the correct id" do
+ expect(page.id).to eq("shared_ownership_previous_tenure")
+ end
+
+ it "has the correct header" do
+ expect(page.header).to eq("")
+ end
+
+ it "has the correct description" do
+ expect(page.description).to eq("")
+ end
+
+ it "has correct depends_on" do
+ expect(page.depends_on).to eq([{
+ "soctenant" => 1,
+ }])
+ end
+end
diff --git a/spec/models/form/sales/pages/privacy_notice_spec.rb b/spec/models/form/sales/pages/privacy_notice_spec.rb
index 8a8de04f1..86a214bfa 100644
--- a/spec/models/form/sales/pages/privacy_notice_spec.rb
+++ b/spec/models/form/sales/pages/privacy_notice_spec.rb
@@ -24,7 +24,7 @@ RSpec.describe Form::Sales::Pages::PrivacyNotice, type: :model do
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
it "has correct depends_on" do
diff --git a/spec/models/form/sales/pages/property_building_type_spec.rb b/spec/models/form/sales/pages/property_building_type_spec.rb
index fb5420105..b4bb43171 100644
--- a/spec/models/form/sales/pages/property_building_type_spec.rb
+++ b/spec/models/form/sales/pages/property_building_type_spec.rb
@@ -20,10 +20,10 @@ RSpec.describe Form::Sales::Pages::PropertyBuildingType, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
end
diff --git a/spec/models/form/sales/pages/property_local_authority_spec.rb b/spec/models/form/sales/pages/property_local_authority_spec.rb
index 17b840186..3c88a0cd6 100644
--- a/spec/models/form/sales/pages/property_local_authority_spec.rb
+++ b/spec/models/form/sales/pages/property_local_authority_spec.rb
@@ -25,10 +25,16 @@ RSpec.describe Form::Sales::Pages::PropertyLocalAuthority, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
+ end
+
+ it "has the correct depends_on" do
+ expect(page.depends_on).to eq([{
+ "is_la_inferred" => false,
+ }])
end
end
diff --git a/spec/models/form/sales/pages/property_number_of_bedrooms_spec.rb b/spec/models/form/sales/pages/property_number_of_bedrooms_spec.rb
index 078694916..1f905091f 100644
--- a/spec/models/form/sales/pages/property_number_of_bedrooms_spec.rb
+++ b/spec/models/form/sales/pages/property_number_of_bedrooms_spec.rb
@@ -20,10 +20,10 @@ RSpec.describe Form::Sales::Pages::PropertyNumberOfBedrooms, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
end
diff --git a/spec/models/form/sales/pages/property_unit_type_spec.rb b/spec/models/form/sales/pages/property_unit_type_spec.rb
index b9e9aa450..0944589f6 100644
--- a/spec/models/form/sales/pages/property_unit_type_spec.rb
+++ b/spec/models/form/sales/pages/property_unit_type_spec.rb
@@ -20,10 +20,10 @@ RSpec.describe Form::Sales::Pages::PropertyUnitType, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
end
diff --git a/spec/models/form/sales/pages/property_wheelchair_accessible_spec.rb b/spec/models/form/sales/pages/property_wheelchair_accessible_spec.rb
index f2ffb3567..f83bb7907 100644
--- a/spec/models/form/sales/pages/property_wheelchair_accessible_spec.rb
+++ b/spec/models/form/sales/pages/property_wheelchair_accessible_spec.rb
@@ -20,10 +20,10 @@ RSpec.describe Form::Sales::Pages::PropertyWheelchairAccessible, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
end
diff --git a/spec/models/form/sales/pages/purchase_price_spec.rb b/spec/models/form/sales/pages/purchase_price_spec.rb
index f6cdef219..ab4cb6789 100644
--- a/spec/models/form/sales/pages/purchase_price_spec.rb
+++ b/spec/models/form/sales/pages/purchase_price_spec.rb
@@ -20,11 +20,11 @@ RSpec.describe Form::Sales::Pages::PurchasePrice, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
it "has correct depends_on" do
diff --git a/spec/models/form/sales/pages/purchaser_code_spec.rb b/spec/models/form/sales/pages/purchaser_code_spec.rb
index 05ee6becc..4abbd4d6b 100644
--- a/spec/models/form/sales/pages/purchaser_code_spec.rb
+++ b/spec/models/form/sales/pages/purchaser_code_spec.rb
@@ -20,10 +20,10 @@ RSpec.describe Form::Sales::Pages::PurchaserCode, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
end
diff --git a/spec/models/form/sales/pages/resale_spec.rb b/spec/models/form/sales/pages/resale_spec.rb
index ce2e81182..4e0a42094 100644
--- a/spec/models/form/sales/pages/resale_spec.rb
+++ b/spec/models/form/sales/pages/resale_spec.rb
@@ -20,11 +20,11 @@ RSpec.describe Form::Sales::Pages::Resale, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
it "has the correct depends_on" do
diff --git a/spec/models/form/sales/pages/sale_date_spec.rb b/spec/models/form/sales/pages/sale_date_spec.rb
index 7f78182a8..40fd51729 100644
--- a/spec/models/form/sales/pages/sale_date_spec.rb
+++ b/spec/models/form/sales/pages/sale_date_spec.rb
@@ -20,10 +20,10 @@ RSpec.describe Form::Sales::Pages::SaleDate, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
end
diff --git a/spec/models/form/sales/pages/savings_spec.rb b/spec/models/form/sales/pages/savings_spec.rb
index 37093da26..aaf3f86c4 100644
--- a/spec/models/form/sales/pages/savings_spec.rb
+++ b/spec/models/form/sales/pages/savings_spec.rb
@@ -20,11 +20,11 @@ RSpec.describe Form::Sales::Pages::Savings, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
it "has correct depends_on" do
diff --git a/spec/models/form/sales/pages/savings_value_check_spec.rb b/spec/models/form/sales/pages/savings_value_check_spec.rb
index d40862da9..d4334118d 100644
--- a/spec/models/form/sales/pages/savings_value_check_spec.rb
+++ b/spec/models/form/sales/pages/savings_value_check_spec.rb
@@ -20,7 +20,7 @@ RSpec.describe Form::Sales::Pages::SavingsValueCheck, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has correct depends_on" do
diff --git a/spec/models/form/sales/pages/shared_ownership_type_spec.rb b/spec/models/form/sales/pages/shared_ownership_type_spec.rb
index 7a7f71f8e..b8b71080f 100644
--- a/spec/models/form/sales/pages/shared_ownership_type_spec.rb
+++ b/spec/models/form/sales/pages/shared_ownership_type_spec.rb
@@ -20,11 +20,11 @@ RSpec.describe Form::Sales::Pages::SharedOwnershipType, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
it "has correct depends_on" do
diff --git a/spec/models/form/sales/pages/staircase_spec.rb b/spec/models/form/sales/pages/staircase_spec.rb
index d2155f972..4518fffbe 100644
--- a/spec/models/form/sales/pages/staircase_spec.rb
+++ b/spec/models/form/sales/pages/staircase_spec.rb
@@ -20,10 +20,10 @@ RSpec.describe Form::Sales::Pages::Staircase, type: :model do
end
it "has the correct header" do
- expect(page.header).to eq("")
+ expect(page.header).to be_nil
end
it "has the correct description" do
- expect(page.description).to eq("")
+ expect(page.description).to be_nil
end
end
diff --git a/spec/models/form/sales/questions/armed_forces_spouse_spec.rb b/spec/models/form/sales/questions/armed_forces_spouse_spec.rb
index 67bf934ff..d3cc9bccc 100644
--- a/spec/models/form/sales/questions/armed_forces_spouse_spec.rb
+++ b/spec/models/form/sales/questions/armed_forces_spouse_spec.rb
@@ -32,7 +32,7 @@ RSpec.describe Form::Sales::Questions::ArmedForcesSpouse, type: :model do
end
it "has the correct hint" do
- expect(question.hint_text).to eq("")
+ expect(question.hint_text).to be_nil
end
it "has the correct answer_options" do
diff --git a/spec/models/form/sales/questions/buyer2_live_in_property_spec.rb b/spec/models/form/sales/questions/buyer2_live_in_property_spec.rb
index 0a5ae3699..c2d276c44 100644
--- a/spec/models/form/sales/questions/buyer2_live_in_property_spec.rb
+++ b/spec/models/form/sales/questions/buyer2_live_in_property_spec.rb
@@ -32,7 +32,7 @@ RSpec.describe Form::Sales::Questions::Buyer2LiveInProperty, type: :model do
end
it "has the correct hint" do
- expect(question.hint_text).to eq("")
+ expect(question.hint_text).to be_nil
end
it "has the correct answer_options" do
diff --git a/spec/models/form/sales/questions/buyer2_relationship_to_buyer1_spec.rb b/spec/models/form/sales/questions/buyer2_relationship_to_buyer1_spec.rb
index 742c12ac0..059e5c084 100644
--- a/spec/models/form/sales/questions/buyer2_relationship_to_buyer1_spec.rb
+++ b/spec/models/form/sales/questions/buyer2_relationship_to_buyer1_spec.rb
@@ -32,7 +32,7 @@ RSpec.describe Form::Sales::Questions::Buyer2RelationshipToBuyer1, type: :model
end
it "has the correct hint" do
- expect(question.hint_text).to eq("")
+ expect(question.hint_text).to be_nil
end
it "has the correct answer_options" do
diff --git a/spec/models/form/sales/questions/buyer2_working_situation_spec.rb b/spec/models/form/sales/questions/buyer2_working_situation_spec.rb
index 02b7a76b0..75b6fd7cb 100644
--- a/spec/models/form/sales/questions/buyer2_working_situation_spec.rb
+++ b/spec/models/form/sales/questions/buyer2_working_situation_spec.rb
@@ -32,7 +32,7 @@ RSpec.describe Form::Sales::Questions::Buyer2WorkingSituation, type: :model do
end
it "has the correct hint" do
- expect(question.hint_text).to eq("")
+ expect(question.hint_text).to be_nil
end
it "has the correct answer_options" do
diff --git a/spec/models/form/sales/questions/buyer_company_spec.rb b/spec/models/form/sales/questions/buyer_company_spec.rb
index 1d7d98940..714aa0986 100644
--- a/spec/models/form/sales/questions/buyer_company_spec.rb
+++ b/spec/models/form/sales/questions/buyer_company_spec.rb
@@ -28,7 +28,7 @@ RSpec.describe Form::Sales::Questions::BuyerCompany, type: :model do
end
it "has the correct hint_text" do
- expect(question.hint_text).to eq("")
+ expect(question.hint_text).to be_nil
end
it "has the correct answer_options" do
diff --git a/spec/models/form/sales/questions/buyer_still_serving_spec.rb b/spec/models/form/sales/questions/buyer_still_serving_spec.rb
index e5d91572e..887944a89 100644
--- a/spec/models/form/sales/questions/buyer_still_serving_spec.rb
+++ b/spec/models/form/sales/questions/buyer_still_serving_spec.rb
@@ -32,7 +32,7 @@ RSpec.describe Form::Sales::Questions::BuyerStillServing, type: :model do
end
it "has the correct hint" do
- expect(question.hint_text).to eq("")
+ expect(question.hint_text).to be_nil
end
it "has the correct answer_options" do
diff --git a/spec/models/form/sales/questions/fromprop_spec.rb b/spec/models/form/sales/questions/fromprop_spec.rb
new file mode 100644
index 000000000..ebfa218c5
--- /dev/null
+++ b/spec/models/form/sales/questions/fromprop_spec.rb
@@ -0,0 +1,47 @@
+require "rails_helper"
+
+RSpec.describe Form::Sales::Questions::Fromprop, type: :model do
+ subject(:question) { described_class.new(question_id, question_definition, page) }
+
+ let(:question_id) { nil }
+ let(:question_definition) { nil }
+ let(:page) { instance_double(Form::Page) }
+
+ it "has correct page" do
+ expect(question.page).to eq(page)
+ end
+
+ it "has the correct id" do
+ expect(question.id).to eq("fromprop")
+ end
+
+ it "has the correct header" do
+ expect(question.header).to eq("What was the previous property type?")
+ end
+
+ it "has the correct check_answer_label" do
+ expect(question.check_answer_label).to eq("Previous property type")
+ end
+
+ it "has the correct type" do
+ expect(question.type).to eq("radio")
+ end
+
+ it "is not marked as derived" do
+ expect(question.derived?).to be false
+ end
+
+ it "has the correct hint" do
+ expect(question.hint_text).to eq("")
+ end
+
+ it "has the correct answer_options" do
+ expect(question.answer_options).to eq({
+ "1" => { "value" => "Flat or maisonette" },
+ "2" => { "value" => "Bedsit" },
+ "3" => { "value" => "House" },
+ "4" => { "value" => "Bungalow" },
+ "9" => { "value" => "Other" },
+ })
+ end
+end
diff --git a/spec/models/form/sales/questions/gender_identity1_spec.rb b/spec/models/form/sales/questions/gender_identity1_spec.rb
index 16ab43df5..2abe952ed 100644
--- a/spec/models/form/sales/questions/gender_identity1_spec.rb
+++ b/spec/models/form/sales/questions/gender_identity1_spec.rb
@@ -40,7 +40,7 @@ RSpec.describe Form::Sales::Questions::GenderIdentity1, type: :model do
"F" => { "value" => "Female" },
"M" => { "value" => "Male" },
"X" => { "value" => "Non-binary" },
- "R" => { "value" => "Prefers not to say " },
+ "R" => { "value" => "Prefers not to say" },
})
end
diff --git a/spec/models/form/sales/questions/housing_benefits_spec.rb b/spec/models/form/sales/questions/housing_benefits_spec.rb
index 5579f3b48..8c3ae57d3 100644
--- a/spec/models/form/sales/questions/housing_benefits_spec.rb
+++ b/spec/models/form/sales/questions/housing_benefits_spec.rb
@@ -32,7 +32,7 @@ RSpec.describe Form::Sales::Questions::HousingBenefits, type: :model do
end
it "has the correct hint" do
- expect(question.hint_text).to eq("")
+ expect(question.hint_text).to be_nil
end
it "has the correct answer_options" do
diff --git a/spec/models/form/sales/questions/joint_purchase_spec.rb b/spec/models/form/sales/questions/joint_purchase_spec.rb
index c9f548071..5d738531c 100644
--- a/spec/models/form/sales/questions/joint_purchase_spec.rb
+++ b/spec/models/form/sales/questions/joint_purchase_spec.rb
@@ -32,7 +32,7 @@ RSpec.describe Form::Sales::Questions::JointPurchase, type: :model do
end
it "has the correct hint_text" do
- expect(question.hint_text).to eq("")
+ expect(question.hint_text).to be_nil
end
it "has the correct answer_options" do
diff --git a/spec/models/form/sales/questions/mortgage_amount_spec.rb b/spec/models/form/sales/questions/mortgage_amount_spec.rb
index ac1e5ad5e..eadec2876 100644
--- a/spec/models/form/sales/questions/mortgage_amount_spec.rb
+++ b/spec/models/form/sales/questions/mortgage_amount_spec.rb
@@ -32,7 +32,7 @@ RSpec.describe Form::Sales::Questions::MortgageAmount, type: :model do
end
it "has the correct hint" do
- expect(question.hint_text).to eq("")
+ expect(question.hint_text).to be_nil
end
it "has correct width" do
diff --git a/spec/models/form/sales/questions/mortgage_lender_other_spec.rb b/spec/models/form/sales/questions/mortgage_lender_other_spec.rb
new file mode 100644
index 000000000..e5a8a3869
--- /dev/null
+++ b/spec/models/form/sales/questions/mortgage_lender_other_spec.rb
@@ -0,0 +1,37 @@
+require "rails_helper"
+
+RSpec.describe Form::Sales::Questions::MortgageLenderOther, type: :model do
+ subject(:question) { described_class.new(question_id, question_definition, page) }
+
+ let(:question_id) { nil }
+ let(:question_definition) { nil }
+ let(:page) { instance_double(Form::Page) }
+
+ it "has correct page" do
+ expect(question.page).to eq(page)
+ end
+
+ it "has the correct id" do
+ expect(question.id).to eq("mortgagelenderother")
+ end
+
+ it "has the correct header" do
+ expect(question.header).to eq("What is the other mortgage lender?")
+ end
+
+ it "has the correct check_answer_label" do
+ expect(question.check_answer_label).to eq("Other Mortgage Lender")
+ end
+
+ it "has the correct type" do
+ expect(question.type).to eq("text")
+ end
+
+ it "is not marked as derived" do
+ expect(question.derived?).to be false
+ end
+
+ it "has the correct hint" do
+ expect(question.hint_text).to be_nil
+ end
+end
diff --git a/spec/models/form/sales/questions/mortgage_lender_spec.rb b/spec/models/form/sales/questions/mortgage_lender_spec.rb
new file mode 100644
index 000000000..659cf7070
--- /dev/null
+++ b/spec/models/form/sales/questions/mortgage_lender_spec.rb
@@ -0,0 +1,88 @@
+require "rails_helper"
+
+RSpec.describe Form::Sales::Questions::MortgageLender, type: :model do
+ subject(:question) { described_class.new(question_id, question_definition, page) }
+
+ let(:question_id) { nil }
+ let(:question_definition) { nil }
+ let(:page) { instance_double(Form::Page) }
+
+ it "has correct page" do
+ expect(question.page).to eq(page)
+ end
+
+ it "has the correct id" do
+ expect(question.id).to eq("mortgagelender")
+ end
+
+ it "has the correct header" do
+ expect(question.header).to eq("What is the name of the mortgage lender?")
+ end
+
+ it "has the correct check_answer_label" do
+ expect(question.check_answer_label).to eq("Mortgage Lender")
+ end
+
+ it "has the correct type" do
+ expect(question.type).to eq("select")
+ end
+
+ it "is not marked as derived" do
+ expect(question.derived?).to be false
+ end
+
+ it "is has correct guidance_position" do
+ expect(question.top_guidance?).to be false
+ expect(question.bottom_guidance?).to be true
+ end
+
+ it "is has correct guidance_partial" do
+ expect(question.guidance_partial).to eq("mortgage_lender")
+ end
+
+ it "has the correct answer_options" do
+ expect(question.answer_options).to eq({
+ "" => "Select an option",
+ "1" => "Atom Bank",
+ "2" => "Barclays Bank PLC",
+ "3" => "Bath Building Society",
+ "4" => "Buckinghamshire Building Society",
+ "5" => "Cambridge Building Society",
+ "6" => "Coventry Building Society",
+ "7" => "Cumberland Building Society",
+ "8" => "Darlington Building Society",
+ "9" => "Dudley Building Society",
+ "10" => "Ecology Building Society",
+ "11" => "Halifax",
+ "12" => "Hanley Economic Building Society",
+ "13" => "Hinckley and Rugby Building Society",
+ "14" => "Holmesdale Building Society",
+ "15" => "Ipswich Building Society",
+ "16" => "Leeds Building Society",
+ "17" => "Lloyds Bank",
+ "18" => "Mansfield Building Society",
+ "19" => "Market Harborough Building Society",
+ "20" => "Melton Mowbray Building Society",
+ "21" => "Nationwide Building Society",
+ "22" => "Natwest",
+ "23" => "Nedbank Private Wealth",
+ "24" => "Newbury Building Society",
+ "25" => "OneSavings Bank",
+ "26" => "Parity Trust",
+ "27" => "Penrith Building Society",
+ "28" => "Pepper Homeloans",
+ "29" => "Royal Bank of Scotland",
+ "30" => "Santander",
+ "31" => "Skipton Building Society",
+ "32" => "Teachers Building Society",
+ "33" => "The Co-operative Bank",
+ "34" => "Tipton & Coseley Building Society",
+ "35" => "TSB",
+ "36" => "Ulster Bank",
+ "37" => "Virgin Money",
+ "38" => "West Bromwich Building Society",
+ "39" => "Yorkshire Building Society",
+ "40" => "Other",
+ })
+ end
+end
diff --git a/spec/models/form/sales/questions/mortgage_length_spec.rb b/spec/models/form/sales/questions/mortgage_length_spec.rb
index 273c13c7b..519289607 100644
--- a/spec/models/form/sales/questions/mortgage_length_spec.rb
+++ b/spec/models/form/sales/questions/mortgage_length_spec.rb
@@ -32,7 +32,7 @@ RSpec.describe Form::Sales::Questions::MortgageLength, type: :model do
end
it "has the correct hint" do
- expect(question.hint_text).to eq("")
+ expect(question.hint_text).to be_nil
end
it "has correct width" do
diff --git a/spec/models/form/sales/questions/mortgageused_spec.rb b/spec/models/form/sales/questions/mortgageused_spec.rb
index 19f41102d..e958de8ea 100644
--- a/spec/models/form/sales/questions/mortgageused_spec.rb
+++ b/spec/models/form/sales/questions/mortgageused_spec.rb
@@ -43,6 +43,6 @@ RSpec.describe Form::Sales::Questions::Mortgageused, type: :model do
end
it "has the correct hint" do
- expect(question.hint_text).to eq("")
+ expect(question.hint_text).to be_nil
end
end
diff --git a/spec/models/form/sales/questions/person_age_known_spec.rb b/spec/models/form/sales/questions/person_age_known_spec.rb
index 2cc760fc5..d61bccfc3 100644
--- a/spec/models/form/sales/questions/person_age_known_spec.rb
+++ b/spec/models/form/sales/questions/person_age_known_spec.rb
@@ -32,7 +32,7 @@ RSpec.describe Form::Sales::Questions::PersonAgeKnown, type: :model do
end
it "has the correct hint" do
- expect(question.hint_text).to eq("")
+ expect(question.hint_text).to be_nil
end
context "with a non joint purchase" do
diff --git a/spec/models/form/sales/questions/person_known_spec.rb b/spec/models/form/sales/questions/person_known_spec.rb
index 551ac096e..9cb7ab578 100644
--- a/spec/models/form/sales/questions/person_known_spec.rb
+++ b/spec/models/form/sales/questions/person_known_spec.rb
@@ -32,7 +32,7 @@ RSpec.describe Form::Sales::Questions::PersonKnown, type: :model do
end
it "has the correct hint" do
- expect(question.hint_text).to eq("")
+ expect(question.hint_text).to be_nil
end
context "with a non joint purchase" do
diff --git a/spec/models/form/sales/questions/postcode_known_spec.rb b/spec/models/form/sales/questions/postcode_known_spec.rb
new file mode 100644
index 000000000..b6c404c56
--- /dev/null
+++ b/spec/models/form/sales/questions/postcode_known_spec.rb
@@ -0,0 +1,59 @@
+require "rails_helper"
+
+RSpec.describe Form::Sales::Questions::PostcodeKnown, type: :model do
+ subject(:question) { described_class.new(question_id, question_definition, page) }
+
+ let(:question_id) { nil }
+ let(:question_definition) { nil }
+ let(:page) { instance_double(Form::Page) }
+
+ it "has correct page" do
+ expect(question.page).to eq(page)
+ end
+
+ it "has the correct id" do
+ expect(question.id).to eq("pcodenk")
+ end
+
+ it "has the correct header" do
+ expect(question.header).to eq("Do you know the property’s postcode?")
+ end
+
+ it "has the correct check_answer_label" do
+ expect(question.check_answer_label).to eq("Property’s postcode")
+ end
+
+ it "has the correct type" do
+ expect(question.type).to eq("radio")
+ end
+
+ it "is not marked as derived" do
+ expect(question.derived?).to be false
+ end
+
+ it "has the correct answer_options" do
+ expect(question.answer_options).to eq({
+ "0" => { "value" => "Yes" },
+ "1" => { "value" => "No" },
+ })
+ end
+
+ it "has correct conditional for" do
+ expect(question.conditional_for).to eq({
+ "postcode_full" => [0],
+ })
+ end
+
+ it "has the correct hint" do
+ expect(question.hint_text).to be_nil
+ end
+
+ it "has the correct hidden_in_check_answers" do
+ expect(question.hidden_in_check_answers).to eq({
+ "depends_on" => [
+ { "pcodenk" => 0 },
+ { "pcodenk" => 1 },
+ ],
+ })
+ end
+end
diff --git a/spec/models/form/sales/questions/postcode_spec.rb b/spec/models/form/sales/questions/postcode_spec.rb
new file mode 100644
index 000000000..b0d7eefcb
--- /dev/null
+++ b/spec/models/form/sales/questions/postcode_spec.rb
@@ -0,0 +1,58 @@
+require "rails_helper"
+
+RSpec.describe Form::Sales::Questions::Postcode, type: :model do
+ subject(:question) { described_class.new(question_id, question_definition, page) }
+
+ let(:question_id) { nil }
+ let(:question_definition) { nil }
+ let(:page) { instance_double(Form::Page) }
+
+ it "has correct page" do
+ expect(question.page).to eq(page)
+ end
+
+ it "has the correct id" do
+ expect(question.id).to eq("postcode_full")
+ end
+
+ it "has the correct header" do
+ expect(question.header).to eq("Postcode")
+ end
+
+ it "has the correct check_answer_label" do
+ expect(question.check_answer_label).to eq("Property’s postcode")
+ end
+
+ it "has the correct type" do
+ expect(question.type).to eq("text")
+ end
+
+ it "is not marked as derived" do
+ expect(question.derived?).to be false
+ end
+
+ it "has the correct hint" do
+ expect(question.hint_text).to be_nil
+ end
+
+ it "has the correct width" do
+ expect(question.width).to eq(5)
+ end
+
+ it "has the correct inferred_answers" do
+ expect(question.inferred_answers).to eq({
+ "la" => {
+ "is_la_inferred" => true,
+ },
+ })
+ end
+
+ it "has the correct inferred_check_answers_value" do
+ expect(question.inferred_check_answers_value).to eq({
+ "condition" => {
+ "pcodenk" => 1,
+ },
+ "value" => "Not known",
+ })
+ end
+end
diff --git a/spec/models/form/sales/questions/previous_postcode_spec.rb b/spec/models/form/sales/questions/previous_postcode_spec.rb
index cb763dc81..eb55b7cf1 100644
--- a/spec/models/form/sales/questions/previous_postcode_spec.rb
+++ b/spec/models/form/sales/questions/previous_postcode_spec.rb
@@ -32,7 +32,7 @@ RSpec.describe Form::Sales::Questions::PreviousPostcode, type: :model do
end
it "has the correct hint" do
- expect(question.hint_text).to eq("")
+ expect(question.hint_text).to be_nil
end
it "has the correct width" do
diff --git a/spec/models/form/sales/questions/previous_tenure_spec.rb b/spec/models/form/sales/questions/previous_tenure_spec.rb
new file mode 100644
index 000000000..fde61271f
--- /dev/null
+++ b/spec/models/form/sales/questions/previous_tenure_spec.rb
@@ -0,0 +1,47 @@
+require "rails_helper"
+
+RSpec.describe Form::Sales::Questions::PreviousTenure, type: :model do
+ subject(:question) { described_class.new(question_id, question_definition, page) }
+
+ let(:question_id) { nil }
+ let(:question_definition) { nil }
+ let(:page) { instance_double(Form::Page) }
+
+ it "has correct page" do
+ expect(question.page).to eq(page)
+ end
+
+ it "has the correct id" do
+ expect(question.id).to eq("socprevten")
+ end
+
+ it "has the correct header" do
+ expect(question.header).to eq("What was the previous tenure of the buyer?")
+ end
+
+ it "has the correct check_answer_label" do
+ expect(question.check_answer_label).to eq("Previous property tenure")
+ end
+
+ it "has the correct type" do
+ expect(question.type).to eq("radio")
+ end
+
+ it "is not marked as derived" do
+ expect(question.derived?).to be false
+ end
+
+ it "has the correct hint" do
+ expect(question.hint_text).to eq("")
+ end
+
+ it "has the correct answer_options" do
+ expect(question.answer_options).to eq({
+ "1" => { "value" => "Social Rent" },
+ "2" => { "value" => "Affordable Rent" },
+ "3" => { "value" => "London Affordable Rent" },
+ "9" => { "value" => "Other" },
+ "10" => { "value" => "Don’t know" },
+ })
+ end
+end
diff --git a/spec/models/form/sales/questions/prevown_spec.rb b/spec/models/form/sales/questions/prevown_spec.rb
index b98ba77ef..dda2b7c70 100644
--- a/spec/models/form/sales/questions/prevown_spec.rb
+++ b/spec/models/form/sales/questions/prevown_spec.rb
@@ -44,6 +44,6 @@ RSpec.describe Form::Sales::Questions::Prevown, type: :model do
end
it "has the correct hint" do
- expect(question.hint_text).to eq("")
+ expect(question.hint_text).to be_nil
end
end
diff --git a/spec/models/form/sales/questions/privacy_notice_spec.rb b/spec/models/form/sales/questions/privacy_notice_spec.rb
index f90daef1b..fc1df796c 100644
--- a/spec/models/form/sales/questions/privacy_notice_spec.rb
+++ b/spec/models/form/sales/questions/privacy_notice_spec.rb
@@ -32,7 +32,7 @@ RSpec.describe Form::Sales::Questions::PrivacyNotice, type: :model do
end
it "has the correct hint" do
- expect(question.hint_text).to eq("")
+ expect(question.hint_text).to be_nil
end
it "has the correct answer_options" do
diff --git a/spec/models/form/sales/questions/property_building_type_spec.rb b/spec/models/form/sales/questions/property_building_type_spec.rb
index 1129bf792..9b8f94b5f 100644
--- a/spec/models/form/sales/questions/property_building_type_spec.rb
+++ b/spec/models/form/sales/questions/property_building_type_spec.rb
@@ -32,7 +32,7 @@ RSpec.describe Form::Sales::Questions::PropertyBuildingType, type: :model do
end
it "has the correct hint_text" do
- expect(question.hint_text).to eq("")
+ expect(question.hint_text).to be_nil
end
it "has the correct answer_options" do
diff --git a/spec/models/form/sales/questions/purchase_price_spec.rb b/spec/models/form/sales/questions/purchase_price_spec.rb
index 1ee30b9a5..8894a592f 100644
--- a/spec/models/form/sales/questions/purchase_price_spec.rb
+++ b/spec/models/form/sales/questions/purchase_price_spec.rb
@@ -32,7 +32,7 @@ RSpec.describe Form::Sales::Questions::PurchasePrice, type: :model do
end
it "has the correct hint" do
- expect(question.hint_text).to eq("")
+ expect(question.hint_text).to be_nil
end
it "has correct width" do
diff --git a/spec/models/form/sales/questions/savings_nk_spec.rb b/spec/models/form/sales/questions/savings_nk_spec.rb
index 6847c4f5a..519bdd8d4 100644
--- a/spec/models/form/sales/questions/savings_nk_spec.rb
+++ b/spec/models/form/sales/questions/savings_nk_spec.rb
@@ -45,7 +45,7 @@ RSpec.describe Form::Sales::Questions::SavingsNk, type: :model do
end
it "has the correct hint" do
- expect(question.hint_text).to eq("")
+ expect(question.hint_text).to be_nil
end
it "has the correct hidden_in_check_answers" do
diff --git a/spec/models/form/sales/subsections/discounted_ownership_scheme_spec.rb b/spec/models/form/sales/subsections/discounted_ownership_scheme_spec.rb
index 6cd7b2493..efead2605 100644
--- a/spec/models/form/sales/subsections/discounted_ownership_scheme_spec.rb
+++ b/spec/models/form/sales/subsections/discounted_ownership_scheme_spec.rb
@@ -19,6 +19,8 @@ RSpec.describe Form::Sales::Subsections::DiscountedOwnershipScheme, type: :model
about_price_not_rtb
mortgage_used_discounted_ownership
mortgage_amount_discounted_ownership
+ mortgage_lender_discounted_ownership
+ mortgage_lender_other_discounted_ownership
mortgage_length_discounted_ownership
extra_borrowing_discounted_ownership
about_deposit_discounted_ownership
diff --git a/spec/models/form/sales/subsections/outright_sale_spec.rb b/spec/models/form/sales/subsections/outright_sale_spec.rb
index 5c76aff83..8f34f68e5 100644
--- a/spec/models/form/sales/subsections/outright_sale_spec.rb
+++ b/spec/models/form/sales/subsections/outright_sale_spec.rb
@@ -17,6 +17,8 @@ RSpec.describe Form::Sales::Subsections::OutrightSale, type: :model do
purchase_price
mortgage_used_outright_sale
mortgage_amount_outright_sale
+ mortgage_lender_outright_sale
+ mortgage_lender_other_outright_sale
mortgage_length_outright_sale
extra_borrowing_outright_sale
about_deposit_outright_sale
diff --git a/spec/models/form/sales/subsections/property_information_spec.rb b/spec/models/form/sales/subsections/property_information_spec.rb
index b512c8e5e..00b901142 100644
--- a/spec/models/form/sales/subsections/property_information_spec.rb
+++ b/spec/models/form/sales/subsections/property_information_spec.rb
@@ -15,8 +15,9 @@ RSpec.describe Form::Sales::Subsections::PropertyInformation, type: :model do
expect(property_information.pages.map(&:id)).to eq(
%w[
property_number_of_bedrooms
- property_building_type
property_unit_type
+ property_building_type
+ property_postcode
property_local_authority
property_wheelchair_accessible
],
diff --git a/spec/models/form/sales/subsections/shared_ownership_scheme_spec.rb b/spec/models/form/sales/subsections/shared_ownership_scheme_spec.rb
index b31de6a67..b453ed0d9 100644
--- a/spec/models/form/sales/subsections/shared_ownership_scheme_spec.rb
+++ b/spec/models/form/sales/subsections/shared_ownership_scheme_spec.rb
@@ -23,9 +23,13 @@ RSpec.describe Form::Sales::Subsections::SharedOwnershipScheme, type: :model do
la_nominations
buyer_previous
previous_bedrooms
+ previous_property_type
+ shared_ownership_previous_tenure
about_price_shared_ownership
mortgage_used_shared_ownership
mortgage_amount_shared_ownership
+ mortgage_lender_shared_ownership
+ mortgage_lender_other_shared_ownership
mortgage_length_shared_ownership
extra_borrowing_shared_ownership
about_deposit_with_discount
diff --git a/spec/models/form_handler_spec.rb b/spec/models/form_handler_spec.rb
index 4365eedcb..ab3ec6576 100644
--- a/spec/models/form_handler_spec.rb
+++ b/spec/models/form_handler_spec.rb
@@ -52,14 +52,14 @@ RSpec.describe FormHandler do
it "is able to load a current sales form" do
form = form_handler.get_form("current_sales")
expect(form).to be_a(Form)
- expect(form.pages.count).to eq(138)
+ expect(form.pages.count).to eq(147)
expect(form.name).to eq("2022_2023_sales")
end
it "is able to load a previous sales form" do
form = form_handler.get_form("previous_sales")
expect(form).to be_a(Form)
- expect(form.pages.count).to eq(138)
+ expect(form.pages.count).to eq(147)
expect(form.name).to eq("2021_2022_sales")
end
end
diff --git a/spec/models/forms/bulk_upload_lettings/upload_your_file_spec.rb b/spec/models/forms/bulk_upload_lettings/upload_your_file_spec.rb
index 49f7510ef..a71d446fe 100644
--- a/spec/models/forms/bulk_upload_lettings/upload_your_file_spec.rb
+++ b/spec/models/forms/bulk_upload_lettings/upload_your_file_spec.rb
@@ -51,5 +51,11 @@ RSpec.describe Forms::BulkUploadLettings::UploadYourFile do
expect(Storage::S3Service).to have_received(:new)
expect(mock_storage_service).to have_received(:write_file).with(bulk_upload.identifier, actual_file.read)
end
+
+ it "enqueues job to process bulk upload" do
+ expect {
+ form.save!
+ }.to have_enqueued_job(ProcessBulkUploadJob)
+ end
end
end
diff --git a/spec/models/forms/bulk_upload_sales/upload_your_file_spec.rb b/spec/models/forms/bulk_upload_sales/upload_your_file_spec.rb
index 8e7497633..512e85aa2 100644
--- a/spec/models/forms/bulk_upload_sales/upload_your_file_spec.rb
+++ b/spec/models/forms/bulk_upload_sales/upload_your_file_spec.rb
@@ -49,5 +49,11 @@ RSpec.describe Forms::BulkUploadSales::UploadYourFile do
expect(Storage::S3Service).to have_received(:new)
expect(mock_storage_service).to have_received(:write_file).with(bulk_upload.identifier, actual_file.read)
end
+
+ it "enqueues job to process bulk upload" do
+ expect {
+ form.save!
+ }.to have_enqueued_job(ProcessBulkUploadJob)
+ end
end
end
diff --git a/spec/models/lettings_log_spec.rb b/spec/models/lettings_log_spec.rb
index 999b4da3e..13f8eafd2 100644
--- a/spec/models/lettings_log_spec.rb
+++ b/spec/models/lettings_log_spec.rb
@@ -715,9 +715,8 @@ RSpec.describe LettingsLog do
context "when tenant is in receipt of housing benefit and universal credit" do
it "correctly derives and saves weekly total shortfall" do
lettings_log.update!(hbrentshortfall: 1, tshortfall: 130, period: 6, hb: 8)
- record_from_db = ActiveRecord::Base.connection.execute("select wtshortfall from lettings_logs where id=#{lettings_log.id}").to_a[0]
+ lettings_log.reload
expect(lettings_log.wtshortfall).to eq(122.5)
- expect(record_from_db["wtshortfall"]).to eq(122.5)
end
end
end
@@ -1908,7 +1907,7 @@ RSpec.describe LettingsLog do
end
context "when a question that has already been answered, no longer has met dependencies" do
- let(:lettings_log) { FactoryBot.create(:lettings_log, :in_progress, cbl: 1, preg_occ: 2, wchair: 1) }
+ let(:lettings_log) { FactoryBot.create(:lettings_log, :in_progress, cbl: 1, preg_occ: 2, wchair: 2) }
it "clears the answer" do
expect { lettings_log.update!(preg_occ: nil) }.to change(lettings_log, :cbl).from(1).to(nil)
@@ -1926,20 +1925,19 @@ RSpec.describe LettingsLog do
let(:lettings_log) { FactoryBot.create(:lettings_log, :in_progress, illness: 1, illness_type_1: 1) }
it "clears the answer" do
- expect { lettings_log.update!(illness: 0) }.to change(lettings_log, :illness_type_1).from(1).to(nil)
+ expect { lettings_log.update!(illness: 2) }.to change(lettings_log, :illness_type_1).from(1).to(nil)
end
end
end
context "with two pages having the same question key, only one's dependency is met" do
- let(:lettings_log) { FactoryBot.create(:lettings_log, :in_progress, cbl: 0, preg_occ: 2, wchair: 1) }
+ let(:lettings_log) { FactoryBot.create(:lettings_log, :in_progress, cbl: 0, preg_occ: 2, wchair: 2) }
it "does not clear the value for answers that apply to both pages" do
expect(lettings_log.cbl).to eq(0)
end
it "does clear the value for answers that do not apply for invalidated page" do
- lettings_log.update!({ wchair: 1, sex2: "F", age2: 33 })
lettings_log.update!({ cbl: 1 })
lettings_log.update!({ preg_occ: 1 })
diff --git a/spec/models/sales_log_spec.rb b/spec/models/sales_log_spec.rb
index 8f46db42d..bad72db3b 100644
--- a/spec/models/sales_log_spec.rb
+++ b/spec/models/sales_log_spec.rb
@@ -127,6 +127,109 @@ RSpec.describe SalesLog, type: :model do
record_from_db = ActiveRecord::Base.connection.execute("select deposit from sales_logs where id=#{sales_log.id}").to_a[0]
expect(record_from_db["deposit"]).to eq(nil)
end
+
+ it "correctly derives and saves pcode1 and pcode1 and pcode2" do
+ sales_log.update!(postcode_full: "W6 0SP")
+ record_from_db = ActiveRecord::Base.connection.execute("select pcode1, pcode2 from sales_logs where id=#{sales_log.id}").to_a[0]
+ expect(record_from_db["pcode1"]).to eq("W6")
+ expect(record_from_db["pcode2"]).to eq("0SP")
+ end
+ end
+
+ context "when saving addresses" do
+ before do
+ stub_request(:get, /api.postcodes.io/)
+ .to_return(status: 200, body: "{\"status\":200,\"result\":{\"admin_district\":\"Manchester\",\"codes\":{\"admin_district\": \"E08000003\"}}}", headers: {})
+ end
+
+ def check_postcode_fields(postcode_field)
+ record_from_db = ActiveRecord::Base.connection.execute("select #{postcode_field} from sales_logs where id=#{address_sales_log.id}").to_a[0]
+ expect(address_sales_log[postcode_field]).to eq("M1 1AE")
+ expect(record_from_db[postcode_field]).to eq("M1 1AE")
+ end
+
+ let!(:address_sales_log) do
+ FactoryBot.create(
+ :sales_log,
+ :completed,
+ managing_organisation: owning_organisation,
+ owning_organisation:,
+ created_by: created_by_user,
+ pcodenk: 0,
+ postcode_full: "M1 1AE",
+ )
+ end
+
+ def check_property_postcode_fields
+ check_postcode_fields("postcode_full")
+ end
+
+ it "correctly formats previous postcode" do
+ address_sales_log.update!(postcode_full: "M1 1AE")
+ check_property_postcode_fields
+
+ address_sales_log.update!(postcode_full: "m1 1ae")
+ check_property_postcode_fields
+
+ address_sales_log.update!(postcode_full: "m11Ae")
+ check_property_postcode_fields
+
+ address_sales_log.update!(postcode_full: "m11ae")
+ check_property_postcode_fields
+ end
+
+ it "correctly infers la" do
+ record_from_db = ActiveRecord::Base.connection.execute("select la from sales_logs where id=#{address_sales_log.id}").to_a[0]
+ expect(address_sales_log.la).to eq("E08000003")
+ expect(record_from_db["la"]).to eq("E08000003")
+ end
+
+ it "errors if the property postcode is emptied" do
+ expect { address_sales_log.update!({ postcode_full: "" }) }
+ .to raise_error(ActiveRecord::RecordInvalid, /#{I18n.t("validations.postcode")}/)
+ end
+
+ it "errors if the property postcode is not valid" do
+ expect { address_sales_log.update!({ postcode_full: "invalid_postcode" }) }
+ .to raise_error(ActiveRecord::RecordInvalid, /#{I18n.t("validations.postcode")}/)
+ end
+
+ context "when the local authority lookup times out" do
+ before do
+ allow(Timeout).to receive(:timeout).and_raise(Timeout::Error)
+ end
+
+ it "logs a warning" do
+ expect(Rails.logger).to receive(:warn).with("Postcodes.io lookup timed out")
+ address_sales_log.update!({ pcodenk: 1, postcode_full: "M1 1AD" })
+ end
+ end
+
+ it "correctly resets all fields if property postcode not known" do
+ address_sales_log.update!({ pcodenk: 1 })
+
+ record_from_db = ActiveRecord::Base.connection.execute("select la, postcode_full from sales_logs where id=#{address_sales_log.id}").to_a[0]
+ expect(record_from_db["postcode_full"]).to eq(nil)
+ expect(address_sales_log.la).to eq(nil)
+ expect(record_from_db["la"]).to eq(nil)
+ end
+
+ it "changes the LA if property postcode changes from not known to known and provided" do
+ address_sales_log.update!({ pcodenk: 1 })
+ address_sales_log.update!({ la: "E09000033" })
+
+ record_from_db = ActiveRecord::Base.connection.execute("select la, postcode_full from sales_logs where id=#{address_sales_log.id}").to_a[0]
+ expect(record_from_db["postcode_full"]).to eq(nil)
+ expect(address_sales_log.la).to eq("E09000033")
+ expect(record_from_db["la"]).to eq("E09000033")
+
+ address_sales_log.update!({ pcodenk: 0, postcode_full: "M1 1AD" })
+
+ record_from_db = ActiveRecord::Base.connection.execute("select la, postcode_full from sales_logs where id=#{address_sales_log.id}").to_a[0]
+ expect(record_from_db["postcode_full"]).to eq("M1 1AD")
+ expect(address_sales_log.la).to eq("E08000003")
+ expect(record_from_db["la"]).to eq("E08000003")
+ end
end
context "when saving previous address" do
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index fd132a8ef..9244ad7e5 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -117,8 +117,24 @@ RSpec.describe User, type: :model do
})
end
- it "can filter lettings logs by user, year and status" do
- expect(user.logs_filters).to eq(%w[status years user])
+ context "and their organisation does not have managing agents" do
+ before do
+ user.organisation.update(holds_own_stock: false)
+ end
+
+ it "can filter lettings logs by user, year and status" do
+ expect(user.logs_filters).to eq(%w[status years user])
+ end
+ end
+
+ context "and their organisation has managing agents" do
+ before do
+ FactoryBot.create(:organisation_relationship, parent_organisation: user.organisation)
+ end
+
+ it "can filter lettings logs by user, year, status and organisation" do
+ expect(user.logs_filters).to eq(%w[status years user organisation])
+ end
end
end
diff --git a/spec/models/validations/financial_validations_spec.rb b/spec/models/validations/financial_validations_spec.rb
index 409ed86c2..ae7875e08 100644
--- a/spec/models/validations/financial_validations_spec.rb
+++ b/spec/models/validations/financial_validations_spec.rb
@@ -126,14 +126,16 @@ RSpec.describe Validations::FinancialValidations do
describe "rent period validations" do
let(:organisation) { FactoryBot.create(:organisation) }
- let(:record) { FactoryBot.create(:lettings_log, owning_organisation: organisation) }
+ let(:user) { FactoryBot.create(:user) }
+ let(:record) { FactoryBot.create(:lettings_log, owning_organisation: user.organisation, managing_organisation: organisation, created_by: user) }
before do
+ FactoryBot.create(:organisation_relationship, parent_organisation: user.organisation, child_organisation: organisation)
FactoryBot.create(:organisation_rent_period, organisation:, rent_period: 2)
end
context "when the organisation only uses specific rent periods" do
- it "validates that the selected rent period is used by the organisation" do
+ it "validates that the selected rent period is used by the managing organisation" do
record.period = 3
financial_validator.validate_rent_period(record)
expect(record.errors["period"])
@@ -927,9 +929,9 @@ RSpec.describe Validations::FinancialValidations do
record.chcharge = 4334
financial_validator.validate_care_home_charges(record)
expect(record.errors["chcharge"])
- .to include(match I18n.t("validations.financial.carehome.out_of_range", min_chcharge: 43, period: "4", max_chcharge: 4333))
+ .to include(match I18n.t("validations.financial.carehome.out_of_range", min_chcharge: 43, period: "every calendar month", max_chcharge: 4333))
expect(record.errors["period"])
- .to include(match I18n.t("validations.financial.carehome.out_of_range", min_chcharge: 43, period: "4", max_chcharge: 4333))
+ .to include(match I18n.t("validations.financial.carehome.out_of_range", min_chcharge: 43, period: "every calendar month", max_chcharge: 4333))
end
it "validates charge when period is every 2 weeks" do
@@ -937,9 +939,9 @@ RSpec.describe Validations::FinancialValidations do
record.chcharge = 2001
financial_validator.validate_care_home_charges(record)
expect(record.errors["chcharge"])
- .to include(match I18n.t("validations.financial.carehome.out_of_range", min_chcharge: 20, period: "2", max_chcharge: 2000))
+ .to include(match I18n.t("validations.financial.carehome.out_of_range", min_chcharge: 20, period: "every 2 weeks", max_chcharge: 2000))
expect(record.errors["period"])
- .to include(match I18n.t("validations.financial.carehome.out_of_range", min_chcharge: 20, period: "2", max_chcharge: 2000))
+ .to include(match I18n.t("validations.financial.carehome.out_of_range", min_chcharge: 20, period: "every 2 weeks", max_chcharge: 2000))
end
it "validates charge when period is every 4 weeks" do
@@ -1015,9 +1017,9 @@ RSpec.describe Validations::FinancialValidations do
record.chcharge = 42
financial_validator.validate_care_home_charges(record)
expect(record.errors["chcharge"])
- .to include(match I18n.t("validations.financial.carehome.out_of_range", min_chcharge: 43, period: "4", max_chcharge: 4333))
+ .to include(match I18n.t("validations.financial.carehome.out_of_range", min_chcharge: 43, period: "every calendar month", max_chcharge: 4333))
expect(record.errors["period"])
- .to include(match I18n.t("validations.financial.carehome.out_of_range", min_chcharge: 43, period: "4", max_chcharge: 4333))
+ .to include(match I18n.t("validations.financial.carehome.out_of_range", min_chcharge: 43, period: "every calendar month", max_chcharge: 4333))
end
it "validates charge when period is every 2 weeks" do
@@ -1025,9 +1027,9 @@ RSpec.describe Validations::FinancialValidations do
record.chcharge = 19
financial_validator.validate_care_home_charges(record)
expect(record.errors["chcharge"])
- .to include(match I18n.t("validations.financial.carehome.out_of_range", min_chcharge: 20, period: "2", max_chcharge: 2000))
+ .to include(match I18n.t("validations.financial.carehome.out_of_range", min_chcharge: 20, period: "every 2 weeks", max_chcharge: 2000))
expect(record.errors["period"])
- .to include(match I18n.t("validations.financial.carehome.out_of_range", min_chcharge: 20, period: "2", max_chcharge: 2000))
+ .to include(match I18n.t("validations.financial.carehome.out_of_range", min_chcharge: 20, period: "every 2 weeks", max_chcharge: 2000))
end
it "validates charge when period is every 4 weeks" do
diff --git a/spec/models/validations/shared_validations_spec.rb b/spec/models/validations/shared_validations_spec.rb
index 2be3f52f3..a88b5dda2 100644
--- a/spec/models/validations/shared_validations_spec.rb
+++ b/spec/models/validations/shared_validations_spec.rb
@@ -1,7 +1,7 @@
require "rails_helper"
RSpec.describe Validations::SharedValidations do
- subject(:household_validator) { validator_class.new }
+ subject(:shared_validator) { validator_class.new }
let(:validator_class) { Class.new { include Validations::SharedValidations } }
let(:record) { FactoryBot.create(:lettings_log) }
@@ -15,57 +15,87 @@ RSpec.describe Validations::SharedValidations do
context "when validating age" do
it "validates that person 1's age is a number" do
record.age1 = "random"
- household_validator.validate_numeric_min_max(record)
+ shared_validator.validate_numeric_min_max(record)
expect(record.errors["age1"])
.to include(match I18n.t("validations.numeric.valid", field: "Lead tenant’s age", min: 16, max: 120))
end
it "validates that other household member ages are a number" do
record.age2 = "random"
- household_validator.validate_numeric_min_max(record)
+ shared_validator.validate_numeric_min_max(record)
expect(record.errors["age2"])
.to include(match I18n.t("validations.numeric.valid", field: "Person 2’s age", min: 1, max: 120))
end
it "validates that person 1's age is greater than 16" do
record.age1 = 15
- household_validator.validate_numeric_min_max(record)
+ shared_validator.validate_numeric_min_max(record)
expect(record.errors["age1"])
.to include(match I18n.t("validations.numeric.valid", field: "Lead tenant’s age", min: 16, max: 120))
end
it "validates that other household member ages are greater than 1" do
record.age2 = 0
- household_validator.validate_numeric_min_max(record)
+ shared_validator.validate_numeric_min_max(record)
expect(record.errors["age2"])
.to include(match I18n.t("validations.numeric.valid", field: "Person 2’s age", min: 1, max: 120))
end
it "validates that person 1's age is less than 121" do
record.age1 = 121
- household_validator.validate_numeric_min_max(record)
+ shared_validator.validate_numeric_min_max(record)
expect(record.errors["age1"])
.to include(match I18n.t("validations.numeric.valid", field: "Lead tenant’s age", min: 16, max: 120))
end
it "validates that other household member ages are greater than 121" do
record.age2 = 123
- household_validator.validate_numeric_min_max(record)
+ shared_validator.validate_numeric_min_max(record)
expect(record.errors["age2"])
.to include(match I18n.t("validations.numeric.valid", field: "Person 2’s age", min: 1, max: 120))
end
it "validates that person 1's age is between 16 and 120" do
record.age1 = 63
- household_validator.validate_numeric_min_max(record)
+ shared_validator.validate_numeric_min_max(record)
expect(record.errors["age1"]).to be_empty
end
it "validates that other household member ages are between 1 and 120" do
record.age6 = 45
- household_validator.validate_numeric_min_max(record)
+ shared_validator.validate_numeric_min_max(record)
expect(record.errors["age6"]).to be_empty
end
end
end
+
+ describe "radio options validations" do
+ it "allows only possible values" do
+ record.needstype = 1
+ shared_validator.validate_valid_radio_option(record)
+
+ expect(record.errors["needstype"]).to be_empty
+ end
+
+ it "denies impossible values" do
+ record.needstype = 3
+ shared_validator.validate_valid_radio_option(record)
+
+ expect(record.errors["needstype"]).to be_present
+ expect(record.errors["needstype"]).to eql(["Enter a valid value for needs type"])
+ end
+
+ context "when feature is toggled off" do
+ before do
+ allow(FeatureToggle).to receive(:validate_valid_radio_options?).and_return(false)
+ end
+
+ it "allows any values" do
+ record.needstype = 3
+ shared_validator.validate_valid_radio_option(record)
+
+ expect(record.errors["needstype"]).to be_empty
+ end
+ end
+ end
end
diff --git a/spec/requests/bulk_upload_lettings_results_controller_spec.rb b/spec/requests/bulk_upload_lettings_results_controller_spec.rb
new file mode 100644
index 000000000..15ba0b7bb
--- /dev/null
+++ b/spec/requests/bulk_upload_lettings_results_controller_spec.rb
@@ -0,0 +1,57 @@
+require "rails_helper"
+
+RSpec.describe BulkUploadLettingsResultsController, type: :request do
+ let(:user) { create(:user) }
+ let(:bulk_upload) { create(:bulk_upload, :lettings, user:, bulk_upload_errors:) }
+ let(:bulk_upload_errors) { create_list(:bulk_upload_error, 2) }
+
+ before do
+ sign_in user
+ end
+
+ describe "GET /lettings-logs/bulk-upload-results/:ID" do
+ it "renders correct year" do
+ get "/lettings-logs/bulk-upload-results/#{bulk_upload.id}"
+
+ expect(response).to be_successful
+ expect(response.body).to include("Bulk Upload for lettings (2022/23)")
+ end
+
+ it "renders correct number of errors" do
+ get "/lettings-logs/bulk-upload-results/#{bulk_upload.id}"
+
+ expect(response).to be_successful
+ expect(response.body).to include("We found 2 errors in your file")
+ end
+
+ it "renders filename of the upload" do
+ get "/lettings-logs/bulk-upload-results/#{bulk_upload.id}"
+
+ expect(response).to be_successful
+ expect(response.body).to include(bulk_upload.filename)
+ end
+
+ context "when there are errors for more than 1 row" do
+ let(:bulk_upload_errors) { [bulk_upload_error_1, bulk_upload_error_2] }
+ let(:bulk_upload_error_1) { create(:bulk_upload_error, row: 1) }
+ let(:bulk_upload_error_2) { create(:bulk_upload_error, row: 2) }
+
+ it "renders no. of tables equal to no. of rows with errors" do
+ get "/lettings-logs/bulk-upload-results/#{bulk_upload.id}"
+
+ expect(response.body).to include("
startdate" do
+ context "when any one of these fields is blank" do
+ let(:attributes) { { bulk_upload:, field_96: nil, field_97: nil, field_98: nil } }
+
+ it "returns an error" do
+ expect(parser.errors[:field_96]).to be_present
+ expect(parser.errors[:field_97]).to be_present
+ expect(parser.errors[:field_98]).to be_present
+ end
+ end
+ end
+
+ describe "#field_134" do
+ context "when an unpermitted value" do
+ let(:attributes) { { bulk_upload:, field_134: 3 } }
+
+ it "has errors on the field" do
+ expect(parser.errors[:field_134]).to be_present
+ end
+ end
+ end
+
+ describe "#field_103" do
+ context "when null" do
+ let(:attributes) { setup_section_params.merge({ field_103: nil }) }
+
+ it "returns an error" do
+ expect(parser.errors[:field_103]).to be_present
+ end
+ end
+
+ context "when unpermitted values" do
+ let(:attributes) { setup_section_params.merge({ field_103: "4" }) }
+
+ it "returns an error" do
+ expect(parser.errors[:field_103]).to be_present
+ end
+ end
+ end
+ end
+
+ describe "#log" do
+ describe "#cbl" do
+ context "when field_75 is yes ie 1" do
+ let(:attributes) { { bulk_upload:, field_75: 1 } }
+
+ it "sets value to 1" do
+ expect(parser.log.cbl).to be(1)
+ end
+ end
+
+ context "when field_75 is no ie 2" do
+ let(:attributes) { { bulk_upload:, field_75: 2 } }
+
+ it "sets value to 0" do
+ expect(parser.log.cbl).to be(0)
+ end
+ end
+ end
+
+ describe "#chr" do
+ context "when field_76 is yes ie 1" do
+ let(:attributes) { { bulk_upload:, field_76: 1 } }
+
+ it "sets value to 1" do
+ expect(parser.log.chr).to be(1)
+ end
+ end
+
+ context "when field_76 is no ie 2" do
+ let(:attributes) { { bulk_upload:, field_76: 2 } }
+
+ it "sets value to 0" do
+ expect(parser.log.chr).to be(0)
+ end
+ end
+ end
+
+ describe "#cap" do
+ context "when field_77 is yes ie 1" do
+ let(:attributes) { { bulk_upload:, field_77: 1 } }
+
+ it "sets value to 1" do
+ expect(parser.log.cap).to be(1)
+ end
+ end
+
+ context "when field_77 is no ie 2" do
+ let(:attributes) { { bulk_upload:, field_77: 2 } }
+
+ it "sets value to 0" do
+ expect(parser.log.cap).to be(0)
+ end
+ end
+ end
+
+ describe "#letting_allocation_unknown" do
+ context "when field_75, 76, 77 are no ie 2" do
+ let(:attributes) { { bulk_upload:, field_75: 2, field_76: 2, field_77: 2 } }
+
+ it "sets value to 1" do
+ expect(parser.log.letting_allocation_unknown).to be(1)
+ end
+ end
+
+ context "when any one of field_75, 76, 77 is yes ie 1" do
+ let(:attributes) { { bulk_upload:, field_75: 1 } }
+
+ it "sets value to 0" do
+ expect(parser.log.letting_allocation_unknown).to be(0)
+ end
+ end
+ end
+
+ describe "#renewal" do
+ context "when field_134 is no ie 2" do
+ let(:attributes) { { bulk_upload:, field_134: 2 } }
+
+ it "sets value to 0" do
+ expect(parser.log.renewal).to eq(0)
+ end
+ end
+
+ context "when field_134 is null but rsnvac/field_116 is 14" do
+ let(:attributes) { { bulk_upload:, field_134: "", field_116: "14" } }
+
+ it "sets renewal to 1" do
+ expect(parser.log.renewal).to eq(1)
+ end
+ end
+ end
+
+ describe "#sexN fields" do
+ let(:attributes) do
+ {
+ bulk_upload:,
+ field_20: "F",
+ field_21: "M",
+ field_22: "X",
+ field_23: "R",
+ field_24: "F",
+ field_25: "M",
+ field_26: "X",
+ field_27: "R",
+ }
+ end
+
+ it "sets value from correct mapping" do
+ expect(parser.log.sex1).to eql("F")
+ expect(parser.log.sex2).to eql("M")
+ expect(parser.log.sex3).to eql("X")
+ expect(parser.log.sex4).to eql("R")
+ expect(parser.log.sex5).to eql("F")
+ expect(parser.log.sex6).to eql("M")
+ expect(parser.log.sex7).to eql("X")
+ expect(parser.log.sex8).to eql("R")
+ end
+ end
+
+ describe "#ecstatN fields" do
+ let(:attributes) do
+ {
+ bulk_upload:,
+ field_35: "1",
+ field_36: "2",
+ field_37: "6",
+ field_38: "7",
+ field_39: "8",
+ field_40: "9",
+ field_41: "0",
+ field_42: "10",
+ }
+ end
+
+ it "sets value from correct mapping", aggregate_failures: true do
+ expect(parser.log.ecstat1).to eq(1)
+ expect(parser.log.ecstat2).to eq(2)
+ expect(parser.log.ecstat3).to eq(6)
+ expect(parser.log.ecstat4).to eq(7)
+ expect(parser.log.ecstat5).to eq(8)
+ expect(parser.log.ecstat6).to eq(9)
+ expect(parser.log.ecstat7).to eq(0)
+ expect(parser.log.ecstat8).to eq(10)
+ end
+ end
+
+ describe "#relatN fields" do
+ let(:attributes) do
+ {
+ bulk_upload:,
+ field_28: "P",
+ field_29: "C",
+ field_30: "X",
+ field_31: "R",
+ field_32: "P",
+ field_33: "C",
+ field_34: "X",
+ }
+ end
+
+ it "sets value from correct mapping", aggregate_failures: true do
+ expect(parser.log.relat2).to eq("P")
+ expect(parser.log.relat3).to eq("C")
+ expect(parser.log.relat4).to eq("X")
+ expect(parser.log.relat5).to eq("R")
+ expect(parser.log.relat6).to eq("P")
+ expect(parser.log.relat7).to eq("C")
+ expect(parser.log.relat8).to eq("X")
+ end
+ end
+
+ describe "#net_income_known" do
+ let(:attributes) { { bulk_upload:, field_51: "1" } }
+
+ it "sets value from correct mapping" do
+ expect(parser.log.net_income_known).to eq(0)
+ end
+ end
+
+ describe "#unitletas" do
+ let(:attributes) { { bulk_upload:, field_105: "1" } }
+
+ it "sets value from correct mapping" do
+ expect(parser.log.unitletas).to eq(1)
+ end
+ end
+
+ describe "#rsnvac" do
+ let(:attributes) { { bulk_upload:, field_106: "5" } }
+
+ it "sets value from correct mapping" do
+ expect(parser.log.rsnvac).to eq(5)
+ end
+ end
+
+ describe "#sheltered" do
+ let(:attributes) { { bulk_upload:, field_117: "1" } }
+
+ it "sets value from correct mapping" do
+ expect(parser.log.sheltered).to eq(1)
+ end
+ end
+
+ describe "illness fields" do
+ mapping = [
+ { attribute: :illness_type_1, field: :field_119 },
+ { attribute: :illness_type_2, field: :field_120 },
+ { attribute: :illness_type_3, field: :field_121 },
+ { attribute: :illness_type_4, field: :field_122 },
+ { attribute: :illness_type_5, field: :field_123 },
+ { attribute: :illness_type_6, field: :field_124 },
+ { attribute: :illness_type_7, field: :field_125 },
+ { attribute: :illness_type_8, field: :field_126 },
+ { attribute: :illness_type_9, field: :field_127 },
+ { attribute: :illness_type_10, field: :field_128 },
+ ]
+
+ mapping.each do |hash|
+ describe "##{hash[:attribute]}" do
+ context "when yes" do
+ let(:attributes) { { bulk_upload:, hash[:field] => "1" } }
+
+ it "sets value from correct mapping" do
+ expect(parser.log.public_send(hash[:attribute])).to eq(1)
+ end
+ end
+
+ context "when no" do
+ let(:attributes) { { bulk_upload:, hash[:field] => "" } }
+
+ it "sets value from correct mapping" do
+ expect(parser.log.public_send(hash[:attribute])).to be_nil
+ end
+ end
+ end
+ end
+ end
+
+ describe "#irproduct_other" do
+ let(:attributes) { { bulk_upload:, field_131: "some other product" } }
+
+ it "sets value to given free text string" do
+ expect(parser.log.irproduct_other).to eql("some other product")
+ end
+ end
+
+ describe "#tenancyother" do
+ let(:attributes) { { bulk_upload:, field_10: "some other tenancy" } }
+
+ it "sets value to given free text string" do
+ expect(parser.log.tenancyother).to eql("some other tenancy")
+ end
+ end
+
+ describe "#tenancylength" do
+ let(:attributes) { { bulk_upload:, field_11: "2" } }
+
+ it "sets value to given free text string" do
+ expect(parser.log.tenancylength).to eq(2)
+ end
+ end
+
+ describe "#earnings" do
+ let(:attributes) { { bulk_upload:, field_50: "104.50" } }
+
+ it "rounds to the nearest whole pound" do
+ expect(parser.log.earnings).to eq(105)
+ end
+ end
+
+ describe "#reasonother" do
+ let(:attributes) { { bulk_upload:, field_53: "some other reason" } }
+
+ it "sets value to given free text string" do
+ expect(parser.log.reasonother).to eql("some other reason")
+ end
+ end
+
+ describe "#ppcodenk" do
+ let(:attributes) { { bulk_upload:, field_65: "2" } }
+
+ it "sets correct value from mapping" do
+ expect(parser.log.ppcodenk).to eq(0)
+ end
+ end
+
+ describe "#household_charge" do
+ let(:attributes) { { bulk_upload:, field_86: "1" } }
+
+ it "sets correct value from mapping" do
+ expect(parser.log.household_charge).to eq(1)
+ end
+ end
+
+ describe "#chcharge" do
+ let(:attributes) { { bulk_upload:, field_85: "123.45" } }
+
+ it "sets value given" do
+ expect(parser.log.chcharge).to eq(123.45)
+ end
+ end
+
+ describe "#tcharge" do
+ let(:attributes) { { bulk_upload:, field_84: "123.45" } }
+
+ it "sets value given" do
+ expect(parser.log.tcharge).to eq(123.45)
+ end
+ end
+
+ describe "#supcharg" do
+ let(:attributes) { { bulk_upload:, field_83: "123.45" } }
+
+ it "sets value given" do
+ expect(parser.log.supcharg).to eq(123.45)
+ end
+ end
+
+ describe "#pscharge" do
+ let(:attributes) { { bulk_upload:, field_82: "123.45" } }
+
+ it "sets value given" do
+ expect(parser.log.pscharge).to eq(123.45)
+ end
+ end
+
+ describe "#scharge" do
+ let(:attributes) { { bulk_upload:, field_81: "123.45" } }
+
+ it "sets value given" do
+ expect(parser.log.scharge).to eq(123.45)
+ end
+ end
+
+ describe "#offered" do
+ let(:attributes) { { bulk_upload:, field_99: "3" } }
+
+ it "sets value given" do
+ expect(parser.log.offered).to eq(3)
+ end
+ end
+
+ describe "#propcode" do
+ let(:attributes) { { bulk_upload:, field_100: "abc123" } }
+
+ it "sets value given" do
+ expect(parser.log.propcode).to eq("abc123")
+ end
+ end
+
+ describe "#mrcdate" do
+ let(:attributes) { { bulk_upload:, field_92: "13", field_93: "12", field_94: "22" } }
+
+ it "sets value given" do
+ expect(parser.log.mrcdate).to eq(Date.new(2022, 12, 13))
+ end
+ end
+
+ describe "#majorrepairs" do
+ context "when mrcdate given" do
+ let(:attributes) { { bulk_upload:, field_92: "13", field_93: "12", field_94: "22" } }
+
+ it "sets #majorrepairs to 1" do
+ expect(parser.log.majorrepairs).to eq(1)
+ end
+ end
+
+ context "when mrcdate not given" do
+ let(:attributes) { { bulk_upload:, field_92: "", field_93: "", field_94: "" } }
+
+ it "sets #majorrepairs to 0" do
+ expect(parser.log.majorrepairs).to eq(0)
+ end
+ end
+ end
+
+ describe "#voiddate" do
+ let(:attributes) { { bulk_upload:, field_89: "13", field_90: "12", field_91: "22" } }
+
+ it "sets value given" do
+ expect(parser.log.voiddate).to eq(Date.new(2022, 12, 13))
+ end
+ end
+
+ describe "#startdate" do
+ let(:attributes) { { bulk_upload:, field_96: now.day.to_s, field_97: now.month.to_s, field_98: now.strftime("%g") } }
+
+ it "sets value given" do
+ expect(parser.log.startdate).to eq(now)
+ end
+ end
+
+ describe "#postcode_full" do
+ let(:attributes) { { bulk_upload:, field_108: " EC1N ", field_109: " 2TD " } }
+
+ it "strips whitespace" do
+ expect(parser.log.postcode_full).to eql("EC1N 2TD")
+ end
+ end
+
+ describe "#la" do
+ let(:attributes) { { bulk_upload:, field_107: "E07000223" } }
+
+ it "sets to given value" do
+ expect(parser.log.la).to eql("E07000223")
+ end
+ end
+
+ describe "#prevloc" do
+ let(:attributes) { { bulk_upload:, field_62: "E07000223" } }
+
+ it "sets to given value" do
+ expect(parser.log.prevloc).to eql("E07000223")
+ end
+ end
+
+ describe "#previous_la_known" do
+ context "when known" do
+ let(:attributes) { { bulk_upload:, field_62: "E07000223" } }
+
+ it "sets to 1" do
+ expect(parser.log.previous_la_known).to eq(1)
+ end
+ end
+
+ context "when not known" do
+ let(:attributes) { { bulk_upload:, field_62: "" } }
+
+ it "sets to 0" do
+ expect(parser.log.previous_la_known).to eq(0)
+ end
+ end
+ end
+
+ describe "#first_time_property_let_as_social_housing" do
+ context "when field_106 is 15, 16, or 17" do
+ let(:attributes) { { bulk_upload:, field_106: %w[15 16 17].sample } }
+
+ it "sets to 1" do
+ expect(parser.log.first_time_property_let_as_social_housing).to eq(1)
+ end
+ end
+ end
+ end
+end
diff --git a/spec/services/bulk_upload/lettings/validator_spec.rb b/spec/services/bulk_upload/lettings/validator_spec.rb
new file mode 100644
index 000000000..1543774e9
--- /dev/null
+++ b/spec/services/bulk_upload/lettings/validator_spec.rb
@@ -0,0 +1,46 @@
+require "rails_helper"
+
+RSpec.describe BulkUpload::Lettings::Validator do
+ subject(:validator) { described_class.new(bulk_upload:, path:) }
+
+ let(:bulk_upload) { create(:bulk_upload) }
+ let(:path) { file.path }
+ let(:file) { Tempfile.new }
+
+ describe "validations" do
+ context "when file is empty" do
+ it "is not valid" do
+ expect(validator).not_to be_valid
+ end
+ end
+
+ context "when file has too many columns" do
+ before do
+ file.write("a," * 136)
+ file.write("\n")
+ file.rewind
+ end
+
+ it "is not valid" do
+ expect(validator).not_to be_valid
+ end
+ end
+
+ context "when incorrect headers"
+ end
+
+ context "when a valid csv" do
+ let(:path) { file_fixture("2022_23_lettings_bulk_upload.csv") }
+
+ it "creates validation errors" do
+ expect { validator.call }.to change(BulkUploadError, :count)
+ end
+
+ it "create validation error with correct values" do
+ validator.call
+
+ error = BulkUploadError.first
+ expect(error.row).to eq("6")
+ end
+ end
+end
diff --git a/spec/services/bulk_upload/processor_spec.rb b/spec/services/bulk_upload/processor_spec.rb
new file mode 100644
index 000000000..fce40b998
--- /dev/null
+++ b/spec/services/bulk_upload/processor_spec.rb
@@ -0,0 +1,34 @@
+require "rails_helper"
+
+RSpec.describe BulkUpload::Processor do
+ subject(:processor) { described_class.new(bulk_upload:) }
+
+ let(:bulk_upload) { create(:bulk_upload, :lettings) }
+
+ context "when processing a bulk upload with errors" do
+ describe "#call" do
+ let(:mock_downloader) do
+ instance_double(
+ BulkUpload::Downloader,
+ call: nil,
+ path: file_fixture("2022_23_lettings_bulk_upload.csv"),
+ delete_local_file!: nil,
+ )
+ end
+
+ it "persist the validation errors" do
+ allow(BulkUpload::Downloader).to receive(:new).with(bulk_upload:).and_return(mock_downloader)
+
+ expect { processor.call }.to change(BulkUploadError, :count)
+ end
+
+ it "deletes the local file afterwards" do
+ allow(BulkUpload::Downloader).to receive(:new).with(bulk_upload:).and_return(mock_downloader)
+
+ processor.call
+
+ expect(mock_downloader).to have_received(:delete_local_file!)
+ end
+ end
+ end
+end
diff --git a/spec/services/bulk_upload/sales/row_parser_spec.rb b/spec/services/bulk_upload/sales/row_parser_spec.rb
new file mode 100644
index 000000000..38f02fabb
--- /dev/null
+++ b/spec/services/bulk_upload/sales/row_parser_spec.rb
@@ -0,0 +1,21 @@
+require "rails_helper"
+
+RSpec.describe BulkUpload::Sales::RowParser do
+ subject(:parser) { described_class.new(attributes) }
+
+ describe "validations" do
+ before do
+ parser.valid?
+ end
+
+ describe "#field_117" do
+ context "when not a possible value" do
+ let(:attributes) { { field_117: "3" } }
+
+ it "is not valid" do
+ expect(parser.errors).to include(:field_117)
+ end
+ end
+ end
+ end
+end
diff --git a/spec/services/bulk_upload/sales/validator_spec.rb b/spec/services/bulk_upload/sales/validator_spec.rb
new file mode 100644
index 000000000..6c0be8bdd
--- /dev/null
+++ b/spec/services/bulk_upload/sales/validator_spec.rb
@@ -0,0 +1,47 @@
+require "rails_helper"
+
+RSpec.describe BulkUpload::Sales::Validator do
+ subject(:validator) { described_class.new(bulk_upload:, path:) }
+
+ let(:bulk_upload) { create(:bulk_upload) }
+ let(:path) { file.path }
+ let(:file) { Tempfile.new }
+
+ describe "validations" do
+ context "when file is empty" do
+ it "is not valid" do
+ expect(validator).not_to be_valid
+ end
+ end
+
+ context "when file has too many columns" do
+ before do
+ file.write((%w[a] * 127).join(","))
+ file.rewind
+ end
+
+ it "is not valid" do
+ expect(validator).not_to be_valid
+ end
+ end
+
+ context "when incorrect headers"
+ end
+
+ context "when a valid csv that contains errors" do
+ let(:path) { file_fixture("2022_23_sales_bulk_upload.csv") }
+
+ it "persists bulk upload errors" do
+ expect {
+ validator.call
+ }.to change(BulkUploadError, :count).by(1)
+ end
+
+ it "populates purchaser_code" do
+ validator.call
+
+ error = BulkUploadError.last
+ expect(error.purchaser_code).to eql("1")
+ end
+ end
+end
diff --git a/spec/services/csv/lettings_log_csv_service_spec.rb b/spec/services/csv/lettings_log_csv_service_spec.rb
index e68be40d7..5679d2ad4 100644
--- a/spec/services/csv/lettings_log_csv_service_spec.rb
+++ b/spec/services/csv/lettings_log_csv_service_spec.rb
@@ -121,7 +121,6 @@ RSpec.describe Csv::LettingsLogCsvService do
illness_type_8
illness_type_1
illness_type_10
- illness_type_0
layear
waityear
reason
diff --git a/spec/services/exports/lettings_log_export_service_spec.rb b/spec/services/exports/lettings_log_export_service_spec.rb
index 71ad30400..eb8ef281f 100644
--- a/spec/services/exports/lettings_log_export_service_spec.rb
+++ b/spec/services/exports/lettings_log_export_service_spec.rb
@@ -59,7 +59,7 @@ RSpec.describe Exports::LettingsLogExportService do
end
context "and one lettings log is available for export" do
- let!(:lettings_log) { FactoryBot.create(:lettings_log, :completed, propcode: "123", ppostcode_full: "SE2 6RT", postcode_full: "NW1 5TY", tenancycode: "BZ737", startdate: Time.utc(2022, 2, 2, 10, 36, 49), tenancylength: 5) }
+ let!(:lettings_log) { FactoryBot.create(:lettings_log, :completed, propcode: "123", ppostcode_full: "SE2 6RT", postcode_full: "NW1 5TY", tenancycode: "BZ737", startdate: Time.utc(2022, 2, 2, 10, 36, 49), tenancylength: 5, underoccupation_benefitcap: 4) }
it "generates a ZIP export file with the expected filename" do
expect(storage_service).to receive(:write_file).with(expected_zip_filename, any_args)
@@ -237,7 +237,7 @@ RSpec.describe Exports::LettingsLogExportService do
let(:csv_export_file) { File.open("spec/fixtures/exports/general_needs_log.csv", "r:UTF-8") }
let(:expected_csv_filename) { "export_2022_05_01.csv" }
- let(:lettings_log) { FactoryBot.create(:lettings_log, :completed, propcode: "123", ppostcode_full: "SE2 6RT", postcode_full: "NW1 5TY", tenancycode: "BZ737", startdate: Time.utc(2022, 2, 2, 10, 36, 49), tenancylength: 5) }
+ let(:lettings_log) { FactoryBot.create(:lettings_log, :completed, propcode: "123", ppostcode_full: "SE2 6RT", postcode_full: "NW1 5TY", tenancycode: "BZ737", startdate: Time.utc(2022, 2, 2, 10, 36, 49), tenancylength: 5, underoccupation_benefitcap: 4) }
it "generates an CSV export file with the expected content" do
expected_content = replace_entity_ids(lettings_log, csv_export_file.read)
@@ -256,7 +256,7 @@ RSpec.describe Exports::LettingsLogExportService do
let(:scheme) { FactoryBot.create(:scheme, :export, owning_organisation: organisation) }
let(:location) { FactoryBot.create(:location, :export, scheme:, startdate: Time.zone.local(2021, 4, 1)) }
- let(:lettings_log) { FactoryBot.create(:lettings_log, :completed, :export, :sh, scheme:, location:, created_by: user, owning_organisation: organisation, startdate: Time.utc(2022, 2, 2, 10, 36, 49)) }
+ let(:lettings_log) { FactoryBot.create(:lettings_log, :completed, :export, :sh, scheme:, location:, created_by: user, owning_organisation: organisation, startdate: Time.utc(2022, 2, 2, 10, 36, 49), underoccupation_benefitcap: 4, sheltered: 1) }
it "generates an XML export file with the expected content" do
expected_content = replace_entity_ids(lettings_log, export_file.read)