mirror of
https://github.com/grocy/grocy.git
synced 2025-08-19 20:11:16 +00:00
First draft for printable location content sheets (references #341)
This commit is contained in:
12
migrations/0079.sql
Normal file
12
migrations/0079.sql
Normal file
@@ -0,0 +1,12 @@
|
||||
CREATE VIEW stock_current_location_content
|
||||
AS
|
||||
SELECT
|
||||
IFNULL(s.location_id, p.location_id) AS location_id,
|
||||
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 location_id = s.location_id AND open = 1), 0) AS amount_opened
|
||||
FROM stock s
|
||||
JOIN products p
|
||||
ON s.product_id = p.id
|
||||
GROUP BY IFNULL(s.location_id, p.location_id), s.product_id;
|
Reference in New Issue
Block a user