An implementation of UK income tax Pay-As-You-Earn calculations
Project description
PAYE
Implementation of UK Income Tax Pay-As-You-Earn algorithms
In the UK, many employees and pensioners pay income tax in weekly or monthly installments as a deduction on their payslip under a system known as Pay-As-You-Earn or PAYE.
In this system, His/Her Majesty's Revenue and Customs (HMRC) gives the employer/pension provider a "Tax Code" which they use to calculate how much income tax to deduct.
This package implements the algorithms for calculating the income tax due as defined by HMRC in their "SPECIFICATION FOR PAYE TAX TABLE ROUTINES" from version 18, dated March 2020 onwards. This is what is meant by "the specification" in the rest of this document.
HMRC Constants
The algorithms use a set of constants that are dependent on tax year and are defined in the specification.
This package reads the constants from a TOML file 'hmrc.toml' which needs to be updated for each new tax year.
Exported Objects
- the TaxCode class
- the Payslip class
- utility function str_to_decimal
Usage
Weekly vs Monthly pay is selected by the environment variable PAYE_PERIOD: PAYE_PERIOD=weekly or PAYE_PERIOD=monthly
if unset, monthly is assumed
The inputs are:
- The pay date
- Your basic pay for the week / month
- Your tax code for the week / month (as given by HMRC via a letter or your Personal Tax Account on gov.uk)
- Any pay adjustments for the week / month (e.g. bonus)
- Any payrolled benefits in kind ... and for cumulative tax codes;
- Your total gross pay for the tax year including this week / month
- The income tax you've paid so far this tax year, NOT including this week/month
Use these to create an instance of the Payslip class
The income tax for this week / month is provided by the income tax property of the payslip.
For example:
import paye
from decimal import Decimal
from fiscalyear import FiscalDate
payslip = paye.Payslip(
pay_date = FiscalDate(2026, 4, 30),
basic_pay=Decimal('1156.25'),
code=paye.TaxCode('1257L'),
pay_to_date=Decimal('1156.25'),
tax_to_date_non_inclusive=Decimal('0.00')
)
print(f"Income tax due this period = {payslip.income_tax}")
Note on weekly pay
The algorithms in the specification use 52 periods for weekly pay, but 52 * 7 = 364 so 5th of April (or 4th and 5th on a leap year) have week number 53. The HMRC test cases do not validate the algorithm for week 53 so this package may calculate incorrect income tax for weekly paid employees if the pay day falls in week 53.
Testing
This module is validated against the test cases provided by HMRC
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file paye-0.8.1.tar.gz.
File metadata
- Download URL: paye-0.8.1.tar.gz
- Upload date:
- Size: 93.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: Hatch/1.16.5 cpython/3.14.5 HTTPX/0.28.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
07837386a11864c613c7970c06ba864ce5c036ced693c410866206b40ab5367a
|
|
| MD5 |
89b1a23e0476fba0f7701226b11624ac
|
|
| BLAKE2b-256 |
2ed456e1e14c5e9cfe5448fb0f7313ae6501cbdc84e39a4be176381127e4cb01
|
File details
Details for the file paye-0.8.1-py3-none-any.whl.
File metadata
- Download URL: paye-0.8.1-py3-none-any.whl
- Upload date:
- Size: 10.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: Hatch/1.16.5 cpython/3.14.5 HTTPX/0.28.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4ed69390b63db24997b898b2ad676eeb29216a33a09ca2ec9ee844ade6a932e1
|
|
| MD5 |
1925be4aa0cf6514cde16604efcf06b4
|
|
| BLAKE2b-256 |
d7b15cb20ec80dedac7ed60bee1be7d4790235fe13296cc1397e7b64c101db1c
|