Browse Source

CLDC-2451 Add submission and edit end dates (#1711)

* Add submission and edit end dates

* lint

* Tests
pull/1720/head
kosiakkatrina 2 years ago committed by GitHub
parent
commit
84c63146ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      app/helpers/tasklist_helper.rb
  2. 12
      app/models/form.rb
  3. 2
      app/views/form/review.html.erb
  4. 17
      docs/adr/adr-019-form-end-dates.md
  5. 4
      spec/helpers/tasklist_helper_spec.rb

2
app/helpers/tasklist_helper.rb

@ -33,7 +33,7 @@ module TasklistHelper
if log.collection_period_open?
path = log.sales? ? review_sales_log_path(id: log, sales_log: true) : review_lettings_log_path(log)
"You can #{govuk_link_to 'review and make changes to this log', path} until #{log.form.display_end_date.to_formatted_s(:govuk_date)}.".html_safe
"You can #{govuk_link_to 'review and make changes to this log', path} until #{log.form.submission_deadline.to_formatted_s(:govuk_date)}.".html_safe
else
start_year = log.startdate ? collection_start_year_for_date(log.startdate) : log.form.start_date.year

12
app/models/form.rb

@ -1,7 +1,7 @@
class Form
attr_reader :form_definition, :sections, :subsections, :pages, :questions,
:start_date, :end_date, :display_end_date, :type, :name, :setup_definition,
:setup_sections, :form_sections, :unresolved_log_redirect_page_id
:start_date, :end_date, :submission_deadline, :type, :name, :setup_definition,
:setup_sections, :form_sections, :unresolved_log_redirect_page_id, :edit_end_date
def initialize(form_path, start_year = "", sections_in_form = [], type = "lettings")
if sales_or_start_year_after_2022?(type, start_year)
@ -11,6 +11,11 @@ class Form
else
Time.zone.local(start_year + 1, 8, 7)
end
@submission_deadline = if start_year && start_year.to_i > 2022
Time.zone.local(start_year + 1, 6, 7)
else
Time.zone.local(start_year + 1, 6, 9)
end
@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
@ -38,9 +43,10 @@ class Form
@questions = pages.flat_map(&:questions)
@start_date = Time.iso8601(form_definition["start_date"])
@end_date = Time.iso8601(form_definition["end_date"])
@submission_deadline = Time.zone.local(2023, 6, 9)
@unresolved_log_redirect_page_id = form_definition["unresolved_log_redirect_page_id"]
end
@display_end_date = start_year == 2022 ? Time.zone.local(2023, 6, 9) : @end_date
@edit_end_date = @end_date
@name = "#{start_date.year}_#{end_date.year}_#{type}"
end

2
app/views/form/review.html.erb

@ -12,7 +12,7 @@
<%= content_for(:title) %>
</h1>
<p class="govuk-body">
You can review and make changes to this log until <%= @log.form.display_end_date.to_formatted_s(:govuk_date) %>.
You can review and make changes to this log until <%= @log.form.submission_deadline.to_formatted_s(:govuk_date) %>.
</p>
<% @log.form.sections.map do |section| %>
<h2 class="govuk-heading-m"><%= section.label %></h2>

17
docs/adr/adr-019-form-end-dates.md

@ -0,0 +1,17 @@
---
parent: Architecture decisions
---
# 019: Form end dates
CORE operates on financial years, e.g. the 2022/23 collection is about tenancies that start on a date between 1st April 2022 and 31st March 2023 inclusive.
We allow providers until the first Friday in June to submit data for the collection year ending in March.
There might be short extensions to the deadline, so shortly after the last day to submit data, new logs cannot be created with a tenancy start date in that collection year, but existing logs can still be edited or deleted.
Also, if incorrect data is found during QA process, data providers might be asked to correct it. Once the data has been through its first QA processes and is as present and correct as possible, the ability to edit and delete logs is closed. This is typically in late summer/autumn, but it depends on the statistical analysis.
To accommodate the different end dates, we will now store 3 different dates on the form definition:
- Submission deadline (submission_deadline) - this is the date displayed at the top of a completed log in lettings and sales - "You can review and make changes to this log until 9 June 2024.". Nothing happens on this date
- New logs end date (end_date) - no new logs for that collection year can be submitted, but logs can be edited
- Edit and delete logs end date (edit_end_date) - logs can no longer be edited or deleted. Completed logs can still be viewed. Materials / references to the collection year are removed.

4
spec/helpers/tasklist_helper_spec.rb

@ -154,7 +154,7 @@ RSpec.describe TasklistHelper do
it "returns relevant text" do
expect(review_log_text(lettings_log)).to eq(
"You can #{govuk_link_to 'review and make changes to this log', review_lettings_log_path(lettings_log)} until 1 July 2023.".html_safe,
"You can #{govuk_link_to 'review and make changes to this log', review_lettings_log_path(lettings_log)} until 9 June 2023.".html_safe,
)
end
end
@ -165,7 +165,7 @@ RSpec.describe TasklistHelper do
it "returns relevant text" do
expect(review_log_text(lettings_log)).to eq(
"You can #{govuk_link_to 'review and make changes to this log', review_lettings_log_path(lettings_log)} until 9 June 2024.".html_safe,
"You can #{govuk_link_to 'review and make changes to this log', review_lettings_log_path(lettings_log)} until 7 June 2024.".html_safe,
)
end
end

Loading…
Cancel
Save