u
This commit is contained in:
@@ -42,17 +42,18 @@ Creates a new article under a given parent category, allocating a SKU and a defa
|
||||
| `input.googleAuthId` | `number` | The id of the Google auth user. |
|
||||
| `input.parentId` | `number` | The id of the parent category. |
|
||||
| `input.name` | `string` | The article name. |
|
||||
| `[input.track_stock=true]` | `boolean|number` | Whether inventory stock is tracked. |
|
||||
| `[tx]` | `object` | Optional transaction to run within. |
|
||||
|
||||
**Returns**
|
||||
|
||||
`Promise<{id: number, parentId: number, name: string, sku: string}>` — The created article.
|
||||
`Promise<{id: number, parentId: number, name: string, sku: string, track_stock: boolean}>` — The created article.
|
||||
|
||||
**Example**
|
||||
|
||||
```js
|
||||
const article = await store.article.createUnderParent({ googleAuthId: 42, parentId: 5, name: 'Cola' });
|
||||
// => { id, parentId, name, sku }
|
||||
// => { id, parentId, name, sku, track_stock }
|
||||
```
|
||||
|
||||
## `article.delete`
|
||||
@@ -128,7 +129,7 @@ Returns the full detail of an article by its SKU, including unit, brand, categor
|
||||
|
||||
**Returns**
|
||||
|
||||
`Promise<{article: {id: number, sku: string, name: string, slug: string, unitamount: number|null, weight: number|null, unit: {si: string|null, basesi: string|null, basesifactor: number|null, symbol: string|null, name: string|null}, brand: {id: number|null, name: string, fullHash: string|null, thumbW: number|null, thumbH: number|null, thumbHash: string|null}|null, categoryIds: number[], photos: Array<{sort: number, fullHash: string, fullW: number, fullH: number, fullSize: number, thumbW: number, thumbH: number, thumbHash: string}>, eans: string[], prices: Array<{minmultiplier: number, net: number, taxRate: number, customergroupId: number}>, suppliers: 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}>, optionsCount: number, articleListCount: number, childCount: number, fatherArticleId: number|null, fatherSku: string|null}}>` — The full article detail.
|
||||
`Promise<{article: {id: number, sku: string, name: string, slug: string, unitamount: number|null, weight: number|null, track_stock: boolean, unit: {si: string|null, basesi: string|null, basesifactor: number|null, symbol: string|null, name: string|null}, brand: {id: number|null, name: string, fullHash: string|null, thumbW: number|null, thumbH: number|null, thumbHash: string|null}|null, categoryIds: number[], photos: Array<{sort: number, fullHash: string, fullW: number, fullH: number, fullSize: number, thumbW: number, thumbH: number, thumbHash: string}>, eans: string[], prices: Array<{minmultiplier: number, net: number, taxRate: number, customergroupId: number}>, suppliers: 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}>, optionsCount: number, articleListCount: number, childCount: number, fatherArticleId: number|null, fatherSku: string|null}}>` — The full article detail.
|
||||
|
||||
**Throws**
|
||||
|
||||
@@ -188,6 +189,7 @@ Imports article rows, creating articles by their SKU and returning per-row impor
|
||||
| `[input.rows[].net]` | `number|string` | The POS net price (accepts German decimals). |
|
||||
| `[input.rows[].tax]` | `number|string` | The tax rate in percent (e.g. `19`). |
|
||||
| `[input.rows[].eans]` | `Array<string>|string` | The EANs to set. |
|
||||
| `[input.rows[].track_stock=true]` | `boolean|number` | Whether inventory stock is tracked. |
|
||||
| `[input.rows[].fatherSku]` | `string` | The father article SKU for a V/K compound link. |
|
||||
| `[input.rows[].deposit]` | `number|string` | The deposit (Pfand) value; currently ignored. |
|
||||
| `[tx]` | `object` | Optional transaction. |
|
||||
@@ -443,6 +445,36 @@ const article = await store.article.setPricesBySku(42, 'SKU-1', [{ price: 1.5, t
|
||||
// => { id, sku, name, ... }
|
||||
```
|
||||
|
||||
## `article.setTrackStockBySku`
|
||||
|
||||
*Source: `src/store/article/setTrackStockBySku.js`*
|
||||
|
||||
Sets the track_stock flag of an article by its SKU.
|
||||
|
||||
**Parameters**
|
||||
|
||||
| Name | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| `googleAuthId` | `number` | The id of the Google auth user. |
|
||||
| `sku` | `string` | The article SKU. |
|
||||
| `trackStock` | `boolean|number` | Whether stock tracking is enabled. |
|
||||
| `[tx]` | `object` | Optional transaction. |
|
||||
|
||||
**Returns**
|
||||
|
||||
`Promise<object>` — The updated article.
|
||||
|
||||
**Throws**
|
||||
|
||||
`Error` — If trackStock is invalid or the article is not found.
|
||||
|
||||
**Example**
|
||||
|
||||
```js
|
||||
const article = await store.article.setTrackStockBySku(42, 'SKU-1', true);
|
||||
// => { id, sku, name, track_stock, ... }
|
||||
```
|
||||
|
||||
## `article.setWeightBySku`
|
||||
|
||||
*Source: `src/store/article/setWeightBySku.js`*
|
||||
@@ -489,6 +521,7 @@ Updates an article's name and/or unit (SI and amount), recording history.
|
||||
| `[patch.name]` | `string` | The new article name. |
|
||||
| `[patch.unitSi]` | `string` | The new unit SI code. |
|
||||
| `[patch.unitamount]` | `number` | The new unit amount (must be > 0). |
|
||||
| `[patch.track_stock]` | `boolean|number` | Whether inventory stock is tracked. |
|
||||
| `[tx]` | `object` | Optional transaction to run within. |
|
||||
|
||||
**Returns**
|
||||
@@ -502,6 +535,6 @@ Updates an article's name and/or unit (SI and amount), recording history.
|
||||
**Example**
|
||||
|
||||
```js
|
||||
const article = await store.article.updateBySku(42, 'SKU-1', { name: 'Cola 1L', unitSi: 'l', unitamount: 1 });
|
||||
const article = await store.article.updateBySku(42, 'SKU-1', { name: 'Cola 1L', unitSi: 'l', unitamount: 1, track_stock: true });
|
||||
// => { id, sku, name, ... }
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user