Home

Awesome

Salary slip kata

Problem description: Salary slip generator for UK companies.

A typical salary slip contains employee details like employee id, employee name and their monthly salary details like their gross salary, national insurance contributions, tax-free allowance, taxable income and tax payable.

Salary slips are generated each month for every employee.

Acceptance criteria:

Java:


      public class SalarySlipGenerator {
        public SalarySlip generateFor(Employee employee);
      }

C#:

    public class SalarySlipGenerator
    {
        public SalarySlip GenerateFor(Employee employee);
    }

You can, however, add private methods and fields to the SalarySlipGenerator class, change the constructor, and add extra classes.

Iterations

Each iteration adds more rules to the calculation. Some iterations also introduce new fields to the salary slip.

In a given iteration, all the salary slips contain the same number fields for each employee (if a tax or contribution does not apply for a given employee, just put £0.00).

This means that for each iteration you will need to add fields to the SalarySlip class. In the first iteration, SalarySlip only contains the Employee ID, Employee Name and Monthly Gross Salary.

Iteration 1: for an annual salary of £5,000.00

This is the most basic case.

<p>*Given* I have an employee John J Doe with an annual gross salary of £5,000.00</p> <p>*When* I generate a monthly salary slip for the employee</p> <p>*Then* the monthly salary slip should contain the below:</p>
       Employee ID: 12345
       Employee Name: John J Doe
       Gross Salary: £416.67

Calculation rules:

Iteration 2: for an annual gross salary of £9,060.00

Here we introduce the National Insurance contribution

<p>The monthly salary slip should contain the below:</p>
       Employee ID: 12345
       Employee Name: John J Doe
       Gross Salary: £755.00
       National Insurance contributions: £10.00

Calculation rules:

Iteration 3: for an annual gross salary of £12,000.00

This employee also needs to pay taxes

<p>The monthly salary slip should contain the below:</p>
       Employee ID: 12345
       Employee Name: John J Doe
       Gross Salary: £1,000.00
       National Insurance contributions: £39.40
       Tax-free allowance: £916.67
       Taxable income: £83.33
       Tax Payable: £16.67

Calculation rules:

Iteration 4: for an annual gross salary of £45,000.00

This employee pays a higher band of National Insurance and Income Tax.

<p>The monthly salary slip should contain the below:</p>
       Employee ID: 12345
       Employee Name: John J Doe
       Gross Salary: £3,750.00
       National Insurance contributions: £352.73
       Tax-free allowance: £916.67
       Taxable income: £2,833.33
       Tax Payable: £600.00

Calculation rules:

Iteration 5: for annual gross salaries of £101,000.00; £111,000.00; £122,000.00 and £150,000.00

For high earners, the tax-free allowance decreases.

<p>The monthly salary slips should contain the below (respectively):</p>
       Employee ID: 12345
       Employee Name: John J Doe
       Gross Salary: £8,416.67
       National Insurance contributions: £446.07
       Tax-free allowance: £875.00
       Taxable income: £7,541.67
       Tax Payable: £2,483.33
<br>
       Employee ID: 12345
       Employee Name: John J Doe
       Gross Salary: £9,250.00
       National Insurance contributions: £462.73
       Tax-free allowance: £458.33
       Taxable income: £8,791.67
       Tax Payable: £2,983.33
<br>
       Employee ID: 12345
       Employee Name: John J Doe
       Gross Salary: £10,166.67
       National Insurance contributions: £481.07
       Tax-free allowance: £0.00
       Taxable income: £10,166.67
       Tax Payable: £3,533.33
<br>
       Employee ID: 12345
       Employee Name: John J Doe
       Gross Salary: £12,500.00
       National Insurance contributions: £527.73
       Tax-free allowance: £0.00
       Taxable income: £12,500.00
       Tax Payable: £4,466.67

Calculation rules:

Iteration 6: for an annual gross salary of £160,000.00

The employee goes into the additional rate band.

<p>The monthly salary slip should contain the below:</p>
      Employee ID: 12345
      Employee Name: John J Doe
      Gross Salary: £13,333.33
      National Insurance contributions: £544.40
      Tax-free allowance: £0.00
      Taxable income: £13,333.33
      Tax Payable: £4,841.67

Calculation rules:

Details on calculation rules

The DETAILS.md file contains a condensed version of the calculation rules with more examples and links to additional resources.

You do not need to read it to complete the Kata, but it is provided to you as an extra help.