4.7 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.
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. |
[tx] |
object |
Optional transaction. |
Returns
Promise<Array<{id: number, number: string, type: string, entityId: number|null, externalNumber: string|null, date: string}>> — The orders.
Example
const orders = await store.order.list(42);
// => [{ id, number, type, entityId, externalNumber, date }]
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: [...] }