Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add living wage to wage calculator #2042

Closed
wants to merge 6 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
32 changes: 25 additions & 7 deletions lib/smart_answer/calculators/minimum_wage_calculator.rb
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
module SmartAnswer::Calculators
class MinimumWageCalculator

attr_accessor :overtime_hours, :overtime_hourly_rate, :accommodation_cost
attr_accessor :age, :pay_frequency, :basic_hours, :basic_pay, :is_apprentice,
:overtime_hours, :overtime_hourly_rate, :accommodation_cost

attr_accessor :age, :date, :pay_frequency, :basic_hours, :basic_pay, :is_apprentice

def date=(date)
@date = date
@minimum_wage_data = minimum_wage_data_for_date(@date)
end
attr_reader :date, :what_to_check

def initialize(params = {})
@age = params[:age]
@date = (params[:date].nil? ? Date.today : params[:date])
@basic_hours = params[:basic_hours].to_f
@basic_pay = params[:basic_pay].to_f
@what_to_check = params[:what_to_check]
@is_apprentice = params[:is_apprentice]
@pay_frequency = params[:pay_frequency] || 7
@overtime_hours = params[:overtime_hours].to_i || 0
@@ -23,6 +20,11 @@ def initialize(params = {})
@minimum_wage_data = minimum_wage_data_for_date(@date)
end

def date=(date)
@date = date
@minimum_wage_data = minimum_wage_data_for_date(@date)
end

def valid_age?(age)
age > 0 && age <= 200
end
@@ -47,6 +49,10 @@ def valid_accommodation_usage?(accommodation_usage)
accommodation_usage >= 0 && accommodation_usage <= 7
end

def valid_age_for_living_wage?(age)
age.to_i >= 25
end

def basic_rate
rate = @basic_pay / @basic_hours
if overtime_hours > 0 and overtime_hourly_rate > 0 and rate > overtime_hourly_rate
@@ -122,6 +128,10 @@ def minimum_wage_or_above?
minimum_hourly_rate <= total_hourly_rate
end

def living_wage_or_above?
national_living_wage_rate <= total_hourly_rate.to_f
end

def accommodation_adjustment(charge, number_of_nights)
charge = charge.to_f
number_of_nights = number_of_nights.to_i
@@ -156,10 +166,18 @@ def free_accommodation_rate
@minimum_wage_data[:accommodation_rate]
end

def national_living_wage_rate
7.2
end

def apprentice_eligible_for_minimum_wage?
date >= Date.parse('2010-10-01')
end

def eligible_for_living_wage?
valid_age_for_living_wage?(age)
end

def under_school_leaving_age?
age < 16
end
Original file line number Diff line number Diff line change
@@ -3,9 +3,13 @@
<% end %>

<% content_for :meta_description do %>
Check if your pay matches the National Minimum Wage or if your employer owes you payments from past years.
Check if your pay matches the National Minimum Wage, the national living wage or if your employer owes you payments from past years.
<% end %>

<% content_for :body do %>
Check if your pay matches the National Minimum Wage or if your employer owes you payments from past years.

You can also check if you'll get the national living wage from 1 April 2016.

^You must be at least 25 years old to get the national living wage.^
<% end %>
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
<% content_for :body do %>
$C
You are getting the National Minimum Wage.
<% if calculator.what_to_check == 'current_payment_april_2016' && calculator.eligible_for_living_wage? %>
<% if calculator.living_wage_or_above? %>
You will be getting the national living wage
<% else %>
You are getting the National Minimum wage but your pay should be increased to at least the national living wage from 1 April 2016.
<% end %>
<% else %>
You are getting the National Minimum Wage.
<% end %>
$C

The National Minimum Wage per hour for your age | Your actual pay
- | -
<%= format_money(calculator.minimum_hourly_rate) %> | <%= format_money(calculator.total_hourly_rate) %>
<% if calculator.what_to_check == 'current_payment_april_2016' && calculator.eligible_for_living_wage? %>
The national living wage per hour for your age will be | Your actual pay
<% else %>
The National Minimum Wage per hour for your age | Your actual pay
<% end %>
- | -
<% if calculator.what_to_check == 'current_payment_april_2016' && calculator.eligible_for_living_wage? %>
<%= format_money(calculator.national_living_wage_rate) %> | <%= format_money(calculator.total_hourly_rate) %>
<% else %>
<%= format_money(calculator.minimum_hourly_rate) %> | <%= format_money(calculator.total_hourly_rate) %>
<% end %>

If you work overtime or your employer provides you with [accommodation](/national-minimum-wage-accommodation), this has been added to the calculation.

Original file line number Diff line number Diff line change
@@ -9,6 +9,8 @@

\* This figure has been rounded to the nearest penny.

^Your actual pay should increase to at least £7.20 per hour from 1 April 2016.^

If you work overtime or your employer provides you with [accommodation](/national-minimum-wage-accommodation), this has been added to the calculation.

<%= render partial: '../../shared/minimum_wage/acas_information.govspeak.erb' -%>
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
en-GB:
flow:
am-i-getting-minimum-wage:
phrases:
how_old_are_you: "How old are you?"
how_old_are_you_april_2016: "How old will you be on 1 April 2016?"

# Q1
what_would_you_like_to_check?:
title: "What would you like to check?"
options:
current_payment: "If you're getting the National Minimum Wage (from October 2015)"
past_payment: "If an employer owes you past payments (before October 2015)"
current_payment_april_2016: "If you'll get the national living wage (from 1 April 2016)"
# Q1A
past_payment_date?:
title: "Which year would you like to check past payments for?"
@@ -37,9 +42,10 @@ en-GB:
apprentice_over_19: "Apprentice aged 19 and over and in your first year"
# Q3
how_old_are_you?:
title: How old are you?
title: "%{age_title}"
suffix_label: years old
error_message: Please enter a whole number greater than 0
valid_age_for_living_wage?: You must be 25 or over to get the national living wage
# Q3 Past
how_old_were_you?:
title: How old were you at the time?
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
This result is an estimate. If you have any questions, call the confidential helpline:
This result is an estimate. If you have any questions, call the confidential helpline.


$C
Acas helpline
Telephone: 0300 123 1100
**Acas helpline**\\
Telephone: 0300 123 1100\\
Monday to Friday, 8am to 8pm\\
Saturday, 9am to 1pm\\
[Find out about call charges](/call-charges)
$C

28 changes: 24 additions & 4 deletions lib/smart_answer_flows/shared_logic/minimum_wage.rb
Original file line number Diff line number Diff line change
@@ -2,28 +2,32 @@
multiple_choice :what_would_you_like_to_check? do
option "current_payment"
option "past_payment"
option "current_payment_april_2016" if self.flow_name == 'am-i-getting-minimum-wage'

calculate :calculator do |response|
Calculators::MinimumWageCalculator.new(what_to_check: response)
end

calculate :accommodation_charge do
nil
end

permitted_next_nodes = [
:are_you_an_apprentice?,
:how_old_are_you?,
:past_payment_date?
]

next_node(permitted: permitted_next_nodes) do |response|
case response
when 'current_payment'
:are_you_an_apprentice?
when 'current_payment_april_2016'
:how_old_are_you?
when 'past_payment'
:past_payment_date?
end
end

calculate :calculator do
Calculators::MinimumWageCalculator.new
end
end

# Q1A
@@ -98,10 +102,26 @@

# Q3
value_question :how_old_are_you?, parse: Integer do
precalculate :age_title do
if calculator.what_to_check == 'current_payment_april_2016'
PhraseList.new(:how_old_are_you_april_2016)
else
PhraseList.new(:how_old_are_you)
end
end

validate do |response|
calculator.valid_age?(response)
end

validate :valid_age_for_living_wage? do |response|
if calculator.what_to_check == 'current_payment_april_2016'
calculator.valid_age_for_living_wage?(response)
else
true
end
end

permitted_next_nodes = [
:under_school_leaving_age,
:how_often_do_you_get_paid?
Original file line number Diff line number Diff line change
@@ -2,3 +2,7 @@ National Minimum Wage calculator for workers

Check if your pay matches the National Minimum Wage or if your employer owes you payments from past years.

You can also check if you'll get the national living wage from 1 April 2016.

^You must be at least 25 years old to get the national living wage.^

Original file line number Diff line number Diff line change
@@ -10,11 +10,13 @@ The National Minimum Wage per hour for your age | Your actual pay

If you work overtime or your employer provides you with [accommodation](/national-minimum-wage-accommodation), this has been added to the calculation.

This result is an estimate. If you have any questions, call the confidential helpline:
This result is an estimate. If you have any questions, call the confidential helpline.

$C
Acas helpline
Telephone: 0300 123 1100
**Acas helpline**\\
Telephone: 0300 123 1100\\
Monday to Friday, 8am to 8pm\\
Saturday, 9am to 1pm\\
[Find out about call charges](/call-charges)
$C

Original file line number Diff line number Diff line change
@@ -10,11 +10,13 @@ The National Minimum Wage per hour for your age | Your actual pay

If you work overtime or your employer provides you with [accommodation](/national-minimum-wage-accommodation), this has been added to the calculation.

This result is an estimate. If you have any questions, call the confidential helpline:
This result is an estimate. If you have any questions, call the confidential helpline.

$C
Acas helpline
Telephone: 0300 123 1100
**Acas helpline**\\
Telephone: 0300 123 1100\\
Monday to Friday, 8am to 8pm\\
Saturday, 9am to 1pm\\
[Find out about call charges](/call-charges)
$C

Original file line number Diff line number Diff line change
@@ -10,11 +10,13 @@ The National Minimum Wage per hour for your age | Your actual pay

If you work overtime or your employer provides you with [accommodation](/national-minimum-wage-accommodation), this has been added to the calculation.

This result is an estimate. If you have any questions, call the confidential helpline:
This result is an estimate. If you have any questions, call the confidential helpline.

$C
Acas helpline
Telephone: 0300 123 1100
**Acas helpline**\\
Telephone: 0300 123 1100\\
Monday to Friday, 8am to 8pm\\
Saturday, 9am to 1pm\\
[Find out about call charges](/call-charges)
$C

Original file line number Diff line number Diff line change
@@ -10,11 +10,13 @@ The National Minimum Wage per hour for your age | Your actual pay

If you work overtime or your employer provides you with [accommodation](/national-minimum-wage-accommodation), this has been added to the calculation.

This result is an estimate. If you have any questions, call the confidential helpline:
This result is an estimate. If you have any questions, call the confidential helpline.

$C
Acas helpline
Telephone: 0300 123 1100
**Acas helpline**\\
Telephone: 0300 123 1100\\
Monday to Friday, 8am to 8pm\\
Saturday, 9am to 1pm\\
[Find out about call charges](/call-charges)
$C

Original file line number Diff line number Diff line change
@@ -10,11 +10,13 @@ The National Minimum Wage per hour for your age | Your actual pay

If you work overtime or your employer provides you with [accommodation](/national-minimum-wage-accommodation), this has been added to the calculation.

This result is an estimate. If you have any questions, call the confidential helpline:
This result is an estimate. If you have any questions, call the confidential helpline.

$C
Acas helpline
Telephone: 0300 123 1100
**Acas helpline**\\
Telephone: 0300 123 1100\\
Monday to Friday, 8am to 8pm\\
Saturday, 9am to 1pm\\
[Find out about call charges](/call-charges)
$C

Original file line number Diff line number Diff line change
@@ -10,11 +10,13 @@ The National Minimum Wage per hour for your age | Your actual pay

If you work overtime or your employer provides you with [accommodation](/national-minimum-wage-accommodation), this has been added to the calculation.

This result is an estimate. If you have any questions, call the confidential helpline:
This result is an estimate. If you have any questions, call the confidential helpline.

$C
Acas helpline
Telephone: 0300 123 1100
**Acas helpline**\\
Telephone: 0300 123 1100\\
Monday to Friday, 8am to 8pm\\
Saturday, 9am to 1pm\\
[Find out about call charges](/call-charges)
$C

Original file line number Diff line number Diff line change
@@ -10,11 +10,13 @@ The National Minimum Wage per hour for your age | Your actual pay

If you work overtime or your employer provides you with [accommodation](/national-minimum-wage-accommodation), this has been added to the calculation.

This result is an estimate. If you have any questions, call the confidential helpline:
This result is an estimate. If you have any questions, call the confidential helpline.

$C
Acas helpline
Telephone: 0300 123 1100
**Acas helpline**\\
Telephone: 0300 123 1100\\
Monday to Friday, 8am to 8pm\\
Saturday, 9am to 1pm\\
[Find out about call charges](/call-charges)
$C

Original file line number Diff line number Diff line change
@@ -10,11 +10,13 @@ The National Minimum Wage per hour for your age | Your actual pay

If you work overtime or your employer provides you with [accommodation](/national-minimum-wage-accommodation), this has been added to the calculation.

This result is an estimate. If you have any questions, call the confidential helpline:
This result is an estimate. If you have any questions, call the confidential helpline.

$C
Acas helpline
Telephone: 0300 123 1100
**Acas helpline**\\
Telephone: 0300 123 1100\\
Monday to Friday, 8am to 8pm\\
Saturday, 9am to 1pm\\
[Find out about call charges](/call-charges)
$C

Loading