Skip to content

Commit

Permalink
Merge pull request #6753 from alphagov/updating_employee_parental_pay…
Browse files Browse the repository at this point in the history
…_calculator

Updating employee parental pay calculator for users in Northern Ireland
  • Loading branch information
anatron committed Apr 29, 2024
2 parents e670cfd + 3d6d4fb commit 7c41abc
Show file tree
Hide file tree
Showing 9 changed files with 349 additions and 23 deletions.
21 changes: 20 additions & 1 deletion app/flows/maternity_paternity_pay_leave_flow.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,26 @@ def define
end

next_node do
outcome :due_date
if calculator.two_carers?
question :where_does_the_mother_partner_live
else
question :due_date
end
end
end

radio :where_does_the_mother_partner_live do
option "england"
option "scotland"
option "wales"
option "northern_ireland"

on_response do |response|
calculator.where_does_the_mother_partner_live = response
end

next_node do
question :due_date
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

The mother’s partner can take up to 2 weeks' [paternity leave](/paternity-pay-leave/leave).

Paternity leave must be used by <%= format_date(calculator.paternity_leave_deadline_date) %>.
Paternity leave must be used by <%= format_date(calculator.take_paternity_leave_by_date) %>.

Tell the partner’s employer by <%= format_date(calculator.paternity_leave_notice_date) %>.
Tell the partner’s employer by <%= format_date(calculator.give_paternity_leave_notice_by_date) %>.
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,6 @@ Tell the partner’s employer | 28 days before they want to start paternity pay

<% else %>

Tell the partner’s employer | by <%= format_date(calculator.paternity_leave_notice_date) %>
Tell the partner’s employer | by <%= format_date(calculator.give_paternity_leave_notice_by_date) %>
<% end %>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<% text_for :title do %>
Where does the mother’s partner live?
<% end %>
<% options(
"england": "England",
"scotland": "Scotland",
"wales": "Wales",
"northern_ireland": "Northern Ireland"
) %>
5 changes: 1 addition & 4 deletions app/flows/maternity_paternity_pay_leave_flow/start.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@
* Statutory Paternity Leave or Pay
* Maternity Allowance

There are different rules for:

* [paternity leave if you’re in Northern Ireland](https://www.nidirect.gov.uk/articles/paternity-leave)
* [claiming adoption pay and leave](/adoption-pay-leave) for adoptions or surrogacies
^There are different rules for [claiming adoption pay and leave](/adoption-pay-leave) for adoptions or surrogacies.

<% end %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ class MaternityPaternityPayLeaveCalculator
include ActiveModel::Model

attr_accessor :two_carers,
:where_does_the_mother_partner_live,
:due_date,
:employment_status_of_mother,
:employment_status_of_partner,
Expand All @@ -15,7 +16,7 @@ class MaternityPaternityPayLeaveCalculator
:partner_still_working_on_continuity_end_date,
:partner_earned_more_than_lower_earnings_limit

DATE_TO_APPLY_28_DAY_PATERNITY_LEAVE_NOTICE_PERIOD_FROM = Date.new(2024, 4, 7)
APRIL_2024_PATERNITY_LEAVE_RULES_CHANGE_DATE = "2024-04-07".freeze

def first_day_in_year(year)
date = Date.new(year, 4, 1)
Expand Down Expand Up @@ -151,17 +152,16 @@ def maternity_leave_notice_date
saturday_before(due_date - 14.weeks)
end

def paternity_leave_notice_date
if due_date >= DATE_TO_APPLY_28_DAY_PATERNITY_LEAVE_NOTICE_PERIOD_FROM
def give_paternity_leave_notice_by_date
if due_date_on_or_after(APRIL_2024_PATERNITY_LEAVE_RULES_CHANGE_DATE) && !mother_partner_living_in_northern_ireland
due_date - 28.days
else
# Preserve the previous behaviour
maternity_leave_notice_date
end
end

def paternity_leave_deadline_date
if due_date >= Date.new(2024, 4, 7)
def take_paternity_leave_by_date
if due_date_on_or_after(APRIL_2024_PATERNITY_LEAVE_RULES_CHANGE_DATE) && !mother_partner_living_in_northern_ireland
due_date + 364.days
else
due_date + 56.days
Expand All @@ -170,6 +170,14 @@ def paternity_leave_deadline_date

private

def mother_partner_living_in_northern_ireland
where_does_the_mother_partner_live == "northern_ireland"
end

def due_date_on_or_after(date)
due_date >= Date.parse(date)
end

def saturday_before(date)
(date - date.wday) - 1.day
end
Expand Down

0 comments on commit 7c41abc

Please sign in to comment.