Added columns for last price on shopping list (closes #410)

This commit is contained in:
Bernd Bestel 2020-12-19 17:55:49 +01:00
parent 7f24ffc484
commit f5e0709913
No known key found for this signature in database
GPG Key ID: 71BD34C0D4891300
6 changed files with 38 additions and 2 deletions

View File

@ -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)

View File

@ -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(),

View File

@ -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 ""

View File

@ -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;

View File

@ -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,

View File

@ -175,6 +175,8 @@
<th>{{ $__t('Amount') }}</th>
<th>{{ $__t('Product group') }}</th>
<th class="d-none">Hidden status</th>
<th class="@if(!GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING) d-none @endif">{{ $__t('Last price (Unit)') }}</th>
<th class="@if(!GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING) d-none @endif">{{ $__t('Last price (Total)') }}</th>
@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
</td>
<td class="@if(!GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING) d-none @endif">
<span class="locale-number locale-number-currency">{{ $listItem->last_price_unit }}</span>
</td>
<td class="@if(!GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING) d-none @endif">
<span class="locale-number locale-number-currency">{{ $listItem->last_price_total }}</span>
</td>
@include('components.userfields_tbody', array(
'userfields' => $userfields,