Browse Source

feat: add one year gap exchange/completion validations

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

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

@ -15,13 +15,18 @@ module Validations::Sales::SaleInformationValidations
end
end
def validate_exchange_date_before_completion_date(record)
def validate_exchange_and_completion_date(record)
return unless record.exdate && record.saledate
if record.exdate > record.saledate
record.errors.add :exdate, I18n.t("validations.sale_information.completion_exchange.exchange_before_completion")
record.errors.add :saledate, I18n.t("validations.sale_information.completion_exchange.completion_after_exchange")
end
if record.exdate < record.saledate - 1.year
record.errors.add :exdate, I18n.t("validations.sale_information.completion_exchange.exchange_after_one_year_before_completion")
record.errors.add :saledate, I18n.t("validations.sale_information.completion_exchange.completion_before_one_year_after_exchange")
end
end
def validate_previous_property_unit_type(record)

3
config/locales/en.yml

@ -422,7 +422,8 @@ en:
completion_exchange:
exchange_before_completion: "Exchange date must be before completion date"
completion_after_exchange: "Completion date must be after exchange date"
exchange_after_one_year_before_completion: "Exchange date must be less than 1 year before completion date"
completion_before_one_year_after_exchange: "Completion date must be less than 1 year after exchange date"
soft_validations:
net_income:
title_text: "Net income is outside the expected range based on the lead tenant’s working situation"

Loading…
Cancel
Save