|
|
@ -6,29 +6,27 @@ module Validations::SetupValidations |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def validate_startdate(record) |
|
|
|
def validate_startdate(record) |
|
|
|
if record.needstype == 2 |
|
|
|
if record.startdate > Time.zone.today |
|
|
|
if record.startdate > Time.zone.today |
|
|
|
record.errors.add :startdate, I18n.t("validations.setup.startdate.today_or_earlier") |
|
|
|
record.errors.add :startdate, I18n.t("validations.setup.startdate.today_or_earlier") |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
if record.voiddate.present? |
|
|
|
if record.voiddate.present? |
|
|
|
if (record.startdate.to_date - record.voiddate.to_date).to_i.abs > 730 |
|
|
|
if (record.startdate.to_date - record.voiddate.to_date).to_i.abs > 730 |
|
|
|
record.errors.add :startdate, I18n.t("validations.setup.startdate.voiddate_difference") |
|
|
|
record.errors.add :startdate, I18n.t("validations.setup.startdate.voiddate_difference") |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
if record.mrcdate.present? |
|
|
|
if record.mrcdate.present? |
|
|
|
if (record.startdate.to_date - record.mrcdate.to_date).to_i.abs > 730 |
|
|
|
if (record.startdate.to_date - record.mrcdate.to_date).to_i.abs > 730 |
|
|
|
record.errors.add :startdate, I18n.t("validations.setup.startdate.mrcdate_difference") |
|
|
|
record.errors.add :startdate, I18n.t("validations.setup.startdate.mrcdate_difference") |
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
if record.scheme_id.present? |
|
|
|
if record.scheme_id.present? |
|
|
|
scheme_end_date = Scheme.find(record.scheme_id).end_date |
|
|
|
scheme_end_date = Scheme.find(record.scheme_id).end_date |
|
|
|
if scheme_end_date.present? |
|
|
|
if scheme_end_date.present? |
|
|
|
if record.startdate > scheme_end_date |
|
|
|
if 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 |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|