What is a stock ledger?
A stock ledger is an append-only list of inventory movements. Each receipt, sale, count or transfer is a row with a quantity, positive or negative. Quantity on hand is never stored; it is the sum of the rows.
Example
Item: 6 mm bolts.
| Date | Movement | Qty |
|---|---|---|
| Mon | received | +500 |
| Tue | used | -120 |
| Wed | shipped | -80 |
| Thu | counted | -4 |
On hand is 500 - 120 - 80 - 4 = 296. The Thursday count found 300 expected and 296 on the shelf, so the ledger wrote the difference of -4 instead of overwriting the total.
In Atta
On hand is sum(stock_movement.quantity). A count writes the difference as a counted row. Committing an outbound (use, ship or sell) locks the item rows and refuses a shortfall with both figures. Cancelling a committed one writes reversed rows, keyed so they happen once.
A receipt writes the stock side for the change on a line linked to an item, so receiving the same line twice doesn't double the count. Stock writes need the inventory capability. The agent only reads: it can check stock and never change it.
Correcting a mistake
An entry is never edited. Shipping 80 instead of 60 is fixed by a +20 row with a reason, so the history still shows what happened. This is also why a stocktake can be audited against everything that moved since the last one.
Questions
Why not just keep a quantity field?
A field loses history. The ledger shows how you got to the number and lets you correct a mistake with a new row.
Related
- What is a bill of materials?A bill of materials lists every part and quantity needed to build one unit of a product. Definition with a costed example and how Atta uses it.
- What is a reorder point?A reorder point is the stock level that triggers a new order. The formula is daily demand times lead time, plus safety stock. With a worked example.
- AI inventory management that ends in a purchase requestAtta keeps stock as a ledger, forecasts when each item runs out from measured usage and quoted lead times, and opens a restock request instead of ordering.