Extracted from /home/wizard/code monorepo into its own repo so Woodpecker CI can watch it. Identical content to /home/wizard/code commit e426028. See README.md for overview, env vars, and Paperless workflow config. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
16 lines
612 B
Python
16 lines
612 B
Python
from datetime import date
|
|
|
|
UK_TAX_YEAR_START_MONTH = 4
|
|
UK_TAX_YEAR_START_DAY = 6
|
|
|
|
|
|
def derive_tax_year(pay_date: date) -> str:
|
|
"""Return the UK tax year label (e.g. "2026/27") for a given pay date.
|
|
|
|
UK tax years run 6 April to 5 April. A pay_date on 5 Apr belongs to the
|
|
previous start-year; on 6 Apr it belongs to the current start-year.
|
|
"""
|
|
boundary = date(pay_date.year, UK_TAX_YEAR_START_MONTH, UK_TAX_YEAR_START_DAY)
|
|
start_year = pay_date.year if pay_date >= boundary else pay_date.year - 1
|
|
end_year_suffix = str(start_year + 1)[-2:]
|
|
return f"{start_year}/{end_year_suffix}"
|