Align store calls with selected-company scoping and add entity numbers.

Drop companyId from company-scoped store wrappers and routes, add GET /entity/next-number plus optional number on entity create/update, and document dashdbschema API.md lookup in sibling-repos.
This commit is contained in:
seb
2026-08-07 06:22:13 +02:00
parent 2767568f5a
commit e6c24654dd
36 changed files with 496 additions and 189 deletions

View File

@@ -5,6 +5,7 @@ Protected. Requires a valid session cookie (`credentials: 'include'`).
Create entity
Creates an entity in a company customer group and writes `entityhistory` (`Erstellt`).
Optional `number`: omit to allocate the next customer number (`type` entity).
## Body (JSON)
@@ -13,7 +14,8 @@ Creates an entity in a company customer group and writes `entityhistory` (`Erste
{
"customergroupId": 1,
"name": "Müller",
"firstName": "Anna"
"firstName": "Anna",
"number": "10042"
}
```
@@ -28,6 +30,7 @@ Created entity
"customergroupId": 1,
"firstName": "…",
"name": "…",
"number": "…",
"createdAt": "2026-08-10T00:00:00.000Z",
"updatedAt": "2026-08-10T00:00:00.000Z"
}
@@ -38,10 +41,11 @@ Created entity
| Status | Description |
|--------|-------------|
| 400 | Name required or no company selected — `{"error":"…"}` |
| 400 | Name/number required or no company selected — `{"error":"…"}` |
| 401 | Unauthorized — `{"error":"…"}` |
| 403 | Not authorized — `{"error":"…"}` |
| 404 | Company or customer group not found — `{"error":"…"}` |
| 409 | Number already in use — `{"error":"…"}` |
---

View File

@@ -23,6 +23,7 @@ Entity
"customergroupId": 1,
"firstName": "…",
"name": "…",
"number": "…",
"createdAt": "2026-08-10T00:00:00.000Z",
"updatedAt": "2026-08-10T00:00:00.000Z"
}

View File

@@ -5,7 +5,8 @@ Protected. Requires a valid session cookie (`credentials: 'include'`).
List entities
Lists entities for the selected company. Optional `customergroupId`
query filters to one group (must belong to the company).
filters to one group. Optional `role=customer` excludes Lieferanten/POS
groups (for quote/order pickers). `role` wins when both are set.
## Query parameters
@@ -13,6 +14,7 @@ query filters to one group (must belong to the company).
| Param | Required | Type | Description |
|-------|----------|------|-------------|
| `customergroupId` | no | integer | |
| `role` | no | string | |
## Response `200`
@@ -26,6 +28,7 @@ Entity list
"customergroupId": 1,
"firstName": "…",
"name": "…",
"number": "…",
"createdAt": "2026-08-10T00:00:00.000Z",
"updatedAt": "2026-08-10T00:00:00.000Z"
}
@@ -37,7 +40,7 @@ Entity list
| Status | Description |
|--------|-------------|
| 400 | No company selected or invalid customergroupId — `{"error":"…"}` |
| 400 | No company selected, invalid customergroupId, or invalid role — `{"error":"…"}` |
| 401 | Unauthorized — `{"error":"…"}` |
| 403 | Not authorized — `{"error":"…"}` |
| 404 | Company or customer group not found — `{"error":"…"}` |

View File

@@ -0,0 +1,32 @@
# `GET /entity/next-number`
Protected. Requires a valid session cookie (`credentials: 'include'`).
Peek next customer number
Returns the next customer number that would be allocated (`type` entity)
without consuming it. Use on the customer add form.
## Response `200`
Next number
```json
{
"number": "…"
}
```
## Errors
| Status | Description |
|--------|-------------|
| 400 | No company selected — `{"error":"…"}` |
| 401 | Unauthorized — `{"error":"…"}` |
| 403 | Not authorized — `{"error":"…"}` |
| 404 | Company not found — `{"error":"…"}` |
---
_Generated from `@openapi` JSDoc. Do not edit by hand — run `npm run docs:api`._

View File

@@ -4,7 +4,9 @@ Protected. Requires a valid session cookie (`credentials: 'include'`).
Update entity
Patches `name` and/or `firstName`. Writes `entityhistory` when values change.
Patches fields that are present (`name`, `firstName`, `number`).
`number` is only changed when the key is present (no auto-allocate).
Writes `entityhistory` when values change.
## Path parameters
@@ -18,7 +20,8 @@ Patches `name` and/or `firstName`. Writes `entityhistory` when values change.
```json
{
"name": "Müller",
"firstName": "Anna"
"firstName": "Anna",
"number": "10042"
}
```
@@ -33,6 +36,7 @@ Updated entity
"customergroupId": 1,
"firstName": "…",
"name": "…",
"number": "…",
"createdAt": "2026-08-10T00:00:00.000Z",
"updatedAt": "2026-08-10T00:00:00.000Z"
}
@@ -43,10 +47,11 @@ Updated entity
| Status | Description |
|--------|-------------|
| 400 | Name required, invalid id, or no company selected — `{"error":"…"}` |
| 400 | Name/number required, invalid id, or no company selected — `{"error":"…"}` |
| 401 | Unauthorized — `{"error":"…"}` |
| 403 | Not authorized — `{"error":"…"}` |
| 404 | Entity or company not found — `{"error":"…"}` |
| 409 | Number already in use — `{"error":"…"}` |
---