This commit is contained in:
seb
2026-09-26 23:06:05 +02:00
parent e491ecfa47
commit e7f92ebef8
41 changed files with 3632 additions and 1751 deletions

141
API.warehouse.md Normal file
View File

@@ -0,0 +1,141 @@
# warehouse
This document is auto-generated from the JSDoc comments in `src/store` by running `npm run api-doc`.
## `warehouse.create`
*Source: `src/store/warehouse/create.js`*
Creates a new warehouse for the user's selected company.
**Parameters**
| Name | Type | Description |
| --- | --- | --- |
| `googleAuthId` | `number` | The id of the Google auth user. |
| `input` | `object` | Warehouse input. |
| `input.name` | `string` | The warehouse name. |
| `[tx]` | `object` | Optional transaction to run within. |
**Returns**
`Promise<{id: number, name: string}>` — The created warehouse.
**Throws**
`Error` — If name is missing or already exists.
**Example**
```js
const wh = await store.warehouse.create(googleAuthId, { name: 'Hauptlager' });
// => { id: 1, name: 'Hauptlager' }
```
## `warehouse.delete`
*Source: `src/store/warehouse/delete.js`*
Deletes a warehouse for the user's selected company, unless referenced in the ledger.
**Parameters**
| Name | Type | Description |
| --- | --- | --- |
| `googleAuthId` | `number` | The id of the Google auth user. |
| `id` | `number` | The warehouse ID to delete. |
| `[tx]` | `object` | Optional transaction to run within. |
**Returns**
`Promise<void>`
**Throws**
`Error` — If warehouse not found or is in use in the ledger.
**Example**
```js
await store.warehouse.delete(googleAuthId, 1);
```
## `warehouse.getById`
*Source: `src/store/warehouse/getById.js`*
Retrieves a warehouse by its ID for the user's selected company.
**Parameters**
| Name | Type | Description |
| --- | --- | --- |
| `googleAuthId` | `number` | The id of the Google auth user. |
| `id` | `number` | The warehouse ID. |
| `[tx]` | `object` | Optional transaction to run within. |
**Returns**
`Promise<{id: number, name: string}|undefined>` — The warehouse or undefined.
**Example**
```js
const wh = await store.warehouse.getById(googleAuthId, 1);
// => { id: 1, name: 'Hauptlager' }
```
## `warehouse.list`
*Source: `src/store/warehouse/list.js`*
Lists all warehouses for the user's selected company.
**Parameters**
| Name | Type | Description |
| --- | --- | --- |
| `googleAuthId` | `number` | The id of the Google auth user. |
| `[tx]` | `object` | Optional transaction to run within. |
**Returns**
`Promise<Array<{id: number, name: string}>>` — List of warehouses.
**Example**
```js
const warehouses = await store.warehouse.list(googleAuthId);
// => [{ id: 1, name: 'Hauptlager' }]
```
## `warehouse.update`
*Source: `src/store/warehouse/update.js`*
Updates a warehouse name for the user's selected company.
**Parameters**
| Name | Type | Description |
| --- | --- | --- |
| `googleAuthId` | `number` | The id of the Google auth user. |
| `id` | `number` | The warehouse ID to update. |
| `input` | `object` | Update payload. |
| `input.name` | `string` | The new warehouse name. |
| `[tx]` | `object` | Optional transaction to run within. |
**Returns**
`Promise<{id: number, name: string}>` — The updated warehouse.
**Throws**
`Error` — If warehouse not found, name is missing, or name already exists.
**Example**
```js
const updated = await store.warehouse.update(googleAuthId, 1, { name: 'Zentrallager' });
// => { id: 1, name: 'Zentrallager' }
```