Files
dashlibstorage/API.warehouse.md
2026-10-16 12:35:07 +02:00

4.1 KiB

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.
[input.sort] number Optional sort order (auto-increments if omitted).
[tx] object Optional transaction to run within.

Returns

Promise<{id: number, name: string, sort: number}> — The created warehouse.

Throws

Error — If name is missing, sort is invalid, or name already exists.

Example

const wh = await store.warehouse.create(googleAuthId, { name: 'Hauptlager' });
// => { id: 1, name: 'Hauptlager', sort: 0 }

warehouse.delete

Source: src/store/warehouse/delete.js

Deletes a warehouse for the user's selected company, unless referenced in the ledger or it is the last warehouse while articles have stock tracking enabled.

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, in use in the ledger, or is the last warehouse with track_stock articles.

Example

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, sort: number}|undefined> — The warehouse or undefined.

Example

const wh = await store.warehouse.getById(googleAuthId, 1);
// => { id: 1, name: 'Hauptlager', sort: 0 }

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, sort: number}>> — List of warehouses.

Example

const warehouses = await store.warehouse.list(googleAuthId);
// => [{ id: 1, name: 'Hauptlager', sort: 0 }]

warehouse.order

Source: src/store/warehouse/order.js

Reorders the warehouses of the user's selected company.

Parameters

Name Type Description
googleAuthId number The id of the Google auth user.
input object The reorder input.
input.warehouseIds Array<number> The warehouse ids in their new order.
[tx] object Optional transaction to run within.

Returns

Promise<{warehouseIds: Array<number>}> — The applied order.

Throws

Error — If the order is invalid.

warehouse.update

Source: src/store/warehouse/update.js

Updates a warehouse name and/or sort order 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.
[input.sort] number The new sort order.
[tx] object Optional transaction to run within.

Returns

Promise<{id: number, name: string, sort: number}> — The updated warehouse.

Throws

Error — If warehouse not found, name is empty, sort is invalid, or name already exists.

Example

const updated = await store.warehouse.update(googleAuthId, 1, { name: 'Zentrallager', sort: 1 });
// => { id: 1, name: 'Zentrallager', sort: 1 }