Add company-scoped delivery store on manifest
This commit is contained in:
49
README.md
49
README.md
@@ -202,6 +202,50 @@ Suppliers are `entity` rows in the company `customergroup` named `Lieferanten` (
|
||||
|
||||
---
|
||||
|
||||
## `delivery`
|
||||
|
||||
Company-scoped goods receipts on `manifest` / `manifestarticle` with fixed `type = 'delivery'`. Auth via `resolveCompanyAccess`. `manifest.company_id` scopes the list (`ON DELETE NO ACTION` — avoid SQL Server multiple cascade paths with `entity_id`).
|
||||
|
||||
| Method | Signature | Returns |
|
||||
| --- | --- | --- |
|
||||
| `list` | `(googleAuthId, companyId)` | `DeliverySummary[]` |
|
||||
| `getById` | `(googleAuthId, companyId, id)` | `Delivery` |
|
||||
| `create` | `(googleAuthId, companyId, { number, date, supplierId?, lines })` | `Delivery` |
|
||||
| `update` | `(googleAuthId, companyId, id, { number?, date?, supplierId?, lines? })` | `Delivery` |
|
||||
| `delete` | `(googleAuthId, companyId, id)` | `void` |
|
||||
|
||||
```ts
|
||||
type DeliverySummary = {
|
||||
id: number,
|
||||
number: string,
|
||||
type: 'delivery',
|
||||
supplierId: number | null, // manifest.entity_id
|
||||
date: Date,
|
||||
}
|
||||
|
||||
type DeliveryLine = {
|
||||
id: number,
|
||||
articleId: number | null,
|
||||
sku: string | null,
|
||||
amount: number,
|
||||
net: number,
|
||||
transactedAmount: number,
|
||||
rebate: number,
|
||||
tax: number, // tax.rate
|
||||
comment: string | null,
|
||||
}
|
||||
|
||||
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`; `transactedAmount` defaults to `amount`. Empty/invalid `number` or `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`.
|
||||
|
||||
`delete` removes the manifest (`manifestarticle` cascades). Errors: `Company not found`, `Not authorized`, `Delivery not found`, `Supplier not found`, `Article not found`, `Invalid delivery`, `Invalid lines`.
|
||||
|
||||
---
|
||||
|
||||
## `posterminal`
|
||||
|
||||
Company-scoped POS terminals. Auth via `resolveCompanyAccess`.
|
||||
@@ -479,6 +523,11 @@ res.set('Content-Type', thumb.contentType).send(thumb.buffer);
|
||||
| `POST /api/supplier` | `supplier.create(googleAuthId, companyId, { name })` |
|
||||
| `PATCH /api/supplier/:id` | `supplier.update(googleAuthId, companyId, id, { name })` |
|
||||
| `DELETE /api/supplier/:id` | `supplier.delete(googleAuthId, companyId, id)` |
|
||||
| `GET /api/delivery` | `delivery.list(googleAuthId, companyId)` |
|
||||
| `GET /api/delivery/:id` | `delivery.getById(googleAuthId, companyId, id)` |
|
||||
| `POST /api/delivery` | `delivery.create(googleAuthId, companyId, { number, date, supplierId?, lines })` |
|
||||
| `PATCH /api/delivery/:id` | `delivery.update(googleAuthId, companyId, id, { number?, date?, supplierId?, lines? })` |
|
||||
| `DELETE /api/delivery/:id` | `delivery.delete(googleAuthId, companyId, id)` |
|
||||
| `GET /api/posterminal` | `posterminal.list(googleAuthId, companyId)` |
|
||||
| `PUT /api/posterminal` | `posterminal.upsert(googleAuthId, companyId, { id?, name, token?, pairingpin })` |
|
||||
| `DELETE /api/posterminal/:id` | `posterminal.delete(googleAuthId, companyId, id)` |
|
||||
|
||||
Reference in New Issue
Block a user