feat(articlesupplier): add sort column, reorder method, and update queries and schema

This commit is contained in:
seb
2026-09-17 12:00:41 +02:00
parent 4c196c7209
commit af52ff595f
16 changed files with 264 additions and 78 deletions

View File

@@ -19,13 +19,14 @@ Assigns a supplier to an article, optionally creating a purchase price.
| `[input.sku]` | `string` | The supplier's item number/SKU. |
| `[input.pu]` | `number` | Packaging unit (defaults to 1). |
| `[input.stock]` | `number|null` | Current stock at the supplier. |
| `[input.sort]` | `number` | Display sort order (defaults to next sort). |
| `[input.netPrice]` | `number|null` | Net purchase price. |
| `[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, priceId: number|null, price: {net: number, taxId: number, taxRate?: number}|null}>` — The created assignment.
`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**
@@ -40,7 +41,7 @@ const created = await store.articlesupplier.create(42, 'SKU-1', {
pu: 1,
netPrice: 4.20,
});
// => { id, articleId, entityId, supplierName, sku, pu, stock, priceId, price }
// => { id, articleId, entityId, supplierName, sku, pu, stock, sort, priceId, price }
```
## `articlesupplier.delete`
@@ -86,7 +87,7 @@ Lists the supplier assignments for an article by its SKU.
**Returns**
`Promise<Array<{id: number, articleId: number, entityId: number, supplierName: string|null, sku: string|null, pu: number, stock: number|null, priceId: number|null, price: {net: number, taxId: number, taxRate?: number}|null}>>` — The supplier assignments.
`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**
@@ -99,6 +100,36 @@ 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**
```js
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`*
@@ -116,13 +147,14 @@ Updates an existing supplier assignment and its associated purchase price.
| `[patch.sku]` | `string|null` | The supplier's item number/SKU. |
| `[patch.pu]` | `number` | Packaging unit (> 0). |
| `[patch.stock]` | `number|null` | Current stock at the supplier. |
| `[patch.sort]` | `number` | Display sort order. |
| `[patch.netPrice]` | `number|null` | Net purchase price. |
| `[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, priceId: number|null, price: {net: number, taxId: number, taxRate?: number}|null}>` — The updated assignment.
`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**
@@ -136,5 +168,5 @@ const updated = await store.articlesupplier.update(42, 'SKU-1', 12, {
pu: 6,
netPrice: 22.50,
});
// => { id, articleId, entityId, supplierName, sku, pu, stock, priceId, price }
// => { id, articleId, entityId, supplierName, sku, pu, stock, sort, priceId, price }
```