Add supplier CRUD on entity with Lieferanten group and entityhistory

This commit is contained in:
seb
2026-08-06 03:56:32 +02:00
parent 561ba5bb99
commit 4f46967f28
17 changed files with 1853 additions and 1338 deletions

View File

@@ -0,0 +1,26 @@
import {
CREATE,
GET_BY_COMPANY_AND_NAME,
} from '../../sql/customergroup.js';
import { SUPPLIER_GROUP_NAME } from '../../sql/entity.js';
/** Ensure company has customergroup "Lieferanten"; return its id. */
export default async function ensureLieferantenGroup(pool, companyId, tx) {
const req = () => (tx ?? pool).request();
const existing = await req()
.input('companyId', companyId)
.input('name', SUPPLIER_GROUP_NAME)
.query(GET_BY_COMPANY_AND_NAME);
if (existing.recordset[0]) {
return existing.recordset[0].id;
}
const created = await req()
.input('companyId', companyId)
.input('name', SUPPLIER_GROUP_NAME)
.query(CREATE);
return created.recordset[0].id;
}