Browse Source

Clear derived working situation of child under 16 when age is changed to 16 or above

pull/2959/head
Manny Dinssa 2 months ago
parent
commit
055b493b44
  1. 9
      app/models/derived_variables/lettings_log_variables.rb
  2. 10
      app/models/derived_variables/sales_log_variables.rb

9
app/models/derived_variables/lettings_log_variables.rb

@ -72,6 +72,7 @@ module DerivedVariables::LettingsLogVariables
self.beds = 1 self.beds = 1
end end
clear_child_ecstat_for_age_changes!
child_under_16_constraints! child_under_16_constraints!
self.hhtype = household_type self.hhtype = household_type
@ -243,6 +244,14 @@ private
end end
end end
def clear_child_ecstat_for_age_changes!
(2..8).each do |idx|
if public_send("age#{idx}_changed?") && self["ecstat#{idx}"] == 9
self["ecstat#{idx}"] = nil
end
end
end
def household_type def household_type
return unless totelder && totadult && totchild return unless totelder && totadult && totchild

10
app/models/derived_variables/sales_log_variables.rb

@ -46,6 +46,7 @@ module DerivedVariables::SalesLogVariables
if saledate && form.start_year_2024_or_later? if saledate && form.start_year_2024_or_later?
self.soctenant = soctenant_from_prevten_values self.soctenant = soctenant_from_prevten_values
clear_child_ecstat_for_age_changes!
child_under_16_constraints! child_under_16_constraints!
end end
@ -181,6 +182,15 @@ private
end end
end end
def clear_child_ecstat_for_age_changes!
start_index = joint_purchase? ? 3 : 2
(start_index..6).each do |idx|
if public_send("age#{idx}_changed?") && self["ecstat#{idx}"] == 9
self["ecstat#{idx}"] = nil
end
end
end
def household_type def household_type
return unless total_elder && total_adult && totchild return unless total_elder && total_adult && totchild

Loading…
Cancel
Save