diff --git a/README.md b/README.md index eb2ab26..2599aef 100644 --- a/README.md +++ b/README.md @@ -328,18 +328,20 @@ type DeliverySummary = { type DeliveryLine = { id: number, sku: string | null, - customname: string | null, + name: string | null, + pu: number, amount: number, net: number, rebate: number, - tax: number, // tax.rate + tax: number, // manifestarticle.taxrate (also exposed as taxrate) + taxrate: number, comment: string | null, } type Delivery = DeliverySummary & { lines: DeliveryLine[] } ``` -`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 either `sku` or `customname`. For delivery manifests, `sku` points to `articlesupplier.sku`; for quote and order manifests, `sku` points to `article.sku`. Lines are stored without FKs so manifest articles are preserved even if articles or suppliers are deleted. `amount`, `net`, `tax` (rate → `tax.ensure`); `rebate` defaults `0`. Empty/invalid `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 either `sku` or `name`. For delivery manifests, `sku` points to `articlesupplier.sku`; for quote and order manifests, `sku` points to `article.sku`. Lines are stored without FKs so manifest articles are preserved even if articles or suppliers are deleted. `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`. diff --git a/schema-graph.dot b/schema-graph.dot index 01a6fe2..124978b 100644 --- a/schema-graph.dot +++ b/schema-graph.dot @@ -11,14 +11,14 @@ digraph schema { fontcolor="#e2e8f0"; margin=14; meta [label=<
| meta | |||
| |||
| |||
| |||||||
| |||||||
| |||||||
| |||||||
| |||||||
| |||||||||||
| |||||||||||
| |||||||||||
| |||||||||||
| |||||||||||
| |||||||||||
| |||||||||||
| |||||||||||
| numbers | |||
| |||
| |||
| |||
| |||
| |||
| |||
| entityaddress | |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||||||||||
| |||||||||||
| |||||||||||
| |||||||||||
| |||||||||||
| |||||||||||
| |||||||||||
| |||||||||||
| |||||
| |||||
| |||||
| |||||
| entitycontact | |||
| |||
| |||
| |||
| |||
| |||
| |||||||||||||||||||||
| |||||||||||||||||||||
| |||||||||||||||||||||
| |||||||||||||||||||||
| |||||||||||||||||||||
| |||||||||||||||||||||
| |||||||||||||||||||||
| |||||||||||||||||||||
| |||||||||||||||||||||
| syncpos | |||
| |||
| |||
| |||
| |||
| entityhistory | |||
| |||
| |||
| |||
| |||
| |||
| |||||||||||||||||||||
| |||||||||||||||||||||
| |||||||||||||||||||||
| |||||||||||||||||||||
| |||||||||||||||||||||
| |||||||||||||||||||||
| |||||||||||||||||||||
| |||||||||||||||||||||
| |||||||||||||||||||||
| companysetting | |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||||||||
| |||||||||
| |||||||||
| unittext | |||
| |||
| |||
| |||
| |||
| |||
| categorytext | |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||
| articletext | |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||
| categorytext | |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||
| articletext | |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||||
| |||||
| categoryarticle | |||
| |||
| |||
| |||
| |||||
| |||||
| |||||
| |||||
| |||||
| optionslistarticle | |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||||||||||||
| |||||||||||||
| |||||||||||||
| |||||||||||||
| articlehistory | |||
| |||
| |||
| |||
| |||
| |||
| |||||||||||||||||||||
| |||||||||||||||||||||
| |||||||||||||||||||||
| |||||||||||||||||||||
| |||||||||||||||||||||
| |||||||||||||||||||||
| |||||||||||||||||||||
| |||||||||||||||||||||
| |||||||||||||||||||||
| |||||||||||||||||||||
| |||||||||||||||||||||
| |||||||||||||||||||||
| |||||||||||||||||||||
| |||||||||||||||||||||
| articleean | |||
| |||
| |||
| |||
| |||||||||||||||||||||
| |||||||||||||||||||||
| |||||||||||||||||||||
| |||||||||||||||||||||
| |||||||||||||||||||||
| |||||||||||||||||||||
| |||||||||||||||||||||
| |||||||||||||||||||||
| |||||||||||||||||||||
| |||||||||||||||||||||
| |||||||||||||||||||||
| |||||||||||||||||||||
| |||||||||||||||||||||
| |||||||||||||||||||||
| |||||
| |||||
| articlesupplier | |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||
| articleean | |||
| |||
| |||
| |||
| articlelistarticle | |||
| |||
| |||
| |||
| |||
| |||
| optionslistarticle | |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||||
| |||||
| |||||
| |||||
| |||||
| |||||
| |||||
| articlesupplier | |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||
| categorypic | |||
| |||
| |||
| |||
| |||
| |||||||
| |||||||
| |||||||
| |||||||
| |||||||
| |||||||
| |||||||
| |||||||
| |||||||
| |||||||
| |||||||
| |||||||
| categorypic | |||
| |||
| |||
| |||
| |||
| brandpic | |||
| |||
| |||
| |||
| |||
| articlepic | |||
| |||
| |||
| |||
| |||
| brandpic | |||
| |||
| |||
| |||
| |||
| articlepic | |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||
| ledger | |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||||||||||
| |||||||||||
| |||||||||||
| |||||||||
| |||||||||
| |||||||||
| |||
| |||
| |||
| |||
| |||
| |||
| |||
| Legend | |
| PK | primary key |
| FK | foreign key |
| ? | nullable column |
| — | FOREIGN KEY constraint |
| - - | naming convention only, no constraint |