Browse Source

feat: add question(s) without depends_on behaviour

pull/1113/head
natdeanlewissoftwire 4 years ago
parent
commit
38d1caaecf
  1. 16
      app/models/form/sales/pages/about_deposit.rb
  2. 14
      app/models/form/sales/questions/deposit_amount.rb
  3. 14
      app/models/form/sales/questions/deposit_discount.rb
  4. 4
      app/models/form/sales/subsections/discounted_ownership_scheme.rb
  5. 4
      app/models/form/sales/subsections/outright_sale.rb
  6. 1
      app/models/form/sales/subsections/shared_ownership_scheme.rb
  7. 8
      db/migrate/20221221164308_add_deposit_fields_to_sales.rb
  8. 6
      db/schema.rb

16
app/models/form/sales/pages/about_deposit.rb

@ -0,0 +1,16 @@
class Form::Sales::Pages::AboutDeposit < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "about_deposit"
@header = "About the deposit"
@description = ""
@subsection = subsection
end
def questions
@questions ||= [
Form::Sales::Questions::DepositAmount.new(nil, nil, self),
Form::Sales::Questions::DepositDiscount.new(nil, nil, self),
]
end
end

14
app/models/form/sales/questions/deposit_amount.rb

@ -0,0 +1,14 @@
class Form::Sales::Questions::DepositAmount < ::Form::Question
def initialize(id, hsh, page)
super
@id = "deposit"
@check_answer_label = "Cash deposit"
@header = "How much cash deposit was paid on the property?"
@type = "numeric"
@page = page
@min = 0
@width = 5
@prefix = "£"
@hint_text = "Enter the total cash sum paid by the buyer towards the property that was not funded by the mortgage"
end
end

14
app/models/form/sales/questions/deposit_discount.rb

@ -0,0 +1,14 @@
class Form::Sales::Questions::DepositDiscount < ::Form::Question
def initialize(id, hsh, page)
super
@id = "cashdis"
@check_answer_label = "Cash discount through SocialHomeBuy"
@header = "How much cash discount was given through Social HomeBuy?"
@type = "numeric"
@page = page
@min = 0
@width = 5
@prefix = "£"
@hint_text = " Enter the total cash discount given on the property being purchased through the Social HomeBuy scheme"
end
end

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

@ -8,7 +8,9 @@ class Form::Sales::Subsections::DiscountedOwnershipScheme < ::Form::Subsection
end
def pages
@pages ||= []
@pages ||= [
Form::Sales::Pages::AboutDeposit.new(nil, nil, self),
]
end
def displayed_in_tasklist?(log)

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

@ -8,7 +8,9 @@ class Form::Sales::Subsections::OutrightSale < ::Form::Subsection
end
def pages
@pages ||= []
@pages ||= [
Form::Sales::Pages::AboutDeposit.new(nil, nil, self),
]
end
def displayed_in_tasklist?(log)

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

@ -12,6 +12,7 @@ class Form::Sales::Subsections::SharedOwnershipScheme < ::Form::Subsection
Form::Sales::Pages::Staircase.new(nil, nil, self),
Form::Sales::Pages::AboutStaircase.new(nil, nil, self),
Form::Sales::Pages::PreviousBedrooms.new(nil, nil, self),
Form::Sales::Pages::AboutDeposit.new(nil, nil, self),
Form::Sales::Pages::MonthlyRent.new(nil, nil, self),
Form::Sales::Pages::ExchangeDate.new(nil, nil, self),
]

8
db/migrate/20221221164308_add_deposit_fields_to_sales.rb

@ -0,0 +1,8 @@
class AddDepositFieldsToSales < ActiveRecord::Migration[7.0]
def change
change_table :sales_logs, bulk: true do |t|
t.column :deposit, :decimal, precision: 10, scale: 2
t.column :cashdis, :decimal, precision: 10, scale: 2
end
end
end

6
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: 2022_12_21_122233) do
ActiveRecord::Schema[7.0].define(version: 2022_12_21_164308) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -405,12 +405,12 @@ ActiveRecord::Schema[7.0].define(version: 2022_12_21_122233) do
t.integer "savings"
t.integer "prevown"
t.string "sex3"
t.bigint "updated_by_id"
t.integer "details_known_1"
t.integer "income1_value_check"
t.integer "mortgage"
t.integer "inc2mort"
t.integer "mortgage_value_check"
t.bigint "updated_by_id"
t.integer "ecstat3"
t.integer "ecstat4"
t.integer "ecstat5"
@ -425,6 +425,8 @@ ActiveRecord::Schema[7.0].define(version: 2022_12_21_122233) do
t.integer "exmonth"
t.integer "exyear"
t.integer "resale"
t.decimal "deposit", precision: 10, scale: 2
t.decimal "cashdis", precision: 10, scale: 2
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