diff --git a/app/models/derived_variables/sales_log_variables.rb b/app/models/derived_variables/sales_log_variables.rb index b00a16b63..245361a80 100644 --- a/app/models/derived_variables/sales_log_variables.rb +++ b/app/models/derived_variables/sales_log_variables.rb @@ -33,7 +33,7 @@ private (2..6).count do |i| age = public_send("age#{i}") relat = public_send("relat#{i}") - age.present? && ((age < 20 && %w[C].include?(relat))) + age.present? && (age < 20 && %w[C].include?(relat) || age < 18) end end @@ -42,7 +42,7 @@ private total + (2..6).count do |i| age = public_send("age#{i}") relat = public_send("relat#{i}") - age.present? && ((age.between?(20, 59) || age.between?(18, 19) && relat != "C")) + age.present? && (age.between?(20, 59) || age.between?(18, 19) && relat != "C") end end diff --git a/spec/models/sales_log_spec.rb b/spec/models/sales_log_spec.rb index a0efcf313..2b7e43331 100644 --- a/spec/models/sales_log_spec.rb +++ b/spec/models/sales_log_spec.rb @@ -240,7 +240,7 @@ RSpec.describe SalesLog, type: :model do relat2: "C", relat3: "C", relat4: "X", - relat5: "C", + relat5: "X", age1: 22, age2: 40, age3: 19,