Functional Weave
Code in Rust

hospitality.tronc-allocation@1.0.0

README.md

3,317 bytes · view raw

# hospitality.tronc-allocation

Shares a pool of tips, gratuities and service charges between the people in
it, in proportion to one of three weights:

- `hours`: minutes worked in the period;
- `points`: each person's points under the venue's tipping policy (for
  example head chef 10, commis 4, kitchen porter 3);
- `hours-and-points`: minutes worked times points, the usual "points per
  hour" scheme.

The shares always add up to the pool exactly. The split is `money.allocate`:
each person gets their proportional share rounded down, and the pennies left
over go one at a time to the largest remainders, ties to whoever is listed
first. So the same inputs always give the same split, and nobody's share is
nudged by rounding more than a penny.

## Why minutes

Hours are often fractional (a 7.5-hour shift), and a fraction of an hour as a
float is exactly the kind of drift this registry avoids. Minutes are whole
numbers, and nothing smaller matters for a tronc.

## Edge cases

- Someone with a weight of 0 (no hours, or no points) receives 0.
- An empty pool gives everyone 0. A pool with money in it but no weight on
  anybody is an error, because there is no fair way to split it.
- Ids must be unique and not empty; minutes and points must not be negative.

## The law this does not enforce

Since 1 October 2024 the **Employment (Allocation of Tips) Act 2023**
(https://www.legislation.gov.uk/ukpga/2023/13/contents), which inserted Part 2B
into the Employment Rights Act 1996, requires employers in Great Britain to pass
on all tips, gratuities and service charges they control or significantly
influence to workers, without deductions other than tax, and to do so fairly.
The **Code of Practice on Fair and Transparent Distribution of Tips**, brought
into force by SI 2024/831
(https://www.legislation.gov.uk/uksi/2024/831/made; guidance at
https://www.gov.uk/government/publications/distributing-tips-fairly-revised-statutory-code-of-practice
and https://www.acas.org.uk/tips-and-service-charges), sets out what fair
means in practice. A revised draft Code was published on 29 June 2026 and
withdrawn on 29 July 2026 pending consultation, so the 2024 Code still applies.

This function does the arithmetic of a policy. It cannot check that the
policy is lawful. In particular, the employer is responsible for:

- allocating fairly (ERA 1996 s27D): choosing fair factors and weights and
  applying them consistently. The Code discusses factors such as role, hours,
  seniority and performance;
- **not** keeping a share for the business. An employer who is an individual
  and works alongside staff may only take part as the Act and the Code allow;
- including agency workers who worked at the venue;
- paying tips no later than the end of the month after the month they were
  paid (s27G);
- having a written tipping policy available to workers (s27I), keeping
  records of the tips and how they were shared for three years, and answering
  a worker's written request for them within four weeks (s27J);
- consulting workers on the tipping policy, a duty the Employment Rights Act
  2025 adds. Check what is in force on the date you use this.

Tax and National Insurance on tronc payments (whether a troncmaster scheme
takes the payments out of Class 1 NICs) are payroll matters and are not done
here.