4 changed files with 93 additions and 0 deletions
@ -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 |
@ -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 |
@ -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 |
@ -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…
Reference in new issue