diff --git a/app/services/imports/sales_logs_import_service.rb b/app/services/imports/sales_logs_import_service.rb index c04bbb291..c2844e019 100644 --- a/app/services/imports/sales_logs_import_service.rb +++ b/app/services/imports/sales_logs_import_service.rb @@ -521,6 +521,7 @@ module Imports attributes["extrabor"] ||= 3 if attributes["mortgageused"] == 1 attributes["socprevten"] ||= 10 if attributes["ownershipsch"] == 1 attributes["fromprop"] ||= 0 if attributes["ownershipsch"] == 1 + attributes["mortgagelender"] ||= 0 if attributes["mortgageused"] == 1 # buyer 1 characteristics attributes["age1_known"] ||= 1 diff --git a/spec/services/imports/sales_logs_import_service_spec.rb b/spec/services/imports/sales_logs_import_service_spec.rb index 4458b59b9..e41ffabaf 100644 --- a/spec/services/imports/sales_logs_import_service_spec.rb +++ b/spec/services/imports/sales_logs_import_service_spec.rb @@ -167,6 +167,23 @@ RSpec.describe Imports::SalesLogsImportService do end end + context "when the mortgage lender is not set" do + let(:sales_log_id) { "discounted_ownership_sales_log" } + + before do + sales_log_xml.at_xpath("//xmlns:Q34a").content = "" + allow(logger).to receive(:warn).and_return(nil) + end + + it "correctly sets mortgage lender and mortgage lender other" do + sales_log_service.send(:create_log, sales_log_xml) + + sales_log = SalesLog.find_by(old_id: sales_log_id) + expect(sales_log&.mortgagelender).to be(0) + expect(sales_log&.mortgagelenderother).to be_nil + end + end + context "with shared ownership type" do let(:sales_log_id) { "shared_ownership_sales_log" }