Browse Source

Rename method

pull/2313/head
Kat 2 years ago
parent
commit
71c5e0f6e7
  1. 4
      app/models/form/sales/pages/about_deposit_with_discount.rb
  2. 4
      app/models/form/sales/pages/about_deposit_without_discount.rb
  3. 2
      app/models/sales_log.rb
  4. 2
      app/models/validations/sales/soft_validations.rb
  5. 8
      spec/models/form/sales/pages/about_deposit_with_discount_spec.rb
  6. 8
      spec/models/form/sales/pages/about_deposit_without_discount_spec.rb

4
app/models/form/sales/pages/about_deposit_with_discount.rb

@ -14,9 +14,9 @@ class Form::Sales::Pages::AboutDepositWithDiscount < ::Form::Page
def depends_on def depends_on
if form.start_year_after_2024? if form.start_year_after_2024?
[{ "is_type_discount?" => true, "stairowned_100?" => @optional }] [{ "social_homebuy?" => true, "stairowned_100?" => @optional }]
else else
[{ "is_type_discount?" => true }] [{ "social_homebuy?" => true }]
end end
end end
end end

4
app/models/form/sales/pages/about_deposit_without_discount.rb

@ -14,11 +14,11 @@ class Form::Sales::Pages::AboutDepositWithoutDiscount < ::Form::Page
def depends_on def depends_on
if form.start_year_after_2024? if form.start_year_after_2024?
[{ "is_type_discount?" => false, "ownershipsch" => 1, "stairowned_100?" => @optional }, [{ "social_homebuy?" => false, "ownershipsch" => 1, "stairowned_100?" => @optional },
{ "ownershipsch" => 2 }, { "ownershipsch" => 2 },
{ "ownershipsch" => 3, "mortgageused" => 1 }] { "ownershipsch" => 3, "mortgageused" => 1 }]
else else
[{ "is_type_discount?" => false, "ownershipsch" => 1 }, [{ "social_homebuy?" => false, "ownershipsch" => 1 },
{ "ownershipsch" => 2 }, { "ownershipsch" => 2 },
{ "ownershipsch" => 3, "mortgageused" => 1 }] { "ownershipsch" => 3, "mortgageused" => 1 }]
end end

2
app/models/sales_log.rb

@ -239,7 +239,7 @@ class SalesLog < Log
ownershipsch == 3 || (ownershipsch == 2 && rent_to_buy_full_ownership?) ownershipsch == 3 || (ownershipsch == 2 && rent_to_buy_full_ownership?)
end end
def is_type_discount? def social_homebuy?
type == 18 type == 18
end end

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

@ -86,7 +86,7 @@ module Validations::Sales::SoftValidations
def shared_ownership_deposit_invalid? def shared_ownership_deposit_invalid?
return unless saledate && collection_start_year <= 2023 return unless saledate && collection_start_year <= 2023
return unless mortgage || mortgageused == 2 || mortgageused == 3 return unless mortgage || mortgageused == 2 || mortgageused == 3
return unless cashdis || !is_type_discount? return unless cashdis || !social_homebuy?
return unless deposit && value && equity return unless deposit && value && equity
!within_tolerance?(mortgage_deposit_and_discount_total, value * equity / 100, 1) !within_tolerance?(mortgage_deposit_and_discount_total, value * equity / 100, 1)

8
spec/models/form/sales/pages/about_deposit_with_discount_spec.rb

@ -33,7 +33,7 @@ RSpec.describe Form::Sales::Pages::AboutDepositWithDiscount, type: :model do
it "has correct depends_on" do it "has correct depends_on" do
expect(page.depends_on).to eq( expect(page.depends_on).to eq(
[{ "is_type_discount?" => true }], [{ "social_homebuy?" => true }],
) )
end end
@ -42,7 +42,7 @@ RSpec.describe Form::Sales::Pages::AboutDepositWithDiscount, type: :model do
it "has correct depends_on" do it "has correct depends_on" do
expect(page.depends_on).to eq( expect(page.depends_on).to eq(
[{ "is_type_discount?" => true }], [{ "social_homebuy?" => true }],
) )
end end
end end
@ -54,7 +54,7 @@ RSpec.describe Form::Sales::Pages::AboutDepositWithDiscount, type: :model do
it "has correct depends_on" do it "has correct depends_on" do
expect(page.depends_on).to eq( expect(page.depends_on).to eq(
[{ "is_type_discount?" => true, "stairowned_100?" => false }], [{ "social_homebuy?" => true, "stairowned_100?" => false }],
) )
end end
@ -63,7 +63,7 @@ RSpec.describe Form::Sales::Pages::AboutDepositWithDiscount, type: :model do
it "has correct depends_on" do it "has correct depends_on" do
expect(page.depends_on).to eq( expect(page.depends_on).to eq(
[{ "is_type_discount?" => true, "stairowned_100?" => true }], [{ "social_homebuy?" => true, "stairowned_100?" => true }],
) )
end end
end end

8
spec/models/form/sales/pages/about_deposit_without_discount_spec.rb

@ -33,7 +33,7 @@ RSpec.describe Form::Sales::Pages::AboutDepositWithoutDiscount, type: :model do
it "has correct depends_on" do it "has correct depends_on" do
expect(page.depends_on).to eq( expect(page.depends_on).to eq(
[{ "is_type_discount?" => false, "ownershipsch" => 1 }, [{ "social_homebuy?" => false, "ownershipsch" => 1 },
{ "ownershipsch" => 2 }, { "ownershipsch" => 2 },
{ "ownershipsch" => 3, "mortgageused" => 1 }], { "ownershipsch" => 3, "mortgageused" => 1 }],
) )
@ -44,7 +44,7 @@ RSpec.describe Form::Sales::Pages::AboutDepositWithoutDiscount, type: :model do
it "has correct depends_on" do it "has correct depends_on" do
expect(page.depends_on).to eq( expect(page.depends_on).to eq(
[{ "is_type_discount?" => false, "ownershipsch" => 1 }, [{ "social_homebuy?" => false, "ownershipsch" => 1 },
{ "ownershipsch" => 2 }, { "ownershipsch" => 2 },
{ "ownershipsch" => 3, "mortgageused" => 1 }], { "ownershipsch" => 3, "mortgageused" => 1 }],
) )
@ -58,7 +58,7 @@ RSpec.describe Form::Sales::Pages::AboutDepositWithoutDiscount, type: :model do
it "has correct depends_on" do it "has correct depends_on" do
expect(page.depends_on).to eq( expect(page.depends_on).to eq(
[{ "is_type_discount?" => false, "ownershipsch" => 1, "stairowned_100?" => false }, [{ "social_homebuy?" => false, "ownershipsch" => 1, "stairowned_100?" => false },
{ "ownershipsch" => 2 }, { "ownershipsch" => 2 },
{ "ownershipsch" => 3, "mortgageused" => 1 }], { "ownershipsch" => 3, "mortgageused" => 1 }],
) )
@ -69,7 +69,7 @@ RSpec.describe Form::Sales::Pages::AboutDepositWithoutDiscount, type: :model do
it "has correct depends_on" do it "has correct depends_on" do
expect(page.depends_on).to eq( expect(page.depends_on).to eq(
[{ "is_type_discount?" => false, "ownershipsch" => 1, "stairowned_100?" => true }, [{ "social_homebuy?" => false, "ownershipsch" => 1, "stairowned_100?" => true },
{ "ownershipsch" => 2 }, { "ownershipsch" => 2 },
{ "ownershipsch" => 3, "mortgageused" => 1 }], { "ownershipsch" => 3, "mortgageused" => 1 }],
) )

Loading…
Cancel
Save