Browse Source

refactor: use log to infer field values when checking for duplicates

cldc-1888-bulk-upload-duplicate-log-validation
Sam Seed 2 years ago
parent
commit
d9fabb03f6
  1. 54
      app/services/bulk_upload/lettings/row_parser.rb

54
app/services/bulk_upload/lettings/row_parser.rb

@ -315,21 +315,21 @@ private
end end
def log_already_exists? def log_already_exists?
field_mappings = { fields_for_duplicity_check = %w(
"startdate" => startdate, startdate
"postcode_full" => postcode_full, postcode_full
"brent" => brent, brent
"scharge" => scharge, scharge
"pscharge" => pscharge, pscharge
"supcharg" => supcharg, supcharg
"tenancycode" => field_7, tenancycode
"age1" => field_12, age1
"sex1" => field_20, sex1
"ecstat1" => field_35, ecstat1
"ethnic" => field_43, ethnic
} )
LettingsLog.exists?(field_mappings) LettingsLog.exists?(Hash[fields_for_duplicity_check.collect { |field| [field, log[field]] }])
end end
def field_mapping_for_errors def field_mapping_for_errors
@ -922,30 +922,6 @@ private
end end
end end
def brent
if %i[field_80 field_81 field_82 field_83].any? { |f| public_send(f).present? }
self.field_80 ||= 0
end
end
def scharge
if %i[field_80 field_81 field_82 field_83].any? { |f| public_send(f).present? }
self.field_81 ||= 0
end
end
def pscharge
if %i[field_80 field_81 field_82 field_83].any? { |f| public_send(f).present? }
self.field_82 ||= 0
end
end
def supcharg
if %i[field_80 field_81 field_82 field_83].any? { |f| public_send(f).present? }
self.field_83 ||= 0
end
end
def scheme def scheme
@scheme ||= Scheme.find_by(old_visible_id: field_4) @scheme ||= Scheme.find_by(old_visible_id: field_4)
end end

Loading…
Cancel
Save