Show amount of opened products on stock overview page and in product card

This commit is contained in:
Bernd Bestel
2018-11-18 13:17:36 +01:00
parent 5966a3d678
commit a403bb687a
7 changed files with 34 additions and 1 deletions

View File

@@ -15,3 +15,14 @@ ADD default_best_before_days_after_open INTEGER NOT NULL DEFAULT 0;
UPDATE products
SET default_best_before_days_after_open = 0;
DROP VIEW stock_current;
CREATE VIEW stock_current
AS
SELECT
s.product_id,
SUM(s.amount) AS amount,
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;