diff --git a/app/models/validations/sales/sale_information_validations.rb b/app/models/validations/sales/sale_information_validations.rb index 3c5e3f2b9..69938eea3 100644 --- a/app/models/validations/sales/sale_information_validations.rb +++ b/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") 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 :saledate, I18n.t("validations.sales.sale_information.saledate.must_be_less_than_3_years_from_hodate") 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 def validate_exchange_date(record) diff --git a/config/locales/validations/sales/sale_information.en.yml b/config/locales/validations/sales/sale_information.en.yml index 20aca17d2..8fb7d02d4 100644 --- a/config/locales/validations/sales/sale_information.en.yml +++ b/config/locales/validations/sales/sale_information.en.yml @@ -8,9 +8,11 @@ en: hodate: 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_5_years_from_saledate: "Practical completion or handover date must be less than 5 years before sale completion date." saledate: 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_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_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."