85 lines
1.8 KiB
Markdown
85 lines
1.8 KiB
Markdown
# account
|
|
|
|
This document is auto-generated from the JSDoc comments in `src/store` by running `npm run api-doc`.
|
|
|
|
## `account.create`
|
|
|
|
*Source: `src/store/account/create.js`*
|
|
|
|
Creates an account for the user's selected company.
|
|
|
|
**Parameters**
|
|
|
|
| Name | Type | Description |
|
|
| --- | --- | --- |
|
|
| `googleAuthId` | `number` | The id of the Google auth user. |
|
|
| `input` | `object` | Account input. |
|
|
| `input.type` | `string` | Account type. |
|
|
| `input.name` | `string` | Account name. |
|
|
| `[tx]` | `object` | Optional transaction to run within. |
|
|
|
|
**Returns**
|
|
|
|
`Promise<{id: number, companyId: number, type: string, name: string}>`
|
|
|
|
**Throws**
|
|
|
|
`Error` — If type or name is missing.
|
|
|
|
**Example**
|
|
|
|
```js
|
|
const account = await store.account.create(googleAuthId, { type: 'bank', name: 'Main' });
|
|
```
|
|
|
|
## `account.delete`
|
|
|
|
*Source: `src/store/account/delete.js`*
|
|
|
|
Deletes an account of the user's selected company. Its payments are removed by cascade.
|
|
|
|
**Parameters**
|
|
|
|
| Name | Type | Description |
|
|
| --- | --- | --- |
|
|
| `googleAuthId` | `number` | The id of the Google auth user. |
|
|
| `id` | `number` | The account id. |
|
|
| `[tx]` | `object` | Optional transaction to run within. |
|
|
|
|
**Returns**
|
|
|
|
`Promise<void>`
|
|
|
|
**Throws**
|
|
|
|
`Error` — If the account id is invalid.
|
|
|
|
**Example**
|
|
|
|
```js
|
|
await store.account.delete(googleAuthId, 3);
|
|
```
|
|
|
|
## `account.list`
|
|
|
|
*Source: `src/store/account/list.js`*
|
|
|
|
Lists accounts 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, companyId: number, type: string, name: string}>>`
|
|
|
|
**Example**
|
|
|
|
```js
|
|
const accounts = await store.account.list(googleAuthId);
|
|
```
|