diff --git a/app/models/form/sales/pages/person1_relationship_to_buyer1.rb b/app/models/form/sales/pages/person1_relationship_to_buyer1.rb index 57182563a..b86b19aef 100644 --- a/app/models/form/sales/pages/person1_relationship_to_buyer1.rb +++ b/app/models/form/sales/pages/person1_relationship_to_buyer1.rb @@ -6,10 +6,10 @@ class Form::Sales::Pages::Person1RelationshipToBuyer1 < ::Form::Page @description = "" @subsection = subsection @depends_on = [ - { "hholdcount" => 1 }, - { "hholdcount" => 2 }, - { "hholdcount" => 3 }, - { "hholdcount" => 4 }, + { "hholdcount" => 1, "jointpur" => 2 }, + { "hholdcount" => 2, "jointpur" => 2 }, + { "hholdcount" => 3, "jointpur" => 2 }, + { "hholdcount" => 4, "jointpur" => 2 }, ] end diff --git a/app/models/form/sales/pages/person1_relationship_to_buyer1_joint_purchase.rb b/app/models/form/sales/pages/person1_relationship_to_buyer1_joint_purchase.rb new file mode 100644 index 000000000..3c1373e21 --- /dev/null +++ b/app/models/form/sales/pages/person1_relationship_to_buyer1_joint_purchase.rb @@ -0,0 +1,21 @@ +class Form::Sales::Pages::Person1RelationshipToBuyer1JointPurchase < ::Form::Page + def initialize(id, hsh, subsection) + super + @id = "person_1_relationship_to_buyer_1_joint_purchase" + @header = "" + @description = "" + @subsection = subsection + @depends_on = [ + { "hholdcount" => 1, "jointpur" => 1 }, + { "hholdcount" => 2, "jointpur" => 1 }, + { "hholdcount" => 3, "jointpur" => 1 }, + { "hholdcount" => 4, "jointpur" => 1 }, + ] + end + + def questions + @questions ||= [ + Form::Sales::Questions::Person1RelationshipToBuyer1JointPurchase.new(nil, nil, self), + ] + end +end diff --git a/app/models/form/sales/questions/person1_gender_identity.rb b/app/models/form/sales/questions/person1_gender_identity.rb index 8cf8f29af..b776ebe37 100644 --- a/app/models/form/sales/questions/person1_gender_identity.rb +++ b/app/models/form/sales/questions/person1_gender_identity.rb @@ -7,7 +7,7 @@ class Form::Sales::Questions::Person1GenderIdentity < ::Form::Question @type = "radio" @page = page @answer_options = ANSWER_OPTIONS - @check_answers_card_number = 2 + @check_answers_card_number = 3 end ANSWER_OPTIONS = { diff --git a/app/models/form/sales/questions/person1_relationship_to_buyer1.rb b/app/models/form/sales/questions/person1_relationship_to_buyer1.rb index 089d14ad6..b90d5d864 100644 --- a/app/models/form/sales/questions/person1_relationship_to_buyer1.rb +++ b/app/models/form/sales/questions/person1_relationship_to_buyer1.rb @@ -1,14 +1,14 @@ class Form::Sales::Questions::Person1RelationshipToBuyer1 < ::Form::Question def initialize(id, hsh, page) super - @id = "relat3" + @id = "relat2" @check_answer_label = "Person 1's relationship to buyer 1" @header = "What is person 1's relationship to buyer 1?" @type = "radio" @hint_text = "" @page = page @answer_options = ANSWER_OPTIONS - @check_answers_card_number = 2 + @check_answers_card_number = 3 end ANSWER_OPTIONS = { diff --git a/app/models/form/sales/questions/person1_relationship_to_buyer1_joint_purchase.rb b/app/models/form/sales/questions/person1_relationship_to_buyer1_joint_purchase.rb new file mode 100644 index 000000000..b2c5d92d1 --- /dev/null +++ b/app/models/form/sales/questions/person1_relationship_to_buyer1_joint_purchase.rb @@ -0,0 +1,20 @@ +class Form::Sales::Questions::Person1RelationshipToBuyer1JointPurchase < ::Form::Question + def initialize(id, hsh, page) + super + @id = "relat3" + @check_answer_label = "Person 1's relationship to buyer 1" + @header = "What is person 1's relationship to buyer 1?" + @type = "radio" + @hint_text = "" + @page = page + @answer_options = ANSWER_OPTIONS + @check_answers_card_number = 3 + end + + ANSWER_OPTIONS = { + "P" => { "value" => "Partner" }, + "C" => { "value" => "Child", "hint" => "Must be eligible for child benefit, aged under 16 or under 20 if still in full-time education." }, + "X" => { "value" => "Other" }, + "R" => { "value" => "Buyer prefers not to say" }, + }.freeze +end diff --git a/app/models/form/sales/subsections/household_characteristics.rb b/app/models/form/sales/subsections/household_characteristics.rb index 4e3728494..39f9b25e0 100644 --- a/app/models/form/sales/subsections/household_characteristics.rb +++ b/app/models/form/sales/subsections/household_characteristics.rb @@ -30,6 +30,7 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection Form::Sales::Pages::NumberOfOthersInProperty.new(nil, nil, self), Form::Sales::Pages::Person1Known.new(nil, nil, self), Form::Sales::Pages::Person1RelationshipToBuyer1.new(nil, nil, self), + Form::Sales::Pages::Person1RelationshipToBuyer1JointPurchase.new(nil, nil, self), Form::Sales::Pages::Person1Age.new(nil, nil, self), Form::Sales::Pages::Person1GenderIdentity.new(nil, nil, self), Form::Sales::Pages::Person1GenderIdentityJointPurchase.new(nil, nil, self), diff --git a/db/migrate/20221213130736_add_person1_relationship_to_buyer1_to_sales_log.rb b/db/migrate/20221213130736_add_person1_relationship_to_buyer1_to_sales_log.rb new file mode 100644 index 000000000..c0a6a130d --- /dev/null +++ b/db/migrate/20221213130736_add_person1_relationship_to_buyer1_to_sales_log.rb @@ -0,0 +1,5 @@ +class AddPerson1RelationshipToBuyer1ToSalesLog < ActiveRecord::Migration[7.0] + change_table :sales_logs, bulk: true do |t| + t.column :relat3, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index f16ab6d9d..3efbbb706 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_12_12_161657) do +ActiveRecord::Schema[7.0].define(version: 2022_12_13_130736) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -404,6 +404,7 @@ ActiveRecord::Schema[7.0].define(version: 2022_12_12_161657) do t.integer "savings" t.string "sex3" t.integer "details_known_1" + t.string "relat3" 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"