Browse Source

Add upcoming deadlines section

pull/2119/head
Kat 2 years ago
parent
commit
b72b7be1c4
  1. 19
      app/helpers/collection_time_helper.rb
  2. 16
      app/views/home/_upcoming_deadlines.html.erb
  3. 2
      app/views/home/index.html.erb
  4. 30
      spec/helpers/collection_time_helper_spec.rb

19
app/helpers/collection_time_helper.rb

@ -45,4 +45,23 @@ module CollectionTimeHelper
def previous_collection_start_date
current_collection_start_date - 1.year
end
def quarter_for_date(date: Time.zone.now)
quarters = [
{ cutoff_date: Time.zone.local(2024, 1, 12), start_date: Time.zone.local(2023, 10, 1), end_date: Time.zone.local(2023, 12, 31) },
{ cutoff_date: Time.zone.local(2024, 7, 12), start_date: Time.zone.local(2024, 4, 1), end_date: Time.zone.local(2024, 6, 30) },
{ cutoff_date: Time.zone.local(2024, 10, 11), start_date: Time.zone.local(2024, 7, 1), end_date: Time.zone.local(2024, 9, 30) },
{ cutoff_date: Time.zone.local(2025, 1, 10), start_date: Time.zone.local(2024, 10, 1), end_date: Time.zone.local(2024, 12, 31) },
]
quarter = quarters.find { |q| date.between?(q[:start_date], q[:cutoff_date] + 1.day) }
return unless quarter
OpenStruct.new(
cutoff_date: quarter[:cutoff_date],
quarter_start_date: quarter[:start_date],
quarter_end_date: quarter[:end_date],
)
end
end

16
app/views/home/_upcoming_deadlines.html.erb

@ -0,0 +1,16 @@
<h1 class="govuk-heading-l">Upcoming deadlines</h1>
<% current_quarter = quarter_for_date(date: Time.zone.now) %>
<% if current_quarter.present? %>
<p class="govuk-body govuk-body-m"><strong>12 January 2024</strong>: Quarterly cut off date for tenancies and sales starting between 1 October 2023 and 31 December 2023.</p>
<% end %>
<% current_lettings_form = FormHandler.instance.current_lettings_form %>
<p class="govuk-body govuk-body-m"><strong><%= current_lettings_form.submission_deadline.to_formatted_s(:govuk_date) %></strong>: Deadline to submit logs for tenancies starting between <%= collection_start_date(Time.zone.now).to_formatted_s(:govuk_date) %> to <%= collection_end_date(Time.zone.now).to_formatted_s(:govuk_date) %></p>
<%= govuk_details(summary_text: "Quarterly cut-off dates for 2024 to 2025") do %>
<ul class="govuk-list govuk-list--bullet">
<li><strong>12 July 2024</strong>: Quarterly cut off date for tenancies and sales starting between 1 April 2024 and 30 June 2024</li>
<li><strong>11 Oct 2024</strong>: Quarterly cut off date for tenancies and sales starting between 1 July 2024 and 30 Sept 2024</li>
<li><strong>10 Jan 2025</strong>: Quarterly cut off date for tenancies and sales starting between 1 Oct 2024 and 31 Dec 2024</li>
<li><strong>6 June 2025</strong>: Deadline to submit logs for tenancies starting between 1 April 2024 to 31 March 2025 </li>
</ul>
<% end %>

2
app/views/home/index.html.erb

@ -2,5 +2,7 @@
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<%= render partial: "layouts/collection_resources" %>
<hr class="govuk-section-break govuk-section-break--visible govuk-section-break--m">
<%= render partial: "home/upcoming_deadlines" %>
</div>
</div>

30
spec/helpers/collection_time_helper_spec.rb

@ -109,4 +109,34 @@ RSpec.describe CollectionTimeHelper do
end
end
end
describe "#quarter_for_date" do
it "returns correct cutoff date for curent quarter" do
quarter = quarter_for_date(date: Time.zone.local(2023, 10, 1))
expect(quarter.cutoff_date).to eq(Time.zone.local(2024, 1, 12))
expect(quarter.quarter_start_date).to eq(Time.zone.local(2023, 10, 1))
expect(quarter.quarter_end_date).to eq(Time.zone.local(2023, 12, 31))
end
it "returns correct cutoff date for the first quarter of 2024/25" do
quarter = quarter_for_date(date: Time.zone.local(2024, 4, 1))
expect(quarter.cutoff_date).to eq(Time.zone.local(2024, 7, 12))
expect(quarter.quarter_start_date).to eq(Time.zone.local(2024, 4, 1))
expect(quarter.quarter_end_date).to eq(Time.zone.local(2024, 6, 30))
end
it "returns correct cutoff date for the second quarter of 2024/25" do
quarter = quarter_for_date(date: Time.zone.local(2024, 9, 30))
expect(quarter.cutoff_date).to eq(Time.zone.local(2024, 10, 11))
expect(quarter.quarter_start_date).to eq(Time.zone.local(2024, 7, 1))
expect(quarter.quarter_end_date).to eq(Time.zone.local(2024, 9, 30))
end
it "returns correct cutoff date for the third quarter of 2024/25" do
quarter = quarter_for_date(date: Time.zone.local(2024, 10, 25))
expect(quarter.cutoff_date).to eq(Time.zone.local(2025, 1, 10))
expect(quarter.quarter_start_date).to eq(Time.zone.local(2024, 10, 1))
expect(quarter.quarter_end_date).to eq(Time.zone.local(2024, 12, 31))
end
end
end

Loading…
Cancel
Save