manicanldes-backend/docs/packaging-material-stock-ap...

13 lines
1.6 KiB
Markdown

# Packaging material stock (Phase 2P)
An operator can post an immutable packaging record's used and wasted material quantities to one warehouse. Each positive quantity becomes a separate negative material-stock ledger entry. Zero quantities create no entry. Packaging records do not change stock until explicitly posted.
| Method | Path | Permission |
| ------ | ------------------------------------------------------------- | ------------------ |
| GET | `/api/v1/production-batches/:batchId/packaging-stock-posting` | `inventory.read` |
| POST | `/api/v1/production-batches/:batchId/packaging-stock-posting` | `inventory.manage` |
POST body: `{ "warehouseId": "<uuid>", "idempotencyKey": "<uuid>" }`. A packaging record can be posted once. A same-key, same-request retry returns the original posting; reusing the key for another warehouse returns `PACKAGING_STOCK_REPLAY_CONFLICT`. A new key for an already posted record returns `PACKAGING_STOCK_ALREADY_POSTED`. The response identifies the source packaging line, material, kind and signed quantity for every ledger entry.
The selected warehouse must have enough of every packaging or label material for the **sum** of used and wasted quantities. `PACKAGING_STOCK_INSUFFICIENT` rejects the entire posting if any material is short. The database verifies each entry's source line, material, warehouse, kind and exact signed quantity, and prevents negative balances. Posting headers and ledger entries are append-only. Finished-goods output is documented separately; material transfers and adjustments remain later milestones.