Browse Source

feat: add condition-less soft validation and update db

pull/1201/head
natdeanlewissoftwire 3 years ago
parent
commit
0a39302363
  1. 23
      app/models/form/sales/pages/extra_borrowing_value_check.rb
  2. 23
      app/models/form/sales/questions/extra_borrowing_value_check.rb
  3. 1
      app/models/form/sales/subsections/discounted_ownership_scheme.rb
  4. 1
      app/models/form/sales/subsections/outright_sale.rb
  5. 1
      app/models/form/sales/subsections/shared_ownership_scheme.rb
  6. 4
      app/models/validations/sales/soft_validations.rb
  7. 3
      config/locales/en.yml
  8. 7
      db/migrate/20230118170602_add_extra_borrowing_value_check_to_sales.rb
  9. 13
      db/schema.rb

23
app/models/form/sales/pages/extra_borrowing_value_check.rb

@ -0,0 +1,23 @@
class Form::Sales::Pages::ExtraBorrowingValueCheck < Form::Page
def initialize(id, hsh, subsection)
super
@depends_on = [
{
"extra_borrowing_expected?" => true,
},
]
@title_text = {
"translation" => "soft_validations.extra_borrowing.title",
}
@informative_text = {
"translation" => "soft_validations.extra_borrowing.hint_text",
"arguments" => [],
}
end
def questions
@questions ||= [
Form::Sales::Questions::ExtraBorrowingValueCheck.new(nil, nil, self),
]
end
end

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

@ -0,0 +1,23 @@
class Form::Sales::Questions::ExtraBorrowingValueCheck < ::Form::Question
def initialize(id, hsh, page)
super(id, hsh, page)
@id = "extrabor_value_check"
@check_answer_label = "Extra borrowing confirmation"
@type = "interruption_screen"
@answer_options = {
"0" => { "value" => "Yes" },
"1" => { "value" => "No" },
}
@hidden_in_check_answers = {
"depends_on" => [
{
"extrabor_value_check" => 0,
},
{
"extrabor_value_check" => 1,
},
],
}
@header = "Are you sure this there is no extra borrowing?"
end
end

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

@ -18,6 +18,7 @@ class Form::Sales::Subsections::DiscountedOwnershipScheme < ::Form::Subsection
Form::Sales::Pages::MortgageLenderOther.new("mortgage_lender_other_discounted_ownership", nil, self),
Form::Sales::Pages::MortgageLength.new("mortgage_length_discounted_ownership", nil, self),
Form::Sales::Pages::ExtraBorrowing.new("extra_borrowing_discounted_ownership", nil, self),
Form::Sales::Pages::ExtraBorrowingValueCheck.new("extra_borrowing_value_check_discounted_ownership", nil, self),
Form::Sales::Pages::AboutDepositWithoutDiscount.new("about_deposit_discounted_ownership", nil, self),
Form::Sales::Pages::DepositValueCheck.new("discounted_ownership_deposit_value_check", nil, self),
Form::Sales::Pages::LeaseholdCharges.new("leasehold_charges_discounted_ownership", nil, self),

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

@ -15,6 +15,7 @@ class Form::Sales::Subsections::OutrightSale < ::Form::Subsection
Form::Sales::Pages::MortgageLenderOther.new("mortgage_lender_other_outright_sale", nil, self),
Form::Sales::Pages::MortgageLength.new("mortgage_length_outright_sale", nil, self),
Form::Sales::Pages::ExtraBorrowing.new("extra_borrowing_outright_sale", nil, self),
Form::Sales::Pages::ExtraBorrowingValueCheck.new("extra_borrowing_value_check_outright_sale", nil, self),
Form::Sales::Pages::AboutDepositWithoutDiscount.new("about_deposit_outright_sale", nil, self),
Form::Sales::Pages::DepositValueCheck.new("outright_sale_deposit_value_check", nil, self),
Form::Sales::Pages::LeaseholdCharges.new("leasehold_charges_outright_sale", nil, self),

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

@ -26,6 +26,7 @@ class Form::Sales::Subsections::SharedOwnershipScheme < ::Form::Subsection
Form::Sales::Pages::MortgageLenderOther.new("mortgage_lender_other_shared_ownership", nil, self),
Form::Sales::Pages::MortgageLength.new("mortgage_length_shared_ownership", nil, self),
Form::Sales::Pages::ExtraBorrowing.new("extra_borrowing_shared_ownership", nil, self),
Form::Sales::Pages::ExtraBorrowingValueCheck.new("extra_borrowing_value_check_shared_ownership", nil, self),
Form::Sales::Pages::AboutDepositWithDiscount.new(nil, nil, self),
Form::Sales::Pages::AboutDepositWithoutDiscount.new("about_deposit_shared_ownership", nil, self),
Form::Sales::Pages::DepositValueCheck.new("shared_ownership_deposit_value_check", nil, self),

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

@ -36,4 +36,8 @@ module Validations::Sales::SoftValidations
deposit > savings * 4 / 3
end
def extra_borrowing_expected?
true
end
end

3
config/locales/en.yml

@ -410,6 +410,9 @@ en:
max:
title: "You told us this person is %{age} or over and not retired"
hint_text: "The minimum expected retirement age for %{gender} in England is %{age}."
extra_borrowing:
title: "You told us this doesn't include any extra borrowing"
hint_text: "The mortgage and deposit are higher than the purchase minus the discount"
pregnancy:
title: "You told us somebody in the household is pregnant"
no_females: "You also told us there are no female tenants living at the property."

7
db/migrate/20230118170602_add_extra_borrowing_value_check_to_sales.rb

@ -0,0 +1,7 @@
class AddExtraBorrowingValueCheckToSales < ActiveRecord::Migration[7.0]
def change
change_table :sales_logs, bulk: true do |t|
t.column :extrabor_value_check, :integer
end
end
end

13
db/schema.rb

@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[7.0].define(version: 2023_01_13_125117) do
ActiveRecord::Schema[7.0].define(version: 2023_01_18_170602) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -488,16 +488,17 @@ ActiveRecord::Schema[7.0].define(version: 2023_01_13_125117) do
t.integer "mortgagelender"
t.string "mortgagelenderother"
t.integer "mortlen"
t.string "pcode1"
t.string "pcode2"
t.integer "pcodenk"
t.string "postcode_full"
t.boolean "is_la_inferred"
t.integer "extrabor"
t.integer "hhmemb"
t.integer "totadult"
t.integer "totchild"
t.integer "hhtype"
t.string "pcode1"
t.string "pcode2"
t.integer "pcodenk"
t.string "postcode_full"
t.boolean "is_la_inferred"
t.integer "extrabor_value_check"
t.index ["created_by_id"], name: "index_sales_logs_on_created_by_id"
t.index ["managing_organisation_id"], name: "index_sales_logs_on_managing_organisation_id"
t.index ["owning_organisation_id"], name: "index_sales_logs_on_owning_organisation_id"

Loading…
Cancel
Save