Browse Source

Add other missing value_checks for sales

pull/1906/head
Kat 3 years ago
parent
commit
c5ce9d6d38
  1. 5
      app/services/imports/sales_logs_import_service.rb
  2. 34
      spec/services/imports/sales_logs_import_service_spec.rb

5
app/services/imports/sales_logs_import_service.rb

@ -153,6 +153,9 @@ module Imports
attributes["buyer_livein_value_check"] = 0
attributes["percentage_discount_value_check"] = 0
attributes["hodate_check"] = 0
attributes["saledate_check"] = 0
attributes["combined_income_value_check"] = 0
attributes["stairowned_value_check"] = 0
# 2023/34 attributes
attributes["address_line1"] = string_or_nil(xml_doc, "AddressLine1")
@ -331,6 +334,8 @@ module Imports
discounted_sale_value_check
buyer_livein_value_check
percentage_discount_value_check
combined_income_value_check
stairowned_value_check
uprn_known
uprn_confirmed]
end

34
spec/services/imports/sales_logs_import_service_spec.rb

@ -611,6 +611,40 @@ RSpec.describe Imports::SalesLogsImportService do
end
end
context "and the combined income soft validation is triggered (combined_income_value_check)" do
let(:sales_log_id) { "shared_ownership_sales_log" }
before do
sales_log_xml.at_xpath("//xmlns:joint").content = "1 Yes"
sales_log_xml.at_xpath("//xmlns:Q2Person1Income").content = "45000"
sales_log_xml.at_xpath("//xmlns:P2IncKnown").content = "1 Yes"
sales_log_xml.at_xpath("//xmlns:Q2Person2Income").content = "45000"
end
it "completes the log" do
sales_log_service.send(:create_log, sales_log_xml)
sales_log = SalesLog.find_by(old_id: sales_log_id)
expect(sales_log.status).to eq("completed")
end
end
context "and the stairowned soft validation is triggered (stairowned_value_check)" do
let(:sales_log_id) { "shared_ownership_sales_log" }
before do
sales_log_xml.at_xpath("//xmlns:DerSaleType").content = "24"
sales_log_xml.at_xpath("//xmlns:PercentOwns").content = "77"
sales_log_xml.at_xpath("//xmlns:Q17aStaircase").content = "1"
sales_log_xml.at_xpath("//xmlns:PercentBought").content = "10"
end
it "completes the log" do
sales_log_service.send(:create_log, sales_log_xml)
sales_log = SalesLog.find_by(old_id: sales_log_id)
expect(sales_log.status).to eq("completed")
end
end
context "and it has an invalid record with invalid child age" do
let(:sales_log_id) { "discounted_ownership_sales_log" }

Loading…
Cancel
Save