From 653b844f36ec440e11522018c1e7f32f6d058e54 Mon Sep 17 00:00:00 2001 From: baarkerlounger <5101747+baarkerlounger@users.noreply.github.com> Date: Fri, 23 Sep 2022 15:05:53 +0100 Subject: [PATCH] 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 --- app/services/imports/lettings_logs_import_service.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/services/imports/lettings_logs_import_service.rb b/app/services/imports/lettings_logs_import_service.rb index 911da4ac3..e8c59518b 100644 --- a/app/services/imports/lettings_logs_import_service.rb +++ b/app/services/imports/lettings_logs_import_service.rb @@ -85,6 +85,12 @@ module Imports (2..8).each do |index| attributes["relat#{index}"] = relat(xml_doc, index) 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 attributes["ethnic"] = unsafe_string_as_integer(xml_doc, "P1Eth") 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_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["chr"] = allocation_system(unsafe_string_as_integer(xml_doc, "Q15CHR")) attributes["cap"] = allocation_system(unsafe_string_as_integer(xml_doc, "Q15CAP"))