The counts always add up

Missing subtracts from arrived automatically; damaged never does, because a cracked board still came off the truck.

What it is

An invariant enforced as you type and again on save, and applied on read so old rows cannot display a contradiction. Received plus missing must equal what was ordered. Missing is treated as the authority — someone deliberately said a quantity did not turn up — while received is often just the untouched 'everything arrived' default. Damaged is capped at what arrived and is not part of the sum.

Also called: received plus missing equals ordered · conflicting counts · damaged still arrived

See it
The counts always add up
New lead 4
Marlin Hoover
$32k
Delia Yoder
$21k
Contacted 4
Sutter Kline
$35k
Ronan Petsch
$61k
Ivy Brubaker
$61k
Estimate 4
Ivy Brubaker
$42k
Gideon Alt
$57k
Sold 2
Marlin Hoover
$54k
Delia Yoder
$66k
Sutter Kline
$58k
Typing '2' into Missing on a line of 44 and watching Arrived drop to 42 while Damaged stays put. supplierOrders.reconcileLine. Sample data — no customer information appears here.
How it works
  1. 1Typing a missing count sets arrived to ordered minus missing, and vice versa
  2. 2reconcileLine(qty, received, missing, damaged) re-derives the three numbers and reports whether the stored row was conflicted
  3. 3Rows are read through the same reconciliation, so a row stored before the invariant existed cannot show '2 of 2 received' next to '1 missing'
  4. 4Damaged clamps to what arrived — you cannot damage more than you received
Why we built it

Two comments say it. On the typing rule: 'MISSING subtracts from ARRIVED — you cannot have received 43 and be short 1 of 43… DAMAGED does NOT subtract. A cracked board still came off the truck; it is a different claim (replace/credit) from one that never shipped. Deducting it would double-count the loss and understate what the supplier delivered.' On the read rule: 'rows written before it did — or by any other path — can hold both "2 of 2 received" AND "1 missing", which is a contradiction that makes the whole count untrustworthy.'

The problem
  • Hand-maintained arrived and missing counts drift apart
  • Damaged material double-counted as a shortage
Sound familiar?
What you get
A count that cannot contradict itself
Old records display honestly

See it on your own jobs

Twenty minutes, your numbers, no slide deck. We’ll build one of your real buildings in front of you and send you the estimate link at the end — yours to keep either way.

or keep browsing features →