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

@@ -300,17 +300,19 @@ Maps articles to suppliers (`entity`) with purchase pricing, stock, packaging un
| `sku` | `NVARCHAR(100)` | Supplier's SKU code, nullable |
| `stock` | `FLOAT` | Stock available at supplier, nullable |
| `pu` | `FLOAT` | Packaging unit (Verpackungseinheit), default `1` |
| `sort` | `INT` | Display sort order (default `0`) |
Unique constraint: `UQ_articlesupplier_article_entity (article_id, entity_id)`
Unique constraints: `UQ_articlesupplier_article_entity (article_id, entity_id)`, `UQ_articlesupplier_article_sort (article_id, sort)`
| Method | Signature | Returns |
| --- | --- | --- |
| `listByArticleSku` | `(googleAuthId, sku)` | `ArticleSupplierSummary[]` |
| `create` | `(googleAuthId, sku, { entityId, sku?, pu?, stock?, netPrice?, taxId?, taxRate? })` | `ArticleSupplierSummary` |
| `update` | `(googleAuthId, sku, id, { sku?, pu?, stock?, netPrice?, taxId?, taxRate? })` | `ArticleSupplierSummary` |
| `create` | `(googleAuthId, sku, { entityId, sku?, pu?, stock?, sort?, netPrice?, taxId?, taxRate? })` | `ArticleSupplierSummary` |
| `update` | `(googleAuthId, sku, id, { sku?, pu?, stock?, sort?, netPrice?, taxId?, taxRate? })` | `ArticleSupplierSummary` |
| `order` | `(googleAuthId, sku, { ids })` | `{ ids: number[] }` |
| `delete` | `(googleAuthId, sku, id)` | `void` |
Errors: `Not authorized`, `Article not found`, `Supplier required`, `Supplier not found`, `Supplier assignment not found`, `Supplier already assigned`, `Invalid pu`, `Invalid stock`, `Invalid price`.
Errors: `Not authorized`, `Article not found`, `Supplier required`, `Supplier not found`, `Supplier assignment not found`, `Supplier already assigned`, `Invalid pu`, `Invalid stock`, `Invalid sort`, `Invalid supplier order`, `Invalid price`.
---
@@ -760,6 +762,7 @@ Company-scoped number sequences (`numbers` table). Auth via selected company (`g
| `GET /api/article/:sku/supplier` | `articlesupplier.listByArticleSku(googleAuthId, sku)` |
| `POST /api/article/:sku/supplier` | `articlesupplier.create(googleAuthId, sku, { entityId, sku?, pu?, stock?, netPrice?, taxId?, taxRate? })` |
| `PATCH /api/article/:sku/supplier/:id` | `articlesupplier.update(googleAuthId, sku, id, patch)` |
| `PUT /api/article/:sku/supplier/order` | `articlesupplier.order(googleAuthId, sku, { ids })` |
| `DELETE /api/article/:sku/supplier/:id` | `articlesupplier.delete(googleAuthId, sku, id)` |
| `GET /api/delivery` | `delivery.list(googleAuthId)` |
| `GET /api/delivery/:id` | `delivery.getById(googleAuthId, id)` |