Files
dashlibstorage/API.stock.md
2026-10-17 23:32:42 +02:00

73 lines
3.6 KiB
Markdown

# stock
This document is auto-generated from the JSDoc comments in `src/store` by running `npm run api-doc`.
## `stock.accept`
*Source: `src/store/stock/accept.js`*
Accepts a delivery manifest item (or multiple delivery items). Requirements: - Every accepted delivery manifest item receives a document ledger entry: - If amount >= 0: transaction_type = 'ACCEPTANCE', amount = +amount, warehouse_id = null. - If amount < 0: transaction_type = 'RETURN', amount = amount (negative), warehouse_id = null. - Always records article history with delivery number, supplier, EK brutto, and quantity. - If the connected article has stock tracking (track_stock == 1): Calls adjust with the item's amount to adjust physical inventory in the target warehouse. - If the connected article does not have stock tracking: Only document acceptance is booked; no warehouse adjust is performed. - Double acceptance of an already accepted line is strictly prevented.
**Parameters**
| Name | Type | Description |
| --- | --- | --- |
| `provider` | `object` | The database provider. |
**Returns**
`Function` — Async function accepting delivery items.
## `stock.adjust`
*Source: `src/store/stock/adjust.js`*
Adjusts article stock manually by creating an implicit manifest of type "adjustment", allocating a number from the "adjustment" number scheme, and appending to the ledger.
**Parameters**
| Name | Type | Description |
| --- | --- | --- |
| `googleAuthId` | `number` | The id of the Google auth user. |
| `input` | `object` | Adjustment payload. |
| `[input.sku]` | `string` | Article SKU (if single-item adjustment). |
| `[input.warehouseId]` | `number` | Warehouse ID (can also pass warehouse_id). |
| `[input.amount]` | `number` | Signed adjustment amount (+ to add, - to remove). |
| `[input.text]` | `string` | Optional adjustment reason/memo. |
| `[input.externalNumber]` | `string` | Optional external reference. |
| `[input.date]` | `string|Date` | Optional date (defaults to now). |
| `[input.lines]` | `Array<object>` | Optional array of items to adjust in one manifest. |
| `[tx]` | `object` | Optional transaction to run within. |
**Returns**
`Promise<{manifest: {id: number, number: string, type: string, date: string, createdAt: string}, lines: Array<object>, ledger: Array<object>}>`
## `stock.rebuildSummaries`
*Source: `src/store/stock/rebuildSummaries.js`*
Rebuilds the `articlewarehousesummary` table for the user's selected company.
**Parameters**
| Name | Type | Description |
| --- | --- | --- |
| `provider` | `import('../../providers/provider.js').DatabaseProvider` | |
## `stock.ship`
*Source: `src/store/stock/ship.js`*
Ships a shipment manifest item (or multiple shipment items). Requirements: - Every shipped shipment manifest item receives a document ledger entry: - If amount >= 0: transaction_type = 'SHIPMENT', amount = -amount, warehouse_id = null. - If amount < 0: transaction_type = 'RETOURE', amount = +|amount|, warehouse_id = null. - Always records article history with shipment number, customer, and quantity. - If the connected article has stock tracking (track_stock == 1): Calls adjust with: - If normal shipment (amount >= 0): -amount (outgoing stock from warehouse). - If retoure (amount < 0): +|amount| (incoming stock into warehouse). - If the connected article does not have stock tracking: Only document shipment is booked; no warehouse adjust is performed. - Double shipping of an already shipped line is strictly prevented.
**Parameters**
| Name | Type | Description |
| --- | --- | --- |
| `provider` | `object` | The database provider. |
**Returns**
`Function` — Async function shipping shipment items.