From 187d48f93d4704164f172c20b613abeea91d213f Mon Sep 17 00:00:00 2001 From: Bernd Bestel Date: Fri, 2 Jul 2021 17:04:40 +0200 Subject: [PATCH] Use stock_log location instead of product location for stock journal (fixes #1381) --- changelog/62_UNRELEASED_xxxx-xx-xx.md | 1 + migrations/0132.sql | 28 +++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 migrations/0132.sql diff --git a/changelog/62_UNRELEASED_xxxx-xx-xx.md b/changelog/62_UNRELEASED_xxxx-xx-xx.md index be79228b..662ecf9d 100644 --- a/changelog/62_UNRELEASED_xxxx-xx-xx.md +++ b/changelog/62_UNRELEASED_xxxx-xx-xx.md @@ -33,6 +33,7 @@ - Fixed that adding a barcode to a product didn't save the selected quantity unit when the product only has a single one - Fixed that the store information on a stock entry was lost when transferring a partial amount to a different location - Fixed that the "Spoil rate" on the product card was wrong in some cases +- Fixed that the stock journal showed always the products default location (instead of the location of the transaction) ### Shopping list improvements/fixes - The amount now defaults to `1` for adding items quicker diff --git a/migrations/0132.sql b/migrations/0132.sql new file mode 100644 index 00000000..e242e25b --- /dev/null +++ b/migrations/0132.sql @@ -0,0 +1,28 @@ +DROP VIEW uihelper_stock_journal; +CREATE VIEW uihelper_stock_journal +AS +SELECT + sl.id, + sl.row_created_timestamp, + sl.correlation_id, + sl.undone, + sl.undone_timestamp, + sl.row_created_timestamp, + sl.transaction_type, + sl.spoiled, + sl.amount, + sl.location_id, + l.name AS location_name, + p.name AS product_name, + qu.name AS qu_name, + qu.name_plural AS qu_name_plural, + u.display_name AS user_display_name +FROM stock_log sl +JOIN users_dto u + ON sl.user_id = u.id +JOIN products p + ON sl.product_id = p.id +JOIN locations l + ON sl.location_id = l.id +JOIN quantity_units qu + ON p.qu_id_stock = qu.id;