Browse Source

Cldc 1545 about the deposit (#1113)

* feat: add question(s) without depends_on behaviour

* feat: separate ids for diff sections

* test: update tests

* test: add tests

* tests: test tweaks

* refactor: linting

* Cldc 1538 la nominations (#1115)

* Add la nominations column to sales logs table

* Add La nominations page and questions

* Add la nominations to the shared ownership subsection

* Add accidentally removed files

* feat: add question(s) without depends_on behaviour

Co-authored-by: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com>
pull/1116/head
natdeanlewissoftwire 2 years ago committed by GitHub
parent
commit
975dd5fcd5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 15
      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. 4
      db/schema.rb
  9. 2
      spec/factories/sales_log.rb
  10. 33
      spec/models/form/sales/pages/about_deposit_spec.rb
  11. 49
      spec/models/form/sales/questions/deposit_amount_spec.rb
  12. 49
      spec/models/form/sales/questions/deposit_discount_spec.rb
  13. 2
      spec/models/form/sales/subsections/discounted_ownership_scheme_spec.rb
  14. 2
      spec/models/form/sales/subsections/outright_sale_spec.rb
  15. 1
      spec/models/form/sales/subsections/shared_ownership_scheme_spec.rb
  16. 4
      spec/models/form_handler_spec.rb

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

@ -0,0 +1,15 @@
class Form::Sales::Pages::AboutDeposit < ::Form::Page
def initialize(id, hsh, subsection)
super
@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("about_deposit_discounted_ownership", 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("about_deposit_outright_sale", nil, self),
]
end
def displayed_in_tasklist?(log)

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

@ -13,6 +13,7 @@ class Form::Sales::Subsections::SharedOwnershipScheme < ::Form::Subsection
Form::Sales::Pages::AboutStaircase.new(nil, nil, self),
Form::Sales::Pages::LaNominations.new(nil, nil, self),
Form::Sales::Pages::PreviousBedrooms.new(nil, nil, self),
Form::Sales::Pages::AboutDeposit.new("about_deposit_shared_ownership", 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

4
db/schema.rb

@ -405,12 +405,12 @@ ActiveRecord::Schema[7.0].define(version: 2022_12_22_081402) 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"
@ -424,6 +424,8 @@ ActiveRecord::Schema[7.0].define(version: 2022_12_22_081402) 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.decimal "mrent", precision: 10, scale: 2
t.integer "lanomagr"
t.index ["created_by_id"], name: "index_sales_logs_on_created_by_id"

2
spec/factories/sales_log.rb

@ -67,6 +67,8 @@ FactoryBot.define do
ecstat4 { 3 }
ecstat5 { 2 }
ecstat6 { 1 }
deposit { 10_000 }
cashdis { 1_000 }
end
end
end

33
spec/models/form/sales/pages/about_deposit_spec.rb

@ -0,0 +1,33 @@
require "rails_helper"
RSpec.describe Form::Sales::Pages::AboutDeposit, type: :model do
subject(:page) { described_class.new(page_id, page_definition, subsection) }
let(:page_id) { nil }
let(:page_definition) { nil }
let(:subsection) { instance_double(Form::Subsection) }
it "has correct subsection" do
expect(page.subsection).to eq(subsection)
end
it "has correct questions" do
expect(page.questions.map(&:id)).to eq(%w[deposit cashdis])
end
it "has the correct id" do
expect(page.id).to eq(nil)
end
it "has the correct header" do
expect(page.header).to eq("About the deposit")
end
it "has the correct description" do
expect(page.description).to eq("")
end
it "has correct depends_on" do
expect(page.depends_on).to be_nil
end
end

49
spec/models/form/sales/questions/deposit_amount_spec.rb

@ -0,0 +1,49 @@
require "rails_helper"
RSpec.describe Form::Sales::Questions::DepositAmount, type: :model do
subject(:question) { described_class.new(question_id, question_definition, page) }
let(:question_id) { nil }
let(:question_definition) { nil }
let(:page) { instance_double(Form::Page) }
it "has correct page" do
expect(question.page).to eq(page)
end
it "has the correct id" do
expect(question.id).to eq("deposit")
end
it "has the correct header" do
expect(question.header).to eq("How much cash deposit was paid on the property?")
end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("Cash deposit")
end
it "has the correct type" do
expect(question.type).to eq("numeric")
end
it "is not marked as derived" do
expect(question.derived?).to be false
end
it "has the correct hint" do
expect(question.hint_text).to eq("Enter the total cash sum paid by the buyer towards the property that was not funded by the mortgage")
end
it "has correct width" do
expect(question.width).to eq(5)
end
it "has correct prefix" do
expect(question.prefix).to eq("£")
end
it "has correct min" do
expect(question.min).to eq(0)
end
end

49
spec/models/form/sales/questions/deposit_discount_spec.rb

@ -0,0 +1,49 @@
require "rails_helper"
RSpec.describe Form::Sales::Questions::DepositDiscount, type: :model do
subject(:question) { described_class.new(question_id, question_definition, page) }
let(:question_id) { nil }
let(:question_definition) { nil }
let(:page) { instance_double(Form::Page) }
it "has correct page" do
expect(question.page).to eq(page)
end
it "has the correct id" do
expect(question.id).to eq("cashdis")
end
it "has the correct header" do
expect(question.header).to eq("How much cash discount was given through Social HomeBuy?")
end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("Cash discount through SocialHomeBuy")
end
it "has the correct type" do
expect(question.type).to eq("numeric")
end
it "is not marked as derived" do
expect(question.derived?).to be false
end
it "has the correct hint" do
expect(question.hint_text).to eq("Enter the total cash discount given on the property being purchased through the Social HomeBuy scheme")
end
it "has correct width" do
expect(question.width).to eq(5)
end
it "has correct prefix" do
expect(question.prefix).to eq("£")
end
it "has correct min" do
expect(question.min).to eq(0)
end
end

2
spec/models/form/sales/subsections/discounted_ownership_scheme_spec.rb

@ -13,7 +13,7 @@ RSpec.describe Form::Sales::Subsections::DiscountedOwnershipScheme, type: :model
it "has correct pages" do
expect(discounted_ownership_scheme.pages.map(&:id)).to eq(
%w[],
%w[about_deposit_discounted_ownership],
)
end

2
spec/models/form/sales/subsections/outright_sale_spec.rb

@ -13,7 +13,7 @@ RSpec.describe Form::Sales::Subsections::OutrightSale, type: :model do
it "has correct pages" do
expect(outright_sale.pages.map(&:id)).to eq(
%w[],
%w[about_deposit_outright_sale],
)
end

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

@ -18,6 +18,7 @@ RSpec.describe Form::Sales::Subsections::SharedOwnershipScheme, type: :model do
about_staircasing
la_nominations
previous_bedrooms
about_deposit_shared_ownership
monthly_rent
exchange_contracts
],

4
spec/models/form_handler_spec.rb

@ -52,14 +52,14 @@ RSpec.describe FormHandler do
it "is able to load a current sales form" do
form = form_handler.get_form("current_sales")
expect(form).to be_a(Form)
expect(form.pages.count).to eq(74)
expect(form.pages.count).to eq(77)
expect(form.name).to eq("2022_2023_sales")
end
it "is able to load a previous sales form" do
form = form_handler.get_form("previous_sales")
expect(form).to be_a(Form)
expect(form.pages.count).to eq(74)
expect(form.pages.count).to eq(77)
expect(form.name).to eq("2021_2022_sales")
end
end

Loading…
Cancel
Save