Browse Source

CLDC-4145: Derive is partner for under 16s

in contrast, clear is partner if the age goes >=16 so the user must answer the question again
CLDC-4145-dont-ask-partner-for-children
Samuel Young 1 week ago
parent
commit
3965ee2ccc
  1. 10
      app/models/derived_variables/lettings_log_variables.rb
  2. 4
      app/models/form/lettings/questions/person_partner.rb
  3. 4
      app/models/lettings_log.rb

10
app/models/derived_variables/lettings_log_variables.rb

@ -75,7 +75,7 @@ module DerivedVariables::LettingsLogVariables
self.beds = nil self.beds = nil
end end
clear_child_ecstat_for_age_changes! clear_child_constraints_for_age_changes!
child_under_16_constraints! child_under_16_constraints!
self.hhtype = household_type self.hhtype = household_type
@ -269,14 +269,16 @@ private
(2..8).each do |idx| (2..8).each do |idx|
if age_under_16?(idx) if age_under_16?(idx)
self["ecstat#{idx}"] = 9 self["ecstat#{idx}"] = 9
self["relat#{idx}"] = "X" if form.start_year_2026_or_later?
end end
end end
end end
def clear_child_ecstat_for_age_changes! def clear_child_constraints_for_age_changes!
(2..8).each do |idx| (2..8).each do |idx|
if public_send("age#{idx}_changed?") && self["ecstat#{idx}"] == 9 if public_send("age#{idx}_changed?")
self["ecstat#{idx}"] = nil self["ecstat#{idx}"] = nil if self["ecstat#{idx}"] == 9
self["relat#{idx}"] = nil if self["relat#{idx}"] == "X" && form.start_year_2026_or_later?
end end
end end
end end

4
app/models/form/lettings/questions/person_partner.rb

@ -27,4 +27,8 @@ class Form::Lettings::Questions::PersonPartner < ::Form::Question
base_question_number + (4 * @person_index) base_question_number + (4 * @person_index)
end end
def derived?(log)
form.start_year_2026_or_later? && log.is_partner_inferred?(@person_index)
end
end end

4
app/models/lettings_log.rb

@ -403,6 +403,10 @@ class LettingsLog < Log
unittype_gn_changed? && unittype_gn_was == 2 unittype_gn_changed? && unittype_gn_was == 2
end end
def is_partner_inferred?(person_index)
public_send("age#{person_index}") && public_send("age#{person_index}") < 16
end
def is_shared_housing? def is_shared_housing?
# 4: Shared flat or maisonette # 4: Shared flat or maisonette
# 9: Shared house # 9: Shared house

Loading…
Cancel
Save