2.0 KiB
Warehouse material stock (Phase 2N)
Raw-material balances are tracked per organization, material and warehouse. Use the existing /api/v1/inventory/warehouses endpoints to create and list warehouses. A goods receipt affects stock only after every line has a QC decision and an operator explicitly posts its accepted quantities to one warehouse. Rejected quantities never enter on-hand stock.
| Method | Path | Permission |
|---|---|---|
| GET | /api/v1/inventory/material-stock-items?warehouseId=&materialId=&limit=&offset= |
inventory.read |
| GET | /api/v1/inventory/material-stock-items/:id |
inventory.read |
| GET | /api/v1/inventory/material-stock-items/:id/ledger?limit=&offset= |
inventory.read |
| GET | /api/v1/goods-receipts/:receiptId/stock-posting |
inventory.read |
| POST | /api/v1/goods-receipts/:receiptId/stock-posting |
inventory.manage |
POST body: { "warehouseId": "<uuid>", "idempotencyKey": "<uuid>" }. A receipt can be posted once. A retry with the same key and warehouse returns the original posting; a changed retry returns MATERIAL_RECEIPT_REPLAY_CONFLICT. Posting again with a different key returns MATERIAL_RECEIPT_ALREADY_POSTED. The response lists one ledger entry for each line with a positive accepted quantity. A fully rejected receipt can be posted with no entries.
Balances and ledger deltas use each material's native unit and three decimal places. Posting is atomic: either all accepted lines reach the selected warehouse or none do. PostgreSQL checks that ledger entries match the receipt's QC decisions and updates balances in the same transaction. The ledger and receipt posting are append-only. Production, packaging, transfer and manual adjustment operations are documented separately.