diff --git a/app/components/check_answers_summary_list_card_component.html.erb b/app/components/check_answers_summary_list_card_component.html.erb
index d04283939..0005ed790 100644
--- a/app/components/check_answers_summary_list_card_component.html.erb
+++ b/app/components/check_answers_summary_list_card_component.html.erb
@@ -2,12 +2,7 @@
<% if applicable_questions.first.check_answers_card_number != 0 && applicable_questions.first.check_answers_card_number.present? %>
<% end %>
diff --git a/app/components/check_answers_summary_list_card_component.rb b/app/components/check_answers_summary_list_card_component.rb
index de7fe9685..246173f48 100644
--- a/app/components/check_answers_summary_list_card_component.rb
+++ b/app/components/check_answers_summary_list_card_component.rb
@@ -15,4 +15,28 @@ class CheckAnswersSummaryListCardComponent < ViewComponent::Base
def get_answer_label(question)
question.answer_label(log).presence || "You didn’t answer this question".html_safe
end
+
+ def check_answers_card_title(question)
+ if question.form.type == "lettings"
+ case question.check_answers_card_number
+ when 1
+ "Lead tenant"
+ when 2..8
+ "Person #{question.check_answers_card_number}"
+ end
+ else
+ case question.check_answers_card_number
+ when 1..number_of_buyers
+ "Buyer #{question.check_answers_card_number}"
+ when (number_of_buyers + 1)..(number_of_buyers + 4)
+ "Person #{question.check_answers_card_number - number_of_buyers}"
+ end
+ end
+ end
+
+private
+
+ def number_of_buyers
+ log[:jointpur] == 1 ? 2 : 1
+ end
end
diff --git a/app/models/derived_variables/sales_log_variables.rb b/app/models/derived_variables/sales_log_variables.rb
index 5fff0900d..c9675d84a 100644
--- a/app/models/derived_variables/sales_log_variables.rb
+++ b/app/models/derived_variables/sales_log_variables.rb
@@ -7,5 +7,8 @@ module DerivedVariables::SalesLogVariables
self.exyear = exdate.year
end
self.deposit = value if outright_sale? && mortgage_not_used?
+ if mscharge_known.present? && mscharge_known.zero?
+ self.mscharge = 0
+ end
end
end
diff --git a/app/models/form/sales/pages/armed_forces_spouse.rb b/app/models/form/sales/pages/armed_forces_spouse.rb
new file mode 100644
index 000000000..7c4128b87
--- /dev/null
+++ b/app/models/form/sales/pages/armed_forces_spouse.rb
@@ -0,0 +1,15 @@
+class Form::Sales::Pages::ArmedForcesSpouse < ::Form::Page
+ def initialize(id, hsh, subsection)
+ super
+ @id = "armed_forces_spouse"
+ @header = ""
+ @description = ""
+ @subsection = subsection
+ end
+
+ def questions
+ @questions ||= [
+ Form::Sales::Questions::ArmedForcesSpouse.new(nil, nil, self),
+ ]
+ end
+end
diff --git a/app/models/form/sales/pages/buyer1_working_situation.rb b/app/models/form/sales/pages/buyer1_working_situation.rb
index caaa0e60f..bde1dba09 100644
--- a/app/models/form/sales/pages/buyer1_working_situation.rb
+++ b/app/models/form/sales/pages/buyer1_working_situation.rb
@@ -2,7 +2,7 @@ class Form::Sales::Pages::Buyer1WorkingSituation < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "buyer_1_working_situation"
- @header = "Which of these best describes buyer 1's working situation?"
+ @header = ""
@description = ""
@subsection = subsection
end
diff --git a/app/models/form/sales/pages/leasehold_charges.rb b/app/models/form/sales/pages/leasehold_charges.rb
new file mode 100644
index 000000000..7aed92db9
--- /dev/null
+++ b/app/models/form/sales/pages/leasehold_charges.rb
@@ -0,0 +1,15 @@
+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),
+ Form::Sales::Questions::LeaseholdCharges.new(nil, nil, self),
+ ]
+ end
+end
diff --git a/app/models/form/sales/pages/mortgage_amount.rb b/app/models/form/sales/pages/mortgage_amount.rb
index 1c80b2f52..88f642042 100644
--- a/app/models/form/sales/pages/mortgage_amount.rb
+++ b/app/models/form/sales/pages/mortgage_amount.rb
@@ -4,6 +4,9 @@ class Form::Sales::Pages::MortgageAmount < ::Form::Page
@header = "Mortgage Amount"
@description = ""
@subsection = subsection
+ @depends_on = [{
+ "mortgageused" => 1,
+ }]
end
def questions
diff --git a/app/models/form/sales/pages/person.rb b/app/models/form/sales/pages/person.rb
index 66e797cfa..3cf347353 100644
--- a/app/models/form/sales/pages/person.rb
+++ b/app/models/form/sales/pages/person.rb
@@ -17,6 +17,8 @@ class Form::Sales::Pages::Person < ::Form::Page
end
def field_for_person(field, suffix = "")
+ return [field, person_display_number, suffix].join if field == "details_known_"
+
[field, @person_index, suffix].join
end
end
diff --git a/app/models/form/sales/pages/person_age.rb b/app/models/form/sales/pages/person_age.rb
index 1eea81818..f0f86a251 100644
--- a/app/models/form/sales/pages/person_age.rb
+++ b/app/models/form/sales/pages/person_age.rb
@@ -4,7 +4,7 @@ class Form::Sales::Pages::PersonAge < Form::Sales::Pages::Person
@header = ""
@description = ""
@subsection = subsection
- @depends_on = page_depends_on
+ @depends_on = [{ details_known_question_id => 1, "jointpur" => joint_purchase? ? 1 : 2 }]
end
def questions
@@ -13,10 +13,4 @@ class Form::Sales::Pages::PersonAge < Form::Sales::Pages::Person
Form::Sales::Questions::PersonAge.new(field_for_person("age"), nil, self, person_index: @person_index),
]
end
-
- def page_depends_on
- return (person_display_number..4).map { |index| { "hholdcount" => index, "jointpur" => joint_purchase? ? 1 : 2 } } if person_display_number == 1
-
- [{ details_known_question_id => 1, "jointpur" => joint_purchase? ? 1 : 2 }]
- end
end
diff --git a/app/models/form/sales/pages/person_known.rb b/app/models/form/sales/pages/person_known.rb
index 8a2d29bba..df82ff41d 100644
--- a/app/models/form/sales/pages/person_known.rb
+++ b/app/models/form/sales/pages/person_known.rb
@@ -1,11 +1,11 @@
class Form::Sales::Pages::PersonKnown < Form::Sales::Pages::Person
def initialize(id, hsh, subsection, person_index:)
super
- @header_partial = "#{id}_page"
+ @header_partial = "person_#{person_display_number}_known_page"
@header = ""
@description = ""
@subsection = subsection
- @depends_on = page_depends_on
+ @depends_on = (person_display_number..4).map { |index| { "hholdcount" => index, "jointpur" => joint_purchase? ? 1 : 2 } }
end
def questions
@@ -13,8 +13,4 @@ class Form::Sales::Pages::PersonKnown < Form::Sales::Pages::Person
Form::Sales::Questions::PersonKnown.new(field_for_person("details_known_"), nil, self, person_index: @person_index),
]
end
-
- def page_depends_on
- (@person_index..4).map { |index| { "hholdcount" => index } }
- end
end
diff --git a/app/models/form/sales/pages/person_working_situation.rb b/app/models/form/sales/pages/person_working_situation.rb
index f232f6a84..a78e90be3 100644
--- a/app/models/form/sales/pages/person_working_situation.rb
+++ b/app/models/form/sales/pages/person_working_situation.rb
@@ -4,7 +4,7 @@ class Form::Sales::Pages::PersonWorkingSituation < Form::Sales::Pages::Person
@header = ""
@description = ""
@subsection = subsection
- @depends_on = page_depends_on
+ @depends_on = [{ details_known_question_id => 1, "jointpur" => joint_purchase? ? 1 : 2 }]
end
def questions
@@ -12,10 +12,4 @@ class Form::Sales::Pages::PersonWorkingSituation < Form::Sales::Pages::Person
Form::Sales::Questions::PersonWorkingSituation.new(field_for_person("ecstat"), nil, self, person_index: @person_index),
]
end
-
- def page_depends_on
- return (person_display_number..4).map { |index| { "hholdcount" => index, "jointpur" => joint_purchase? ? 1 : 2 } } if person_display_number == 1
-
- [{ details_known_question_id => 1, "jointpur" => joint_purchase? ? 1 : 2 }]
- end
end
diff --git a/app/models/form/sales/pages/property_wheelchair_accessible.rb b/app/models/form/sales/pages/property_wheelchair_accessible.rb
new file mode 100644
index 000000000..d587d61a7
--- /dev/null
+++ b/app/models/form/sales/pages/property_wheelchair_accessible.rb
@@ -0,0 +1,15 @@
+class Form::Sales::Pages::PropertyWheelchairAccessible < ::Form::Page
+ def initialize(id, hsh, subsection)
+ super
+ @id = "property_wheelchair_accessible"
+ @header = ""
+ @description = ""
+ @subsection = subsection
+ end
+
+ def questions
+ @questions ||= [
+ Form::Sales::Questions::PropertyWheelchairAccessible.new(nil, nil, self),
+ ]
+ end
+end
diff --git a/app/models/form/sales/questions/armed_forces_spouse.rb b/app/models/form/sales/questions/armed_forces_spouse.rb
new file mode 100644
index 000000000..cd9a3aca1
--- /dev/null
+++ b/app/models/form/sales/questions/armed_forces_spouse.rb
@@ -0,0 +1,19 @@
+class Form::Sales::Questions::ArmedForcesSpouse < ::Form::Question
+ def initialize(id, hsh, page)
+ super
+ @id = "armedforcesspouse"
+ @check_answer_label = "Are any of the buyers a spouse or civil partner of a UK armed forces regular who died in service within the last 2 years?"
+ @header = "Are any of the buyers a spouse or civil partner of a UK armed forces regular who died in service within the last 2 years?"
+ @type = "radio"
+ @hint_text = ""
+ @answer_options = ANSWER_OPTIONS
+ @page = page
+ end
+
+ ANSWER_OPTIONS = {
+ "4" => { "value" => "Yes" },
+ "5" => { "value" => "No" },
+ "6" => { "value" => "Buyer prefers not to say" },
+ "7" => { "value" => "Don't know" },
+ }.freeze
+end
diff --git a/app/models/form/sales/questions/leasehold_charges.rb b/app/models/form/sales/questions/leasehold_charges.rb
new file mode 100644
index 000000000..eb19a7377
--- /dev/null
+++ b/app/models/form/sales/questions/leasehold_charges.rb
@@ -0,0 +1,13 @@
+class Form::Sales::Questions::LeaseholdCharges < ::Form::Question
+ def initialize(id, hsh, page)
+ super
+ @id = "mscharge"
+ @check_answer_label = "Monthly leasehold charges"
+ @header = "Enter the total monthly charge"
+ @type = "numeric"
+ @page = page
+ @min = 0
+ @width = 5
+ @prefix = "£"
+ end
+end
diff --git a/app/models/form/sales/questions/leasehold_charges_known.rb b/app/models/form/sales/questions/leasehold_charges_known.rb
new file mode 100644
index 000000000..a94e7f63e
--- /dev/null
+++ b/app/models/form/sales/questions/leasehold_charges_known.rb
@@ -0,0 +1,27 @@
+class Form::Sales::Questions::LeaseholdChargesKnown < ::Form::Question
+ def initialize(id, hsh, page)
+ super
+ @id = "mscharge_known"
+ @check_answer_label = "Monthly leasehold charges known?"
+ @header = "Does the property have any monthly leasehold charges?"
+ @hint_text = "For example, service and management charges"
+ @type = "radio"
+ @answer_options = ANSWER_OPTIONS
+ @page = page
+ @conditional_for = {
+ "mscharge" => [1],
+ }
+ @hidden_in_check_answers = {
+ "depends_on" => [
+ {
+ "mscharge_known" => 1,
+ },
+ ],
+ }
+ end
+
+ ANSWER_OPTIONS = {
+ "1" => { "value" => "Yes" },
+ "0" => { "value" => "No" },
+ }.freeze
+end
diff --git a/app/models/form/sales/questions/person.rb b/app/models/form/sales/questions/person.rb
index ebc280860..3c7f78214 100644
--- a/app/models/form/sales/questions/person.rb
+++ b/app/models/form/sales/questions/person.rb
@@ -13,6 +13,8 @@ class Form::Sales::Questions::Person < ::Form::Question
end
def field_for_person(field, suffix = "")
+ return [field, person_display_number, suffix].join if field == "details_known_"
+
[field, @person_index, suffix].join
end
end
diff --git a/app/models/form/sales/questions/person_known.rb b/app/models/form/sales/questions/person_known.rb
index 0c1ef09c2..487b3f6d9 100644
--- a/app/models/form/sales/questions/person_known.rb
+++ b/app/models/form/sales/questions/person_known.rb
@@ -1,8 +1,8 @@
class Form::Sales::Questions::PersonKnown < Form::Sales::Questions::Person
def initialize(id, hsh, page, person_index:)
super
- @check_answer_label = "Details known for person #{person_index}?"
- @header = "Do you know the details for person #{person_index}?"
+ @check_answer_label = "Details known for person #{person_display_number}?"
+ @header = "Do you know the details for person #{person_display_number}?"
@type = "radio"
@answer_options = ANSWER_OPTIONS
@page = page
@@ -14,7 +14,7 @@ class Form::Sales::Questions::PersonKnown < Form::Sales::Questions::Person
},
],
}
- @check_answers_card_number = person_index + 2
+ @check_answers_card_number = person_index
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
new file mode 100644
index 000000000..0290815ef
--- /dev/null
+++ b/app/models/form/sales/questions/property_wheelchair_accessible.rb
@@ -0,0 +1,17 @@
+class Form::Sales::Questions::PropertyWheelchairAccessible < ::Form::Question
+ def initialize(id, hsh, page)
+ super
+ @id = "wchair"
+ @check_answer_label = "Property build or adapted to wheelchair-user standards"
+ @header = "Is the property build or adapted to wheelchair-user standards?"
+ @type = "radio"
+ @answer_options = ANSWER_OPTIONS
+ @page = page
+ end
+
+ ANSWER_OPTIONS = {
+ "1" => { "value" => "Yes" },
+ "2" => { "value" => "No" },
+ "3" => { "value" => "Don't know" },
+ }.freeze
+end
diff --git a/app/models/form/sales/subsections/discounted_ownership_scheme.rb b/app/models/form/sales/subsections/discounted_ownership_scheme.rb
index 9181e9c41..827ecf1de 100644
--- a/app/models/form/sales/subsections/discounted_ownership_scheme.rb
+++ b/app/models/form/sales/subsections/discounted_ownership_scheme.rb
@@ -16,6 +16,7 @@ class Form::Sales::Subsections::DiscountedOwnershipScheme < ::Form::Subsection
Form::Sales::Pages::MortgageAmount.new("mortgage_amount_discounted_ownership", nil, self),
Form::Sales::Pages::AboutDepositWithoutDiscount.new("about_deposit_discounted_ownership", nil, self),
Form::Sales::Pages::DepositValueCheck.new("discounted_ownership_deposit_value_check", nil, self),
+ Form::Sales::Pages::LeaseholdCharges.new("leasehold_charges_discounted_ownership", nil, self),
]
end
diff --git a/app/models/form/sales/subsections/household_characteristics.rb b/app/models/form/sales/subsections/household_characteristics.rb
index 2090b0f87..5fe1175e3 100644
--- a/app/models/form/sales/subsections/household_characteristics.rb
+++ b/app/models/form/sales/subsections/household_characteristics.rb
@@ -29,7 +29,8 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection
Form::Sales::Pages::Buyer2WorkingSituation.new(nil, nil, self),
Form::Sales::Pages::Buyer2LiveInProperty.new(nil, nil, self),
Form::Sales::Pages::NumberOfOthersInProperty.new(nil, nil, self),
- Form::Sales::Pages::PersonKnown.new("person_1_known", nil, self, person_index: 1),
+ Form::Sales::Pages::PersonKnown.new("person_1_known", nil, self, person_index: 2),
+ Form::Sales::Pages::PersonKnown.new("person_1_known_joint_purchase", nil, self, person_index: 3),
Form::Sales::Pages::PersonRelationshipToBuyer1.new("person_1_relationship_to_buyer_1", nil, self, person_index: 2),
Form::Sales::Pages::PersonRelationshipToBuyer1.new("person_1_relationship_to_buyer_1_joint_purchase", nil, self, person_index: 3),
Form::Sales::Pages::PersonAge.new("person_1_age", nil, self, person_index: 2),
@@ -38,7 +39,8 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection
Form::Sales::Pages::PersonGenderIdentity.new("person_1_gender_identity_joint_purchase", nil, self, person_index: 3),
Form::Sales::Pages::PersonWorkingSituation.new("person_1_working_situation", nil, self, person_index: 2),
Form::Sales::Pages::PersonWorkingSituation.new("person_1_working_situation_joint_purchase", nil, self, person_index: 3),
- Form::Sales::Pages::PersonKnown.new("person_2_known", nil, self, person_index: 2),
+ Form::Sales::Pages::PersonKnown.new("person_2_known", nil, self, person_index: 3),
+ Form::Sales::Pages::PersonKnown.new("person_2_known_joint_purchase", nil, self, person_index: 4),
Form::Sales::Pages::PersonRelationshipToBuyer1.new("person_2_relationship_to_buyer_1", nil, self, person_index: 3),
Form::Sales::Pages::PersonRelationshipToBuyer1.new("person_2_relationship_to_buyer_1_joint_purchase", nil, self, person_index: 4),
Form::Sales::Pages::PersonAge.new("person_2_age", nil, self, person_index: 3),
@@ -47,7 +49,8 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection
Form::Sales::Pages::PersonGenderIdentity.new("person_2_gender_identity_joint_purchase", nil, self, person_index: 4),
Form::Sales::Pages::PersonWorkingSituation.new("person_2_working_situation", nil, self, person_index: 3),
Form::Sales::Pages::PersonWorkingSituation.new("person_2_working_situation_joint_purchase", nil, self, person_index: 4),
- Form::Sales::Pages::PersonKnown.new("person_3_known", nil, self, person_index: 3),
+ Form::Sales::Pages::PersonKnown.new("person_3_known", nil, self, person_index: 4),
+ Form::Sales::Pages::PersonKnown.new("person_3_known_joint_purchase", nil, self, person_index: 5),
Form::Sales::Pages::PersonRelationshipToBuyer1.new("person_3_relationship_to_buyer_1", nil, self, person_index: 4),
Form::Sales::Pages::PersonRelationshipToBuyer1.new("person_3_relationship_to_buyer_1_joint_purchase", nil, self, person_index: 5),
Form::Sales::Pages::PersonAge.new("person_3_age", nil, self, person_index: 4),
@@ -56,7 +59,8 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection
Form::Sales::Pages::PersonGenderIdentity.new("person_3_gender_identity_joint_purchase", nil, self, person_index: 5),
Form::Sales::Pages::PersonWorkingSituation.new("person_3_working_situation", nil, self, person_index: 4),
Form::Sales::Pages::PersonWorkingSituation.new("person_3_working_situation_joint_purchase", nil, self, person_index: 5),
- Form::Sales::Pages::PersonKnown.new("person_4_known", nil, self, person_index: 4),
+ Form::Sales::Pages::PersonKnown.new("person_4_known", nil, self, person_index: 5),
+ Form::Sales::Pages::PersonKnown.new("person_4_known_joint_purchase", nil, self, person_index: 6),
Form::Sales::Pages::PersonRelationshipToBuyer1.new("person_4_relationship_to_buyer_1", nil, self, person_index: 5),
Form::Sales::Pages::PersonRelationshipToBuyer1.new("person_4_relationship_to_buyer_1_joint_purchase", nil, self, person_index: 6),
Form::Sales::Pages::PersonAge.new("person_4_age", nil, self, person_index: 5),
diff --git a/app/models/form/sales/subsections/household_needs.rb b/app/models/form/sales/subsections/household_needs.rb
index 9c93e8ba4..4e9cab5f5 100644
--- a/app/models/form/sales/subsections/household_needs.rb
+++ b/app/models/form/sales/subsections/household_needs.rb
@@ -11,6 +11,7 @@ class Form::Sales::Subsections::HouseholdNeeds < ::Form::Subsection
@pages ||= [
Form::Sales::Pages::ArmedForces.new(nil, nil, self),
Form::Sales::Pages::BuyerStillServing.new(nil, nil, self),
+ Form::Sales::Pages::ArmedForcesSpouse.new(nil, nil, self),
Form::Sales::Pages::HouseholdDisability.new(nil, nil, self),
Form::Sales::Pages::HouseholdWheelchair.new(nil, nil, self),
Form::Sales::Pages::HouseholdWheelchairCheck.new("wheelchair_check", nil, self),
diff --git a/app/models/form/sales/subsections/outright_sale.rb b/app/models/form/sales/subsections/outright_sale.rb
index 2b38841ba..a751c6734 100644
--- a/app/models/form/sales/subsections/outright_sale.rb
+++ b/app/models/form/sales/subsections/outright_sale.rb
@@ -14,6 +14,7 @@ class Form::Sales::Subsections::OutrightSale < ::Form::Subsection
Form::Sales::Pages::MortgageAmount.new("mortgage_amount_outright_sale", nil, self),
Form::Sales::Pages::AboutDepositWithoutDiscount.new("about_deposit_outright_sale", nil, self),
Form::Sales::Pages::DepositValueCheck.new("outright_sale_deposit_value_check", nil, self),
+ Form::Sales::Pages::LeaseholdCharges.new("leasehold_charges_outright_sale", nil, self),
]
end
diff --git a/app/models/form/sales/subsections/property_information.rb b/app/models/form/sales/subsections/property_information.rb
index 2a29e27c2..02d7b4037 100644
--- a/app/models/form/sales/subsections/property_information.rb
+++ b/app/models/form/sales/subsections/property_information.rb
@@ -13,6 +13,7 @@ class Form::Sales::Subsections::PropertyInformation < ::Form::Subsection
Form::Sales::Pages::PropertyBuildingType.new(nil, nil, self),
Form::Sales::Pages::PropertyUnitType.new(nil, nil, self),
Form::Sales::Pages::PropertyLocalAuthority.new(nil, nil, self),
+ Form::Sales::Pages::PropertyWheelchairAccessible.new(nil, nil, self),
]
end
end
diff --git a/app/models/form/sales/subsections/shared_ownership_scheme.rb b/app/models/form/sales/subsections/shared_ownership_scheme.rb
index c40fa9441..043459adb 100644
--- a/app/models/form/sales/subsections/shared_ownership_scheme.rb
+++ b/app/models/form/sales/subsections/shared_ownership_scheme.rb
@@ -24,6 +24,7 @@ class Form::Sales::Subsections::SharedOwnershipScheme < ::Form::Subsection
Form::Sales::Pages::AboutDepositWithoutDiscount.new("about_deposit_shared_ownership", nil, self),
Form::Sales::Pages::DepositValueCheck.new("shared_ownership_deposit_value_check", nil, self),
Form::Sales::Pages::MonthlyRent.new(nil, nil, self),
+ Form::Sales::Pages::LeaseholdCharges.new("leasehold_charges_shared_ownership", nil, self),
]
end
diff --git a/app/services/imports/lettings_logs_import_service.rb b/app/services/imports/lettings_logs_import_service.rb
index c70da3ab4..1d5ddfca3 100644
--- a/app/services/imports/lettings_logs_import_service.rb
+++ b/app/services/imports/lettings_logs_import_service.rb
@@ -246,6 +246,7 @@ module Imports
apply_date_consistency!(attributes)
apply_household_consistency!(attributes)
+ create_organisation_relationship!(attributes)
lettings_log = save_lettings_log(attributes, previous_status)
compute_differences(lettings_log, attributes)
@@ -681,5 +682,13 @@ module Imports
0
end
end
+
+ def create_organisation_relationship!(attributes)
+ parent_organisation_id = attributes["owning_organisation_id"]
+ child_organisation_id = attributes["managing_organisation_id"]
+ return if parent_organisation_id == child_organisation_id
+
+ OrganisationRelationship.find_or_create_by!(parent_organisation_id:, child_organisation_id:)
+ end
end
end
diff --git a/config/forms/2021_2022.json b/config/forms/2021_2022.json
index ca2fa6e2e..92d495f24 100644
--- a/config/forms/2021_2022.json
+++ b/config/forms/2021_2022.json
@@ -4624,7 +4624,7 @@
}
},
"person_7_known": {
- "header": "You’ve given us the details for 7 people in the household",
+ "header": "You’ve given us the details for 6 people in the household",
"description": "",
"questions": {
"details_known_7": {
diff --git a/config/forms/2022_2023.json b/config/forms/2022_2023.json
index dd6d933a3..f49070bbf 100644
--- a/config/forms/2022_2023.json
+++ b/config/forms/2022_2023.json
@@ -4623,7 +4623,7 @@
}
},
"person_7_known": {
- "header": "You’ve given us the details for 7 people in the household",
+ "header": "You’ve given us the details for 6 people in the household",
"description": "",
"questions": {
"details_known_7": {
diff --git a/db/migrate/20230103112225_add_mscharge_known_to_sales.rb b/db/migrate/20230103112225_add_mscharge_known_to_sales.rb
new file mode 100644
index 000000000..cf09e8a52
--- /dev/null
+++ b/db/migrate/20230103112225_add_mscharge_known_to_sales.rb
@@ -0,0 +1,8 @@
+class AddMschargeKnownToSales < ActiveRecord::Migration[7.0]
+ def change
+ change_table :sales_logs, bulk: true do |t|
+ t.column :mscharge_known, :integer
+ t.column :mscharge, :decimal, precision: 10, scale: 2
+ end
+ end
+end
diff --git a/db/migrate/20230104152012_add_wchair_to_sales_log.rb b/db/migrate/20230104152012_add_wchair_to_sales_log.rb
new file mode 100644
index 000000000..62097c944
--- /dev/null
+++ b/db/migrate/20230104152012_add_wchair_to_sales_log.rb
@@ -0,0 +1,7 @@
+class AddWchairToSalesLog < ActiveRecord::Migration[7.0]
+ def change
+ change_table :sales_logs, bulk: true do |t|
+ t.column :wchair, :integer
+ end
+ end
+end
diff --git a/db/migrate/20230105103733_add_armed_forces_spouse.rb b/db/migrate/20230105103733_add_armed_forces_spouse.rb
new file mode 100644
index 000000000..37576d9e2
--- /dev/null
+++ b/db/migrate/20230105103733_add_armed_forces_spouse.rb
@@ -0,0 +1,7 @@
+class AddArmedForcesSpouse < ActiveRecord::Migration[7.0]
+ def change
+ change_table :sales_logs, bulk: true do |t|
+ t.column :armedforcesspouse, :integer
+ end
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 5e0691006..8812128eb 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema[7.0].define(version: 2023_01_04_164318) do
+ActiveRecord::Schema[7.0].define(version: 2023_01_05_103733) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -421,9 +421,6 @@ ActiveRecord::Schema[7.0].define(version: 2023_01_04_164318) 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"
@@ -462,6 +459,10 @@ ActiveRecord::Schema[7.0].define(version: 2023_01_04_164318) do
t.integer "proplen"
t.integer "prevten"
t.integer "mortgageused"
+ t.integer "wchair"
+ t.integer "armedforcesspouse"
+ t.integer "mscharge_known"
+ t.decimal "mscharge", precision: 10, scale: 2
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/spec/factories/sales_log.rb b/spec/factories/sales_log.rb
index 882279e70..04cf7a94d 100644
--- a/spec/factories/sales_log.rb
+++ b/spec/factories/sales_log.rb
@@ -91,6 +91,10 @@ FactoryBot.define do
relat6 { "P" }
hb { 4 }
mortgageused { 1 }
+ wchair { 1 }
+ armedforcesspouse { 5 }
+ mscharge_known { 1 }
+ mscharge { 100 }
end
end
end
diff --git a/spec/features/form/check_answers_page_spec.rb b/spec/features/form/check_answers_page_lettings_logs_spec.rb
similarity index 99%
rename from spec/features/form/check_answers_page_spec.rb
rename to spec/features/form/check_answers_page_lettings_logs_spec.rb
index 7834e0dad..f8f0b8064 100644
--- a/spec/features/form/check_answers_page_spec.rb
+++ b/spec/features/form/check_answers_page_lettings_logs_spec.rb
@@ -1,7 +1,7 @@
require "rails_helper"
require_relative "helpers"
-RSpec.describe "Form Check Answers Page" do
+RSpec.describe "Lettings Log Check Answers Page" do
include Helpers
let(:user) { FactoryBot.create(:user) }
let(:subsection) { "household-characteristics" }
diff --git a/spec/features/form/check_answers_page_sales_logs_spec.rb b/spec/features/form/check_answers_page_sales_logs_spec.rb
new file mode 100644
index 000000000..9d1f33d64
--- /dev/null
+++ b/spec/features/form/check_answers_page_sales_logs_spec.rb
@@ -0,0 +1,62 @@
+require "rails_helper"
+require_relative "helpers"
+
+RSpec.describe "Sales Log Check Answers Page" do
+ include Helpers
+ let(:user) { FactoryBot.create(:user) }
+ let(:subsection) { "household-characteristics" }
+ let(:conditional_subsection) { "conditional-question" }
+
+ let(:completed_sales_log_joint_purchase) do
+ FactoryBot.create(
+ :sales_log,
+ :completed,
+ created_by: user,
+ jointpur: 1,
+ )
+ end
+
+ let(:completed_sales_log_non_joint_purchase) do
+ FactoryBot.create(
+ :sales_log,
+ :completed,
+ created_by: user,
+ jointpur: 2,
+ )
+ end
+
+ before do
+ sign_in user
+ end
+
+ context "when the user needs to check their answers for a subsection" do
+ let(:last_question_for_subsection) { "propcode" }
+
+ it "does not group questions into summary cards if the questions in the subsection don't have a check_answers_card_number attribute" do
+ visit("/sales-logs/#{completed_sales_log_joint_purchase.id}/household-needs/check-answers")
+ assert_selector ".x-govuk-summary-card__title", count: 0
+ end
+
+ context "when the user is checking their answers for the household characteristics subsection" do
+ context "and the log is for a joint purchase" do
+ it "they see a seperate summary card for each member of the household" do
+ visit("/sales-logs/#{completed_sales_log_joint_purchase.id}/#{subsection}/check-answers")
+ assert_selector ".x-govuk-summary-card__title", text: "Buyer 1", count: 1
+ assert_selector ".x-govuk-summary-card__title", text: "Buyer 2", count: 1
+ assert_selector ".x-govuk-summary-card__title", text: "Person 1", count: 1
+ assert_selector ".x-govuk-summary-card__title", text: "Person 2", count: 0
+ end
+ end
+
+ context "and the log is for a non-joint purchase" do
+ it "they see a seperate summary card for each member of the household" do
+ visit("/sales-logs/#{completed_sales_log_non_joint_purchase.id}/#{subsection}/check-answers")
+ assert_selector ".x-govuk-summary-card__title", text: "Buyer 1", count: 1
+ assert_selector ".x-govuk-summary-card__title", text: "Buyer 2", count: 0
+ assert_selector ".x-govuk-summary-card__title", text: "Person 1", count: 1
+ assert_selector ".x-govuk-summary-card__title", text: "Person 2", count: 0
+ end
+ end
+ end
+ end
+end
diff --git a/spec/fixtures/imports/logs/00d2343e-d5fa-4c89-8400-ec3854b0f2b4.xml b/spec/fixtures/imports/logs/00d2343e-d5fa-4c89-8400-ec3854b0f2b4.xml
index e9835d1e1..8bc6a935c 100644
--- a/spec/fixtures/imports/logs/00d2343e-d5fa-4c89-8400-ec3854b0f2b4.xml
+++ b/spec/fixtures/imports/logs/00d2343e-d5fa-4c89-8400-ec3854b0f2b4.xml
@@ -413,7 +413,7 @@
655
655
- 1
+ 2
3
diff --git a/spec/fixtures/imports/logs/0b4a68df-30cc-474a-93c0-a56ce8fdad3b.xml b/spec/fixtures/imports/logs/0b4a68df-30cc-474a-93c0-a56ce8fdad3b.xml
index 3faacf28b..38cef1339 100644
--- a/spec/fixtures/imports/logs/0b4a68df-30cc-474a-93c0-a56ce8fdad3b.xml
+++ b/spec/fixtures/imports/logs/0b4a68df-30cc-474a-93c0-a56ce8fdad3b.xml
@@ -413,7 +413,7 @@
N/A
N/A
- 1
+ 2
false
diff --git a/spec/models/form/sales/pages/armed_forces_spouse_spec.rb b/spec/models/form/sales/pages/armed_forces_spouse_spec.rb
new file mode 100644
index 000000000..75be2b3f3
--- /dev/null
+++ b/spec/models/form/sales/pages/armed_forces_spouse_spec.rb
@@ -0,0 +1,29 @@
+require "rails_helper"
+
+RSpec.describe Form::Sales::Pages::ArmedForcesSpouse, 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[armedforcesspouse])
+ end
+
+ it "has the correct id" do
+ expect(page.id).to eq("armed_forces_spouse")
+ 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
+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 2a48f0b0f..4b432ed03 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("Which of these best describes buyer 1's working situation?")
+ expect(page.header).to eq("")
end
end
diff --git a/spec/models/form/sales/pages/leasehold_charges_spec.rb b/spec/models/form/sales/pages/leasehold_charges_spec.rb
new file mode 100644
index 000000000..d35d1076b
--- /dev/null
+++ b/spec/models/form/sales/pages/leasehold_charges_spec.rb
@@ -0,0 +1,33 @@
+require "rails_helper"
+
+RSpec.describe Form::Sales::Pages::LeaseholdCharges, 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[mscharge_known mscharge])
+ end
+
+ it "has the correct id" do
+ expect(page.id).to eq(nil)
+ 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_amount_spec.rb b/spec/models/form/sales/pages/mortgage_amount_spec.rb
index 28c37908b..4df02d1af 100644
--- a/spec/models/form/sales/pages/mortgage_amount_spec.rb
+++ b/spec/models/form/sales/pages/mortgage_amount_spec.rb
@@ -28,6 +28,8 @@ RSpec.describe Form::Sales::Pages::MortgageAmount, type: :model do
end
it "has correct depends_on" do
- expect(page.depends_on).to be_nil
+ expect(page.depends_on).to eq([{
+ "mortgageused" => 1,
+ }])
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 4c4159896..f8bc96692 100644
--- a/spec/models/form/sales/pages/person_age_spec.rb
+++ b/spec/models/form/sales/pages/person_age_spec.rb
@@ -35,7 +35,7 @@ RSpec.describe Form::Sales::Pages::PersonAge, type: :model do
it "has correct depends_on" do
expect(page.depends_on).to eq(
- [{ "hholdcount" => 1, "jointpur" => 2 }, { "hholdcount" => 2, "jointpur" => 2 }, { "hholdcount" => 3, "jointpur" => 2 }, { "hholdcount" => 4, "jointpur" => 2 }],
+ [{ "details_known_1" => 1, "jointpur" => 2 }],
)
end
end
@@ -119,7 +119,7 @@ RSpec.describe Form::Sales::Pages::PersonAge, type: :model do
it "has correct depends_on" do
expect(page.depends_on).to eq(
- [{ "hholdcount" => 1, "jointpur" => 1 }, { "hholdcount" => 2, "jointpur" => 1 }, { "hholdcount" => 3, "jointpur" => 1 }, { "hholdcount" => 4, "jointpur" => 1 }],
+ [{ "details_known_1" => 1, "jointpur" => 1 }],
)
end
end
diff --git a/spec/models/form/sales/pages/person_known_spec.rb b/spec/models/form/sales/pages/person_known_spec.rb
index 0dc454143..bb73d6b63 100644
--- a/spec/models/form/sales/pages/person_known_spec.rb
+++ b/spec/models/form/sales/pages/person_known_spec.rb
@@ -3,117 +3,229 @@ require "rails_helper"
RSpec.describe Form::Sales::Pages::PersonKnown, type: :model do
subject(:page) { described_class.new(page_id, page_definition, subsection, person_index:) }
- let(:page_id) { "person_2_known" }
- let(:page_definition) { nil }
- let(:subsection) { instance_double(Form::Subsection) }
- let(:person_index) { 1 }
+ context "without joint purchase" do
+ let(:page_id) { "person_2_known" }
+ let(:page_definition) { nil }
+ let(:subsection) { instance_double(Form::Subsection) }
+ let(:person_index) { 3 }
- it "has correct subsection" do
- expect(page.subsection).to eq(subsection)
- end
+ it "has correct subsection" do
+ expect(page.subsection).to eq(subsection)
+ end
- it "has the correct header" do
- expect(page.header).to eq("")
- 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 the correct description" do
+ expect(page.description).to eq("")
+ end
+
+ context "with person 1" do
+ let(:page_id) { "person_1_known" }
+ let(:person_index) { 2 }
+
+ it "has correct questions" do
+ expect(page.questions.map(&:id)).to eq(%w[details_known_1])
+ end
+
+ it "has the correct id" do
+ expect(page.id).to eq("person_1_known")
+ end
- context "with person 1" do
- let(:page_id) { "person_1_known" }
- let(:person_index) { 1 }
+ it "has the correct header_partial" do
+ expect(page.header_partial).to eq("person_1_known_page")
+ end
- it "has correct questions" do
- expect(page.questions.map(&:id)).to eq(%w[details_known_1])
+ it "has correct depends_on" do
+ expect(page.depends_on).to eq(
+ [
+ { "hholdcount" => 1, "jointpur" => 2 }, { "hholdcount" => 2, "jointpur" => 2 }, { "hholdcount" => 3, "jointpur" => 2 }, { "hholdcount" => 4, "jointpur" => 2 }
+ ],
+ )
+ end
end
- it "has the correct id" do
- expect(page.id).to eq("person_1_known")
+ context "with person 2" do
+ let(:page_id) { "person_2_known" }
+ let(:person_index) { 3 }
+
+ it "has correct questions" do
+ expect(page.questions.map(&:id)).to eq(%w[details_known_2])
+ end
+
+ it "has the correct id" do
+ expect(page.id).to eq("person_2_known")
+ end
+
+ it "has the correct header_partial" do
+ expect(page.header_partial).to eq("person_2_known_page")
+ end
+
+ it "has correct depends_on" do
+ expect(page.depends_on).to eq(
+ [{ "hholdcount" => 2, "jointpur" => 2 }, { "hholdcount" => 3, "jointpur" => 2 }, { "hholdcount" => 4, "jointpur" => 2 }],
+ )
+ end
end
- it "has the correct header_partial" do
- expect(page.header_partial).to eq("person_1_known_page")
+ context "with person 3" do
+ let(:page_id) { "person_3_known" }
+ let(:person_index) { 4 }
+
+ it "has correct questions" do
+ expect(page.questions.map(&:id)).to eq(%w[details_known_3])
+ end
+
+ it "has the correct id" do
+ expect(page.id).to eq("person_3_known")
+ end
+
+ it "has the correct header_partial" do
+ expect(page.header_partial).to eq("person_3_known_page")
+ end
+
+ it "has correct depends_on" do
+ expect(page.depends_on).to eq(
+ [{ "hholdcount" => 3, "jointpur" => 2 }, { "hholdcount" => 4, "jointpur" => 2 }],
+ )
+ end
end
- it "has correct depends_on" do
- expect(page.depends_on).to eq(
- [
- { "hholdcount" => 1 },
- { "hholdcount" => 2 },
- { "hholdcount" => 3 },
- { "hholdcount" => 4 },
- ],
- )
+ context "with person 4" do
+ let(:page_id) { "person_4_known" }
+ let(:person_index) { 5 }
+
+ it "has correct questions" do
+ expect(page.questions.map(&:id)).to eq(%w[details_known_4])
+ end
+
+ it "has the correct id" do
+ expect(page.id).to eq("person_4_known")
+ end
+
+ it "has the correct header_partial" do
+ expect(page.header_partial).to eq("person_4_known_page")
+ end
+
+ it "has correct depends_on" do
+ expect(page.depends_on).to eq(
+ [{ "hholdcount" => 4, "jointpur" => 2 }],
+ )
+ end
end
end
- context "with person 2" do
+ context "with joint purchase" do
let(:page_id) { "person_2_known" }
- let(:person_index) { 2 }
+ let(:page_definition) { nil }
+ let(:subsection) { instance_double(Form::Subsection) }
+ let(:person_index) { 4 }
- it "has correct questions" do
- expect(page.questions.map(&:id)).to eq(%w[details_known_2])
+ it "has correct subsection" do
+ expect(page.subsection).to eq(subsection)
end
- it "has the correct id" do
- expect(page.id).to eq("person_2_known")
+ it "has the correct header" do
+ expect(page.header).to eq("")
end
- it "has the correct header_partial" do
- expect(page.header_partial).to eq("person_2_known_page")
+ it "has the correct description" do
+ expect(page.description).to eq("")
end
- it "has correct depends_on" do
- expect(page.depends_on).to eq(
- [{ "hholdcount" => 2 }, { "hholdcount" => 3 }, { "hholdcount" => 4 }],
- )
- end
- end
+ context "with person 1" do
+ let(:page_id) { "person_1_known_joint_purchase" }
+ let(:person_index) { 3 }
- context "with person 3" do
- let(:page_id) { "person_3_known" }
- let(:person_index) { 3 }
+ it "has correct questions" do
+ expect(page.questions.map(&:id)).to eq(%w[details_known_1])
+ end
- it "has correct questions" do
- expect(page.questions.map(&:id)).to eq(%w[details_known_3])
- end
+ it "has the correct id" do
+ expect(page.id).to eq("person_1_known_joint_purchase")
+ end
- it "has the correct id" do
- expect(page.id).to eq("person_3_known")
- end
+ it "has the correct header_partial" do
+ expect(page.header_partial).to eq("person_1_known_page")
+ end
- it "has the correct header_partial" do
- expect(page.header_partial).to eq("person_3_known_page")
+ it "has correct depends_on" do
+ expect(page.depends_on).to eq(
+ [
+ { "hholdcount" => 1, "jointpur" => 1 }, { "hholdcount" => 2, "jointpur" => 1 }, { "hholdcount" => 3, "jointpur" => 1 }, { "hholdcount" => 4, "jointpur" => 1 }
+ ],
+ )
+ end
end
- it "has correct depends_on" do
- expect(page.depends_on).to eq(
- [{ "hholdcount" => 3 }, { "hholdcount" => 4 }],
- )
- end
- end
+ context "with person 2" do
+ let(:page_id) { "person_2_known_joint_purchase" }
+ let(:person_index) { 4 }
- context "with person 4" do
- let(:page_id) { "person_4_known" }
- let(:person_index) { 4 }
+ it "has correct questions" do
+ expect(page.questions.map(&:id)).to eq(%w[details_known_2])
+ end
- it "has correct questions" do
- expect(page.questions.map(&:id)).to eq(%w[details_known_4])
- end
+ it "has the correct id" do
+ expect(page.id).to eq("person_2_known_joint_purchase")
+ end
+
+ it "has the correct header_partial" do
+ expect(page.header_partial).to eq("person_2_known_page")
+ end
- it "has the correct id" do
- expect(page.id).to eq("person_4_known")
+ it "has correct depends_on" do
+ expect(page.depends_on).to eq(
+ [{ "hholdcount" => 2, "jointpur" => 1 }, { "hholdcount" => 3, "jointpur" => 1 }, { "hholdcount" => 4, "jointpur" => 1 }],
+ )
+ end
end
- it "has the correct header_partial" do
- expect(page.header_partial).to eq("person_4_known_page")
+ context "with person 3" do
+ let(:page_id) { "person_3_known_joint_purchase" }
+ let(:person_index) { 5 }
+
+ it "has correct questions" do
+ expect(page.questions.map(&:id)).to eq(%w[details_known_3])
+ end
+
+ it "has the correct id" do
+ expect(page.id).to eq("person_3_known_joint_purchase")
+ end
+
+ it "has the correct header_partial" do
+ expect(page.header_partial).to eq("person_3_known_page")
+ end
+
+ it "has correct depends_on" do
+ expect(page.depends_on).to eq(
+ [{ "hholdcount" => 3, "jointpur" => 1 }, { "hholdcount" => 4, "jointpur" => 1 }],
+ )
+ end
end
- it "has correct depends_on" do
- expect(page.depends_on).to eq(
- [{ "hholdcount" => 4 }],
- )
+ context "with person 4" do
+ let(:page_id) { "person_4_known_joint_purchase" }
+ let(:person_index) { 6 }
+
+ it "has correct questions" do
+ expect(page.questions.map(&:id)).to eq(%w[details_known_4])
+ end
+
+ it "has the correct id" do
+ expect(page.id).to eq("person_4_known_joint_purchase")
+ end
+
+ it "has the correct header_partial" do
+ expect(page.header_partial).to eq("person_4_known_page")
+ end
+
+ it "has correct depends_on" do
+ expect(page.depends_on).to eq(
+ [{ "hholdcount" => 4, "jointpur" => 1 }],
+ )
+ end
end
end
end
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 e38d5ff47..65bdb42d0 100644
--- a/spec/models/form/sales/pages/person_working_situation_spec.rb
+++ b/spec/models/form/sales/pages/person_working_situation_spec.rb
@@ -35,7 +35,7 @@ RSpec.describe Form::Sales::Pages::PersonWorkingSituation, type: :model do
end
it "has correct depends_on" do
- expect(page.depends_on).to eq([{ "hholdcount" => 1, "jointpur" => 2 }, { "hholdcount" => 2, "jointpur" => 2 }, { "hholdcount" => 3, "jointpur" => 2 }, { "hholdcount" => 4, "jointpur" => 2 }])
+ expect(page.depends_on).to eq([{ "details_known_1" => 1, "jointpur" => 2 }])
end
end
@@ -119,7 +119,7 @@ RSpec.describe Form::Sales::Pages::PersonWorkingSituation, type: :model do
end
it "has correct depends_on" do
- expect(page.depends_on).to eq([{ "hholdcount" => 1, "jointpur" => 1 }, { "hholdcount" => 2, "jointpur" => 1 }, { "hholdcount" => 3, "jointpur" => 1 }, { "hholdcount" => 4, "jointpur" => 1 }])
+ expect(page.depends_on).to eq([{ "details_known_1" => 1, "jointpur" => 1 }])
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
new file mode 100644
index 000000000..17b840186
--- /dev/null
+++ b/spec/models/form/sales/pages/property_local_authority_spec.rb
@@ -0,0 +1,34 @@
+require "rails_helper"
+
+RSpec.describe Form::Sales::Pages::PropertyLocalAuthority, 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[
+ la_known
+ la
+ ],
+ )
+ end
+
+ it "has the correct id" do
+ expect(page.id).to eq("property_local_authority")
+ 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
+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
new file mode 100644
index 000000000..f2ffb3567
--- /dev/null
+++ b/spec/models/form/sales/pages/property_wheelchair_accessible_spec.rb
@@ -0,0 +1,29 @@
+require "rails_helper"
+
+RSpec.describe Form::Sales::Pages::PropertyWheelchairAccessible, 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[wchair])
+ end
+
+ it "has the correct id" do
+ expect(page.id).to eq("property_wheelchair_accessible")
+ 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
+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
new file mode 100644
index 000000000..67bf934ff
--- /dev/null
+++ b/spec/models/form/sales/questions/armed_forces_spouse_spec.rb
@@ -0,0 +1,46 @@
+require "rails_helper"
+
+RSpec.describe Form::Sales::Questions::ArmedForcesSpouse, 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("armedforcesspouse")
+ end
+
+ it "has the correct header" do
+ expect(question.header).to eq("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?")
+ end
+
+ it "has the correct check_answer_label" do
+ expect(question.check_answer_label).to eq("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?")
+ 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({
+ "4" => { "value" => "Yes" },
+ "5" => { "value" => "No" },
+ "6" => { "value" => "Buyer prefers not to say" },
+ "7" => { "value" => "Don't know" },
+ })
+ end
+end
diff --git a/spec/models/form/sales/questions/leasehold_charges_known_spec.rb b/spec/models/form/sales/questions/leasehold_charges_known_spec.rb
new file mode 100644
index 000000000..d47b535eb
--- /dev/null
+++ b/spec/models/form/sales/questions/leasehold_charges_known_spec.rb
@@ -0,0 +1,60 @@
+require "rails_helper"
+
+RSpec.describe Form::Sales::Questions::LeaseholdChargesKnown, 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("mscharge_known")
+ end
+
+ it "has the correct header" do
+ expect(question.header).to eq("Does the property have any monthly leasehold charges?")
+ end
+
+ it "has the correct check_answer_label" do
+ expect(question.check_answer_label).to eq("Monthly leasehold charges known?")
+ 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" => "No" },
+ "1" => { "value" => "Yes" },
+ })
+ end
+
+ it "has correct conditional for" do
+ expect(question.conditional_for).to eq({
+ "mscharge" => [1],
+ })
+ end
+
+ it "has the correct hint" do
+ expect(question.hint_text).to eq("For example, service and management charges")
+ end
+
+ it "has correct hidden_in_check_answers for" do
+ expect(question.hidden_in_check_answers).to eq({
+ "depends_on" => [
+ {
+ "mscharge_known" => 1,
+ },
+ ],
+ })
+ end
+end
diff --git a/spec/models/form/sales/questions/leasehold_charges_spec.rb b/spec/models/form/sales/questions/leasehold_charges_spec.rb
new file mode 100644
index 000000000..a06fc9975
--- /dev/null
+++ b/spec/models/form/sales/questions/leasehold_charges_spec.rb
@@ -0,0 +1,49 @@
+require "rails_helper"
+
+RSpec.describe Form::Sales::Questions::LeaseholdCharges, 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("mscharge")
+ end
+
+ it "has the correct header" do
+ expect(question.header).to eq("Enter the total monthly charge")
+ end
+
+ it "has the correct check_answer_label" do
+ expect(question.check_answer_label).to eq("Monthly leasehold charges")
+ end
+
+ it "has the correct type" do
+ expect(question.type).to eq("numeric")
+ end
+
+ it "is not marked as derived" do
+ expect(question.derived?).to be false
+ end
+
+ it "has the correct hint" do
+ expect(question.hint_text).to be_nil
+ end
+
+ it "has the correct width" do
+ expect(question.width).to eq(5)
+ end
+
+ it "has the correct min" do
+ expect(question.min).to eq(0)
+ end
+
+ it "has the correct prefix" do
+ expect(question.prefix).to eq("£")
+ end
+end
diff --git a/spec/models/form/sales/questions/person_known_spec.rb b/spec/models/form/sales/questions/person_known_spec.rb
index 2c33346f0..551ac096e 100644
--- a/spec/models/form/sales/questions/person_known_spec.rb
+++ b/spec/models/form/sales/questions/person_known_spec.rb
@@ -6,7 +6,11 @@ RSpec.describe Form::Sales::Questions::PersonKnown, type: :model do
let(:question_id) { "details_known_1" }
let(:question_definition) { nil }
let(:page) { instance_double(Form::Page) }
- let(:person_index) { 1 }
+ let(:person_index) { 2 }
+
+ before do
+ allow(page).to receive(:id).and_return("person_1_known")
+ end
it "has correct page" do
expect(question.page).to eq(page)
@@ -27,44 +31,291 @@ RSpec.describe Form::Sales::Questions::PersonKnown, type: :model do
})
end
- it "has correct conditional for" do
- expect(question.conditional_for).to eq(nil)
- end
-
it "has the correct hint" do
expect(question.hint_text).to eq("")
end
- context "with person 1" do
- let(:question_id) { "details_known_1" }
- let(:person_index) { 1 }
+ context "with a non joint purchase" do
+ context "and person 1" do
+ let(:question_id) { "details_known_1" }
+ let(:person_index) { 2 }
+
+ before do
+ allow(page).to receive(:id).and_return("person_1_known")
+ end
+
+ it "has the correct id" do
+ expect(question.id).to eq("details_known_1")
+ end
+
+ it "has the correct header" do
+ expect(question.header).to eq("Do you know the details for person 1?")
+ end
+
+ it "has the correct check_answer_label" do
+ expect(question.check_answer_label).to eq("Details known for person 1?")
+ end
+
+ it "has correct conditional for" do
+ expect(question.conditional_for).to be_nil
+ end
+
+ it "has the correct hidden_in_check_answers" do
+ expect(question.hidden_in_check_answers).to eq(
+ "depends_on" => [{ "details_known_1" => 1 }],
+ )
+ end
+
+ it "has the correct check_answers_card_number" do
+ expect(question.check_answers_card_number).to eq(2)
+ end
+ end
+
+ context "and person 2" do
+ let(:question_id) { "details_known_2" }
+ let(:person_index) { 3 }
+
+ before do
+ allow(page).to receive(:id).and_return("person_2_known")
+ end
+
+ it "has the correct id" do
+ expect(question.id).to eq("details_known_2")
+ end
+
+ it "has the correct header" do
+ expect(question.header).to eq("Do you know the details for person 2?")
+ end
+
+ it "has the correct check_answer_label" do
+ expect(question.check_answer_label).to eq("Details known for person 2?")
+ end
+
+ it "has correct conditional for" do
+ expect(question.conditional_for).to be_nil
+ end
+
+ it "has the correct hidden_in_check_answers" do
+ expect(question.hidden_in_check_answers).to eq(
+ "depends_on" => [{ "details_known_2" => 1 }],
+ )
+ end
+
+ it "has the correct check_answers_card_number" do
+ expect(question.check_answers_card_number).to eq(3)
+ end
+ end
+
+ context "and person 3" do
+ let(:question_id) { "details_known_3" }
+ let(:person_index) { 4 }
+
+ before do
+ allow(page).to receive(:id).and_return("person_3_known")
+ end
+
+ it "has the correct id" do
+ expect(question.id).to eq("details_known_3")
+ end
+
+ it "has the correct header" do
+ expect(question.header).to eq("Do you know the details for person 3?")
+ end
+
+ it "has the correct check_answer_label" do
+ expect(question.check_answer_label).to eq("Details known for person 3?")
+ end
+
+ it "has correct conditional for" do
+ expect(question.conditional_for).to be_nil
+ end
+
+ it "has the correct hidden_in_check_answers" do
+ expect(question.hidden_in_check_answers).to eq(
+ "depends_on" => [{ "details_known_3" => 1 }],
+ )
+ end
+
+ it "has the correct check_answers_card_number" do
+ expect(question.check_answers_card_number).to eq(4)
+ end
+ end
+
+ context "and person 4" do
+ let(:question_id) { "details_known_4" }
+ let(:person_index) { 5 }
+
+ before do
+ allow(page).to receive(:id).and_return("person_4_known")
+ end
+
+ it "has the correct id" do
+ expect(question.id).to eq("details_known_4")
+ end
- it "has the correct id" do
- expect(question.id).to eq("details_known_1")
+ it "has the correct header" do
+ expect(question.header).to eq("Do you know the details for person 4?")
+ end
+
+ it "has the correct check_answer_label" do
+ expect(question.check_answer_label).to eq("Details known for person 4?")
+ end
+
+ it "has correct conditional for" do
+ expect(question.conditional_for).to be_nil
+ end
+
+ it "has the correct hidden_in_check_answers" do
+ expect(question.hidden_in_check_answers).to eq(
+ "depends_on" => [{ "details_known_4" => 1 }],
+ )
+ end
+
+ it "has the correct check_answers_card_number" do
+ expect(question.check_answers_card_number).to eq(5)
+ end
end
+ end
+
+ context "with a joint purchase" do
+ context "and person 1" do
+ let(:question_id) { "details_known_1" }
+ let(:person_index) { 3 }
+
+ before do
+ allow(page).to receive(:id).and_return("person_1_known_joint_purchase")
+ end
+
+ it "has the correct id" do
+ expect(question.id).to eq("details_known_1")
+ end
+
+ it "has the correct header" do
+ expect(question.header).to eq("Do you know the details for person 1?")
+ end
- it "has the correct header" do
- expect(question.header).to eq("Do you know the details for person 1?")
+ it "has the correct check_answer_label" do
+ expect(question.check_answer_label).to eq("Details known for person 1?")
+ end
+
+ it "has correct conditional for" do
+ expect(question.conditional_for).to be_nil
+ end
+
+ it "has the correct hidden_in_check_answers" do
+ expect(question.hidden_in_check_answers).to eq(
+ "depends_on" => [{ "details_known_1" => 1 }],
+ )
+ end
+
+ it "has the correct check_answers_card_number" do
+ expect(question.check_answers_card_number).to eq(3)
+ end
end
- it "has the correct check_answer_label" do
- expect(question.check_answer_label).to eq("Details known for person 1?")
+ context "and person 2" do
+ let(:question_id) { "details_known_2" }
+ let(:person_index) { 4 }
+
+ before do
+ allow(page).to receive(:id).and_return("person_2_known_joint_purchase")
+ end
+
+ it "has the correct id" do
+ expect(question.id).to eq("details_known_2")
+ end
+
+ it "has the correct header" do
+ expect(question.header).to eq("Do you know the details for person 2?")
+ end
+
+ it "has the correct check_answer_label" do
+ expect(question.check_answer_label).to eq("Details known for person 2?")
+ end
+
+ it "has correct conditional for" do
+ expect(question.conditional_for).to be_nil
+ end
+
+ it "has the correct hidden_in_check_answers" do
+ expect(question.hidden_in_check_answers).to eq(
+ "depends_on" => [{ "details_known_2" => 1 }],
+ )
+ end
+
+ it "has the correct check_answers_card_number" do
+ expect(question.check_answers_card_number).to eq(4)
+ end
end
- it "has the correct hidden_in_check_answers" do
- expect(question.hidden_in_check_answers).to eq(
- {
- "depends_on" => [
- {
- "details_known_1" => 1,
- },
- ],
- },
- )
+ context "and person 3" do
+ let(:question_id) { "details_known_3" }
+ let(:person_index) { 5 }
+
+ before do
+ allow(page).to receive(:id).and_return("person_3_known_joint_purchase")
+ end
+
+ it "has the correct id" do
+ expect(question.id).to eq("details_known_3")
+ end
+
+ it "has the correct header" do
+ expect(question.header).to eq("Do you know the details for person 3?")
+ end
+
+ it "has the correct check_answer_label" do
+ expect(question.check_answer_label).to eq("Details known for person 3?")
+ end
+
+ it "has correct conditional for" do
+ expect(question.conditional_for).to be_nil
+ end
+
+ it "has the correct hidden_in_check_answers" do
+ expect(question.hidden_in_check_answers).to eq(
+ "depends_on" => [{ "details_known_3" => 1 }],
+ )
+ end
+
+ it "has the correct check_answers_card_number" do
+ expect(question.check_answers_card_number).to eq(5)
+ end
end
- it "has the correct check_answers_card_number" do
- expect(question.check_answers_card_number).to eq(3)
+ context "and person 4" do
+ let(:question_id) { "details_known_4" }
+ let(:person_index) { 6 }
+
+ before do
+ allow(page).to receive(:id).and_return("person_4_known_joint_purchase")
+ end
+
+ it "has the correct id" do
+ expect(question.id).to eq("details_known_4")
+ end
+
+ it "has the correct header" do
+ expect(question.header).to eq("Do you know the details for person 4?")
+ end
+
+ it "has the correct check_answer_label" do
+ expect(question.check_answer_label).to eq("Details known for person 4?")
+ end
+
+ it "has correct conditional for" do
+ expect(question.conditional_for).to be_nil
+ end
+
+ it "has the correct hidden_in_check_answers" do
+ expect(question.hidden_in_check_answers).to eq(
+ "depends_on" => [{ "details_known_4" => 1 }],
+ )
+ end
+
+ it "has the correct check_answers_card_number" do
+ expect(question.check_answers_card_number).to eq(6)
+ end
end
end
end
diff --git a/spec/models/form/sales/questions/property_local_authority_spec.rb b/spec/models/form/sales/questions/property_local_authority_spec.rb
new file mode 100644
index 000000000..060f69bfa
--- /dev/null
+++ b/spec/models/form/sales/questions/property_local_authority_spec.rb
@@ -0,0 +1,355 @@
+require "rails_helper"
+
+RSpec.describe Form::Sales::Questions::PropertyLocalAuthority, 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("la")
+ end
+
+ it "has the correct header" do
+ expect(question.header).to eq("What is the local authority of the property?")
+ end
+
+ it "has the correct check_answer_label" do
+ expect(question.check_answer_label).to eq("Local authority")
+ 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 "has the correct answer_options" do
+ expect(question.answer_options).to eq({
+ "" => "Select an option",
+ "E06000001" => "Hartlepool",
+ "E06000002" => "Middlesbrough",
+ "E06000003" => "Redcar and Cleveland",
+ "E06000004" => "Stockton-on-Tees",
+ "E06000005" => "Darlington",
+ "E06000006" => "Halton",
+ "E06000007" => "Warrington",
+ "E06000008" => "Blackburn with Darwen",
+ "E06000009" => "Blackpool",
+ "E06000010" => "Kingston upon Hull, City of",
+ "E06000011" => "East Riding of Yorkshire",
+ "E06000012" => "North East Lincolnshire",
+ "E06000013" => "North Lincolnshire",
+ "E06000014" => "York",
+ "E06000015" => "Derby",
+ "E06000016" => "Leicester",
+ "E06000017" => "Rutland",
+ "E06000018" => "Nottingham",
+ "E06000019" => "Herefordshire, County of",
+ "E06000020" => "Telford and Wrekin",
+ "E06000021" => "Stoke-on-Trent",
+ "E06000022" => "Bath and North East Somerset",
+ "E06000023" => "Bristol, City of",
+ "E06000024" => "North Somerset",
+ "E06000025" => "South Gloucestershire",
+ "E06000026" => "Plymouth",
+ "E06000027" => "Torbay",
+ "E06000030" => "Swindon",
+ "E06000031" => "Peterborough",
+ "E06000032" => "Luton",
+ "E06000033" => "Southend-on-Sea",
+ "E06000034" => "Thurrock",
+ "E06000035" => "Medway",
+ "E06000036" => "Bracknell Forest",
+ "E06000037" => "West Berkshire",
+ "E06000038" => "Reading",
+ "E06000039" => "Slough",
+ "E06000040" => "Windsor and Maidenhead",
+ "E06000041" => "Wokingham",
+ "E06000042" => "Milton Keynes",
+ "E06000043" => "Brighton and Hove",
+ "E06000044" => "Portsmouth",
+ "E06000045" => "Southampton",
+ "E06000046" => "Isle of Wight",
+ "E06000047" => "County Durham",
+ "E06000049" => "Cheshire East",
+ "E06000050" => "Cheshire West and Chester",
+ "E06000051" => "Shropshire",
+ "E06000052" => "Cornwall",
+ "E06000053" => "Isles of Scilly",
+ "E06000054" => "Wiltshire",
+ "E06000055" => "Bedford",
+ "E06000056" => "Central Bedfordshire",
+ "E06000057" => "Northumberland",
+ "E06000058" => "Bournemouth, Christchurch and Poole",
+ "E06000059" => "Dorset",
+ "E06000060" => "Buckinghamshire",
+ "E07000008" => "Cambridge",
+ "E07000009" => "East Cambridgeshire",
+ "E07000010" => "Fenland",
+ "E07000011" => "Huntingdonshire",
+ "E07000012" => "South Cambridgeshire",
+ "E07000026" => "Allerdale",
+ "E07000027" => "Barrow-in-Furness",
+ "E07000028" => "Carlisle",
+ "E07000029" => "Copeland",
+ "E07000030" => "Eden",
+ "E07000031" => "South Lakeland",
+ "E07000032" => "Amber Valley",
+ "E07000033" => "Bolsover",
+ "E07000034" => "Chesterfield",
+ "E07000035" => "Derbyshire Dales",
+ "E07000036" => "Erewash",
+ "E07000037" => "High Peak",
+ "E07000038" => "North East Derbyshire",
+ "E07000039" => "South Derbyshire",
+ "E07000040" => "East Devon",
+ "E07000041" => "Exeter",
+ "E07000042" => "Mid Devon",
+ "E07000043" => "North Devon",
+ "E07000044" => "South Hams",
+ "E07000045" => "Teignbridge",
+ "E07000046" => "Torridge",
+ "E07000047" => "West Devon",
+ "E07000061" => "Eastbourne",
+ "E07000062" => "Hastings",
+ "E07000063" => "Lewes",
+ "E07000064" => "Rother",
+ "E07000065" => "Wealden",
+ "E07000066" => "Basildon",
+ "E07000067" => "Braintree",
+ "E07000068" => "Brentwood",
+ "E07000069" => "Castle Point",
+ "E07000070" => "Chelmsford",
+ "E07000071" => "Colchester",
+ "E07000072" => "Epping Forest",
+ "E07000073" => "Harlow",
+ "E07000074" => "Maldon",
+ "E07000075" => "Rochford",
+ "E07000076" => "Tendring",
+ "E07000077" => "Uttlesford",
+ "E07000078" => "Cheltenham",
+ "E07000079" => "Cotswold",
+ "E07000080" => "Forest of Dean",
+ "E07000081" => "Gloucester",
+ "E07000082" => "Stroud",
+ "E07000083" => "Tewkesbury",
+ "E07000084" => "Basingstoke and Deane",
+ "E07000085" => "East Hampshire",
+ "E07000086" => "Eastleigh",
+ "E07000087" => "Fareham",
+ "E07000088" => "Gosport",
+ "E07000089" => "Hart",
+ "E07000090" => "Havant",
+ "E07000091" => "New Forest",
+ "E07000092" => "Rushmoor",
+ "E07000093" => "Test Valley",
+ "E07000094" => "Winchester",
+ "E07000095" => "Broxbourne",
+ "E07000096" => "Dacorum",
+ "E07000098" => "Hertsmere",
+ "E07000099" => "North Hertfordshire",
+ "E07000102" => "Three Rivers",
+ "E07000103" => "Watford",
+ "E07000105" => "Ashford",
+ "E07000106" => "Canterbury",
+ "E07000107" => "Dartford",
+ "E07000108" => "Dover",
+ "E07000109" => "Gravesham",
+ "E07000110" => "Maidstone",
+ "E07000111" => "Sevenoaks",
+ "E07000112" => "Folkestone and Hythe",
+ "E07000113" => "Swale",
+ "E07000114" => "Thanet",
+ "E07000115" => "Tonbridge and Malling",
+ "E07000116" => "Tunbridge Wells",
+ "E07000117" => "Burnley",
+ "E07000118" => "Chorley",
+ "E07000119" => "Fylde",
+ "E07000120" => "Hyndburn",
+ "E07000121" => "Lancaster",
+ "E07000122" => "Pendle",
+ "E07000123" => "Preston",
+ "E07000124" => "Ribble Valley",
+ "E07000125" => "Rossendale",
+ "E07000126" => "South Ribble",
+ "E07000127" => "West Lancashire",
+ "E07000128" => "Wyre",
+ "E07000129" => "Blaby",
+ "E07000130" => "Charnwood",
+ "E07000131" => "Harborough",
+ "E07000132" => "Hinckley and Bosworth",
+ "E07000133" => "Melton",
+ "E07000134" => "North West Leicestershire",
+ "E07000135" => "Oadby and Wigston",
+ "E07000136" => "Boston",
+ "E07000137" => "East Lindsey",
+ "E07000138" => "Lincoln",
+ "E07000139" => "North Kesteven",
+ "E07000140" => "South Holland",
+ "E07000141" => "South Kesteven",
+ "E07000142" => "West Lindsey",
+ "E07000143" => "Breckland",
+ "E07000144" => "Broadland",
+ "E07000145" => "Great Yarmouth",
+ "E07000146" => "King’s Lynn and West Norfolk",
+ "E07000147" => "North Norfolk",
+ "E07000148" => "Norwich",
+ "E07000149" => "South Norfolk",
+ "E07000150" => "Corby",
+ "E07000151" => "Daventry",
+ "E07000152" => "East Northamptonshire",
+ "E07000153" => "Kettering",
+ "E07000154" => "Northampton",
+ "E07000155" => "South Northamptonshire",
+ "E07000156" => "Wellingborough",
+ "E07000163" => "Craven",
+ "E07000164" => "Hambleton",
+ "E07000165" => "Harrogate",
+ "E07000166" => "Richmondshire",
+ "E07000167" => "Ryedale",
+ "E07000168" => "Scarborough",
+ "E07000169" => "Selby",
+ "E07000170" => "Ashfield",
+ "E07000171" => "Bassetlaw",
+ "E07000172" => "Broxtowe",
+ "E07000173" => "Gedling",
+ "E07000174" => "Mansfield",
+ "E07000175" => "Newark and Sherwood",
+ "E07000176" => "Rushcliffe",
+ "E07000177" => "Cherwell",
+ "E07000178" => "Oxford",
+ "E07000179" => "South Oxfordshire",
+ "E07000180" => "Vale of White Horse",
+ "E07000181" => "West Oxfordshire",
+ "E07000187" => "Mendip",
+ "E07000188" => "Sedgemoor",
+ "E07000189" => "South Somerset",
+ "E07000192" => "Cannock Chase",
+ "E07000193" => "East Staffordshire",
+ "E07000194" => "Lichfield",
+ "E07000195" => "Newcastle-under-Lyme",
+ "E07000196" => "South Staffordshire",
+ "E07000197" => "Stafford",
+ "E07000198" => "Staffordshire Moorlands",
+ "E07000199" => "Tamworth",
+ "E07000200" => "Babergh",
+ "E07000202" => "Ipswich",
+ "E07000203" => "Mid Suffolk",
+ "E07000207" => "Elmbridge",
+ "E07000208" => "Epsom and Ewell",
+ "E07000209" => "Guildford",
+ "E07000210" => "Mole Valley",
+ "E07000211" => "Reigate and Banstead",
+ "E07000212" => "Runnymede",
+ "E07000213" => "Spelthorne",
+ "E07000214" => "Surrey Heath",
+ "E07000215" => "Tandridge",
+ "E07000216" => "Waverley",
+ "E07000217" => "Woking",
+ "E07000218" => "North Warwickshire",
+ "E07000219" => "Nuneaton and Bedworth",
+ "E07000220" => "Rugby",
+ "E07000221" => "Stratford-on-Avon",
+ "E07000222" => "Warwick",
+ "E07000223" => "Adur",
+ "E07000224" => "Arun",
+ "E07000225" => "Chichester",
+ "E07000226" => "Crawley",
+ "E07000227" => "Horsham",
+ "E07000228" => "Mid Sussex",
+ "E07000229" => "Worthing",
+ "E07000234" => "Bromsgrove",
+ "E07000235" => "Malvern Hills",
+ "E07000236" => "Redditch",
+ "E07000237" => "Worcester",
+ "E07000238" => "Wychavon",
+ "E07000239" => "Wyre Forest",
+ "E07000240" => "St Albans",
+ "E07000241" => "Welwyn Hatfield",
+ "E07000242" => "East Hertfordshire",
+ "E07000243" => "Stevenage",
+ "E07000244" => "East Suffolk",
+ "E07000245" => "West Suffolk",
+ "E07000246" => "Somerset West and Taunton",
+ "E08000001" => "Bolton",
+ "E08000002" => "Bury",
+ "E08000003" => "Manchester",
+ "E08000004" => "Oldham",
+ "E08000005" => "Rochdale",
+ "E08000006" => "Salford",
+ "E08000007" => "Stockport",
+ "E08000008" => "Tameside",
+ "E08000009" => "Trafford",
+ "E08000010" => "Wigan",
+ "E08000011" => "Knowsley",
+ "E08000012" => "Liverpool",
+ "E08000013" => "St. Helens",
+ "E08000014" => "Sefton",
+ "E08000015" => "Wirral",
+ "E08000016" => "Barnsley",
+ "E08000017" => "Doncaster",
+ "E08000018" => "Rotherham",
+ "E08000019" => "Sheffield",
+ "E08000021" => "Newcastle upon Tyne",
+ "E08000022" => "North Tyneside",
+ "E08000023" => "South Tyneside",
+ "E08000024" => "Sunderland",
+ "E08000025" => "Birmingham",
+ "E08000026" => "Coventry",
+ "E08000027" => "Dudley",
+ "E08000028" => "Sandwell",
+ "E08000029" => "Solihull",
+ "E08000030" => "Walsall",
+ "E08000031" => "Wolverhampton",
+ "E08000032" => "Bradford",
+ "E08000033" => "Calderdale",
+ "E08000034" => "Kirklees",
+ "E08000035" => "Leeds",
+ "E08000036" => "Wakefield",
+ "E08000037" => "Gateshead",
+ "E09000001" => "City of London",
+ "E09000002" => "Barking and Dagenham",
+ "E09000003" => "Barnet",
+ "E09000004" => "Bexley",
+ "E09000005" => "Brent",
+ "E09000006" => "Bromley",
+ "E09000007" => "Camden",
+ "E09000008" => "Croydon",
+ "E09000009" => "Ealing",
+ "E09000010" => "Enfield",
+ "E09000011" => "Greenwich",
+ "E09000012" => "Hackney",
+ "E09000013" => "Hammersmith and Fulham",
+ "E09000014" => "Haringey",
+ "E09000015" => "Harrow",
+ "E09000016" => "Havering",
+ "E09000017" => "Hillingdon",
+ "E09000018" => "Hounslow",
+ "E09000019" => "Islington",
+ "E09000020" => "Kensington and Chelsea",
+ "E09000021" => "Kingston upon Thames",
+ "E09000022" => "Lambeth",
+ "E09000023" => "Lewisham",
+ "E09000024" => "Merton",
+ "E09000025" => "Newham",
+ "E09000026" => "Redbridge",
+ "E09000027" => "Richmond upon Thames",
+ "E09000028" => "Southwark",
+ "E09000029" => "Sutton",
+ "E09000030" => "Tower Hamlets",
+ "E09000031" => "Waltham Forest",
+ "E09000032" => "Wandsworth",
+ "E09000033" => "Westminster",
+ "S12000017" => "Highland",
+ "W06000002" => "Gwynedd",
+ })
+ end
+end
diff --git a/spec/models/form/sales/questions/property_wheelchair_accessible_spec.rb b/spec/models/form/sales/questions/property_wheelchair_accessible_spec.rb
new file mode 100644
index 000000000..c8d7eadaf
--- /dev/null
+++ b/spec/models/form/sales/questions/property_wheelchair_accessible_spec.rb
@@ -0,0 +1,41 @@
+require "rails_helper"
+
+RSpec.describe Form::Sales::Questions::PropertyWheelchairAccessible, 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("wchair")
+ end
+
+ it "has the correct header" do
+ expect(question.header).to eq("Is the property build or adapted to wheelchair-user standards?")
+ end
+
+ it "has the correct check_answer_label" do
+ expect(question.check_answer_label).to eq("Property build or adapted to wheelchair-user standards")
+ 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({
+ "1" => { "value" => "Yes" },
+ "2" => { "value" => "No" },
+ "3" => { "value" => "Don't know" },
+ })
+ end
+end
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 f6c05aeb6..e30e5bfde 100644
--- a/spec/models/form/sales/subsections/discounted_ownership_scheme_spec.rb
+++ b/spec/models/form/sales/subsections/discounted_ownership_scheme_spec.rb
@@ -21,6 +21,7 @@ RSpec.describe Form::Sales::Subsections::DiscountedOwnershipScheme, type: :model
mortgage_amount_discounted_ownership
about_deposit_discounted_ownership
discounted_ownership_deposit_value_check
+ leasehold_charges_discounted_ownership
],
)
end
diff --git a/spec/models/form/sales/subsections/household_characteristics_spec.rb b/spec/models/form/sales/subsections/household_characteristics_spec.rb
index b71351c0c..15c8be02f 100644
--- a/spec/models/form/sales/subsections/household_characteristics_spec.rb
+++ b/spec/models/form/sales/subsections/household_characteristics_spec.rb
@@ -35,6 +35,7 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model
buyer_2_live_in_property
number_of_others_in_property
person_1_known
+ person_1_known_joint_purchase
person_1_relationship_to_buyer_1
person_1_relationship_to_buyer_1_joint_purchase
person_1_age
@@ -44,6 +45,7 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model
person_1_working_situation
person_1_working_situation_joint_purchase
person_2_known
+ person_2_known_joint_purchase
person_2_relationship_to_buyer_1
person_2_relationship_to_buyer_1_joint_purchase
person_2_age
@@ -53,6 +55,7 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model
person_2_working_situation
person_2_working_situation_joint_purchase
person_3_known
+ person_3_known_joint_purchase
person_3_relationship_to_buyer_1
person_3_relationship_to_buyer_1_joint_purchase
person_3_age
@@ -62,6 +65,7 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model
person_3_working_situation
person_3_working_situation_joint_purchase
person_4_known
+ person_4_known_joint_purchase
person_4_relationship_to_buyer_1
person_4_relationship_to_buyer_1_joint_purchase
person_4_age
diff --git a/spec/models/form/sales/subsections/household_needs_spec.rb b/spec/models/form/sales/subsections/household_needs_spec.rb
index 40daf93b0..5220f2d05 100644
--- a/spec/models/form/sales/subsections/household_needs_spec.rb
+++ b/spec/models/form/sales/subsections/household_needs_spec.rb
@@ -16,6 +16,7 @@ RSpec.describe Form::Sales::Subsections::HouseholdNeeds, type: :model do
%w[
armed_forces
buyer_still_serving
+ armed_forces_spouse
household_disability
household_wheelchair
wheelchair_check
diff --git a/spec/models/form/sales/subsections/outright_sale_spec.rb b/spec/models/form/sales/subsections/outright_sale_spec.rb
index d39dee44c..06b394f27 100644
--- a/spec/models/form/sales/subsections/outright_sale_spec.rb
+++ b/spec/models/form/sales/subsections/outright_sale_spec.rb
@@ -13,11 +13,14 @@ RSpec.describe Form::Sales::Subsections::OutrightSale, type: :model do
it "has correct pages" do
expect(outright_sale.pages.map(&:id)).to eq(
- %w[purchase_price
- mortgage_used_outright_sale
- mortgage_amount_outright_sale
- about_deposit_outright_sale
- outright_sale_deposit_value_check],
+ %w[
+ purchase_price
+ mortgage_used_outright_sale
+ mortgage_amount_outright_sale
+ about_deposit_outright_sale
+ outright_sale_deposit_value_check
+ leasehold_charges_outright_sale
+ ],
)
end
diff --git a/spec/models/form/sales/subsections/property_information_spec.rb b/spec/models/form/sales/subsections/property_information_spec.rb
index 284d0e02c..b512c8e5e 100644
--- a/spec/models/form/sales/subsections/property_information_spec.rb
+++ b/spec/models/form/sales/subsections/property_information_spec.rb
@@ -18,6 +18,7 @@ RSpec.describe Form::Sales::Subsections::PropertyInformation, type: :model do
property_building_type
property_unit_type
property_local_authority
+ property_wheelchair_accessible
],
)
end
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 e95579df3..06f98ba09 100644
--- a/spec/models/form/sales/subsections/shared_ownership_scheme_spec.rb
+++ b/spec/models/form/sales/subsections/shared_ownership_scheme_spec.rb
@@ -29,6 +29,7 @@ RSpec.describe Form::Sales::Subsections::SharedOwnershipScheme, type: :model do
about_deposit_shared_ownership
shared_ownership_deposit_value_check
monthly_rent
+ leasehold_charges_shared_ownership
],
)
end
diff --git a/spec/models/form_handler_spec.rb b/spec/models/form_handler_spec.rb
index 7d5339806..44ddbe3b8 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(122)
+ expect(form.pages.count).to eq(131)
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(122)
+ expect(form.pages.count).to eq(131)
expect(form.name).to eq("2021_2022_sales")
end
end
diff --git a/spec/services/imports/lettings_logs_import_service_spec.rb b/spec/services/imports/lettings_logs_import_service_spec.rb
index acb9d9dd4..7850008a1 100644
--- a/spec/services/imports/lettings_logs_import_service_spec.rb
+++ b/spec/services/imports/lettings_logs_import_service_spec.rb
@@ -11,6 +11,7 @@ RSpec.describe Imports::LettingsLogsImportService do
let(:fixture_directory) { "spec/fixtures/imports/logs" }
let(:organisation) { FactoryBot.create(:organisation, old_visible_id: "1", provider_type: "PRP") }
+ let(:managing_organisation) { FactoryBot.create(:organisation, old_visible_id: "2", provider_type: "PRP") }
let(:scheme1) { FactoryBot.create(:scheme, old_visible_id: "0123", owning_organisation: organisation) }
let(:scheme2) { FactoryBot.create(:scheme, old_visible_id: "456", owning_organisation: organisation) }
@@ -24,6 +25,7 @@ RSpec.describe Imports::LettingsLogsImportService do
allow(Organisation).to receive(:find_by).and_return(nil)
allow(Organisation).to receive(:find_by).with(old_visible_id: organisation.old_visible_id).and_return(organisation)
+ allow(Organisation).to receive(:find_by).with(old_visible_id: managing_organisation.old_visible_id).and_return(managing_organisation)
# Created by users
FactoryBot.create(:user, old_user_id: "c3061a2e6ea0b702e6f6210d5c52d2a92612d2aa", organisation:)
@@ -80,6 +82,13 @@ RSpec.describe Imports::LettingsLogsImportService do
.to change(LettingsLog, :count).by(4)
end
+ it "creates organisation relationship once" do
+ expect(logger).not_to receive(:error)
+ expect(logger).not_to receive(:warn)
+ expect { lettings_log_service.create_logs(remote_folder) }
+ .to change(OrganisationRelationship, :count).by(1)
+ end
+
context "when there are status discrepancies" do
let(:lettings_log_id5) { "893ufj2s-lq77-42m4-rty6-ej09gh585uy1" }
let(:lettings_log_id6) { "5ybz29dj-l33t-k1l0-hj86-n4k4ma77xkcd" }