u
This commit is contained in:
@@ -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). If state is 'shipped', adjusts stock by appending negative ledger movements for tracked order lines, writes article history for all items, and ensures the order was not already shipped.
|
||||
Creates a shipping (package) for a shipment manifest. 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 shipment lines, writes article history for all items, and ensures stock is deducted once.
|
||||
|
||||
**Parameters**
|
||||
|
||||
@@ -14,24 +14,26 @@ Creates a shipping for a manifest (order). The number is allocated from the `shi
|
||||
| --- | --- | --- |
|
||||
| `googleAuthId` | `number` | The id of the Google auth user. |
|
||||
| `input` | `object` | Shipping input. |
|
||||
| `input.manifestId` | `number` | The manifest (order) id. |
|
||||
| `input.manifestId` | `number` | The shipment manifest id. |
|
||||
| `input.type` | `string` | Shipping type. |
|
||||
| `input.state` | `string` | Shipping state ('shipped' or other). |
|
||||
| `[input.trackingCode]` | `string` | Carrier tracking code. |
|
||||
| `[input.carrier]` | `string` | Carrier name. |
|
||||
| `[input.warehouseId]` | `number` | Optional warehouse ID for stock deduction (defaults to company's first warehouse). |
|
||||
| `[tx]` | `object` | Optional transaction to run within. |
|
||||
|
||||
**Returns**
|
||||
|
||||
`Promise<{id: number, manifestId: number, number: string, type: string, state: string}>`
|
||||
`Promise<{id: number, manifestId: number, number: string, trackingCode: string|null, carrier: string|null, type: string, state: string}>`
|
||||
|
||||
**Throws**
|
||||
|
||||
`Error` — If manifest is not found, order already shipped, or input is invalid.
|
||||
`Error` — If manifest is not found, manifest is not a shipment, or input is invalid.
|
||||
|
||||
**Example**
|
||||
|
||||
```js
|
||||
await store.shipping.create(googleAuthId, { manifestId: 42, type: 'parcel', state: 'shipped' });
|
||||
await store.shipping.create(googleAuthId, { manifestId: 42, type: 'parcel', state: 'shipped', trackingCode: '1Z999', carrier: 'UPS' });
|
||||
```
|
||||
|
||||
## `shipping.delete`
|
||||
|
||||
Reference in New Issue
Block a user