diff --git a/public/viewjs/components/productcard.js b/public/viewjs/components/productcard.js index 05e5e8c6..2fc953aa 100644 --- a/public/viewjs/components/productcard.js +++ b/public/viewjs/components/productcard.js @@ -6,12 +6,23 @@ Grocy.Components.ProductCard.Refresh = function(productId) function(productDetails) { var stockAmount = productDetails.stock_amount || '0'; + var stockFactorPurchaseAmount = productDetails.stock_factor_purchase_amount || '0'; var stockValue = productDetails.stock_value || '0'; var stockAmountOpened = productDetails.stock_amount_opened || '0'; $('#productcard-product-name').text(productDetails.product.name); $('#productcard-product-description').html(productDetails.product.description); $('#productcard-product-stock-amount').text(stockAmount); $('#productcard-product-stock-qu-name').text(__n(stockAmount, productDetails.quantity_unit_stock.name, productDetails.quantity_unit_stock.name_plural)); + if (productDetails.last_qu_factor_purchase_to_stock > 1) + { + $('#productcard-product-stock-factor-purchase-amount').text('(' + stockFactorPurchaseAmount); + $('#productcard-product-stock-factor-purchase-qu-name').text(__n(stockFactorPurchaseAmount, productDetails.quantity_unit_purchase.name, productDetails.quantity_unit_purchase.name_plural) + ')'); + } + else + { + $('#productcard-product-stock-factor-purchase-amount').text(''); + $('#productcard-product-stock-factor-purchase-qu-name').text(''); + } $('#productcard-product-stock-value').text(stockValue + ' ' + Grocy.Currency); $('#productcard-product-last-purchased').text((productDetails.last_purchased || '2999-12-31').substring(0, 10)); $('#productcard-product-last-purchased-timeago').attr("datetime", productDetails.last_purchased || '2999-12-31'); diff --git a/services/StockService.php b/services/StockService.php index 96e0404a..ddfd1331 100644 --- a/services/StockService.php +++ b/services/StockService.php @@ -105,6 +105,7 @@ class StockService extends BaseService { $stockCurrentRow = new \stdClass(); $stockCurrentRow->amount = 0; + $stockCurrentRow->factor_purchase_amount = 0; $stockCurrentRow->value = 0; $stockCurrentRow->amount_opened = 0; $stockCurrentRow->amount_aggregated = 0; @@ -140,6 +141,7 @@ class StockService extends BaseService 'last_purchased' => $productLastPurchased->purchased_date, 'last_used' => $productLastUsed, 'stock_amount' => $stockCurrentRow->amount, + 'stock_factor_purchase_amount' => $stockCurrentRow->factor_purchase_amount, 'stock_value' => $stockCurrentRow->value, 'stock_amount_opened' => $stockCurrentRow->amount_opened, 'stock_amount_aggregated' => $stockCurrentRow->amount_aggregated, diff --git a/views/components/productcard.blade.php b/views/components/productcard.blade.php index 3ccddcec..91b93aaa 100644 --- a/views/components/productcard.blade.php +++ b/views/components/productcard.blade.php @@ -21,7 +21,9 @@ - {{ $__t('Stock amount') . ' / ' . $__t('Quantity unit') }}:
+ {{ $__t('Stock amount') }}: + +
{{ $__t('Stock value') }}:
@if(GROCY_FEATURE_FLAG_STOCK_LOCATION_TRACKING){{ $__t('Default location') }}:
@endif