From 6f7d2f8ca5bef8f604a0a43152b52279e1a21f4c Mon Sep 17 00:00:00 2001 From: Kat Date: Wed, 1 Mar 2023 10:07:41 +0000 Subject: [PATCH] Set default relat2, update default household count --- app/services/imports/sales_logs_import_service.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/services/imports/sales_logs_import_service.rb b/app/services/imports/sales_logs_import_service.rb index 1748c2447..678017e0d 100644 --- a/app/services/imports/sales_logs_import_service.rb +++ b/app/services/imports/sales_logs_import_service.rb @@ -435,6 +435,7 @@ module Imports attributes["sex2"] ||= "R" attributes["ecstat2"] ||= 10 attributes["income2nk"] ||= attributes["income2"].present? ? 0 : 1 + attributes["relat2"] ||= "R" end # other household members characteristics @@ -451,11 +452,12 @@ module Imports applicable_questions.filter { |q| q.unanswered?(sales_log) }.map(&:id) end - # just for testing, logic might need to change + # just for testing, logic will need to change to match the number of people details known def default_household_count(attributes) return 0 if attributes["hhmemb"].zero? || attributes["hhmemb"].blank? - attributes["jointpur"] == 1 ? attributes["hhmemb"] - 2 : attributes["hhmemb"] - 1 + household_count = attributes["jointpur"] == 1 ? attributes["hhmemb"] - 2 : attributes["hhmemb"] - 1 + household_count.positive? ? household_count : 0 end end end