From 57db0bdf74d4626db202575bd24455f15cb82f6e Mon Sep 17 00:00:00 2001 From: Sam Seed Date: Wed, 8 Feb 2023 11:31:41 +0000 Subject: [PATCH] feat: check for duplicate logs in row_parser --- app/services/bulk_upload/lettings/row_parser.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/app/services/bulk_upload/lettings/row_parser.rb b/app/services/bulk_upload/lettings/row_parser.rb index bf1f62eba..2acd82d99 100644 --- a/app/services/bulk_upload/lettings/row_parser.rb +++ b/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],