diff --git a/changelog/60_3.0.0_2020-12-22.md b/changelog/60_3.0.0_2020-12-22.md index a262ac57..3d869f89 100644 --- a/changelog/60_3.0.0_2020-12-22.md +++ b/changelog/60_3.0.0_2020-12-22.md @@ -144,6 +144,7 @@ - There are also new columns on some pages, hidden by default - Stock overview: Value, product group, calories, last purchased, last price, min. stock amount - Products list: Default store + - Shopping list: Last price (Unit), Last price (Total) - Row grouping can be customized to use any available column (thanks @edenhaus) - Table states (visible columns, sorting, column order and so on) are now saved server side (in user settings) means that this stays the same when using different browsers - Dialogs are now used everywhere where appropriate instead of jumping between pages (for example when adding/editing shopping list items) diff --git a/controllers/StockController.php b/controllers/StockController.php index 7879a891..21cb16a1 100644 --- a/controllers/StockController.php +++ b/controllers/StockController.php @@ -334,7 +334,7 @@ class StockController extends BaseController } return $this->renderPage($response, 'shoppinglist', [ - 'listItems' => $this->getDatabase()->shopping_list()->where('shopping_list_id = :1', $listId), + 'listItems' => $this->getDatabase()->uihelper_shopping_list()->where('shopping_list_id = :1', $listId), 'products' => $this->getDatabase()->products()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'), 'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name', 'COLLATE NOCASE'), 'missingProducts' => $this->getStockService()->GetMissingProducts(), diff --git a/localization/strings.pot b/localization/strings.pot index 192e3298..63a04920 100644 --- a/localization/strings.pot +++ b/localization/strings.pot @@ -2029,3 +2029,9 @@ msgstr "" msgid "A different amount/unit can then be used below while for stock fulfillment checking it is sufficient when any amount of the product in stock" msgstr "" + +msgid "Last price (Unit)" +msgstr "" + +msgid "Last price (Total)" +msgstr "" diff --git a/migrations/0123.sql b/migrations/0123.sql index b500d031..57269277 100644 --- a/migrations/0123.sql +++ b/migrations/0123.sql @@ -1,2 +1,19 @@ ALTER TABLE product_barcodes ADD note TEXT; + +CREATE VIEW uihelper_shopping_list +AS +SELECT + sl.*, + p.name AS product_name, + plp.price * IFNULL(qucr.factor, 1.0) AS last_price_unit, + plp.price * IFNULL(qucr.factor, 1.0) * sl.amount AS last_price_total +FROM shopping_list sl +LEFT JOIN products p + ON sl.product_id = p.id +LEFT JOIN quantity_unit_conversions_resolved qucr + ON sl.product_id = qucr.product_id + AND p.qu_id_stock = qucr.from_qu_id + AND sl.qu_id = qucr.to_qu_id +LEFT JOIN products_last_purchased plp + ON sl.product_id = plp.product_id; diff --git a/public/viewjs/shoppinglist.js b/public/viewjs/shoppinglist.js index 0e2d65ba..85552474 100644 --- a/public/viewjs/shoppinglist.js +++ b/public/viewjs/shoppinglist.js @@ -5,7 +5,11 @@ { 'orderable': false, 'targets': 0 }, { 'searchable': false, "targets": 0 }, { 'visible': false, 'targets': 3 }, - { "type": "num", "targets": 2 } + { 'visible': false, 'targets': 5 }, + { 'visible': false, 'targets': 6 }, + { "type": "num", "targets": 2 }, + { "type": "html-num-fmt", "targets": 5 }, + { "type": "html-num-fmt", "targets": 6 } ].concat($.fn.dataTable.defaults.columnDefs), 'rowGroup': { enable: true, diff --git a/views/shoppinglist.blade.php b/views/shoppinglist.blade.php index 2bc10643..8df486f1 100644 --- a/views/shoppinglist.blade.php +++ b/views/shoppinglist.blade.php @@ -175,6 +175,8 @@ {{ $__t('Amount') }} {{ $__t('Product group') }} Hidden status + {{ $__t('Last price (Unit)') }} + {{ $__t('Last price (Total)') }} @include('components.userfields_thead', array( 'userfields' => $userfields @@ -248,6 +250,12 @@ @if(FindObjectInArrayByPropertyValue($missingProducts, 'id', $listItem->product_id) !== null) belowminstockamount @endif @if($listItem->done != 1) xxUNDONExx @endif + + {{ $listItem->last_price_unit }} + + + {{ $listItem->last_price_total }} + @include('components.userfields_tbody', array( 'userfields' => $userfields,