Movements
A movement records one change to a resource’s balance. It commits with the change and identifies the resource, its scope, and the reason. Adding supply, placing a hold, committing it, correcting a count, and transferring stock all leave movements.
What moved
quantity is the signed change to onHand. before and after show its old and new values. A change to held or expected has its own signed quantity and before and after values. So does a change to owed, what a balance owes beyond its supply entries; its pegs name the entries that paid it down. Owing explains when a balance owes. Placing a hold changes held and leaves the on-hand quantity unchanged.
Placing a hold records one hold movement for each balance a line affects, one per bucketStart on a resource that counts time in buckets. Each movement records quantity as 0, with equal on-hand before and after values. Its held.quantity equals the line’s quantity, and held.before and held.after show the held balance before and after placement.
On a resource that counts time in buckets, bucketStart identifies the bucket. A write spanning several buckets records each bucket’s change separately. On a resource that tracks units individually, scope.instanceId identifies the unit. A movement that draws from separately tracked supply entries carries pegs that tell you how much it drew from each entry.
Why it moved
The reason says which kind of change this is, such as add, hold, commit, or use. A movement names its actor and, when the actor acted under a delegation, onBehalfOf, as Who acted describes. Evidence and links to records such as a supply entry, claim, hold, or transfer explain a particular change when those records apply.
Movements are append-only. For example, taking back an added receipt records a reversal movement and keeps the earlier add movement. A transfer records a take and an add, linked by transferId.
Reading the history
List movements answers in increasing seq, as a feed. Filter by resource, place, holder, batch, or instance. A signed-in principal’s user token reaches only the history of their own holder. Totals sums the on-hand changes by reason over a time period.
Where to act on it
- Sell prepaid credits reads a holder’s movements. Sum usage with totals chooses which reasons count as usage.
- Stock records transfers, counts, corrections, and conversions. Movements reads the resulting history.