6.8 KiB
articlesupplier
This document is auto-generated from the JSDoc comments in src/store by running npm run api-doc.
articlesupplier.create
Source: src/store/articlesupplier/create.js
Assigns a supplier to an article, optionally creating a purchase price.
Parameters
| Name | Type | Description |
|---|---|---|
googleAuthId |
number |
The id of the Google auth user. |
sku |
string |
The article SKU. |
input |
object |
The supplier assignment input. |
input.entityId |
number |
The id of the supplier entity. |
[input.sku] |
string |
The supplier's item number/SKU. |
[input.pu] |
number |
Packaging unit (defaults to 1). |
[input.stock] |
`number | null` |
[input.sort] |
number |
Display sort order (defaults to next sort). |
[input.netPrice] |
`number | null` |
[input.taxId] |
number |
The tax id for the purchase price. |
[input.taxRate] |
number |
The tax rate in percent (used if taxId is not provided). |
[tx] |
object |
Optional transaction to run within. |
Returns
Promise<{id: number, articleId: number, entityId: number, supplierName: string|null, sku: string|null, pu: number, stock: number|null, sort: number, price: {net: number, taxId: number, taxRate?: number}|null}> — The created assignment.
Throws
Error — If input is invalid, article or supplier is not found, or supplier is already assigned.
Example
const created = await store.articlesupplier.create(42, 'SKU-1', {
entityId: 88,
sku: 'MET-44910',
pu: 1,
netPrice: 4.20,
});
// => { id, articleId, entityId, supplierName, sku, pu, stock, sort, price }
articlesupplier.delete
Source: src/store/articlesupplier/delete.js
Deletes a supplier assignment and cleans up its associated purchase price.
Parameters
| Name | Type | Description |
|---|---|---|
googleAuthId |
number |
The id of the Google auth user. |
sku |
string |
The article SKU. |
id |
number |
The id of the articlesupplier record. |
[tx] |
object |
Optional transaction to run within. |
Returns
Promise<void>
Throws
Error — If the supplier assignment is not found.
Example
await store.articlesupplier.delete(42, 'SKU-1', 12);
articlesupplier.listByArticleSku
Source: src/store/articlesupplier/listByArticleSku.js
Lists the supplier assignments for an article by its SKU.
Parameters
| Name | Type | Description |
|---|---|---|
googleAuthId |
number |
The id of the Google auth user. |
sku |
string |
The article SKU. |
[tx] |
object |
Optional transaction. |
Returns
Promise<Array<{id: number, articleId: number, entityId: number, supplierName: string|null, sku: string|null, pu: number, stock: number|null, sort: number, price: {net: number, taxId: number, taxRate?: number}|null}>> — The supplier assignments.
Throws
Error — If the article is not found or the user is not authorized.
Example
const suppliers = await store.articlesupplier.listByArticleSku(42, 'SKU-1');
// => [{ id, articleId, entityId, supplierName, sku, pu, stock, price }]
articlesupplier.listByEntityAndSkus
Source: src/store/articlesupplier/listByEntityAndSkus.js
Lists article-supplier assignments for a given supplier (entityId) and SKU list, including linked article details (name, slug, photos, eans).
Parameters
| Name | Type | Description |
|---|---|---|
googleAuthId |
number |
The id of the Google auth user. |
entityIdOrOptions |
`number | {entityId?: number, supplierId?: number, skus?: string[] |
[maybeSkus] |
`string[] | string` |
[tx] |
object |
Optional transaction. |
Returns
Promise<Array<{id: number, articleId: number, entityId: number, supplierName: string|null, sku: string|null, pu: number, stock: number|null, sort: number, price: {net: number, taxId: number, taxRate?: number}|null, article: {id: number, sku: string, name: string|null, slug: string|null, photos: Array<{sort: number, fullHash: string, thumbW: number, thumbH: number, thumbHash: string}>, eans: string[]}}>> — The supplier assignments with article details.
Throws
Error — If user is not authorized, entityId is missing, or supplier does not exist.
Example
const items = await store.articlesupplier.listByEntityAndSkus(42, 5, ['SKU-1', 'SKU-2']);
// => [{ id, articleId, entityId, supplierName, sku, pu, stock, sort, price, article: { id, sku, name, slug, photos, eans } }]
articlesupplier.order
Source: src/store/articlesupplier/order.js
Reorders the supplier assignments of an article by its SKU.
Parameters
| Name | Type | Description |
|---|---|---|
googleAuthId |
number |
The id of the Google auth user. |
sku |
string |
The article SKU. |
input |
object |
The reorder input. |
input.ids |
Array<number> |
The articlesupplier ids in their new order. |
[tx] |
object |
Optional transaction to run within. |
Returns
Promise<{ids: Array<number>}> — The applied order.
Throws
Error — If the order is invalid.
Example
const result = await store.articlesupplier.order(42, 'SKU-1', { ids: [12, 10, 15] });
// => { ids: [12, 10, 15] }
articlesupplier.update
Source: src/store/articlesupplier/update.js
Updates an existing supplier assignment and its associated purchase price.
Parameters
| Name | Type | Description |
|---|---|---|
googleAuthId |
number |
The id of the Google auth user. |
sku |
string |
The article SKU. |
id |
number |
The id of the articlesupplier record. |
patch |
object |
The fields to update. |
[patch.sku] |
`string | null` |
[patch.pu] |
number |
Packaging unit (> 0). |
[patch.stock] |
`number | null` |
[patch.sort] |
number |
Display sort order. |
[patch.netPrice] |
`number | null` |
[patch.taxId] |
number |
The tax id for the purchase price. |
[patch.taxRate] |
number |
The tax rate in percent. |
[tx] |
object |
Optional transaction to run within. |
Returns
Promise<{id: number, articleId: number, entityId: number, supplierName: string|null, sku: string|null, pu: number, stock: number|null, sort: number, price: {net: number, taxId: number, taxRate?: number}|null}> — The updated assignment.
Throws
Error — If input is invalid or supplier assignment is not found.
Example
const updated = await store.articlesupplier.update(42, 'SKU-1', 12, {
sku: 'MET-44910-B',
pu: 6,
netPrice: 22.50,
});
// => { id, articleId, entityId, supplierName, sku, pu, stock, sort, price }