This commit is contained in:
seb
2026-10-29 03:28:02 +01:00
parent 907ee998c0
commit bcdfba1742
14 changed files with 184 additions and 60 deletions

View File

@@ -132,6 +132,12 @@ export function register(app, basePath = '') {
* syncRootArticles:
* type: boolean
* default: true
* sort:
* type: integer
* default: 0
* enabled:
* type: boolean
* default: true
* example:
* name: "Kassa 1"
* responses:
@@ -190,6 +196,11 @@ export function register(app, basePath = '') {
const syncRootArticles = req.body.syncRootArticles !== undefined
? req.body.syncRootArticles
: req.body.sync_root_articles;
const sort = req.body.sort !== undefined ? Number(req.body.sort) : undefined;
if (sort !== undefined && !Number.isInteger(sort)) {
return res.status(400).json({ error: 'sort must be an integer' });
}
const enabled = req.body.enabled !== undefined ? Boolean(req.body.enabled) : undefined;
try {
const posterminal = await db.upsert(req.user.id, {
@@ -197,6 +208,8 @@ export function register(app, basePath = '') {
pairingpin,
rootCategoryId,
syncRootArticles,
sort,
enabled,
});
res.status(200).json({ posterminal });
} catch (error) {
@@ -239,6 +252,13 @@ export function register(app, basePath = '') {
* nullable: true
* syncRootArticles:
* type: boolean
* sort:
* type: integer
* enabled:
* type: boolean
* clientversion:
* type: string
* nullable: true
* pairingpin:
* type: string
* nullable: true
@@ -312,6 +332,22 @@ export function register(app, basePath = '') {
payload.syncRootArticles = Boolean(rawSync);
}
if (req.body.sort !== undefined) {
const rawSort = Number(req.body.sort);
if (!Number.isInteger(rawSort)) {
return res.status(400).json({ error: 'sort must be an integer' });
}
payload.sort = rawSort;
}
if (req.body.enabled !== undefined) {
payload.enabled = Boolean(req.body.enabled);
}
if (req.body.clientversion !== undefined) {
payload.clientversion = req.body.clientversion ? String(req.body.clientversion).trim() : null;
}
if (req.body.pairingpin !== undefined) {
payload.pairingpin = req.body.pairingpin ? String(req.body.pairingpin).trim() : null;
}