Browse Source

Set jointmore to don't know if not given for incomplete logs too (#1449)

pull/1446/head
kosiakkatrina 2 years ago committed by GitHub
parent
commit
926fdccad0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      app/services/imports/sales_logs_import_service.rb
  2. 18
      spec/services/imports/sales_logs_import_service_spec.rb

3
app/services/imports/sales_logs_import_service.rb

@ -38,7 +38,7 @@ module Imports
attributes["ownershipsch"] = ownership_from_type(attributes) if attributes["ownershipsch"].blank? # sometimes Ownership is missing, but type is set
attributes["othtype"] = string_or_nil(xml_doc, "Q38OtherSale")
attributes["jointpur"] = unsafe_string_as_integer(xml_doc, "joint")
attributes["jointmore"] = unsafe_string_as_integer(xml_doc, "JointMore") if attributes["jointpur"] == 1
attributes["jointmore"] = unsafe_string_as_integer(xml_doc, "JointMore") || 3 if attributes["jointpur"] == 1
attributes["beds"] = safe_string_as_integer(xml_doc, "Q11Bedrooms")
attributes["companybuy"] = unsafe_string_as_integer(xml_doc, "company") if attributes["ownershipsch"] == 3
attributes["hholdcount"] = other_household_members(xml_doc, attributes)
@ -509,7 +509,6 @@ module Imports
attributes["hb"] ||= 4
attributes["prevown"] ||= 3
attributes["savingsnk"] ||= attributes["savings"].present? ? 0 : 1
attributes["jointmore"] ||= 3 if attributes["jointpur"] == 1
attributes["inc1mort"] ||= 3
if [attributes["pregyrha"], attributes["pregla"], attributes["pregghb"], attributes["pregother"]].all?(&:blank?)
attributes["pregblank"] = 1

18
spec/services/imports/sales_logs_import_service_spec.rb

@ -1278,6 +1278,24 @@ RSpec.describe Imports::SalesLogsImportService do
expect(sales_log&.socprevten).to be(10)
end
end
context "when it's a joint tenancy and jointmore is not answered" do
let(:sales_log_id) { "outright_sale_sales_log" }
before do
allow(logger).to receive(:warn).and_return(nil)
end
it "sets jointmore to don't know" do
sales_log_xml.at_xpath("//meta:status").content = "invalid"
sales_log_xml.at_xpath("//xmlns:joint").content = "1 Yes"
sales_log_xml.at_xpath("//xmlns:JointMore").content = ""
sales_log_service.send(:create_log, sales_log_xml)
sales_log = SalesLog.find_by(old_id: sales_log_id)
expect(sales_log&.jointmore).to eq(3)
end
end
end
end
end

Loading…
Cancel
Save