Browse Source
* add the question * CLDC-4174: update question number for 2026 * CLDc-4174: update question number for 2026 * CLDc-4174: update subsection * CLDc-4174: update question specs * CLDC-4174: add subsection spec * CLDc-4174: lint * CLDc-4174: add new page test * CLDC-4241: lint * CLDC-4241: lint * CLDC-4174: copy sales log csv updates from CLDC-4176 --------- Co-authored-by: Samuel Young <samuel.young@softwire.com>pull/3186/head^2
10 changed files with 249 additions and 20 deletions
@ -0,0 +1,13 @@
|
||||
class Form::Sales::Pages::ServiceChargeStaircasing < ::Form::Page |
||||
def initialize(id, hsh, subsection) |
||||
super |
||||
@copy_key = "sales.sale_information.servicecharges" |
||||
end |
||||
|
||||
def questions |
||||
@questions ||= [ |
||||
Form::Sales::Questions::HasServiceCharge.new(nil, nil, self, staircasing: true), |
||||
Form::Sales::Questions::ServiceCharge.new(nil, nil, self, staircasing: true), |
||||
] |
||||
end |
||||
end |
||||
@ -1,16 +1,24 @@
|
||||
class Form::Sales::Questions::ServiceCharge < ::Form::Question |
||||
def initialize(id, hsh, subsection) |
||||
super |
||||
def initialize(id, hsh, subsection, staircasing:) |
||||
super(id, hsh, subsection) |
||||
@id = "mscharge" |
||||
@type = "numeric" |
||||
@min = 1 |
||||
@max = 9999.99 |
||||
@step = 0.01 |
||||
@width = 5 |
||||
@prefix = "£" |
||||
@copy_key = "sales.sale_information.servicecharges.servicecharge" |
||||
@question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] |
||||
@staircasing = staircasing |
||||
@question_number = question_number_from_year[form.start_date.year] || question_number_from_year[question_number_from_year.keys.max] |
||||
@strip_commas = true |
||||
end |
||||
|
||||
QUESTION_NUMBER_FROM_YEAR = { 2025 => 88 }.freeze |
||||
def question_number_from_year |
||||
if @staircasing |
||||
{ 2026 => 0 }.freeze |
||||
else |
||||
{ 2025 => 88, 2026 => 0 }.freeze |
||||
end |
||||
end |
||||
end |
||||
|
||||
@ -0,0 +1,29 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Sales::Pages::ServiceChargeStaircasing, 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, form: instance_double(Form, start_date: Time.zone.local(2026, 4, 1))) } |
||||
|
||||
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[has_mscharge mscharge]) |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(page.id).to be_nil |
||||
end |
||||
|
||||
it "has the correct description" do |
||||
expect(page.description).to be_nil |
||||
end |
||||
|
||||
it "has correct depends_on" do |
||||
expect(page.depends_on).to be_nil |
||||
end |
||||
end |
||||
@ -0,0 +1,85 @@
|
||||
require "rails_helper" |
||||
|
||||
RSpec.describe Form::Sales::Subsections::SharedOwnershipStaircasingTransaction, type: :model do |
||||
subject(:shared_ownership_staircasing_transaction) { described_class.new(nil, nil, section) } |
||||
|
||||
let(:form) { instance_double(Form, start_year_2026_or_later?: false) } |
||||
let(:section) { instance_double(Form::Sales::Sections::SaleInformation, form:) } |
||||
|
||||
it "has correct section" do |
||||
expect(shared_ownership_staircasing_transaction.section).to eq(section) |
||||
end |
||||
|
||||
it "has the correct depends_on" do |
||||
expect(shared_ownership_staircasing_transaction.depends_on).to eq([{ "ownershipsch" => 1, "setup_completed?" => true, "staircase" => 1 }]) |
||||
end |
||||
|
||||
it "has the correct id" do |
||||
expect(shared_ownership_staircasing_transaction.id).to eq("shared_ownership_staircasing_transaction") |
||||
end |
||||
|
||||
it "has the correct label" do |
||||
expect(shared_ownership_staircasing_transaction.label).to eq("Shared ownership - staircasing transaction") |
||||
end |
||||
|
||||
it "has the correct copy key" do |
||||
expect(shared_ownership_staircasing_transaction.copy_key).to eq("sale_information") |
||||
end |
||||
|
||||
context "when the start year is 2025" do |
||||
let(:form) { instance_double(Form, start_year_2025_or_later?: true, start_year_2026_or_later?: false, start_date: Time.utc(2025, 4, 1)) } |
||||
|
||||
it "has correct pages" do |
||||
expect(shared_ownership_staircasing_transaction.pages.map(&:id)).to eq( |
||||
%w[ |
||||
about_staircasing_joint_purchase |
||||
about_staircasing_not_joint_purchase |
||||
staircase_sale |
||||
staircase_bought_value_check |
||||
staircase_owned_value_check_joint_purchase |
||||
staircase_owned_value_check_not_joint_purchase |
||||
staircase_first_time |
||||
staircase_previous |
||||
staircase_initial_date |
||||
value_shared_ownership_staircase |
||||
about_price_shared_ownership_value_check_staircasing |
||||
staircase_equity |
||||
shared_ownership_equity_value_check_staircasing |
||||
staircase_mortgage_used_shared_ownership |
||||
monthly_rent_staircasing_owned |
||||
monthly_rent_staircasing |
||||
monthly_charges_shared_ownership_value_check |
||||
], |
||||
) |
||||
end |
||||
end |
||||
|
||||
context "when the start year is 2026" do |
||||
let(:form) { instance_double(Form, start_year_2025_or_later?: true, start_year_2026_or_later?: true, start_date: Time.utc(2026, 4, 1)) } |
||||
|
||||
it "has correct pages" do |
||||
expect(shared_ownership_staircasing_transaction.pages.map(&:id)).to eq( |
||||
%w[ |
||||
about_staircasing_joint_purchase |
||||
about_staircasing_not_joint_purchase |
||||
staircase_sale |
||||
staircase_bought_value_check |
||||
staircase_owned_value_check_joint_purchase |
||||
staircase_owned_value_check_not_joint_purchase |
||||
staircase_first_time |
||||
staircase_previous |
||||
staircase_initial_date |
||||
value_shared_ownership_staircase |
||||
about_price_shared_ownership_value_check_staircasing |
||||
staircase_equity |
||||
shared_ownership_equity_value_check_staircasing |
||||
staircase_mortgage_used_shared_ownership |
||||
monthly_rent_staircasing_owned |
||||
monthly_rent_staircasing |
||||
service_charge_staircasing |
||||
monthly_charges_shared_ownership_value_check |
||||
], |
||||
) |
||||
end |
||||
end |
||||
end |
||||
Loading…
Reference in new issue