diff --git a/app/services/imports/case_logs_import_service.rb b/app/services/imports/case_logs_import_service.rb index 8eb272d62..7a9799078 100644 --- a/app/services/imports/case_logs_import_service.rb +++ b/app/services/imports/case_logs_import_service.rb @@ -152,7 +152,7 @@ module Imports attributes["la_known"] = 1 # Defaulting to Yes (Required) 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"] = 1 + attributes["declaration"] = declaration(xml_doc) unless attributes["brent"].nil? && attributes["scharge"].nil? && @@ -205,8 +205,8 @@ module Imports # Safe: A string that represents only a decimal (or empty/nil) def safe_string_as_decimal(xml_doc, attribute) - str = field_value(xml_doc, "xmlns", attribute) - if str.blank? + str = string_or_nil(xml_doc, attribute) + if str.nil? nil else BigDecimal(str, exception: false) @@ -215,8 +215,8 @@ module Imports # Unsafe: A string that has more than just the integer value def unsafe_string_as_integer(xml_doc, attribute) - str = field_value(xml_doc, "xmlns", attribute) - if str.blank? + str = string_or_nil(xml_doc, attribute) + if str.nil? nil else str.to_i @@ -300,7 +300,7 @@ module Imports end def sex(xml_doc, index) - sex = field_value(xml_doc, "xmlns", "P#{index}Sex") + sex = string_or_nil(xml_doc, "P#{index}Sex") case sex when "Male" "M" @@ -314,7 +314,7 @@ module Imports end def relat(xml_doc, index) - relat = field_value(xml_doc, "xmlns", "P#{index}Rel") + relat = string_or_nil(xml_doc, "P#{index}Rel") case relat when "Child" "C" @@ -330,7 +330,7 @@ module Imports def age_known(xml_doc, index, hhmemb) return nil if index > hhmemb - age_refused = field_value(xml_doc, "xmlns", "P#{index}AR") + age_refused = string_or_nil(xml_doc, "P#{index}AR") if age_refused == "AGE_REFUSED" 1 # No else @@ -352,7 +352,7 @@ module Imports end def previous_postcode_known(xml_doc, previous_postcode) - previous_postcode_known = field_value(xml_doc, "xmlns", "Q12bnot") + previous_postcode_known = string_or_nil(xml_doc, "Q12bnot") if previous_postcode_known == "Temporary or Unknown" 0 elsif previous_postcode.nil? @@ -363,9 +363,9 @@ module Imports end def compose_postcode(xml_doc, outcode, incode) - outcode_value = field_value(xml_doc, "xmlns", outcode) - incode_value = field_value(xml_doc, "xmlns", incode) - if outcode_value.blank? || incode_value.blank? + outcode_value = string_or_nil(xml_doc, outcode) + incode_value = string_or_nil(xml_doc, incode) + if outcode_value.nil? || incode_value.nil? nil else "#{outcode_value}#{incode_value}" @@ -421,7 +421,7 @@ module Imports # Letters should be lowercase to match case def housing_needs(xml_doc, letter) - housing_need = field_value(xml_doc, "xmlns", "Q10-#{letter}") + housing_need = string_or_nil(xml_doc, "Q10-#{letter}") if housing_need == "Yes" 1 else @@ -430,7 +430,7 @@ module Imports end def net_income_known(xml_doc, earnings) - incref = field_value(xml_doc, "xmlns", "Q8Refused") + incref = string_or_nil(xml_doc, "Q8Refused") if incref == "Refused" # Tenant prefers not to say 2 @@ -459,5 +459,12 @@ module Imports 0 end end + + def declaration(xml_doc) + declaration = string_or_nil(xml_doc, "Qdp") + if declaration == "Yes" + 1 + end + end end end