Browse Source

CLDC-4006: Add validations for purchase price and mortage

CLDC-4006-add-purchase-price-validation
SuperrrrrFrank 3 months ago
parent
commit
89186dda25
  1. 12
      app/models/validations/sales/sale_information_validations.rb
  2. 2
      config/locales/validations/sales/sale_information.en.yml

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

@ -134,6 +134,12 @@ module Validations::Sales::SaleInformationValidations
end
end
def validate_purchase_amount(record)
return unless record.value && record.value > 999_999
record.errors.add :value, I18n.t("validations.sales.sale_information.value.purchase_price_out_of_range")
end
def validate_grant_amount(record)
return unless record.saledate && record.form.start_year_2024_or_later?
return unless record.grant && (record.type == 8 || record.type == 21)
@ -143,6 +149,12 @@ module Validations::Sales::SaleInformationValidations
end
end
def validate_mortgage_amount(record)
return unless record.mortgage && record.mortgage > 999_999
record.errors.add :mortgage, I18n.t("validations.sales.sale_information.mortgage.mortgage_out_of_range")
end
def validate_stairbought(record)
return unless record.stairbought && record.type
return unless record.saledate && record.form.start_year_2024_or_later?

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

@ -53,6 +53,7 @@ en:
staircasing_mortgage:
mortgage_used: "The mortgage (%{mortgage}) and cash deposit (%{deposit}) added together is %{mortgage_and_deposit_total}.</br></br>The full purchase price (%{value}) multiplied by the percentage bought is %{stairbought_part_of_value}.</br></br>These two amounts should be the same."
mortgage_used_socialhomebuy: "The mortgage amount (%{mortgage}), cash deposit (%{deposit}), and cash discount (%{cashdis}) added together is %{mortgage_deposit_and_discount_total}.</br></br>The full purchase price (%{value}) multiplied by the percentage bought (%{stairbought}) is %{stairbought_part_of_value}.</br></br>These two amounts should be the same."
mortgage_out_of_range: "Mortgage amount must be between £0 and £999,999."
value:
discounted_ownership_value: "The mortgage%{mortgage}%{deposit_and_grant_sentence} added together is %{mortgage_deposit_and_grant_total}.</br></br>The full purchase price%{discount_sentence} is %{value_with_discount}.</br></br>These two amounts should be the same."
outright_sale_value: "The mortgage%{mortgage} and cash deposit (%{deposit}) when added together is %{mortgage_and_deposit_total}.</br></br>The full purchase price is %{value}.</br></br>These two amounts should be the same."
@ -68,6 +69,7 @@ en:
mortgage_not_used: "The cash deposit is %{deposit}.</br></br>The full purchase price (%{value}) multiplied by the percentage bought is %{stairbought_part_of_value}.</br></br>These two amounts should be the same."
mortgage_used_socialhomebuy: "The mortgage amount (%{mortgage}), cash deposit (%{deposit}), and cash discount (%{cashdis}) added together is %{mortgage_deposit_and_discount_total}.</br></br>The full purchase price (%{value}) multiplied by the percentage bought (%{stairbought}) is %{stairbought_part_of_value}.</br></br>These two amounts should be the same."
mortgage_not_used_socialhomebuy: "The cash deposit (%{deposit}) and cash discount (%{cashdis}) added together is %{deposit_and_discount_total}.</br></br>The full purchase price (%{value}) multiplied by the percentage bought (%{stairbought}) is %{stairbought_part_of_value}.</br></br>These two amounts should be the same."
purchase_price_out_of_range: "Purchase price must be between £0 and £999,999."
deposit:
discounted_ownership_value: "The mortgage%{mortgage}%{deposit_and_grant_sentence} added together is %{mortgage_deposit_and_grant_total}.</br></br>The full purchase price%{discount_sentence} is %{value_with_discount}.</br></br>These two amounts should be the same."
outright_sale_value: "The mortgage%{mortgage} and cash deposit (%{deposit}) when added together is %{mortgage_and_deposit_total}.</br></br>The full purchase price is %{value}.</br></br>These two amounts should be the same."

Loading…
Cancel
Save