Added amount value for locations api (#668)

This commit is contained in:
Marc Ole Bulling
2020-03-27 14:29:26 +01:00
committed by GitHub
parent d7738aa1ec
commit 9a27b8e3a5
2 changed files with 19 additions and 0 deletions

View File

@@ -10,3 +10,18 @@ ADD shopping_location_id INTEGER;
ALTER TABLE stock
ADD shopping_location_id INTEGER;
DROP VIEW stock_current_locations;
CREATE VIEW stock_current_locations
AS
SELECT
1 AS id, -- Dummy, LessQL needs an id column
s.product_id,
SUM(s.amount) as amount,
s.location_id AS location_id,
l.name AS location_name,
l.is_freezer AS location_is_freezer
FROM stock s
JOIN locations l
ON s.location_id = l.id
GROUP BY s.product_id, s.location_id, l.name;