- Rewrite JSDoc across all store methods to document the actual async methods (real params, returns, throws) instead of the internal wrappers - Split quote/order into individual module files backed by shared manifestDoc helpers; remove the createStore factory and thin wrappers - Deduplicate manifest line helpers into src/store/manifestLines.js - Extend generate-api-doc.js to render parameter/return/throws types and emit per-namespace API.<module>.md files with an API.md index - Regenerate all API docs
167 lines
3.9 KiB
Markdown
167 lines
3.9 KiB
Markdown
# company
|
|
|
|
This document is auto-generated from the JSDoc comments in `src/store` by running `npm run api-doc`.
|
|
|
|
## `company.create`
|
|
|
|
*Source: `src/store/company/create.js`*
|
|
|
|
Creates a new company together with its root category, POS customer group, default language and tax rates, and links it to the given Google auth user.
|
|
|
|
**Parameters**
|
|
|
|
| Name | Type | Description |
|
|
| --- | --- | --- |
|
|
| `input` | `object` | The company creation input. |
|
|
| `input.iso639` | `string` | The ISO 639 language code for the company. |
|
|
| `input.name` | `string` | The company name (must be unique). |
|
|
| `input.taxrate` | `number` | The standard tax rate in percent. |
|
|
| `input.reducedtaxrate` | `number` | The reduced tax rate in percent. |
|
|
| `input.googleAuthId` | `number` | The id of the Google auth user to link. |
|
|
|
|
**Returns**
|
|
|
|
`Promise<{id: number, rootCategoryId: number, languageId: number, taxrateId: number, reducedtaxrateId: number, taxfreerateId: number, posCustomerGroupId: number}>` — The created company ids.
|
|
|
|
**Throws**
|
|
|
|
`Error` — If the company name is already taken.
|
|
|
|
**Example**
|
|
|
|
```js
|
|
const company = await store.company.create({
|
|
iso639: 'de',
|
|
name: 'Acme',
|
|
taxrate: 19,
|
|
reducedtaxrate: 7,
|
|
googleAuthId: 42,
|
|
});
|
|
// => { id, rootCategoryId, languageId, taxrateId, reducedtaxrateId, taxfreerateId, posCustomerGroupId }
|
|
```
|
|
|
|
## `company.delete`
|
|
|
|
*Source: `src/store/company/delete.js`*
|
|
|
|
Deletes a company by its id.
|
|
|
|
**Parameters**
|
|
|
|
| Name | Type | Description |
|
|
| --- | --- | --- |
|
|
| `companyId` | `number` | The id of the company to delete. |
|
|
|
|
**Returns**
|
|
|
|
`Promise<void>`
|
|
|
|
**Example**
|
|
|
|
```js
|
|
await store.company.delete(1);
|
|
```
|
|
|
|
## `company.getById`
|
|
|
|
*Source: `src/store/company/getById.js`*
|
|
|
|
Returns a single company by its id.
|
|
|
|
**Parameters**
|
|
|
|
| Name | Type | Description |
|
|
| --- | --- | --- |
|
|
| `id` | `number` | The id of the company. |
|
|
| `[tx]` | `object` | Optional transaction to run within. |
|
|
|
|
**Returns**
|
|
|
|
`Promise<object|undefined>` — The company row, or `undefined` if not found.
|
|
|
|
**Example**
|
|
|
|
```js
|
|
const company = await store.company.getById(1);
|
|
// => { id, name, ... }
|
|
```
|
|
|
|
## `company.getByName`
|
|
|
|
*Source: `src/store/company/getByName.js`*
|
|
|
|
Returns a single company by its name.
|
|
|
|
**Parameters**
|
|
|
|
| Name | Type | Description |
|
|
| --- | --- | --- |
|
|
| `name` | `string` | The company name. |
|
|
| `[tx]` | `object` | Optional transaction to run within. |
|
|
|
|
**Returns**
|
|
|
|
`Promise<object|undefined>` — The company row, or `undefined` if not found.
|
|
|
|
**Example**
|
|
|
|
```js
|
|
const company = await store.company.getByName('Acme');
|
|
// => { id, name, ... }
|
|
```
|
|
|
|
## `company.list`
|
|
|
|
*Source: `src/store/company/list.js`*
|
|
|
|
Lists the companies accessible to the given Google auth user.
|
|
|
|
**Parameters**
|
|
|
|
| Name | Type | Description |
|
|
| --- | --- | --- |
|
|
| `googleAuthId` | `number` | The id of the Google auth user. |
|
|
|
|
**Returns**
|
|
|
|
`Promise<Array<object>>` — The accessible company rows.
|
|
|
|
**Example**
|
|
|
|
```js
|
|
const companies = await store.company.list(42);
|
|
// => [{ id, name, ... }]
|
|
```
|
|
|
|
## `company.update`
|
|
|
|
*Source: `src/store/company/update.js`*
|
|
|
|
Updates an existing company's name, language and tax rates.
|
|
|
|
**Parameters**
|
|
|
|
| Name | Type | Description |
|
|
| --- | --- | --- |
|
|
| `id` | `number` | The id of the company to update. |
|
|
| `input` | `object` | The update input. |
|
|
| `input.iso639` | `string` | The ISO 639 language code. |
|
|
| `input.name` | `string` | The new company name (must be unique). |
|
|
| `input.taxrate` | `number` | The standard tax rate in percent. |
|
|
| `input.reducedtaxrate` | `number` | The reduced tax rate in percent. |
|
|
|
|
**Returns**
|
|
|
|
`Promise<{id: number, rootCategoryId: number, languageId: number, taxrateId: number, reducedtaxrateId: number, taxfreerateId: number}>` — The updated company ids.
|
|
|
|
**Throws**
|
|
|
|
`Error` — If the company is not found or the name is taken.
|
|
|
|
**Example**
|
|
|
|
```js
|
|
const result = await store.company.update(1, { iso639: 'de', name: 'Acme', taxrate: 19, reducedtaxrate: 7 });
|
|
// => { id, rootCategoryId, languageId, taxrateId, reducedtaxrateId, taxfreerateId }
|
|
```
|