This commit is contained in:
seb
2026-09-30 21:56:37 +02:00
parent bc467e29da
commit 3d2f8e9296
4 changed files with 7 additions and 13 deletions

View File

@@ -30,14 +30,14 @@ WHERE cg.company_id = @companyId
ORDER BY e.name, e.id
`;
/** Entities whose group is not Lieferanten and not POS (customer picker). */
/** Entities whose group is not Lieferanten (customer picker). */
export const LIST_CUSTOMERS_BY_COMPANY = `
SELECT
${ENTITY_COLUMNS}
FROM entity e
INNER JOIN customergroup cg ON cg.id = e.customergroup_id
WHERE cg.company_id = @companyId
AND cg.name NOT IN (@supplierGroupName, @posGroupName)
AND cg.name <> @supplierGroupName
ORDER BY e.name, e.id
`;
@@ -60,7 +60,7 @@ WHERE cg.company_id = @companyId
AND (@excludeEntityId IS NULL OR e.id <> @excludeEntityId)
`;
/** Customer entity: company-scoped and not Lieferanten/POS. */
/** Customer entity: company-scoped and not Lieferanten. */
export const GET_CUSTOMER_BY_ID = `
SELECT
${ENTITY_COLUMNS}
@@ -68,7 +68,7 @@ FROM entity e
INNER JOIN customergroup cg ON cg.id = e.customergroup_id
WHERE e.id = @id
AND cg.company_id = @companyId
AND cg.name NOT IN (@supplierGroupName, @posGroupName)
AND cg.name <> @supplierGroupName
`;
export const LIST_SUPPLIERS_BY_COMPANY = `

View File

@@ -2,7 +2,6 @@ import {
LIST_BY_COMPANY as MSSQL_LIST_BY_COMPANY,
LIST_BY_COMPANY_AND_GROUP as MSSQL_LIST_BY_COMPANY_AND_GROUP,
LIST_CUSTOMERS_BY_COMPANY as MSSQL_LIST_CUSTOMERS_BY_COMPANY,
POS_GROUP_NAME,
SUPPLIER_GROUP_NAME,
} from '../../providers/mssql/queries/entity.js';
import {
@@ -58,7 +57,6 @@ export default function list(provider) {
const result = await runner.query(listCustomersSql, {
companyId,
supplierGroupName: SUPPLIER_GROUP_NAME,
posGroupName: POS_GROUP_NAME,
});
return result.rows.map(shape);
}

View File

@@ -8,12 +8,10 @@ import {
} from '../../providers/sqlite3/queries/manifestDoc.js';
import {
GET_CUSTOMER_BY_ID as MSSQL_GET_CUSTOMER_BY_ID,
POS_GROUP_NAME as MSSQL_POS_GROUP_NAME,
SUPPLIER_GROUP_NAME as MSSQL_SUPPLIER_GROUP_NAME,
} from '../../providers/mssql/queries/entity.js';
import {
GET_CUSTOMER_BY_ID as SQLITE_GET_CUSTOMER_BY_ID,
POS_GROUP_NAME as SQLITE_POS_GROUP_NAME,
SUPPLIER_GROUP_NAME as SQLITE_SUPPLIER_GROUP_NAME,
} from '../../providers/sqlite3/queries/entity.js';
import makeRunner from '../runner.js';
@@ -56,13 +54,11 @@ export async function assertCustomerEntity(runnerOrPool, txOrCompanyId, maybeCom
const isSqlite = runner?.dialect === 'sqlite3';
const getCustomerSql = isSqlite ? SQLITE_GET_CUSTOMER_BY_ID : MSSQL_GET_CUSTOMER_BY_ID;
const supplierGroupName = isSqlite ? SQLITE_SUPPLIER_GROUP_NAME : MSSQL_SUPPLIER_GROUP_NAME;
const posGroupName = isSqlite ? SQLITE_POS_GROUP_NAME : MSSQL_POS_GROUP_NAME;
const result = await runner.query(getCustomerSql, {
id: entityId,
companyId,
supplierGroupName,
posGroupName,
});
if (!result.rows[0]) {