feat(articlesupplier): implement store methods, schema constraints, and embed in getBySku

This commit is contained in:
seb
2026-09-17 11:41:13 +02:00
parent 1fafeeb5f2
commit 4c196c7209
15 changed files with 812 additions and 6 deletions

View File

@@ -296,11 +296,22 @@ Maps articles to suppliers (`entity`) with purchase pricing, stock, packaging un
| `id` | `INT` | Primary Key (`IDENTITY(1,1)`) |
| `article_id` | `INT` | FK → `article(id)` (`ON DELETE CASCADE`) |
| `entity_id` | `INT` | FK → `entity(id)` (`ON DELETE CASCADE`) |
| `price_id` | `INT` | FK → `price(id)` (`ON DELETE NO ACTION`), nullable |
| `price_id` | `INT` | FK → `price(id)` (`ON DELETE SET NULL`), nullable |
| `sku` | `NVARCHAR(100)` | Supplier's SKU code, nullable |
| `stock` | `FLOAT` | Stock available at supplier, nullable |
| `pu` | `FLOAT` | Packaging unit (Verpackungseinheit), default `1` |
Unique constraint: `UQ_articlesupplier_article_entity (article_id, entity_id)`
| 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` |
| `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`.
---
## `delivery`
@@ -746,6 +757,10 @@ Company-scoped number sequences (`numbers` table). Auth via selected company (`g
| `POST /api/supplier` | `supplier.create(googleAuthId, { name })` |
| `PATCH /api/supplier/:id` | `supplier.update(googleAuthId, id, { name })` |
| `DELETE /api/supplier/:id` | `supplier.delete(googleAuthId, id)` |
| `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)` |
| `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)` |
| `POST /api/delivery` | `delivery.create(googleAuthId, { number, date, supplierId?, lines })` |