Browse Source

CLDC-4269: update counts in vars and validations

pull/3332/head
Nat Dean-Lewis 2 weeks ago
parent
commit
b9460764cf
  1. 2
      app/models/derived_variables/lettings_log_variables.rb
  2. 2
      app/models/lettings_log.rb
  3. 4
      app/models/validations/financial_validations.rb
  4. 8
      app/models/validations/soft_validations.rb

2
app/models/derived_variables/lettings_log_variables.rb

@ -339,7 +339,7 @@ private
def infer_only_partner!(partner_number)
return unless hhmemb
(2..hhmemb).each do |i|
(2..[hhmemb, 8].min).each do |i|
next if i == partner_number
if ["P", nil].include?(public_send("relat#{i}"))

2
app/models/lettings_log.rb

@ -284,7 +284,7 @@ class LettingsLog < Log
range = ALLOWED_INCOME_RANGES[ecstat1].clone
if hhmemb > 1
(2..hhmemb).each do |person_index|
(2..[hhmemb, 8].min).each do |person_index|
ecstat = self["ecstat#{person_index}"]
if ecstat.nil?

4
app/models/validations/financial_validations.rb

@ -41,7 +41,7 @@ module Validations::FinancialValidations
:over_hard_max,
message: I18n.t("validations.lettings.financial.hhmemb.earnings_over_hard_max", earnings: format_as_currency(record.earnings), frequency:),
)
(1..record.hhmemb).each do |n|
(1..[record.hhmemb, 8].min).each do |n|
record.errors.add(
"ecstat#{n}",
:over_hard_max,
@ -70,7 +70,7 @@ module Validations::FinancialValidations
:under_hard_min,
message: I18n.t("validations.lettings.financial.hhmemb.earnings_under_hard_min", earnings: format_as_currency(record.earnings), frequency:),
)
(1..record.hhmemb).each do |n|
(1..[record.hhmemb, 8].min).each do |n|
record.errors.add(
"ecstat#{n}",
:under_hard_min,

8
app/models/validations/soft_validations.rb

@ -258,17 +258,17 @@ private
end
def any_non_male_in_expected_pregnancy_age_range(min, max)
person_count = hhmemb || 8
max_person_with_details = [hhmemb || 8, 8].min
(1..person_count).any? do |n|
(1..max_person_with_details).any? do |n|
person_in_expected_pregnancy_age_range(n, min, max) && person_is_non_male(n)
end
end
def non_males_in_the_household?
person_count = hhmemb || 8
max_person_with_details = [hhmemb || 8, 8].min
(1..person_count).any? do |n|
(1..max_person_with_details).any? do |n|
person_is_non_male(n)
end
end

Loading…
Cancel
Save