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
3ce699a234
  1. 15
      app/models/validations/sales/soft_validations.rb
  2. 4
      config/locales/forms/2025/sales/sale_information.en.yml
  3. 4
      config/locales/forms/2026/sales/sale_information.en.yml
  4. 56
      spec/models/validations/sales/soft_validations_spec.rb

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

@ -96,9 +96,8 @@ module Validations::Sales::SoftValidations
def purchase_price_out_of_soft_range? def purchase_price_out_of_soft_range?
return unless value && beds && la && sale_range return unless value && beds && la && sale_range
return if is_staircase? && !stairbought&.positive?
!full_purchase_price.between?(sale_range.soft_min, sale_range.soft_max) !value.between?(sale_range.soft_min, sale_range.soft_max)
end end
def staircase_owned_out_of_soft_range? def staircase_owned_out_of_soft_range?
@ -137,11 +136,11 @@ module Validations::Sales::SoftValidations
end end
def purchase_price_higher_or_lower_text def purchase_price_higher_or_lower_text
full_purchase_price < sale_range.soft_min ? "lower" : "higher" value < sale_range.soft_min ? "lower" : "higher"
end end
def purchase_price_soft_min_or_soft_max def purchase_price_soft_min_or_soft_max
full_purchase_price < sale_range.soft_min ? sale_range.soft_min : sale_range.soft_max value < sale_range.soft_min ? sale_range.soft_min : sale_range.soft_max
end end
def grant_outside_common_range? def grant_outside_common_range?
@ -204,14 +203,6 @@ module Validations::Sales::SoftValidations
private private
def full_purchase_price
if is_staircase? && stairbought&.positive?
value * 100 / stairbought
else
value
end
end
def sale_range def sale_range
LaSaleRange.find_by( LaSaleRange.find_by(
start_year: collection_start_year, start_year: collection_start_year,

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

@ -153,8 +153,8 @@ en:
value_shared_ownership_staircase: value_shared_ownership_staircase:
check_answer_label: "Full purchase price" check_answer_label: "Full purchase price"
check_answer_prompt: "" check_answer_prompt: ""
hint_text: "Enter the full purchase price paid for the equity bought in this staircasing transaction (this is equal to the value of the share 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 for this staircasing transaction?" question_text: "What was the full purchase price?"
equity: equity:
page_header: "About the price of the property" page_header: "About the price of the property"

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

@ -153,8 +153,8 @@ en:
value_shared_ownership_staircase: value_shared_ownership_staircase:
check_answer_label: "Full purchase price" check_answer_label: "Full purchase price"
check_answer_prompt: "" check_answer_prompt: ""
hint_text: "Enter the full purchase price paid for the equity bought in this staircasing transaction (this is equal to the value of the share 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 for this staircasing transaction?" question_text: "What was the full purchase price?"
equity: equity:
page_header: "About the price of the property" page_header: "About the price of the property"

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

@ -809,62 +809,6 @@ RSpec.describe Validations::Sales::SoftValidations do
expect(record).not_to be_purchase_price_out_of_soft_range expect(record).not_to be_purchase_price_out_of_soft_range
end end
context "when staircasing" do
it "is not out of range when stairbought is 10% and value is 20,000 (full price 200,000 is in soft range)" do
record.staircase = 1
record.stairbought = 10
record.value = 20_000
record.beds = 2
record.la = "E07000223"
record.saledate = Time.zone.local(2023, 1, 1)
expect(record).not_to be_purchase_price_out_of_soft_range
end
it "is out of range when stairbought is 10% and value is 17,000 (full price 170,000 is below soft min of 177,000)" do
record.staircase = 1
record.stairbought = 10
record.value = 17_000
record.beds = 2
record.la = "E07000223"
record.saledate = Time.zone.local(2023, 1, 1)
expect(record).to be_purchase_price_out_of_soft_range
end
it "is out of range when stairbought is 10% and value is 40,000 (full price 400,000 is above soft max of 384,000)" do
record.staircase = 1
record.stairbought = 10
record.value = 40_000
record.beds = 2
record.la = "E07000223"
record.saledate = Time.zone.local(2023, 1, 1)
expect(record).to be_purchase_price_out_of_soft_range
end
it "does not trigger when stairbought is not set" do
record.staircase = 1
record.stairbought = nil
record.value = 20_000
record.beds = 2
record.la = "E07000223"
record.saledate = Time.zone.local(2023, 1, 1)
expect(record).not_to be_purchase_price_out_of_soft_range
end
it "does not trigger when stairbought is 0" do
record.staircase = 1
record.stairbought = 0
record.value = 20_000
record.beds = 2
record.la = "E07000223"
record.saledate = Time.zone.local(2023, 1, 1)
expect(record).not_to be_purchase_price_out_of_soft_range
end
end
end end
describe "#grant_outside_common_range?" do describe "#grant_outside_common_range?" do

Loading…
Cancel
Save