diff --git a/app/frontend/controllers/conditional_question_controller.js b/app/frontend/controllers/conditional_question_controller.js index 974deeb2e..fb52d07c1 100644 --- a/app/frontend/controllers/conditional_question_controller.js +++ b/app/frontend/controllers/conditional_question_controller.js @@ -8,14 +8,16 @@ export default class extends Controller { displayConditional () { if (this.element.checked) { const selectedValue = this.element.value - const conditionalFor = JSON.parse(this.element.dataset.info) + const dataInfo = JSON.parse(this.element.dataset.info) + const conditionalFor = dataInfo.conditional_questions + const logType = dataInfo.log_type Object.entries(conditionalFor).forEach(([targetQuestion, conditions]) => { if (!conditions.map(String).includes(String(selectedValue))) { - const textNumericInput = document.getElementById(`lettings-log-${targetQuestion.replaceAll('_', '-')}-field`) + const textNumericInput = document.getElementById(`${logType}-log-${targetQuestion.replaceAll('_', '-')}-field`) if (textNumericInput == null) { const dateInputs = [1, 2, 3].map((idx) => { - return document.getElementById(`lettings_log_${targetQuestion}_${idx}i`) + return document.getElementById(`${logType}_log_${targetQuestion}_${idx}i`) }) this.clearDateInputs(dateInputs) } else { diff --git a/app/helpers/question_attribute_helper.rb b/app/helpers/question_attribute_helper.rb index f2f148568..857ce5eb1 100644 --- a/app/helpers/question_attribute_helper.rb +++ b/app/helpers/question_attribute_helper.rb @@ -27,7 +27,7 @@ private { "data-controller": "conditional-question", "data-action": "click->conditional-question#displayConditional", - "data-info": question.conditional_for.to_json, + "data-info": { conditional_questions: question.conditional_for, log_type: question.form.type }.to_json, } end end diff --git a/app/models/derived_variables/sales_log_variables.rb b/app/models/derived_variables/sales_log_variables.rb new file mode 100644 index 000000000..2b3542813 --- /dev/null +++ b/app/models/derived_variables/sales_log_variables.rb @@ -0,0 +1,5 @@ +module DerivedVariables::SalesLogVariables + def set_derived_fields! + self.ethnic = 17 if ethnic_refused? + end +end diff --git a/app/models/form/question.rb b/app/models/form/question.rb index 4478f63fd..227e6079e 100644 --- a/app/models/form/question.rb +++ b/app/models/form/question.rb @@ -50,9 +50,11 @@ class Form::Question answer = label_from_value(log[id]) if log[id].present? answer_label = [prefix, format_value(answer), suffix_label(log)].join("") if answer - return answer_label if answer_label - has_inferred_check_answers_value?(log) ? inferred_check_answers_value["value"] : "" + inferred = inferred_check_answers_value["value"] if inferred_check_answers_value && has_inferred_check_answers_value?(log) + return inferred if inferred.present? + + answer_label end def get_inferred_answers(log) diff --git a/app/models/form/sales/pages/buyer1_ethnic_background_arab.rb b/app/models/form/sales/pages/buyer1_ethnic_background_arab.rb new file mode 100644 index 000000000..93fb1afe0 --- /dev/null +++ b/app/models/form/sales/pages/buyer1_ethnic_background_arab.rb @@ -0,0 +1,18 @@ +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, + }] + end + + def questions + @questions ||= [ + Form::Sales::Questions::Buyer1EthnicBackgroundArab.new(nil, nil, self), + ] + end +end diff --git a/app/models/form/sales/pages/buyer1_ethnic_background_asian.rb b/app/models/form/sales/pages/buyer1_ethnic_background_asian.rb new file mode 100644 index 000000000..dd6802a99 --- /dev/null +++ b/app/models/form/sales/pages/buyer1_ethnic_background_asian.rb @@ -0,0 +1,18 @@ +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, + }] + end + + def questions + @questions ||= [ + Form::Sales::Questions::Buyer1EthnicBackgroundAsian.new(nil, nil, self), + ] + end +end diff --git a/app/models/form/sales/pages/buyer1_ethnic_background_black.rb b/app/models/form/sales/pages/buyer1_ethnic_background_black.rb new file mode 100644 index 000000000..ce6cf3a0b --- /dev/null +++ b/app/models/form/sales/pages/buyer1_ethnic_background_black.rb @@ -0,0 +1,18 @@ +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, + }] + end + + def questions + @questions ||= [ + Form::Sales::Questions::Buyer1EthnicBackgroundBlack.new(nil, nil, self), + ] + end +end diff --git a/app/models/form/sales/pages/buyer1_ethnic_background_mixed.rb b/app/models/form/sales/pages/buyer1_ethnic_background_mixed.rb new file mode 100644 index 000000000..5225feed1 --- /dev/null +++ b/app/models/form/sales/pages/buyer1_ethnic_background_mixed.rb @@ -0,0 +1,18 @@ +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, + }] + end + + def questions + @questions ||= [ + Form::Sales::Questions::Buyer1EthnicBackgroundMixed.new(nil, nil, self), + ] + end +end diff --git a/app/models/form/sales/pages/buyer1_ethnic_background_white.rb b/app/models/form/sales/pages/buyer1_ethnic_background_white.rb new file mode 100644 index 000000000..6351e50d7 --- /dev/null +++ b/app/models/form/sales/pages/buyer1_ethnic_background_white.rb @@ -0,0 +1,18 @@ +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, + }] + end + + def questions + @questions ||= [ + Form::Sales::Questions::Buyer1EthnicBackgroundWhite.new(nil, nil, self), + ] + end +end diff --git a/app/models/form/sales/pages/buyer1_ethnic_group.rb b/app/models/form/sales/pages/buyer1_ethnic_group.rb new file mode 100644 index 000000000..4daad4f1d --- /dev/null +++ b/app/models/form/sales/pages/buyer1_ethnic_group.rb @@ -0,0 +1,15 @@ +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 + @questions ||= [ + Form::Sales::Questions::Buyer1EthnicGroup.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 new file mode 100644 index 000000000..caaa0e60f --- /dev/null +++ b/app/models/form/sales/pages/buyer1_working_situation.rb @@ -0,0 +1,15 @@ +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?" + @description = "" + @subsection = subsection + end + + def questions + @questions ||= [ + Form::Sales::Questions::Buyer1WorkingSituation.new(nil, nil, self), + ] + end +end diff --git a/app/models/form/sales/pages/buyer2_live_in_property.rb b/app/models/form/sales/pages/buyer2_live_in_property.rb new file mode 100644 index 000000000..0d2393503 --- /dev/null +++ b/app/models/form/sales/pages/buyer2_live_in_property.rb @@ -0,0 +1,15 @@ +class Form::Sales::Pages::Buyer2LiveInProperty < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "buyer_2_live_in_property" + @header = "" + @description = "" + @subsection = subsection + end + + def questions + @questions ||= [ + Form::Sales::Questions::Buyer2LiveInProperty.new(nil, nil, self), + ] + end +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 7576e947c..8927ddd5a 100644 --- a/app/models/form/sales/pages/buyer2_relationship_to_buyer1.rb +++ b/app/models/form/sales/pages/buyer2_relationship_to_buyer1.rb @@ -13,7 +13,6 @@ class Form::Sales::Pages::Buyer2RelationshipToBuyer1 < ::Form::Page def questions @questions ||= [ Form::Sales::Questions::Buyer2RelationshipToBuyer1.new(nil, nil, self), - Form::Sales::Questions::OtherBuyer2RelationshipToBuyer1.new(nil, nil, self), ] end end diff --git a/app/models/form/sales/pages/buyer2_working_situation.rb b/app/models/form/sales/pages/buyer2_working_situation.rb new file mode 100644 index 000000000..e445a56c1 --- /dev/null +++ b/app/models/form/sales/pages/buyer2_working_situation.rb @@ -0,0 +1,15 @@ +class Form::Sales::Pages::Buyer2WorkingSituation < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "buyer_2_working_situation" + @header = "" + @description = "" + @subsection = subsection + end + + def questions + @questions ||= [ + Form::Sales::Questions::Buyer2WorkingSituation.new(nil, nil, self), + ] + end +end diff --git a/app/models/form/sales/pages/buyer_interview.rb b/app/models/form/sales/pages/buyer_interview.rb new file mode 100644 index 000000000..a781d8a07 --- /dev/null +++ b/app/models/form/sales/pages/buyer_interview.rb @@ -0,0 +1,15 @@ +class Form::Sales::Pages::BuyerInterview < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "buyer_interview" + @header = "" + @description = "" + @subsection = subsection + end + + def questions + @questions ||= [ + Form::Sales::Questions::BuyerInterview.new(nil, nil, self), + ] + end +end diff --git a/app/models/form/sales/pages/gender_identity2.rb b/app/models/form/sales/pages/gender_identity2.rb new file mode 100644 index 000000000..f5db5aecb --- /dev/null +++ b/app/models/form/sales/pages/gender_identity2.rb @@ -0,0 +1,18 @@ +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, + }] + end + + def questions + @questions ||= [ + Form::Sales::Questions::GenderIdentity2.new(nil, nil, self), + ] + end +end diff --git a/app/models/form/sales/pages/household_wheelchair.rb b/app/models/form/sales/pages/household_wheelchair.rb new file mode 100644 index 000000000..97d4abc52 --- /dev/null +++ b/app/models/form/sales/pages/household_wheelchair.rb @@ -0,0 +1,15 @@ +class Form::Sales::Pages::HouseholdWheelchair < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "household_wheelchair" + @header = "" + @description = "" + @subsection = subsection + end + + def questions + @questions ||= [ + Form::Sales::Questions::HouseholdWheelchair.new(nil, nil, self), + ] + end +end diff --git a/app/models/form/sales/pages/nationality1.rb b/app/models/form/sales/pages/nationality1.rb new file mode 100644 index 000000000..740aa694f --- /dev/null +++ b/app/models/form/sales/pages/nationality1.rb @@ -0,0 +1,16 @@ +class Form::Sales::Pages::Nationality1 < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "buyer_1_nationality" + @header = "" + @description = "" + @subsection = subsection + end + + def questions + @questions ||= [ + Form::Sales::Questions::Nationality1.new(nil, nil, self), + Form::Sales::Questions::OtherNationality1.new(nil, nil, self), + ] + end +end 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 new file mode 100644 index 000000000..b97c70775 --- /dev/null +++ b/app/models/form/sales/pages/number_of_others_in_property.rb @@ -0,0 +1,15 @@ +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 + @questions ||= [ + Form::Sales::Questions::NumberOfOthersInProperty.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 new file mode 100644 index 000000000..a7e8ca219 --- /dev/null +++ b/app/models/form/sales/pages/privacy_notice.rb @@ -0,0 +1,18 @@ +class Form::Sales::Pages::PrivacyNotice < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "privacy_notice" + @header = "Department for Levelling Up, Housing and Communities privacy notice" + @description = "" + @subsection = subsection + @depends_on = [{ + "noint" => 1, + }] + end + + def questions + @questions ||= [ + Form::Sales::Questions::PrivacyNotice.new(nil, nil, self), + ] + end +end diff --git a/app/models/form/sales/pages/building_type.rb b/app/models/form/sales/pages/property_building_type.rb similarity index 61% rename from app/models/form/sales/pages/building_type.rb rename to app/models/form/sales/pages/property_building_type.rb index 1005c7b9f..8f93b305c 100644 --- a/app/models/form/sales/pages/building_type.rb +++ b/app/models/form/sales/pages/property_building_type.rb @@ -1,4 +1,4 @@ -class Form::Sales::Pages::BuildingType < ::Form::Page +class Form::Sales::Pages::PropertyBuildingType < ::Form::Page def initialize(id, hsh, subsection) super @id = "property_building_type" @@ -9,7 +9,7 @@ class Form::Sales::Pages::BuildingType < ::Form::Page def questions @questions ||= [ - Form::Sales::Questions::BuildingType.new(nil, nil, self), + Form::Sales::Questions::PropertyBuildingType.new(nil, nil, self), ] end end diff --git a/app/models/form/sales/questions/buyer1_ethnic_background_arab.rb b/app/models/form/sales/questions/buyer1_ethnic_background_arab.rb new file mode 100644 index 000000000..f6bf163b0 --- /dev/null +++ b/app/models/form/sales/questions/buyer1_ethnic_background_arab.rb @@ -0,0 +1,17 @@ +class Form::Sales::Questions::Buyer1EthnicBackgroundArab < ::Form::Question + def initialize(id, hsh, page) + super + @id = "ethnic" + @check_answer_label = "Buyer 1’s ethnic background" + @header = "Which of the following best describes 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." + end + + ANSWER_OPTIONS = { + "19" => { "value" => "Arab" }, + "16" => { "value" => "Other ethnic group" }, + }.freeze +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 new file mode 100644 index 000000000..a6b8ea64f --- /dev/null +++ b/app/models/form/sales/questions/buyer1_ethnic_background_asian.rb @@ -0,0 +1,20 @@ +class Form::Sales::Questions::Buyer1EthnicBackgroundAsian < ::Form::Question + def initialize(id, hsh, page) + super + @id = "ethnic" + @check_answer_label = "Buyer 1’s ethnic background" + @header = "Which of the following best describes 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." + end + + ANSWER_OPTIONS = { + "10" => { "value" => "Bangladeshi" }, + "15" => { "value" => "Chinese" }, + "8" => { "value" => "Indian" }, + "9" => { "value" => "Pakistani" }, + "11" => { "value" => "Any other Asian or Asian British background" }, + }.freeze +end diff --git a/app/models/form/sales/questions/buyer1_ethnic_background_black.rb b/app/models/form/sales/questions/buyer1_ethnic_background_black.rb new file mode 100644 index 000000000..841086ec3 --- /dev/null +++ b/app/models/form/sales/questions/buyer1_ethnic_background_black.rb @@ -0,0 +1,18 @@ +class Form::Sales::Questions::Buyer1EthnicBackgroundBlack < ::Form::Question + def initialize(id, hsh, page) + super + @id = "ethnic" + @check_answer_label = "Buyer 1’s ethnic background" + @header = "Which of the following best describes 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." + end + + ANSWER_OPTIONS = { + "13" => { "value" => "African" }, + "12" => { "value" => "Caribbean" }, + "14" => { "value" => "Any other Black, African or Caribbean background" }, + }.freeze +end diff --git a/app/models/form/sales/questions/buyer1_ethnic_background_mixed.rb b/app/models/form/sales/questions/buyer1_ethnic_background_mixed.rb new file mode 100644 index 000000000..69451e9e9 --- /dev/null +++ b/app/models/form/sales/questions/buyer1_ethnic_background_mixed.rb @@ -0,0 +1,19 @@ +class Form::Sales::Questions::Buyer1EthnicBackgroundMixed < ::Form::Question + def initialize(id, hsh, page) + super + @id = "ethnic" + @check_answer_label = "Buyer 1’s ethnic background" + @header = "Which of the following best describes 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." + end + + ANSWER_OPTIONS = { + "4" => { "value" => "White and Black Caribbean" }, + "5" => { "value" => "White and Black African" }, + "6" => { "value" => "White and Asian" }, + "7" => { "value" => "Any other Mixed or Multiple ethnic background" }, + }.freeze +end diff --git a/app/models/form/sales/questions/buyer1_ethnic_background_white.rb b/app/models/form/sales/questions/buyer1_ethnic_background_white.rb new file mode 100644 index 000000000..cb9f2918f --- /dev/null +++ b/app/models/form/sales/questions/buyer1_ethnic_background_white.rb @@ -0,0 +1,19 @@ +class Form::Sales::Questions::Buyer1EthnicBackgroundWhite < ::Form::Question + def initialize(id, hsh, page) + super + @id = "ethnic" + @check_answer_label = "Buyer 1’s ethnic background" + @header = "Which of the following best describes 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." + end + + ANSWER_OPTIONS = { + "1" => { "value" => "English, Welsh, Northern Irish, Scottish or British" }, + "2" => { "value" => "Irish" }, + "18" => { "value" => "Gypsy or Irish Traveller" }, + "3" => { "value" => "Any other White background" }, + }.freeze +end diff --git a/app/models/form/sales/questions/buyer1_ethnic_group.rb b/app/models/form/sales/questions/buyer1_ethnic_group.rb new file mode 100644 index 000000000..cb1a6da28 --- /dev/null +++ b/app/models/form/sales/questions/buyer1_ethnic_group.rb @@ -0,0 +1,28 @@ +class Form::Sales::Questions::Buyer1EthnicGroup < ::Form::Question + def initialize(id, hsh, page) + super + @id = "ethnic_group" + @check_answer_label = "Buyer 1’s ethnic group" + @header = "What is buyer 1’s ethnic group?" + @type = "radio" + @answer_options = ANSWER_OPTIONS + @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" => { + "ethnic_group" => 17, + }, + "value" => "Prefers not to say", + } + end + + ANSWER_OPTIONS = { + "0" => { "value" => "White" }, + "1" => { "value" => "Mixed or Multiple ethnic groups" }, + "2" => { "value" => "Asian or Asian British" }, + "3" => { "value" => "Black, African, Caribbean or Black British" }, + "4" => { "value" => "Arab or other ethnic group" }, + "divider" => { "value" => true }, + "17" => { "value" => "Buyer 1 prefers not to say" }, + }.freeze +end diff --git a/app/models/form/sales/questions/buyer1_working_situation.rb b/app/models/form/sales/questions/buyer1_working_situation.rb new file mode 100644 index 000000000..571ab7366 --- /dev/null +++ b/app/models/form/sales/questions/buyer1_working_situation.rb @@ -0,0 +1,26 @@ +class Form::Sales::Questions::Buyer1WorkingSituation < ::Form::Question + def initialize(id, hsh, page) + super + @id = "ecstat1" + @check_answer_label = "Buyer 1's working situation" + @header = "Which of these best describes buyer 1's working situation?" + @type = "radio" + @answer_options = ANSWER_OPTIONS + @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." + end + + ANSWER_OPTIONS = { + "2" => { "value" => "Part-time - Less than 30 hours" }, + "1" => { "value" => "Full-time - 30 hours or more" }, + "3" => { "value" => "In government training into work, such as New Deal" }, + "4" => { "value" => "Jobseeker" }, + "6" => { "value" => "Not seeking work" }, + "8" => { "value" => "Unable to work due to long term sick or disability" }, + "5" => { "value" => "Retired" }, + "0" => { "value" => "Other" }, + "10" => { "value" => "Buyer prefers not to say" }, + "7" => { "value" => "Full-time student" }, + "9" => { "value" => "Child under 16" }, + }.freeze +end diff --git a/app/models/form/sales/questions/buyer2_live_in_property.rb b/app/models/form/sales/questions/buyer2_live_in_property.rb new file mode 100644 index 000000000..060f52afc --- /dev/null +++ b/app/models/form/sales/questions/buyer2_live_in_property.rb @@ -0,0 +1,17 @@ +class Form::Sales::Questions::Buyer2LiveInProperty < ::Form::Question + def initialize(id, hsh, page) + super + @id = "buy2livein" + @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 + end + + ANSWER_OPTIONS = { + "1" => { "value" => "Yes" }, + "2" => { "value" => "No" }, + }.freeze +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 67db6677d..11c9717ba 100644 --- a/app/models/form/sales/questions/buyer2_relationship_to_buyer1.rb +++ b/app/models/form/sales/questions/buyer2_relationship_to_buyer1.rb @@ -8,16 +8,6 @@ class Form::Sales::Questions::Buyer2RelationshipToBuyer1 < ::Form::Question @hint_text = "" @page = page @answer_options = ANSWER_OPTIONS - @conditional_for = { - "otherrelat2" => %w[X], - } - @hidden_in_check_answers = { - "depends_on" => [ - { - "relat2" => "X", - }, - ], - } end ANSWER_OPTIONS = { diff --git a/app/models/form/sales/questions/buyer2_working_situation.rb b/app/models/form/sales/questions/buyer2_working_situation.rb new file mode 100644 index 000000000..11b587f92 --- /dev/null +++ b/app/models/form/sales/questions/buyer2_working_situation.rb @@ -0,0 +1,26 @@ +class Form::Sales::Questions::Buyer2WorkingSituation < ::Form::Question + def initialize(id, hsh, page) + super + @id = "ecstat2" + @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 + end + + ANSWER_OPTIONS = { + "2" => { "value" => "Part-time - Less than 30 hours" }, + "1" => { "value" => "Full-time - 30 hours or more" }, + "3" => { "value" => "In government training into work, such as New Deal" }, + "4" => { "value" => "Jobseeker" }, + "6" => { "value" => "Not seeking work" }, + "8" => { "value" => "Unable to work due to long term sick or disability" }, + "5" => { "value" => "Retired" }, + "0" => { "value" => "Other" }, + "10" => { "value" => "Buyer prefers not to say" }, + "7" => { "value" => "Full-time student" }, + "9" => { "value" => "Child under 16" }, + }.freeze +end diff --git a/app/models/form/sales/questions/buyer_interview.rb b/app/models/form/sales/questions/buyer_interview.rb new file mode 100644 index 000000000..d270d9d33 --- /dev/null +++ b/app/models/form/sales/questions/buyer_interview.rb @@ -0,0 +1,17 @@ +class Form::Sales::Questions::BuyerInterview < ::Form::Question + def initialize(id, hsh, page) + super + @id = "noint" + @check_answer_label = "Buyer interviewed in person?" + @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 + + ANSWER_OPTIONS = { + "1" => { "value" => "No" }, + "2" => { "value" => "Yes" }, + }.freeze +end diff --git a/app/models/form/sales/questions/gender_identity2.rb b/app/models/form/sales/questions/gender_identity2.rb new file mode 100644 index 000000000..2c0946edb --- /dev/null +++ b/app/models/form/sales/questions/gender_identity2.rb @@ -0,0 +1,18 @@ +class Form::Sales::Questions::GenderIdentity2 < ::Form::Question + def initialize(id, hsh, page) + super + @id = "sex2" + @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 + end + + ANSWER_OPTIONS = { + "F" => { "value" => "Female" }, + "M" => { "value" => "Male" }, + "X" => { "value" => "Non-binary" }, + "R" => { "value" => "Buyer prefers not to say" }, + }.freeze +end diff --git a/app/models/form/sales/questions/household_wheelchair.rb b/app/models/form/sales/questions/household_wheelchair.rb new file mode 100644 index 000000000..43acfcc24 --- /dev/null +++ b/app/models/form/sales/questions/household_wheelchair.rb @@ -0,0 +1,17 @@ +class Form::Sales::Questions::HouseholdWheelchair < ::Form::Question + def initialize(id, hsh, page) + super + @id = "wheel" + @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 + + ANSWER_OPTIONS = { + "1" => { "value" => "Yes" }, + "2" => { "value" => "No" }, + "3" => { "value" => "Don't know" }, + }.freeze +end diff --git a/app/models/form/sales/questions/nationality1.rb b/app/models/form/sales/questions/nationality1.rb new file mode 100644 index 000000000..737bfc01e --- /dev/null +++ b/app/models/form/sales/questions/nationality1.rb @@ -0,0 +1,30 @@ +class Form::Sales::Questions::Nationality1 < ::Form::Question + def initialize(id, hsh, page) + super + @id = "national" + @check_answer_label = "Buyer 1’s nationality" + @header = "What is buyer 1’s nationality?" + @type = "radio" + @hint_text = "Buyer 1 is the person in the household who does the most paid work. If it’s a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest." + @page = page + @answer_options = ANSWER_OPTIONS + @conditional_for = { + "othernational" => [12], + } + @hidden_in_check_answers = { + "depends_on" => [ + { + "national" => 12, + }, + ], + } + end + + ANSWER_OPTIONS = { + "18" => { "value" => "United Kingdom" }, + "17" => { "value" => "Republic of Ireland" }, + "19" => { "value" => "European Economic Area (EEA), excluding ROI" }, + "12" => { "value" => "Other" }, + "13" => { "value" => "Buyer prefers not to say" }, + }.freeze +end 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 new file mode 100644 index 000000000..ddf2adb31 --- /dev/null +++ b/app/models/form/sales/questions/number_of_others_in_property.rb @@ -0,0 +1,12 @@ +class Form::Sales::Questions::NumberOfOthersInProperty < ::Form::Question + def initialize(id, hsh, page) + super + @id = "hholdcount" + @check_answer_label = "Number of other people living in the property" + @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_buyer2_relationship_to_buyer1.rb b/app/models/form/sales/questions/other_buyer2_relationship_to_buyer1.rb deleted file mode 100644 index f9959e3bd..000000000 --- a/app/models/form/sales/questions/other_buyer2_relationship_to_buyer1.rb +++ /dev/null @@ -1,10 +0,0 @@ -class Form::Sales::Questions::OtherBuyer2RelationshipToBuyer1 < ::Form::Question - def initialize(id, hsh, page) - super - @id = "otherrelat2" - @check_answer_label = "Buyer 2's relationship to buyer 1" - @header = "Buyer 2's relationship to buyer 1" - @type = "text" - @page = page - end -end diff --git a/app/models/form/sales/questions/other_nationality1.rb b/app/models/form/sales/questions/other_nationality1.rb new file mode 100644 index 000000000..a779d4fc8 --- /dev/null +++ b/app/models/form/sales/questions/other_nationality1.rb @@ -0,0 +1,10 @@ +class Form::Sales::Questions::OtherNationality1 < ::Form::Question + def initialize(id, hsh, page) + super + @id = "othernational" + @check_answer_label = "Buyer 1’s nationality" + @header = "Nationality" + @type = "text" + @page = page + end +end diff --git a/app/models/form/sales/questions/privacy_notice.rb b/app/models/form/sales/questions/privacy_notice.rb new file mode 100644 index 000000000..e853b38de --- /dev/null +++ b/app/models/form/sales/questions/privacy_notice.rb @@ -0,0 +1,18 @@ +class Form::Sales::Questions::PrivacyNotice < ::Form::Question + def initialize(id, hsh, page) + super + @id = "privacynotice" + @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" + end + + ANSWER_OPTIONS = { + "privacynotice" => { "value" => "The buyer has seen the DLUHC privacy notice" }, + }.freeze +end diff --git a/app/models/form/sales/questions/building_type.rb b/app/models/form/sales/questions/property_building_type.rb similarity index 86% rename from app/models/form/sales/questions/building_type.rb rename to app/models/form/sales/questions/property_building_type.rb index 6673d5a6d..416c9928e 100644 --- a/app/models/form/sales/questions/building_type.rb +++ b/app/models/form/sales/questions/property_building_type.rb @@ -1,4 +1,4 @@ -class Form::Sales::Questions::BuildingType < ::Form::Question +class Form::Sales::Questions::PropertyBuildingType < ::Form::Question def initialize(id, hsh, page) super @id = "builtype" diff --git a/app/models/form/sales/sections/household.rb b/app/models/form/sales/sections/household.rb index b3432522e..e6f71a26d 100644 --- a/app/models/form/sales/sections/household.rb +++ b/app/models/form/sales/sections/household.rb @@ -5,6 +5,9 @@ class Form::Sales::Sections::Household < ::Form::Section @label = "About the household" @description = "" @form = form - @subsections = [Form::Sales::Subsections::HouseholdCharacteristics.new(nil, nil, self)] || [] + @subsections = [ + Form::Sales::Subsections::HouseholdCharacteristics.new(nil, nil, self), + Form::Sales::Subsections::HouseholdNeeds.new(nil, nil, self), + ] end end diff --git a/app/models/form/sales/subsections/household_characteristics.rb b/app/models/form/sales/subsections/household_characteristics.rb index 6a6cb2824..7af439221 100644 --- a/app/models/form/sales/subsections/household_characteristics.rb +++ b/app/models/form/sales/subsections/household_characteristics.rb @@ -9,11 +9,25 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection def pages @pages ||= [ + Form::Sales::Pages::BuyerInterview.new(nil, nil, self), + Form::Sales::Pages::PrivacyNotice.new(nil, nil, self), Form::Sales::Pages::Age1.new(nil, nil, self), Form::Sales::Pages::GenderIdentity1.new(nil, nil, self), + Form::Sales::Pages::Buyer1EthnicGroup.new(nil, nil, self), + Form::Sales::Pages::Buyer1EthnicBackgroundBlack.new(nil, nil, self), + Form::Sales::Pages::Buyer1EthnicBackgroundAsian.new(nil, nil, self), + Form::Sales::Pages::Buyer1EthnicBackgroundArab.new(nil, nil, self), + Form::Sales::Pages::Buyer1EthnicBackgroundMixed.new(nil, nil, self), + Form::Sales::Pages::Buyer1EthnicBackgroundWhite.new(nil, nil, self), + Form::Sales::Pages::Nationality1.new(nil, nil, self), + Form::Sales::Pages::Buyer1WorkingSituation.new(nil, nil, self), Form::Sales::Pages::Buyer1LiveInProperty.new(nil, nil, self), Form::Sales::Pages::Buyer2RelationshipToBuyer1.new(nil, nil, self), Form::Sales::Pages::Age2.new(nil, nil, self), + Form::Sales::Pages::GenderIdentity2.new(nil, nil, self), + Form::Sales::Pages::Buyer2WorkingSituation.new(nil, nil, self), + Form::Sales::Pages::Buyer2LiveInProperty.new(nil, nil, self), + Form::Sales::Pages::NumberOfOthersInProperty.new(nil, nil, self), ] end end diff --git a/app/models/form/sales/subsections/household_needs.rb b/app/models/form/sales/subsections/household_needs.rb new file mode 100644 index 000000000..bf7a5df3a --- /dev/null +++ b/app/models/form/sales/subsections/household_needs.rb @@ -0,0 +1,15 @@ +class Form::Sales::Subsections::HouseholdNeeds < ::Form::Subsection + def initialize(id, hsh, section) + super + @id = "household_needs" + @label = "Household needs" + @section = section + @depends_on = [{ "setup" => "completed" }] + end + + def pages + @pages ||= [ + Form::Sales::Pages::HouseholdWheelchair.new(nil, nil, self), + ] + end +end diff --git a/app/models/form/sales/subsections/property_information.rb b/app/models/form/sales/subsections/property_information.rb index dee530487..3f09e03aa 100644 --- a/app/models/form/sales/subsections/property_information.rb +++ b/app/models/form/sales/subsections/property_information.rb @@ -10,6 +10,7 @@ class Form::Sales::Subsections::PropertyInformation < ::Form::Subsection 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::BuildingType.new(nil, nil, self), ] diff --git a/app/models/lettings_log.rb b/app/models/lettings_log.rb index f97568f59..9e38138eb 100644 --- a/app/models/lettings_log.rb +++ b/app/models/lettings_log.rb @@ -372,10 +372,6 @@ class LettingsLog < Log hb == 7 end - def ethnic_refused? - ethnic_group == 17 - end - def receives_housing_related_benefits? if collection_start_year <= 2021 receives_housing_benefit_only? || receives_uc_with_housing_element_excl_housing_benefit? || diff --git a/app/models/log.rb b/app/models/log.rb index e24a205fc..54770515f 100644 --- a/app/models/log.rb +++ b/app/models/log.rb @@ -36,6 +36,10 @@ class Log < ApplicationRecord false end + def ethnic_refused? + ethnic_group == 17 + end + private def update_status! diff --git a/app/models/sales_log.rb b/app/models/sales_log.rb index 0f0ca54c7..e1458caa9 100644 --- a/app/models/sales_log.rb +++ b/app/models/sales_log.rb @@ -3,10 +3,15 @@ class SalesLogValidator < ActiveModel::Validator end class SalesLog < Log + include DerivedVariables::SalesLogVariables + self.inheritance_column = :_type_disabled + has_paper_trail validates_with SalesLogValidator + before_validation :set_derived_fields! + before_validation :reset_invalidated_dependent_fields! scope :filter_by_year, ->(year) { where(saledate: Time.zone.local(year.to_i, 4, 1)...Time.zone.local(year.to_i + 1, 4, 1)) } scope :search_by, ->(param) { filter_by_id(param) } diff --git a/app/views/form/guidance/_privacy_notice_buyer.erb b/app/views/form/guidance/_privacy_notice_buyer.erb new file mode 100644 index 000000000..fabe9ced1 --- /dev/null +++ b/app/views/form/guidance/_privacy_notice_buyer.erb @@ -0,0 +1 @@ +

Make sure the buyer has seen <%= govuk_link_to "the Department for Levelling Up, Housing & Communities (DLUHC) privacy notice", privacy_notice_path, target: :_blank %> before completing this log.

diff --git a/app/views/form/guidance/_privacy_notice.erb b/app/views/form/guidance/_privacy_notice_tenant.erb similarity index 57% rename from app/views/form/guidance/_privacy_notice.erb rename to app/views/form/guidance/_privacy_notice_tenant.erb index c6e0b9adc..88b281730 100644 --- a/app/views/form/guidance/_privacy_notice.erb +++ b/app/views/form/guidance/_privacy_notice_tenant.erb @@ -1 +1 @@ -

Make sure the tenant has seen <%= govuk_link_to "the Department for Levelling Up, Housing & Communities (DLUHC) privacy notice", privacy_notice_path %> before completing this log.

+

Make sure the tenant has seen <%= govuk_link_to "the Department for Levelling Up, Housing & Communities (DLUHC) privacy notice", privacy_notice_path, target: :_blank %> before completing this log.

diff --git a/config/forms/2021_2022.json b/config/forms/2021_2022.json index 2ed0f3fdc..801ab5717 100644 --- a/config/forms/2021_2022.json +++ b/config/forms/2021_2022.json @@ -32,15 +32,19 @@ } }, "conditional_for": { - "postcode_full": [1] + "postcode_full": [ + 1 + ] }, "hidden_in_check_answers": { - "depends_on": [{ - "postcode_known": 0 - }, - { - "postcode_known": 1 - }] + "depends_on": [ + { + "postcode_known": 0 + }, + { + "postcode_known": 1 + } + ] } }, "postcode_full": { @@ -772,7 +776,11 @@ ] }, "void_date_value_check": { - "depends_on": [{ "voiddate_in_soft_range?": true }], + "depends_on": [ + { + "voiddate_in_soft_range?": true + } + ], "title_text": { "translation": "soft_validations.void_date.title_text" }, @@ -839,7 +847,9 @@ } }, "conditional_for": { - "mrcdate": [1] + "mrcdate": [ + 1 + ] } }, "mrcdate": { @@ -901,7 +911,11 @@ ] }, "property_major_repairs_value_check": { - "depends_on": [{ "major_repairs_date_in_soft_range?": true }], + "depends_on": [ + { + "major_repairs_date_in_soft_range?": true + } + ], "title_text": { "translation": "soft_validations.major_repairs_date.title_text" }, @@ -989,7 +1003,9 @@ } }, "conditional_for": { - "tenancyother": [3] + "tenancyother": [ + 3 + ] } }, "tenancyother": { @@ -1031,7 +1047,9 @@ } }, "conditional_for": { - "tenancyother": [3] + "tenancyother": [ + 3 + ] } }, "tenancyother": { @@ -1125,7 +1143,7 @@ "questions": { "declaration": { "header": "", - "guidance_partial": "privacy_notice", + "guidance_partial": "privacy_notice_tenant", "check_answer_label": "Tenant has seen the privacy notice", "check_answers_card_number": 0, "type": "checkbox", @@ -1153,10 +1171,18 @@ "width": 2 } }, - "depends_on": [{ "declaration": 1 }] + "depends_on": [ + { + "declaration": 1 + } + ] }, "no_females_pregnant_household_lead_hhmemb_value_check": { - "depends_on": [{ "no_females_in_a_pregnant_household?": true }], + "depends_on": [ + { + "no_females_in_a_pregnant_household?": true + } + ], "title_text": { "translation": "soft_validations.pregnancy.title", "arguments": [ @@ -1255,7 +1281,9 @@ } }, "conditional_for": { - "age1": [0] + "age1": [ + 0 + ] }, "hidden_in_check_answers": { "depends_on": [ @@ -1285,10 +1313,18 @@ } } }, - "depends_on": [{ "declaration": 1 }] + "depends_on": [ + { + "declaration": 1 + } + ] }, "no_females_pregnant_household_lead_age_value_check": { - "depends_on": [{ "no_females_in_a_pregnant_household?": true }], + "depends_on": [ + { + "no_females_in_a_pregnant_household?": true + } + ], "title_text": { "translation": "soft_validations.pregnancy.title", "arguments": [ @@ -1398,10 +1434,18 @@ } } }, - "depends_on": [{ "declaration": 1 }] + "depends_on": [ + { + "declaration": 1 + } + ] }, "no_females_pregnant_household_lead_value_check": { - "depends_on": [{ "no_females_in_a_pregnant_household?": true }], + "depends_on": [ + { + "no_females_in_a_pregnant_household?": true + } + ], "title_text": { "translation": "soft_validations.pregnancy.title", "arguments": [ @@ -1517,7 +1561,11 @@ } } }, - "depends_on": [{ "declaration": 1 }] + "depends_on": [ + { + "declaration": 1 + } + ] }, "lead_tenant_ethnic_background_arab": { "header": "", @@ -1539,7 +1587,11 @@ } } }, - "depends_on": [{ "ethnic_group": 4 }] + "depends_on": [ + { + "ethnic_group": 4 + } + ] }, "lead_tenant_ethnic_background_asian": { "header": "", @@ -1570,7 +1622,11 @@ } } }, - "depends_on": [{ "ethnic_group": 2 }] + "depends_on": [ + { + "ethnic_group": 2 + } + ] }, "lead_tenant_ethnic_background_black": { "header": "", @@ -1595,7 +1651,11 @@ } } }, - "depends_on": [{ "ethnic_group": 3 }] + "depends_on": [ + { + "ethnic_group": 3 + } + ] }, "lead_tenant_ethnic_background_mixed": { "header": "", @@ -1623,7 +1683,11 @@ } } }, - "depends_on": [{ "ethnic_group": 1 }] + "depends_on": [ + { + "ethnic_group": 1 + } + ] }, "lead_tenant_ethnic_background_white": { "header": "", @@ -1651,7 +1715,11 @@ } } }, - "depends_on": [{ "ethnic_group": 0 }] + "depends_on": [ + { + "ethnic_group": 0 + } + ] }, "lead_tenant_nationality": { "header": "", @@ -1719,7 +1787,11 @@ } } }, - "depends_on": [{ "declaration": 1 }] + "depends_on": [ + { + "declaration": 1 + } + ] }, "lead_tenant_working_situation": { "header": "", @@ -1768,10 +1840,18 @@ } } }, - "depends_on": [{ "declaration": 1 }] + "depends_on": [ + { + "declaration": 1 + } + ] }, "lead_tenant_under_retirement_value_check": { - "depends_on": [{ "person_1_retired_under_soft_min_age?": true }], + "depends_on": [ + { + "person_1_retired_under_soft_min_age?": true + } + ], "title_text": { "translation": "soft_validations.retirement.min.title", "arguments": [ @@ -1826,7 +1906,9 @@ }, "lead_tenant_over_retirement_value_check": { "depends_on": [ - { "person_1_not_retired_over_soft_max_age?": true } + { + "person_1_not_retired_over_soft_max_age?": true + } ], "title_text": { "translation": "soft_validations.retirement.max.title", @@ -1978,7 +2060,9 @@ } }, "conditional_for": { - "age2": [0] + "age2": [ + 0 + ] }, "hidden_in_check_answers": { "depends_on": [ @@ -2016,7 +2100,10 @@ }, "no_females_pregnant_household_person_2_age_value_check": { "depends_on": [ - { "no_females_in_a_pregnant_household?": true, "age2_known": 0 } + { + "no_females_in_a_pregnant_household?": true, + "age2_known": 0 + } ], "title_text": { "translation": "soft_validations.pregnancy.title", @@ -2260,8 +2347,15 @@ "9": { "value": "Child under 16", "depends_on": [ - { "age2_known": 1 }, - { "age2": { "operator": "<", "operand": 16 } } + { + "age2_known": 1 + }, + { + "age2": { + "operator": "<", + "operand": 16 + } + } ] }, "0": { @@ -2291,7 +2385,11 @@ ] }, "person_2_under_retirement_value_check": { - "depends_on": [{ "person_2_retired_under_soft_min_age?": true }], + "depends_on": [ + { + "person_2_retired_under_soft_min_age?": true + } + ], "title_text": { "translation": "soft_validations.retirement.min.title", "arguments": [ @@ -2346,7 +2444,9 @@ }, "person_2_over_retirement_value_check": { "depends_on": [ - { "person_2_not_retired_over_soft_max_age?": true } + { + "person_2_not_retired_over_soft_max_age?": true + } ], "title_text": { "translation": "soft_validations.retirement.max.title", @@ -2495,7 +2595,9 @@ } }, "conditional_for": { - "age3": [0] + "age3": [ + 0 + ] }, "hidden_in_check_answers": { "depends_on": [ @@ -2533,7 +2635,10 @@ }, "no_females_pregnant_household_person_3_age_value_check": { "depends_on": [ - { "no_females_in_a_pregnant_household?": true, "age3_known": 0 } + { + "no_females_in_a_pregnant_household?": true, + "age3_known": 0 + } ], "title_text": { "translation": "soft_validations.pregnancy.title", @@ -2777,8 +2882,15 @@ "9": { "value": "Child under 16", "depends_on": [ - { "age3_known": 1 }, - { "age3": { "operator": "<", "operand": 16 } } + { + "age3_known": 1 + }, + { + "age3": { + "operator": "<", + "operand": 16 + } + } ] }, "0": { @@ -2808,7 +2920,11 @@ ] }, "person_3_under_retirement_value_check": { - "depends_on": [{ "person_3_retired_under_soft_min_age?": true }], + "depends_on": [ + { + "person_3_retired_under_soft_min_age?": true + } + ], "title_text": { "translation": "soft_validations.retirement.min.title", "arguments": [ @@ -2863,7 +2979,9 @@ }, "person_3_over_retirement_value_check": { "depends_on": [ - { "person_3_not_retired_over_soft_max_age?": true } + { + "person_3_not_retired_over_soft_max_age?": true + } ], "title_text": { "translation": "soft_validations.retirement.max.title", @@ -3009,7 +3127,9 @@ } }, "conditional_for": { - "age4": [0] + "age4": [ + 0 + ] }, "hidden_in_check_answers": { "depends_on": [ @@ -3047,7 +3167,10 @@ }, "no_females_pregnant_household_person_4_age_value_check": { "depends_on": [ - { "no_females_in_a_pregnant_household?": true, "age4_known": 0 } + { + "no_females_in_a_pregnant_household?": true, + "age4_known": 0 + } ], "title_text": { "translation": "soft_validations.pregnancy.title", @@ -3291,8 +3414,15 @@ "9": { "value": "Child under 16", "depends_on": [ - { "age4_known": 1 }, - { "age4": { "operator": "<", "operand": 16 } } + { + "age4_known": 1 + }, + { + "age4": { + "operator": "<", + "operand": 16 + } + } ] }, "0": { @@ -3322,7 +3452,11 @@ ] }, "person_4_under_retirement_value_check": { - "depends_on": [{ "person_4_retired_under_soft_min_age?": true }], + "depends_on": [ + { + "person_4_retired_under_soft_min_age?": true + } + ], "title_text": { "translation": "soft_validations.retirement.min.title", "arguments": [ @@ -3377,7 +3511,9 @@ }, "person_4_over_retirement_value_check": { "depends_on": [ - { "person_4_not_retired_over_soft_max_age?": true } + { + "person_4_not_retired_over_soft_max_age?": true + } ], "title_text": { "translation": "soft_validations.retirement.max.title", @@ -3520,7 +3656,9 @@ } }, "conditional_for": { - "age5": [0] + "age5": [ + 0 + ] }, "hidden_in_check_answers": { "depends_on": [ @@ -3558,7 +3696,10 @@ }, "no_females_pregnant_household_person_5_age_value_check": { "depends_on": [ - { "no_females_in_a_pregnant_household?": true, "age5_known": 0 } + { + "no_females_in_a_pregnant_household?": true, + "age5_known": 0 + } ], "title_text": { "translation": "soft_validations.pregnancy.title", @@ -3802,8 +3943,15 @@ "9": { "value": "Child under 16", "depends_on": [ - { "age5_known": 1 }, - { "age5": { "operator": "<", "operand": 16 } } + { + "age5_known": 1 + }, + { + "age5": { + "operator": "<", + "operand": 16 + } + } ] }, "0": { @@ -3833,7 +3981,11 @@ ] }, "person_5_under_retirement_value_check": { - "depends_on": [{ "person_5_retired_under_soft_min_age?": true }], + "depends_on": [ + { + "person_5_retired_under_soft_min_age?": true + } + ], "title_text": { "translation": "soft_validations.retirement.min.title", "arguments": [ @@ -3888,7 +4040,9 @@ }, "person_5_over_retirement_value_check": { "depends_on": [ - { "person_5_not_retired_over_soft_max_age?": true } + { + "person_5_not_retired_over_soft_max_age?": true + } ], "title_text": { "translation": "soft_validations.retirement.max.title", @@ -4028,7 +4182,9 @@ } }, "conditional_for": { - "age6": [0] + "age6": [ + 0 + ] }, "hidden_in_check_answers": { "depends_on": [ @@ -4066,7 +4222,10 @@ }, "no_females_pregnant_household_person_6_age_value_check": { "depends_on": [ - { "no_females_in_a_pregnant_household?": true, "age6_known": 0 } + { + "no_females_in_a_pregnant_household?": true, + "age6_known": 0 + } ], "title_text": { "translation": "soft_validations.pregnancy.title", @@ -4310,8 +4469,15 @@ "9": { "value": "Child under 16", "depends_on": [ - { "age6_known": 1 }, - { "age6": { "operator": "<", "operand": 16 } } + { + "age6_known": 1 + }, + { + "age6": { + "operator": "<", + "operand": 16 + } + } ] }, "0": { @@ -4341,7 +4507,11 @@ ] }, "person_6_under_retirement_value_check": { - "depends_on": [{ "person_6_retired_under_soft_min_age?": true }], + "depends_on": [ + { + "person_6_retired_under_soft_min_age?": true + } + ], "title_text": { "translation": "soft_validations.retirement.min.title", "arguments": [ @@ -4396,7 +4566,9 @@ }, "person_6_over_retirement_value_check": { "depends_on": [ - { "person_6_not_retired_over_soft_max_age?": true } + { + "person_6_not_retired_over_soft_max_age?": true + } ], "title_text": { "translation": "soft_validations.retirement.max.title", @@ -4533,7 +4705,9 @@ } }, "conditional_for": { - "age7": [0] + "age7": [ + 0 + ] }, "hidden_in_check_answers": { "depends_on": [ @@ -4571,7 +4745,10 @@ }, "no_females_pregnant_household_person_7_age_value_check": { "depends_on": [ - { "no_females_in_a_pregnant_household?": true, "age7_known": 0 } + { + "no_females_in_a_pregnant_household?": true, + "age7_known": 0 + } ], "title_text": { "translation": "soft_validations.pregnancy.title", @@ -4815,8 +4992,15 @@ "9": { "value": "Child under 16", "depends_on": [ - { "age7_known": 1 }, - { "age7": { "operator": "<", "operand": 16 } } + { + "age7_known": 1 + }, + { + "age7": { + "operator": "<", + "operand": 16 + } + } ] }, "0": { @@ -4846,7 +5030,11 @@ ] }, "person_7_under_retirement_value_check": { - "depends_on": [{ "person_7_retired_under_soft_min_age?": true }], + "depends_on": [ + { + "person_7_retired_under_soft_min_age?": true + } + ], "title_text": { "translation": "soft_validations.retirement.min.title", "arguments": [ @@ -4901,7 +5089,9 @@ }, "person_7_over_retirement_value_check": { "depends_on": [ - { "person_7_not_retired_over_soft_max_age?": true } + { + "person_7_not_retired_over_soft_max_age?": true + } ], "title_text": { "translation": "soft_validations.retirement.max.title", @@ -5035,7 +5225,9 @@ } }, "conditional_for": { - "age8": [0] + "age8": [ + 0 + ] }, "hidden_in_check_answers": { "depends_on": [ @@ -5073,7 +5265,10 @@ }, "no_females_pregnant_household_person_8_age_value_check": { "depends_on": [ - { "no_females_in_a_pregnant_household?": true, "age8_known": 0 } + { + "no_females_in_a_pregnant_household?": true, + "age8_known": 0 + } ], "title_text": { "translation": "soft_validations.pregnancy.title", @@ -5317,8 +5512,15 @@ "9": { "value": "Child under 16", "depends_on": [ - { "age8_known": 1 }, - { "age8": { "operator": "<", "operand": 16 } } + { + "age8_known": 1 + }, + { + "age8": { + "operator": "<", + "operand": 16 + } + } ] }, "0": { @@ -5348,7 +5550,11 @@ ] }, "person_8_under_retirement_value_check": { - "depends_on": [{ "person_8_retired_under_soft_min_age?": true }], + "depends_on": [ + { + "person_8_retired_under_soft_min_age?": true + } + ], "title_text": { "translation": "soft_validations.retirement.min.title", "arguments": [ @@ -5403,7 +5609,9 @@ }, "person_8_over_retirement_value_check": { "depends_on": [ - { "person_8_not_retired_over_soft_max_age?": true } + { + "person_8_not_retired_over_soft_max_age?": true + } ], "title_text": { "translation": "soft_validations.retirement.max.title", @@ -5594,7 +5802,11 @@ } }, "no_females_pregnant_household_value_check": { - "depends_on": [{ "no_females_in_a_pregnant_household?": true }], + "depends_on": [ + { + "no_females_in_a_pregnant_household?": true + } + ], "title_text": { "translation": "soft_validations.pregnancy.title", "arguments": [ @@ -5662,7 +5874,8 @@ "pregnancy_value_check": { "check_answer_label": "Pregnancy confirmation", "hidden_in_check_answers": { - "depends_on": [{ + "depends_on": [ + { "pregnancy_value_check": 0 }, { @@ -6052,7 +6265,9 @@ } }, "conditional_for": { - "reasonother": [20] + "reasonother": [ + 20 + ] } }, "reasonother": { @@ -6283,7 +6498,9 @@ } }, "conditional_for": { - "ppostcode_full": [1] + "ppostcode_full": [ + 1 + ] }, "hidden_in_check_answers": { "depends_on": [ @@ -6344,7 +6561,9 @@ } }, "conditional_for": { - "prevloc": [1] + "prevloc": [ + 1 + ] } }, "prevloc": { @@ -7175,7 +7394,11 @@ } }, "net_income_value_check": { - "depends_on": [{ "net_income_soft_validation_triggered?": true }], + "depends_on": [ + { + "net_income_soft_validation_triggered?": true + } + ], "title_text": { "translation": "soft_validations.net_income.title_text" }, @@ -7376,7 +7599,9 @@ } }, "conditional_for": { - "chcharge": [1] + "chcharge": [ + 1 + ] } }, "chcharge": { @@ -7471,7 +7696,9 @@ } }, "conditional_for": { - "chcharge": [1] + "chcharge": [ + 1 + ] } }, "chcharge": { @@ -7516,7 +7743,9 @@ } }, "conditional_for": { - "chcharge": [1] + "chcharge": [ + 1 + ] } }, "chcharge": { @@ -7561,7 +7790,9 @@ } }, "conditional_for": { - "chcharge": [1] + "chcharge": [ + 1 + ] } }, "chcharge": { @@ -7602,7 +7833,12 @@ "width": 5, "prefix": "£", "suffix": " every week", - "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"], + "fields-to-add": [ + "brent", + "scharge", + "pscharge", + "supcharg" + ], "result-field": "tcharge", "hidden_in_check_answers": true }, @@ -7616,7 +7852,12 @@ "width": 5, "prefix": "£", "suffix": " every week", - "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"], + "fields-to-add": [ + "brent", + "scharge", + "pscharge", + "supcharg" + ], "result-field": "tcharge", "hidden_in_check_answers": true }, @@ -7630,7 +7871,12 @@ "width": 5, "prefix": "£", "suffix": " every week", - "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"], + "fields-to-add": [ + "brent", + "scharge", + "pscharge", + "supcharg" + ], "result-field": "tcharge", "hidden_in_check_answers": true }, @@ -7644,7 +7890,12 @@ "width": 5, "prefix": "£", "suffix": " every week", - "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"], + "fields-to-add": [ + "brent", + "scharge", + "pscharge", + "supcharg" + ], "result-field": "tcharge", "hidden_in_check_answers": true }, @@ -7660,7 +7911,12 @@ "suffix": " every week", "readonly": true, "requires_js": true, - "fields_added": ["brent", "scharge", "pscharge", "supcharg"] + "fields_added": [ + "brent", + "scharge", + "pscharge", + "supcharg" + ] } }, "depends_on": [ @@ -7800,7 +8056,12 @@ "width": 5, "prefix": "£", "suffix": " every 2 weeks", - "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"], + "fields-to-add": [ + "brent", + "scharge", + "pscharge", + "supcharg" + ], "result-field": "tcharge", "hidden_in_check_answers": true }, @@ -7814,7 +8075,12 @@ "width": 5, "prefix": "£", "suffix": " every 2 weeks", - "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"], + "fields-to-add": [ + "brent", + "scharge", + "pscharge", + "supcharg" + ], "result-field": "tcharge", "hidden_in_check_answers": true }, @@ -7828,7 +8094,12 @@ "width": 5, "prefix": "£", "suffix": " every 2 weeks", - "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"], + "fields-to-add": [ + "brent", + "scharge", + "pscharge", + "supcharg" + ], "result-field": "tcharge", "hidden_in_check_answers": true }, @@ -7842,7 +8113,12 @@ "width": 5, "prefix": "£", "suffix": " every 2 weeks", - "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"], + "fields-to-add": [ + "brent", + "scharge", + "pscharge", + "supcharg" + ], "result-field": "tcharge", "hidden_in_check_answers": true }, @@ -7858,7 +8134,12 @@ "suffix": " every 2 weeks", "readonly": true, "requires_js": true, - "fields_added": ["brent", "scharge", "pscharge", "supcharg"] + "fields_added": [ + "brent", + "scharge", + "pscharge", + "supcharg" + ] } }, "depends_on": [ @@ -7898,7 +8179,12 @@ "width": 5, "prefix": "£", "suffix": " every 4 weeks", - "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"], + "fields-to-add": [ + "brent", + "scharge", + "pscharge", + "supcharg" + ], "result-field": "tcharge", "hidden_in_check_answers": true }, @@ -7912,7 +8198,12 @@ "width": 5, "prefix": "£", "suffix": " every 4 weeks", - "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"], + "fields-to-add": [ + "brent", + "scharge", + "pscharge", + "supcharg" + ], "result-field": "tcharge", "hidden_in_check_answers": true }, @@ -7926,7 +8217,12 @@ "width": 5, "prefix": "£", "suffix": " every 4 weeks", - "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"], + "fields-to-add": [ + "brent", + "scharge", + "pscharge", + "supcharg" + ], "result-field": "tcharge", "hidden_in_check_answers": true }, @@ -7940,7 +8236,12 @@ "width": 5, "prefix": "£", "suffix": " every 4 weeks", - "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"], + "fields-to-add": [ + "brent", + "scharge", + "pscharge", + "supcharg" + ], "result-field": "tcharge", "hidden_in_check_answers": true }, @@ -7956,7 +8257,12 @@ "suffix": " every 4 weeks", "readonly": true, "requires_js": true, - "fields_added": ["brent", "scharge", "pscharge", "supcharg"] + "fields_added": [ + "brent", + "scharge", + "pscharge", + "supcharg" + ] } }, "depends_on": [ @@ -7996,7 +8302,12 @@ "width": 5, "prefix": "£", "suffix": " every month", - "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"], + "fields-to-add": [ + "brent", + "scharge", + "pscharge", + "supcharg" + ], "result-field": "tcharge", "hidden_in_check_answers": true }, @@ -8010,7 +8321,12 @@ "width": 5, "prefix": "£", "suffix": " every month", - "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"], + "fields-to-add": [ + "brent", + "scharge", + "pscharge", + "supcharg" + ], "result-field": "tcharge", "hidden_in_check_answers": true }, @@ -8024,7 +8340,12 @@ "width": 5, "prefix": "£", "suffix": " every month", - "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"], + "fields-to-add": [ + "brent", + "scharge", + "pscharge", + "supcharg" + ], "result-field": "tcharge", "hidden_in_check_answers": true }, @@ -8038,7 +8359,12 @@ "width": 5, "prefix": "£", "suffix": " every month", - "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"], + "fields-to-add": [ + "brent", + "scharge", + "pscharge", + "supcharg" + ], "result-field": "tcharge", "hidden_in_check_answers": true }, @@ -8054,7 +8380,12 @@ "suffix": " every month", "readonly": true, "requires_js": true, - "fields_added": ["brent", "scharge", "pscharge", "supcharg"] + "fields_added": [ + "brent", + "scharge", + "pscharge", + "supcharg" + ] } }, "depends_on": [ @@ -8081,7 +8412,11 @@ ] }, "min_rent_value_check": { - "depends_on": [{ "rent_in_soft_min_range?": true }], + "depends_on": [ + { + "rent_in_soft_min_range?": true + } + ], "title_text": { "translation": "soft_validations.rent.min.title_text", "arguments": [ @@ -8134,7 +8469,11 @@ } }, "max_rent_value_check": { - "depends_on": [{ "rent_in_soft_max_range?": true }], + "depends_on": [ + { + "rent_in_soft_max_range?": true + } + ], "title_text": { "translation": "soft_validations.rent.max.title_text", "arguments": [ @@ -8253,7 +8592,9 @@ } }, "conditional_for": { - "tshortfall": [0] + "tshortfall": [ + 0 + ] } }, "tshortfall": { @@ -8267,39 +8608,57 @@ "suffix": [ { "label": " every 2 weeks", - "depends_on": { "period": 2 } + "depends_on": { + "period": 2 + } }, { "label": " every 4 weeks", - "depends_on": { "period": 3 } + "depends_on": { + "period": 3 + } }, { "label": " every calendar month", - "depends_on": { "period": 4 } + "depends_on": { + "period": 4 + } }, { "label": " every week for 50 weeks", - "depends_on": { "period": 5 } + "depends_on": { + "period": 5 + } }, { "label": " every week for 49 weeks", - "depends_on": { "period": 6 } + "depends_on": { + "period": 6 + } }, { "label": " every week for 48 weeks", - "depends_on": { "period": 7 } + "depends_on": { + "period": 7 + } }, { "label": " every week for 47 weeks", - "depends_on": { "period": 8 } + "depends_on": { + "period": 8 + } }, { "label": " every week for 46 weeks", - "depends_on": { "period": 9 } + "depends_on": { + "period": 9 + } }, { "label": " every week for 52 weeks", - "depends_on": { "period": 1 } + "depends_on": { + "period": 1 + } } ] } diff --git a/config/forms/2022_2023.json b/config/forms/2022_2023.json index 190fa04bd..490d28e12 100644 --- a/config/forms/2022_2023.json +++ b/config/forms/2022_2023.json @@ -32,15 +32,19 @@ } }, "conditional_for": { - "postcode_full": [1] + "postcode_full": [ + 1 + ] }, "hidden_in_check_answers": { - "depends_on": [{ - "postcode_known": 0 - }, - { - "postcode_known": 1 - }] + "depends_on": [ + { + "postcode_known": 0 + }, + { + "postcode_known": 1 + } + ] } }, "postcode_full": { @@ -772,7 +776,11 @@ ] }, "void_date_value_check": { - "depends_on": [{ "voiddate_in_soft_range?": true }], + "depends_on": [ + { + "voiddate_in_soft_range?": true + } + ], "title_text": { "translation": "soft_validations.void_date.title_text" }, @@ -839,7 +847,9 @@ } }, "conditional_for": { - "mrcdate": [1] + "mrcdate": [ + 1 + ] } }, "mrcdate": { @@ -901,7 +911,11 @@ ] }, "property_major_repairs_value_check": { - "depends_on": [{ "major_repairs_date_in_soft_range?": true }], + "depends_on": [ + { + "major_repairs_date_in_soft_range?": true + } + ], "title_text": { "translation": "soft_validations.major_repairs_date.title_text" }, @@ -1018,7 +1032,9 @@ } }, "conditional_for": { - "tenancyother": [3] + "tenancyother": [ + 3 + ] } }, "tenancyother": { @@ -1063,7 +1079,9 @@ } }, "conditional_for": { - "tenancyother": [3] + "tenancyother": [ + 3 + ] } }, "tenancyother": { @@ -1160,7 +1178,7 @@ "questions": { "declaration": { "header": "", - "guidance_partial": "privacy_notice", + "guidance_partial": "privacy_notice_tenant", "check_answer_label": "Tenant has seen the privacy notice", "check_answers_card_number": 0, "type": "checkbox", @@ -1188,10 +1206,18 @@ "width": 2 } }, - "depends_on": [{ "declaration": 1 }] + "depends_on": [ + { + "declaration": 1 + } + ] }, "no_females_pregnant_household_lead_hhmemb_value_check": { - "depends_on": [{ "no_females_in_a_pregnant_household?": true }], + "depends_on": [ + { + "no_females_in_a_pregnant_household?": true + } + ], "title_text": { "translation": "soft_validations.pregnancy.title", "arguments": [ @@ -1290,7 +1316,9 @@ } }, "conditional_for": { - "age1": [0] + "age1": [ + 0 + ] }, "hidden_in_check_answers": { "depends_on": [ @@ -1320,10 +1348,18 @@ } } }, - "depends_on": [{ "declaration": 1 }] + "depends_on": [ + { + "declaration": 1 + } + ] }, "no_females_pregnant_household_lead_age_value_check": { - "depends_on": [{ "no_females_in_a_pregnant_household?": true }], + "depends_on": [ + { + "no_females_in_a_pregnant_household?": true + } + ], "title_text": { "translation": "soft_validations.pregnancy.title", "arguments": [ @@ -1433,10 +1469,18 @@ } } }, - "depends_on": [{ "declaration": 1 }] + "depends_on": [ + { + "declaration": 1 + } + ] }, "no_females_pregnant_household_lead_value_check": { - "depends_on": [{ "no_females_in_a_pregnant_household?": true }], + "depends_on": [ + { + "no_females_in_a_pregnant_household?": true + } + ], "title_text": { "translation": "soft_validations.pregnancy.title", "arguments": [ @@ -1552,7 +1596,11 @@ } } }, - "depends_on": [{ "declaration": 1 }] + "depends_on": [ + { + "declaration": 1 + } + ] }, "lead_tenant_ethnic_background_arab": { "header": "", @@ -1574,7 +1622,11 @@ } } }, - "depends_on": [{ "ethnic_group": 4 }] + "depends_on": [ + { + "ethnic_group": 4 + } + ] }, "lead_tenant_ethnic_background_asian": { "header": "", @@ -1605,7 +1657,11 @@ } } }, - "depends_on": [{ "ethnic_group": 2 }] + "depends_on": [ + { + "ethnic_group": 2 + } + ] }, "lead_tenant_ethnic_background_black": { "header": "", @@ -1630,7 +1686,11 @@ } } }, - "depends_on": [{ "ethnic_group": 3 }] + "depends_on": [ + { + "ethnic_group": 3 + } + ] }, "lead_tenant_ethnic_background_mixed": { "header": "", @@ -1658,7 +1718,11 @@ } } }, - "depends_on": [{ "ethnic_group": 1 }] + "depends_on": [ + { + "ethnic_group": 1 + } + ] }, "lead_tenant_ethnic_background_white": { "header": "", @@ -1686,7 +1750,11 @@ } } }, - "depends_on": [{ "ethnic_group": 0 }] + "depends_on": [ + { + "ethnic_group": 0 + } + ] }, "lead_tenant_nationality": { "header": "", @@ -1718,7 +1786,11 @@ } } }, - "depends_on": [{ "declaration": 1 }] + "depends_on": [ + { + "declaration": 1 + } + ] }, "lead_tenant_working_situation": { "header": "", @@ -1767,10 +1839,18 @@ } } }, - "depends_on": [{ "declaration": 1 }] + "depends_on": [ + { + "declaration": 1 + } + ] }, "lead_tenant_under_retirement_value_check": { - "depends_on": [{ "person_1_retired_under_soft_min_age?": true }], + "depends_on": [ + { + "person_1_retired_under_soft_min_age?": true + } + ], "title_text": { "translation": "soft_validations.retirement.min.title", "arguments": [ @@ -1825,7 +1905,9 @@ }, "lead_tenant_over_retirement_value_check": { "depends_on": [ - { "person_1_not_retired_over_soft_max_age?": true } + { + "person_1_not_retired_over_soft_max_age?": true + } ], "title_text": { "translation": "soft_validations.retirement.max.title", @@ -1977,7 +2059,9 @@ } }, "conditional_for": { - "age2": [0] + "age2": [ + 0 + ] }, "hidden_in_check_answers": { "depends_on": [ @@ -2015,7 +2099,10 @@ }, "no_females_pregnant_household_person_2_age_value_check": { "depends_on": [ - { "no_females_in_a_pregnant_household?": true, "age2_known": 0 } + { + "no_females_in_a_pregnant_household?": true, + "age2_known": 0 + } ], "title_text": { "translation": "soft_validations.pregnancy.title", @@ -2259,8 +2346,15 @@ "9": { "value": "Child under 16", "depends_on": [ - { "age2_known": 1 }, - { "age2": { "operator": "<", "operand": 16 } } + { + "age2_known": 1 + }, + { + "age2": { + "operator": "<", + "operand": 16 + } + } ] }, "0": { @@ -2290,7 +2384,11 @@ ] }, "person_2_under_retirement_value_check": { - "depends_on": [{ "person_2_retired_under_soft_min_age?": true }], + "depends_on": [ + { + "person_2_retired_under_soft_min_age?": true + } + ], "title_text": { "translation": "soft_validations.retirement.min.title", "arguments": [ @@ -2345,7 +2443,9 @@ }, "person_2_over_retirement_value_check": { "depends_on": [ - { "person_2_not_retired_over_soft_max_age?": true } + { + "person_2_not_retired_over_soft_max_age?": true + } ], "title_text": { "translation": "soft_validations.retirement.max.title", @@ -2494,7 +2594,9 @@ } }, "conditional_for": { - "age3": [0] + "age3": [ + 0 + ] }, "hidden_in_check_answers": { "depends_on": [ @@ -2532,7 +2634,10 @@ }, "no_females_pregnant_household_person_3_age_value_check": { "depends_on": [ - { "no_females_in_a_pregnant_household?": true, "age3_known": 0 } + { + "no_females_in_a_pregnant_household?": true, + "age3_known": 0 + } ], "title_text": { "translation": "soft_validations.pregnancy.title", @@ -2776,8 +2881,15 @@ "9": { "value": "Child under 16", "depends_on": [ - { "age3_known": 1 }, - { "age3": { "operator": "<", "operand": 16 } } + { + "age3_known": 1 + }, + { + "age3": { + "operator": "<", + "operand": 16 + } + } ] }, "0": { @@ -2807,7 +2919,11 @@ ] }, "person_3_under_retirement_value_check": { - "depends_on": [{ "person_3_retired_under_soft_min_age?": true }], + "depends_on": [ + { + "person_3_retired_under_soft_min_age?": true + } + ], "title_text": { "translation": "soft_validations.retirement.min.title", "arguments": [ @@ -2862,7 +2978,9 @@ }, "person_3_over_retirement_value_check": { "depends_on": [ - { "person_3_not_retired_over_soft_max_age?": true } + { + "person_3_not_retired_over_soft_max_age?": true + } ], "title_text": { "translation": "soft_validations.retirement.max.title", @@ -3008,7 +3126,9 @@ } }, "conditional_for": { - "age4": [0] + "age4": [ + 0 + ] }, "hidden_in_check_answers": { "depends_on": [ @@ -3046,7 +3166,10 @@ }, "no_females_pregnant_household_person_4_age_value_check": { "depends_on": [ - { "no_females_in_a_pregnant_household?": true, "age4_known": 0 } + { + "no_females_in_a_pregnant_household?": true, + "age4_known": 0 + } ], "title_text": { "translation": "soft_validations.pregnancy.title", @@ -3290,8 +3413,15 @@ "9": { "value": "Child under 16", "depends_on": [ - { "age4_known": 1 }, - { "age4": { "operator": "<", "operand": 16 } } + { + "age4_known": 1 + }, + { + "age4": { + "operator": "<", + "operand": 16 + } + } ] }, "0": { @@ -3321,7 +3451,11 @@ ] }, "person_4_under_retirement_value_check": { - "depends_on": [{ "person_4_retired_under_soft_min_age?": true }], + "depends_on": [ + { + "person_4_retired_under_soft_min_age?": true + } + ], "title_text": { "translation": "soft_validations.retirement.min.title", "arguments": [ @@ -3376,7 +3510,9 @@ }, "person_4_over_retirement_value_check": { "depends_on": [ - { "person_4_not_retired_over_soft_max_age?": true } + { + "person_4_not_retired_over_soft_max_age?": true + } ], "title_text": { "translation": "soft_validations.retirement.max.title", @@ -3519,7 +3655,9 @@ } }, "conditional_for": { - "age5": [0] + "age5": [ + 0 + ] }, "hidden_in_check_answers": { "depends_on": [ @@ -3557,7 +3695,10 @@ }, "no_females_pregnant_household_person_5_age_value_check": { "depends_on": [ - { "no_females_in_a_pregnant_household?": true, "age5_known": 0 } + { + "no_females_in_a_pregnant_household?": true, + "age5_known": 0 + } ], "title_text": { "translation": "soft_validations.pregnancy.title", @@ -3801,8 +3942,15 @@ "9": { "value": "Child under 16", "depends_on": [ - { "age5_known": 1 }, - { "age5": { "operator": "<", "operand": 16 } } + { + "age5_known": 1 + }, + { + "age5": { + "operator": "<", + "operand": 16 + } + } ] }, "0": { @@ -3832,7 +3980,11 @@ ] }, "person_5_under_retirement_value_check": { - "depends_on": [{ "person_5_retired_under_soft_min_age?": true }], + "depends_on": [ + { + "person_5_retired_under_soft_min_age?": true + } + ], "title_text": { "translation": "soft_validations.retirement.min.title", "arguments": [ @@ -3887,7 +4039,9 @@ }, "person_5_over_retirement_value_check": { "depends_on": [ - { "person_5_not_retired_over_soft_max_age?": true } + { + "person_5_not_retired_over_soft_max_age?": true + } ], "title_text": { "translation": "soft_validations.retirement.max.title", @@ -4027,7 +4181,9 @@ } }, "conditional_for": { - "age6": [0] + "age6": [ + 0 + ] }, "hidden_in_check_answers": { "depends_on": [ @@ -4065,7 +4221,10 @@ }, "no_females_pregnant_household_person_6_age_value_check": { "depends_on": [ - { "no_females_in_a_pregnant_household?": true, "age6_known": 0 } + { + "no_females_in_a_pregnant_household?": true, + "age6_known": 0 + } ], "title_text": { "translation": "soft_validations.pregnancy.title", @@ -4309,8 +4468,15 @@ "9": { "value": "Child under 16", "depends_on": [ - { "age6_known": 1 }, - { "age6": { "operator": "<", "operand": 16 } } + { + "age6_known": 1 + }, + { + "age6": { + "operator": "<", + "operand": 16 + } + } ] }, "0": { @@ -4340,7 +4506,11 @@ ] }, "person_6_under_retirement_value_check": { - "depends_on": [{ "person_6_retired_under_soft_min_age?": true }], + "depends_on": [ + { + "person_6_retired_under_soft_min_age?": true + } + ], "title_text": { "translation": "soft_validations.retirement.min.title", "arguments": [ @@ -4395,7 +4565,9 @@ }, "person_6_over_retirement_value_check": { "depends_on": [ - { "person_6_not_retired_over_soft_max_age?": true } + { + "person_6_not_retired_over_soft_max_age?": true + } ], "title_text": { "translation": "soft_validations.retirement.max.title", @@ -4532,7 +4704,9 @@ } }, "conditional_for": { - "age7": [0] + "age7": [ + 0 + ] }, "hidden_in_check_answers": { "depends_on": [ @@ -4570,7 +4744,10 @@ }, "no_females_pregnant_household_person_7_age_value_check": { "depends_on": [ - { "no_females_in_a_pregnant_household?": true, "age7_known": 0 } + { + "no_females_in_a_pregnant_household?": true, + "age7_known": 0 + } ], "title_text": { "translation": "soft_validations.pregnancy.title", @@ -4814,8 +4991,15 @@ "9": { "value": "Child under 16", "depends_on": [ - { "age7_known": 1 }, - { "age7": { "operator": "<", "operand": 16 } } + { + "age7_known": 1 + }, + { + "age7": { + "operator": "<", + "operand": 16 + } + } ] }, "0": { @@ -4845,7 +5029,11 @@ ] }, "person_7_under_retirement_value_check": { - "depends_on": [{ "person_7_retired_under_soft_min_age?": true }], + "depends_on": [ + { + "person_7_retired_under_soft_min_age?": true + } + ], "title_text": { "translation": "soft_validations.retirement.min.title", "arguments": [ @@ -4900,7 +5088,9 @@ }, "person_7_over_retirement_value_check": { "depends_on": [ - { "person_7_not_retired_over_soft_max_age?": true } + { + "person_7_not_retired_over_soft_max_age?": true + } ], "title_text": { "translation": "soft_validations.retirement.max.title", @@ -5034,7 +5224,9 @@ } }, "conditional_for": { - "age8": [0] + "age8": [ + 0 + ] }, "hidden_in_check_answers": { "depends_on": [ @@ -5072,7 +5264,10 @@ }, "no_females_pregnant_household_person_8_age_value_check": { "depends_on": [ - { "no_females_in_a_pregnant_household?": true, "age8_known": 0 } + { + "no_females_in_a_pregnant_household?": true, + "age8_known": 0 + } ], "title_text": { "translation": "soft_validations.pregnancy.title", @@ -5316,8 +5511,15 @@ "9": { "value": "Child under 16", "depends_on": [ - { "age8_known": 1 }, - { "age8": { "operator": "<", "operand": 16 } } + { + "age8_known": 1 + }, + { + "age8": { + "operator": "<", + "operand": 16 + } + } ] }, "0": { @@ -5347,7 +5549,11 @@ ] }, "person_8_under_retirement_value_check": { - "depends_on": [{ "person_8_retired_under_soft_min_age?": true }], + "depends_on": [ + { + "person_8_retired_under_soft_min_age?": true + } + ], "title_text": { "translation": "soft_validations.retirement.min.title", "arguments": [ @@ -5402,7 +5608,9 @@ }, "person_8_over_retirement_value_check": { "depends_on": [ - { "person_8_not_retired_over_soft_max_age?": true } + { + "person_8_not_retired_over_soft_max_age?": true + } ], "title_text": { "translation": "soft_validations.retirement.max.title", @@ -5596,7 +5804,11 @@ } }, "no_females_pregnant_household_value_check": { - "depends_on": [{ "no_females_in_a_pregnant_household?": true }], + "depends_on": [ + { + "no_females_in_a_pregnant_household?": true + } + ], "title_text": { "translation": "soft_validations.pregnancy.title", "arguments": [ @@ -5664,7 +5876,8 @@ "pregnancy_value_check": { "check_answer_label": "Pregnancy confirmation", "hidden_in_check_answers": { - "depends_on": [{ + "depends_on": [ + { "pregnancy_value_check": 0 }, { @@ -6051,7 +6264,9 @@ } }, "conditional_for": { - "reasonother": [20] + "reasonother": [ + 20 + ] } }, "reasonother": { @@ -6242,7 +6457,9 @@ } }, "conditional_for": { - "ppostcode_full": [1] + "ppostcode_full": [ + 1 + ] }, "hidden_in_check_answers": { "depends_on": [ @@ -6303,7 +6520,9 @@ } }, "conditional_for": { - "prevloc": [1] + "prevloc": [ + 1 + ] } }, "prevloc": { @@ -7134,8 +7353,14 @@ } }, "net_income_value_check": { - "depends_on": [{ "net_income_soft_validation_triggered?": true }], - "title_text": { "translation": "soft_validations.net_income.title_text" }, + "depends_on": [ + { + "net_income_soft_validation_triggered?": true + } + ], + "title_text": { + "translation": "soft_validations.net_income.title_text" + }, "informative_text": { "translation": "soft_validations.net_income.hint_text", "arguments": [ @@ -7330,7 +7555,9 @@ } }, "conditional_for": { - "chcharge": [1] + "chcharge": [ + 1 + ] } }, "chcharge": { @@ -7425,7 +7652,9 @@ } }, "conditional_for": { - "chcharge": [1] + "chcharge": [ + 1 + ] } }, "chcharge": { @@ -7470,7 +7699,9 @@ } }, "conditional_for": { - "chcharge": [1] + "chcharge": [ + 1 + ] } }, "chcharge": { @@ -7515,7 +7746,9 @@ } }, "conditional_for": { - "chcharge": [1] + "chcharge": [ + 1 + ] } }, "chcharge": { @@ -7556,7 +7789,12 @@ "width": 5, "prefix": "£", "suffix": " every week", - "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"], + "fields-to-add": [ + "brent", + "scharge", + "pscharge", + "supcharg" + ], "result-field": "tcharge", "hidden_in_check_answers": true }, @@ -7570,7 +7808,12 @@ "width": 5, "prefix": "£", "suffix": " every week", - "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"], + "fields-to-add": [ + "brent", + "scharge", + "pscharge", + "supcharg" + ], "result-field": "tcharge", "hidden_in_check_answers": true }, @@ -7584,7 +7827,12 @@ "width": 5, "prefix": "£", "suffix": " every week", - "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"], + "fields-to-add": [ + "brent", + "scharge", + "pscharge", + "supcharg" + ], "result-field": "tcharge", "hidden_in_check_answers": true }, @@ -7598,7 +7846,12 @@ "width": 5, "prefix": "£", "suffix": " every week", - "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"], + "fields-to-add": [ + "brent", + "scharge", + "pscharge", + "supcharg" + ], "result-field": "tcharge", "hidden_in_check_answers": true }, @@ -7614,7 +7867,12 @@ "suffix": " every week", "readonly": true, "requires_js": true, - "fields_added": ["brent", "scharge", "pscharge", "supcharg"] + "fields_added": [ + "brent", + "scharge", + "pscharge", + "supcharg" + ] } }, "depends_on": [ @@ -7754,7 +8012,12 @@ "width": 5, "prefix": "£", "suffix": " every 2 weeks", - "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"], + "fields-to-add": [ + "brent", + "scharge", + "pscharge", + "supcharg" + ], "result-field": "tcharge", "hidden_in_check_answers": true }, @@ -7768,7 +8031,12 @@ "width": 5, "prefix": "£", "suffix": " every 2 weeks", - "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"], + "fields-to-add": [ + "brent", + "scharge", + "pscharge", + "supcharg" + ], "result-field": "tcharge", "hidden_in_check_answers": true }, @@ -7782,7 +8050,12 @@ "width": 5, "prefix": "£", "suffix": " every 2 weeks", - "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"], + "fields-to-add": [ + "brent", + "scharge", + "pscharge", + "supcharg" + ], "result-field": "tcharge", "hidden_in_check_answers": true }, @@ -7796,7 +8069,12 @@ "width": 5, "prefix": "£", "suffix": " every 2 weeks", - "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"], + "fields-to-add": [ + "brent", + "scharge", + "pscharge", + "supcharg" + ], "result-field": "tcharge", "hidden_in_check_answers": true }, @@ -7812,7 +8090,12 @@ "suffix": " every 2 weeks", "readonly": true, "requires_js": true, - "fields_added": ["brent", "scharge", "pscharge", "supcharg"] + "fields_added": [ + "brent", + "scharge", + "pscharge", + "supcharg" + ] } }, "depends_on": [ @@ -7852,7 +8135,12 @@ "width": 5, "prefix": "£", "suffix": " every 4 weeks", - "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"], + "fields-to-add": [ + "brent", + "scharge", + "pscharge", + "supcharg" + ], "result-field": "tcharge", "hidden_in_check_answers": true }, @@ -7866,7 +8154,12 @@ "width": 5, "prefix": "£", "suffix": " every 4 weeks", - "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"], + "fields-to-add": [ + "brent", + "scharge", + "pscharge", + "supcharg" + ], "result-field": "tcharge", "hidden_in_check_answers": true }, @@ -7880,7 +8173,12 @@ "width": 5, "prefix": "£", "suffix": " every 4 weeks", - "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"], + "fields-to-add": [ + "brent", + "scharge", + "pscharge", + "supcharg" + ], "result-field": "tcharge", "hidden_in_check_answers": true }, @@ -7894,7 +8192,12 @@ "width": 5, "prefix": "£", "suffix": " every 4 weeks", - "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"], + "fields-to-add": [ + "brent", + "scharge", + "pscharge", + "supcharg" + ], "result-field": "tcharge", "hidden_in_check_answers": true }, @@ -7910,7 +8213,12 @@ "suffix": " every 4 weeks", "readonly": true, "requires_js": true, - "fields_added": ["brent", "scharge", "pscharge", "supcharg"] + "fields_added": [ + "brent", + "scharge", + "pscharge", + "supcharg" + ] } }, "depends_on": [ @@ -7950,7 +8258,12 @@ "width": 5, "prefix": "£", "suffix": " every month", - "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"], + "fields-to-add": [ + "brent", + "scharge", + "pscharge", + "supcharg" + ], "result-field": "tcharge", "hidden_in_check_answers": true }, @@ -7964,7 +8277,12 @@ "width": 5, "prefix": "£", "suffix": " every month", - "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"], + "fields-to-add": [ + "brent", + "scharge", + "pscharge", + "supcharg" + ], "result-field": "tcharge", "hidden_in_check_answers": true }, @@ -7978,7 +8296,12 @@ "width": 5, "prefix": "£", "suffix": " every month", - "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"], + "fields-to-add": [ + "brent", + "scharge", + "pscharge", + "supcharg" + ], "result-field": "tcharge", "hidden_in_check_answers": true }, @@ -7992,7 +8315,12 @@ "width": 5, "prefix": "£", "suffix": " every month", - "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"], + "fields-to-add": [ + "brent", + "scharge", + "pscharge", + "supcharg" + ], "result-field": "tcharge", "hidden_in_check_answers": true }, @@ -8008,7 +8336,12 @@ "suffix": " every month", "readonly": true, "requires_js": true, - "fields_added": ["brent", "scharge", "pscharge", "supcharg"] + "fields_added": [ + "brent", + "scharge", + "pscharge", + "supcharg" + ] } }, "depends_on": [ @@ -8035,7 +8368,11 @@ ] }, "min_rent_value_check": { - "depends_on": [{ "rent_in_soft_min_range?": true }], + "depends_on": [ + { + "rent_in_soft_min_range?": true + } + ], "title_text": { "translation": "soft_validations.rent.min.title_text", "arguments": [ @@ -8088,7 +8425,11 @@ } }, "max_rent_value_check": { - "depends_on": [{ "rent_in_soft_max_range?": true }], + "depends_on": [ + { + "rent_in_soft_max_range?": true + } + ], "title_text": { "translation": "soft_validations.rent.max.title_text", "arguments": [ @@ -8199,7 +8540,9 @@ } }, "conditional_for": { - "tshortfall": [0] + "tshortfall": [ + 0 + ] } }, "tshortfall": { @@ -8213,39 +8556,57 @@ "suffix": [ { "label": " every 2 weeks", - "depends_on": { "period": 2 } + "depends_on": { + "period": 2 + } }, { "label": " every 4 weeks", - "depends_on": { "period": 3 } + "depends_on": { + "period": 3 + } }, { "label": " every calendar month", - "depends_on": { "period": 4 } + "depends_on": { + "period": 4 + } }, { "label": " every week for 50 weeks", - "depends_on": { "period": 5 } + "depends_on": { + "period": 5 + } }, { "label": " every week for 49 weeks", - "depends_on": { "period": 6 } + "depends_on": { + "period": 6 + } }, { "label": " every week for 48 weeks", - "depends_on": { "period": 7 } + "depends_on": { + "period": 7 + } }, { "label": " every week for 47 weeks", - "depends_on": { "period": 8 } + "depends_on": { + "period": 8 + } }, { "label": " every week for 46 weeks", - "depends_on": { "period": 9 } + "depends_on": { + "period": 9 + } }, { "label": " every week for 52 weeks", - "depends_on": { "period": 1 } + "depends_on": { + "period": 1 + } } ] } diff --git a/config/forms/schema/2021_2022.json b/config/forms/schema/2021_2022.json index d91600c4d..326394391 100644 --- a/config/forms/schema/2021_2022.json +++ b/config/forms/schema/2021_2022.json @@ -4,7 +4,12 @@ "title": "Form", "description": "A form", "type": "object", - "required": ["form_type", "start_year", "end_year", "sections"], + "required": [ + "form_type", + "start_year", + "end_year", + "sections" + ], "properties": { "form_type": { "description": "", @@ -35,7 +40,9 @@ "[a-z_]+": { "description": "", "type": "object", - "required": ["label"], + "required": [ + "label" + ], "properties": { "label": { "description": "", @@ -62,7 +69,10 @@ "[a-z_]+": { "description": "", "type": "object", - "required": ["header", "check_answer_label"], + "required": [ + "header", + "check_answer_label" + ], "properties": { "check_answer_label": { "description": "", diff --git a/config/forms/schema/generic.json b/config/forms/schema/generic.json index 7535ca339..97552a5f4 100644 --- a/config/forms/schema/generic.json +++ b/config/forms/schema/generic.json @@ -4,7 +4,12 @@ "title": "Form", "description": "A form", "type": "object", - "required": ["form_type", "start_year", "end_year", "sections"], + "required": [ + "form_type", + "start_year", + "end_year", + "sections" + ], "properties": { "form_type": { "description": "", @@ -35,7 +40,9 @@ "[a-z_]+": { "description": "SubSection Name", "type": "object", - "required": ["label"], + "required": [ + "label" + ], "properties": { "label": { "description": "", @@ -47,7 +54,10 @@ "^(?!(depends_on))[a-z_]+$": { "description": "Page Name", "type": "object", - "required": ["header", "questions"], + "required": [ + "header", + "questions" + ], "properties": { "header": { "description": "", @@ -63,7 +73,10 @@ "[a-z_]+": { "description": "Question Name", "type": "object", - "required": ["header", "type"], + "required": [ + "header", + "type" + ], "properties": { "header": { "description": "", diff --git a/db/migrate/20220927082602_add_national_column.rb b/db/migrate/20220927082602_add_national_column.rb new file mode 100644 index 000000000..d794bc858 --- /dev/null +++ b/db/migrate/20220927082602_add_national_column.rb @@ -0,0 +1,8 @@ +class AddNationalColumn < ActiveRecord::Migration[7.0] + def change + change_table :sales_logs, bulk: true do |t| + t.column :national, :integer + t.column :othernational, :string + end + end +end diff --git a/db/migrate/20220927100350_add_background_to_sales_log.rb b/db/migrate/20220927100350_add_background_to_sales_log.rb new file mode 100644 index 000000000..21dc70d82 --- /dev/null +++ b/db/migrate/20220927100350_add_background_to_sales_log.rb @@ -0,0 +1,6 @@ +class AddBackgroundToSalesLog < ActiveRecord::Migration[7.0] + change_table :sales_logs, bulk: true do |t| + t.column :ethnic, :integer + t.column :ethnic_group, :integer + end +end diff --git a/db/migrate/20220930134358_add_buyer2_sex_to_sales_log.rb b/db/migrate/20220930134358_add_buyer2_sex_to_sales_log.rb new file mode 100644 index 000000000..5d45f147e --- /dev/null +++ b/db/migrate/20220930134358_add_buyer2_sex_to_sales_log.rb @@ -0,0 +1,5 @@ +class AddBuyer2SexToSalesLog < ActiveRecord::Migration[7.0] + def change + add_column :sales_logs, :sex2, :string + end +end diff --git a/db/migrate/20221003092048_add_noint_to_sales_log.rb b/db/migrate/20221003092048_add_noint_to_sales_log.rb new file mode 100644 index 000000000..ab21aead6 --- /dev/null +++ b/db/migrate/20221003092048_add_noint_to_sales_log.rb @@ -0,0 +1,7 @@ +class AddNointToSalesLog < ActiveRecord::Migration[7.0] + def change + change_table :sales_logs, bulk: true do |t| + t.column :noint, :int + end + end +end diff --git a/db/migrate/20221003134554_add_buy2livein_to_sales_log.rb b/db/migrate/20221003134554_add_buy2livein_to_sales_log.rb new file mode 100644 index 000000000..ac8d4fbd7 --- /dev/null +++ b/db/migrate/20221003134554_add_buy2livein_to_sales_log.rb @@ -0,0 +1,7 @@ +class AddBuy2liveinToSalesLog < ActiveRecord::Migration[7.0] + def change + change_table :sales_logs, bulk: true do |t| + t.column :buy2livein, :int + end + end +end diff --git a/db/migrate/20221003150610_add_ecstat2_to_sales_log.rb b/db/migrate/20221003150610_add_ecstat2_to_sales_log.rb new file mode 100644 index 000000000..e6efb825b --- /dev/null +++ b/db/migrate/20221003150610_add_ecstat2_to_sales_log.rb @@ -0,0 +1,7 @@ +class AddEcstat2ToSalesLog < ActiveRecord::Migration[7.0] + def change + change_table :sales_logs, bulk: true do |t| + t.column :ecstat2, :int + end + end +end diff --git a/db/migrate/20221004095132_add_privacy_notice_to_sales_log.rb b/db/migrate/20221004095132_add_privacy_notice_to_sales_log.rb new file mode 100644 index 000000000..f60b00823 --- /dev/null +++ b/db/migrate/20221004095132_add_privacy_notice_to_sales_log.rb @@ -0,0 +1,7 @@ +class AddPrivacyNoticeToSalesLog < ActiveRecord::Migration[7.0] + def change + change_table :sales_logs, bulk: true do |t| + t.column :privacynotice, :int + end + end +end diff --git a/db/migrate/20221004184301_add_ecstat1_to_sales_log.rb b/db/migrate/20221004184301_add_ecstat1_to_sales_log.rb new file mode 100644 index 000000000..989a4442a --- /dev/null +++ b/db/migrate/20221004184301_add_ecstat1_to_sales_log.rb @@ -0,0 +1,7 @@ +class AddEcstat1ToSalesLog < ActiveRecord::Migration[7.0] + def change + change_table :sales_logs, bulk: true do |t| + t.column :ecstat1, :int + end + end +end diff --git a/db/migrate/20221005090129_add_wheel_to_sales_log.rb b/db/migrate/20221005090129_add_wheel_to_sales_log.rb new file mode 100644 index 000000000..33f08d7ff --- /dev/null +++ b/db/migrate/20221005090129_add_wheel_to_sales_log.rb @@ -0,0 +1,7 @@ +class AddWheelToSalesLog < ActiveRecord::Migration[7.0] + def change + change_table :sales_logs, bulk: true do |t| + t.column :wheel, :int + end + end +end diff --git a/db/migrate/20221005125543_add_hholdcount_to_sales_log.rb b/db/migrate/20221005125543_add_hholdcount_to_sales_log.rb new file mode 100644 index 000000000..c21b6dd8c --- /dev/null +++ b/db/migrate/20221005125543_add_hholdcount_to_sales_log.rb @@ -0,0 +1,7 @@ +class AddHholdcountToSalesLog < ActiveRecord::Migration[7.0] + def change + change_table :sales_logs, bulk: true do |t| + t.column :hholdcount, :int + end + end +end diff --git a/db/migrate/20221005150022_remove_otherrelat2_from_sales_log.rb b/db/migrate/20221005150022_remove_otherrelat2_from_sales_log.rb new file mode 100644 index 000000000..9cc5a35cf --- /dev/null +++ b/db/migrate/20221005150022_remove_otherrelat2_from_sales_log.rb @@ -0,0 +1,5 @@ +class RemoveOtherrelat2FromSalesLog < ActiveRecord::Migration[7.0] + def change + remove_column :sales_logs, :otherrelat2, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index fa885644b..eec74a385 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: 2022_09_29_125204) do +ActiveRecord::Schema[7.0].define(version: 2022_10_05_150022) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -337,14 +337,26 @@ ActiveRecord::Schema[7.0].define(version: 2022_09_29_125204) do t.integer "age1" t.integer "age1_known" t.string "sex1" + t.integer "national" + t.string "othernational" + t.integer "ethnic" + t.integer "ethnic_group" t.integer "buy1livein" t.integer "buylivein" t.integer "builtype" t.integer "proptype" - t.string "relat2" - t.string "otherrelat2" t.integer "age2" t.integer "age2_known" + t.string "relat2" + t.string "otherrelat2" + t.string "sex2" + t.integer "noint" + t.integer "buy2livein" + t.integer "ecstat2" + t.integer "privacynotice" + t.integer "ecstat1" + t.integer "hholdcount" + t.integer "wheel" 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 0a8a56ee0..321c9800f 100644 --- a/spec/factories/sales_log.rb +++ b/spec/factories/sales_log.rb @@ -20,15 +20,25 @@ FactoryBot.define do jointpur { 1 } beds { 2 } jointmore { 1 } + noint { 2 } age1_known { 0 } age1 { 30 } sex1 { "X" } + national { 18 } buy1livein { 1 } relat2 { "P" } proptype { 1 } age2_known { 0 } age2 { 35 } builtype { 1 } + ethnic { 3 } + ethnic_group { 12 } + sex2 { "X" } + buy2livein { "1" } + ecstat1 { "1" } + ecstat2 { "1" } + hholdcount { "1" } + wheel { 1 } end end end diff --git a/spec/features/form/conditional_questions_spec.rb b/spec/features/form/conditional_questions_spec.rb index 4f3f44b5a..33d99955e 100644 --- a/spec/features/form/conditional_questions_spec.rb +++ b/spec/features/form/conditional_questions_spec.rb @@ -12,6 +12,14 @@ RSpec.describe "Form Conditional Questions" do managing_organisation: user.organisation, ) end + let(:sales_log) do + FactoryBot.create( + :sales_log, + :completed, + owning_organisation: user.organisation, + managing_organisation: user.organisation, + ) + end let(:id) { lettings_log.id } let(:fake_2021_2022_form) { Form.new("spec/fixtures/forms/2021_2022.json") } @@ -44,5 +52,15 @@ RSpec.describe "Form Conditional Questions" do visit("/lettings-logs/#{id}/property-postcode") expect(page).to have_field("lettings-log-postcode-full-field", with: "NW1 6RT") end + + it "gets cleared if the conditional question is hidden after editing the answer" do + sales_log.update!(national: 12, othernational: "other") + visit("/sales-logs/#{sales_log.id}/buyer-1-nationality") + expect(page).to have_field("sales-log-othernational-field", with: "other") + + choose("sales-log-national-18-field", allow_label_click: true) + choose("sales-log-national-12-field", allow_label_click: true) + expect(page).to have_field("sales-log-othernational-field", with: "") + end end end diff --git a/spec/fixtures/forms/2021_2022.json b/spec/fixtures/forms/2021_2022.json index 99b4d8713..ac02a62a2 100644 --- a/spec/fixtures/forms/2021_2022.json +++ b/spec/fixtures/forms/2021_2022.json @@ -1,638 +1,708 @@ { - "form_type": "lettings", - "start_date": "2021-04-01T00:00:00.000+01:00", - "end_date": "2022-07-01T00:00:00.000+01:00", - "sections": { - "household": { - "label": "About the household", - "description": "Make sure the tenant has seen the privacy notice.", - "subsections": { - "household_characteristics": { - "label": "Household characteristics", - "pages": { - "tenant_code_test": { - "questions": { - "tenancycode": { - "check_answers_card_number": 0, - "check_answer_label": "Tenant code", - "header": "What is the tenant code?", - "hint_text": "This is how you usually refer to this tenancy on your own systems.", - "type": "text", - "width": 10 - } - }, - "depends_on": [ - { - "housingneeds_a": 1 - }, - { - "housingneeds_a": null - } - ]}, - "person_1_age": { - "questions": { - "age1": { - "check_answers_card_number": 1, - "check_answer_label": "Lead tenant’s age", - "header": "What is the tenant’s age?", - "type": "numeric", - "min": 16, - "max": 120, - "step": 1, - "width": 2 - } + "form_type": "lettings", + "start_date": "2021-04-01T00:00:00.000+01:00", + "end_date": "2022-07-01T00:00:00.000+01:00", + "sections": { + "household": { + "label": "About the household", + "description": "Make sure the tenant has seen the privacy notice.", + "subsections": { + "household_characteristics": { + "label": "Household characteristics", + "pages": { + "tenant_code_test": { + "questions": { + "tenancycode": { + "check_answers_card_number": 0, + "check_answer_label": "Tenant code", + "header": "What is the tenant code?", + "hint_text": "This is how you usually refer to this tenancy on your own systems.", + "type": "text", + "width": 10 + } + }, + "depends_on": [ + { + "housingneeds_a": 1 }, - "depends_on": [ - { - "housingneeds_a": 1 - }, - { - "housingneeds_a": null - } - ] + { + "housingneeds_a": null + } + ] + }, + "person_1_age": { + "questions": { + "age1": { + "check_answers_card_number": 1, + "check_answer_label": "Lead tenant’s age", + "header": "What is the tenant’s age?", + "type": "numeric", + "min": 16, + "max": 120, + "step": 1, + "width": 2 + } }, - "person_1_gender": { - "questions": { - "sex1": { - "check_answers_card_number": 1, - "check_answer_label": "Lead tenant’s gender identity", - "header": "Which of these best describes the tenant’s gender identity?", - "type": "radio", - "answer_options": { - "F": { - "value": "Female" - }, - "M": { - "value": "Male" - }, - "X": { - "value": "Non-binary" - }, - "R": { - "value": "Prefer not to say" - } + "depends_on": [ + { + "housingneeds_a": 1 + }, + { + "housingneeds_a": null + } + ] + }, + "person_1_gender": { + "questions": { + "sex1": { + "check_answers_card_number": 1, + "check_answer_label": "Lead tenant’s gender identity", + "header": "Which of these best describes the tenant’s gender identity?", + "type": "radio", + "answer_options": { + "F": { + "value": "Female" + }, + "M": { + "value": "Male" + }, + "X": { + "value": "Non-binary" + }, + "R": { + "value": "Prefer not to say" } } } - }, - "person_1_working_situation": { - "header": "", - "description": "", - "questions": { - "ecstat1": { - "check_answers_card_number": 1, - "check_answer_label": "Lead tenant’s working situation", - "header": "Which of these best describes the lead tenant’s socks?", - "hint_text": "The lead tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest.", - "type": "radio", - "answer_options": { - "0": { - "value": "Part-time – Less than 30 hours" - }, - "1": { - "value": "Full-time – 30 hours or more" - }, - "2": { - "value": "Full-time student" - }, - "3": { - "value": "In government training into work, such as New Deal" - }, - "4": { - "value": "Jobseeker" - }, - "5": { - "value": "Not seeking work" - }, - "6": { - "value": "Unable to work because of long term sick or disability" - }, - "7": { - "value": "Retired" - }, - "8": { - "value": "Child under 16" - }, - "9": { - "value": "Other" - }, - "divider": { - "value": true - }, - "10": { - "value": "Tenant prefers not to say" - } + } + }, + "person_1_working_situation": { + "header": "", + "description": "", + "questions": { + "ecstat1": { + "check_answers_card_number": 1, + "check_answer_label": "Lead tenant’s working situation", + "header": "Which of these best describes the lead tenant’s socks?", + "hint_text": "The lead tenant is the person in the household who does the most paid work. If several people do the same paid work, the lead tenant is whoever is the oldest.", + "type": "radio", + "answer_options": { + "0": { + "value": "Part-time – Less than 30 hours" + }, + "1": { + "value": "Full-time – 30 hours or more" + }, + "2": { + "value": "Full-time student" + }, + "3": { + "value": "In government training into work, such as New Deal" + }, + "4": { + "value": "Jobseeker" + }, + "5": { + "value": "Not seeking work" + }, + "6": { + "value": "Unable to work because of long term sick or disability" + }, + "7": { + "value": "Retired" + }, + "8": { + "value": "Child under 16" + }, + "9": { + "value": "Other" + }, + "divider": { + "value": true + }, + "10": { + "value": "Tenant prefers not to say" } } } - }, - "household_number_of_members": { - "questions": { - "hhmemb": { - "check_answers_card_number": 0, - "check_answer_label": "Number of Household Members", - "header": "How many people are there in the household?", - "hint_text": "The maximum number of members is 8", - "type": "numeric", - "min": 0, - "max": 8, - "step": 1, - "width": 2, - "conditional_for": { - "relat2": ">1", - "age2": ">1", - "sex2": ">1" - } - }, - "relat2": { - "check_answers_card_number": 2, - "check_answer_label": "Person 2’s relationship to lead tenant", - "header": "What is person 2’s relationship to lead tenant", - "type": "radio", - "answer_options": { - "X": { - "value": "Other" - }, - "R": { - "value": "Prefer not to say" - } + } + }, + "household_number_of_members": { + "questions": { + "hhmemb": { + "check_answers_card_number": 0, + "check_answer_label": "Number of Household Members", + "header": "How many people are there in the household?", + "hint_text": "The maximum number of members is 8", + "type": "numeric", + "min": 0, + "max": 8, + "step": 1, + "width": 2, + "conditional_for": { + "relat2": ">1", + "age2": ">1", + "sex2": ">1" + } + }, + "relat2": { + "check_answers_card_number": 2, + "check_answer_label": "Person 2’s relationship to lead tenant", + "header": "What is person 2’s relationship to lead tenant", + "type": "radio", + "answer_options": { + "X": { + "value": "Other" + }, + "R": { + "value": "Prefer not to say" } - }, - "age2": { - "check_answers_card_number": 2, - "check_answer_label": "Person 2’s age", - "header": "Do you know person 2’s age?", - "type": "numeric", - "min": 1, - "max": 120, - "step": 1, - "width": 2 - }, - "sex2": { - "check_answers_card_number": 2, - "check_answer_label": "Person 2’s gender identity", - "header": "Which of these best describes person 2’s gender identity?", - "type": "radio", - "answer_options": { - "F": { - "value": "Female" - }, - "M": { - "value": "Male" - }, - "X": { - "value": "Non-binary" - }, - "R": { - "value": "Prefer not to say" - } + } + }, + "age2": { + "check_answers_card_number": 2, + "check_answer_label": "Person 2’s age", + "header": "Do you know person 2’s age?", + "type": "numeric", + "min": 1, + "max": 120, + "step": 1, + "width": 2 + }, + "sex2": { + "check_answers_card_number": 2, + "check_answer_label": "Person 2’s gender identity", + "header": "Which of these best describes person 2’s gender identity?", + "type": "radio", + "answer_options": { + "F": { + "value": "Female" + }, + "M": { + "value": "Male" + }, + "X": { + "value": "Non-binary" + }, + "R": { + "value": "Prefer not to say" } } } - }, - "retirement_value_check": { - "questions": { - "retirement_value_check": { - "check_answer_label": "Retirement age soft validation", - "hidden_in_check_answers": true, - "header": "Are you sure this person is retired?", - "type": "radio", - "answer_options": { - "0": { - "value": "Yes" - }, - "1": { - "value": "No" - } + } + }, + "retirement_value_check": { + "questions": { + "retirement_value_check": { + "check_answer_label": "Retirement age soft validation", + "hidden_in_check_answers": true, + "header": "Are you sure this person is retired?", + "type": "radio", + "answer_options": { + "0": { + "value": "Yes" + }, + "1": { + "value": "No" } } - }, - "depends_on": [ - { - "age2": { "operator": ">", "operand": 50 } - } - ] + } }, - "person_2_working_situation": { - "header": "", - "description": "", - "questions": { - "ecstat2": { - "check_answers_card_number": 2, - "check_answer_label": "Person 2’s Work", - "header": "Which of these best describes person 2’s working situation?", - "type": "radio", - "answer_options": { - "0": { - "value": "Other" - }, - "9": { - "value": "Child under 16", - "depends_on": [ - { "age2_known": 1 }, - { "age2": { "operator": "<", "operand": 16 } } - ] - }, - "1": { - "value": "Prefer not to say" - } - } + "depends_on": [ + { + "age2": { + "operator": ">", + "operand": 50 } - }, - "depends_on": [ - { - "age2": { "operator": ">", "operand": 15 } + } + ] + }, + "person_2_working_situation": { + "header": "", + "description": "", + "questions": { + "ecstat2": { + "check_answers_card_number": 2, + "check_answer_label": "Person 2’s Work", + "header": "Which of these best describes person 2’s working situation?", + "type": "radio", + "answer_options": { + "0": { + "value": "Other" + }, + "9": { + "value": "Child under 16", + "depends_on": [ + { + "age2_known": 1 + }, + { + "age2": { + "operator": "<", + "operand": 16 + } + } + ] + }, + "1": { + "value": "Prefer not to say" + } } - ] + } }, - "propcode": { - "questions": { - "propcode": { - "check_answers_card_number": 0, - "check_answer_label": "", - "header": "property reference?", - "type": "text" + "depends_on": [ + { + "age2": { + "operator": ">", + "operand": 15 } } + ] + }, + "propcode": { + "questions": { + "propcode": { + "check_answers_card_number": 0, + "check_answer_label": "", + "header": "property reference?", + "type": "text" + } } } - }, - "household_needs": { - "label": "Household needs", - "pages": { - "armed_forces": { - "header": "Experience of the UK Armed Forces", - "questions": { - "armedforces": { - "header": "Does anybody in the household have any links to the UK armed forces?", - "hint_text": "This excludes national service. If there are several people in the household with links to the UK armed forces, you should answer for the regular. If there’s no regular, answer for the reserve. If there’s no reserve, answer for the spouse or civil partner.", - "type": "radio", - "check_answer_label": "Household links to UK armed forces", - "answer_options": { - "1": { - "value": "Yes, the person is a current or former regular" - }, - "4": { - "value": "Yes, the person is a current or former reserve" - }, - "5": { - "value": "Yes, the tenant is a spouse or civil partner of a UK armed forces member and has been bereaved or separated from them within the last 2 years" - }, - "2": { - "value": "No" - }, - "3": { - "value": "Person prefers not to say" - } + } + }, + "household_needs": { + "label": "Household needs", + "pages": { + "armed_forces": { + "header": "Experience of the UK Armed Forces", + "questions": { + "armedforces": { + "header": "Does anybody in the household have any links to the UK armed forces?", + "hint_text": "This excludes national service. If there are several people in the household with links to the UK armed forces, you should answer for the regular. If there’s no regular, answer for the reserve. If there’s no reserve, answer for the spouse or civil partner.", + "type": "radio", + "check_answer_label": "Household links to UK armed forces", + "answer_options": { + "1": { + "value": "Yes, the person is a current or former regular" + }, + "4": { + "value": "Yes, the person is a current or former reserve" }, - "conditional_for": { - "leftreg": [1] + "5": { + "value": "Yes, the tenant is a spouse or civil partner of a UK armed forces member and has been bereaved or separated from them within the last 2 years" + }, + "2": { + "value": "No" + }, + "3": { + "value": "Person prefers not to say" } }, - "leftreg": { - "header": "Are they still serving?", - "hint_text": "", - "type": "text", - "check_answer_label": "When did they leave the Armed Forces?" + "conditional_for": { + "leftreg": [ + 1 + ] + }, + "inferred_check_answers_value": { + "condition": { + "armedforces": 3 + }, + "value": "Prefers not to say" } + }, + "leftreg": { + "header": "Are they still serving?", + "hint_text": "", + "type": "text", + "check_answer_label": "When did they leave the Armed Forces?" } - }, - "medical_conditions": { - "questions": { - "illness": { - "header": "Does anyone in the household have any of the following that they expect to last for 12 months or more:", - "type": "radio", - "check_answer_label": "Physical, mental health or illness in the household", - "answer_options": { - "1": { - "value": "Yes" - }, - "2": { - "value": "No" - }, - "3": { - "value": "Don’t know" - } + } + }, + "medical_conditions": { + "questions": { + "illness": { + "header": "Does anyone in the household have any of the following that they expect to last for 12 months or more:", + "type": "radio", + "check_answer_label": "Physical, mental health or illness in the household", + "answer_options": { + "1": { + "value": "Yes" + }, + "2": { + "value": "No" + }, + "3": { + "value": "Don’t know" } } } - }, - "accessibility_requirements": { - "questions": { - "accessibility_requirements": { - "header": "Are any of these affected by their condition or illness?", - "hint_text": "Select all that apply", - "type": "checkbox", - "check_answer_label": "Disability requirements", - "answer_options": { - "housingneeds_a": { - "value": "Fully wheelchair accessible housing" - }, - "housingneeds_b": { - "value": "Wheelchair access to essential rooms" - }, - "housingneeds_c": { - "value": "Level access housing" - }, - "divider": { - "value": true - }, - "housingneeds_h": { - "value": "Don’t know" - } + } + }, + "accessibility_requirements": { + "questions": { + "accessibility_requirements": { + "header": "Are any of these affected by their condition or illness?", + "hint_text": "Select all that apply", + "type": "checkbox", + "check_answer_label": "Disability requirements", + "answer_options": { + "housingneeds_a": { + "value": "Fully wheelchair accessible housing" + }, + "housingneeds_b": { + "value": "Wheelchair access to essential rooms" + }, + "housingneeds_c": { + "value": "Level access housing" + }, + "divider": { + "value": true + }, + "housingneeds_h": { + "value": "Don’t know" } } } - }, - "accessible_select": { - "questions": { - "prevloc": { - "header": "Select options", - "hint_text": "Type ahead to filter the options", - "type": "select", - "check_answer_label": "Accessible Select", - "answer_options": { - "" : "Select an option", - "E07000223": "Adur", - "E09000023": "Lewisham", - "E08000003": "Manchester", - "E07000178": "Oxford", - "E07000114": "Thanet", - "E09000033": "Westminster", - "E06000014": "The one and only york town" - } - } - }, - "depends_on": [ - { - "previous_la_known": 1, - "is_previous_la_inferred": false + } + }, + "accessible_select": { + "questions": { + "prevloc": { + "header": "Select options", + "hint_text": "Type ahead to filter the options", + "type": "select", + "check_answer_label": "Accessible Select", + "answer_options": { + "": "Select an option", + "E07000223": "Adur", + "E09000023": "Lewisham", + "E08000003": "Manchester", + "E07000178": "Oxford", + "E07000114": "Thanet", + "E09000033": "Westminster", + "E06000014": "The one and only york town" } - ] + } }, - "condition_effects": { - "questions": { - "condition_effects": { - "header": "Are any of these affected by their condition or illness?", - "hint_text": "Select all that apply", - "type": "checkbox", - "check_answer_label": "Conditions or illnesses", - "answer_options": { - "illness_type_1": { - "value": "Vision - such as blindness or partial sight" - }, - "illness_type_2": { - "value": "Hearing - such as deafness or partial hearing" - } + "depends_on": [ + { + "previous_la_known": 1, + "is_previous_la_inferred": false + } + ] + }, + "condition_effects": { + "questions": { + "condition_effects": { + "header": "Are any of these affected by their condition or illness?", + "hint_text": "Select all that apply", + "type": "checkbox", + "check_answer_label": "Conditions or illnesses", + "answer_options": { + "illness_type_1": { + "value": "Vision - such as blindness or partial sight" + }, + "illness_type_2": { + "value": "Hearing - such as deafness or partial hearing" } } + } + }, + "depends_on": [ + { + "illness": 1 }, - "depends_on": [ - { - "illness": 1 - }, - { - "illness": 100 - } - ] - } + { + "illness": 100 + } + ] } } } - }, - "tenancy_and_property": { - "label": "Tenancy and property information", - "subsections": { - "property_information": { - "label": "Property information", - "pages": { - "accessible_select_too": { - "questions": { - "la": { - "header": "Select options", - "hint_text": "Type ahead to filter the options", - "type": "select", - "check_answer_label": "Accessible Select", - "answer_options": { - "" : "Select an option", - "E07000223": "Adur", - "E09000023": "Lewisham", - "E08000003": "Manchester", - "E07000178": "Oxford", - "E07000114": "Thanet", - "E09000033": "Westminster", - "E06000014": "York" - } - } - }, - "depends_on": [ - { - "is_la_inferred": false + } + }, + "tenancy_and_property": { + "label": "Tenancy and property information", + "subsections": { + "property_information": { + "label": "Property information", + "pages": { + "accessible_select_too": { + "questions": { + "la": { + "header": "Select options", + "hint_text": "Type ahead to filter the options", + "type": "select", + "check_answer_label": "Accessible Select", + "answer_options": { + "": "Select an option", + "E07000223": "Adur", + "E09000023": "Lewisham", + "E08000003": "Manchester", + "E07000178": "Oxford", + "E07000114": "Thanet", + "E09000033": "Westminster", + "E06000014": "York" } - ] + } }, - "property_postcode": { - "header": "", - "description": "", - "questions": { - "postcode_known": { - "check_answer_label": "Do you know the property postcode?", - "header": "Do you know the property’s postcode?", - "hint_text": "", - "type": "radio", - "answer_options": { - "1": { - "value": "Yes" - }, - "0": { - "value": "No" - } - }, - "conditional_for": { - "postcode_full": [ - 1 - ] + "depends_on": [ + { + "is_la_inferred": false + } + ] + }, + "property_postcode": { + "header": "", + "description": "", + "questions": { + "postcode_known": { + "check_answer_label": "Do you know the property postcode?", + "header": "Do you know the property’s postcode?", + "hint_text": "", + "type": "radio", + "answer_options": { + "1": { + "value": "Yes" }, - "hidden_in_check_answers": true + "0": { + "value": "No" + } }, - "postcode_full": { - "check_answer_label": "Postcode", - "header": "", - "hint_text": "", - "type": "text", - "width": 5, - "inferred_answers": { "la": { "is_la_inferred": true } }, - "inferred_check_answers_value": { - "condition": { "postcode_known": 0 }, - "value": "Not known" + "conditional_for": { + "postcode_full": [ + 1 + ] + }, + "hidden_in_check_answers": true + }, + "postcode_full": { + "check_answer_label": "Postcode", + "header": "", + "hint_text": "", + "type": "text", + "width": 5, + "inferred_answers": { + "la": { + "is_la_inferred": true } + }, + "inferred_check_answers_value": { + "condition": { + "postcode_known": 0 + }, + "value": "Not known" } } - }, - "do_you_know_the_local_authority": { - "header": "", - "description": "", - "questions": { - "previous_la_known": { - "check_answer_label": "Do you know what local authority the property is located in?", - "header": "Do you know what local authority the property is located in?", - "hint_text": "", - "type": "radio", - "answer_options": { - "0": { - "value": "No" - }, - "1": { - "value": "Yes" - } + } + }, + "do_you_know_the_local_authority": { + "header": "", + "description": "", + "questions": { + "previous_la_known": { + "check_answer_label": "Do you know what local authority the property is located in?", + "header": "Do you know what local authority the property is located in?", + "hint_text": "", + "type": "radio", + "answer_options": { + "0": { + "value": "No" + }, + "1": { + "value": "Yes" } } - }, - "depends_on": [{"is_la_inferred": false}] + } }, - "property_wheelchair_accessible": { - "questions": { - "wchair": { - "check_answer_label": "Wheelchair adaptation", - "header": "Is the property built or adapted to wheelchair-user standards?", - "type": "radio", - "answer_options": { - "0": { - "value": "Yes" - }, - "1": { - "value": "No" - } + "depends_on": [ + { + "is_la_inferred": false + } + ] + }, + "property_wheelchair_accessible": { + "questions": { + "wchair": { + "check_answer_label": "Wheelchair adaptation", + "header": "Is the property built or adapted to wheelchair-user standards?", + "type": "radio", + "answer_options": { + "0": { + "value": "Yes" + }, + "1": { + "value": "No" } } } } } - }, - "conditional_question": { - "label": "Conditional question", - "pages": { - "conditional_question": { - "questions": { - "preg_occ": { - "check_answer_label": "Has the condition been met?", - "header": "Has the condition been met?", - "type": "radio", - "answer_options": { - "1": { - "value": "Yes" - }, - "2": { - "value": "No" - } + } + }, + "conditional_question": { + "label": "Conditional question", + "pages": { + "conditional_question": { + "questions": { + "preg_occ": { + "check_answer_label": "Has the condition been met?", + "header": "Has the condition been met?", + "type": "radio", + "answer_options": { + "1": { + "value": "Yes" + }, + "2": { + "value": "No" } } } - }, - "conditional_question_yes_page": { - "questions": { - "cbl": { - "check_answer_label": "Has the next condition been met?", - "header": "Has the next condition been met?", - "type": "radio", - "answer_options": { - "0": { - "value": "Yes" - } + } + }, + "conditional_question_yes_page": { + "questions": { + "cbl": { + "check_answer_label": "Has the next condition been met?", + "header": "Has the next condition been met?", + "type": "radio", + "answer_options": { + "0": { + "value": "Yes" } } - }, - "depends_on": [{ "preg_occ": 1 }, { "wchair" : 1 }] + } }, - "conditional_question_no_page": { - "questions": { - "cbl": { - "check_answer_label": "Has the condition not been met?", - "header": "Has the next condition not been met?", - "type": "radio", - "answer_options": { - "0": { - "value": "Yes" - }, - "1": { - "value": "No" - } + "depends_on": [ + { + "preg_occ": 1 + }, + { + "wchair": 1 + } + ] + }, + "conditional_question_no_page": { + "questions": { + "cbl": { + "check_answer_label": "Has the condition not been met?", + "header": "Has the next condition not been met?", + "type": "radio", + "answer_options": { + "0": { + "value": "Yes" + }, + "1": { + "value": "No" } } - }, - "depends_on": [{ "preg_occ": 2 }] + } }, - "conditional_question_no_second_page": { - "questions": { - "conditional_question_no_second_question": { - "check_answer_label": "Has the condition not been met again?", - "header": "Has the next condition not been met again?", - "type": "radio", - "answer_options": { - "0": { - "value": "Yes" - }, - "1": { - "value": "No" - } + "depends_on": [ + { + "preg_occ": 2 + } + ] + }, + "conditional_question_no_second_page": { + "questions": { + "conditional_question_no_second_question": { + "check_answer_label": "Has the condition not been met again?", + "header": "Has the next condition not been met again?", + "type": "radio", + "answer_options": { + "0": { + "value": "Yes" + }, + "1": { + "value": "No" } } - }, - "depends_on": [{ "preg_occ": 2, "sex1": "M" }] - } + } + }, + "depends_on": [ + { + "preg_occ": 2, + "sex1": "M" + } + ] } } } - }, - "rent_and_charges": { - "label": "Rent and charges", - "subsections": { - "income_and_benefits": { - "label": "Income and benefits", - "pages": { - "net_income": { - "header": "Test header", - "description": "Some extra text for the page", - "questions": { - "earnings": { - "check_answer_label": "Income", - "header": "What is the tenant’s /and partner’s combined income after tax?", - "guidance_partial": "what_counts_as_income", - "type": "numeric", - "min": 0, - "step": 1, - "width": 5, - "prefix": "£", - "suffix": [ - { "label": " every week", "depends_on" : { "incfreq": 1 } }, - { "label": " every month", "depends_on" : { "incfreq": 2 } }, - { "label": " every year", "depends_on" : { "incfreq": 3 } } - ] - }, - "incfreq": { - "check_answer_label": "Income Frequency", - "header": "How often do they receive this income?", - "type": "radio", - "answer_options": { - "1": { - "value": "Weekly" - }, - "2": { - "value": "Monthly" - }, - "3": { - "value": "Yearly" + } + }, + "rent_and_charges": { + "label": "Rent and charges", + "subsections": { + "income_and_benefits": { + "label": "Income and benefits", + "pages": { + "net_income": { + "header": "Test header", + "description": "Some extra text for the page", + "questions": { + "earnings": { + "check_answer_label": "Income", + "header": "What is the tenant’s /and partner’s combined income after tax?", + "guidance_partial": "what_counts_as_income", + "type": "numeric", + "min": 0, + "step": 1, + "width": 5, + "prefix": "£", + "suffix": [ + { + "label": " every week", + "depends_on": { + "incfreq": 1 + } + }, + { + "label": " every month", + "depends_on": { + "incfreq": 2 + } + }, + { + "label": " every year", + "depends_on": { + "incfreq": 3 } } + ] + }, + "incfreq": { + "check_answer_label": "Income Frequency", + "header": "How often do they receive this income?", + "type": "radio", + "answer_options": { + "1": { + "value": "Weekly" + }, + "2": { + "value": "Monthly" + }, + "3": { + "value": "Yearly" + } } } + } + }, + "net_income_value_check": { + "depends_on": [ + { + "net_income_soft_validation_triggered?": true + } + ], + "title_text": { + "translation": "soft_validations.net_income.title_text" }, - "net_income_value_check": { - "depends_on": [{ "net_income_soft_validation_triggered?": true }], - "title_text": { "translation": "soft_validations.net_income.title_text" }, - "informative_text": { - "translation": "soft_validations.net_income.hint_text", - "arguments": [{ + "informative_text": { + "translation": "soft_validations.net_income.hint_text", + "arguments": [ + { "key": "ecstat1", "label": true, "i18n_template": "ecstat1" @@ -693,7 +763,9 @@ } }, "conditional_for": { - "conditional_question": [0] + "conditional_question": [ + 0 + ] } }, "conditional_question": { @@ -712,7 +784,11 @@ } }, "dependent_page": { - "depends_on": [{ "incfreq": 1 }], + "depends_on": [ + { + "incfreq": 1 + } + ], "questions": { "dependent_question": { "check_answer_label": "Dependent Question", @@ -757,7 +833,12 @@ "min": 0, "step": 1, "width": 4, - "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"], + "fields-to-add": [ + "brent", + "scharge", + "pscharge", + "supcharg" + ], "result-field": "tcharge" }, "scharge": { @@ -768,7 +849,12 @@ "min": 0, "step": 1, "width": 4, - "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"], + "fields-to-add": [ + "brent", + "scharge", + "pscharge", + "supcharg" + ], "result-field": "tcharge" }, "pscharge": { @@ -779,7 +865,12 @@ "min": 0, "step": 1, "width": 4, - "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"], + "fields-to-add": [ + "brent", + "scharge", + "pscharge", + "supcharg" + ], "result-field": "tcharge" }, "supcharg": { @@ -791,7 +882,12 @@ "max": 300, "step": 1, "width": 4, - "fields-to-add": ["brent", "scharge", "pscharge", "supcharg"], + "fields-to-add": [ + "brent", + "scharge", + "pscharge", + "supcharg" + ], "result-field": "tcharge" }, "tcharge": { @@ -836,7 +932,11 @@ "width": 4 } }, - "depends_on": [{ "period": 3 }] + "depends_on": [ + { + "period": 3 + } + ] }, "care_home_charge_bi_weekly": { "questions": { @@ -850,7 +950,11 @@ "width": 4 } }, - "depends_on": [{ "period": 2 }] + "depends_on": [ + { + "period": 2 + } + ] } } } @@ -898,11 +1002,22 @@ } }, "hidden_in_check_answers": { - "depends_on": [{ "layear": 0 }, { "layear": 1 }] + "depends_on": [ + { + "layear": 0 + }, + { + "layear": 1 + } + ] } } }, - "depends_on": [{ "renewal": 0 }] + "depends_on": [ + { + "renewal": 0 + } + ] }, "time_on_la_waiting_list": { "questions": { @@ -950,7 +1065,9 @@ "hint_text": "If the household has moved from settled accommodation immediately prior to being re-housed", "type": "text", "width": 5, - "conditional_for": { "fake_key": "fake_condition" } + "conditional_for": { + "fake_key": "fake_condition" + } }, "ppostcode_full": { "check_answer_label": "Postcode of previous accommodation if the household has moved from settled accommodation", diff --git a/spec/fixtures/forms/2022_2023.json b/spec/fixtures/forms/2022_2023.json index 81c190a46..a704a9229 100644 --- a/spec/fixtures/forms/2022_2023.json +++ b/spec/fixtures/forms/2022_2023.json @@ -1,55 +1,57 @@ { - "form_type": "lettings", - "start_date": "2022-04-01T00:00:00.000+01:00", - "end_date": "2023-07-01T00:00:00.000+01:00", - "sections": { - "household": { - "label": "About the household", - "subsections": { - "household_characteristics": { - "label": "Household characteristics", - "pages": { - "tenant_code_test": { - "questions": { - "tenancycode": { - "check_answer_label": "Tenant code", - "header": "Different question header text for this year - 2023", - "type": "text", - "width": 10 - } + "form_type": "lettings", + "start_date": "2022-04-01T00:00:00.000+01:00", + "end_date": "2023-07-01T00:00:00.000+01:00", + "sections": { + "household": { + "label": "About the household", + "subsections": { + "household_characteristics": { + "label": "Household characteristics", + "pages": { + "tenant_code_test": { + "questions": { + "tenancycode": { + "check_answer_label": "Tenant code", + "header": "Different question header text for this year - 2023", + "type": "text", + "width": 10 } - }, - "outstanding_amount_known": { - "header": "", - "description": "", - "questions": { - "tshortfall_known": { - "check_answer_label": "", - "header": "", - "hint_text": "", - "hidden_in_check_answers": true, - "type": "radio", - "derived": true, - "answer_options": { - "0": { - "value": "Yes" - }, - "1": { - "value": "No" - } - } - } - }, - "depends_on": [false] } }, - "depends_on": [ - { - "setup": "completed" - } - ] - } + "outstanding_amount_known": { + "header": "", + "description": "", + "questions": { + "tshortfall_known": { + "check_answer_label": "", + "header": "", + "hint_text": "", + "hidden_in_check_answers": true, + "type": "radio", + "derived": true, + "answer_options": { + "0": { + "value": "Yes" + }, + "1": { + "value": "No" + } + } + } + }, + "depends_on": [ + false + ] + } + }, + "depends_on": [ + { + "setup": "completed" + } + ] } } } } +} diff --git a/spec/fixtures/forms/test_validator.json b/spec/fixtures/forms/test_validator.json index 512298a5d..e6edc4d16 100644 --- a/spec/fixtures/forms/test_validator.json +++ b/spec/fixtures/forms/test_validator.json @@ -22,7 +22,11 @@ "type": "text" } }, - "depends_on": [{"test": "Yes"}] + "depends_on": [ + { + "test": "Yes" + } + ] }, "person_1_age": { "header": "", diff --git a/spec/helpers/question_attribute_helper_spec.rb b/spec/helpers/question_attribute_helper_spec.rb index 96f2f7ef6..2be903535 100644 --- a/spec/helpers/question_attribute_helper_spec.rb +++ b/spec/helpers/question_attribute_helper_spec.rb @@ -40,7 +40,7 @@ RSpec.describe QuestionAttributeHelper do "conditional_for" => { "next_question": ">1", }, - }, nil) + }, form.get_page("rent")) end let(:expected_attribs) do { @@ -48,7 +48,7 @@ RSpec.describe QuestionAttributeHelper do "data-action": "input->numeric-question#calculateFields click->conditional-question#displayConditional", "data-target": "lettings-log-#{question.result_field.to_s.dasherize}-field", "data-calculated": question.fields_to_add.to_json, - "data-info": question.conditional_for.to_json, + "data-info": { conditional_questions: question.conditional_for, log_type: "lettings" }.to_json, } end diff --git a/spec/models/form/question_spec.rb b/spec/models/form/question_spec.rb index da59ad354..637407bc1 100644 --- a/spec/models/form/question_spec.rb +++ b/spec/models/form/question_spec.rb @@ -340,6 +340,29 @@ RSpec.describe Form::Question, type: :model do expect(question.answer_label(lettings_log)).to eq("£500.00 every year") end end + + context "with inferred_check_answers_value" do + context "when Lettings form" do + let(:section_id) { "household" } + let(:subsection_id) { "household_needs" } + let(:page_id) { "armed_forces" } + let(:question_id) { "armedforces" } + + it "returns the inferred label value" do + lettings_log.armedforces = 3 + expect(question.answer_label(lettings_log)).to eq("Prefers not to say") + end + end + + context "when Sales form" do + let(:sales_log) { FactoryBot.create(:sales_log, :completed, ethnic_group: 17) } + let(:question) { sales_log.form.get_question("ethnic_group", sales_log) } + + it "returns the inferred label value" do + expect(question.answer_label(sales_log)).to eq("Prefers not to say") + end + end + end end describe ".completed?" do 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 new file mode 100644 index 000000000..821874a0f --- /dev/null +++ b/spec/models/form/sales/pages/buyer1_ethnic_background_arab_spec.rb @@ -0,0 +1,33 @@ +require "rails_helper" + +RSpec.describe Form::Sales::Pages::Buyer1EthnicBackgroundArab, 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[ethnic]) + end + + it "has the correct id" do + expect(page.id).to eq("buyer_1_ethnic_background_arab") + 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([{ "ethnic_group" => 4 }]) + end +end 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 new file mode 100644 index 000000000..ad8b47846 --- /dev/null +++ b/spec/models/form/sales/pages/buyer1_ethnic_background_asian_spec.rb @@ -0,0 +1,33 @@ +require "rails_helper" + +RSpec.describe Form::Sales::Pages::Buyer1EthnicBackgroundAsian, 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[ethnic]) + end + + it "has the correct id" do + expect(page.id).to eq("buyer_1_ethnic_background_asian") + 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([{ "ethnic_group" => 2 }]) + end +end 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 new file mode 100644 index 000000000..1f5618a0b --- /dev/null +++ b/spec/models/form/sales/pages/buyer1_ethnic_background_black_spec.rb @@ -0,0 +1,33 @@ +require "rails_helper" + +RSpec.describe Form::Sales::Pages::Buyer1EthnicBackgroundBlack, 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[ethnic]) + end + + it "has the correct id" do + expect(page.id).to eq("buyer_1_ethnic_background_black") + 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([{ "ethnic_group" => 3 }]) + end +end 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 new file mode 100644 index 000000000..648734242 --- /dev/null +++ b/spec/models/form/sales/pages/buyer1_ethnic_background_mixed_spec.rb @@ -0,0 +1,33 @@ +require "rails_helper" + +RSpec.describe Form::Sales::Pages::Buyer1EthnicBackgroundMixed, 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[ethnic]) + end + + it "has the correct id" do + expect(page.id).to eq("buyer_1_ethnic_background_mixed") + 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([{ "ethnic_group" => 1 }]) + end +end 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 new file mode 100644 index 000000000..620918b0e --- /dev/null +++ b/spec/models/form/sales/pages/buyer1_ethnic_background_white_spec.rb @@ -0,0 +1,29 @@ +require "rails_helper" + +RSpec.describe Form::Sales::Pages::Buyer1EthnicBackgroundWhite, 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[ethnic]) + end + + it "has the correct id" do + expect(page.id).to eq("buyer_1_ethnic_background_white") + 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_ethnic_group_spec.rb b/spec/models/form/sales/pages/buyer1_ethnic_group_spec.rb new file mode 100644 index 000000000..406f78676 --- /dev/null +++ b/spec/models/form/sales/pages/buyer1_ethnic_group_spec.rb @@ -0,0 +1,33 @@ +require "rails_helper" + +RSpec.describe Form::Sales::Pages::Buyer1EthnicGroup, 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[ethnic_group]) + end + + it "has the correct id" do + expect(page.id).to eq("buyer_1_ethnic_group") + 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/buyer1_working_situation_spec.rb b/spec/models/form/sales/pages/buyer1_working_situation_spec.rb new file mode 100644 index 000000000..2a48f0b0f --- /dev/null +++ b/spec/models/form/sales/pages/buyer1_working_situation_spec.rb @@ -0,0 +1,25 @@ +require "rails_helper" + +RSpec.describe Form::Sales::Pages::Buyer1WorkingSituation, 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[ecstat1]) + end + + it "has the correct id" do + expect(page.id).to eq("buyer_1_working_situation") + end + + it "has the correct header" do + expect(page.header).to eq("Which of these best describes buyer 1's working situation?") + end +end diff --git a/spec/models/form/sales/pages/buyer2_live_in_property_spec.rb b/spec/models/form/sales/pages/buyer2_live_in_property_spec.rb new file mode 100644 index 000000000..cfabcf04c --- /dev/null +++ b/spec/models/form/sales/pages/buyer2_live_in_property_spec.rb @@ -0,0 +1,29 @@ +require "rails_helper" + +RSpec.describe Form::Sales::Pages::Buyer2LiveInProperty, 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[buy2livein]) + end + + it "has the correct id" do + expect(page.id).to eq("buyer_2_live_in_property") + 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/buyer2_relationship_to_buyer1_spec.rb b/spec/models/form/sales/pages/buyer2_relationship_to_buyer1_spec.rb index 675913419..2e87764d6 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 @@ -12,7 +12,7 @@ RSpec.describe Form::Sales::Pages::Buyer2RelationshipToBuyer1, type: :model do end it "has correct questions" do - expect(page.questions.map(&:id)).to eq(%w[relat2 otherrelat2]) + expect(page.questions.map(&:id)).to eq(%w[relat2]) end it "has the correct id" 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 new file mode 100644 index 000000000..5077ab6f4 --- /dev/null +++ b/spec/models/form/sales/pages/buyer2_working_situation_spec.rb @@ -0,0 +1,29 @@ +require "rails_helper" + +RSpec.describe Form::Sales::Pages::Buyer2WorkingSituation, 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[ecstat2]) + end + + it "has the correct id" do + expect(page.id).to eq("buyer_2_working_situation") + 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/buyer_interview_spec.rb b/spec/models/form/sales/pages/buyer_interview_spec.rb new file mode 100644 index 000000000..1347fb782 --- /dev/null +++ b/spec/models/form/sales/pages/buyer_interview_spec.rb @@ -0,0 +1,29 @@ +require "rails_helper" + +RSpec.describe Form::Sales::Pages::BuyerInterview, 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[noint]) + end + + it "has the correct id" do + expect(page.id).to eq("buyer_interview") + 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/gender_identity2_spec.rb b/spec/models/form/sales/pages/gender_identity2_spec.rb new file mode 100644 index 000000000..0fdd96e27 --- /dev/null +++ b/spec/models/form/sales/pages/gender_identity2_spec.rb @@ -0,0 +1,35 @@ +require "rails_helper" + +RSpec.describe Form::Sales::Pages::GenderIdentity2, 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[sex2]) + end + + it "has the correct id" do + expect(page.id).to eq("buyer_2_gender_identity") + 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([{ + "jointpur" => 1, + }]) + end +end diff --git a/spec/models/form/sales/pages/nationality1_spec.rb b/spec/models/form/sales/pages/nationality1_spec.rb new file mode 100644 index 000000000..5d156e041 --- /dev/null +++ b/spec/models/form/sales/pages/nationality1_spec.rb @@ -0,0 +1,33 @@ +require "rails_helper" + +RSpec.describe Form::Sales::Pages::Nationality1, 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[national othernational]) + end + + it "has the correct id" do + expect(page.id).to eq("buyer_1_nationality") + 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/number_of_others_in_property_spec.rb b/spec/models/form/sales/pages/number_of_others_in_property_spec.rb new file mode 100644 index 000000000..4d7f6862b --- /dev/null +++ b/spec/models/form/sales/pages/number_of_others_in_property_spec.rb @@ -0,0 +1,29 @@ +require "rails_helper" + +RSpec.describe Form::Sales::Pages::NumberOfOthersInProperty, 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[hholdcount]) + end + + it "has the correct id" do + expect(page.id).to eq("number_of_others_in_property") + 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/privacy_notice_spec.rb b/spec/models/form/sales/pages/privacy_notice_spec.rb new file mode 100644 index 000000000..9c957b0b5 --- /dev/null +++ b/spec/models/form/sales/pages/privacy_notice_spec.rb @@ -0,0 +1,33 @@ +require "rails_helper" + +RSpec.describe Form::Sales::Pages::PrivacyNotice, 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[privacynotice]) + end + + it "has the correct id" do + expect(page.id).to eq("privacy_notice") + end + + it "has the correct header" do + expect(page.header).to eq("Department for Levelling Up, Housing and Communities privacy notice") + 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([{ "noint" => 1 }]) + end +end diff --git a/spec/models/form/sales/pages/building_type_spec.rb b/spec/models/form/sales/pages/property_building_type_spec.rb similarity index 82% rename from spec/models/form/sales/pages/building_type_spec.rb rename to spec/models/form/sales/pages/property_building_type_spec.rb index 03824cb4e..fb5420105 100644 --- a/spec/models/form/sales/pages/building_type_spec.rb +++ b/spec/models/form/sales/pages/property_building_type_spec.rb @@ -1,6 +1,6 @@ require "rails_helper" -RSpec.describe Form::Sales::Pages::BuildingType, type: :model do +RSpec.describe Form::Sales::Pages::PropertyBuildingType, type: :model do subject(:page) { described_class.new(page_id, page_definition, subsection) } let(:page_id) { nil } @@ -16,7 +16,7 @@ RSpec.describe Form::Sales::Pages::BuildingType, type: :model do end it "has the correct id" do - expect(page.id).to eq("builtype") + expect(page.id).to eq("property_building_type") end it "has the correct header" do diff --git a/spec/models/form/sales/questions/buyer1_ethnic_background_arab_spec.rb b/spec/models/form/sales/questions/buyer1_ethnic_background_arab_spec.rb new file mode 100644 index 000000000..c13eda0c5 --- /dev/null +++ b/spec/models/form/sales/questions/buyer1_ethnic_background_arab_spec.rb @@ -0,0 +1,44 @@ +require "rails_helper" + +RSpec.describe Form::Sales::Questions::Buyer1EthnicBackgroundArab, 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("ethnic") + end + + it "has the correct header" do + expect(question.header).to eq("Which of the following best describes the buyer 1’s Arab background?") + end + + it "has the correct check_answer_label" do + expect(question.check_answer_label).to eq("Buyer 1’s ethnic background") + 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_text" do + expect(question.hint_text).to eq("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.") + end + + it "has the correct answer_options" do + expect(question.answer_options).to eq({ + "16" => { "value" => "Other ethnic group" }, + "19" => { "value" => "Arab" }, + }) + end +end diff --git a/spec/models/form/sales/questions/buyer1_ethnic_background_asian_spec.rb b/spec/models/form/sales/questions/buyer1_ethnic_background_asian_spec.rb new file mode 100644 index 000000000..3fe9cee96 --- /dev/null +++ b/spec/models/form/sales/questions/buyer1_ethnic_background_asian_spec.rb @@ -0,0 +1,47 @@ +require "rails_helper" + +RSpec.describe Form::Sales::Questions::Buyer1EthnicBackgroundAsian, 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("ethnic") + end + + it "has the correct header" do + expect(question.header).to eq("Which of the following best describes the buyer 1’s Asian or Asian British background?") + end + + it "has the correct check_answer_label" do + expect(question.check_answer_label).to eq("Buyer 1’s ethnic background") + 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_text" do + expect(question.hint_text).to eq("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.") + end + + it "has the correct answer_options" do + expect(question.answer_options).to eq({ + "10" => { "value" => "Bangladeshi" }, + "11" => { "value" => "Any other Asian or Asian British background" }, + "15" => { "value" => "Chinese" }, + "8" => { "value" => "Indian" }, + "9" => { "value" => "Pakistani" }, + }) + end +end diff --git a/spec/models/form/sales/questions/buyer1_ethnic_background_black_spec.rb b/spec/models/form/sales/questions/buyer1_ethnic_background_black_spec.rb new file mode 100644 index 000000000..28949b598 --- /dev/null +++ b/spec/models/form/sales/questions/buyer1_ethnic_background_black_spec.rb @@ -0,0 +1,45 @@ +require "rails_helper" + +RSpec.describe Form::Sales::Questions::Buyer1EthnicBackgroundBlack, 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("ethnic") + end + + it "has the correct header" do + expect(question.header).to eq("Which of the following best describes the buyer 1’s Black, African, Caribbean or Black British background?") + end + + it "has the correct check_answer_label" do + expect(question.check_answer_label).to eq("Buyer 1’s ethnic background") + 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_text" do + expect(question.hint_text).to eq("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.") + end + + it "has the correct answer_options" do + expect(question.answer_options).to eq({ + "12" => { "value" => "Caribbean" }, + "13" => { "value" => "African" }, + "14" => { "value" => "Any other Black, African or Caribbean background" }, + }) + end +end diff --git a/spec/models/form/sales/questions/buyer1_ethnic_background_mixed_spec.rb b/spec/models/form/sales/questions/buyer1_ethnic_background_mixed_spec.rb new file mode 100644 index 000000000..48ad38fa8 --- /dev/null +++ b/spec/models/form/sales/questions/buyer1_ethnic_background_mixed_spec.rb @@ -0,0 +1,46 @@ +require "rails_helper" + +RSpec.describe Form::Sales::Questions::Buyer1EthnicBackgroundMixed, 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("ethnic") + end + + it "has the correct header" do + expect(question.header).to eq("Which of the following best describes the buyer 1’s Mixed or Multiple ethnic groups background?") + end + + it "has the correct check_answer_label" do + expect(question.check_answer_label).to eq("Buyer 1’s ethnic background") + 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_text" do + expect(question.hint_text).to eq("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.") + end + + it "has the correct answer_options" do + expect(question.answer_options).to eq({ + "4" => { "value" => "White and Black Caribbean" }, + "5" => { "value" => "White and Black African" }, + "6" => { "value" => "White and Asian" }, + "7" => { "value" => "Any other Mixed or Multiple ethnic background" }, + }) + end +end diff --git a/spec/models/form/sales/questions/buyer1_ethnic_background_white_spec.rb b/spec/models/form/sales/questions/buyer1_ethnic_background_white_spec.rb new file mode 100644 index 000000000..4b72afb92 --- /dev/null +++ b/spec/models/form/sales/questions/buyer1_ethnic_background_white_spec.rb @@ -0,0 +1,46 @@ +require "rails_helper" + +RSpec.describe Form::Sales::Questions::Buyer1EthnicBackgroundWhite, 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("ethnic") + end + + it "has the correct header" do + expect(question.header).to eq("Which of the following best describes the buyer 1’s White background?") + end + + it "has the correct check_answer_label" do + expect(question.check_answer_label).to eq("Buyer 1’s ethnic background") + 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_text" do + expect(question.hint_text).to eq("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.") + end + + it "has the correct answer_options" do + expect(question.answer_options).to eq({ + "1" => { "value" => "English, Welsh, Northern Irish, Scottish or British" }, + "18" => { "value" => "Gypsy or Irish Traveller" }, + "2" => { "value" => "Irish" }, + "3" => { "value" => "Any other White background" }, + }) + end +end diff --git a/spec/models/form/sales/questions/buyer1_ethnic_group_spec.rb b/spec/models/form/sales/questions/buyer1_ethnic_group_spec.rb new file mode 100644 index 000000000..4823b43c8 --- /dev/null +++ b/spec/models/form/sales/questions/buyer1_ethnic_group_spec.rb @@ -0,0 +1,49 @@ +require "rails_helper" + +RSpec.describe Form::Sales::Questions::Buyer1EthnicGroup, 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("ethnic_group") + end + + it "has the correct header" do + expect(question.header).to eq("What is buyer 1’s ethnic group?") + end + + it "has the correct check_answer_label" do + expect(question.check_answer_label).to eq("Buyer 1’s ethnic group") + 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_text" do + expect(question.hint_text).to eq("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.") + end + + it "has the correct answer_options" do + expect(question.answer_options).to eq({ + "0" => { "value" => "White" }, + "1" => { "value" => "Mixed or Multiple ethnic groups" }, + "17" => { "value" => "Buyer 1 prefers not to say" }, + "2" => { "value" => "Asian or Asian British" }, + "3" => { "value" => "Black, African, Caribbean or Black British" }, + "4" => { "value" => "Arab or other ethnic group" }, + "divider" => { "value" => true }, + }) + end +end diff --git a/spec/models/form/sales/questions/buyer1_working_situation_spec.rb b/spec/models/form/sales/questions/buyer1_working_situation_spec.rb new file mode 100644 index 000000000..832c91538 --- /dev/null +++ b/spec/models/form/sales/questions/buyer1_working_situation_spec.rb @@ -0,0 +1,49 @@ +require "rails_helper" + +RSpec.describe Form::Sales::Questions::Buyer1WorkingSituation, 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("ecstat1") + end + + it "has the correct header" do + expect(question.header).to eq("Which of these best describes buyer 1's working situation?") + end + + it "has the correct check_answer_label" do + expect(question.check_answer_label).to eq("Buyer 1's working situation") + 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({ + "2" => { "value" => "Part-time - Less than 30 hours" }, + "1" => { "value" => "Full-time - 30 hours or more" }, + "3" => { "value" => "In government training into work, such as New Deal" }, + "4" => { "value" => "Jobseeker" }, + "6" => { "value" => "Not seeking work" }, + "8" => { "value" => "Unable to work due to long term sick or disability" }, + "5" => { "value" => "Retired" }, + "0" => { "value" => "Other" }, + "10" => { "value" => "Buyer prefers not to say" }, + "7" => { "value" => "Full-time student" }, + "9" => { "value" => "Child under 16" }, + }) + end +end 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 new file mode 100644 index 000000000..b0d1af779 --- /dev/null +++ b/spec/models/form/sales/questions/buyer2_live_in_property_spec.rb @@ -0,0 +1,44 @@ +require "rails_helper" + +RSpec.describe Form::Sales::Questions::Buyer2LiveInProperty, 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("buy2livein") + end + + it "has the correct header" do + expect(question.header).to eq("Will buyer 2 live in the property?") + end + + it "has the correct check_answer_label" do + expect(question.check_answer_label).to eq("Will buyer 2 live in the property?") + 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" => "Yes" }, + "2" => { "value" => "No" }, + }) + end +end 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 cabd2168a..14bf2cb23 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 @@ -43,20 +43,4 @@ RSpec.describe Form::Sales::Questions::Buyer2RelationshipToBuyer1, type: :model "R" => { "value" => "Buyer prefers not to say" }, }) end - - it "has correct conditional for" do - expect(question.conditional_for).to eq({ - "otherrelat2" => %w[X], - }) - end - - it "has correct hidden in check answers" do - expect(question.hidden_in_check_answers).to eq({ - "depends_on" => [ - { - "relat2" => "X", - }, - ], - }) - end end diff --git a/spec/models/form/sales/questions/buyer2_working_situation_spec.rb b/spec/models/form/sales/questions/buyer2_working_situation_spec.rb new file mode 100644 index 000000000..0573f02ed --- /dev/null +++ b/spec/models/form/sales/questions/buyer2_working_situation_spec.rb @@ -0,0 +1,53 @@ +require "rails_helper" + +RSpec.describe Form::Sales::Questions::Buyer2WorkingSituation, 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("ecstat2") + end + + it "has the correct header" do + expect(question.header).to eq("Which of these best describes buyer 2's working situation?") + end + + it "has the correct check_answer_label" do + expect(question.check_answer_label).to eq("Buyer 2's working situation") + 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({ + "2" => { "value" => "Part-time - Less than 30 hours" }, + "1" => { "value" => "Full-time - 30 hours or more" }, + "3" => { "value" => "In government training into work, such as New Deal" }, + "4" => { "value" => "Jobseeker" }, + "6" => { "value" => "Not seeking work" }, + "8" => { "value" => "Unable to work due to long term sick or disability" }, + "5" => { "value" => "Retired" }, + "0" => { "value" => "Other" }, + "10" => { "value" => "Buyer prefers not to say" }, + "7" => { "value" => "Full-time student" }, + "9" => { "value" => "Child under 16" }, + }) + end +end diff --git a/spec/models/form/sales/questions/buyer_interview_spec.rb b/spec/models/form/sales/questions/buyer_interview_spec.rb new file mode 100644 index 000000000..69c45ee4e --- /dev/null +++ b/spec/models/form/sales/questions/buyer_interview_spec.rb @@ -0,0 +1,44 @@ +require "rails_helper" + +RSpec.describe Form::Sales::Questions::BuyerInterview, 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("noint") + end + + it "has the correct header" do + expect(question.header).to eq("Was the buyer interviewed for any of the answers you will provide on this log?") + end + + it "has the correct check_answer_label" do + expect(question.check_answer_label).to eq("Buyer interviewed in person?") + end + + it "has the correct type" do + expect(question.type).to eq("radio") + end + + it "is not marked as derived" do + expect(question.derived?).to be false + end + + it "has the correct hint" do + expect(question.hint_text).to eq("You should still try to answer all questions even if the buyer wasn't interviewed in person") + end + + it "has the correct answer_options" do + expect(question.answer_options).to eq({ + "1" => { "value" => "No" }, + "2" => { "value" => "Yes" }, + }) + end +end diff --git a/spec/models/form/sales/questions/gender_identity2_spec.rb b/spec/models/form/sales/questions/gender_identity2_spec.rb new file mode 100644 index 000000000..e4da94a24 --- /dev/null +++ b/spec/models/form/sales/questions/gender_identity2_spec.rb @@ -0,0 +1,42 @@ +require "rails_helper" + +RSpec.describe Form::Sales::Questions::GenderIdentity2, 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("sex2") + end + + it "has the correct header" do + expect(question.header).to eq("Which of these best describes buyer 2’s gender identity?") + end + + it "has the correct check_answer_label" do + expect(question.check_answer_label).to eq("Buyer 2’s gender identity") + 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({ + "F" => { "value" => "Female" }, + "M" => { "value" => "Male" }, + "X" => { "value" => "Non-binary" }, + "R" => { "value" => "Buyer prefers not to say" }, + }) + end +end diff --git a/spec/models/form/sales/questions/nationality1_spec.rb b/spec/models/form/sales/questions/nationality1_spec.rb new file mode 100644 index 000000000..819d41ae4 --- /dev/null +++ b/spec/models/form/sales/questions/nationality1_spec.rb @@ -0,0 +1,63 @@ +require "rails_helper" + +RSpec.describe Form::Sales::Questions::Nationality1, 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("national") + end + + it "has the correct header" do + expect(question.header).to eq("What is buyer 1’s nationality?") + end + + it "has the correct check_answer_label" do + expect(question.check_answer_label).to eq("Buyer 1’s nationality") + 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("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.") + end + + it "has the correct answer_options" do + expect(question.answer_options).to eq({ + "18" => { "value" => "United Kingdom" }, + "17" => { "value" => "Republic of Ireland" }, + "19" => { "value" => "European Economic Area (EEA), excluding ROI" }, + "12" => { "value" => "Other" }, + "13" => { "value" => "Buyer prefers not to say" }, + }) + end + + it "has correct conditional for" do + expect(question.conditional_for).to eq({ + "othernational" => [12], + }) + end + + it "has correct hidden in check answers" do + expect(question.hidden_in_check_answers).to eq({ + "depends_on" => [ + { + "national" => 12, + }, + ], + }) + end +end diff --git a/spec/models/form/sales/questions/number_of_others_in_property_spec.rb b/spec/models/form/sales/questions/number_of_others_in_property_spec.rb new file mode 100644 index 000000000..0742a98b6 --- /dev/null +++ b/spec/models/form/sales/questions/number_of_others_in_property_spec.rb @@ -0,0 +1,37 @@ +require "rails_helper" + +RSpec.describe Form::Sales::Questions::NumberOfOthersInProperty, 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("hholdcount") + end + + it "has the correct header" do + expect(question.header).to eq("Besides the buyers, how many other people live in the property?") + end + + it "has the correct check_answer_label" do + expect(question.check_answer_label).to eq("Number of other people living in the property") + 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 eq("You can provide details for a maximum of 4 other people.") + end +end diff --git a/spec/models/form/sales/questions/other_buyer2_relationship_to_buyer1_spec.rb b/spec/models/form/sales/questions/other_nationality1_spec.rb similarity index 69% rename from spec/models/form/sales/questions/other_buyer2_relationship_to_buyer1_spec.rb rename to spec/models/form/sales/questions/other_nationality1_spec.rb index 1b4b3f91e..b01928efc 100644 --- a/spec/models/form/sales/questions/other_buyer2_relationship_to_buyer1_spec.rb +++ b/spec/models/form/sales/questions/other_nationality1_spec.rb @@ -1,6 +1,6 @@ require "rails_helper" -RSpec.describe Form::Sales::Questions::OtherBuyer2RelationshipToBuyer1, type: :model do +RSpec.describe Form::Sales::Questions::OtherNationality1, type: :model do subject(:question) { described_class.new(question_id, question_definition, page) } let(:question_id) { nil } @@ -12,15 +12,15 @@ RSpec.describe Form::Sales::Questions::OtherBuyer2RelationshipToBuyer1, type: :m end it "has the correct id" do - expect(question.id).to eq("otherrelat2") + expect(question.id).to eq("othernational") end it "has the correct header" do - expect(question.header).to eq("Buyer 2's relationship to buyer 1") + expect(question.header).to eq("Nationality") end it "has the correct check_answer_label" do - expect(question.check_answer_label).to eq("Buyer 2's relationship to buyer 1") + expect(question.check_answer_label).to eq("Buyer 1’s nationality") end it "has the correct type" do diff --git a/spec/models/form/sales/questions/privacy_notice_spec.rb b/spec/models/form/sales/questions/privacy_notice_spec.rb new file mode 100644 index 000000000..f90daef1b --- /dev/null +++ b/spec/models/form/sales/questions/privacy_notice_spec.rb @@ -0,0 +1,43 @@ +require "rails_helper" + +RSpec.describe Form::Sales::Questions::PrivacyNotice, 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("privacynotice") + end + + it "has the correct header" do + expect(question.header).to eq("Declaration") + end + + it "has the correct check_answer_label" do + expect(question.check_answer_label).to eq("Buyer has seen the privacy notice?") + end + + it "has the correct type" do + expect(question.type).to eq("checkbox") + 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({ + "privacynotice" => { "value" => "The buyer has seen the DLUHC privacy notice" }, + }) + end +end diff --git a/spec/models/form/sales/questions/building_type_spec.rb b/spec/models/form/sales/questions/property_building_type_spec.rb similarity index 93% rename from spec/models/form/sales/questions/building_type_spec.rb rename to spec/models/form/sales/questions/property_building_type_spec.rb index bc81ccda0..1129bf792 100644 --- a/spec/models/form/sales/questions/building_type_spec.rb +++ b/spec/models/form/sales/questions/property_building_type_spec.rb @@ -1,6 +1,6 @@ require "rails_helper" -RSpec.describe Form::Sales::Questions::BuildingType, type: :model do +RSpec.describe Form::Sales::Questions::PropertyBuildingType, type: :model do subject(:question) { described_class.new(question_id, question_definition, page) } let(:question_id) { nil } diff --git a/spec/models/form/sales/sections/household_spec.rb b/spec/models/form/sales/sections/household_spec.rb index 53d81f2fb..e415e8f0c 100644 --- a/spec/models/form/sales/sections/household_spec.rb +++ b/spec/models/form/sales/sections/household_spec.rb @@ -12,7 +12,12 @@ RSpec.describe Form::Sales::Sections::Household, type: :model do end it "has correct subsections" do - expect(household.subsections.map(&:id)).to eq(%w[household_characteristics]) + expect(household.subsections.map(&:id)).to eq( + %w[ + household_characteristics + household_needs + ], + ) end it "has the correct id" do diff --git a/spec/models/form/sales/subsections/household_characteristics_spec.rb b/spec/models/form/sales/subsections/household_characteristics_spec.rb index 71a8e898d..2efeb640c 100644 --- a/spec/models/form/sales/subsections/household_characteristics_spec.rb +++ b/spec/models/form/sales/subsections/household_characteristics_spec.rb @@ -13,7 +13,27 @@ RSpec.describe Form::Sales::Subsections::HouseholdCharacteristics, type: :model it "has correct pages" do expect(household_characteristics.pages.map(&:id)).to eq( - %w[buyer_1_age buyer_1_gender_identity buyer_1_live_in_property buyer_2_relationship_to_buyer_1 buyer_2_age], + %w[ + buyer_interview + privacy_notice + buyer_1_age + buyer_1_gender_identity + buyer_1_ethnic_group + buyer_1_ethnic_background_black + buyer_1_ethnic_background_asian + buyer_1_ethnic_background_arab + buyer_1_ethnic_background_mixed + buyer_1_ethnic_background_white + buyer_1_nationality + buyer_1_working_situation + buyer_1_live_in_property + buyer_2_relationship_to_buyer_1 + buyer_2_age + buyer_2_gender_identity + buyer_2_working_situation + buyer_2_live_in_property + number_of_others_in_property + ], ) end diff --git a/spec/models/form/sales/subsections/property_information_spec.rb b/spec/models/form/sales/subsections/property_information_spec.rb index 76985d7c0..ab33936c5 100644 --- a/spec/models/form/sales/subsections/property_information_spec.rb +++ b/spec/models/form/sales/subsections/property_information_spec.rb @@ -13,7 +13,11 @@ RSpec.describe Form::Sales::Subsections::PropertyInformation, type: :model do it "has correct pages" do expect(property_information.pages.map(&:id)).to eq( - %w[property_number_of_bedrooms property_unit_type], + %w[ + property_number_of_bedrooms + property_building_type + property_unit_type + ], ) end diff --git a/spec/models/form/sales/subsections/setup_spec.rb b/spec/models/form/sales/subsections/setup_spec.rb index ec7ff4ada..36fbf247a 100644 --- a/spec/models/form/sales/subsections/setup_spec.rb +++ b/spec/models/form/sales/subsections/setup_spec.rb @@ -13,7 +13,20 @@ RSpec.describe Form::Sales::Subsections::Setup, type: :model do it "has correct pages" do expect(setup.pages.map(&:id)).to eq( - %w[organisation created_by completion_date purchaser_code ownership_scheme shared_ownership_type discounted_ownership_type outright_ownership_type buyer_company buyer_live joint_purchase number_joint_buyers builtype], + %w[ + organisation + created_by + completion_date + purchaser_code + ownership_scheme + shared_ownership_type + discounted_ownership_type + outright_ownership_type + buyer_company + buyer_live + joint_purchase + number_joint_buyers + ], ) end diff --git a/spec/models/form_handler_spec.rb b/spec/models/form_handler_spec.rb index e323fdaea..a53ca575f 100644 --- a/spec/models/form_handler_spec.rb +++ b/spec/models/form_handler_spec.rb @@ -61,14 +61,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(20) + expect(form.pages.count).to eq(35) 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(20) + expect(form.pages.count).to eq(35) expect(form.name).to eq("2021_2022_sales") end end diff --git a/spec/models/form_spec.rb b/spec/models/form_spec.rb index 571e7930e..d7a8e12ce 100644 --- a/spec/models/form_spec.rb +++ b/spec/models/form_spec.rb @@ -206,7 +206,7 @@ RSpec.describe Form, type: :model do end end - describe "when creating a sales log" do + describe "when creating a sales log", :aggregate_failures do it "creates a valid sales form" do sections = [] form = described_class.new(nil, 2022, sections, "sales") diff --git a/spec/models/lettings_log_spec.rb b/spec/models/lettings_log_spec.rb index 6251e050f..dc4a646fe 100644 --- a/spec/models/lettings_log_spec.rb +++ b/spec/models/lettings_log_spec.rb @@ -1,4 +1,5 @@ require "rails_helper" +require "shared/shared_examples_for_derived_fields" RSpec.describe LettingsLog do let(:owning_organisation) { FactoryBot.create(:organisation) } @@ -10,6 +11,8 @@ RSpec.describe LettingsLog do allow(FormHandler.instance).to receive(:current_lettings_form).and_return(fake_2021_2022_form) end + include_examples "shared examples for derived fields", :lettings_log + it "inherits from log" do expect(described_class).to be < Log expect(described_class).to be < ApplicationRecord diff --git a/spec/models/sales_log_spec.rb b/spec/models/sales_log_spec.rb index 31a41d411..3ee033971 100644 --- a/spec/models/sales_log_spec.rb +++ b/spec/models/sales_log_spec.rb @@ -1,9 +1,12 @@ require "rails_helper" +require "shared/shared_examples_for_derived_fields" RSpec.describe SalesLog, type: :model do let(:owning_organisation) { FactoryBot.create(:organisation) } let(:created_by_user) { FactoryBot.create(:user) } + include_examples "shared examples for derived fields", :sales_log + it "inherits from log" do expect(described_class).to be < Log expect(described_class).to be < ApplicationRecord diff --git a/spec/shared/shared_examples_for_derived_fields.rb b/spec/shared/shared_examples_for_derived_fields.rb new file mode 100644 index 000000000..6382ef4f4 --- /dev/null +++ b/spec/shared/shared_examples_for_derived_fields.rb @@ -0,0 +1,17 @@ +require "rails_helper" + +RSpec.shared_examples "shared examples for derived fields" do |log_type| + describe "sets ethnic based on the value of ethnic_refused" do + it "is set to 17 when ethnic_group is 17" do + log = FactoryBot.build(log_type, ethnic_group: 17, ethnic: nil) + + expect { log.set_derived_fields! }.to change(log, :ethnic).from(nil).to(17) + end + + it "is is not modified otherwise" do + log = FactoryBot.build(log_type, ethnic_group: nil, ethnic: nil) + + expect { log.set_derived_fields! }.not_to change(log, :ethnic) + end + end +end