Skip to content

Commit

Permalink
Merge pull request #6743 from alphagov/revert-6741-revert-6716-part-3…
Browse files Browse the repository at this point in the history
…-holiday-entitlement-calculator-change

Part 3 holiday entitlement calculator change: update calculator to reflect post-April policy change
  • Loading branch information
anatron authored Apr 9, 2024
2 parents a149fae + af87850 commit 021c778
Show file tree
Hide file tree
Showing 17 changed files with 316 additions and 495 deletions.
88 changes: 69 additions & 19 deletions app/flows/calculate_your_holiday_entitlement_flow.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,38 @@ def define
status :published

# Q1
radio :regular_or_irregular_hours? do
option "irregular-hours-and-part-year"
option "regular"

on_response do |response|
self.calculator = SmartAnswer::Calculators::HolidayEntitlement.new
calculator.regular_or_irregular_hours = response
end

next_node do
if calculator.regular_or_irregular_hours == "regular"
question :basis_of_calculation?
elsif calculator.regular_or_irregular_hours == "irregular-hours-and-part-year"
question :when_does_your_leave_year_start?
end
end
end

radio :basis_of_calculation? do
option "days-worked-per-week"
option "hours-worked-per-week"
option "irregular-hours"
option "annualised-hours"
option "compressed-hours"
option "shift-worker"

on_response do |response|
self.calculator = SmartAnswer::Calculators::HolidayEntitlement.new
calculator.calculation_basis = response
end

next_node do
case calculator.calculation_basis
when "days-worked-per-week", "hours-worked-per-week", "compressed-hours", "irregular-hours", "annualised-hours"
when "days-worked-per-week", "hours-worked-per-week", "compressed-hours", "annualised-hours"
question :calculation_period?
when "shift-worker"
question :shift_worker_basis?
Expand All @@ -47,8 +63,8 @@ def define
question :what_is_your_leaving_date?
when "full-year"
case calculator.calculation_basis
when "irregular-hours", "annualised-hours"
outcome :irregular_and_annualised_done
when "annualised-hours"
outcome :annualised_done
when "days-worked-per-week"
question :how_many_days_per_week?
else
Expand Down Expand Up @@ -82,6 +98,17 @@ def define
next_node do
if calculator.holiday_period == "starting-and-leaving"
question :what_is_your_leaving_date?
elsif calculator.regular_or_irregular_hours == "irregular-hours-and-part-year" && calculator.leave_year_start_date < (Date.new(2024, 4, 1))
case calculator.calculation_basis
when "days-worked-per-week"
question :how_many_days_per_week?
when "hours-worked-per-week", "compressed-hours"
question :how_many_hours_per_week?
when "annualised-hours"
outcome :annualised_done
when "shift-worker"
question :shift_worker_hours_per_shift?
end
else
question :when_does_your_leave_year_start?
end
Expand All @@ -103,24 +130,23 @@ def define
end

next_node do
if calculator.holiday_period == "starting-and-leaving"
if calculator.holiday_period == "starting-and-leaving" || (calculator.regular_or_irregular_hours == "irregular-hours-and-part-year" && calculator.leave_year_start_date < (Date.new(2024, 4, 1)))
case calculator.calculation_basis
when "days-worked-per-week"
question :how_many_days_per_week?
when "hours-worked-per-week", "compressed-hours"
question :how_many_hours_per_week?
when "shift-worker"
question :shift_worker_hours_per_shift?
when "irregular-hours", "annualised-hours"
outcome :irregular_and_annualised_done
when "annualised-hours"
outcome :annualised_done
end
else
question :when_does_your_leave_year_start?
end
end
end

# Q6 - Q14 - Q22 - Q31 - Q38
date_question :when_does_your_leave_year_start? do
on_response do |response|
calculator.leave_year_start_date = response
Expand All @@ -143,19 +169,42 @@ def define
end

next_node do
case calculator.calculation_basis
when "days-worked-per-week"
question :how_many_days_per_week?
when "hours-worked-per-week", "compressed-hours"
question :how_many_hours_per_week?
when "irregular-hours", "annualised-hours"
outcome :irregular_and_annualised_done
when "shift-worker"
question :shift_worker_hours_per_shift?
if calculator.regular_or_irregular_hours == "irregular-hours-and-part-year"

if calculator.leave_year_start_date >= (Date.new(2024, 4, 1))
question :hours_in_pay_period?
else
question :basis_of_calculation?
end
else
case calculator.calculation_basis
when "days-worked-per-week"
question :how_many_days_per_week?
when "hours-worked-per-week", "compressed-hours"
question :how_many_hours_per_week?
when "annualised-hours"
outcome :annualised_done
when "shift-worker"
question :shift_worker_hours_per_shift?
end
end
end
end

value_question :hours_in_pay_period?, parse: Float do
on_response do |response|
calculator.hours_in_pay_period = response
end

validate :error_no_hours_worked do
calculator.hours_in_pay_period.positive?
end

next_node do
outcome :irregular_hours_and_part_year_done
end
end

# Q10 - Q15 - Q18
value_question :how_many_hours_per_week?, parse: Float do
on_response do |response|
Expand Down Expand Up @@ -276,6 +325,7 @@ def define
outcome :days_per_week_done
outcome :hours_per_week_done
outcome :compressed_hours_done
outcome :irregular_and_annualised_done
outcome :annualised_done
outcome :irregular_hours_and_part_year_done
end
end

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1 +1 @@
[Read detailed guidance on how holiday entitlement is calculated](/government/publications/holiday-entitlement-calculator-temporary-replacement).
[Read detailed guidance on how holiday entitlement is calculated](/holiday-entitlement-rights).
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
There are no rules on how to convert the entitlement into days or hours for employees who work irregular hours or for part of the year. You can [use the calculator again](https://www.gov.uk/calculate-your-holiday-entitlement/y) and calculate the average days or hours worked each week based on a representative reference period.
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
<% govspeak_for :body do %>
The statutory holiday entitlement is <%= calculator.formatted_full_time_part_time_weeks %> weeks holiday.

There are no regulations on how to convert the entitlement into days or hours for workers with irregular hours.

<%= render partial: "april2024_announcement_for_irregular_hours_or_part_of_the_year" %>

You may wish to [use the calculator again](/calculate-your-holiday-entitlement/y) and calculate the average days or hours worked each week based on a representative reference period instead.
<% if calculator.regular_or_irregular_hours == "irregular-hours-and-part-year" && calculator.leave_year_start_date < (Date.new(2024, 4, 1)) %>
<%= render partial: "irregular_hours_leave_before_april_2024" %>
<% end %>
<%= render partial: 'your_employer_with_rounding' %>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
<% govspeak_for :body do %>
$!The statutory holiday entitlement is <%= "#{calculator.holiday_entitlement_hours} #{'hour'.pluralize(calculator.holiday_entitlement_hours)}" %> and <%= "#{calculator.holiday_entitlement_minutes} #{'minute'.pluralize(calculator.holiday_entitlement_minutes)}" %> holiday for the year. Rather than taking a day’s holiday it’s <%= "#{calculator.hours_daily} #{'hour'.pluralize(calculator.hours_daily)}" %> and <%= "#{calculator.minutes_daily} #{'minute'.pluralize(calculator.minutes_daily)}" %> holiday for each day otherwise worked.$!

<% if calculator.regular_or_irregular_hours == "irregular-hours-and-part-year" && calculator.leave_year_start_date < (Date.new(2024, 4, 1)) %>
<%= render partial: "irregular_hours_leave_before_april_2024" %>
<% end %>
<%= render partial: 'your_employer_with_rounding' %>
<% if calculator.holiday_period == "starting" %>
<%= render partial: "the_user_should_be_aware" %>
<% end %>
<%= render partial: "guidance_on_calculations" %>
<%= render partial: "april2024_announcement_for_irregular_hours_or_part_of_the_year" %>
<% end %>
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
Even though more than 5 days a week are worked, the maximum statutory holiday entitlement is 28 days.
<% end %>
<% if calculator.regular_or_irregular_hours == "irregular-hours-and-part-year" && calculator.leave_year_start_date < (Date.new(2024, 4, 1)) %>
<%= render partial: "irregular_hours_leave_before_april_2024" %>
<% end %>
<%= render partial: "your_employer_with_rounding" %>
<% if calculator.holiday_period == "starting" %>
<%= render partial: "the_user_should_be_aware" %>
<% end %>
<%= render partial: "guidance_on_calculations" %>
<%= render partial: "april2024_announcement_for_irregular_hours_or_part_of_the_year" %>
<% end %>
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
Even though more than 5 days a week are worked the maximum statutory holiday entitlement is 28 days.
<% end %>
<% if calculator.regular_or_irregular_hours == "irregular-hours-and-part-year" && calculator.leave_year_start_date < (Date.new(2024, 4, 1)) %>
<%= render partial: "irregular_hours_leave_before_april_2024" %>
<% end %>
<%= render partial: 'your_employer_with_rounding' %>
<% if calculator.holiday_period == "starting" %>
Expand All @@ -13,5 +17,5 @@
<%= render partial: "guidance_on_calculations" %>
<%= render partial: "april2024_announcement_for_irregular_hours_or_part_of_the_year" %>
<% end %>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<% govspeak_for :body do %>
The statutory entitlement for this pay period is <%= "#{calculator.irregular_hours_entitlement} #{'hour'.pluralize(calculator.irregular_hours_entitlement)}."%>

Employees cannot accrue more than 28 days (5.6 weeks) over the leave year.

The employer:

- can include bank and public holidays as part of the statutory entitlement
- must round up to the nearest hour if the entitlement is 0.5 of an hour or more (for example, 3.6 hours is 4 hours’ entitlement)
- can include an amount for holiday pay in the hourly rate (‘rolled-up holiday pay’) for irregular hours and part-year workers
- can provide more paid holiday - this will be in the employment contract and is called ‘contractual leave entitlement’
<% end %>
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
Even though more than 5 shifts a week are worked the maximum statutory holiday entitlement is 28 shifts.
<% end %>
<% if calculator.regular_or_irregular_hours == "irregular-hours-and-part-year" && calculator.leave_year_start_date < (Date.new(2024, 4, 1)) %>
<%= render partial: "irregular_hours_leave_before_april_2024" %>
<% end %>
<%= render partial: 'shift_worker_your_employer_with_rounding' %>
<% if calculator.holiday_period == "starting" %>
<%= render partial: "the_user_should_be_aware" %>
<% end %>
<%= render partial: "guidance_on_calculations" %>
<%= render partial: "april2024_announcement_for_irregular_hours_or_part_of_the_year" %>
<% end %>
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<% options(
"days-worked-per-week": "days worked per week",
"hours-worked-per-week": "hours worked per week",
"irregular-hours": "casual or irregular hours, including zero hours contracts",
"annualised-hours": "annualised hours",
"compressed-hours": "compressed hours",
"shift-worker": "shifts"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<% text_for :title do %>
How many hours has the employee worked in the pay period?
<% end %>
<% text_for :error_no_hours_worked do %>
You need to enter a number greater than 0. Do not enter fractions. If you work half-hours, enter .5 for half. For example 4.5
<% end %>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<% text_for :title do %>
Does the employee work irregular hours or for part of the year?
<% end %>
<% options(
"irregular-hours-and-part-year": "Yes",
"regular": "No",
) %>
<% text_for :hint do %>
‘Irregular hours’ means the number of hours an employee works in a pay period often or always changes. ‘Part of the year’ means there are periods of at least a week in a leave year where the employee does not need to work and is not paid.
<% end %>
3 changes: 2 additions & 1 deletion app/flows/calculate_your_holiday_entitlement_flow/start.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@
- a full leave year
- part of a leave year, if the job started or finished part way through the year

^If you work irregular hours or for part of the year, there are different rules for calculating holiday entitlement if your leave year began after 1 April 2024. [Read guidance on how to calculate your entitlement](/holiday-entitlement-rights/calculate-leave-entitlement).
If an employee works irregular hours or for part of the year, you also use this calculator to work out how much leave they’ve built up (‘accrued’) over a pay period.

<% end %>
33 changes: 15 additions & 18 deletions lib/smart_answer/calculators/holiday_entitlement.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,23 @@ class HolidayEntitlement
DAYS_PER_WEEK = 7.to_d
DAYS_PER_LEAP_YEAR = 366.to_d
STANDARD_WORKING_DAYS_PER_WEEK = 5.to_d
PERCENT_OF_HOURS_ENTITLED_TO = (12.07 / 100).to_f

attr_accessor :calculation_basis,
:holiday_period,
:leave_year_start_date,
:hours_per_shift
:hours_per_shift,
:regular_or_irregular_hours,
:hours_in_pay_period,
:start_date,
:leaving_date

attr_reader :hours_per_week,
:start_date,
:leaving_date,
:working_days_per_week,
:shifts_per_shift_pattern,
:days_per_shift_pattern

def initialize
@leave_year_start_date = calculate_leave_year_start_date
end

def start_date=(date)
@start_date = date
@leave_year_start_date = calculate_leave_year_start_date
end

def leaving_date=(date)
@leaving_date = date
@leave_year_start_date = calculate_leave_year_start_date
end
def initialize; end

def hours_per_week=(hours)
@hours_per_week = BigDecimal(hours, 10)
Expand Down Expand Up @@ -181,9 +172,15 @@ def shifts_per_week
(shifts_per_shift_pattern / days_per_shift_pattern * DAYS_PER_WEEK).round(10)
end

def irregular_hours_entitlement
(hours_in_pay_period.to_f * PERCENT_OF_HOURS_ENTITLED_TO).round
end

private

def calculate_leave_year_start_date
return leave_year_start_date if leave_year_start_date.present?

worked_partial_year? ? start_date : Time.zone.today
end

Expand All @@ -210,11 +207,11 @@ def months_worked
end

def leave_year_range
SmartAnswer::YearRange.resetting_on(leave_year_start_date).including(date_calc)
SmartAnswer::YearRange.resetting_on(calculate_leave_year_start_date).including(date_calc)
end

def date_calc
return leave_year_start_date if worked_full_year?
return calculate_leave_year_start_date if worked_full_year?

return leaving_date if leaving_date

Expand Down
Loading

0 comments on commit 021c778

Please sign in to comment.