u
This commit is contained in:
23
src/queries/max-order-id.js
Normal file
23
src/queries/max-order-id.js
Normal file
@@ -0,0 +1,23 @@
|
||||
import sql from 'mssql';
|
||||
import { getPool } from '../db.js';
|
||||
import { getActiveShopSubshopId } from '../shop.js';
|
||||
|
||||
const MAX_ORDER_ID_SQL = `
|
||||
SELECT ISNULL(MAX(kPosAuftrag), 0) AS MaxOrderId
|
||||
FROM Pos.tAuftragMapping
|
||||
WHERE kShopSubShop = @kShopSubShop;
|
||||
`;
|
||||
|
||||
export async function getMaxOrderIdCount() {
|
||||
const kShopSubShop = getActiveShopSubshopId();
|
||||
if (!kShopSubShop) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
const result = await getPool()
|
||||
.request()
|
||||
.input('kShopSubShop', sql.Int, kShopSubShop)
|
||||
.query(MAX_ORDER_ID_SQL);
|
||||
|
||||
return result.recordset[0]?.MaxOrderId ?? 0;
|
||||
}
|
||||
Reference in New Issue
Block a user