From 246b34a7271e5bb47faaf7b7f7495309814d5693 Mon Sep 17 00:00:00 2001 From: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com> Date: Fri, 3 Mar 2023 08:02:28 +0000 Subject: [PATCH] CLDC-1938 Fix household members import (#1372) * Fix household members * Add test --- app/services/imports/sales_logs_import_service.rb | 8 +++++--- spec/services/imports/sales_logs_import_service_spec.rb | 7 +++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/services/imports/sales_logs_import_service.rb b/app/services/imports/sales_logs_import_service.rb index d31b7b1d8..95af610b6 100644 --- a/app/services/imports/sales_logs_import_service.rb +++ b/app/services/imports/sales_logs_import_service.rb @@ -432,9 +432,11 @@ module Imports end def household_members(_xml_doc, attributes) - return attributes["hholdcount"] + 2 if attributes["jointpur"] == 1 - - attributes["hholdcount"] + 1 if attributes["jointpur"] == 2 + if attributes["jointpur"] == 2 + attributes["hholdcount"] + 1 + else + attributes["hholdcount"] + 2 + end end def set_default_values(attributes) diff --git a/spec/services/imports/sales_logs_import_service_spec.rb b/spec/services/imports/sales_logs_import_service_spec.rb index 1d2fecdb4..7fd5de7de 100644 --- a/spec/services/imports/sales_logs_import_service_spec.rb +++ b/spec/services/imports/sales_logs_import_service_spec.rb @@ -604,6 +604,13 @@ RSpec.describe Imports::SalesLogsImportService do sales_log = SalesLog.find_by(old_id: sales_log_id) expect(sales_log&.hholdcount).to eq(0) end + + it "doesn't hang if jointpur is not given" do + sales_log_xml.at_xpath("//xmlns:joint").content = "" + sales_log_xml.at_xpath("//xmlns:HHMEMB").content = "0" + + sales_log_service.send(:create_log, sales_log_xml) + end end context "when inferring income used" do