Browse Source

feat: add validation for voiddate and mrcdate when startdate changed after these have been added later

pull/942/head
natdeanlewissoftwire 3 years ago
parent
commit
026a4ac56c
  1. 8
      app/models/validations/date_validations.rb
  2. 2
      config/locales/en.yml

8
app/models/validations/date_validations.rb

@ -51,6 +51,14 @@ module Validations::DateValidations
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

2
config/locales/en.yml

@ -118,6 +118,8 @@ en:
startdate: startdate:
later_than_14_days_after: "The tenancy start date must not be later than 14 days from today’s date" later_than_14_days_after: "The tenancy start date must not be later than 14 days from today’s date"
before_scheme_end_date: "The tenancy start date must be before the end date for this supported housing scheme" before_scheme_end_date: "The tenancy start date must be before the end date for this supported housing scheme"
after_void_date: "Enter a tenancy start date that is after the void date"
after_major_repair_date: "Enter a tenancy start date that is after the major repair date"
property: property:
mrcdate: mrcdate:

Loading…
Cancel
Save