Browse Source

validate staircasing dates

pull/3001/head
Carolyn 2 months ago
parent
commit
9748156c74
  1. 23
      app/models/validations/sales/sale_information_validations.rb
  2. 9
      config/locales/validations/sales/sale_information.en.yml

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

@ -41,6 +41,29 @@ module Validations::Sales::SaleInformationValidations
if record.initialpurchase < Time.zone.local(1980, 1, 1) if record.initialpurchase < Time.zone.local(1980, 1, 1)
record.errors.add :initialpurchase, I18n.t("validations.sales.sale_information.initialpurchase.must_be_after_1980") record.errors.add :initialpurchase, I18n.t("validations.sales.sale_information.initialpurchase.must_be_after_1980")
end end
if record.initialpurchase > record.saledate
record.errors.add :initialpurchase, I18n.t("validations.sales.sale_information.initialpurchase.must_be_before_saledate")
record.errors.add :saledate, I18n.t("validations.sales.sale_information.saledate.must_be_after_initial_purchase_date")
end
end
def validate_staircasing_last_transaction_date(record)
return unless record.lasttransaction
if record.lasttransaction < Time.zone.local(1980, 1, 1)
record.errors.add :lasttransaction, I18n.t("validations.sales.sale_information.lasttransaction.must_be_after_1980")
end
if record.lasttransaction > record.saledate
record.errors.add :lasttransaction, I18n.t("validations.sales.sale_information.lasttransaction.must_be_before_saledate")
record.errors.add :saledate, I18n.t("validations.sales.sale_information.saledate.must_be_after_last_transaction_date")
end
if record.initialpurchase.present? && record.lasttransaction < record.initialpurchase
record.errors.add :initialpurchase, I18n.t("validations.sales.sale_information.initialpurchase.must_be_before_last_transaction")
record.errors.add :lasttransaction, I18n.t("validations.sales.sale_information.lasttransaction.must_be_after_initial_purchase")
end
end end
def validate_previous_property_unit_type(record) def validate_previous_property_unit_type(record)

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

@ -16,11 +16,20 @@ en:
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."
must_be_after_initial_purchase_date: "Sale completion date for a staircasing transaction must be after the date of the initial purchase of a share."
must_be_after_last_transaction_date: "Sale completion date must be after the date of the last staircasing transaction."
exdate: exdate:
must_be_before_saledate: "Contract exchange date must be before sale completion date." must_be_before_saledate: "Contract exchange date must be before sale completion date."
must_be_less_than_1_year_from_saledate: "Contract exchange date must be less than 1 year before sale completion date." must_be_less_than_1_year_from_saledate: "Contract exchange date must be less than 1 year before sale completion date."
initialpurchase: initialpurchase:
must_be_after_1980: "The initial purchase date must be after January 1, 1980." must_be_after_1980: "The initial purchase date must be after January 1, 1980."
must_be_before_last_transaction: "The initial purchase date must be before the last staircasing transaction date."
must_be_before_saledate: "The initial purchase date must be before the date of this sale."
lasttransaction:
must_be_after_1980: "The last staircasing transaction date must be after January 1, 1980."
must_be_after_initial_purchase: "The last staircasing transaction date must be after the initial purchase date."
must_be_before_saledate: "The last staircasing transaction date must be before the date of this sale."
fromprop: fromprop:
previous_property_type_bedsit: "A bedsit cannot have more than 1 bedroom." previous_property_type_bedsit: "A bedsit cannot have more than 1 bedroom."
frombeds: frombeds:

Loading…
Cancel
Save