Browse Source

Update validation for 2025

pull/2781/head
Manny Dinssa 7 months ago
parent
commit
268eb3cd7e
  1. 7
      app/models/validations/sales/sale_information_validations.rb
  2. 2
      config/locales/validations/sales/sale_information.en.yml

7
app/models/validations/sales/sale_information_validations.rb

@ -12,10 +12,15 @@ module Validations::Sales::SaleInformationValidations
record.errors.add :saledate, I18n.t("validations.sales.sale_information.saledate.must_be_after_hodate") record.errors.add :saledate, I18n.t("validations.sales.sale_information.saledate.must_be_after_hodate")
end end
if record.saledate - record.hodate >= 3.years && record.form.start_year_2024_or_later? if record.saledate - record.hodate >= 3.years && record.startdate.year <= 2024
record.errors.add :hodate, I18n.t("validations.sales.sale_information.hodate.must_be_less_than_3_years_from_saledate") record.errors.add :hodate, I18n.t("validations.sales.sale_information.hodate.must_be_less_than_3_years_from_saledate")
record.errors.add :saledate, I18n.t("validations.sales.sale_information.saledate.must_be_less_than_3_years_from_hodate") record.errors.add :saledate, I18n.t("validations.sales.sale_information.saledate.must_be_less_than_3_years_from_hodate")
end end
if record.saledate - record.hodate >= 5.years && record.form.start_year_2025_or_later?
record.errors.add :hodate, I18n.t("validations.sales.sale_information.hodate.must_be_less_than_5_years_from_saledate")
record.errors.add :saledate, I18n.t("validations.sales.sale_information.saledate.must_be_less_than_5_years_from_hodate")
end
end end
def validate_exchange_date(record) def validate_exchange_date(record)

2
config/locales/validations/sales/sale_information.en.yml

@ -8,9 +8,11 @@ en:
hodate: hodate:
must_be_before_saledate: "Practical completion or handover date must be before sale completion date." must_be_before_saledate: "Practical completion or handover date must be before sale completion date."
must_be_less_than_3_years_from_saledate: "Practical completion or handover date must be less than 3 years before sale completion date." must_be_less_than_3_years_from_saledate: "Practical completion or handover date must be less than 3 years before sale completion date."
must_be_less_than_5_years_from_saledate: "Practical completion or handover date must be less than 5 years before sale completion date."
saledate: saledate:
must_be_after_hodate: "Sale completion date must be after practical completion or handover date." must_be_after_hodate: "Sale completion date must be after practical completion or handover date."
must_be_less_than_3_years_from_hodate: "Sale completion date must be less than 3 years after practical completion or handover date." must_be_less_than_3_years_from_hodate: "Sale completion date must be less than 3 years after practical completion or handover date."
must_be_less_than_5_years_from_hodate: "Sale completion date must be less than 5 years after practical completion or handover date."
must_be_after_exdate: "Sale completion date must be after contract exchange date." must_be_after_exdate: "Sale completion date must be after contract exchange date."
must_be_less_than_1_year_from_exdate: "Sale completion date must be less than 1 year after contract exchange date." must_be_less_than_1_year_from_exdate: "Sale completion date must be less than 1 year after contract exchange date."
mortgage_used_year: "You must answer either ‘yes’ or ‘no’ to the question ‘was a mortgage used’ for the selected year." mortgage_used_year: "You must answer either ‘yes’ or ‘no’ to the question ‘was a mortgage used’ for the selected year."

Loading…
Cancel
Save