← All articles

Using AI to build payroll software? Don't turn the official worked examples straight into tests

In short
  • A worked example is the first thing a developer, or an AI model, turns into a test. I checked the examples in three official guides and each one has mistakes.
  • HMRC's employer guide calls 5 May 2026 a Wednesday in tax month 2. It is a Tuesday in tax month 1.
  • HMRC's levy guidance for developers prints £1,500 minus £1,250 as £1,250. GOV.UK's maternity pay example uses a qualifying week that is a week early.
On this page
  1. 1. Dates that aren’t on the calendar
  2. 2. Sums that don’t add up
  3. 3. An example that uses the wrong week
  4. What this has to do with AI
  5. What I do about it
  6. Sources

So the first thing I do with a new payroll rule is find the worked example. Somebody official has already picked the numbers and shown the answer, so you copy it into a test and write code until the test passes. AI models do exactly the same thing, just faster.

This follows on from the missing 22 days in regulation 16, where the page was out of date. Here the example itself is wrong.

Tuesdaywhat 5 May 2026 is. HMRC's guide says Wednesday
£250what £1,500 minus £1,250 comes to. The levy guidance prints £1,250
1 weekhow early the maternity pay example puts the qualifying week
11 Nov 2026when the guide with the wrong dates was last republished

1. Dates that aren’t on the calendar#

CWG2 (opens in a new tab) is HMRC’s further guide to PAYE and National Insurance for employers. Section 1.8 (opens in a new tab) covers what to do when payday lands on a weekend or a bank holiday. It matters because the date decides which tax month, and sometimes which tax year, the pay belongs to.

What the guide saysWhat’s wrong
“Pay due on Wednesday 5 May 2026 (tax month 2) but paid on Thursday 6 May 2026” (opens in a new tab)5 May 2026 is a Tuesday. It’s the last day of tax month 1. It isn’t a bank holiday either, that was Monday 4 May
“Regular payday on Friday 3 April 2026 (tax year 2026 to 2027) but paid on Monday 6 April 2026 (tax year 2026 to 2027)” (opens in a new tab)The example is about pay that crosses a tax year, but both dates are given the same year. 3 April is in 2025 to 2026. And 6 April 2026 is Easter Monday, so in England and Wales it isn’t the next working day
For a weekly payday of Friday 18 December, paid a week early: “must be treated as having been paid on 18 December 2026. The ‘payment date’ on the FPS should be 19 December” (opens in a new tab)Two different dates for the same thing, one sentence apart. 19 December is a Saturday

Interactive: pick a payday between 6 April 2025 and 5 April 2027, or one of the dates from HMRC’s guide, and see its day of the week, tax year, tax month, tax week and whether it is a banking day in England and Wales. For the guide’s own dates it shows what CWG2 section 1.8 says next to what the calendar says: 5 May 2026 is a Tuesday in tax month 1, not a Wednesday in tax month 2; 3 April 2026 is in tax year 2025 to 2026; 6 April 2026 is Easter Monday; 19 December 2026 is a Saturday (web version only).

My working
  • A tax month runs from the 6th to the 5th. Month 1 is 6 April to 5 May, so 5 May is in month 1 and 6 May is in month 2.
  • 5 May is a Wednesday in 2021 and in 2027. My guess is the example was written for another year and only the year got changed. I can’t prove that.
  • Good Friday 2026 is 3 April and Easter Monday is 6 April, from GOV.UK’s bank holiday list (opens in a new tab). Easter Monday isn’t a bank holiday in Scotland, so up there the example’s Monday does work.

2. Sums that don’t add up#

HMRC has a page of Apprenticeship Levy guidance for software developers (opens in a new tab). It has six numbered examples, plus one about a business going into liquidation. They use a levy of 0.5% of the pay bill and an allowance of £15,000 a year, and work through the year month by month.

Where on HMRC’s pageWhat it printsWhat it should be
The liquidation example (opens in a new tab), month 1“Levy payable to month 1 is £1,250 (£1,500 - £1,250)”£250
Example 5 (opens in a new tab), month 12“Levy payable to month 12 is £100,000.08 (£15,000 – £5,000)”£10,000.08. There’s a zero too many
Example 5 (opens in a new tab), month 1“Levy payable to month 1 is £833 (£1,250 – £316.66)”The line above it gives the allowance as £416.66
Example 3 (opens in a new tab), month 12Starts with a yearly pay bill of £4,240,926.72, then month 12 uses £4,220,926.74The first one. 12 × £353,410.56 is £4,240,926.72

Nobody is going to believe a £100,000 levy on a £3 million pay bill. The problem is that one of the actual rules is only shown in these examples.

Example 5 (opens in a new tab) is HMRC’s example of three companies sharing the £15,000 allowance equally, so £5,000 each. The page’s own rule for the monthly allowance (opens in a new tab) says it is “rounded to 2 decimal places”. Example 5 splits its £5,000 over 12 months and prints £416.66.

My working
  • £5,000 ÷ 12 = £416.666… Rounded to two places that’s £416.67. The example prints £416.66, so it has cut the number off, not rounded it.
  • 12 × £416.66 = £4,999.92, which is 8p under the allowance. 12 × £416.67 would be £5,000.04, which is 4p over.
  • The text straight after example 5 backs the cut-off version. It says the employer “receives 8 pence less than £5,000 in allowance for the year” and talks about “the rules on rounding down and truncating”.

So the example is the best evidence I can find for whether to round or cut off, and it’s on the same page as the typos above.

3. An example that uses the wrong week#

To work out Statutory Maternity Pay you average about eight weeks of the employee’s pay. Which eight weeks depends on one week, called the qualifying week. Get that week wrong and you average the wrong paydays.

GOV.UK’s page for working SMP out by hand (opens in a new tab) gives the rule (opens in a new tab). The qualifying week is “the 15th week (Sunday to Saturday) before the week the baby is due”. So you find the week the baby is due and count back 15.

The page’s example (opens in a new tab) is a baby due on 23 March 2025. It gives the qualifying week as “1 December 2024 to 6 December 2024”. Here’s the count.

Weeks beforeSunday to SaturdayWhat it is
023 to 29 March 2025The week the baby is due
116 to 22 March 2025
29 to 15 March 2025
3 to 13…
1415 to 21 December 2024
158 to 14 December 2024The qualifying week
161 to 7 December 2024The week GOV.UK’s example uses

So the example has counted back 16 weeks, not 15. Its week is also only six days long. It stops on Friday 6 December, where a Sunday to Saturday week ends on the 7th.

Interactive: enter the date a baby is due and see the week the baby is due, the qualifying week (the 15th week before, Sunday to Saturday), the last Friday payday in the qualifying week and the relevant period for average earnings. For a baby due 23 March 2025 the qualifying week is Sunday 8 December to Saturday 14 December 2024 and the relevant period for a Friday payday is 19 October to 13 December 2024. GOV.UK’s example gives 1 to 6 December 2024 and 12 October to 6 December 2024 (web version only).

My working
  • 23 March 2025 is a Sunday, so the week the baby is due starts that day.
  • HMRC’s own table of dates (opens in a new tab) agrees with the count. For a baby due 23 to 29 March 2025 it lists 8 to 14 December 2024.
  • For someone paid every Friday, the pay that gets averaged is 19 October to 13 December. HMRC calls this the relevant period. The example’s version is 12 October to 6 December, a week earlier.

The levy typos look wrong. An average taken over the wrong eight weeks looks completely normal, and for someone whose pay changes from week to week it gives a different answer.

The monthly example (opens in a new tab) on the same page has its own slip. It says “The relevant period is 30 October 2024 to 30 November 2024” and then, on the next line, adds up earnings “between 1 October 2024 and 29 November 2024”.

What this has to do with AI#

If you ask a model to “write tests from the worked examples”, it copies what’s printed.

If you copyWhat happens
The printed answer (£1,250)The test fails against correct code. Then you, or the model, change the code until it passes
The printed dates (Wednesday 5 May, tax month 2)Your test data is wrong before any code runs
The example instead of its own definition (1 to 6 December)Nothing fails. The average is just taken over the wrong weeks

What I do about it#

DoWhy
Take the inputs from an example, not the answerThe inputs are a realistic case. The printed answer might be a typo
Work the answer out yourself, then compareIf they differ, find out which one is wrong before you write any code
Check every date with codeDay of the week, tax month, bank holiday. It’s one line each
If an example disagrees with its own definition, follow the definitionAnd write down that you did
Ask the model to recompute, not copyAsk it to work out every example again and list the ones that don’t match. If you only ask for tests from the examples, it copies the typos too

One from my own code. My levy test uses example 3. It only takes the monthly pay bill of £353,410.56 from it and works the year out itself, so the wrong month 12 line never got near it.

And the ledger entry for the maternity one:

rule       SMP qualifying week
value      15th week before the week the baby is due, Sunday to Saturday
source     GOV.UK "Work out your employee's payments for SMP" (the definition)
backed by  HMRC SMP table of dates, 2024
not using  the worked example on the same page (1 to 6 December 2024)
checked    23 Nov 2026
note       the example matches the table row for a baby due a week earlier

Sources#

All checked on 23 November 2026.

My reading of the published pages as at 23 November 2026. Not legal advice. HMRC may well have fixed these by the time you read this. The date widget uses England and Wales bank holidays only.

Comments