From b01b3b6c17c6c199cc2059ad341a1f8644ab3a83 Mon Sep 17 00:00:00 2001 From: Kat Date: Mon, 10 Jul 2023 13:32:04 +0100 Subject: [PATCH] Update fields to work with supported housing --- app/controllers/duplicate_logs_controller.rb | 2 +- app/models/lettings_log.rb | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/controllers/duplicate_logs_controller.rb b/app/controllers/duplicate_logs_controller.rb index e08ec828d..9539494c0 100644 --- a/app/controllers/duplicate_logs_controller.rb +++ b/app/controllers/duplicate_logs_controller.rb @@ -28,7 +28,7 @@ private def duplicate_check_question_ids if @log.lettings? - %w[owning_organisation_id startdate tenancycode postcode_full age1 sex1 ecstat1 tcharge] + ["owning_organisation_id", "startdate", "tenancycode", @log.is_general_needs? ? "postcode_full" : nil, @log.is_supported_housing? ? "location_id" : nil, "age1", "sex1", "ecstat1", "tcharge"].compact else %w[owning_organisation_id saledate purchid age1 sex1 ecstat1 postcode_full] end diff --git a/app/models/lettings_log.rb b/app/models/lettings_log.rb index 6f3ce1cec..d93a173f9 100644 --- a/app/models/lettings_log.rb +++ b/app/models/lettings_log.rb @@ -56,8 +56,9 @@ class LettingsLog < Log scope :duplicate_logs, lambda { |log| visible.where(log.slice(*DUPLICATE_LOG_ATTRIBUTES)) .where.not(id: log.id) - .where.not("startdate IS NULL OR age1 IS NULL OR sex1 IS NULL OR ecstat1 IS NULL OR tcharge IS NULL OR postcode_full IS NULL OR needstype IS NULL") + .where.not("startdate IS NULL OR age1 IS NULL OR sex1 IS NULL OR ecstat1 IS NULL OR tcharge IS NULL OR needstype IS NULL") .where("location_id = ? OR needstype = 1", log.location_id) + .where("postcode_full = ? OR needstype = 2", log.postcode_full) } AUTOGENERATED_FIELDS = %w[id status created_at updated_at discarded_at].freeze @@ -67,7 +68,7 @@ class LettingsLog < Log NUM_OF_WEEKS_FROM_PERIOD = { 2 => 26, 3 => 13, 4 => 12, 5 => 50, 6 => 49, 7 => 48, 8 => 47, 9 => 46, 1 => 52, 10 => 53 }.freeze SUFFIX_FROM_PERIOD = { 2 => "every 2 weeks", 3 => "every 4 weeks", 4 => "every month" }.freeze RETIREMENT_AGES = { "M" => 67, "F" => 60, "X" => 67 }.freeze - DUPLICATE_LOG_ATTRIBUTES = %w[tenancycode startdate age1 sex1 ecstat1 tcharge postcode_full].freeze + DUPLICATE_LOG_ATTRIBUTES = %w[tenancycode startdate age1 sex1 ecstat1 tcharge].freeze def form FormHandler.instance.get_form(form_name) || FormHandler.instance.current_lettings_form