This commit is contained in:
seb
2026-10-12 13:11:33 +02:00
parent 17cb4f4c72
commit c614a67b97
12 changed files with 645 additions and 17 deletions

View File

@@ -6,7 +6,7 @@ This document is auto-generated from the JSDoc comments in `src/store` by runnin
*Source: `src/store/shipping/create.js`*
Creates a shipping for a manifest (order). The number is allocated from the `shipping` numbers sequence (own prefix + counter).
Creates a shipping for a manifest (order). The number is allocated from the `shipping` numbers sequence (own prefix + counter). If state is 'shipped', adjusts stock by appending negative ledger movements for tracked order lines, writes article history, and ensures the order was not already shipped.
**Parameters**
@@ -16,7 +16,8 @@ Creates a shipping for a manifest (order). The number is allocated from the `shi
| `input` | `object` | Shipping input. |
| `input.manifestId` | `number` | The manifest (order) id. |
| `input.type` | `string` | Shipping type. |
| `input.state` | `string` | Shipping state. |
| `input.state` | `string` | Shipping state ('shipped' or other). |
| `[input.warehouseId]` | `number` | Optional warehouse ID for stock deduction (defaults to company's first warehouse). |
| `[tx]` | `object` | Optional transaction to run within. |
**Returns**
@@ -25,19 +26,19 @@ Creates a shipping for a manifest (order). The number is allocated from the `shi
**Throws**
`Error` — If manifest is not found or input is invalid.
`Error` — If manifest is not found, order already shipped, or input is invalid.
**Example**
```js
await store.shipping.create(googleAuthId, { manifestId: 42, type: 'parcel', state: 'open' });
await store.shipping.create(googleAuthId, { manifestId: 42, type: 'parcel', state: 'shipped' });
```
## `shipping.delete`
*Source: `src/store/shipping/delete.js`*
Deletes a shipping of the user's selected company. Its packages are removed by cascade.
Deletes a shipping of the user's selected company. Its packages are removed by cascade. Once shipped, a shipping cannot be deleted because stock movements have been ledgered.
**Parameters**
@@ -51,6 +52,10 @@ Deletes a shipping of the user's selected company. Its packages are removed by c
`Promise<void>`
**Throws**
`Error` — If shipping is not found or is already shipped.
**Example**
```js
@@ -80,3 +85,15 @@ Lists shippings of a manifest (order) in the user's selected company.
```js
const shippings = await store.shipping.listByManifestId(googleAuthId, 42);
```
## `shipping.update`
*Source: `src/store/shipping/update.js`*
Updates a shipping record for the user's selected company. If transitioned to 'shipped', books ledger movements and adjusts stock. Once shipped, shipping cannot be undone (state cannot be changed away from 'shipped').
**Parameters**
| Name | Type | Description |
| --- | --- | --- |
| `provider` | `import('../../providers/provider.js').DatabaseProvider` | |