@ -41,16 +41,24 @@ module Validations::DateValidations
record . errors . add :startdate , I18n . t ( " validations.date.outside_collection_window " )
record . errors . add :startdate , I18n . t ( " validations.date.outside_collection_window " )
end
end
if FeatureToggle . startdate_two_week_validation_enabled? && ( record . startdate > Time . zone . today + 14 )
if FeatureToggle . startdate_two_week_validation_enabled? && record . startdate > Time . zone . today + 14
record . errors . add :startdate , I18n . t ( " validations.setup.startdate.later_than_14_days_after " )
record . errors . add :startdate , I18n . t ( " validations.setup.startdate.later_than_14_days_after " )
end
end
if record . scheme_id . present?
if record . scheme_id . present?
scheme_end_date = record . scheme . end_date
scheme_end_date = record . scheme . end_date
if scheme_end_date . present? && ( record . startdate > scheme_end_date )
if scheme_end_date . present? && record . startdate > scheme_end_date
record . errors . add :startdate , I18n . t ( " validations.setup.startdate.before_scheme_end_date " )
record . errors . add :startdate , I18n . t ( " validations.setup.startdate.before_scheme_end_date " )
end
end
end
end
if record [ " voiddate " ] . present? && record . startdate < record [ " voiddate " ]
record . errors . add :startdate , I18n . t ( " validations.setup.startdate.after_void_date " )
end
if record [ " mrcdate " ] . present? && record . startdate < record [ " mrcdate " ]
record . errors . add :startdate , I18n . t ( " validations.setup.startdate.after_major_repair_date " )
end
end
end
private
private