Browse Source

refactor

pull/1263/head
Kat 3 years ago
parent
commit
946c0ec73e
  1. 2
      app/models/form.rb
  2. 8
      app/models/form_handler.rb

2
app/models/form.rb

@ -7,7 +7,7 @@ class Form
if type == "sales" || (start_year && start_year.to_i > 2022)
@setup_sections = type == "sales" ? [Form::Sales::Sections::Setup.new(nil, nil, self)] : [Form::Lettings::Sections::Setup.new(nil, nil, self)]
@form_sections = sections_in_form.map { |sec| sec.new(nil, nil, self) }
@type = type == "sales" ? "sales" : "lettings"
@type = type
@sections = setup_sections + form_sections
@subsections = sections.flat_map(&:subsections)
@pages = subsections.flat_map(&:pages)

8
app/models/form_handler.rb

@ -54,12 +54,8 @@ class FormHandler
if forms["previous_lettings"].blank? && current_collection_start_year >= 2022
forms["previous_lettings"] = Form.new(nil, current_collection_start_year - 1, lettings_sections, "lettings")
end
if forms["current_lettings"].blank? && current_collection_start_year >= 2022
forms["current_lettings"] = Form.new(nil, current_collection_start_year, lettings_sections, "lettings")
end
if forms["next_lettings"].blank? && current_collection_start_year >= 2022
forms["next_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
end

Loading…
Cancel
Save