|
|
|
@ -3,6 +3,19 @@ class FormHandler
|
|
|
|
|
include CollectionTimeHelper |
|
|
|
|
attr_reader :forms |
|
|
|
|
|
|
|
|
|
SALES_SECTIONS = [ |
|
|
|
|
Form::Sales::Sections::PropertyInformation, |
|
|
|
|
Form::Sales::Sections::Household, |
|
|
|
|
Form::Sales::Sections::Finances, |
|
|
|
|
Form::Sales::Sections::SaleInformation, |
|
|
|
|
].freeze |
|
|
|
|
|
|
|
|
|
LETTINGS_SECTIONS = [ |
|
|
|
|
Form::Lettings::Sections::TenancyAndProperty, |
|
|
|
|
Form::Lettings::Sections::Household, |
|
|
|
|
Form::Lettings::Sections::RentAndCharges, |
|
|
|
|
].freeze |
|
|
|
|
|
|
|
|
|
def initialize |
|
|
|
|
@forms = get_all_forms |
|
|
|
|
end |
|
|
|
@ -20,18 +33,11 @@ class FormHandler
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def sales_forms |
|
|
|
|
sales_sections = [ |
|
|
|
|
Form::Sales::Sections::PropertyInformation, |
|
|
|
|
Form::Sales::Sections::Household, |
|
|
|
|
Form::Sales::Sections::Finances, |
|
|
|
|
Form::Sales::Sections::SaleInformation, |
|
|
|
|
] |
|
|
|
|
current_form = Form.new(nil, current_collection_start_year, sales_sections, "sales") |
|
|
|
|
previous_form = Form.new(nil, current_collection_start_year - 1, sales_sections, "sales") |
|
|
|
|
next_form = Form.new(nil, current_collection_start_year + 1, sales_sections, "sales") |
|
|
|
|
{ "current_sales" => current_form, |
|
|
|
|
"previous_sales" => previous_form, |
|
|
|
|
"next_sales" => next_form } |
|
|
|
|
{ |
|
|
|
|
"current_sales" => Form.new(nil, current_collection_start_year, SALES_SECTIONS, "sales"), |
|
|
|
|
"previous_sales" => Form.new(nil, current_collection_start_year - 1, SALES_SECTIONS, "sales"), |
|
|
|
|
"next_sales" => Form.new(nil, current_collection_start_year + 1, SALES_SECTIONS, "sales"), |
|
|
|
|
} |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def lettings_forms |
|
|
|
@ -45,17 +51,11 @@ class FormHandler
|
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
lettings_sections = [ |
|
|
|
|
Form::Lettings::Sections::TenancyAndProperty, |
|
|
|
|
Form::Lettings::Sections::Household, |
|
|
|
|
Form::Lettings::Sections::RentAndCharges, |
|
|
|
|
] |
|
|
|
|
|
|
|
|
|
if forms["previous_lettings"].blank? && current_collection_start_year >= 2022 |
|
|
|
|
forms["previous_lettings"] = Form.new(nil, current_collection_start_year - 1, lettings_sections, "lettings") |
|
|
|
|
forms["previous_lettings"] = Form.new(nil, current_collection_start_year - 1, LETTINGS_SECTIONS, "lettings") |
|
|
|
|
end |
|
|
|
|
forms["current_lettings"] = Form.new(nil, current_collection_start_year, lettings_sections, "lettings") if forms["current_lettings"].blank? |
|
|
|
|
forms["next_lettings"] = Form.new(nil, current_collection_start_year + 1, lettings_sections, "lettings") if forms["next_lettings"].blank? |
|
|
|
|
forms["current_lettings"] = Form.new(nil, current_collection_start_year, LETTINGS_SECTIONS, "lettings") if forms["current_lettings"].blank? |
|
|
|
|
forms["next_lettings"] = Form.new(nil, current_collection_start_year + 1, LETTINGS_SECTIONS, "lettings") if forms["next_lettings"].blank? |
|
|
|
|
|
|
|
|
|
forms |
|
|
|
|
end |
|
|
|
|