Browse Source

feat: use kebab case org fields

pull/1913/head
natdeanlewissoftwire 3 years ago
parent
commit
5d41f30824
  1. 4
      app/services/imports/lettings_logs_import_service.rb
  2. 6
      app/services/imports/logs_import_service.rb
  3. 2
      app/services/imports/sales_logs_field_import_service.rb
  4. 2
      app/services/imports/sales_logs_import_service.rb

4
app/services/imports/lettings_logs_import_service.rb

@ -61,8 +61,8 @@ module Imports
# Required fields for status complete or logic to work
# Note: order matters when we derive from previous values (attributes parameter)
attributes["startdate"] = compose_date(xml_doc, "DAY", "MONTH", "YEAR")
attributes["owning_organisation_id"] = find_organisation_id(xml_doc, "OWNINGORGID")
attributes["managing_organisation_id"] = find_organisation_id(xml_doc, "MANINGORGID")
attributes["owning_organisation_id"] = find_organisation_id(xml_doc, "owner-institution-id")
attributes["managing_organisation_id"] = find_organisation_id(xml_doc, "managing-institution-id")
attributes["creation_method"] = creation_method(xml_doc)
attributes["joint"] = unsafe_string_as_integer(xml_doc, "joint")
attributes["startertenancy"] = unsafe_string_as_integer(xml_doc, "_2a")

6
app/services/imports/logs_import_service.rb

@ -31,9 +31,9 @@ module Imports
end
def find_organisation_id(xml_doc, id_field)
old_visible_id = string_or_nil(xml_doc, id_field)
organisation = Organisation.find_by(old_visible_id:)
raise "Organisation not found with legacy ID #{old_visible_id}" if organisation.nil?
old_org_id = meta_field_value(xml_doc, id_field)&.strip.presence
organisation = Organisation.find_by(old_org_id:)
raise "Organisation not found with old org ID #{old_org_id}" if organisation.nil?
organisation.id
end

2
app/services/imports/sales_logs_field_import_service.rb

@ -45,7 +45,7 @@ module Imports
if record.owning_organisation_id.present?
@logger.info("sales log #{record.id} has a value for owning_organisation_id, skipping update")
else
owning_organisation_id = find_organisation_id(xml_doc, "OWNINGORGID")
owning_organisation_id = find_organisation_id(xml_doc, "owner-institution-id")
record.update!(owning_organisation_id:)
@logger.info("sales log #{record.id}'s owning_organisation_id value has been set to #{owning_organisation_id}")
end

2
app/services/imports/sales_logs_import_service.rb

@ -27,7 +27,7 @@ module Imports
# Note: order matters when we derive from previous values (attributes parameter)
attributes["saledate"] = compose_date(xml_doc, "DAY", "MONTH", "YEAR") || Time.zone.parse(field_value(xml_doc, "xmlns", "CompletionDate"))
attributes["owning_organisation_id"] = find_organisation_id(xml_doc, "OWNINGORGID")
attributes["owning_organisation_id"] = find_organisation_id(xml_doc, "owner-institution-id")
attributes["type"] = unsafe_string_as_integer(xml_doc, "DerSaleType")
attributes["old_id"] = meta_field_value(xml_doc, "document-id")
attributes["old_form_id"] = safe_string_as_integer(xml_doc, "Form")

Loading…
Cancel
Save