From 01aa26a05342d98be0d6463e5e5fe65c85b37810 Mon Sep 17 00:00:00 2001 From: Manny Dinssa <44172848+Dinssa@users.noreply.github.com> Date: Wed, 17 Jul 2024 11:19:15 +0100 Subject: [PATCH] Alternative to prevent tenancy dates before location start date --- app/models/location.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/location.rb b/app/models/location.rb index 7248d6424..e75b81423 100644 --- a/app/models/location.rb +++ b/app/models/location.rb @@ -157,9 +157,9 @@ class Location < ApplicationRecord return :incomplete unless confirmed return :deactivated if scheme.owning_organisation.status_at(date) == :deactivated || open_deactivation&.deactivation_date.present? && date >= open_deactivation.deactivation_date - return :deactivating_soon if open_deactivation&.deactivation_date.present? && date < open_deactivation.deactivation_date && (startdate.blank? || date >= startdate) - return :reactivating_soon if last_deactivation_before(date)&.reactivation_date.present? && date < last_deactivation_before(date).reactivation_date return :activating_soon if startdate.present? && date < startdate + return :deactivating_soon if open_deactivation&.deactivation_date.present? && date < open_deactivation.deactivation_date + return :reactivating_soon if last_deactivation_before(date)&.reactivation_date.present? && date < last_deactivation_before(date).reactivation_date :active end