Functional Weave
Code in TypeScript

construction.retention@1.0.0

README.md

2,218 bytes · view raw

# construction.retention

Retention is the part of each interim payment a client (or main contractor)
keeps back as security until the work is complete and any defects are put
right. This works out the retention on one valuation.

## Shape

- **Work it out on the cumulative value, every time.** Valuations are
  cumulative (everything done to date), and so is retention: pass the gross
  value certified to date (work done plus materials on site), not this
  month's increase. A later valuation then corrects an earlier one
  automatically, and `construction.valuation` takes the previous payments off
  the net figure.
- **The usual release pattern.** Before practical completion the full
  percentage is held (`interim`). At practical completion half of it is
  released: the retention becomes **half the percentage on the value**
  (`practical-completion`), which is how JCT contracts word it. After the end
  of the rectification (defects) period, when the defects are made good, the
  rest is released (`final`, nothing held).
- `released` is `full - held`, the total released so far, not the release in
  this valuation.

## Rounding

Each figure is one rounding of an exact product, half up to the minor unit:
`full` is value x percentage, `held` at practical completion is value x
percentage / 2. Halving the already rounded full retention can differ by a
penny: 5% of 10,000.10 is 500.005 (500.01) and 2.5% is 250.0025 (250.00),
where half of 500.01 would round to 250.01.

## Edges and limits

Percentages are basis points from 0 to 10000; the common figures are 3% and
5%. Negative values are refused (a valuation below the previous one is still
a positive cumulative value). Contracts that cap retention at a fixed sum, or
release it in more than two parts, are not modelled: compute the cap in the
caller, or call this with the stage that applies. value x percentage must stay
within 2^53 - 1.

Source: the JCT Standard Building Contract (2016 edition, section 4, rules
on retention: the Retention Percentage, 3% unless stated, halved after
practical completion). The contract text is not freely published, so this was
not checked against it; the percentage and stages are whatever your contract
states.