|
|
@ -42,6 +42,8 @@ module Imports |
|
|
|
def create_log(xml_doc) |
|
|
|
def create_log(xml_doc) |
|
|
|
attributes = {} |
|
|
|
attributes = {} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
previous_status = field_value(xml_doc, "meta", "status") |
|
|
|
|
|
|
|
|
|
|
|
# Required fields for status complete or logic to work |
|
|
|
# Required fields for status complete or logic to work |
|
|
|
# Note: order matters when we derive from previous values (attributes parameter) |
|
|
|
# Note: order matters when we derive from previous values (attributes parameter) |
|
|
|
attributes["startdate"] = compose_date(xml_doc, "DAY", "MONTH", "YEAR") |
|
|
|
attributes["startdate"] = compose_date(xml_doc, "DAY", "MONTH", "YEAR") |
|
|
@ -56,7 +58,7 @@ module Imports |
|
|
|
attributes["irproduct"] = unsafe_string_as_integer(xml_doc, "IRProduct") |
|
|
|
attributes["irproduct"] = unsafe_string_as_integer(xml_doc, "IRProduct") |
|
|
|
attributes["irproduct_other"] = string_or_nil(xml_doc, "IRProductOther") |
|
|
|
attributes["irproduct_other"] = string_or_nil(xml_doc, "IRProductOther") |
|
|
|
attributes["rent_type"] = rent_type(xml_doc, attributes["lar"], attributes["irproduct"]) |
|
|
|
attributes["rent_type"] = rent_type(xml_doc, attributes["lar"], attributes["irproduct"]) |
|
|
|
attributes["hhmemb"] = household_members(xml_doc, attributes) |
|
|
|
attributes["hhmemb"] = household_members(xml_doc, attributes, previous_status) |
|
|
|
(1..8).each do |index| |
|
|
|
(1..8).each do |index| |
|
|
|
attributes["age#{index}"] = safe_string_as_integer(xml_doc, "P#{index}Age") |
|
|
|
attributes["age#{index}"] = safe_string_as_integer(xml_doc, "P#{index}Age") |
|
|
|
attributes["age#{index}_known"] = age_known(xml_doc, index, attributes["hhmemb"]) |
|
|
|
attributes["age#{index}_known"] = age_known(xml_doc, index, attributes["hhmemb"]) |
|
|
@ -170,8 +172,6 @@ module Imports |
|
|
|
attributes["postcode_full"] = nil |
|
|
|
attributes["postcode_full"] = nil |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
previous_status = field_value(xml_doc, "meta", "status") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
owner_id = field_value(xml_doc, "meta", "owner-user-id").strip |
|
|
|
owner_id = field_value(xml_doc, "meta", "owner-user-id").strip |
|
|
|
if owner_id.present? |
|
|
|
if owner_id.present? |
|
|
|
attributes["created_by"] = User.find_by(old_user_id: owner_id) |
|
|
|
attributes["created_by"] = User.find_by(old_user_id: owner_id) |
|
|
@ -490,10 +490,11 @@ module Imports |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def household_members(xml_doc, _attributes) |
|
|
|
def household_members(xml_doc, _attributes, previous_status) |
|
|
|
hhmemb = safe_string_as_integer(xml_doc, "HHMEMB") |
|
|
|
hhmemb = safe_string_as_integer(xml_doc, "HHMEMB") |
|
|
|
return safe_string_as_integer(xml_doc, "TOTADULT") + safe_string_as_integer(xml_doc, "TCHILD") if hhmemb.nil? |
|
|
|
if previous_status.include?("submitted") |
|
|
|
|
|
|
|
return safe_string_as_integer(xml_doc, "TOTADULT").to_i + safe_string_as_integer(xml_doc, "TCHILD").to_i if hhmemb.nil? |
|
|
|
|
|
|
|
end |
|
|
|
hhmemb |
|
|
|
hhmemb |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|