# shipping This document is auto-generated from the JSDoc comments in `src/store` by running `npm run api-doc`. ## `shipping.create` *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. **Parameters** | Name | Type | Description | | --- | --- | --- | | `googleAuthId` | `number` | The id of the Google auth user. | | `input` | `object` | Shipping input. | | `input.manifestId` | `number` | The manifest (order) id. | | `input.type` | `string` | Shipping type. | | `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** `Promise<{id: number, manifestId: number, number: string, type: string, state: string}>` **Throws** `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: 'shipped' }); ``` ## `shipping.delete` *Source: `src/store/shipping/delete.js`* 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** | Name | Type | Description | | --- | --- | --- | | `googleAuthId` | `number` | The id of the Google auth user. | | `id` | `number` | The shipping id. | | `[tx]` | `object` | Optional transaction to run within. | **Returns** `Promise` **Throws** `Error` — If shipping is not found or is already shipped. **Example** ```js await store.shipping.delete(googleAuthId, 9); ``` ## `shipping.listByManifestId` *Source: `src/store/shipping/listByManifestId.js`* Lists shippings of a manifest (order) in the user's selected company. **Parameters** | Name | Type | Description | | --- | --- | --- | | `googleAuthId` | `number` | The id of the Google auth user. | | `manifestId` | `number` | The manifest id. | | `[tx]` | `object` | Optional transaction to run within. | **Returns** `Promise>` **Example** ```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` | |