Auto-allocate delivery number via getnextnumberwithprefixandpadding

This commit is contained in:
seb
2026-08-08 10:09:08 +02:00
parent 91e7c03655
commit fb88cb92a5
3 changed files with 12 additions and 9 deletions

View File

@@ -293,7 +293,7 @@ Company-scoped goods receipts on `manifest` / `manifestarticle` with fixed `type
| --- | --- | --- |
| `list` | `(googleAuthId)` | `DeliverySummary[]` |
| `getById` | `(googleAuthId, id)` | `Delivery` |
| `create` | `(googleAuthId, { number, date, supplierId?, externalNumber?, lines })` | `Delivery` |
| `create` | `(googleAuthId, { date, supplierId?, externalNumber?, lines })` | `Delivery` |
| `update` | `(googleAuthId, id, { number?, date?, supplierId?, externalNumber?, lines? })` | `Delivery` |
| `delete` | `(googleAuthId, id)` | `void` |
@@ -321,7 +321,7 @@ type DeliveryLine = {
type Delivery = DeliverySummary & { lines: DeliveryLine[] }
```
`create` inserts header + lines in one transaction. `supplierId` null or a Lieferanten `entity` of the company (else `Supplier not found`). Each line requires `sku` (resolved in the company category tree → `Article not found`), `amount`, `net`, `tax` (rate → `tax.ensure`); `rebate` defaults `0`. Empty/invalid `number` or `date` → `Invalid delivery`; bad line payload → `Invalid lines`.
`create` inserts header + lines in one transaction. The `number` is auto-allocated via `getnextnumberwithprefixandpadding` (`numbers` type `delivery`); supply `externalNumber` for an external (supplier) reference. `supplierId` null or a Lieferanten `entity` of the company (else `Supplier not found`). Each line requires `sku` (resolved in the company category tree → `Article not found`), `amount`, `net`, `tax` (rate → `tax.ensure`); `rebate` defaults `0`. Empty/invalid `date` → `Invalid delivery`; bad line payload → `Invalid lines`.
`update` patches header fields that are present. If `lines` is present, replace-all lines; if omitted, leave lines unchanged. Returns full `Delivery`.