diff --git a/README.md b/README.md index 7de4925..c3daa7f 100644 --- a/README.md +++ b/README.md @@ -187,6 +187,21 @@ Company-scoped brands. Auth via `resolveCompanyAccess`. --- +## `supplier` + +Suppliers are `entity` rows in the company `customergroup` named `Lieferanten` (created implicitly on first supplier). Auth via `resolveCompanyAccess`. + +| Method | Signature | Returns | +| --- | --- | --- | +| `list` | `(googleAuthId, companyId)` | `{ id, name, createdAt, updatedAt }[]` | +| `create` | `(googleAuthId, companyId, { name })` | `{ id, name, createdAt, updatedAt }` | +| `update` | `(googleAuthId, companyId, id, { name })` | `{ id, name, createdAt, updatedAt }` | +| `delete` | `(googleAuthId, companyId, id)` | `void` | + +`create` ensures `customergroup` `Lieferanten` for the company, inserts `entity` (`name` only; `first_name` null), writes `entityhistory` (`Erstellt`) with the auth `companyuser_id`. `update` renames and writes `Name geändert von "…" auf "…"` when the name actually changes; bumps `updated_at`. Empty name → `Name required`. `delete` removes the entity (`entityhistory` cascades; `manifest.entity_id` set null). Errors: `Company not found`, `Not authorized`, `Name required`, `Supplier not found`. + +--- + ## `posterminal` Company-scoped POS terminals. Auth via `resolveCompanyAccess`. @@ -460,6 +475,10 @@ res.set('Content-Type', thumb.contentType).send(thumb.buffer); | `GET /api/brand` | `brand.list(googleAuthId, companyId)` | | `PUT /api/brand` | `brand.upsert(googleAuthId, companyId, { name, gsprpinfo? })` | | `DELETE /api/brand/:id` | `brand.delete(googleAuthId, companyId, id)` | +| `GET /api/supplier` | `supplier.list(googleAuthId, companyId)` | +| `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/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)` | diff --git a/generate-schema-graph.js b/generate-schema-graph.js index d9edbbc..ff6b20f 100644 --- a/generate-schema-graph.js +++ b/generate-schema-graph.js @@ -274,6 +274,7 @@ const CLUSTERS = [ 'companysetting', 'customergroup', 'entity', + 'entityhistory', 'numbers', ], }, diff --git a/schema-graph.dot b/schema-graph.dot index 1b5d6f3..4221cc3 100644 --- a/schema-graph.dot +++ b/schema-graph.dot @@ -9,24 +9,25 @@ digraph schema { label="Identity & Company"; labeljust="l"; fontsize=15; style="rounded,filled"; fillcolor="#ffffff60"; color="#a0aec0"; fontcolor="#1a365d"; margin=14; - numbers [label=<
| numbers | |||
| |||
| |||
| |||
| |||
| |||
| |||
| entity | |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||
| syncpos | |||
| |||
| |||
| |||
| |||
| |||||||||||||||||||
| |||||||||||||||||||
| |||||||||||||||||||
| |||||||||||||||||||
| |||||||||||||||||||
| |||||||||||||||||||
| |||||||||||||||||||
| |||||||||||||||||||
| |||||||||||||||||||
| |||||
| |||||
| |||||
| |||||
| |||||
| |||||
| |||||
| meta | |||
| |||
| |||
| numbers | |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||||||
| |||||||
| |||||||
| |||||||
| syncpos | |||
| |||
| |||
| |||
| |||
| |||||||||||||||||||
| |||||||||||||||||||
| |||||||||||||||||||
| |||||||||||||||||||
| |||||||||||||||||||
| |||||||||||||||||||
| |||||||||||||||||||
| |||||||||||||||||||
| |||||||||||||||||||
| entityhistory | |||
| |||
| |||
| |||
| |||
| |||
| companysetting | |||
| |||
| |||
| |||
| |||
| |||
| |||||
| |||||
| |||||
| |||||
| |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||
| unittext | |||
| |||
| |||
| |||
| |||
| |||
| |||||||||
| |||||||||
| |||||||||
| articletext | |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||
| unittext | |||
| |||
| |||
| |||
| |||
| |||
| categorytext | |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||
| articletext | |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||
| categorytext | |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||||||||||||
| |||||||||||||
| |||||||||||||
| |||||||||||||
| categoryarticle | |||
| |||
| |||
| |||
| articlelistarticle | |||
| |||
| |||
| |||
| |||
| |||
| |||||
| |||||
| |||||
| |||||
| |||||
| articleean | |||
| |||
| |||
| |||
| |||||||||||||||||||||
| |||||||||||||||||||||
| |||||||||||||||||||||
| |||||||||||||||||||||
| |||||||||||||||||||||
| |||||||||||||||||||||
| |||||||||||||||||||||
| |||||||||||||||||||||
| |||||||||||||||||||||
| |||||||||||||||||||||
| |||||||||||||||||||||
| |||||||||||||||||||||
| |||||||||||||||||||||
| |||||||||||||||||||||
| articlelistarticle | |||
| |||
| |||
| |||
| |||
| |||
| |||||
| |||||
| articlehistory | |||
| |||
| |||
| |||
| |||
| |||
| |||||||||||||||||||||
| |||||||||||||||||||||
| |||||||||||||||||||||
| |||||||||||||||||||||
| |||||||||||||||||||||
| |||||||||||||||||||||
| |||||||||||||||||||||
| |||||||||||||||||||||
| |||||||||||||||||||||
| |||||||||||||||||||||
| |||||||||||||||||||||
| |||||||||||||||||||||
| |||||||||||||||||||||
| |||||||||||||||||||||
| articlehistory | |||
| |||
| |||
| |||
| |||
| |||
| |||||
| |||||
| articleean | |||
| |||
| |||
| |||
| |||||
| |||||
| |||||
| |||||
| |||||
| optionslistarticle | |||
| |||
| |||
| |||
| |||
| |||
| |||
| categorypic | |||
| |||
| |||
| |||
| |||
| categorypic | |||
| |||
| |||
| |||
| |||
| articlepic | |||
| |||
| |||
| |||
| |||
| |||||||
| |||||||
| |||||||
| |||||||
| |||||||
| |||||||
| |||||||
| |||||||
| |||||||
| |||||||
| |||||||
| |||||||
| articlepic | |||
| |||
| |||
| |||
| |||
| brandpic | |||
| |||
| |||
| |||
| |||
| brandpic | |||
| |||
| |||
| |||
| |||
| price | |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||
| manifestarticle | |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||||||||||
| |||||||||||
| |||||||||||
| price | |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||
| manifestarticle | |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||
| |||
| Legend | |
| PK | primary key |
| FK | foreign key |
| ? | nullable column |
| — | FOREIGN KEY constraint |
| - - | naming convention only, no constraint |