Browse Source

refactor: cleanup

pull/1232/head
natdeanlewissoftwire 3 years ago
parent
commit
5b74254631
  1. 12
      app/models/validations/sales/sale_information_validations.rb
  2. 2
      config/locales/en.yml

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

@ -3,7 +3,7 @@ module Validations::Sales::SaleInformationValidations
return if record.saledate.blank? || record.hodate.blank?
unless record.saledate > record.hodate
record.errors.add :hodate, "Practical completion or handover date must be before exchange date"
record.errors.add :hodate, I18n.t("validations.sale_information.hodate.must_be_before_exdate")
end
end
@ -11,13 +11,13 @@ module Validations::Sales::SaleInformationValidations
return unless record.exdate && record.saledate
if record.exdate > record.saledate
record.errors.add(:exdate, I18n.t("validations.sale_information.exdate.must_be_before_saledate"))
record.errors.add(:saledate, I18n.t("validations.sale_information.saledate.must_be_after_exdate"))
record.errors.add :exdate, I18n.t("validations.sale_information.exdate.must_be_before_saledate")
record.errors.add :saledate, I18n.t("validations.sale_information.saledate.must_be_after_exdate")
end
if record.saledate.to_date - record.exdate.to_date > 1.year.in_days
record.errors.add(:exdate, I18n.t("validations.sale_information.exdate.must_be_less_than_1_year_from_saledate"))
record.errors.add(:saledate, I18n.t("validations.sale_information.saledate.must_be_less_than_1_year_from_exdate"))
if record.saledate - record.exdate > 1.year
record.errors.add :exdate, I18n.t("validations.sale_information.exdate.must_be_less_than_1_year_from_saledate")
record.errors.add :saledate, I18n.t("validations.sale_information.saledate.must_be_less_than_1_year_from_exdate")
end
end

2
config/locales/en.yml

@ -415,6 +415,8 @@ en:
deactivation:
during_deactivated_period: "The location is already deactivated during this date, please enter a different date"
sale_information:
hodate:
must_be_before_exdate: "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_less_than_1_year_from_saledate: "Contract exchange date must be less than 1 year before completion date"

Loading…
Cancel
Save