|
|
@ -6,6 +6,8 @@ module Imports |
|
|
|
import_from(folder, :update_tenant_code) |
|
|
|
import_from(folder, :update_tenant_code) |
|
|
|
when "major_repairs" |
|
|
|
when "major_repairs" |
|
|
|
import_from(folder, :update_major_repairs) |
|
|
|
import_from(folder, :update_major_repairs) |
|
|
|
|
|
|
|
when "lettings_allocation" |
|
|
|
|
|
|
|
import_from(folder, :update_lettings_allocation) |
|
|
|
else |
|
|
|
else |
|
|
|
raise "Updating #{field} is not supported by the field import service" |
|
|
|
raise "Updating #{field} is not supported by the field import service" |
|
|
|
end |
|
|
|
end |
|
|
@ -13,6 +15,32 @@ module Imports |
|
|
|
|
|
|
|
|
|
|
|
private |
|
|
|
private |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def update_lettings_allocation(xml_doc) |
|
|
|
|
|
|
|
old_id = field_value(xml_doc, "meta", "document-id") |
|
|
|
|
|
|
|
previous_status = field_value(xml_doc, "meta", "status") |
|
|
|
|
|
|
|
record = CaseLog.find_by(old_id:) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if record.present? && previous_status.include?("submitted") |
|
|
|
|
|
|
|
cbl = unsafe_string_as_integer(xml_doc, "Q15CBL") |
|
|
|
|
|
|
|
chr = unsafe_string_as_integer(xml_doc, "Q15CHR") |
|
|
|
|
|
|
|
cap = unsafe_string_as_integer(xml_doc, "Q15CAP") |
|
|
|
|
|
|
|
if cbl == 2 && record.cbl == 1 |
|
|
|
|
|
|
|
record.update!(cbl: 0) |
|
|
|
|
|
|
|
@logger.info("Case Log #{record.id}'s cbl value has been updated'") |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
if chr == 2 && record.chr == 1 |
|
|
|
|
|
|
|
record.update!(chr: 0) |
|
|
|
|
|
|
|
@logger.info("Case Log #{record.id}'s chr value has been updated'") |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
if cap == 2 && record.cap == 1 |
|
|
|
|
|
|
|
record.update!(cap: 0) |
|
|
|
|
|
|
|
@logger.info("Case Log #{record.id}'s cap value has been updated'") |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
@logger.warn("Could not find record matching legacy ID #{old_id}") |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def update_major_repairs(xml_doc) |
|
|
|
def update_major_repairs(xml_doc) |
|
|
|
old_id = field_value(xml_doc, "meta", "document-id") |
|
|
|
old_id = field_value(xml_doc, "meta", "document-id") |
|
|
|
record = CaseLog.find_by(old_id:) |
|
|
|
record = CaseLog.find_by(old_id:) |
|
|
@ -67,5 +95,15 @@ module Imports |
|
|
|
str = field_value(xml_doc, "xmlns", attribute) |
|
|
|
str = field_value(xml_doc, "xmlns", attribute) |
|
|
|
str.presence |
|
|
|
str.presence |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Unsafe: A string that has more than just the integer value |
|
|
|
|
|
|
|
def unsafe_string_as_integer(xml_doc, attribute) |
|
|
|
|
|
|
|
str = string_or_nil(xml_doc, attribute) |
|
|
|
|
|
|
|
if str.nil? |
|
|
|
|
|
|
|
nil |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
str.to_i |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|