Browse Source

CLDC-4333: update hint text instead to ensure value is 100% of equity

pull/3270/head
Nat Dean-Lewis 1 week ago
parent
commit
1d61cefc30
  1. 6
      app/models/form/sales/questions/value.rb
  2. 15
      app/models/validations/sales/sale_information_validations.rb
  3. 2
      config/locales/forms/2025/sales/sale_information.en.yml
  4. 2
      config/locales/forms/2026/sales/sale_information.en.yml
  5. 2
      config/locales/validations/sales/sale_information.en.yml
  6. 2
      spec/models/form/sales/questions/value_spec.rb
  7. 56
      spec/models/validations/sales/sale_information_validations_spec.rb

6
app/models/form/sales/questions/value.rb

@ -4,11 +4,7 @@ class Form::Sales::Questions::Value < ::Form::Question
@id = "value"
@copy_key = form.start_year_2025_or_later? ? "sales.sale_information.value.#{page.id}" : "sales.sale_information.value"
@type = "numeric"
@min = if form.start_year_2026_or_later? && subsection.id != "shared_ownership_staircasing_transaction"
15_000
else
0
end
@min = form.start_year_2026_or_later? ? 15_000 : 0
@step = 1
@width = 10
@prefix = "£"

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

@ -370,21 +370,6 @@ module Validations::Sales::SaleInformationValidations
end
end
def validate_staircasing_purchase_price(record)
return unless record.form.start_year_2026_or_later?
return unless record.is_staircase? && record.value && record.stairbought&.positive?
full_purchase_price = record.value * 100 / record.stairbought
if full_purchase_price < 15_000
%i[value stairbought].each do |field|
record.errors.add field, I18n.t("validations.sales.sale_information.#{field}.full_purchase_price_below_min",
value: record.field_formatted_as_currency("value"),
stairbought: record.stairbought,
full_purchase_price: format_as_currency(full_purchase_price))
end
end
end
def validate_mortgage_used_dont_know(record)
return unless record.mortgage_use_unknown?
return if record.form.start_year_2026_or_later?

2
config/locales/forms/2025/sales/sale_information.en.yml

@ -148,7 +148,7 @@ en:
value_shared_ownership:
check_answer_label: "Full purchase price"
check_answer_prompt: ""
hint_text: "Enter the full purchase price of the property before any discounts are applied. This is the full purchase price paid for 100% equity (this is equal to the value of the share owned by the PRP plus the value bought by the purchaser)."
hint_text: "Enter the full purchase price of the property before any discounts are applied. For shared ownership, enter the full purchase price paid for 100% equity (this is equal to the value of the share owned by the PRP plus the value bought by the purchaser in the current and all previous transactions)."
question_text: "What was the full purchase price?"
value_shared_ownership_staircase:
check_answer_label: "Full purchase price"

2
config/locales/forms/2026/sales/sale_information.en.yml

@ -148,7 +148,7 @@ en:
value_shared_ownership:
check_answer_label: "Full purchase price"
check_answer_prompt: ""
hint_text: "Enter the full purchase price of the property before any discounts are applied. This is the full purchase price paid for 100% equity (this is equal to the value of the share owned by the PRP plus the value bought by the purchaser)."
hint_text: "Enter the full purchase price of the property before any discounts are applied. For shared ownership, enter the full purchase price paid for 100% equity (this is equal to the value of the share owned by the PRP plus the value bought by the purchaser in the current and all previous transactions)."
question_text: "What was the full purchase price?"
value_shared_ownership_staircase:
check_answer_label: "Full purchase price"

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

@ -54,7 +54,6 @@ en:
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."
value:
full_purchase_price_below_min: "Based on the purchase price of %{value} and the percentage bought of %{stairbought}%, the implied full property value is %{full_purchase_price}. The full property value must be at least £15,000."
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."
value_over_discounted_london_max: "The percentage discount multiplied by the purchase price is %{discount_value}. This figure should not be more than £137,400 for properties in London."
@ -118,7 +117,6 @@ en:
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."
stairbought:
full_purchase_price_below_min: "Based on the purchase price of %{value} and the percentage bought of %{stairbought}%, the implied full property value is %{full_purchase_price}. The full property value must be at least £15,000."
stairbought_over_max: "The percentage bought in this staircasing transaction cannot be higher than %{max_stairbought}% for %{type} sales."
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."

2
spec/models/form/sales/questions/value_spec.rb

@ -66,7 +66,7 @@ RSpec.describe Form::Sales::Questions::Value, type: :model do
end
it "has correct min" do
expect(question.min).to eq(0)
expect(question.min).to eq(15_000)
end
end
end

56
spec/models/validations/sales/sale_information_validations_spec.rb

@ -994,62 +994,6 @@ RSpec.describe Validations::Sales::SaleInformationValidations do
end
end
describe "#validate_staircasing_purchase_price" do
let(:saledate) { Time.zone.local(2026, 4, 1) }
let(:record) { build(:sales_log, ownershipsch: 1, staircase: 1, saledate:) }
it "does not add an error when not staircasing" do
record.staircase = 2
record.value = 5_000
record.stairbought = 10
sale_information_validator.validate_staircasing_purchase_price(record)
expect(record.errors).to be_empty
end
it "does not add an error when value is nil" do
record.value = nil
record.stairbought = 10
sale_information_validator.validate_staircasing_purchase_price(record)
expect(record.errors).to be_empty
end
it "does not add an error when stairbought is nil" do
record.value = 5_000
record.stairbought = nil
sale_information_validator.validate_staircasing_purchase_price(record)
expect(record.errors).to be_empty
end
it "does not add an error when full purchase price is at least 15,000" do
record.value = 1_500
record.stairbought = 10
sale_information_validator.validate_staircasing_purchase_price(record)
expect(record.errors).to be_empty
end
it "adds an error when full purchase price is below 15,000" do
record.value = 1_000
record.stairbought = 10
sale_information_validator.validate_staircasing_purchase_price(record)
expect(record.errors[:value]).to be_present
expect(record.errors[:stairbought]).to be_present
end
it "does not add an error for years before 2026" do
record.saledate = Time.zone.local(2025, 4, 1)
record.value = 1_000
record.stairbought = 10
sale_information_validator.validate_staircasing_purchase_price(record)
expect(record.errors).to be_empty
end
end
describe "#validate_discount_and_value" do
let(:record) { FactoryBot.build(:sales_log, value: 200_000, discount: 50, ownershipsch: 2, type: 9, saledate:) }
let(:saledate) { current_collection_start_date }

Loading…
Cancel
Save