Removed unnecessary calculation step in view uihelper_shopping_list (closes #2298)

This commit is contained in:
Bernd Bestel 2023-08-07 21:57:12 +02:00
parent e2ebc037f2
commit 4691b45510
No known key found for this signature in database
GPG Key ID: 71BD34C0D4891300

31
migrations/0228.sql Normal file
View File

@ -0,0 +1,31 @@
DROP VIEW uihelper_shopping_list;
CREATE VIEW uihelper_shopping_list
AS
SELECT
sl.*,
p.name AS product_name,
plp.price * IFNULL(quc.factor, 1.0) AS last_price_unit,
plp.price * sl.amount AS last_price_total,
st.name AS default_shopping_location_name,
qu.name AS qu_name,
qu.name_plural AS qu_name_plural,
pg.id AS product_group_id,
pg.name AS product_group_name,
pbcs.barcodes AS product_barcodes
FROM shopping_list sl
LEFT JOIN products p
ON sl.product_id = p.id
LEFT JOIN cache__products_last_purchased plp
ON sl.product_id = plp.product_id
LEFT JOIN shopping_locations st
ON p.shopping_location_id = st.id
LEFT JOIN quantity_units qu
ON sl.qu_id = qu.id
LEFT JOIN product_groups pg
ON p.product_group_id = pg.id
LEFT JOIN cache__quantity_unit_conversions_resolved quc
ON p.id = quc.product_id
AND p.qu_id_stock = quc.to_qu_id
AND sl.qu_id = quc.from_qu_id
LEFT JOIN product_barcodes_comma_separated pbcs
ON sl.product_id = pbcs.product_id;