Browse Source

Create 2025 versions of these questions

pull/2774/head
Manny Dinssa 9 months ago
parent
commit
823d4f5a6c
  1. 23
      app/models/form/sales/pages/buyer2_relationship_to_buyer1_yes_no.rb
  2. 15
      app/models/form/sales/pages/person_relationship_to_buyer_1_yes_no.rb
  3. 23
      app/models/form/sales/questions/buyer2_relationship_to_buyer1_yes_no.rb
  4. 32
      app/models/form/sales/questions/person_relationship_to_buyer_1_yes_no.rb

23
app/models/form/sales/pages/buyer2_relationship_to_buyer1_yes_no.rb

@ -0,0 +1,23 @@
class Form::Sales::Pages::Buyer2RelationshipToBuyer1YesNo < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "buyer_2_relationship_to_buyer_1"
@copy_key = "sales.household_characteristics.relat2.buyer"
@depends_on = [
{
"joint_purchase?" => true,
"buyer_has_seen_privacy_notice?" => true,
},
{
"joint_purchase?" => true,
"buyer_not_interviewed?" => true,
},
]
end
def questions
@questions ||= [
Form::Sales::Questions::Buyer2RelationshipToBuyer1YesNo.new(nil, nil, self),
]
end
end

15
app/models/form/sales/pages/person_relationship_to_buyer_1_yes_no.rb

@ -0,0 +1,15 @@
class Form::Sales::Pages::PersonRelationshipToBuyer1YesNo < ::Form::Sales::Pages::Person
def initialize(id, hsh, subsection, person_index:)
super
@copy_key = "sales.household_characteristics.relat2.person" if person_index == 2
@depends_on = [
{ "details_known_#{person_index}" => 1 },
]
end
def questions
@questions ||= [
Form::Sales::Questions::PersonRelationshipToBuyer1YesNo.new("relat#{@person_index}", nil, self, person_index: @person_index),
]
end
end

23
app/models/form/sales/questions/buyer2_relationship_to_buyer1_yes_no.rb

@ -0,0 +1,23 @@
class Form::Sales::Questions::Buyer2RelationshipToBuyer1YesNo < ::Form::Question
def initialize(id, hsh, page)
super
@id = "relat2"
@copy_key = "sales.household_characteristics.relat2.buyer"
@type = "radio"
@answer_options = {
"P" => { "value" => "Yes" },
"X" => { "value" => "No" },
"R" => { "value" => "Buyer prefers not to say" },
}
@inferred_check_answers_value = [{
"condition" => {
"relat2" => "R",
},
"value" => "Prefers not to say",
}]
@check_answers_card_number = 2
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max]
end
QUESTION_NUMBER_FROM_YEAR = { 2025 => 29 }.freeze
end

32
app/models/form/sales/questions/person_relationship_to_buyer_1_yes_no.rb

@ -0,0 +1,32 @@
class Form::Sales::Questions::PersonRelationshipToBuyer1YesNo < ::Form::Question
def initialize(id, hsh, page, person_index:)
super(id, hsh, page)
@type = "radio"
@copy_key = "sales.household_characteristics.relat2.person" if person_index == 2
@answer_options = {
"P" => { "value" => "Yes" },
"X" => { "value" => "No" },
"R" => { "value" => "Buyer prefers not to say" },
}
@inferred_check_answers_value = [{
"condition" => {
id => "R",
},
"value" => "Prefers not to say",
}]
@check_answers_card_number = person_index
@person_index = person_index
@question_number = question_number
end
def question_number
base_question_number = case form.start_date.year
when 2023
28
else
30
end
base_question_number + (4 * @person_index)
end
end
Loading…
Cancel
Save