6.2 KiB
order
This document is auto-generated from the JSDoc comments in src/store by running npm run api-doc.
order.create
Source: src/store/order/create.js
Creates a new order for the user's selected company with its lines and records article history.
Parameters
| Name | Type | Description |
|---|---|---|
googleAuthId |
number |
The id of the Google auth user. |
body |
object |
The order input. |
body.number |
string |
The order number. |
body.date |
string |
The order date. |
[body.entityId] |
number |
The id of the customer entity. |
[body.externalNumber] |
string |
An external (customer) reference number. |
[body.lines] |
`Array<{sku?: string, name?: string, pu?: number, amount: number, net: number, rebate?: number, taxrate: number, comment?: string | null}>` |
[tx] |
object |
Optional transaction to run within. |
Returns
Promise<{id: number, number: string, type: string, entityId: number|null, externalNumber: string|null, date: string, lines: Array<{id: number, sku: string|null, name: string|null, pu: number, amount: number, net: number, rebate: number, taxrate: number, comment: string|null}>}> — The created order.
Throws
Error — If the order is invalid.
Example
const order = await store.order.create(42, { number: 'B-2026-001', date: '2026-09-15', entityId: 12, lines: [...] });
// => { id, number, type, entityId, externalNumber, date, lines: [...] }
order.delete
Source: src/store/order/delete.js
Deletes an order 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 order to delete. |
[tx] |
object |
Optional transaction. |
Returns
Promise<void>
Throws
Error — If the order is not found.
Example
await store.order.delete(42, 5);
order.getById
Source: src/store/order/getById.js
Returns a single order 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 order. |
[tx] |
object |
Optional transaction. |
Returns
Promise<{id: number, number: string, type: string, entityId: number|null, externalNumber: string|null, date: string, lines: Array<{id: number, sku: string|null, name: string|null, pu: number, amount: number, net: number, rebate: number, taxrate: number, comment: string|null}>}> — The order with its lines.
Throws
Error — If the order is not found.
Example
const order = await store.order.getById(42, 5);
// => { id, number, type, entityId, externalNumber, date, lines: [...] }
order.list
Source: src/store/order/list.js
Lists the orders 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 orders to skip. |
[opts.limit=50] |
number |
Number of orders to return. |
[opts.search] |
string |
Free-text search matching order number, external number, or customer name. |
[opts.onlyUnpaid=false] |
boolean |
When true, returns only unpaid orders. |
[opts.onlyUndelivered=false] |
boolean |
When true, returns only undelivered orders. |
[opts.seekMonths] |
number |
Negative integer for cutoff months ago (e.g. -1). |
[tx] |
object |
Optional transaction. |
Returns
Promise<{orders: Array<{id: number, number: string, type: string, entityId: number|null, externalNumber: string|null, date: string, createdAt: string|null, lines: Array<{id: number, sku: string|null, name: string|null, pu: number, amount: number, net: number, rebate: number, taxrate: number, comment: string|null}>}>, total: number, unfilteredTotal: number, offset: number, limit: number}|Array<object>> — The orders.
Example
const result = await store.order.list(42, { offset: 0, limit: 50, search: '1002', onlyUnpaid: true, onlyUndelivered: true, seekMonths: -1 });
// => { orders: [...], total: 10, unfilteredTotal: 42, offset: 0, limit: 50 }
const orders = await store.order.list(42);
// => [{ id, number, type, entityId, externalNumber, date, createdAt, lines: [...] }]
order.rebuildSummaries
Source: src/store/order/rebuildSummaries.js
Rebuilds the ordersummary table for the user's selected company.
Parameters
| Name | Type | Description |
|---|---|---|
provider |
import('../../providers/provider.js').DatabaseProvider |
order.syncSummary
Source: src/store/order/syncSummary.js
Centralized sync and rebuild logic for the materialized ordersummary table.
order.update
Source: src/store/order/update.js
Updates an order's header and/or lines.
Parameters
| Name | Type | Description |
|---|---|---|
googleAuthId |
number |
The id of the Google auth user. |
id |
number |
The id of the order to update. |
patch |
object |
The update patch. |
[patch.number] |
string |
The new order number. |
[patch.date] |
string |
The new order date. |
[patch.entityId] |
number |
The new customer entity id. |
[patch.externalNumber] |
string |
The new external (customer) reference number. |
[patch.lines] |
`Array<{sku?: string, name?: string, pu?: number, amount: number, net: number, rebate?: number, taxrate: number, comment?: string | null}>` |
[tx] |
object |
Optional transaction to run within. |
Returns
Promise<{id: number, number: string, type: string, entityId: number|null, externalNumber: string|null, date: string, lines: Array<{id: number, sku: string|null, name: string|null, pu: number, amount: number, net: number, rebate: number, taxrate: number, comment: string|null}>}> — The updated order.
Throws
Error — If the order is not found.
Example
const order = await store.order.update(42, 5, { number: 'B-2026-002', lines: [...] });
// => { id, number, type, entityId, date, lines: [...] }