Browse Source

Handle import validation failures (#895)

* Set age and relat to nil when inconsistent

* Set homeless and reasonable preference due to homelessness to nil if inconsistent

* Age not answered case

* Refused is also valid

* Check relationship has been answered
pull/896/head
baarkerlounger 2 years ago committed by GitHub
parent
commit
653b844f36
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      app/services/imports/lettings_logs_import_service.rb

12
app/services/imports/lettings_logs_import_service.rb

@ -85,6 +85,12 @@ module Imports
(2..8).each do |index| (2..8).each do |index|
attributes["relat#{index}"] = relat(xml_doc, index) attributes["relat#{index}"] = relat(xml_doc, index)
attributes["details_known_#{index}"] = details_known(index, attributes) attributes["details_known_#{index}"] = details_known(index, attributes)
# Trips validation
if attributes["age#{index}"].present? && attributes["age#{index}"] < 16 && attributes["relat#{index}"].present? && attributes["relat#{index}"] != "C" && attributes["relat#{index}"] != "R"
attributes["age#{index}"] = nil
attributes["relat#{index}"] = nil
end
end end
attributes["ethnic"] = unsafe_string_as_integer(xml_doc, "P1Eth") attributes["ethnic"] = unsafe_string_as_integer(xml_doc, "P1Eth")
attributes["ethnic_group"] = ethnic_group(attributes["ethnic"]) attributes["ethnic_group"] = ethnic_group(attributes["ethnic"])
@ -137,6 +143,12 @@ module Imports
attributes["rp_hardship"] = unsafe_string_as_integer(xml_doc, "Q14b4").present? ? 1 : nil attributes["rp_hardship"] = unsafe_string_as_integer(xml_doc, "Q14b4").present? ? 1 : nil
attributes["rp_dontknow"] = unsafe_string_as_integer(xml_doc, "Q14b5").present? ? 1 : nil attributes["rp_dontknow"] = unsafe_string_as_integer(xml_doc, "Q14b5").present? ? 1 : nil
# Trips validation
if attributes["homeless"] == 1 && attributes["rp_homeless"] == 1
attributes["homeless"] = nil
attributes["rp_homeless"] = nil
end
attributes["cbl"] = allocation_system(unsafe_string_as_integer(xml_doc, "Q15CBL")) attributes["cbl"] = allocation_system(unsafe_string_as_integer(xml_doc, "Q15CBL"))
attributes["chr"] = allocation_system(unsafe_string_as_integer(xml_doc, "Q15CHR")) attributes["chr"] = allocation_system(unsafe_string_as_integer(xml_doc, "Q15CHR"))
attributes["cap"] = allocation_system(unsafe_string_as_integer(xml_doc, "Q15CAP")) attributes["cap"] = allocation_system(unsafe_string_as_integer(xml_doc, "Q15CAP"))

Loading…
Cancel
Save