# What is a stock ledger?

> A stock ledger records every movement of inventory as a signed entry, so on-hand is the sum of the entries. Definition with a worked example.

Updated 2026-11-06. Source: https://atta.sh/glossary/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.
