From 6ff617c572309b26fe3ca2f964b237dfc3c863b0 Mon Sep 17 00:00:00 2001 From: Kat Date: Tue, 3 May 2022 12:04:02 +0100 Subject: [PATCH] Set hhmemb to totadult and tchild sum if hhmemb is not given Co-authored-by: Ted Co-authored-by: Dushan --- app/services/imports/case_logs_import_service.rb | 8 +++++++- .../case_logs/0ead17cb-1668-442d-898c-0d52879ff592.xml | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/services/imports/case_logs_import_service.rb b/app/services/imports/case_logs_import_service.rb index be1605d86..b73409d38 100644 --- a/app/services/imports/case_logs_import_service.rb +++ b/app/services/imports/case_logs_import_service.rb @@ -56,7 +56,7 @@ module Imports attributes["irproduct"] = unsafe_string_as_integer(xml_doc, "IRProduct") attributes["irproduct_other"] = string_or_nil(xml_doc, "IRProductOther") attributes["rent_type"] = rent_type(xml_doc, attributes["lar"], attributes["irproduct"]) - attributes["hhmemb"] = safe_string_as_integer(xml_doc, "HHMEMB") + attributes["hhmemb"] = household_members(xml_doc, attributes) (1..8).each do |index| attributes["age#{index}"] = safe_string_as_integer(xml_doc, "P#{index}Age") attributes["age#{index}_known"] = age_known(xml_doc, index, attributes["hhmemb"]) @@ -489,5 +489,11 @@ module Imports 1 end end + + def household_members(xml_doc, attributes) + hhmemb = safe_string_as_integer(xml_doc, "HHMEMB") + return safe_string_as_integer(xml_doc, "TOTADULT") + safe_string_as_integer(xml_doc, "TCHILD") if hhmemb.nil? + hhmemb + end end end diff --git a/spec/fixtures/softwire_imports/case_logs/0ead17cb-1668-442d-898c-0d52879ff592.xml b/spec/fixtures/softwire_imports/case_logs/0ead17cb-1668-442d-898c-0d52879ff592.xml index 9bf6b5a87..bdd95321b 100644 --- a/spec/fixtures/softwire_imports/case_logs/0ead17cb-1668-442d-898c-0d52879ff592.xml +++ b/spec/fixtures/softwire_imports/case_logs/0ead17cb-1668-442d-898c-0d52879ff592.xml @@ -393,7 +393,7 @@ 1 1 0 - 2 + 1 0 0