diff --git a/app/controllers/schemes_controller.rb b/app/controllers/schemes_controller.rb index 5c2fe355f..6dc24ddcd 100644 --- a/app/controllers/schemes_controller.rb +++ b/app/controllers/schemes_controller.rb @@ -318,7 +318,7 @@ private if params[:scheme_deactivation_period].blank? return elsif params[:scheme_deactivation_period]["#{key}_type".to_sym] == "default" - return FormHandler.instance.start_date_of_earliest_open_collection_period + return FormHandler.instance.start_date_of_earliest_open_for_editing_collection_period elsif params[:scheme_deactivation_period][key.to_sym].present? return params[:scheme_deactivation_period][key.to_sym] end diff --git a/app/models/scheme_deactivation_period.rb b/app/models/scheme_deactivation_period.rb index e413bb6a9..176d15211 100644 --- a/app/models/scheme_deactivation_period.rb +++ b/app/models/scheme_deactivation_period.rb @@ -34,8 +34,8 @@ class SchemeDeactivationPeriodValidator < ActiveModel::Validator end elsif scheme.scheme_deactivation_periods.any? { |period| period.reactivation_date.present? && record.deactivation_date.between?(period.deactivation_date, period.reactivation_date - 1.day) } record.errors.add(:deactivation_date, message: I18n.t("validations.scheme.deactivation.during_deactivated_period")) - elsif record.deactivation_date.before? FormHandler.instance.start_date_of_earliest_open_collection_period - record.errors.add(:deactivation_date, message: I18n.t("validations.scheme.toggle_date.out_of_range", date: FormHandler.instance.start_date_of_earliest_open_collection_period.to_formatted_s(:govuk_date))) + elsif record.deactivation_date.before? FormHandler.instance.start_date_of_earliest_open_for_editing_collection_period + record.errors.add(:deactivation_date, message: I18n.t("validations.scheme.toggle_date.out_of_range", date: FormHandler.instance.start_date_of_earliest_open_for_editing_collection_period.to_formatted_s(:govuk_date))) elsif record.deactivation_date.before? scheme.available_from record.errors.add(:deactivation_date, message: I18n.t("validations.scheme.toggle_date.before_creation", date: scheme.available_from.to_formatted_s(:govuk_date))) end diff --git a/app/views/schemes/toggle_active.html.erb b/app/views/schemes/toggle_active.html.erb index e989be995..b23c9591c 100644 --- a/app/views/schemes/toggle_active.html.erb +++ b/app/views/schemes/toggle_active.html.erb @@ -10,7 +10,7 @@ <%= form_with model: @scheme_deactivation_period, url: toggle_scheme_form_path(action, @scheme), method: "patch", local: true do |f| %>