8 changed files with 79 additions and 2 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,18 @@
|
||||
class Form::Sales::Questions::LeaseholdCharges < ::Form::Question |
||||
def initialize(id, hsh, page) |
||||
super |
||||
@id = "mscharge" |
||||
@check_answer_label = "Monthly rent" |
||||
@header = "Enter the total monthly charge" |
||||
@type = "numeric" |
||||
@page = page |
||||
@width = 2 |
||||
@prefix = "£" |
||||
@inferred_check_answers_value = { |
||||
"condition" => { |
||||
"mscharge_known" => 0, |
||||
}, |
||||
"value" => 0, |
||||
} |
||||
end |
||||
end |
||||
@ -0,0 +1,30 @@
|
||||
class Form::Sales::Questions::LeaseholdChargesKnown < ::Form::Question |
||||
def initialize(id, hsh, page) |
||||
super |
||||
@id = "mscharge_known" |
||||
@check_answer_label = "Monthly rent" |
||||
@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" => 0, |
||||
}, |
||||
{ |
||||
"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 |
||||
Loading…
Reference in new issue