100 lines
2.6 KiB
Markdown
100 lines
2.6 KiB
Markdown
# `POST /stock/adjust`
|
|
|
|
Protected. Requires a valid session cookie (`credentials: 'include'`).
|
|
|
|
Adjust stock manually
|
|
|
|
Writes signed (+ or -) entries to the append-only ledger under an implicit manifest
|
|
of type "adjustment", allocating a number from the "adjustment" number scheme.
|
|
|
|
**Note:** `sku` must be a string (e.g. `"25"`), not a number. For single-item adjustments, provide `sku` and `amount` at top-level. For batch adjustments, provide `lines: [{ sku, amount, ... }]`.
|
|
|
|
|
|
## Body (JSON)
|
|
|
|
| Field | Required | Type | Description |
|
|
|-------|----------|------|-------------|
|
|
| `sku` | no | string | Article SKU string (e.g. "25", not a number; for single-item adjustment) |
|
|
| `warehouseId` | no | integer | Target warehouse ID |
|
|
| `amount` | no | number | Signed adjustment quantity (+ to add, - to remove) |
|
|
| `text` | no | string | Reason or memo |
|
|
| `lines` | no | object[] | Batch adjustment lines |
|
|
| `lines[].sku` | yes | string | Article SKU string (e.g. "25", not a number) |
|
|
| `lines[].warehouseId` | no | integer | Target warehouse ID |
|
|
| `lines[].amount` | yes | number | Signed adjustment quantity (+ to add, - to remove) |
|
|
| `lines[].text` | no | string | Reason or memo |
|
|
|
|
```json
|
|
{
|
|
"sku": "…",
|
|
"warehouseId": 1,
|
|
"amount": 1,
|
|
"text": "…",
|
|
"lines": [
|
|
{
|
|
"sku": "…",
|
|
"warehouseId": 1,
|
|
"amount": 1,
|
|
"text": "…"
|
|
}
|
|
]
|
|
}
|
|
```
|
|
|
|
## Signals
|
|
|
|
On success, emits SSE signals: `stock`, `ledger`, `articles`, `article-<sku>` (see [`GET /events`](../events.md)).
|
|
|
|
## Response `201`
|
|
|
|
Stock adjusted successfully
|
|
|
|
```json
|
|
{
|
|
"manifest": {
|
|
"id": 1,
|
|
"number": "…",
|
|
"type": "adjustment",
|
|
"date": "2026-08-10T00:00:00.000Z",
|
|
"createdAt": "2026-08-10T00:00:00.000Z"
|
|
},
|
|
"lines": [
|
|
{
|
|
"manifestarticle_id": 1,
|
|
"sku": "…",
|
|
"name": "…",
|
|
"warehouse_id": 1,
|
|
"amount": 1,
|
|
"text": "…"
|
|
}
|
|
],
|
|
"ledger": [
|
|
{
|
|
"id": 1,
|
|
"manifestarticle_id": 1,
|
|
"transaction_type": "…",
|
|
"amount": 1,
|
|
"transaction_text": "…",
|
|
"hash_version": 1,
|
|
"prev_hash": "…",
|
|
"sku": "…",
|
|
"created_at": "2026-08-10T00:00:00.000Z"
|
|
}
|
|
]
|
|
}
|
|
```
|
|
|
|
## Errors
|
|
|
|
| Status | Description |
|
|
|--------|-------------|
|
|
| 400 | Missing fields, invalid amount, parent article cannot have stock, or no company selected — `{"error":"…"}` |
|
|
| 401 | Unauthorized — `{"error":"…"}` |
|
|
| 403 | Not authorized — `{"error":"…"}` |
|
|
| 404 | Article or warehouse not found — `{"error":"…"}` |
|
|
| 409 | Stock tracking is disabled — `{"error":"…"}` |
|
|
|
|
---
|
|
|
|
_Generated from `@openapi` JSDoc. Do not edit by hand — run `npm run docs:api`._
|