Prevent opening more products than are unopened in stock

This commit is contained in:
Bernd Bestel
2018-11-18 13:35:21 +01:00
parent a489190e81
commit 2ff5faacc0
5 changed files with 31 additions and 6 deletions

View File

@@ -25,4 +25,14 @@ SELECT
MIN(s.best_before_date) AS best_before_date,
IFNULL((SELECT SUM(amount) FROM stock WHERE product_id = s.product_id AND open = 1), 0) AS amount_opened
FROM stock s
GROUP BY s.product_id;
GROUP BY s.product_id
UNION
SELECT
id,
0,
null,
0
FROM stock_missing_products
WHERE is_partly_in_stock = 0;