Browse Source

feat: add hodate/saledate hard validation to saledate as well

pull/1259/head
natdeanlewissoftwire 3 years ago
parent
commit
3f5c8d3ba7
  1. 5
      app/models/validations/sales/sale_information_validations.rb
  2. 7
      config/locales/en.yml

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

@ -2,8 +2,9 @@ module Validations::Sales::SaleInformationValidations
def validate_practical_completion_date_before_saledate(record)
return if record.saledate.blank? || record.hodate.blank?
unless record.saledate > record.hodate
record.errors.add :hodate, I18n.t("validations.sale_information.hodate.must_be_before_exdate")
if record.hodate > record.saledate
record.errors.add :hodate, I18n.t("validations.sale_information.hodate.must_be_before_saledate")
record.errors.add :saledate, I18n.t("validations.sale_information.saledate.must_be_after_hodate")
end
end

7
config/locales/en.yml

@ -422,13 +422,14 @@ en:
social_homebuy: "Social HomeBuy buyers should not have lived here before"
rent_to_buy: "Rent to Buy buyers should not have lived here before"
hodate:
must_be_before_exdate: "Practical completion or handover date must be before exchange date"
must_be_before_saledate: "Practical completion or handover date must be before exchange date"
exdate:
must_be_before_saledate: "Contract exchange date must be less than 1 year before completion date"
must_be_before_saledate: "Contract exchange date must be before completion date"
must_be_less_than_1_year_from_saledate: "Contract exchange date must be less than 1 year before completion date"
saledate:
must_be_after_exdate: "Completion date must be less than 1 year after contract exchange date"
must_be_after_exdate: "Completion date must be after contract exchange date"
must_be_less_than_1_year_from_exdate: "Completion date must be less than 1 year after contract exchange date"
must_be_after_hodate: "Completion date must be after practical completion or handover date"
previous_property_beds:
property_type_bedsit: "Bedsit bedroom maximum 1"
discounted_ownership_value: "Mortgage, deposit, and grant total must equal £%{value_with_discount}"

Loading…
Cancel
Save