Browse Source

CLDC-3676: sales deposit value soft validation

CLDC-3676-remove-all-pre-2025-validations
samyou-softwire 1 week ago
parent
commit
8f89c1e3f7
  1. 35
      app/models/form/sales/pages/shared_ownership_deposit_value_check.rb
  2. 22
      app/models/form/sales/questions/shared_ownership_deposit_value_check.rb
  3. 3
      app/models/form/sales/subsections/shared_ownership_initial_purchase.rb
  4. 3
      app/models/form/sales/subsections/shared_ownership_scheme.rb
  5. 1
      app/models/form/sales/subsections/shared_ownership_staircasing_transaction.rb
  6. 9
      app/models/validations/sales/soft_validations.rb
  7. 44
      spec/models/form/sales/pages/shared_ownership_deposit_value_check_spec.rb
  8. 45
      spec/models/form/sales/questions/shared_ownership_deposit_value_check_spec.rb
  9. 9
      spec/models/form/sales/subsections/shared_ownership_initial_purchase_spec.rb
  10. 3
      spec/models/form/sales/subsections/shared_ownership_scheme_spec.rb
  11. 2
      spec/models/form/sales/subsections/shared_ownership_staircasing_transaction_spec.rb
  12. 143
      spec/models/validations/sales/soft_validations_spec.rb

35
app/models/form/sales/pages/shared_ownership_deposit_value_check.rb

@ -1,35 +0,0 @@
class Form::Sales::Pages::SharedOwnershipDepositValueCheck < ::Form::Page
def initialize(id, hsh, subsection)
super
@depends_on = [
{
"shared_ownership_deposit_invalid?" => true,
},
]
@copy_key = "sales.soft_validations.shared_ownership_deposit_value_check"
@title_text = {
"translation" => "forms.#{form.start_date.year}.#{@copy_key}.title_text",
"arguments" => [
{
"key" => "mortgage_deposit_and_discount_error_fields",
"i18n_template" => "mortgage_deposit_and_discount_error_fields",
},
{
"key" => "field_formatted_as_currency",
"arguments_for_key" => "mortgage_deposit_and_discount_total",
"i18n_template" => "mortgage_deposit_and_discount_total",
},
],
}
end
def questions
@questions ||= [
Form::Sales::Questions::SharedOwnershipDepositValueCheck.new(nil, nil, self),
]
end
def interruption_screen_question_ids
%w[mortgage mortgageused cashdis type deposit value equity]
end
end

22
app/models/form/sales/questions/shared_ownership_deposit_value_check.rb

@ -1,22 +0,0 @@
class Form::Sales::Questions::SharedOwnershipDepositValueCheck < ::Form::Question
def initialize(id, hsh, page)
super
@id = "shared_ownership_deposit_value_check"
@copy_key = "sales.soft_validations.shared_ownership_deposit_value_check"
@type = "interruption_screen"
@answer_options = {
"0" => { "value" => "Yes" },
"1" => { "value" => "No" },
}
@hidden_in_check_answers = {
"depends_on" => [
{
"shared_ownership_deposit_value_check" => 0,
},
{
"shared_ownership_deposit_value_check" => 1,
},
],
}
end
end

3
app/models/form/sales/subsections/shared_ownership_initial_purchase.rb

@ -22,11 +22,9 @@ class Form::Sales::Subsections::SharedOwnershipInitialPurchase < ::Form::Subsect
Form::Sales::Pages::ValueSharedOwnership.new("value_shared_ownership", nil, self), Form::Sales::Pages::ValueSharedOwnership.new("value_shared_ownership", nil, self),
Form::Sales::Pages::AboutPriceValueCheck.new("about_price_shared_ownership_value_check", nil, self), Form::Sales::Pages::AboutPriceValueCheck.new("about_price_shared_ownership_value_check", nil, self),
Form::Sales::Pages::Equity.new("initial_equity", nil, self), Form::Sales::Pages::Equity.new("initial_equity", nil, self),
Form::Sales::Pages::SharedOwnershipDepositValueCheck.new("shared_ownership_equity_value_check", nil, self),
Form::Sales::Pages::Mortgageused.new("mortgage_used_shared_ownership", nil, self, ownershipsch: 1), Form::Sales::Pages::Mortgageused.new("mortgage_used_shared_ownership", nil, self, ownershipsch: 1),
Form::Sales::Pages::MortgageValueCheck.new("mortgage_used_mortgage_value_check", nil, self), Form::Sales::Pages::MortgageValueCheck.new("mortgage_used_mortgage_value_check", nil, self),
Form::Sales::Pages::MortgageAmount.new("mortgage_amount_shared_ownership", nil, self, ownershipsch: 1), Form::Sales::Pages::MortgageAmount.new("mortgage_amount_shared_ownership", nil, self, ownershipsch: 1),
Form::Sales::Pages::SharedOwnershipDepositValueCheck.new("shared_ownership_mortgage_amount_value_check", nil, self),
Form::Sales::Pages::MortgageValueCheck.new("mortgage_amount_mortgage_value_check", nil, self), Form::Sales::Pages::MortgageValueCheck.new("mortgage_amount_mortgage_value_check", nil, self),
(Form::Sales::Pages::MortgageLength.new("mortgage_length_shared_ownership", nil, self, ownershipsch: 1) unless form.start_year_2026_or_later?), (Form::Sales::Pages::MortgageLength.new("mortgage_length_shared_ownership", nil, self, ownershipsch: 1) unless form.start_year_2026_or_later?),
(Form::Sales::Pages::MortgageLengthNotInterviewed.new("mortgage_length_shared_ownership_not_interviewed", nil, self, ownershipsch: 1) if form.start_year_2026_or_later?), (Form::Sales::Pages::MortgageLengthNotInterviewed.new("mortgage_length_shared_ownership_not_interviewed", nil, self, ownershipsch: 1) if form.start_year_2026_or_later?),
@ -37,7 +35,6 @@ class Form::Sales::Subsections::SharedOwnershipInitialPurchase < ::Form::Subsect
Form::Sales::Pages::DepositValueCheck.new("deposit_value_check", nil, self, joint_purchase: false), Form::Sales::Pages::DepositValueCheck.new("deposit_value_check", nil, self, joint_purchase: false),
Form::Sales::Pages::DepositDiscount.new("deposit_discount", nil, self, optional: false), Form::Sales::Pages::DepositDiscount.new("deposit_discount", nil, self, optional: false),
Form::Sales::Pages::DepositDiscount.new("deposit_discount_optional", nil, self, optional: true), Form::Sales::Pages::DepositDiscount.new("deposit_discount_optional", nil, self, optional: true),
Form::Sales::Pages::SharedOwnershipDepositValueCheck.new("shared_ownership_deposit_value_check", nil, self),
Form::Sales::Pages::MonthlyRent.new(nil, nil, self), Form::Sales::Pages::MonthlyRent.new(nil, nil, self),
Form::Sales::Pages::ServiceCharge.new("service_charge", nil, self), Form::Sales::Pages::ServiceCharge.new("service_charge", nil, self),
Form::Sales::Pages::MonthlyChargesValueCheck.new("monthly_charges_initial_purchase_value_check", nil, self), Form::Sales::Pages::MonthlyChargesValueCheck.new("monthly_charges_initial_purchase_value_check", nil, self),

3
app/models/form/sales/subsections/shared_ownership_scheme.rb

@ -30,11 +30,9 @@ class Form::Sales::Subsections::SharedOwnershipScheme < ::Form::Subsection
Form::Sales::Pages::ValueSharedOwnership.new("value_shared_ownership", nil, self), Form::Sales::Pages::ValueSharedOwnership.new("value_shared_ownership", nil, self),
Form::Sales::Pages::AboutPriceValueCheck.new("about_price_shared_ownership_value_check", nil, self), Form::Sales::Pages::AboutPriceValueCheck.new("about_price_shared_ownership_value_check", nil, self),
Form::Sales::Pages::Equity.new("equity", nil, self), Form::Sales::Pages::Equity.new("equity", nil, self),
Form::Sales::Pages::SharedOwnershipDepositValueCheck.new("shared_ownership_equity_value_check", nil, self),
Form::Sales::Pages::Mortgageused.new("mortgage_used_shared_ownership", nil, self, ownershipsch: 1), Form::Sales::Pages::Mortgageused.new("mortgage_used_shared_ownership", nil, self, ownershipsch: 1),
Form::Sales::Pages::MortgageValueCheck.new("mortgage_used_mortgage_value_check", nil, self), Form::Sales::Pages::MortgageValueCheck.new("mortgage_used_mortgage_value_check", nil, self),
Form::Sales::Pages::MortgageAmount.new("mortgage_amount_shared_ownership", nil, self, ownershipsch: 1), Form::Sales::Pages::MortgageAmount.new("mortgage_amount_shared_ownership", nil, self, ownershipsch: 1),
Form::Sales::Pages::SharedOwnershipDepositValueCheck.new("shared_ownership_mortgage_amount_value_check", nil, self),
Form::Sales::Pages::MortgageValueCheck.new("mortgage_amount_mortgage_value_check", nil, self), Form::Sales::Pages::MortgageValueCheck.new("mortgage_amount_mortgage_value_check", nil, self),
Form::Sales::Pages::MortgageLender.new("mortgage_lender_shared_ownership", nil, self, ownershipsch: 1), Form::Sales::Pages::MortgageLender.new("mortgage_lender_shared_ownership", nil, self, ownershipsch: 1),
Form::Sales::Pages::MortgageLenderOther.new("mortgage_lender_other_shared_ownership", nil, self, ownershipsch: 1), Form::Sales::Pages::MortgageLenderOther.new("mortgage_lender_other_shared_ownership", nil, self, ownershipsch: 1),
@ -46,7 +44,6 @@ class Form::Sales::Subsections::SharedOwnershipScheme < ::Form::Subsection
Form::Sales::Pages::DepositValueCheck.new("deposit_value_check", nil, self, joint_purchase: false), Form::Sales::Pages::DepositValueCheck.new("deposit_value_check", nil, self, joint_purchase: false),
Form::Sales::Pages::DepositDiscount.new("deposit_discount", nil, self, optional: false), Form::Sales::Pages::DepositDiscount.new("deposit_discount", nil, self, optional: false),
(Form::Sales::Pages::DepositDiscount.new("deposit_discount_optional", nil, self, optional: true) if form.start_year_2024_or_later?), (Form::Sales::Pages::DepositDiscount.new("deposit_discount_optional", nil, self, optional: true) if form.start_year_2024_or_later?),
Form::Sales::Pages::SharedOwnershipDepositValueCheck.new("shared_ownership_deposit_value_check", nil, self),
Form::Sales::Pages::MonthlyRent.new(nil, nil, self), Form::Sales::Pages::MonthlyRent.new(nil, nil, self),
Form::Sales::Pages::LeaseholdCharges.new("leasehold_charges_shared_ownership", nil, self, ownershipsch: 1), Form::Sales::Pages::LeaseholdCharges.new("leasehold_charges_shared_ownership", nil, self, ownershipsch: 1),
Form::Sales::Pages::MonthlyChargesValueCheck.new("monthly_charges_shared_ownership_value_check", nil, self), Form::Sales::Pages::MonthlyChargesValueCheck.new("monthly_charges_shared_ownership_value_check", nil, self),

1
app/models/form/sales/subsections/shared_ownership_staircasing_transaction.rb

@ -21,7 +21,6 @@ class Form::Sales::Subsections::SharedOwnershipStaircasingTransaction < ::Form::
Form::Sales::Pages::ValueSharedOwnership.new("value_shared_ownership_staircase", nil, self), Form::Sales::Pages::ValueSharedOwnership.new("value_shared_ownership_staircase", nil, self),
Form::Sales::Pages::AboutPriceValueCheck.new("about_price_shared_ownership_value_check_staircasing", nil, self), Form::Sales::Pages::AboutPriceValueCheck.new("about_price_shared_ownership_value_check_staircasing", nil, self),
Form::Sales::Pages::Equity.new("staircase_equity", nil, self), Form::Sales::Pages::Equity.new("staircase_equity", nil, self),
Form::Sales::Pages::SharedOwnershipDepositValueCheck.new("shared_ownership_equity_value_check_staircasing", nil, self),
Form::Sales::Pages::Mortgageused.new("staircase_mortgage_used_shared_ownership", nil, self, ownershipsch: 1), Form::Sales::Pages::Mortgageused.new("staircase_mortgage_used_shared_ownership", nil, self, ownershipsch: 1),
Form::Sales::Pages::MonthlyRentStaircasingOwned.new(nil, nil, self), Form::Sales::Pages::MonthlyRentStaircasingOwned.new(nil, nil, self),
Form::Sales::Pages::MonthlyRentStaircasing.new(nil, nil, self), Form::Sales::Pages::MonthlyRentStaircasing.new(nil, nil, self),

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

@ -90,15 +90,6 @@ module Validations::Sales::SoftValidations
type == 24 && stairowned.between?(76, 100) type == 24 && stairowned.between?(76, 100)
end end
def shared_ownership_deposit_invalid?
return unless saledate && collection_start_year <= 2023
return unless mortgage || mortgageused == 2 || mortgageused == 3
return unless cashdis || !social_homebuy?
return unless deposit && value && equity
over_tolerance?(mortgage_deposit_and_discount_total, value * equity / 100, 1)
end
def mortgage_plus_deposit_less_than_discounted_value? def mortgage_plus_deposit_less_than_discounted_value?
return unless mortgage && deposit && value && discount return unless mortgage && deposit && value && discount
return if form.start_year_2026_or_later? return if form.start_year_2026_or_later?

44
spec/models/form/sales/pages/shared_ownership_deposit_value_check_spec.rb

@ -1,44 +0,0 @@
require "rails_helper"
RSpec.describe Form::Sales::Pages::SharedOwnershipDepositValueCheck, type: :model do
subject(:page) { described_class.new(page_id, page_definition, subsection) }
let(:page_id) { "shared_ownership_deposit_value_check" }
let(:page_definition) { nil }
let(:form) { instance_double(Form, start_date: Time.zone.local(2024, 4, 1)) }
let(:subsection) { instance_double(Form::Subsection, form:) }
it "has correct subsection" do
expect(page.subsection).to eq(subsection)
end
it "has correct questions" do
expect(page.questions.map(&:id)).to eq(%w[shared_ownership_deposit_value_check])
end
it "has the correct id" do
expect(page.id).to eq("shared_ownership_deposit_value_check")
end
it "has correct depends_on" do
expect(page.depends_on).to eq([
{
"shared_ownership_deposit_invalid?" => true,
},
])
end
it "has the correct title_text" do
expect(page.title_text).to eq({
"translation" => "forms.2024.sales.soft_validations.shared_ownership_deposit_value_check.title_text",
"arguments" => [
{ "i18n_template" => "mortgage_deposit_and_discount_error_fields", "key" => "mortgage_deposit_and_discount_error_fields" },
{ "arguments_for_key" => "mortgage_deposit_and_discount_total", "i18n_template" => "mortgage_deposit_and_discount_total", "key" => "field_formatted_as_currency" },
],
})
end
it "has the correct interruption_screen_question_ids" do
expect(page.interruption_screen_question_ids).to eq(%w[mortgage mortgageused cashdis type deposit value equity])
end
end

45
spec/models/form/sales/questions/shared_ownership_deposit_value_check_spec.rb

@ -1,45 +0,0 @@
require "rails_helper"
RSpec.describe Form::Sales::Questions::SharedOwnershipDepositValueCheck, type: :model do
subject(:question) { described_class.new(question_id, question_definition, page) }
let(:question_id) { nil }
let(:question_definition) { nil }
let(:page) { instance_double(Form::Page) }
it "has correct page" do
expect(question.page).to eq(page)
end
it "has the correct id" do
expect(question.id).to eq("shared_ownership_deposit_value_check")
end
it "has the correct type" do
expect(question.type).to eq("interruption_screen")
end
it "is not marked as derived" do
expect(question.derived?(nil)).to be false
end
it "has the correct answer_options" do
expect(question.answer_options).to eq({
"0" => { "value" => "Yes" },
"1" => { "value" => "No" },
})
end
it "has the correct hidden_in_check_answers" do
expect(question.hidden_in_check_answers).to eq({
"depends_on" => [
{
"shared_ownership_deposit_value_check" => 0,
},
{
"shared_ownership_deposit_value_check" => 1,
},
],
})
end
end

9
spec/models/form/sales/subsections/shared_ownership_initial_purchase_spec.rb

@ -43,11 +43,9 @@ RSpec.describe Form::Sales::Subsections::SharedOwnershipInitialPurchase, type: :
value_shared_ownership value_shared_ownership
about_price_shared_ownership_value_check about_price_shared_ownership_value_check
initial_equity initial_equity
shared_ownership_equity_value_check
mortgage_used_shared_ownership mortgage_used_shared_ownership
mortgage_used_mortgage_value_check mortgage_used_mortgage_value_check
mortgage_amount_shared_ownership mortgage_amount_shared_ownership
shared_ownership_mortgage_amount_value_check
mortgage_amount_mortgage_value_check mortgage_amount_mortgage_value_check
mortgage_length_shared_ownership mortgage_length_shared_ownership
deposit_shared_ownership deposit_shared_ownership
@ -56,7 +54,6 @@ RSpec.describe Form::Sales::Subsections::SharedOwnershipInitialPurchase, type: :
deposit_value_check deposit_value_check
deposit_discount deposit_discount
deposit_discount_optional deposit_discount_optional
shared_ownership_deposit_value_check
monthly_rent monthly_rent
service_charge service_charge
monthly_charges_initial_purchase_value_check monthly_charges_initial_purchase_value_check
@ -86,11 +83,9 @@ RSpec.describe Form::Sales::Subsections::SharedOwnershipInitialPurchase, type: :
value_shared_ownership value_shared_ownership
about_price_shared_ownership_value_check about_price_shared_ownership_value_check
initial_equity initial_equity
shared_ownership_equity_value_check
mortgage_used_shared_ownership mortgage_used_shared_ownership
mortgage_used_mortgage_value_check mortgage_used_mortgage_value_check
mortgage_amount_shared_ownership mortgage_amount_shared_ownership
shared_ownership_mortgage_amount_value_check
mortgage_amount_mortgage_value_check mortgage_amount_mortgage_value_check
mortgage_length_shared_ownership mortgage_length_shared_ownership
deposit_shared_ownership deposit_shared_ownership
@ -99,7 +94,6 @@ RSpec.describe Form::Sales::Subsections::SharedOwnershipInitialPurchase, type: :
deposit_value_check deposit_value_check
deposit_discount deposit_discount
deposit_discount_optional deposit_discount_optional
shared_ownership_deposit_value_check
monthly_rent monthly_rent
service_charge service_charge
monthly_charges_initial_purchase_value_check monthly_charges_initial_purchase_value_check
@ -128,11 +122,9 @@ RSpec.describe Form::Sales::Subsections::SharedOwnershipInitialPurchase, type: :
value_shared_ownership value_shared_ownership
about_price_shared_ownership_value_check about_price_shared_ownership_value_check
initial_equity initial_equity
shared_ownership_equity_value_check
mortgage_used_shared_ownership mortgage_used_shared_ownership
mortgage_used_mortgage_value_check mortgage_used_mortgage_value_check
mortgage_amount_shared_ownership mortgage_amount_shared_ownership
shared_ownership_mortgage_amount_value_check
mortgage_amount_mortgage_value_check mortgage_amount_mortgage_value_check
mortgage_length_shared_ownership_not_interviewed mortgage_length_shared_ownership_not_interviewed
mortgage_length_shared_ownership_interviewed mortgage_length_shared_ownership_interviewed
@ -142,7 +134,6 @@ RSpec.describe Form::Sales::Subsections::SharedOwnershipInitialPurchase, type: :
deposit_value_check deposit_value_check
deposit_discount deposit_discount
deposit_discount_optional deposit_discount_optional
shared_ownership_deposit_value_check
monthly_rent monthly_rent
service_charge service_charge
monthly_charges_initial_purchase_value_check monthly_charges_initial_purchase_value_check

3
spec/models/form/sales/subsections/shared_ownership_scheme_spec.rb

@ -39,11 +39,9 @@ RSpec.describe Form::Sales::Subsections::SharedOwnershipScheme, type: :model do
value_shared_ownership value_shared_ownership
about_price_shared_ownership_value_check about_price_shared_ownership_value_check
equity equity
shared_ownership_equity_value_check
mortgage_used_shared_ownership mortgage_used_shared_ownership
mortgage_used_mortgage_value_check mortgage_used_mortgage_value_check
mortgage_amount_shared_ownership mortgage_amount_shared_ownership
shared_ownership_mortgage_amount_value_check
mortgage_amount_mortgage_value_check mortgage_amount_mortgage_value_check
mortgage_lender_shared_ownership mortgage_lender_shared_ownership
mortgage_lender_other_shared_ownership mortgage_lender_other_shared_ownership
@ -53,7 +51,6 @@ RSpec.describe Form::Sales::Subsections::SharedOwnershipScheme, type: :model do
deposit_joint_purchase_value_check deposit_joint_purchase_value_check
deposit_value_check deposit_value_check
deposit_discount deposit_discount
shared_ownership_deposit_value_check
monthly_rent monthly_rent
leasehold_charges_shared_ownership leasehold_charges_shared_ownership
monthly_charges_shared_ownership_value_check monthly_charges_shared_ownership_value_check

2
spec/models/form/sales/subsections/shared_ownership_staircasing_transaction_spec.rb

@ -44,7 +44,6 @@ RSpec.describe Form::Sales::Subsections::SharedOwnershipStaircasingTransaction,
value_shared_ownership_staircase value_shared_ownership_staircase
about_price_shared_ownership_value_check_staircasing about_price_shared_ownership_value_check_staircasing
staircase_equity staircase_equity
shared_ownership_equity_value_check_staircasing
staircase_mortgage_used_shared_ownership staircase_mortgage_used_shared_ownership
monthly_rent_staircasing_owned monthly_rent_staircasing_owned
monthly_rent_staircasing monthly_rent_staircasing
@ -72,7 +71,6 @@ RSpec.describe Form::Sales::Subsections::SharedOwnershipStaircasingTransaction,
value_shared_ownership_staircase value_shared_ownership_staircase
about_price_shared_ownership_value_check_staircasing about_price_shared_ownership_value_check_staircasing
staircase_equity staircase_equity
shared_ownership_equity_value_check_staircasing
staircase_mortgage_used_shared_ownership staircase_mortgage_used_shared_ownership
monthly_rent_staircasing_owned monthly_rent_staircasing_owned
monthly_rent_staircasing monthly_rent_staircasing

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

@ -465,149 +465,6 @@ RSpec.describe Validations::Sales::SoftValidations do
.not_to be_deposit_over_soft_max .not_to be_deposit_over_soft_max
end end
end end
context "when validating shared ownership deposit" do
before do
record.saledate = Time.zone.local(2023, 4, 3)
end
it "returns false if MORTGAGE + DEPOSIT + CASHDIS are equal VALUE * EQUITY/100" do
record.mortgage = 1000
record.deposit = 1000
record.cashdis = 1000
record.value = 3000
record.equity = 100
expect(record)
.not_to be_shared_ownership_deposit_invalid
end
it "returns false if MORTGAGE + DEPOSIT + CASHDIS are within 1£ of VALUE * EQUITY/100" do
record.mortgage = 500
record.deposit = 500
record.cashdis = 500
record.value = 3001
record.equity = 50
expect(record)
.not_to be_shared_ownership_deposit_invalid
end
it "returns false if mortgage is used and no mortgage is given" do
record.mortgage = nil
record.deposit = 1000
record.cashdis = 1000
record.value = 3000
record.equity = 100
expect(record)
.not_to be_shared_ownership_deposit_invalid
end
it "returns true if mortgage is not used and no mortgage is given" do
record.mortgage = nil
record.mortgageused = 2
record.deposit = 1000
record.cashdis = 1000
record.value = 3000
record.equity = 100
expect(record)
.to be_shared_ownership_deposit_invalid
end
it "returns false if no deposit is given" do
record.mortgage = 1000
record.deposit = nil
record.cashdis = 1000
record.value = 3000
record.equity = 100
expect(record)
.not_to be_shared_ownership_deposit_invalid
end
it "returns false if no cashdis is given and cashdis is routed to" do
record.mortgage = 1000
record.deposit = 1000
record.type = 18
record.cashdis = nil
record.value = 3000
record.equity = 100
expect(record)
.not_to be_shared_ownership_deposit_invalid
end
it "returns true if no cashdis is given and cashdis is not routed to" do
record.mortgage = 1000
record.deposit = 1000
record.type = 2
record.cashdis = nil
record.value = 3000
record.equity = 100
expect(record)
.to be_shared_ownership_deposit_invalid
end
it "returns false if no cashdis not routed to and MORTGAGE + DEPOSIT are within 1£ of VALUE * EQUITY/100" do
record.mortgage = 500
record.deposit = 500
record.type = 2
record.cashdis = nil
record.value = 1999
record.equity = 50
expect(record)
.not_to be_shared_ownership_deposit_invalid
end
it "returns false if no value is given" do
record.mortgage = 1000
record.deposit = 1000
record.cashdis = 1000
record.value = nil
record.equity = 100
expect(record)
.not_to be_shared_ownership_deposit_invalid
end
it "returns false if no equity is given" do
record.mortgage = 1000
record.deposit = 1000
record.cashdis = 1000
record.value = 3000
record.equity = nil
expect(record)
.not_to be_shared_ownership_deposit_invalid
end
it "returns true if MORTGAGE + DEPOSIT + CASHDIS are not equal VALUE * EQUITY/100" do
record.mortgage = 1000
record.deposit = 1000
record.cashdis = 1000
record.value = 4323
record.equity = 100
expect(record)
.to be_shared_ownership_deposit_invalid
end
it "returns false if startyear is after 2024" do
record.saledate = Time.zone.local(2025, 1, 1)
record.mortgage = 1000
record.deposit = 1000
record.cashdis = 1000
record.value = 4323
record.equity = 100
expect(record)
.not_to be_shared_ownership_deposit_invalid
end
end
end end
describe "hodate_more_than_3_years_before_saledate" do describe "hodate_more_than_3_years_before_saledate" do

Loading…
Cancel
Save