property.deposit-cap
Maximum tenancy deposit a landlord may take: five or six weeks' rent under the Tenant Fees Act 2019.
1.0.0 (not the latest) · published 2026-10-03 by charlie · Anterra
Pinned by 17 tests, run in TypeScript, Python and Rust.
Not professional advice. This capability calculates property figures from published rules. It is a software component for developers, not legal or financial advice. Rules change and every rate here has an effective date. Check that the dates cover your case. Verify results against the official sources listed in its README, and have a conveyancer or tax adviser review how you use it, before anyone relies on the output. Provided “as is” under its licence, without warranty.
What it does
The most a landlord or letting agent in England may take as a tenancy deposit: five weeks' rent when the annual rent is under £50,000, six weeks' rent when it is £50,000 or more. Anything above the cap is a prohibited payment.
`depositCap(money(100000, "GBP"), "monthly", "england", "2026-09-01")` is a maximum of £1,153.84: £1,000 × 12 = £12,000 a year, under £50,000, so five weeks, and £12,000 × 5 ÷ 52 = £1,153.846…
For example
depositCap(£1,000.00, monthly, england, 2026-09-01)→ annual rent £12,000.00, weekly rent £230.76, weeks 5, maximum £1,153.84 £1,000 a month: five weeks is £1,153.84 (rounded down from £1,153.846)depositCap(£240.00, weekly, england, 2026-09-01)→ annual rent £12,480.00, weekly rent £240.00, weeks 5, maximum £1,200.00 £240 a week: five weeks is exactly £1,200 (the guidance's joint-tenancy example)depositCap(£4,166.66, monthly, england, 2026-09-01)→ annual rent £49,999.92, weekly rent £961.53, weeks 5, maximum £4,807.68 £4,166.66 a month is £49,999.92 a year: still five weeks
The function
The same function in TypeScript, Python and Rust, pinned by the same tests. Pick your language; the choice follows you around the registry.
export function depositCap(rent: Money, rentPeriod: RentPeriod, jurisdiction: string, onDate: string): DepositCap
| rent | Money | the total rent for the whole tenancy (all joint tenants together), in GBP, zero or more |
| rentPeriod | RentPeriod | what one payment of rent covers |
| jurisdiction | string | "england"; the only one with data so far |
| onDate | date | the date the tenancy is granted, renewed or continued |
| returns | DepositCap |
The types it declares, generated into your project
export type RentPeriod = "weekly" | "monthly" | "annual";
/** The cap and how it was reached. */
export interface DepositCap {
/** rent for a year: weekly × 52, monthly × 12, or the annual rent */
readonly annualRent: Money;
/** annual rent ÷ 52, rounded down to the penny */
readonly weeklyRent: Money;
/** 5 below the threshold, 6 at or above it */
readonly weeks: number;
/** annual rent × weeks ÷ 52, rounded down to the penny */
readonly maximum: Money;
}
Your code names it in one line, in the file that uses it
import { depositCap } from "#fune/property.deposit-cap@^1";
Imports name this capability’s declared dependencies, which fune builds next to it in your project; each one links to its page.
import { type Money, money } from "./money_amount.ts"; ← from money.amount ^1.0.0 · built alongside by fune
import { DEPOSIT_CAPS, DEPOSIT_CAPS_HISTORY, type DepositCapRule } from "./property_deposit_cap_data.ts"; ← this capability’s own data, compiled from data/deposit-caps.json into the same file by fune build
import { type DepositCap, type RentPeriod } from "./property_deposit_cap_types.ts";
const ISO_DATE = /^\d{4}-\d{2}-\d{2}$/;
// Keeps annual rent × 6 exact as a JavaScript number.
const MAX_MINOR = 1_000_000_000_000;
function findRule(jurisdiction: string, onDate: string): DepositCapRule {
let best: DepositCapRule | null = null;
let earliest: string | null = null;
for (const rule of DEPOSIT_CAPS) {
if (rule.jurisdiction !== jurisdiction) continue;
if (earliest === null || rule.validFrom < earliest) earliest = rule.validFrom;
if (onDate < rule.validFrom) continue;
if (rule.validTo !== null && onDate > rule.validTo) continue;
if (best === null || rule.validFrom > best.validFrom) best = rule;
}
if (best !== null) return best;
// A build installed with a pruned history must not answer an old date with
// today's rule, so it says what happened instead.
if (DEPOSIT_CAPS_HISTORY !== "full" && earliest !== null && onDate < earliest) {
throw new RangeError(
`no deposit cap rule for ${jurisdiction} on ${onDate}: this build was installed with history=${DEPOSIT_CAPS_HISTORY}, so it only carries rules from ${earliest}`,
);
}
throw new RangeError(`no deposit cap rule for ${jurisdiction} on ${onDate}`);
}
/**
* The maximum tenancy deposit: five weeks' rent below the annual-rent
* threshold, six at or above it. The threshold is tested on the exact annual
* rent, and the cap is annual rent × weeks ÷ 52 rounded down once, so it can
* never sit a fraction of a penny over the statutory limit.
*/
export function depositCap(rent: Money, rentPeriod: RentPeriod, jurisdiction: string, onDate: string): DepositCap {
if (!ISO_DATE.test(onDate)) {
throw new RangeError(`onDate must be an ISO date (YYYY-MM-DD), received "${onDate}"`);
}
if (rent.currency !== "GBP") {
throw new RangeError(`rent must be in GBP, received ${rent.currency}`);
}
if (!Number.isInteger(rent.minor) || rent.minor < 0) {
throw new RangeError(`rent must not be negative, received ${rent.minor}`);
}
let annual: number;
if (rentPeriod === "weekly") annual = rent.minor * 52;
else if (rentPeriod === "monthly") annual = rent.minor * 12;
else if (rentPeriod === "annual") annual = rent.minor;
else throw new RangeError(`unknown rent period "${rentPeriod}"`);
if (annual > MAX_MINOR) {
throw new RangeError(`annual rent must be at most ${MAX_MINOR} minor units`);
}
const rule = findRule(jurisdiction, onDate);
const weeks = annual < rule.annualRentThresholdMinor ? rule.weeksBelow : rule.weeksAtOrAbove;
return {
annualRent: money(annual, "GBP"),
weeklyRent: money(Math.floor(annual / 52), "GBP"),
weeks,
maximum: money(Math.floor((annual * weeks) / 52), "GBP"),
};
}Install
fune build
With that line in your source, in a TypeScript project (language typescript in fune.project), fune build resolves it and its 1 dependency, pins them in fune.lock, downloads only the TypeScript package of each, and builds the code above into your project’s .fune/build, one readable file per capability with a header linking back here. Or pin a range in fune.project and build in one step:
fune add property.deposit-cap
The manifest, vectors and README with only the TypeScript implementation. Install it without the registry with fune add ./property.deposit-cap-1.0.0-typescript.fune, or fetch it from a terminal with fune pull property.deposit-cap@1.0.0:typescript.
The whole function, every language, is one file too: property.deposit-cap-1.0.0.fune, 23,485 bytes, sha256 b56c6062814945c1d963a228be68dd265c98c4696e736c876dab11797c4ee986. It installs into a project of any language.
Customise it in your app
The seams this capability offers. Put a marker directly above a function of your own and fune build wires it into the built code; the package on the registry is not changed, the built file’s header lists it under CUSTOMISED, and fune hooks lists every hook in the project. How hooks work.
before — your function gets the arguments and returns them, changed or not, or throws to refuse the call.
// fune: before property.deposit-cap
after — your function gets the result and the arguments, and returns the final result.
// fune: after property.deposit-cap
replace — inside this capability’s code only, calls to a dependency go to your function, with the same signature. Other capabilities that use it are unaffected; write in * to replace it everywhere.
// fune: replace money.amount in property.deposit-cap
step — your function runs at a numbered point inside the function’s body, receives the in-scope values it names as parameters, and may return replacements. List the points with fune show property.deposit-cap --steps.
// fune: step property.deposit-cap after <n|label>
Tests
A version published now needs at least 8 tests for every function, and one that expects the error for each function that throws; the registry refuses it otherwise. fune verify --all runs each case in TypeScript, Python and Rust, and a project runs them again with fune verify. This page lists the cases; it does not run them. The exact JSON is vectors.json.
| Case | Arguments | Expected | |
|---|---|---|---|
| £1,000 a month: five weeks is £1,153.84 (rounded down from £1,153.846) | £1,000.00, monthly, england, 2026-09-01 | → | annual rent £12,000.00, weekly rent £230.76, weeks 5, maximum £1,153.84 |
| £240 a week: five weeks is exactly £1,200 (the guidance's joint-tenancy example) | £240.00, weekly, england, 2026-09-01 | → | annual rent £12,480.00, weekly rent £240.00, weeks 5, maximum £1,200.00 |
| £4,166.66 a month is £49,999.92 a year: still five weeks | £4,166.66, monthly, england, 2026-09-01 | → | annual rent £49,999.92, weekly rent £961.53, weeks 5, maximum £4,807.68 |
| £4,166.67 a month is £50,000.04 a year: six weeks | £4,166.67, monthly, england, 2026-09-01 | → | annual rent £50,000.04, weekly rent £961.53, weeks 6, maximum £5,769.23 |
| exactly £50,000 a year is six weeks, not five | £50,000.00, annual, england, 2026-09-01 | → | annual rent £50,000.00, weekly rent £961.53, weeks 6, maximum £5,769.23 |
| £49,999.99 a year is five weeks | £49,999.99, annual, england, 2026-09-01 | → | annual rent £49,999.99, weekly rent £961.53, weeks 5, maximum £4,807.69 |
| £961.54 a week (£50,000.08 a year): six weeks, exactly 6 × weekly | £961.54, weekly, england, 2026-09-01 | → | annual rent £50,000.08, weekly rent £961.54, weeks 6, maximum £5,769.24 |
| £961.53 a week (£49,999.56 a year): five weeks | £961.53, weekly, england, 2026-09-01 | → | annual rent £49,999.56, weekly rent £961.53, weeks 5, maximum £4,807.65 |
| the cap is not five times the rounded weekly rent: £1,250 a month | £1,250.00, monthly, england, 2026-09-01 | → | annual rent £15,000.00, weekly rent £288.46, weeks 5, maximum £1,442.30 |
| zero rent: zero deposit | £0.00, monthly, england, 2026-09-01 | → | annual rent £0.00, weekly rent £0.00, weeks 5, maximum £0.00 |
Show the other 7 tests
| Case | Arguments | Expected | |
|---|---|---|---|
| the first day of the cap, 1 June 2019 | £1,000.00, monthly, england, 2019-06-01 | → | annual rent £12,000.00, weekly rent £230.76, weeks 5, maximum £1,153.84 |
| before 1 June 2019 there is no cap to apply | £1,000.00, monthly, england, 2019-05-31 | → | error: no deposit cap rule for england on 2019-05-31 |
| no data for Scotland | £1,000.00, monthly, scotland, 2026-09-01 | → | error: no deposit cap rule for scotland |
| rent in euros is refused | €1,000.00, monthly, england, 2026-09-01 | → | error: rent must be in GBP |
| negative rent is refused | -£0.01, monthly, england, 2026-09-01 | → | error: rent must not be negative |
| an unknown rent period is refused | £1,000.00, fortnightly, england, 2026-09-01 | → | error: unknown rent period |
| a malformed date is refused | £1,000.00, monthly, england, 1/6/2019 | → | error: onDate must be an ISO date |
More from the author
## How it is calculated
The Act defines a week's rent as the annual rent divided by 52, and the government guidance gives the formulae: annual rent is monthly rent × 12 or weekly rent × 52, and weekly rent is (monthly rent × 12) ÷ 52.
- The threshold test is made on the exact annual rent, so £4,166.66 a month (£49,999.92 a year) is five weeks and £4,166.67 (£50,000.04) is six. - The maximum is annual rent × weeks ÷ 52, computed exactly and **rounded down** to the penny once. Rounding the weekly rent first and multiplying by five can land a penny or more away; rounding up would put the deposit a fraction of a penny over the statutory cap. The Act and guidance do not state a rounding rule, so down is the one that can never breach it. - `weeklyRent` is shown for reference, rounded down too.
Pass the total rent for the property: for a joint tenancy the cap applies to the rent all the tenants are jointly liable for, not to each tenant.
## Dates and jurisdictions
The rule is a dated row in `data/deposit-caps.json`. England's cap applies to tenancies granted, renewed or continued on or after 1 June 2019; an earlier date is refused rather than answered. The Renters' Rights Act 2025 amended the Tenant Fees Act but left the deposit cap unchanged (statutory guidance updated 1 May 2026). Wales and Scotland have different regimes and no data here yet; asking for them is an error, not a guess.
## Sources
- Tenant Fees Act 2019, Schedule 1 paragraph 2 (tenancy deposit; "one week's rent" is the annual rent divided by 52): https://www.legislation.gov.uk/ukpga/2019/4/schedule/1 - Ministry of Housing, Communities and Local Government, "Tenant Fees Act 2019: Guidance for landlords and agents" (tenancy deposits: the annual and weekly rent formulae; the cap applies from 1 June 2019): https://assets.publishing.service.gov.uk/media/5f745d308fa8f5189a93d141/Tenant_Fees_Act_2019_-_Guidance_for_landlords_and_agents.pdf - "Tenant Fees Act 2019: statutory guidance for enforcement authorities" (as amended by the Renters' Rights Act 2025): https://www.gov.uk/government/publications/tenant-fees-act-amended-by-the-renters-rights-act-2025/tenant-fees-act-2019-statutory-guidance-for-enforcement-authorities
Files
| Path | Bytes |
|---|---|
| README.md | 2,711 |
| data/deposit-caps.json | 265 |
| impl/python.py | 2,979 |
| impl/rust.rs | 4,016 |
| impl/typescript.ts | 2,930 |
| vectors.json | 5,891 |