Browse Source

CLDC-3234: Handle nil hhmemb gracefully in soft validations

pull/2301/head
Rachael Booth 2 years ago
parent
commit
0874f81982
  1. 16
      app/models/validations/soft_validations.rb

16
app/models/validations/soft_validations.rb

@ -73,13 +73,17 @@ module Validations::SoftValidations
end
def all_tenants_age_and_gender_information_completed?
(1..hhmemb).all? do |n|
person_count = hhmemb || 8
(1..person_count).all? do |n|
public_send("sex#{n}").present? && public_send("age#{n}").present? && details_known_or_lead_tenant?(n) && public_send("age#{n}_known").present? && public_send("age#{n}_known").zero?
end
end
def all_tenants_gender_information_completed?
(1..hhmemb).all? do |n|
person_count = hhmemb || 8
(1..person_count).all? do |n|
public_send("sex#{n}").present? && details_known_or_lead_tenant?(n)
end
end
@ -197,13 +201,17 @@ private
end
def females_in_age_range(min, max)
(1..hhmemb).any? do |n|
person_count = hhmemb || 8
(1..person_count).any? do |n|
public_send("sex#{n}") == "F" && public_send("age#{n}").present? && public_send("age#{n}").between?(min, max)
end
end
def females_in_the_household?
(1..hhmemb).any? do |n|
person_count = hhmemb || 8
(1..person_count).any? do |n|
public_send("sex#{n}") == "F" || public_send("sex#{n}").nil?
end
end

Loading…
Cancel
Save