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 #2161

Merged
merged 21 commits into from
Dec 8, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
8edbee9
Add living wage to wage calculator
chrisroos Nov 23, 2015
bd63cd5
Update am-i-getting-minimum-wage-questions-and-responses.yml
chrisroos Nov 23, 2015
ffe163f
Update am-i-getting-minimum-wage-responses-and-expected-results.yml
chrisroos Nov 23, 2015
1ec9d25
Regenerate test artefacts for am-i-getting-minimum-wage
chrisroos Nov 23, 2015
42cf2cf
Add 1st to April 2016 to indicate living wage start date
chrisroos Nov 23, 2015
6d32901
Regenerate test artefacts for am-i-getting-minimum-wage
chrisroos Nov 23, 2015
8858f13
Rename MinimumWageCalculator#check
erkde Nov 9, 2015
cbc44f4
Ask person's age when checking for national living wage
chrisroos Nov 23, 2015
6c98925
Update am-i-getting-minimum-wage-responses-and-expected-results.yml
chrisroos Nov 23, 2015
dffe505
Regenerate test artefacts for am-i-getting-minimum-wage
chrisroos Nov 23, 2015
5abd191
Update _acas_information.govspeak.erb
chrisroos Nov 23, 2015
9424631
Regenerate test artefacts for am-i-getting-minimum-wage
chrisroos Nov 23, 2015
07fbd3a
Regenerate test artefacts for minimum-wage-calculator-employers
chrisroos Nov 23, 2015
8fee7ca
Update _acas_information.govspeak.erb
chrisroos Nov 23, 2015
f92e4e0
Regenerate test artefacts for am-i-getting-minimum-wage
chrisroos Nov 23, 2015
549e99d
Regenerate test artefacts for minimum-wage-calculator-employers
chrisroos Nov 23, 2015
e616184
Update checksum data for minimum-wage flows
chrisroos Nov 23, 2015
b6596e0
Add living wage restriction for apprentices
erkde Dec 4, 2015
909be50
Move the specific logic from shared to flow files
erkde Dec 8, 2015
b6454ea
Regenerate checksums for smart answer artefacts
erkde Dec 8, 2015
486c309
Regenerate checksums for smart answer artefacts
erkde Dec 8, 2015
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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
92 changes: 92 additions & 0 deletions lib/smart_answer_flows/am-i-getting-minimum-wage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,99 @@ def define
status :published
satisfies_need "100145"

# Q1
multiple_choice :what_would_you_like_to_check? do
option "current_payment"
option "past_payment"
option "current_payment_april_2016"

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?,
:will_you_be_a_first_year_apprentice?,
: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'
:will_you_be_a_first_year_apprentice?
when 'past_payment'
:past_payment_date?
end
end
end

# Q2 - April 2016
multiple_choice :will_you_be_a_first_year_apprentice? do
option :yes
option :no

permitted_next_nodes = [
:does_not_apply_to_first_year_apprentices,
:how_old_are_you?
]

next_node(permitted: permitted_next_nodes) do |response|
case response
when 'yes'
calculator.is_apprentice = true
:does_not_apply_to_first_year_apprentices
when 'no'
:how_old_are_you? #Q3
end
end
end

# Q3
value_question :how_old_are_you?, parse: Integer do
precalculate :age_title do
if calculator.what_to_check == 'current_payment_april_2016'
"How old will you be on 1 April 2016?"
else
"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?
]

next_node(permitted: permitted_next_nodes) do |response|
calculator.age = response
if calculator.under_school_leaving_age?
:under_school_leaving_age
else
:how_often_do_you_get_paid?
end
end
end

use_shared_logic "minimum_wage"

outcome :does_not_apply_to_first_year_apprentices
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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' -%>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<% content_for :body do %>
You won't get the national living wage as a first year apprentice.

You'll only get the [National Minimum Wage for an apprentice.](/apprenticeships-guide/pay-and-conditions)
<% end %>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<% content_for :title do %>
How old are you?
<%= age_title %>
<% end %>

<% content_for :suffix_label do %>
Expand All @@ -9,3 +9,6 @@
<% content_for :error_message do %>
Please enter a whole number greater than 0
<% end %>
<% content_for :valid_age_for_living_wage? do %>
You must be 25 or over to get the national living wage
<% end %>
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@

<% 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)"
"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)"
) %>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<% content_for :title do %>
Will you be in the first year of an apprenticeship on 1 April 2016?
<% end %>

<% options(
"no": "No",
"yes": "Yes"
) %>
53 changes: 53 additions & 0 deletions lib/smart_answer_flows/minimum-wage-calculator-employers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,59 @@ def define
status :published
satisfies_need "100145"

# Q1
multiple_choice :what_would_you_like_to_check? do
option "current_payment"
option "past_payment"

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?,
:past_payment_date?
]

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

# Q3
value_question :how_old_are_you?, parse: Integer do
precalculate :age_title do
"How old are you?"
end

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

permitted_next_nodes = [
:under_school_leaving_age,
:how_often_do_you_get_paid?
]

next_node(permitted: permitted_next_nodes) do |response|
calculator.age = response
if calculator.under_school_leaving_age?
:under_school_leaving_age
else
:how_often_do_you_get_paid?
end
end
end

use_shared_logic "minimum_wage"
end
end
Expand Down
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

Expand Down
Loading