Files
dashlibstorage/API.supplier.md
2026-10-17 23:32:42 +02:00

117 lines
2.6 KiB
Markdown

# supplier
This document is auto-generated from the JSDoc comments in `src/store` by running `npm run api-doc`.
## `supplier.create`
*Source: `src/store/supplier/create.js`*
Creates a new supplier for the user's selected company, recording history.
**Parameters**
| Name | Type | Description |
| --- | --- | --- |
| `googleAuthId` | `number` | The id of the Google auth user. |
| `input` | `object` | The supplier input. |
| `input.name` | `string` | The supplier name. |
| `[tx]` | `object` | Optional transaction to run within. |
**Returns**
`Promise<{id: number, name: string, createdAt: string, updatedAt: string}>` — The created supplier.
**Throws**
`Error` — If the name is empty.
**Example**
```js
const supplier = await store.supplier.create(42, { name: 'Acme Supplies' });
// => { id, name, createdAt, updatedAt }
```
## `supplier.delete`
*Source: `src/store/supplier/delete.js`*
Deletes a supplier 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 supplier to delete. |
| `[tx]` | `object` | Optional transaction to run within. |
**Returns**
`Promise<void>`
**Throws**
`Error` — If the supplier is not found or is in use.
**Example**
```js
await store.supplier.delete(42, 5);
```
## `supplier.list`
*Source: `src/store/supplier/list.js`*
Lists the suppliers of 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, createdAt: string, updatedAt: string}>>` — The suppliers.
**Example**
```js
const suppliers = await store.supplier.list(42);
// => [{ id, name, createdAt, updatedAt }]
```
## `supplier.update`
*Source: `src/store/supplier/update.js`*
Updates the name of a supplier, recording history.
**Parameters**
| Name | Type | Description |
| --- | --- | --- |
| `googleAuthId` | `number` | The id of the Google auth user. |
| `id` | `number` | The id of the supplier to update. |
| `input` | `object` | The update input. |
| `input.name` | `string` | The new supplier name. |
| `[tx]` | `object` | Optional transaction to run within. |
**Returns**
`Promise<{id: number, name: string, createdAt: string, updatedAt: string}>` — The updated supplier.
**Throws**
`Error` — If the supplier is not found or the name is empty.
**Example**
```js
const supplier = await store.supplier.update(42, 5, { name: 'Acme GmbH' });
// => { id, name, createdAt, updatedAt }
```