mirror of
https://github.com/grocy/grocy.git
synced 2025-10-15 01:37:13 +00:00
Test/review/rework (and hopefully finalized) new price handling
This commit is contained in:
@@ -6,23 +6,12 @@ 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');
|
||||
@@ -95,14 +84,7 @@ Grocy.Components.ProductCard.Refresh = function(productId)
|
||||
|
||||
if (productDetails.last_price !== null)
|
||||
{
|
||||
if (productDetails.last_qu_factor_purchase_to_stock > 1)
|
||||
{
|
||||
$('#productcard-product-last-price').text(Number.parseFloat(productDetails.last_price * productDetails.last_qu_factor_purchase_to_stock).toLocaleString() + ' ' + Grocy.Currency + ' per 1 ' + productDetails.quantity_unit_purchase.name + ' of ' + productDetails.last_qu_factor_purchase_to_stock + ' ' + productDetails.quantity_unit_stock.name_plural);
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#productcard-product-last-price').text(Number.parseFloat(productDetails.last_price).toLocaleString() + ' ' + Grocy.Currency + ' per ' + productDetails.quantity_unit_purchase.name);
|
||||
}
|
||||
$('#productcard-product-last-price').text(Number.parseFloat(productDetails.last_price).toLocaleString() + ' ' + Grocy.Currency + ' per ' + productDetails.quantity_unit_stock.name);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Reference in New Issue
Block a user