construction.day-rate-quote
A trade quote from labour days at a day rate, materials with a markup, and VAT.
1.0.0 · published 2026-10-03 by charlie · Anterra
Pinned by 19 tests, run in TypeScript, Python and Rust.
What it does
The price of a small job the way trades quote it: so many days at a day rate, materials at cost plus a markup, and VAT on top.
- **Labour** is days x day rate, rounded half up to the penny once. Days are hundredths of a day (`250` is 2.5 days, `50` a half day), so no float ever touches the money. - **Materials** are the cost plus a markup, priced by `finance.markup-price` on the `markup` basis (profit over cost: 15% on 100.00 is 115.00), rounded half up. The markup applies to materials only; the day rate is already the price of labour. For a margin target instead, price the materials with `finance.markup-price` yourself. - **VAT** is `finance.tax.add-vat` on the net total, GB rates, at the rate in force on `onDate`. Pass `null` when you are not VAT registered. Under the domestic reverse charge (see `construction.vat-reverse-charge`) quote with `null` too and say on the quote that the customer accounts for the VAT.
For example
day_rate_quote(300, £250.00, £400.00, 20%, STANDARD, 2026-09-23)→ labour £750.00, materials £480.00, net £1,230.00, vat £246.00, gross £1,476.00, vat basis points 20% 3 days at 250.00 and 400.00 of materials marked up 20%, standard-rated: the markup is on materials onlyday_rate_quote(250, £180.00, £0.00, 15%, —, 2026-09-23)→ labour £450.00, materials £0.00, net £450.00, vat £0.00, gross £450.00, vat basis points 0% 2.5 days at 180.00, no materials, not VAT registeredday_rate_quote(33, £199.99, £12.34, 15%, STANDARD, 2026-09-23)→ labour £66.00, materials £14.19, net £80.19, vat £16.04, gross £96.23, vat basis points 20% a third of a day at 199.99 is 65.9967, rounded half up to 66.00; 12.34 of materials at 15% is 14.191, 14.19; VAT 20% of 80.19 is 16.038, 16.04
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.
def day_rate_quote(labour_days_hundredths: int, day_rate: Money, materials_cost: Money, materials_markup_basis_points: int, vat_category: Optional[str], on_date: str) -> DayRateQuote
| labour_days_hundredths | int | labour in hundredths of a day: 250 = 2.5 days, 50 = half a day |
| day_rate | Money | the charge for one day's labour |
| materials_cost | Money | what the materials cost you, excluding VAT |
| materials_markup_basis_points | int | markup on the materials cost, 1500 = 15% |
| vat_category | string? | GB VAT category (STANDARD, REDUCED, ZERO); null when you are not VAT registered |
| on_date | date | the date of the quote's supply, which decides the VAT rate |
| returns | DayRateQuote |
The type it declares, generated into your project
@dataclass(frozen=True)
class DayRateQuote:
"""The quote as the customer sees it."""
#: days x day rate
labour: Money
#: materials cost with the markup
materials: Money
#: labour plus materials
net: Money
vat: Money
#: net plus VAT: the price quoted
gross: Money
#: the VAT rate applied, 0 when none
vat_basis_points: int
Your code names it in one line, in the file that uses it
from fune.construction.day_rate_quote import day_rate_quote # construction.day-rate-quote@^1
Imports name this capability’s declared dependencies, which fune builds next to it in your project; each one links to its page.
from typing import Optional
from .construction_day_rate_quote_types import DayRateQuote
from .finance_markup_price import markup_price ← from finance.markup-price ^1.0.0 · built alongside by fune
from .finance_tax_add_vat import add_vat ← from finance.tax.add-vat ^1.0.0 · built alongside by fune
from .math_round_div import round_div ← from math.round-div ^1.0.0 · built alongside by fune
from .money_add import add_money ← from money.add ^1.0.0 · built alongside by fune
from .money_amount import Money, money ← from money.amount ^1.0.0 · built alongside by fune
MAX_SAFE = 9007199254740991
def day_rate_quote(
labour_days_hundredths: int,
day_rate: Money,
materials_cost: Money,
materials_markup_basis_points: int,
vat_category: Optional[str],
on_date: str,
) -> DayRateQuote:
"""A quote from labour days, a day rate, marked-up materials and VAT.
The markup goes on the materials only: the day rate already is the price of
labour. Labour is rounded once, to the penny, from days x rate; VAT is one
rounding on the net total, as on the invoice that follows.
"""
if (
isinstance(labour_days_hundredths, bool)
or not isinstance(labour_days_hundredths, int)
or labour_days_hundredths < 0
):
raise ValueError(
"labourDaysHundredths must be a whole number of hundredths, not negative, received %r"
% (labour_days_hundredths,)
)
if day_rate.minor < 0:
raise ValueError("dayRate must not be negative, received %d" % (day_rate.minor,))
product = day_rate.minor * labour_days_hundredths
# Python would carry on, but TypeScript cannot, and all three must agree.
if product > MAX_SAFE:
raise ValueError("the labour calculation exceeds 2^53 - 1")
labour = money(round_div(product, 100, "half-up"), day_rate.currency)
materials = markup_price(materials_cost, materials_markup_basis_points, "markup", "half-up")
net = add_money(labour, materials)
if vat_category is None:
return DayRateQuote(labour=labour, materials=materials, net=net, vat=money(0, net.currency), gross=net, vat_basis_points=0)
vat = add_vat(net, "GB", vat_category, on_date)
return DayRateQuote(
labour=labour, materials=materials, net=net, vat=vat.tax, gross=vat.gross, vat_basis_points=vat.basis_points
)Install
fune build
With that line in your source, in a Python project (language python in fune.project), fune build resolves it and its 5 dependencies, pins them in fune.lock, downloads only the Python 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 construction.day-rate-quote
The manifest, vectors and README with only the Python implementation. Install it without the registry with fune add ./construction.day-rate-quote-1.0.0-python.fune, or fetch it from a terminal with fune pull construction.day-rate-quote@1.0.0:python.
The whole function, every language, is one file too: construction.day-rate-quote-1.0.0.fune, 23,229 bytes, sha256 99bc4e96eeef9b0a55ff34a9020b41d78b29d57268ffd4b169f99205d1c6f6a1. 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 construction.day-rate-quote
after — your function gets the result and the arguments, and returns the final result.
# fune: after construction.day-rate-quote
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 finance.markup-price in construction.day-rate-quote
# fune: replace finance.tax.add-vat in construction.day-rate-quote
# fune: replace math.round-div in construction.day-rate-quote
# fune: replace money.add in construction.day-rate-quote
# fune: replace money.amount in construction.day-rate-quote
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 construction.day-rate-quote --steps.
# fune: step construction.day-rate-quote 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 | |
|---|---|---|---|
| 3 days at 250.00 and 400.00 of materials marked up 20%, standard-rated: the markup is on materials only | 300, £250.00, £400.00, 20%, STANDARD, 2026-09-23 | → | labour £750.00, materials £480.00, net £1,230.00, vat £246.00, gross £1,476.00, vat basis points 20% |
| 2.5 days at 180.00, no materials, not VAT registered | 250, £180.00, £0.00, 15%, —, 2026-09-23 | → | labour £450.00, materials £0.00, net £450.00, vat £0.00, gross £450.00, vat basis points 0% |
| a third of a day at 199.99 is 65.9967, rounded half up to 66.00; 12.34 of materials at 15% is 14.191, 14.19; VAT 20% of 80.19 is 16.038, 16.04 | 33, £199.99, £12.34, 15%, STANDARD, 2026-09-23 | → | labour £66.00, materials £14.19, net £80.19, vat £16.04, gross £96.23, vat basis points 20% |
| reduced-rated installation at 5% | 100, £200.00, £1,000.00, 0%, REDUCED, 2026-09-23 | → | labour £200.00, materials £1,000.00, net £1,200.00, vat £60.00, gross £1,260.00, vat basis points 5% |
| zero-rated work | 200, £150.00, £300.00, 10%, ZERO, 2026-09-23 | → | labour £300.00, materials £330.00, net £630.00, vat £0.00, gross £630.00, vat basis points 0% |
| a quote for a 2010 job uses the 17.5% rate then in force | 100, £100.00, £0.00, 0%, STANDARD, 2010-06-30 | → | labour £100.00, materials £0.00, net £100.00, vat £17.50, gross £117.50, vat basis points 17.5% |
| materials only: no labour days | 0, £250.00, £50.00, 10%, STANDARD, 2026-09-23 | → | labour £0.00, materials £55.00, net £55.00, vat £11.00, gross £66.00, vat basis points 20% |
| half a day at 250.00 | 50, £250.00, £0.00, 0%, —, 2026-09-23 | → | labour £125.00, materials £0.00, net £125.00, vat £0.00, gross £125.00, vat basis points 0% |
| half a day at 250.01 is 125.005, rounded half up to 125.01 | 50, £250.01, £0.00, 0%, —, 2026-09-23 | → | labour £125.01, materials £0.00, net £125.01, vat £0.00, gross £125.01, vat basis points 0% |
| materials sold at cost: no markup | 100, £200.00, £77.77, 0%, STANDARD, 2026-09-23 | → | labour £200.00, materials £77.77, net £277.77, vat £55.55, gross £333.32, vat basis points 20% |
Show the other 9 tests
| Case | Arguments | Expected | |
|---|---|---|---|
| negative labour days | -50, £250.00, £0.00, 0%, —, 2026-09-23 | → | error: labourDaysHundredths must be a whole number of hundredths, not negative |
| fractional hundredths | 2.5, £250.00, £0.00, 0%, —, 2026-09-23 | → | error: labourDaysHundredths must be a whole number of hundredths, not negative |
| a negative day rate | 100, -£0.01, £0.00, 0%, —, 2026-09-23 | → | error: dayRate must not be negative |
| negative materials | 100, £250.00, -£0.01, 0%, —, 2026-09-23 | → | error: cost must not be negative |
| a markup below -100% | 100, £250.00, £1.00, -100.01%, —, 2026-09-23 | → | error: a markup of -10001 basis points gives a negative price |
| a fractional markup | 100, £250.00, £1.00, 0.015%, —, 2026-09-23 | → | error: must be an integer |
| day rate and materials in different currencies | 100, £250.00, €1.00, 0%, —, 2026-09-23 | → | error: currency mismatch |
| an unknown VAT category | 100, £250.00, £0.00, 0%, LUXURY, 2026-09-23 | → | error: no VAT rule for GB/LUXURY |
| a labour product beyond 2^53 - 1 | 10,000,000, £10,000,000,000.00, £0.00, 0%, —, 2026-09-23 | → | error: exceeds 2^53 - 1 |
More from the author
Edges: zero days (a materials-only quote) and zero materials are fine. Negative days, rates or materials are errors, as is a markup below -100% and mixed currencies. day rate x hundredths must stay within 2^53 - 1.
Files
| Path | Bytes |
|---|---|
| README.md | 1,194 |
| impl/python.py | 2,082 |
| impl/rust.rs | 3,353 |
| impl/typescript.ts | 1,847 |
| vectors.json | 9,957 |