Add quote and order stores plus ledger hash_version.

Mirror delivery on manifest for quote/order with customer entityId (excluding Lieferanten/POS), and support entity.list role=customer for pickers.
This commit is contained in:
seb
2026-08-06 19:58:35 +02:00
parent ae549fd022
commit b095ab6199
12 changed files with 987 additions and 45 deletions

View File

@@ -1,6 +1,9 @@
import {
LIST_BY_COMPANY,
LIST_BY_COMPANY_AND_GROUP,
LIST_CUSTOMERS_BY_COMPANY,
POS_GROUP_NAME,
SUPPLIER_GROUP_NAME,
} from '../../sql/entity.js';
import resolveCompanyAccess from '../companyuser/resolveCompanyAccess.js';
import resolveCustomerGroupAccess from '../customergroup/resolveCustomerGroupAccess.js';
@@ -20,9 +23,27 @@ export default function list(pool) {
const access = resolveCompanyAccess(pool);
const groupAccess = resolveCustomerGroupAccess(pool);
return async (googleAuthId, companyId, { customergroupId } = {}) => {
return async (
googleAuthId,
companyId,
{ customergroupId, role } = {},
) => {
await access(googleAuthId, companyId);
if (role != null && role !== 'customer') {
throw new Error('Invalid role');
}
if (role === 'customer') {
const result = await pool
.request()
.input('companyId', companyId)
.input('supplierGroupName', SUPPLIER_GROUP_NAME)
.input('posGroupName', POS_GROUP_NAME)
.query(LIST_CUSTOMERS_BY_COMPANY);
return result.recordset.map(shape);
}
if (customergroupId != null) {
await groupAccess(companyId, customergroupId);
const result = await pool