Browse Source
* Mark subsection as completed if it is not displayed in the tasklist and hide it from the UI * Add sale_information section * add sales information subsections * Cldc 1531 staircasing (#1109) * Add staircase field to sales_logs table * Add staircase question and page * add staircase page to the shared ownership scheme subsection fix file name * Cldc 1539 previous bedrooms (#1108) * add frombeds field * Add previous_bedrooms page and question * add Previous Bedrooms page to the shared ownership subsection * Cldc 1532 about staircasing (#1110) * Add stairboughts and stairowned fields to the database * Add about staircasing page and questions * Add about staircasing page to the shared wnership scheme subsection * Add a space before percent * Cldc 1546 monthly rent (#1111) * Add monthly rent column to sales logs table * Add monthly rent question and page * Add monthly rent page to the shared ownership scheme subsection * Cldc 1535 exchange contracts (#1112) * Add exdate to sales logs table * Add exchange date page and question * Add exchange contracts page to the shared ownership subsection * derive exday, exmonth and exyear, tests and lint * rebase tests * 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 * 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> * Cldc 1533 is resale (#1118) * feat: add resale question and page * tests: add new tests * test: update previous tests * refactor: linting * refactor: linting * Cldc 1576 buyer prp (#1117) * Add soctenant field to sales logs * Add buyer previous page and question * Add buyer previous page to shared ownership scheme subsection * rebase migrate * rebase too * Cldc 1540 about price (#1121) * add price fields to the sales logs table * Add about proce questions * add about proce pages * Add about price pages to sale information sections * rebase changes * happy new year * Switch the order of sales log sections * Cldc 1540 fixes (#1130) * Update order of pages and remove wrong id's * Add spacing to the hint text * feat: add page, question, and update db * Cldc 1521 living before purchase (#1129) * feat: add new page and question and update db * test: add and update tests * feat: reset db * feat: infer mscharge if mscharge_known == No * test: add and update tests * feat: add page, question, and update db * feat: infer mscharge if mscharge_known == No * test: add and update tests * feat: update to main * test: update tests * tests: update tests * faet: move mscharge derivation Co-authored-by: Kat <katrina@kosiak.co.uk> Co-authored-by: kosiakkatrina <54268893+kosiakkatrina@users.noreply.github.com>pull/1162/head
natdeanlewissoftwire
2 years ago
committed by
GitHub
17 changed files with 227 additions and 7 deletions
@ -0,0 +1,15 @@
|
||||
class Form::Sales::Pages::LeaseholdCharges < ::Form::Page |
||||
def initialize(id, hsh, subsection) |
||||
super |
||||
@header = "" |
||||
@description = "" |
||||
@subsection = subsection |
||||
end |
||||
|
||||
def questions |
||||
@questions ||= [ |
||||
Form::Sales::Questions::LeaseholdChargesKnown.new(nil, nil, self), |
||||
Form::Sales::Questions::LeaseholdCharges.new(nil, nil, self), |
||||
] |
||||
end |
||||
end |
@ -0,0 +1,13 @@
|
||||
class Form::Sales::Questions::LeaseholdCharges < ::Form::Question |
||||
def initialize(id, hsh, page) |
||||
super |
||||
@id = "mscharge" |
||||
@check_answer_label = "Monthly leasehold charges" |
||||
@header = "Enter the total monthly charge" |
||||
@type = "numeric" |
||||
@page = page |
||||
@min = 0 |
||||
@width = 5 |
||||
@prefix = "£" |
||||
end |
||||
end |
@ -0,0 +1,27 @@
|
||||
class Form::Sales::Questions::LeaseholdChargesKnown < ::Form::Question |
||||
def initialize(id, hsh, page) |
||||
super |
||||
@id = "mscharge_known" |
||||
@check_answer_label = "Monthly leasehold charges known?" |
||||
@header = "Does the property have any monthly leasehold charges?" |
||||
@hint_text = "For example, service and management charges" |
||||
@type = "radio" |
||||
@answer_options = ANSWER_OPTIONS |
||||
@page = page |
||||
@conditional_for = { |
||||
"mscharge" => [1], |
||||
} |
||||
@hidden_in_check_answers = { |
||||
"depends_on" => [ |
||||
{ |
||||
"mscharge_known" => 1, |
||||
}, |
||||
], |
||||
} |
||||
end |
||||
|
||||
ANSWER_OPTIONS = { |
||||
"1" => { "value" => "Yes" }, |
||||
"0" => { "value" => "No" }, |
||||
}.freeze |
||||
end |
@ -0,0 +1,8 @@
|
||||
class AddMschargeKnownToSales < ActiveRecord::Migration[7.0] |
||||
def change |
||||
change_table :sales_logs, bulk: true do |t| |
||||
t.column :mscharge_known, :integer |
||||
t.column :mscharge, :decimal, precision: 10, scale: 2 |
||||
end |
||||
end |
||||
end |
@ -0,0 +1,33 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Sales::Pages::LeaseholdCharges, 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[mscharge_known mscharge]) |
||||
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("") |
||||
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 |
@ -0,0 +1,60 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Sales::Questions::LeaseholdChargesKnown, 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("mscharge_known") |
||||
end |
||||
|
||||
it "has the correct header" do |
||||
expect(question.header).to eq("Does the property have any monthly leasehold charges?") |
||||
end |
||||
|
||||
it "has the correct check_answer_label" do |
||||
expect(question.check_answer_label).to eq("Monthly leasehold charges known?") |
||||
end |
||||
|
||||
it "has the correct type" do |
||||
expect(question.type).to eq("radio") |
||||
end |
||||
|
||||
it "is not marked as derived" do |
||||
expect(question.derived?).to be false |
||||
end |
||||
|
||||
it "has the correct answer_options" do |
||||
expect(question.answer_options).to eq({ |
||||
"0" => { "value" => "No" }, |
||||
"1" => { "value" => "Yes" }, |
||||
}) |
||||
end |
||||
|
||||
it "has correct conditional for" do |
||||
expect(question.conditional_for).to eq({ |
||||
"mscharge" => [1], |
||||
}) |
||||
end |
||||
|
||||
it "has the correct hint" do |
||||
expect(question.hint_text).to eq("For example, service and management charges") |
||||
end |
||||
|
||||
it "has correct hidden_in_check_answers for" do |
||||
expect(question.hidden_in_check_answers).to eq({ |
||||
"depends_on" => [ |
||||
{ |
||||
"mscharge_known" => 1, |
||||
}, |
||||
], |
||||
}) |
||||
end |
||||
end |
@ -0,0 +1,49 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Sales::Questions::LeaseholdCharges, 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("mscharge") |
||||
end |
||||
|
||||
it "has the correct header" do |
||||
expect(question.header).to eq("Enter the total monthly charge") |
||||
end |
||||
|
||||
it "has the correct check_answer_label" do |
||||
expect(question.check_answer_label).to eq("Monthly leasehold charges") |
||||
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 be_nil |
||||
end |
||||
|
||||
it "has the correct width" do |
||||
expect(question.width).to eq(5) |
||||
end |
||||
|
||||
it "has the correct min" do |
||||
expect(question.min).to eq(0) |
||||
end |
||||
|
||||
it "has the correct prefix" do |
||||
expect(question.prefix).to eq("£") |
||||
end |
||||
end |
Loading…
Reference in new issue