Browse Source

feat: wip behaviour

pull/1225/head
natdeanlewissoftwire 2 years ago
parent
commit
d2cd5b0b0a
  1. 18
      app/models/form/sales/pages/about_price_shared_ownership_value_check.rb
  2. 27
      app/models/form/sales/questions/about_price_shared_ownership_value_check.rb
  3. 1
      app/models/form/sales/subsections/shared_ownership_scheme.rb
  4. 6
      app/models/validations/sales/soft_validations.rb
  5. 5
      db/migrate/20230123171907_add_about_price_shared_ownership_value_check_to_sales_log.rb
  6. 4
      db/schema.rb

18
app/models/form/sales/pages/about_price_shared_ownership_value_check.rb

@ -0,0 +1,18 @@
class Form::Sales::Pages::AboutPriceSharedOwnershipValueCheck < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "about_price_shared_ownership_value_check"
@depends_on = [
{
"purchase_price_out_of_expected_range?" => true,
},
]
@informative_text = {}
end
def questions
@questions ||= [
Form::Sales::Questions::AboutPriceSharedOwnershipValueCheck.new(nil, nil, self),
]
end
end

27
app/models/form/sales/questions/about_price_shared_ownership_value_check.rb

@ -0,0 +1,27 @@
class Form::Sales::Questions::AboutPriceSharedOwnershipValueCheck < ::Form::Question
def initialize(id, hsh, page)
super
@id = "value_value_check"
@check_answer_label = "Deposit confirmation"
@header = "Are you sure? You said purchase price was #{log.value}, which seems #{value_is_high?(log.value) ? 'high' : 'low'}"
@type = "interruption_screen"
@answer_options = {
"0" => { "value" => "Yes" },
"1" => { "value" => "No" },
}
@hidden_in_check_answers = {
"depends_on" => [
{
"value_value_check" => 0,
},
{
"value_value_check" => 1,
},
],
}
end
def value_is_high?(value)
true
end
end

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

@ -21,6 +21,7 @@ class Form::Sales::Subsections::SharedOwnershipScheme < ::Form::Subsection
Form::Sales::Pages::PreviousPropertyType.new(nil, nil, self),
Form::Sales::Pages::PreviousTenure.new(nil, nil, self),
Form::Sales::Pages::AboutPriceSharedOwnership.new(nil, nil, self),
Form::Sales::Pages::AboutPriceSharedOwnershipValueCheck.new(nil, nil, self),
Form::Sales::Pages::Mortgageused.new("mortgage_used_shared_ownership", nil, self),
Form::Sales::Pages::MortgageAmount.new("mortgage_amount_shared_ownership", nil, self),
Form::Sales::Pages::MortgageLender.new("mortgage_lender_shared_ownership", nil, self),

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

@ -42,4 +42,10 @@ module Validations::Sales::SoftValidations
((saledate.to_date - hodate.to_date).to_i / 365) >= 3
end
def purchase_price_out_of_expected_range?
return unless value
true
end
end

5
db/migrate/20230123171907_add_about_price_shared_ownership_value_check_to_sales_log.rb

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

4
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_16_151942) do
ActiveRecord::Schema[7.0].define(version: 2023_01_23_171907) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -499,6 +499,8 @@ ActiveRecord::Schema[7.0].define(version: 2023_01_16_151942) do
t.string "postcode_full"
t.boolean "is_la_inferred"
t.integer "hodate_check"
t.integer "extrabor_value_check"
t.integer "value_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