Files
dashlibstorage/API.articlesupplier.md

5.1 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).

Returns

Promise<{id: number, articleId: number, entityId: number, supplierName: string|null, sku: string|null, pu: number, stock: number|null, sort: number, priceId: number|null, 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, priceId, 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.

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.

Returns

Promise<Array<{id: number, articleId: number, entityId: number, supplierName: string|null, sku: string|null, pu: number, stock: number|null, sort: number, priceId: number|null, 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, priceId, price }]

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.

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.

Returns

Promise<{id: number, articleId: number, entityId: number, supplierName: string|null, sku: string|null, pu: number, stock: number|null, sort: number, priceId: number|null, 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, priceId, price }