Construction Act payment timetable
BodyWorks out when an interim payment falls due, the payment notice deadline five days later, the final date for payment, and the pay less deadline counted back from that final date, never forward from the due date. Days are counted under section 116: Christmas Day, Good Friday and the contract region's own bank holidays are skipped, weekends are not, so a Scottish job never uses England's list. With no valid payment notice, the payee's claim stands as the notified sum, or the payee's default notice does and moves the final date back by its delay. A contract with a residential occupier gets one sentence saying the Act does not apply. All of it is one deriver.
npx dxcl add construction-payment-timetable Vorschaudaten
das JSON, mit dem diese Vorschau gebaut wurde{
"contract": {
"region": "SC",
"dueDateDays": 14,
"finalDateDays": 30,
"payLessDays": 7
},
"payment": {
"valuationPeriodEnd": "2026-12-04",
"claimReceived": "2027-01-12",
"paymentNoticeIssued": "2027-01-06",
"defaultNoticeIssued": "2027-01-14"
},
"bankHolidays": {
"SC": [
"2026-01-01",
"2026-01-02",
"2026-04-03",
"2026-05-04",
"2026-05-25",
"2026-08-03",
"2026-11-30",
"2026-12-25",
"2026-12-28",
"2027-01-01",
"2027-01-04",
"2027-03-26",
"2027-05-03",
"2027-05-31",
"2027-08-02",
"2027-11-30",
"2027-12-27",
"2027-12-28"
]
}
} Gerenderte Vorschau
jede Anordnung für sich gerendertAufgelöste Nodes
was ein Renderer erhält — 1 Nodespayment-timetable section Die Dateien
was die Installation schreibt; die gewählte Datei ist die Komponentenodes/construction-payment-timetable.node.tsx import { arrange, Section, type Section as SectionComponent, useDeriver, useState } from "docxcelerate/template";
import type { ConstructionPaymentTimetableLines } from "../arrangements/construction-payment-timetable/lines.ts";
import { stacked } from "../arrangements/construction-payment-timetable/stacked.arrangement.tsx";
import { table } from "../arrangements/construction-payment-timetable/table.arrangement.tsx";
import constructionPaymentTimetable from "../derivers/construction-payment-timetable.deriver.ts";
/**
* The statutory payment timetable for one interim payment under a UK
* construction contract: when payment falls due, the last day for the payer's
* payment notice, the final date for payment and the last day for a pay less
* notice. Each mistake below produces a deadline an adjudicator would reject.
*
* Counting: a period starts the day after its start date. Christmas Day, Good
* Friday and the bank holidays of the contract's own region are not counted
* (section 116). Weekends are, and a deadline that lands on a Saturday stays on
* the Saturday rather than rolling to Monday.
*
* Region: the bank holidays come from the contract's region, so a Scottish job
* never uses England's list. Northern Ireland is governed by its own Order.
*
* Pay less: counted back from the final date for payment as it stands after any
* postponement, never forward from the due date.
*
* Notified sum: when the payer gives no valid payment notice, the payee's claim
* stands if it arrived before the payment notice deadline (s110B(4)). Otherwise
* the payee's own default notice stands, and the final date moves back by the
* days it came after the deadline (s110B(3)). A payment notice after the
* deadline is printed as late and treated as not given.
*
* Residential occupier: the Act does not apply, so one sentence says so and
* nothing else is printed.
*
* All of it is decided in one deriver, because date arithmetic on request data
* cannot run at publish time. The node only prints what it returns. The s110B
* readings are interpretations, so have a lawyer confirm them.
*
* Installed by `dxcl add construction-payment-timetable`, which also installs
* its deriver.
*/
/** What this component reads. Add these fields to your document data type. */
export interface ConstructionPaymentTimetableData {
contract: {
/**
* Whose law and whose bank holidays apply: `EW` England and Wales, `SC`
* Scotland, `NI` Northern Ireland. Required, even for a residential
* occupier, because it names the Act. Anything else throws.
*/
region: "EW" | "SC" | "NI";
/**
* Whether the contract is with a residential occupier (s106). `true`
* prints only the "does not apply" sentence, and nothing else is read or
* checked. Missing or anything but `true` means not residential.
*/
residentialOccupier?: boolean;
/**
* Days after the valuation period ends that payment falls due, under the
* contract. A whole number, 0 or more (0 is due on the day the period
* ends). Missing (`undefined` or `null`) means the Scheme applies: due on
* the later of 7 days after the period ends and receipt of the claim.
* Negative, fractional or not a number throws.
*/
dueDateDays?: number;
/**
* Days after the due date of the final date for payment. A fixed period,
* a whole number, 1 or more. Missing means the Scheme's 17. Anything else
* throws.
*/
finalDateDays?: number;
/**
* The prescribed period for a pay less notice: days before the final date
* for payment. A whole number, 0 or more (0 is the final date itself).
* Missing means the Scheme's 7. Anything else throws.
*/
payLessDays?: number;
};
payment: {
/** The last day of the valuation period, as an ISO 8601 date (`2026-12-04`). Required. */
valuationPeriodEnd: string;
/**
* When the payee's payment claim (application) was received, ISO 8601. A
* claim states the sum the payee considers due and how it was worked out.
* Leave the field out for anything that does not. Required when
* `contract.dueDateDays` is missing, because under the Scheme it can set
* the due date. When it was received before the payment notice deadline,
* it stands as the notified sum if no payment notice is given. Missing or
* `""` means no claim.
*/
claimReceived?: string;
/**
* When the payer (or specified person) gave the payment notice, ISO 8601.
* It counts only if given on or before the payment notice deadline. A
* later one prints as late and is treated as not given. Missing or `""`
* means none was given.
*/
paymentNoticeIssued?: string;
/**
* When the payee gave its own notice in default of the payer's (s110B(2)),
* ISO 8601. Read only when no valid payment notice was given and the claim
* does not stand. It is ignored otherwise, because the Act then gives no
* right to one. When read, it must be after the payment notice deadline,
* or the deriver throws. Missing or `""` means none yet.
*/
defaultNoticeIssued?: string;
};
/**
* Bank holidays by region, each an array of ISO 8601 dates. This is the
* shape of https://www.gov.uk/bank-holidays.json once its keys are mapped
* to EW/SC/NI. Only `bankHolidays[contract.region]` is read. It is required
* unless residential, and missing throws. It must contain at least one date
* in every calendar year the timetable runs through, or the deriver throws,
* because a year with none means the list is stale. Christmas Day and Good
* Friday are excluded whether listed or not.
*/
bankHolidays: { EW?: string[]; SC?: string[]; NI?: string[] };
}
/**
* Where the dates sit.
*
* - `table`: the four dates in a label and date table. The default.
* - `stacked`: one line per date, for a letter that reads as prose.
*/
export type ConstructionPaymentTimetableArrangement = "table" | "stacked";
/** Props for {@linkcode ConstructionPaymentTimetable}. */
export interface ConstructionPaymentTimetableProps {
/** Where the dates sit. Defaults to `"table"`. */
arrangement?: ConstructionPaymentTimetableArrangement;
}
export const ConstructionPaymentTimetable: SectionComponent<ConstructionPaymentTimetableProps> = async (
{ arrangement },
) => {
const [contract] = useState((data: ConstructionPaymentTimetableData) => data.contract);
const [payment] = useState((data: ConstructionPaymentTimetableData) => data.payment);
const [bankHolidays] = useState((data: ConstructionPaymentTimetableData) => data.bankHolidays);
const t = await useDeriver(constructionPaymentTimetable, [contract, payment, bankHolidays]);
const lines: ConstructionPaymentTimetableLines = {
applies: t.applies,
notApplicable: t.notApplicable,
basis: t.basis,
dueDate: t.dueDate,
paymentNoticeBy: t.paymentNoticeBy,
finalDate: t.finalDate,
payLessBy: t.payLessBy,
noticeLate: t.noticeLate,
noticeGiven: t.noticeGiven,
applicationStands: t.applicationStands,
defaultNotice: t.defaultNotice,
defaultOpen: t.defaultOpen,
reckoning: t.reckoning,
};
return (
<Section id="payment-timetable" title="Payment timetable">
{arrange(arrangement, {
table: () => table(lines),
stacked: () => stacked(lines),
})}
</Section>
);
}; derivers/construction-payment-timetable.deriver.ts import { deriver } from "docxcelerate/template";
/**
* Works out the Construction Act payment timetable for one interim payment.
* Installed by `dxcl add construction-payment-timetable`.
*
* It is self-contained on purpose: it travels to the engine as source text, so
* a module-level helper or constant would be a ReferenceError there. The Easter
* calculation, the day counting and the formatter all live inside `run`.
*/
export default deriver({
name: "constructionPaymentTimetable",
run: (contract: unknown, payment: unknown, bankHolidays: unknown) => {
// deno-lint-ignore no-explicit-any
const con = contract as any;
// deno-lint-ignore no-explicit-any
const pay = payment as any;
// deno-lint-ignore no-explicit-any
const bh = bankHolidays as any;
const regions = ["EW", "SC", "NI"];
const region: string = con?.region;
if (!regions.includes(region)) throw new Error("contract.region must be one of " + regions.join(", "));
const act = region === "NI"
? "Construction Contracts (Northern Ireland) Order 1997"
: "Housing Grants, Construction and Regeneration Act 1996";
const regionName = { EW: "England and Wales", SC: "Scotland", NI: "Northern Ireland" }[region];
const scheme = "the Scheme for Construction Contracts (" + regionName + ")";
if (con.residentialOccupier === true) {
return {
applies: false,
notApplicable: "This contract is with a residential occupier, so the " + act +
" does not apply to it, and neither does the payment timetable it sets.",
basis: null,
dueDate: null,
paymentNoticeBy: null,
finalDate: null,
payLessBy: null,
noticeLate: null,
noticeGiven: null,
applicationStands: null,
defaultNotice: null,
defaultOpen: null,
reckoning: null,
};
}
const DAY = 86400000;
const missing = (v: unknown) => v === undefined || v === null || v === "";
// UTC midnight, so no local time or daylight saving ever enters the sum.
const parse = (v: unknown, path: string): number => {
const text = typeof v === "string" ? v.slice(0, 10) : "";
const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(text);
const t = m ? Date.UTC(+m[1], +m[2] - 1, +m[3]) : NaN;
if (!m || new Date(t).toISOString().slice(0, 10) !== text) {
throw new Error(path + " must be an ISO 8601 date");
}
return t;
};
const days = (v: unknown, name: string, min: number, fallback: number | undefined): number | undefined => {
if (v === undefined || v === null) return fallback;
if (!Number.isInteger(v) || (v as number) < min) {
throw new Error("contract." + name + " must be a whole number of days, at least " + min);
}
return v as number;
};
const dueDays = days(con.dueDateDays, "dueDateDays", 0, undefined);
const finalDays = days(con.finalDateDays, "finalDateDays", 1, 17) as number;
const payLessDays = days(con.payLessDays, "payLessDays", 0, 7) as number;
const list = bh?.[region];
if (!Array.isArray(list)) {
throw new Error("bankHolidays." + region + " is required for a contract in " + regionName);
}
const holidays = new Set<number>(
list.map((d: unknown, i: number) => parse(d, "bankHolidays." + region + "[" + i + "]")),
);
// Anonymous Gregorian algorithm (Meeus/Jones/Butcher).
const goodFriday = (year: number): number => {
const a = year % 19, b = Math.floor(year / 100), c = year % 100;
const d = Math.floor(b / 4), e = b % 4, f = Math.floor((b + 8) / 25);
const g = Math.floor((b - f + 1) / 3), h = (19 * a + b - d - g + 15) % 30;
const i = Math.floor(c / 4), k = c % 4, l = (32 + 2 * e + 2 * i - h - k) % 7;
const m = Math.floor((a + 11 * h + 22 * l) / 451);
const month = Math.floor((h + l - 7 * m + 114) / 31);
const day = ((h + l - 7 * m + 114) % 31) + 1;
return Date.UTC(year, month - 1, day) - 2 * DAY;
};
const excluded = (t: number): boolean => {
const d = new Date(t);
return (d.getUTCMonth() === 11 && d.getUTCDate() === 25) ||
t === goodFriday(d.getUTCFullYear()) || holidays.has(t);
};
const step = (from: number, n: number, dir: number): number => {
let t = from;
while (n > 0) {
t += dir * DAY;
if (!excluded(t)) n--;
}
return t;
};
const addDays = (t: number, n: number) => step(t, n, 1);
const subDays = (t: number, n: number) => step(t, n, -1);
const daysBetween = (a: number, b: number): number => {
let n = 0;
for (let t = a + DAY; t <= b; t += DAY) if (!excluded(t)) n++;
return n;
};
const fmt = new Intl.DateTimeFormat("en-GB", {
weekday: "long",
day: "numeric",
month: "long",
year: "numeric",
timeZone: "UTC",
});
const show = (t: number) => fmt.format(new Date(t));
const iso = (t: number) => new Date(t).toISOString().slice(0, 10);
const V = parse(pay?.valuationPeriodEnd, "payment.valuationPeriodEnd");
const hasClaim = !missing(pay.claimReceived);
const C = hasClaim ? parse(pay.claimReceived, "payment.claimReceived") : undefined;
let D0: number;
if (dueDays !== undefined) {
D0 = addDays(V, dueDays);
} else {
if (C === undefined) {
throw new Error("payment.claimReceived is required when contract.dueDateDays is not given");
}
D0 = Math.max(addDays(V, 7), C);
}
const PN = addDays(D0, 5);
const F0 = addDays(D0, finalDays);
const P = missing(pay.paymentNoticeIssued) ? undefined : parse(pay.paymentNoticeIssued, "payment.paymentNoticeIssued");
const valid = P !== undefined && P <= PN;
let F = F0;
let latest = F0;
let noticeLate: string | null = null;
let noticeGiven: string | null = null;
let applicationStands: string | null = null;
let defaultNotice: string | null = null;
let defaultOpen: string | null = null;
let open = false;
if (P !== undefined && !valid) {
noticeLate = "The payment notice given on " + show(P) + " came after the deadline of " + show(PN) +
", so it does not count as one.";
}
if (valid) {
noticeGiven = "The payer gave its payment notice on " + show(P) +
". The sum it states is the notified sum.";
} else if (C !== undefined && C < PN) {
applicationStands = "No payment notice was given by " + show(PN) + ", so the payment claim received on " +
show(C) + " stands as the notified sum.";
} else if (!missing(pay.defaultNoticeIssued)) {
const N = parse(pay.defaultNoticeIssued, "payment.defaultNoticeIssued");
if (N <= PN) {
throw new Error("payment.defaultNoticeIssued must be after the payment notice deadline, " + iso(PN));
}
const k = daysBetween(PN, N);
F = addDays(F0, k);
latest = Math.max(F, N);
const lead = "No payment notice was given by " + show(PN) + ". The payee's notice of " + show(N) +
" stands as the notified sum";
defaultNotice = k === 0
? lead + ". The final date for payment does not move."
: lead + ", and moves the final date for payment back " + k + (k === 1 ? " day" : " days") +
", from " + show(F0) + " to " + show(F) + ".";
} else {
open = true;
defaultOpen = "No payment notice was given by " + show(PN) +
", and the payee has not yet given a notice in its place. When it does, the final date for payment moves back one day for each day after " +
show(PN) + " the notice is given, and the pay less notice deadline with it.";
}
const PL = subDays(F, payLessDays);
if (PL < PN) {
throw new Error(
"the pay less notice deadline falls before the payment notice deadline; check contract.finalDateDays and contract.payLessDays",
);
}
// A year with no bank holidays means the list is stale, and every count
// through it would be quietly wrong.
const years = new Set<number>([...holidays].map((t) => new Date(t).getUTCFullYear()));
const last = new Date(latest).getUTCFullYear();
for (let year = new Date(V).getUTCFullYear(); year <= last; year++) {
if (!years.has(year)) throw new Error("bankHolidays." + region + " has no dates in " + year);
}
const earliest = open ? " at the earliest" : "";
const basis = dueDays === undefined
? "Under " + scheme + ", payment falls due on the later of 7 days after the valuation period ended on " +
show(V) + " and receipt of the payment claim on " + show(C as number) + "."
: dueDays === 0
? "Under the contract, payment falls due on the day the valuation period ended, " + show(V) + "."
: "Under the contract, payment falls due " + dueDays + (dueDays === 1 ? " day" : " days") +
" after the valuation period ended on " + show(V) + ".";
const reckoning = region === "NI"
? "Days are counted under the " + act +
": Christmas Day, Good Friday and bank holidays in Northern Ireland are not counted. Weekends are."
: "Days are counted under section 116 of the " + act + ": Christmas Day, Good Friday and bank holidays in " +
regionName + " are not counted. Weekends are.";
return {
applies: true,
notApplicable: null,
basis,
dueDate: show(D0),
paymentNoticeBy: show(PN),
finalDate: show(F) + earliest,
payLessBy: show(PL) + earliest,
noticeLate,
noticeGiven,
applicationStands,
defaultNotice,
defaultOpen,
reckoning,
};
},
}); arrangements/construction-payment-timetable/lines.ts /**
* What the construction payment timetable hands each of its arrangements:
* every line it may print, already decided. An arrangement places these and
* decides nothing, so both print the same lines under the same conditions.
*
* A field that is `null` is a line this timetable does not carry. Test it in
* the JSX, `{lines.noticeLate && …}`, so the test is compiled into a condition
* the engine settles per document.
*
* Installed by `dxcl add construction-payment-timetable`, with the arrangements.
*/
export interface ConstructionPaymentTimetableLines {
/** False for a residential occupier: only `notApplicable` is printed. */
applies: boolean;
/** The one sentence saying the Act does not apply, or null. */
notApplicable: string | null;
/** How the due date was reached. */
basis: string | null;
/** The payment due date. */
dueDate: string | null;
/** The last day for the payer's payment notice. */
paymentNoticeBy: string | null;
/** The final date for payment, after any postponement. */
finalDate: string | null;
/** The last day for a pay less notice. */
payLessBy: string | null;
/** That the payment notice came late and is treated as not given, or null. */
noticeLate: string | null;
/** That a valid payment notice was given, or null. */
noticeGiven: string | null;
/** That the payee's application stands as the notified sum, or null. */
applicationStands: string | null;
/** That the payee's default notice stands, or null. */
defaultNotice: string | null;
/** That the payee may still give a default notice, or null. */
defaultOpen: string | null;
/** Which days were not counted, and under what. */
reckoning: string | null;
} arrangements/construction-payment-timetable/table.arrangement.tsx import { Cell, Paragraph, Row, Table, type Yield } from "docxcelerate/template";
import type { ConstructionPaymentTimetableLines } from "./lines.ts";
/**
* The four dates in a label and date table, for a timetable read at a glance.
* The default.
*/
export const table = (lines: ConstructionPaymentTimetableLines): Yield => (
<>
{lines.notApplicable && <Paragraph id="payment-timetable-not-applicable">{lines.notApplicable}</Paragraph>}
{lines.applies && (
<>
<Paragraph id="payment-timetable-basis">{lines.basis}</Paragraph>
{/* 50mm holds the longest label, "Pay less notice due by", on one line. */}
<Table id="payment-timetable-dates" columns={[{ width: 50 }, { width: "auto" }]}>
<Row id="payment-timetable-due">
<Cell>Payment due date</Cell>
<Cell>{lines.dueDate}</Cell>
</Row>
<Row id="payment-timetable-notice-by">
<Cell>Payment notice due by</Cell>
<Cell>{lines.paymentNoticeBy}</Cell>
</Row>
<Row id="payment-timetable-final">
<Cell>Final date for payment</Cell>
<Cell>{lines.finalDate}</Cell>
</Row>
<Row id="payment-timetable-pay-less-by">
<Cell>Pay less notice due by</Cell>
<Cell>{lines.payLessBy}</Cell>
</Row>
</Table>
{lines.noticeLate && <Paragraph id="payment-timetable-notice-late">{lines.noticeLate}</Paragraph>}
{lines.noticeGiven && <Paragraph id="payment-timetable-notice-given">{lines.noticeGiven}</Paragraph>}
{lines.applicationStands && (
<Paragraph id="payment-timetable-application-stands">{lines.applicationStands}</Paragraph>
)}
{lines.defaultNotice && <Paragraph id="payment-timetable-default-notice">{lines.defaultNotice}</Paragraph>}
{lines.defaultOpen && <Paragraph id="payment-timetable-default-open">{lines.defaultOpen}</Paragraph>}
<Paragraph id="payment-timetable-reckoning">{lines.reckoning}</Paragraph>
</>
)}
</>
); arrangements/construction-payment-timetable/stacked.arrangement.tsx import { Paragraph, type Yield } from "docxcelerate/template";
import type { ConstructionPaymentTimetableLines } from "./lines.ts";
/** One line per date, for a letter that reads as prose. */
export const stacked = (lines: ConstructionPaymentTimetableLines): Yield => (
<>
{lines.notApplicable && <Paragraph id="payment-timetable-not-applicable">{lines.notApplicable}</Paragraph>}
{lines.applies && (
<>
<Paragraph id="payment-timetable-basis">{lines.basis}</Paragraph>
<Paragraph id="payment-timetable-due">Payment due date: {lines.dueDate}</Paragraph>
<Paragraph id="payment-timetable-notice-by">Payment notice due by: {lines.paymentNoticeBy}</Paragraph>
<Paragraph id="payment-timetable-final">Final date for payment: {lines.finalDate}</Paragraph>
<Paragraph id="payment-timetable-pay-less-by">Pay less notice due by: {lines.payLessBy}</Paragraph>
{lines.noticeLate && <Paragraph id="payment-timetable-notice-late">{lines.noticeLate}</Paragraph>}
{lines.noticeGiven && <Paragraph id="payment-timetable-notice-given">{lines.noticeGiven}</Paragraph>}
{lines.applicationStands && (
<Paragraph id="payment-timetable-application-stands">{lines.applicationStands}</Paragraph>
)}
{lines.defaultNotice && <Paragraph id="payment-timetable-default-notice">{lines.defaultNotice}</Paragraph>}
{lines.defaultOpen && <Paragraph id="payment-timetable-default-open">{lines.defaultOpen}</Paragraph>}
<Paragraph id="payment-timetable-reckoning">{lines.reckoning}</Paragraph>
</>
)}
</>
);