Files
dashlibstorage/API.return.md
2026-10-26 19:22:04 +01:00

84 lines
2.4 KiB
Markdown

# return
This document is auto-generated from the JSDoc comments in `src/store` by running `npm run api-doc`.
## `return.book`
*Source: `src/store/return/book.js`*
Books all positions of a return manifest to the ledger.
**Parameters**
| Name | Type | Description |
| --- | --- | --- |
| `provider` | `object` | Storage provider instance. |
**Returns**
`Function` — `(googleAuthId, input, tx) => Promise<object>`
## `return.getById`
*Source: `src/store/return/getById.js`*
Returns a return manifest 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 return manifest. |
| `[tx]` | `object` | Optional transaction. |
**Returns**
`Promise<object>` — The return manifest with lines and summary.
**Throws**
`Error` — If the return is not found.
## `return.list`
*Source: `src/store/return/list.js`*
Lists the returns of the user's selected company.
**Parameters**
| Name | Type | Description |
| --- | --- | --- |
| `googleAuthId` | `number` | The id of the Google auth user. |
| `[opts]` | `object` | Optional pagination and filter options. |
| `[opts.offset=0]` | `number` | Number of returns to skip. |
| `[opts.limit=50]` | `number` | Number of returns to return. |
| `[opts.search]` | `string` | Free-text search matching return number, external number, or supplier name. |
| `[opts.onlyUnbooked=false]` | `boolean` | When true, returns only returns with unbooked stock items. |
| `[opts.supplierId]` | `number` | Filter by supplier entity id. |
| `[opts.seekMonths]` | `number` | Negative integer for cutoff months ago. |
| `[tx]` | `object` | Optional transaction. |
**Returns**
`Promise<{returns: Array<object>, total: number, unfilteredTotal: number, offset: number, limit: number}|Array<object>>`
## `return.rebuildSummaries`
*Source: `src/store/return/rebuildSummaries.js`*
Rebuilds the `returnsummary` table for the user's selected company.
**Parameters**
| Name | Type | Description |
| --- | --- | --- |
| `provider` | `import('../../providers/provider.js').DatabaseProvider` | |
## `return.syncSummary`
*Source: `src/store/return/syncSummary.js`*
Centralized sync and rebuild logic for the materialized `returnsummary` table. Keeps `returnsummary` in sync with manifest (return), manifestarticle, article (track_stock), and ledger (RETURN transactions).