Browse Source

fix rebase conflicts

pull/1235/head
Arthur Campbell 3 years ago
parent
commit
d7ae2fa3cf
  1. 27
      app/models/form/sales/pages/staircase_bought_value_check.rb
  2. 23
      app/models/form/sales/questions/staircase_bought_value_check.rb
  3. 1
      app/models/form/sales/subsections/shared_ownership_scheme.rb
  4. 4
      app/models/validations/sales/soft_validations.rb
  5. 5
      db/migrate/20230125152916_add_staircase_bought_value_check_to_sales_log.rb
  6. 1
      spec/models/form/sales/subsections/shared_ownership_scheme_spec.rb
  7. 22
      spec/models/validations/sales/soft_validations_spec.rb

27
app/models/form/sales/pages/staircase_bought_value_check.rb

@ -0,0 +1,27 @@
class Form::Sales::Pages::StaircaseBoughtValueCheck < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "staircase_bought_value_check"
@depends_on = [
{
"staircase_bought_above_fifty?" => true,
},
]
@title_text = {
"translation" => "soft_validations.staircase_bought_seems_high",
"arguments" => [
{
"key" => "stairbought",
"i18n_template" => "percentage",
}
]
}
@informative_text = {}
end
def questions
@questions ||= [
Form::Sales::Questions::StaircaseBoughtValueCheck.new(nil, nil, self),
]
end
end

23
app/models/form/sales/questions/staircase_bought_value_check.rb

@ -0,0 +1,23 @@
class Form::Sales::Questions::StaircaseBoughtValueCheck < ::Form::Question
def initialize(id, hsh, page)
super
@id = "staircase_bought_value_check"
@check_answer_label = "Percentage bought confirmation"
@header = "Are you sure this is correct?"
@type = "interruption_screen"
@answer_options = {
"0" => { "value" => "Yes" },
"1" => { "value" => "No" },
}
@hidden_in_check_answers = {
"depends_on" => [
{
"staircase_bought_value_check" => 0,
},
{
"staircase_bought_value_check" => 1,
},
],
}
end
end

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

@ -11,6 +11,7 @@ class Form::Sales::Subsections::SharedOwnershipScheme < ::Form::Subsection
Form::Sales::Pages::LivingBeforePurchase.new("living_before_purchase_shared_ownership", nil, self),
Form::Sales::Pages::Staircase.new(nil, nil, self),
Form::Sales::Pages::AboutStaircase.new(nil, nil, self),
Form::Sales::Pages::StaircaseBoughtValueCheck.new(nil, nil, self),
Form::Sales::Pages::Resale.new(nil, nil, self),
Form::Sales::Pages::ExchangeDate.new(nil, nil, self),
Form::Sales::Pages::HandoverDate.new(nil, nil, self),

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

@ -13,6 +13,10 @@ module Validations::Sales::SoftValidations
income1 < ALLOWED_INCOME_RANGES[ecstat1][:soft_min]
end
def staircase_bought_above_fifty?
stairbought && stairbought > 50
end
def mortgage_over_soft_max?
return false unless mortgage && inc1mort && inc2mort
return false if income1_used_for_mortgage? && income1.blank? || income2_used_for_mortgage? && income2.blank?

5
db/migrate/20230125152916_add_staircase_bought_value_check_to_sales_log.rb

@ -0,0 +1,5 @@
class AddStaircaseBoughtValueCheckToSalesLog < ActiveRecord::Migration[7.0]
def change
add_column :sales_logs, :staircase_bought_value_check, :integer
end
end

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

@ -17,6 +17,7 @@ RSpec.describe Form::Sales::Subsections::SharedOwnershipScheme, type: :model do
living_before_purchase_shared_ownership
staircasing
about_staircasing
staircase_bought_value_check
resale
exchange_contracts
handover_date

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

@ -367,7 +367,7 @@ RSpec.describe Validations::Sales::SoftValidations do
.to be_deposit_over_soft_max
end
it "returns fals if deposit is less than 4/3 of savings" do
it "returns false if deposit is less than 4/3 of savings" do
record.deposit = 7_999
record.savings = 6_000
expect(record)
@ -573,4 +573,24 @@ RSpec.describe Validations::Sales::SoftValidations do
expect(record).not_to be_grant_outside_common_range
end
end
describe "#staircase_bought_above_fifty" do
it "returns false when stairbought is not set" do
record.stairbought = nil
expect(record).not_to be_staircase_bought_above_fifty
end
it "returns false when stairbought is below fifty" do
record.stairbought = 40
expect(record).not_to be_staircase_bought_above_fifty
end
it "returns true when stairbought is above fifty" do
record.stairbought = 70
expect(record).to be_staircase_bought_above_fifty
end
end
end

Loading…
Cancel
Save