You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
1.4 KiB
32 lines
1.4 KiB
module Validations::Sales::SaleInformationValidations |
|
def validate_pratical_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") |
|
end |
|
end |
|
|
|
def validate_exchange_date(record) |
|
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") |
|
end |
|
|
|
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 |
|
|
|
def validate_previous_property_unit_type(record) |
|
return unless record.fromprop && record.frombeds |
|
|
|
if record.frombeds != 1 && record.fromprop == 2 |
|
record.errors.add :frombeds, I18n.t("validations.sale_information.previous_property_beds.property_type_bedsit") |
|
record.errors.add :fromprop, I18n.t("validations.sale_information.previous_property_type.property_type_bedsit") |
|
end |
|
end |
|
end
|
|
|