Add customergroup bulk reorder and list editable flag.

Expose PUT /customergroup/order for exact-set sort updates, keep create/update name-only, and mark POS/Lieferanten as non-editable in list responses.
This commit is contained in:
seb
2026-08-07 03:40:40 +02:00
parent cdae7b6eab
commit 57fd3b4837
9 changed files with 344 additions and 23 deletions

View File

@@ -4193,7 +4193,7 @@
"Customergroup"
],
"summary": "List customer groups",
"description": "Lists customer groups for the authenticated user's selected company.",
"description": "Lists customer groups for the selected company, ordered by `sort`.\nEach item includes `editable`: `false` for implicit `POS` / `Lieferanten`\n(name locked), `true` otherwise. Reorder via `PUT /customergroup/order`.\n",
"security": [
{
"cookieAuth": []
@@ -4211,7 +4211,7 @@
"customergroups": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Customergroup"
"$ref": "#/components/schemas/CustomergroupListItem"
}
}
}
@@ -4266,7 +4266,7 @@
"Customergroup"
],
"summary": "Create customer group",
"description": "Creates a customer group for the selected company.",
"description": "Creates a customer group for the selected company.\nAppends with the next `sort` index. Reserved names `POS` and `Lieferanten`\nare not allowed (`Name not allowed`).\n",
"security": [
{
"cookieAuth": []
@@ -4311,7 +4311,111 @@
}
},
"400": {
"description": "Name required or no company selected",
"description": "Name required, name not allowed, or no company selected",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"401": {
"description": "Unauthorized",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"403": {
"description": "Not authorized",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"404": {
"description": "Company not found",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
}
}
},
"/customergroup/order": {
"put": {
"tags": [
"Customergroup"
],
"summary": "Reorder customer groups",
"description": "Sets `sort` to each id’s index `0…n-1` in one transaction.\n`customergroupIds` must be exactly the company’s groups (same set, no dups)\nelse `Invalid customer group order`.\n",
"security": [
{
"cookieAuth": []
}
],
"x-markdown": "customergroup/order.md",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"customergroupIds"
],
"properties": {
"customergroupIds": {
"type": "array",
"items": {
"type": "integer"
}
}
},
"example": {
"customergroupIds": [
4,
3,
1,
2
]
}
}
}
}
},
"responses": {
"200": {
"description": "New order",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"customergroupIds": {
"type": "array",
"items": {
"type": "integer"
}
}
}
}
}
}
},
"400": {
"description": "Invalid customer group order or no company selected",
"content": {
"application/json": {
"schema": {
@@ -4359,7 +4463,7 @@
"Customergroup"
],
"summary": "Update customer group",
"description": "Renames a customer group for the selected company.",
"description": "Renames a customer group. Implicit `POS` / `Lieferanten` cannot be\nrenamed (`Name cannot be changed`). Reorder via `PUT /customergroup/order`.\n",
"security": [
{
"cookieAuth": []
@@ -4414,7 +4518,7 @@
}
},
"400": {
"description": "Name required, invalid id, or no company selected",
"description": "Name required, name cannot be changed, invalid id, or no company selected",
"content": {
"application/json": {
"schema": {
@@ -7925,7 +8029,8 @@
"type": "object",
"required": [
"id",
"name"
"name",
"sort"
],
"properties": {
"id": {
@@ -7933,9 +8038,31 @@
},
"name": {
"type": "string"
},
"sort": {
"type": "integer"
}
}
},
"CustomergroupListItem": {
"allOf": [
{
"$ref": "#/components/schemas/Customergroup"
},
{
"type": "object",
"required": [
"editable"
],
"properties": {
"editable": {
"type": "boolean",
"description": "`false` for implicit groups `POS` and `Lieferanten` (name locked).\n`true` for user-created groups. Reorder all groups via\n`PUT /customergroup/order`.\n"
}
}
}
]
},
"Entity": {
"type": "object",
"required": [