Add customergroup sort with bulk order and locked implicit names.
Reorder via customergroup.order (exact id list → sort 0…n-1); block renaming POS/Lieferanten while still allowing create/update of other groups by name.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import {
|
||||
CREATE,
|
||||
GET_BY_COMPANY_AND_NAME,
|
||||
GET_NEXT_SORT,
|
||||
} from '../../sql/customergroup.js';
|
||||
import { SUPPLIER_GROUP_NAME } from '../../sql/entity.js';
|
||||
|
||||
@@ -17,9 +18,15 @@ export default async function ensureLieferantenGroup(pool, companyId, tx) {
|
||||
return existing.recordset[0].id;
|
||||
}
|
||||
|
||||
const next = await req()
|
||||
.input('companyId', companyId)
|
||||
.query(GET_NEXT_SORT);
|
||||
const sort = next.recordset[0].sort;
|
||||
|
||||
const created = await req()
|
||||
.input('companyId', companyId)
|
||||
.input('name', SUPPLIER_GROUP_NAME)
|
||||
.input('sort', sort)
|
||||
.query(CREATE);
|
||||
|
||||
return created.recordset[0].id;
|
||||
|
||||
Reference in New Issue
Block a user