diff --git a/app/models/form/sales/pages/about_deposit.rb b/app/models/form/sales/pages/about_deposit.rb new file mode 100644 index 000000000..8557c6668 --- /dev/null +++ b/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 \ No newline at end of file diff --git a/app/models/form/sales/questions/deposit_amount.rb b/app/models/form/sales/questions/deposit_amount.rb new file mode 100644 index 000000000..1b881ddfb --- /dev/null +++ b/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 \ No newline at end of file diff --git a/app/models/form/sales/questions/deposit_discount.rb b/app/models/form/sales/questions/deposit_discount.rb new file mode 100644 index 000000000..66bfee668 --- /dev/null +++ b/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 \ No newline at end of file diff --git a/app/models/form/sales/subsections/discounted_ownership_scheme.rb b/app/models/form/sales/subsections/discounted_ownership_scheme.rb index ea67d3566..7ade43da6 100644 --- a/app/models/form/sales/subsections/discounted_ownership_scheme.rb +++ b/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) diff --git a/app/models/form/sales/subsections/outright_sale.rb b/app/models/form/sales/subsections/outright_sale.rb index 82f5bd055..214943e7e 100644 --- a/app/models/form/sales/subsections/outright_sale.rb +++ b/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) diff --git a/app/models/form/sales/subsections/shared_ownership_scheme.rb b/app/models/form/sales/subsections/shared_ownership_scheme.rb index f4b02a9e5..c8995fda3 100644 --- a/app/models/form/sales/subsections/shared_ownership_scheme.rb +++ b/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), ] diff --git a/db/migrate/20221221164308_add_deposit_fields_to_sales.rb b/db/migrate/20221221164308_add_deposit_fields_to_sales.rb new file mode 100644 index 000000000..82087110f --- /dev/null +++ b/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 diff --git a/db/schema.rb b/db/schema.rb index d616fd6d5..4df4e8a37 100644 --- a/db/schema.rb +++ b/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"