Skip to main content

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

  1. the TaxCode class
  2. the Payslip class

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:

  1. The pay date
  2. Your basic pay for the week / month
  3. Your tax code for the week / month (as given by HMRC via a letter or your Personal Tax Account on gov.uk)
  4. Any pay adjustments for the week / month (e.g. bonus)
  5. Any payrolled benefits in kind ... and for cumulative tax codes;
  6. Your total gross pay for the tax year including this week / month
  7. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

paye-0.9.0.tar.gz (94.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

paye-0.9.0-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file paye-0.9.0.tar.gz.

File metadata

  • Download URL: paye-0.9.0.tar.gz
  • Upload date:
  • Size: 94.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Hatch/1.17.0 {"ci":null,"cpu":"x86_64","distro":{"libc":{"lib":"glibc","version":"2.43"},"name":"Arch Linux"},"implementation":{"name":"CPython","version":"3.14.6"},"installer":{"name":"hatch","version":"1.17.0"},"openssl_version":"OpenSSL 3.6.3 9 Jun 2026","python":"3.14.6","system":{"name":"Linux","release":"7.1.2-arch3-1"}} HTTPX2/2.3.0

File hashes

Hashes for paye-0.9.0.tar.gz
Algorithm Hash digest
SHA256 8650ee561421c95c3c367cde079e8b249325c7dc185fbd478ee5b07b61a92d3e
MD5 7736bcffe48c6a6d831f2a7c25d0e336
BLAKE2b-256 7c99122fd47f201dd37b31f9a51d4e3ab6751c29c23542aae0ff5d1352fcc64a

See more details on using hashes here.

File details

Details for the file paye-0.9.0-py3-none-any.whl.

File metadata

  • Download URL: paye-0.9.0-py3-none-any.whl
  • Upload date:
  • Size: 10.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Hatch/1.17.0 {"ci":null,"cpu":"x86_64","distro":{"libc":{"lib":"glibc","version":"2.43"},"name":"Arch Linux"},"implementation":{"name":"CPython","version":"3.14.6"},"installer":{"name":"hatch","version":"1.17.0"},"openssl_version":"OpenSSL 3.6.3 9 Jun 2026","python":"3.14.6","system":{"name":"Linux","release":"7.1.2-arch3-1"}} HTTPX2/2.3.0

File hashes

Hashes for paye-0.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dd45dfeeb31172ca7d7d182194671f00aa0fb5374ceed712fbaa0cae4d25bb94
MD5 f988d0e17f1fc080365e9fd9898b1976
BLAKE2b-256 f0c110a35bad2ad4299f4e4b03866caf686012db4b0fb75e3d2b1e87d480afd8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page