Browse Source

add the question

CLDC-4174-clone-q88-service-charges
Samuel Young 2 weeks ago
parent
commit
a571e4b7ce
  1. 4
      app/models/form/sales/pages/service_charge.rb
  2. 13
      app/models/form/sales/pages/service_charge_staircasing.rb
  3. 15
      app/models/form/sales/questions/has_service_charge.rb
  4. 16
      app/models/form/sales/questions/service_charge.rb
  5. 1
      app/models/form/sales/subsections/shared_ownership_staircasing_transaction.rb

4
app/models/form/sales/pages/service_charge.rb

@ -6,8 +6,8 @@ class Form::Sales::Pages::ServiceCharge < ::Form::Page
def questions def questions
@questions ||= [ @questions ||= [
Form::Sales::Questions::HasServiceCharge.new(nil, nil, self), Form::Sales::Questions::HasServiceCharge.new(nil, nil, self, staircasing: false),
Form::Sales::Questions::ServiceCharge.new(nil, nil, self), Form::Sales::Questions::ServiceCharge.new(nil, nil, self, staircasing: false),
] ]
end end
end end

13
app/models/form/sales/pages/service_charge_staircasing.rb

@ -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

15
app/models/form/sales/questions/has_service_charge.rb

@ -1,6 +1,6 @@
class Form::Sales::Questions::HasServiceCharge < ::Form::Question class Form::Sales::Questions::HasServiceCharge < ::Form::Question
def initialize(id, hsh, subsection) def initialize(id, hsh, subsection, staircasing:)
super super(id, hsh, subsection)
@id = "has_mscharge" @id = "has_mscharge"
@type = "radio" @type = "radio"
@answer_options = ANSWER_OPTIONS @answer_options = ANSWER_OPTIONS
@ -15,7 +15,8 @@ class Form::Sales::Questions::HasServiceCharge < ::Form::Question
], ],
} }
@copy_key = "sales.sale_information.servicecharges.has_servicecharge" @copy_key = "sales.sale_information.servicecharges.has_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]
end end
ANSWER_OPTIONS = { ANSWER_OPTIONS = {
@ -23,5 +24,11 @@ class Form::Sales::Questions::HasServiceCharge < ::Form::Question
"0" => { "value" => "No" }, "0" => { "value" => "No" },
}.freeze }.freeze
QUESTION_NUMBER_FROM_YEAR = { 2025 => 88 }.freeze def question_number_from_year
if @staircasing
{ 2026 => 0 }.freeze
else
{ 2025 => 88 }.freeze
end
end
end end

16
app/models/form/sales/questions/service_charge.rb

@ -1,16 +1,24 @@
class Form::Sales::Questions::ServiceCharge < ::Form::Question class Form::Sales::Questions::ServiceCharge < ::Form::Question
def initialize(id, hsh, subsection) def initialize(id, hsh, subsection, staircasing:)
super super(id, hsh, subsection)
@id = "mscharge" @id = "mscharge"
@type = "numeric" @type = "numeric"
@min = 1 @min = 1
@max = 9999.99
@step = 0.01 @step = 0.01
@width = 5 @width = 5
@prefix = "£" @prefix = "£"
@copy_key = "sales.sale_information.servicecharges.servicecharge" @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 @strip_commas = true
end end
QUESTION_NUMBER_FROM_YEAR = { 2025 => 88 }.freeze def question_number_from_year
if @staircasing
{ 2026 => 0 }.freeze
else
{ 2025 => 88 }.freeze
end
end
end end

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

@ -25,6 +25,7 @@ class Form::Sales::Subsections::SharedOwnershipStaircasingTransaction < ::Form::
Form::Sales::Pages::Mortgageused.new("staircase_mortgage_used_shared_ownership", nil, self, ownershipsch: 1), Form::Sales::Pages::Mortgageused.new("staircase_mortgage_used_shared_ownership", nil, self, ownershipsch: 1),
Form::Sales::Pages::MonthlyRentStaircasingOwned.new(nil, nil, self), Form::Sales::Pages::MonthlyRentStaircasingOwned.new(nil, nil, self),
Form::Sales::Pages::MonthlyRentStaircasing.new(nil, nil, self), Form::Sales::Pages::MonthlyRentStaircasing.new(nil, nil, self),
Form::Sales::Pages::ServiceChargeStaircasing.new("service_charge_staircasing", nil, self),
Form::Sales::Pages::MonthlyChargesValueCheck.new("monthly_charges_shared_ownership_value_check", nil, self), Form::Sales::Pages::MonthlyChargesValueCheck.new("monthly_charges_shared_ownership_value_check", nil, self),
].compact ].compact
end end

Loading…
Cancel
Save