mirror of
https://github.com/grocy/grocy.git
synced 2026-04-11 15:06:15 +02:00
Make sure that the view products_last_purchased always returns a row per product, also for not in stock items (references #801)
Otherwise there are errors when getting product details for currently not in stock items...
This commit is contained in:
parent
939b98e470
commit
0a3e85dab4
|
|
@ -3,9 +3,9 @@ DROP VIEW products_current_price;
|
|||
|
||||
CREATE VIEW products_last_purchased
|
||||
AS
|
||||
select
|
||||
SELECT
|
||||
1 AS id, -- Dummy, LessQL needs an id column
|
||||
sl.product_id,
|
||||
p.id AS product_id,
|
||||
sl.amount,
|
||||
sl.best_before_date,
|
||||
sl.purchased_date,
|
||||
|
|
@ -13,8 +13,10 @@ select
|
|||
sl.qu_factor_purchase_to_stock,
|
||||
sl.location_id,
|
||||
sl.shopping_location_id
|
||||
FROM stock_log sl
|
||||
JOIN (
|
||||
FROM products p
|
||||
LEFT JOIN stock_log sl
|
||||
ON p.id = sl.product_id
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
s1.product_id,
|
||||
MAX(s1.id) max_stock_id
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user