Browse Source
* add price fields to the sales logs table * Add about proce questions * add about proce pages * Add about price pages to sale information sectionspull/1130/head
25 changed files with 512 additions and 3 deletions
@ -0,0 +1,18 @@
|
||||
class Form::Sales::Pages::AboutPrice < ::Form::Page |
||||
def initialize(id, hsh, subsection) |
||||
super |
||||
@id = "about_price" |
||||
@header = "About the price of the property" |
||||
@description = "" |
||||
@subsection = subsection |
||||
@depends_on = [{ |
||||
"soctenant" => 2, |
||||
}] |
||||
end |
||||
|
||||
def questions |
||||
@questions ||= [ |
||||
Form::Sales::Questions::Value.new(nil, nil, self), |
||||
] |
||||
end |
||||
end |
||||
@ -0,0 +1,19 @@
|
||||
class Form::Sales::Pages::AboutPriceNotRtb < ::Form::Page |
||||
def initialize(id, hsh, subsection) |
||||
super |
||||
@id = "about_price_not_rtb" |
||||
@header = "About the price of the property" |
||||
@description = "" |
||||
@subsection = subsection |
||||
@depends_on = [{ |
||||
"right_to_buy?" => false, |
||||
}] |
||||
end |
||||
|
||||
def questions |
||||
@questions ||= [ |
||||
Form::Sales::Questions::Value.new(nil, nil, self), |
||||
Form::Sales::Questions::Grant.new(nil, nil, self), |
||||
] |
||||
end |
||||
end |
||||
@ -0,0 +1,19 @@
|
||||
class Form::Sales::Pages::AboutPriceRtb < ::Form::Page |
||||
def initialize(id, hsh, subsection) |
||||
super |
||||
@id = "about_price_rtb" |
||||
@header = "About the price of the property" |
||||
@description = "" |
||||
@subsection = subsection |
||||
@depends_on = [{ |
||||
"right_to_buy?" => true, |
||||
}] |
||||
end |
||||
|
||||
def questions |
||||
@questions ||= [ |
||||
Form::Sales::Questions::Value.new(nil, nil, self), |
||||
Form::Sales::Questions::Discount.new(nil, nil, self), |
||||
] |
||||
end |
||||
end |
||||
@ -0,0 +1,19 @@
|
||||
class Form::Sales::Pages::AboutPriceSocialHousing < ::Form::Page |
||||
def initialize(id, hsh, subsection) |
||||
super |
||||
@id = "about_price_social_housing" |
||||
@header = "About the price of the property" |
||||
@description = "" |
||||
@subsection = subsection |
||||
@depends_on = [{ |
||||
"soctenant" => 1, |
||||
}] |
||||
end |
||||
|
||||
def questions |
||||
@questions ||= [ |
||||
Form::Sales::Questions::Value.new(nil, nil, self), |
||||
Form::Sales::Questions::Equity.new(nil, nil, self), |
||||
] |
||||
end |
||||
end |
||||
@ -0,0 +1,17 @@
|
||||
class Form::Sales::Questions::Discount < ::Form::Question |
||||
def initialize(id, hsh, page) |
||||
super |
||||
@id = "discount" |
||||
@check_answer_label = "Percentage discount" |
||||
@header = "What was the percentage discount?" |
||||
@type = "numeric" |
||||
@page = page |
||||
@min = 0 |
||||
@max = 100 |
||||
@width = 5 |
||||
@suffix = "%" |
||||
@hint_text = "For Right to Buy (RTB), Preserved Right to Buy (PRTB), and Voluntary Right to Buy (VRTB) |
||||
If discount capped, enter capped % |
||||
If the property is being sold to an existing tenant under the RTB, PRTB, or VRTB schemes, enter the % discount from the full market value that is being given." |
||||
end |
||||
end |
||||
@ -0,0 +1,15 @@
|
||||
class Form::Sales::Questions::Equity < ::Form::Question |
||||
def initialize(id, hsh, page) |
||||
super |
||||
@id = "equity" |
||||
@check_answer_label = "Initial percentage equity stake" |
||||
@header = "What was the initial percentage equity stake purchased?" |
||||
@type = "numeric" |
||||
@page = page |
||||
@min = 0 |
||||
@max = 100 |
||||
@width = 5 |
||||
@suffix = "%" |
||||
@hint_text = "Enter the amount of initial equity held by the purchaser (for example, 25% or 50%)" |
||||
end |
||||
end |
||||
@ -0,0 +1,14 @@
|
||||
class Form::Sales::Questions::Grant < ::Form::Question |
||||
def initialize(id, hsh, page) |
||||
super |
||||
@id = "grant" |
||||
@check_answer_label = "Amount of any loan, grant or subsidy" |
||||
@header = "What was the amount of any loan, grant, discount or subsidy given?" |
||||
@type = "numeric" |
||||
@page = page |
||||
@min = 0 |
||||
@width = 5 |
||||
@prefix = "£" |
||||
@hint_text = "For all schemes except Right to Buy (RTB), Preserved Right to Buy (PRTB), Voluntary Right to Buy (VRTB)" |
||||
end |
||||
end |
||||
@ -0,0 +1,14 @@
|
||||
class Form::Sales::Questions::Value < ::Form::Question |
||||
def initialize(id, hsh, page) |
||||
super |
||||
@id = "value" |
||||
@check_answer_label = "Full purchase price" |
||||
@header = "What was the full purchase price?" |
||||
@type = "numeric" |
||||
@page = page |
||||
@min = 0 |
||||
@width = 5 |
||||
@prefix = "£" |
||||
@hint_text = "Enter the full purchase price of the property before any discounts are applied. For shared ownership, enter the full purchase price paid for 100% equity (this is equal to the value of the share owned by the PRP plus the value bought by the purchaser)" |
||||
end |
||||
end |
||||
@ -0,0 +1,10 @@
|
||||
class AddPriceFields < ActiveRecord::Migration[7.0] |
||||
def change |
||||
change_table :sales_logs, bulk: true do |t| |
||||
t.column :value, :decimal, precision: 10, scale: 2 |
||||
t.column :equity, :decimal, precision: 10, scale: 2 |
||||
t.column :discount, :decimal, precision: 10, scale: 2 |
||||
t.column :grant, :decimal, precision: 10, scale: 2 |
||||
end |
||||
end |
||||
end |
||||
@ -0,0 +1,35 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Sales::Pages::AboutPriceNotRtb, 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[value grant]) |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(page.id).to eq("about_price_not_rtb") |
||||
end |
||||
|
||||
it "has the correct header" do |
||||
expect(page.header).to eq("About the price of the property") |
||||
end |
||||
|
||||
it "has the correct description" do |
||||
expect(page.description).to eq("") |
||||
end |
||||
|
||||
it "has correct depends_on" do |
||||
expect(page.depends_on).to eq([{ |
||||
"right_to_buy?" => false, |
||||
}]) |
||||
end |
||||
end |
||||
@ -0,0 +1,35 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Sales::Pages::AboutPriceRtb, 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[value discount]) |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(page.id).to eq("about_price_rtb") |
||||
end |
||||
|
||||
it "has the correct header" do |
||||
expect(page.header).to eq("About the price of the property") |
||||
end |
||||
|
||||
it "has the correct description" do |
||||
expect(page.description).to eq("") |
||||
end |
||||
|
||||
it "has correct depends_on" do |
||||
expect(page.depends_on).to eq([{ |
||||
"right_to_buy?" => true, |
||||
}]) |
||||
end |
||||
end |
||||
@ -0,0 +1,35 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Sales::Pages::AboutPriceSocialHousing, 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[value equity]) |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(page.id).to eq("about_price_social_housing") |
||||
end |
||||
|
||||
it "has the correct header" do |
||||
expect(page.header).to eq("About the price of the property") |
||||
end |
||||
|
||||
it "has the correct description" do |
||||
expect(page.description).to eq("") |
||||
end |
||||
|
||||
it "has correct depends_on" do |
||||
expect(page.depends_on).to eq([{ |
||||
"soctenant" => 1, |
||||
}]) |
||||
end |
||||
end |
||||
@ -0,0 +1,35 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Sales::Pages::AboutPrice, 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[value]) |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(page.id).to eq("about_price") |
||||
end |
||||
|
||||
it "has the correct header" do |
||||
expect(page.header).to eq("About the price of the property") |
||||
end |
||||
|
||||
it "has the correct description" do |
||||
expect(page.description).to eq("") |
||||
end |
||||
|
||||
it "has correct depends_on" do |
||||
expect(page.depends_on).to eq([{ |
||||
"soctenant" => 2, |
||||
}]) |
||||
end |
||||
end |
||||
@ -0,0 +1,55 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Sales::Questions::Discount, 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("discount") |
||||
end |
||||
|
||||
it "has the correct header" do |
||||
expect(question.header).to eq("What was the percentage discount?") |
||||
end |
||||
|
||||
it "has the correct check_answer_label" do |
||||
expect(question.check_answer_label).to eq("Percentage discount") |
||||
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("For Right to Buy (RTB), Preserved Right to Buy (PRTB), and Voluntary Right to Buy (VRTB) |
||||
If discount capped, enter capped % |
||||
If the property is being sold to an existing tenant under the RTB, PRTB, or VRTB schemes, enter the % discount from the full market value that is being given.") |
||||
end |
||||
|
||||
it "has correct width" do |
||||
expect(question.width).to eq(5) |
||||
end |
||||
|
||||
it "has correct suffix" do |
||||
expect(question.suffix).to eq("%") |
||||
end |
||||
|
||||
it "has correct min" do |
||||
expect(question.min).to eq(0) |
||||
end |
||||
|
||||
it "has correct max" do |
||||
expect(question.max).to eq(100) |
||||
end |
||||
end |
||||
@ -0,0 +1,53 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Sales::Questions::Equity, 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("equity") |
||||
end |
||||
|
||||
it "has the correct header" do |
||||
expect(question.header).to eq("What was the initial percentage equity stake purchased?") |
||||
end |
||||
|
||||
it "has the correct check_answer_label" do |
||||
expect(question.check_answer_label).to eq("Initial percentage equity stake") |
||||
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 amount of initial equity held by the purchaser (for example, 25% or 50%)") |
||||
end |
||||
|
||||
it "has correct width" do |
||||
expect(question.width).to eq(5) |
||||
end |
||||
|
||||
it "has correct suffix" do |
||||
expect(question.suffix).to eq("%") |
||||
end |
||||
|
||||
it "has correct min" do |
||||
expect(question.min).to eq(0) |
||||
end |
||||
|
||||
it "has correct max" do |
||||
expect(question.max).to eq(100) |
||||
end |
||||
end |
||||
@ -0,0 +1,49 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Sales::Questions::Grant, 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("grant") |
||||
end |
||||
|
||||
it "has the correct header" do |
||||
expect(question.header).to eq("What was the amount of any loan, grant, discount or subsidy given?") |
||||
end |
||||
|
||||
it "has the correct check_answer_label" do |
||||
expect(question.check_answer_label).to eq("Amount of any loan, grant or subsidy") |
||||
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("For all schemes except Right to Buy (RTB), Preserved Right to Buy (PRTB), Voluntary Right to Buy (VRTB)") |
||||
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 |
||||
@ -0,0 +1,49 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Sales::Questions::Value, 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("value") |
||||
end |
||||
|
||||
it "has the correct header" do |
||||
expect(question.header).to eq("What was the full purchase price?") |
||||
end |
||||
|
||||
it "has the correct check_answer_label" do |
||||
expect(question.check_answer_label).to eq("Full purchase price") |
||||
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 full purchase price of the property before any discounts are applied. For shared ownership, enter the full purchase price paid for 100% equity (this is equal to the value of the share owned by the PRP plus the value bought by the purchaser)") |
||||
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 |
||||
Loading…
Reference in new issue