Add entity address/contact tables and CRUD for entity resources

This commit is contained in:
seb
2026-08-06 05:43:50 +02:00
parent 0b7e40ac9c
commit 3b77a1c946
32 changed files with 3078 additions and 1363 deletions

View File

@@ -0,0 +1,22 @@
import { GET_BY_COMPANY_AND_ID } from '../../sql/customergroup.js';
import request from '../request.js';
/** Ensure customergroup belongs to company. Throws Customer group not found. */
export default function resolveCustomerGroupAccess(pool) {
return async (companyId, customergroupId, tx) => {
if (!Number.isFinite(customergroupId)) {
throw new Error('Customer group not found');
}
const result = await request(pool, tx)
.input('id', customergroupId)
.input('companyId', companyId)
.query(GET_BY_COMPANY_AND_ID);
const row = result.recordset[0];
if (!row) {
throw new Error('Customer group not found');
}
return row;
};
}