Browse Source

fixup! CLDC-4145: Derive is partner for under 16s

CLDC-4145-dont-ask-partner-for-children
Samuel Young 1 week ago
parent
commit
3f1f8c4d94
  1. 4
      app/models/derived_variables/lettings_log_variables.rb
  2. 4
      app/models/lettings_log.rb

4
app/models/derived_variables/lettings_log_variables.rb

@ -278,7 +278,9 @@ private
(2..8).each do |idx|
if public_send("age#{idx}_changed?")
self["ecstat#{idx}"] = nil if self["ecstat#{idx}"] == 9
self["relat#{idx}"] = nil if self["relat#{idx}"] == "X" && form.start_year_2026_or_later?
# since the user can also input 'No' for relat there are cases when we don't want to clear this (changing age from 50 to 55 for example)
# note if age is changed from 10 to 15 we will clear it but the inference will set it back immediately after, see child_under_16_constraints!
self["relat#{idx}"] = nil if self["relat#{idx}"] == "X" && age_changed_from_below_16(idx) && form.start_year_2026_or_later?
end
end
end

4
app/models/lettings_log.rb

@ -407,6 +407,10 @@ class LettingsLog < Log
public_send("age#{person_index}") && public_send("age#{person_index}") < 16
end
def age_changed_from_below_16(person_index)
public_send("age#{person_index}") && public_send("age#{person_index}_was") < 16
end
def is_shared_housing?
# 4: Shared flat or maisonette
# 9: Shared house

Loading…
Cancel
Save