Browse Source

Infer Mscharge known as no for outright sale

pull/1331/head
Kat 3 years ago
parent
commit
e62ff98e7c
  1. 8
      app/services/imports/sales_logs_import_service.rb
  2. 8
      spec/services/imports/sales_logs_import_service_spec.rb

8
app/services/imports/sales_logs_import_service.rb

@ -104,7 +104,7 @@ module Imports
attributes["hhregresstill"] = still_serving(xml_doc)
attributes["proplen"] = safe_string_as_integer(xml_doc, "Q16aProplen2")
attributes["mscharge"] = monthly_charges(xml_doc, attributes)
attributes["mscharge_known"] = 1 if attributes["mscharge"].present?
attributes["mscharge_known"] = mscharge_known(attributes)
attributes["prevten"] = unsafe_string_as_integer(xml_doc, "Q6PrevTenure")
attributes["mortgageused"] = unsafe_string_as_integer(xml_doc, "MORTGAGEUSED")
attributes["wchair"] = unsafe_string_as_integer(xml_doc, "Q15Wheelchair")
@ -394,5 +394,11 @@ module Imports
safe_string_as_decimal(xml_doc, "Q37MonthlyCharges")
end
end
def mscharge_known(attributes)
return 1 if attributes["mscharge"].present?
0 if attributes["ownershipsch"] == 3
end
end
end

8
spec/services/imports/sales_logs_import_service_spec.rb

@ -188,6 +188,14 @@ RSpec.describe Imports::SalesLogsImportService do
applicable_questions = sales_log.form.subsections.map { |s| s.applicable_questions(sales_log) }.flatten
expect(applicable_questions.filter { |q| q.unanswered?(sales_log) }.map(&:id)).to be_empty
end
it "infers mscharge_known as no, if it is not given" do
allow(logger).to receive(:warn).and_return(nil)
sales_log_service.send(:create_log, sales_log_xml)
sales_log = SalesLog.find_by(old_id: sales_log_id)
expect(sales_log.mscharge_known).to eq(0)
end
end
end
end

Loading…
Cancel
Save