manicanldes-backend/docs/material-adjustments-api.md

14 lines
1.8 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Manual material-stock adjustments (Phase 2S)
Authorized inventory adjusters can correct a material's on-hand quantity in one organization-scoped warehouse. Every correction requires a reason and creates one immutable signed ledger entry. Use goods receipts, production or packaging postings, and warehouse transfers for their normal movements; adjustments are for counted discrepancies or corrections.
| Method | Path | Permission |
| ------ | -------------------------------------------------------------------------------- | ------------------ |
| GET | `/api/v1/inventory/material-adjustments?materialId=&warehouseId=&limit=&offset=` | `inventory.read` |
| GET | `/api/v1/inventory/material-adjustments/:id` | `inventory.read` |
| POST | `/api/v1/inventory/material-adjustments` | `inventory.adjust` |
POST body: `{ "materialId": "<uuid>", "warehouseId": "<uuid>", "delta": "-0.250", "reason": "Counted physical inventory", "idempotencyKey": "<uuid>" }`. Delta must be nonzero, signed if negative, and have exactly three decimal places in the material's native unit. Reason is trimmed and must contain 3–200 characters. A positive adjustment creates the warehouse material-stock item when missing; a negative adjustment requires existing, sufficient stock.
The API rejects adjustments that would make on-hand stock negative or exceed the supported balance. A retry with the same key and request returns the original adjustment; a changed request returns `MATERIAL_ADJUSTMENT_REPLAY_CONFLICT`. The database independently checks the material, warehouse, signed quantity and ledger kind, then changes the balance in the same transaction. Adjustment records and ledger entries cannot be edited or deleted.