Skip to main content

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
  3. the DescribedAmount named tuple

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

Metadata

Release files for paye 0.11.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for paye 0.11.0
File Size Uploaded Provenance Actions
paye-0.11.0.tar.gz 94.3 kB Without provenance Details for paye-0.11.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for paye 0.11.0
File Interpreter ABI Platform Actions
paye-0.11.0-py3-none-any.whl Python 3 none any Details for paye-0.11.0-py3-none-any.whl

Total release size: 104.7 kB

Release files / paye-0.11.0.tar.gz

Download URL paye-0.11.0.tar.gz
Size 94.3 kB
Tags Source
SHA-256 checksum
How to use checksums
99972ecf8b22ef5afda649a50e77466abec8baf291d60215bc2ebc870b8f2c8f
BLAKE2b-256 checksum
How to use checksums
bc552de36e318918682f3d3c57c1ecf91a4b4d7e4f80eec52d3723002ccb7568
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via Hatch/1.18.1 {"ci":null,"cpu":"x86_64","distro":{"libc":{"lib":"glibc","version":"2.44"},"name":"Arch Linux"},"implementation":{"name":"CPython","version":"3.14.10"},"installer":{"name":"hatch","version":"1.18.1"},"openssl_version":"OpenSSL 3.5.9 29 Sep 2026","python":"3.14.10","system":{"name":"Linux","release":"7.2.15-arch1-1"}} HTTPX2/2.13.1

Release files / paye-0.11.0-py3-none-any.whl

Download URL paye-0.11.0-py3-none-any.whl
Size 10.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
877941f1ef885a52aca318fda0af3a3f5f538f424913229293e6b69e61fd4aef
BLAKE2b-256 checksum
How to use checksums
8550c766e4032620abe9abf15c687393883e1ea3b2a4803aa2db6fdf0313abad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via Hatch/1.18.1 {"ci":null,"cpu":"x86_64","distro":{"libc":{"lib":"glibc","version":"2.44"},"name":"Arch Linux"},"implementation":{"name":"CPython","version":"3.14.10"},"installer":{"name":"hatch","version":"1.18.1"},"openssl_version":"OpenSSL 3.5.9 29 Sep 2026","python":"3.14.10","system":{"name":"Linux","release":"7.2.15-arch1-1"}} HTTPX2/2.13.1

Security for paye 0.11.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page