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

@@ -12,6 +12,7 @@ function requireSelectedCompany(req) {
}
function customergroupErrorStatus(error) {
if (error.message === 'No company selected') return 400;
if (error.message === 'Not authorized') return 403;
if (error.message === 'Company not found') return 404;
if (error.message === 'Customer group not found') return 404;
@@ -149,7 +150,7 @@ export function register(app, basePath = '') {
}
try {
const rows = await db.list(req.user.id, selected.companyId);
const rows = await db.list(req.user.id);
res.status(200).json({ customergroups: rows.map(withEditable) });
} catch (error) {
const status = customergroupErrorStatus(error);
@@ -167,7 +168,7 @@ export function register(app, basePath = '') {
const { name } = req.body ?? {};
try {
const customergroup = await db.create(req.user.id, selected.companyId, { name });
const customergroup = await db.create(req.user.id, { name });
res.status(201).json({ customergroup });
} catch (error) {
const status = customergroupErrorStatus(error);
@@ -260,7 +261,7 @@ export function register(app, basePath = '') {
}
try {
const result = await db.order(req.user.id, selected.companyId, { customergroupIds });
const result = await db.order(req.user.id, { customergroupIds });
res.status(200).json(result);
} catch (error) {
const status = customergroupErrorStatus(error);
@@ -396,7 +397,7 @@ export function register(app, basePath = '') {
const { name } = req.body ?? {};
try {
const customergroup = await db.update(req.user.id, selected.companyId, id, { name });
const customergroup = await db.update(req.user.id, id, { name });
res.status(200).json({ customergroup });
} catch (error) {
const status = customergroupErrorStatus(error);
@@ -417,7 +418,7 @@ export function register(app, basePath = '') {
}
try {
await db.remove(req.user.id, selected.companyId, id);
await db.remove(req.user.id, id);
res.sendStatus(204);
} catch (error) {
const status = customergroupErrorStatus(error);