From 64f245d066f7659191c52266a27f0169de6d3b0f Mon Sep 17 00:00:00 2001 From: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com> Date: Tue, 17 Jan 2023 12:15:12 +0000 Subject: [PATCH] Consider everyone below 18 a child (#1195) --- app/models/derived_variables/sales_log_variables.rb | 4 ++-- spec/models/sales_log_spec.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) 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,