Value information (#1045)

* viewjs stockoverview: add total value to stock overview

* view stockoverview.blade: add Value column

* refresh stockOverview value column

* Removed the total units info

* Properly format the total stock value number

* Added new localization strings

* Resolved merge conflict

Co-authored-by: Bernd Bestel <bernd@berrnd.de>
This commit is contained in:
kriddles 2020-10-15 12:46:27 -05:00 committed by GitHub
parent 56d79d7db8
commit 5ae36e6ba8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 33 additions and 7 deletions

View File

@ -1915,3 +1915,9 @@ msgstr ""
msgid "Consume exact amount"
msgstr ""
msgid "Value"
msgstr ""
msgid "%s total value"
msgstr ""

View File

@ -6,6 +6,7 @@ SELECT
p.tare_weight AS tare_weight,
p.enable_tare_weight_handling AS enable_tare_weight_handling,
sc.amount AS amount,
sc.value as value,
sc.product_id AS product_id,
sc.best_before_date AS best_before_date,
EXISTS(SELECT id FROM stock_missing_products_including_opened WHERE id = sc.product_id) AS product_missing,
@ -40,6 +41,7 @@ SELECT
p.tare_weight AS tare_weight,
p.enable_tare_weight_handling AS enable_tare_weight_handling,
sc.amount AS amount,
sc.value as value,
sc.product_id AS product_id,
sc.best_before_date AS best_before_date,
EXISTS(SELECT id FROM stock_missing_products_including_opened WHERE id = sc.product_id) AS product_missing,

View File

@ -5,9 +5,9 @@
{ 'orderable': false, 'targets': 0 },
{ 'searchable': false, "targets": 0 },
{ 'searchable': false, "targets": 0 },
{ 'visible': false, 'targets': 5 },
{ 'visible': false, 'targets': 6 },
{ 'visible': false, 'targets': 7 }
{ 'visible': false, 'targets': 7 },
{ 'visible': false, 'targets': 8 }
],
});
$('#stock-overview-table tbody').removeClass("d-none");
@ -25,7 +25,7 @@ $("#location-filter").on("change", function()
value = "xx" + value + "xx";
}
stockOverviewTable.column(5).search(value).draw();
stockOverviewTable.column(6).search(value).draw();
});
$("#product-group-filter").on("change", function()
@ -40,7 +40,7 @@ $("#product-group-filter").on("change", function()
value = "xx" + value + "xx";
}
stockOverviewTable.column(7).search(value).draw();
stockOverviewTable.column(8).search(value).draw();
});
$("#status-filter").on("change", function()
@ -54,7 +54,7 @@ $("#status-filter").on("change", function()
// Transfer CSS classes of selected element to dropdown element (for background)
$(this).attr("class", $("#" + $(this).attr("id") + " option[value='" + value + "']").attr("class") + " form-control");
stockOverviewTable.column(6).search(value).draw();
stockOverviewTable.column(7).search(value).draw();
});
$(".status-filter-message").on("click", function()
@ -70,9 +70,9 @@ $("#clear-filter-button").on("click", function()
$("#status-filter").val("all");
$("#product-group-filter").val("all");
$("#location-filter").val("all");
stockOverviewTable.column(5).search("").draw();
stockOverviewTable.column(6).search("").draw();
stockOverviewTable.column(7).search("").draw();
stockOverviewTable.column(8).search("").draw();
stockOverviewTable.search("").draw();
});
@ -204,7 +204,20 @@ function RefreshStatistics()
{
amountSum += parseInt(element.amount);
});
$("#info-current-stock").text(__n(result.length, '%s Product', '%s Products'));
if (!Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING)
{
$("#info-current-stock").text(__n(result.length, '%s Product', '%s Products'));
}
else
{
var valueSum = 0;
result.forEach(element =>
{
valueSum += parseInt(element.value);
});
$("#info-current-stock").text(__n(result.length, '%s Product', '%s Products') + ", " + __t('%s total value', valueSum.toLocaleString(undefined, { style: "currency", currency: Grocy.Currency })));
}
},
function(xhr)
{
@ -276,6 +289,7 @@ function RefreshProductRow(productId)
$('#product-' + productId + '-amount').text(result.stock_amount);
$('#product-' + productId + '-consume-all-button').attr('data-consume-amount', result.stock_amount);
$('#product-' + productId + '-factor-purchase-amount').text(__t('( %s', result.stock_factor_purchase_amount));
$('#product-' + productId + '-value').text(result.stock_value);
$('#product-' + productId + '-next-best-before-date').text(result.next_best_before_date);
$('#product-' + productId + '-next-best-before-date-timeago').attr('datetime', result.next_best_before_date);

View File

@ -128,6 +128,7 @@
<th>{{ $__t('Product') }}</th>
<th>{{ $__t('Product group') }}</th>
<th>{{ $__t('Amount') }}</th>
<th class="@if(!GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING) d-none @endif">{{ $__t('Value') }}</th>
<th class="@if(!GROCY_FEATURE_FLAG_STOCK_BEST_BEFORE_DATE_TRACKING) d-none @endif">{{ $__t('Next best before date') }}</th>
<th class="d-none">Hidden location</th>
<th class="d-none">Hidden status</th>
@ -308,6 +309,9 @@
@endif
@endif
</td>
<td>
<span id="product-{{ $currentStockEntry->product_id }}-value" class="locale-number locale-number-currency">{{ $currentStockEntry->value }}</span>
</td>
<td class="@if(!GROCY_FEATURE_FLAG_STOCK_BEST_BEFORE_DATE_TRACKING) d-none @endif">
<span id="product-{{ $currentStockEntry->product_id }}-next-best-before-date">{{ $currentStockEntry->best_before_date }}</span>
<time id="product-{{ $currentStockEntry->product_id }}-next-best-before-date-timeago"