Browse Source

Fix errors during import process

pull/507/head
Stéphane Meny 3 years ago
parent
commit
cbf02f4de7
No known key found for this signature in database
GPG Key ID: 9D0AFEA988527923
  1. 22
      app/services/imports/case_logs_import_service.rb

22
app/services/imports/case_logs_import_service.rb

@ -139,7 +139,7 @@ module Imports
attributes["la"] = string_or_nil(xml_doc, "Q28ONS")
attributes["postcode_full"] = compose_postcode(xml_doc, "POSTCODE", "POSTCOD2")
attributes["postcode_known"] = attributes["postcode_full"].nil? ? 0 : 1
attributes["postcode_known"] = postcode_known(attributes)
# Not specific to our form but required for consistency (present in import)
attributes["old_form_id"] = safe_string_as_integer(xml_doc, "FORM")
@ -148,7 +148,7 @@ module Imports
attributes["old_id"] = field_value(xml_doc, "meta", "document-id")
# Required for our form invalidated questions (not present in import)
attributes["previous_la_known"] = 1 # Defaulting to Yes (Required)
attributes["previous_la_known"] = attributes["prevloc"].nil? ? nil : 1 # 0 (No) is not selectable in OLD Core
attributes["is_la_inferred"] = false # Always keep the given LA
attributes["first_time_property_let_as_social_housing"] = first_time_let(attributes["rsnvac"])
attributes["declaration"] = declaration(xml_doc)
@ -327,7 +327,7 @@ module Imports
end
def age_known(xml_doc, index, hhmemb)
return nil if index > hhmemb
return nil if hhmemb.present? && index > hhmemb
age_refused = string_or_nil(xml_doc, "P#{index}AR")
if age_refused == "AGE_REFUSED"
@ -338,9 +338,9 @@ module Imports
end
def details_known(index, attributes)
if index > attributes["hhmemb"]
nil
elsif attributes["age#{index}_known"] == 1 &&
return nil if attributes["hhmemb"].present? && index > attributes["hhmemb"]
if attributes["age#{index}_known"] == 1 &&
attributes["sex#{index}"] == "R" &&
attributes["relat#{index}"] == "R" &&
attributes["ecstat#{index}"] == 10
@ -465,5 +465,15 @@ module Imports
1
end
end
def postcode_known(attributes)
if attributes["postcode_full"].nil? && attributes["la"].nil?
nil
elsif attributes["postcode_full"].nil?
0 # Assumes we selected No in the form since the LA is present
else
1
end
end
end
end

Loading…
Cancel
Save