# delivery This document is auto-generated from the JSDoc comments in `src/store` by running `npm run api-doc`. ## `delivery.attachments` *Source: `src/store/delivery/attachments.js`* Loads attachment metadata (without binary content) for a manifest. ## `delivery.create` *Source: `src/store/delivery/create.js`* Creates a new delivery for the user's selected company with its lines. The delivery number is allocated internally via `getnextnumberwithprefixandpadding` (`type` `delivery`); supply `externalNumber` for an external (supplier) reference. **Parameters** | Name | Type | Description | | --- | --- | --- | | `googleAuthId` | `number` | The id of the Google auth user. | | `body` | `object` | The delivery input. | | `body.date` | `string` | The delivery date. | | `body.supplierId` | `number` | The id of the supplier. | | `[body.externalNumber]` | `string` | An external (supplier) reference number. | | `[body.lines]` | `Array<{sku?: string, name?: string, pu?: number, amount: number, net: number, rebate?: number, taxrate: number, comment?: string|null}>` | The delivery lines. | **Returns** `Promise<{id: number, number: string, type: string, entityId: number, externalNumber: string|null, date: string, lines: Array<{id: number, sku: string|null, name: string|null, pu: number, amount: number, net: number, rebate: number, taxrate: number, comment: string|null}>}>` — The created delivery. **Throws** `Error` — If the delivery is invalid. **Example** ```js const delivery = await store.delivery.create(42, { date: '2026-01-01', supplierId: 5, lines: [...] }); // => { id, number, type, entityId, externalNumber, date, lines: [...] } ``` ## `delivery.delete` *Source: `src/store/delivery/delete.js`* Deletes a delivery by its id within the user's selected company. **Parameters** | Name | Type | Description | | --- | --- | --- | | `googleAuthId` | `number` | The id of the Google auth user. | | `id` | `number` | The id of the delivery to delete. | **Returns** `Promise` **Throws** `Error` — If the delivery is not found. **Example** ```js await store.delivery.delete(42, 5); ``` ## `delivery.getById` *Source: `src/store/delivery/getById.js`* Returns a single delivery by its id within the user's selected company. **Parameters** | Name | Type | Description | | --- | --- | --- | | `googleAuthId` | `number` | The id of the Google auth user. | | `id` | `number` | The id of the delivery. | **Returns** `Promise<{id: number, number: string, type: string, entityId: number, externalNumber: string|null, date: string, lines: Array<{id: number, sku: string|null, name: string|null, pu: number, amount: number, net: number, rebate: number, taxrate: number, comment: string|null}>}>` — The delivery. **Throws** `Error` — If the delivery is not found. **Example** ```js const delivery = await store.delivery.getById(42, 5); // => { id, number, type, entityId, externalNumber, date, lines: [...] } ``` ## `delivery.list` *Source: `src/store/delivery/list.js`* Lists the deliveries of the user's selected company. **Parameters** | Name | Type | Description | | --- | --- | --- | | `googleAuthId` | `number` | The id of the Google auth user. | **Returns** `Promise>` — The deliveries. **Example** ```js const deliveries = await store.delivery.list(42); // => [{ id, number, type, entityId, externalNumber, date }] ``` ## `delivery.update` *Source: `src/store/delivery/update.js`* Updates a delivery's header and/or lines. **Parameters** | Name | Type | Description | | --- | --- | --- | | `googleAuthId` | `number` | The id of the Google auth user. | | `id` | `number` | The id of the delivery to update. | | `patch` | `object` | The update patch. | | `[patch.number]` | `string` | The new delivery number. | | `[patch.date]` | `string` | The new delivery date. | | `[patch.supplierId]` | `number` | The new supplier id. | | `[patch.externalNumber]` | `string` | The new external (supplier) reference number. | | `[patch.lines]` | `Array<{sku?: string, name?: string, pu?: number, amount: number, net: number, rebate?: number, taxrate: number, comment?: string|null}>` | The new delivery lines. | **Returns** `Promise<{id: number, number: string, type: string, entityId: number, externalNumber: string|null, date: string, lines: Array<{id: number, sku: string|null, name: string|null, pu: number, amount: number, net: number, rebate: number, taxrate: number, comment: string|null}>}>` — The updated delivery. **Throws** `Error` — If the delivery is not found. **Example** ```js const delivery = await store.delivery.update(42, 5, { number: 'D-2', lines: [...] }); // => { id, number, type, entityId, date, lines: [...] } ```