Browse Source

feat: check for duplicate logs in row_parser

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

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

@ -150,6 +150,7 @@ class BulkUpload::Lettings::RowParser
validate :validate_cannot_be_la_referral_if_general_needs
validate :validate_leaving_reason_for_renewal
validate :validate_lettings_type_matches_bulk_upload
validate :validate_if_log_already_exists
validate :validate_only_one_housing_needs_type
validate :validate_no_disabled_needs_conjunction
validate :validate_dont_know_disabled_needs_conjunction
@ -292,6 +293,18 @@ private
end
end
def validate_if_log_already_exists
fields = {
"beds" => field_101,
"joint" => field_133,
}
duplicate_log_exists = LettingsLog.where(fields).present?
if duplicate_log_exists
errors.add('test', "test")
end
end
def field_mapping_for_errors
{
lettype: [:field_1],

Loading…
Cancel
Save