Browse Source

feat: wip add new page, dynamic CYA card behaviour to come

CLDC-1528-person-1-relationship-to-buyer-1
natdeanlewissoftwire 2 years ago
parent
commit
640eb362f6
  1. 8
      app/models/form/sales/pages/person1_relationship_to_buyer1.rb
  2. 21
      app/models/form/sales/pages/person1_relationship_to_buyer1_joint_purchase.rb
  3. 2
      app/models/form/sales/questions/person1_gender_identity.rb
  4. 4
      app/models/form/sales/questions/person1_relationship_to_buyer1.rb
  5. 20
      app/models/form/sales/questions/person1_relationship_to_buyer1_joint_purchase.rb
  6. 1
      app/models/form/sales/subsections/household_characteristics.rb
  7. 5
      db/migrate/20221213130736_add_person1_relationship_to_buyer1_to_sales_log.rb
  8. 3
      db/schema.rb

8
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

21
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

2
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 = {

4
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 = {

20
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

1
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),

5
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

3
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"

Loading…
Cancel
Save