Erlaube mehrere offene Lagerchargen
This commit is contained in:
1 parent
e656841de2
commit
ca5cf5a03f
4 files changed
+23
-12
No files matched your search
@@ -35,13 +35,15 @@ function lager_forecast_load_current_lots(PDO $pdo): array
|
||||
{
|
||||
$stmt = $pdo->query(
|
||||
"SELECT p.id AS product_id, p.sku, sl.id AS lot_id,
|
||||
COALESCE(v.qty_net, 0) + GREATEST(COALESCE(open_v.qty_net, 0), 0) AS physical_qty
|
||||
COALESCE(v.qty_net, 0) + COALESCE((
|
||||
SELECT SUM(GREATEST(COALESCE(open_v.qty_net, 0), 0))
|
||||
FROM stock_lot open_lot
|
||||
LEFT JOIN v_stock_lot_balance open_v ON open_v.stock_lot_id = open_lot.id
|
||||
WHERE open_lot.product_id = p.id AND open_lot.status = 'open'
|
||||
), 0) AS physical_qty
|
||||
FROM product p
|
||||
LEFT JOIN stock_lot sl ON sl.product_id = p.id AND sl.status = 'current'
|
||||
LEFT JOIN v_stock_lot_balance v ON v.stock_lot_id = sl.id
|
||||
LEFT JOIN stock_lot open_lot
|
||||
ON open_lot.product_id = p.id AND open_lot.status = 'open'
|
||||
LEFT JOIN v_stock_lot_balance open_v ON open_v.stock_lot_id = open_lot.id
|
||||
WHERE p.status = 'active'
|
||||
ORDER BY p.id"
|
||||
);
|
||||
@@ -52,13 +54,15 @@ function lager_forecast_load_current_lot(PDO $pdo, int $productId): ?array
|
||||
{
|
||||
$stmt = $pdo->prepare(
|
||||
"SELECT p.id AS product_id, p.sku, sl.id AS lot_id,
|
||||
COALESCE(v.qty_net, 0) + GREATEST(COALESCE(open_v.qty_net, 0), 0) AS physical_qty
|
||||
COALESCE(v.qty_net, 0) + COALESCE((
|
||||
SELECT SUM(GREATEST(COALESCE(open_v.qty_net, 0), 0))
|
||||
FROM stock_lot open_lot
|
||||
LEFT JOIN v_stock_lot_balance open_v ON open_v.stock_lot_id = open_lot.id
|
||||
WHERE open_lot.product_id = p.id AND open_lot.status = 'open'
|
||||
), 0) AS physical_qty
|
||||
FROM product p
|
||||
LEFT JOIN stock_lot sl ON sl.product_id = p.id AND sl.status = 'current'
|
||||
LEFT JOIN v_stock_lot_balance v ON v.stock_lot_id = sl.id
|
||||
LEFT JOIN stock_lot open_lot
|
||||
ON open_lot.product_id = p.id AND open_lot.status = 'open'
|
||||
LEFT JOIN v_stock_lot_balance open_v ON open_v.stock_lot_id = open_lot.id
|
||||
WHERE p.status = 'active' AND p.id = :product_id
|
||||
LIMIT 1"
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user