mirror of
https://github.com/grocy/grocy.git
synced 2025-08-17 11:06:36 +00:00
fix for price and total price (#1057)
* fix for price and total price * product card clarity
This commit is contained in:
@@ -95,7 +95,7 @@ Grocy.Components.ProductCard.Refresh = function(productId)
|
|||||||
{
|
{
|
||||||
if (productDetails.last_qu_factor_purchase_to_stock > 1)
|
if (productDetails.last_qu_factor_purchase_to_stock > 1)
|
||||||
{
|
{
|
||||||
$('#productcard-product-last-price').text(Number.parseFloat(productDetails.last_price).toLocaleString() + ' ' + Grocy.Currency + ' per 1 ' + productDetails.quantity_unit_purchase.name + ' of ' + productDetails.last_qu_factor_purchase_to_stock + ' ' + productDetails.quantity_unit_stock.name_plural);
|
$('#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
|
else
|
||||||
{
|
{
|
||||||
@@ -109,7 +109,7 @@ Grocy.Components.ProductCard.Refresh = function(productId)
|
|||||||
|
|
||||||
if (productDetails.avg_price !== null)
|
if (productDetails.avg_price !== null)
|
||||||
{
|
{
|
||||||
$('#productcard-product-average-price').text(Number.parseFloat(productDetails.avg_price).toLocaleString() + ' ' + Grocy.Currency);
|
$('#productcard-product-average-price').text(Number.parseFloat(productDetails.avg_price).toLocaleString() + ' ' + Grocy.Currency + ' per ' + productDetails.quantity_unit_stock.name);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@@ -183,7 +183,6 @@ if (Grocy.Components.ProductPicker !== undefined)
|
|||||||
function(productDetails)
|
function(productDetails)
|
||||||
{
|
{
|
||||||
|
|
||||||
$('#price').val(parseFloat(productDetails.last_price).toLocaleString({ minimumFractionDigits: 2, maximumFractionDigits: 2 }));
|
|
||||||
|
|
||||||
var qu_factor_purchase_to_stock = null;
|
var qu_factor_purchase_to_stock = null;
|
||||||
var barcode_shopping_location_id = null;
|
var barcode_shopping_location_id = null;
|
||||||
@@ -232,6 +231,8 @@ if (Grocy.Components.ProductPicker !== undefined)
|
|||||||
$('#amount_qu_unit').attr("quantity-unit-stock-name-plural", productDetails.quantity_unit_stock.name_plural);
|
$('#amount_qu_unit').attr("quantity-unit-stock-name-plural", productDetails.quantity_unit_stock.name_plural);
|
||||||
$('#qu_factor_purchase_to_stock').val(qu_factor_purchase_to_stock);
|
$('#qu_factor_purchase_to_stock').val(qu_factor_purchase_to_stock);
|
||||||
|
|
||||||
|
$('#price').val(parseFloat(productDetails.last_price * qu_factor_purchase_to_stock).toLocaleString({ minimumFractionDigits: 2, maximumFractionDigits: 2 }));
|
||||||
|
|
||||||
|
|
||||||
if (qu_factor_purchase_to_stock == 1)
|
if (qu_factor_purchase_to_stock == 1)
|
||||||
{
|
{
|
||||||
@@ -439,9 +440,17 @@ function refreshPriceHint()
|
|||||||
|
|
||||||
if ($("input[name='price-type']:checked").val() == "total-price")
|
if ($("input[name='price-type']:checked").val() == "total-price")
|
||||||
{
|
{
|
||||||
var price = parseFloat($('#price').val()) / parseFloat($('#amount').val());
|
var price = $('#price').val() / document.getElementById("amount_qu_unit").getAttribute("qu-factor-purchase-to-stock") / $('#amount').val();
|
||||||
|
var quprice = $('#price').val() / $('#amount').val();
|
||||||
|
|
||||||
$('#price-hint').text(__t('means %1$s per %2$s', price.toLocaleString({ minimumFractionDigits: 2, maximumFractionDigits: 2 }), document.getElementById("amount_qu_unit").getAttribute("quantity-unit-stock-name")));
|
if (document.getElementById("amount_qu_unit").getAttribute("qu-factor-purchase-to-stock") > 1)
|
||||||
|
{
|
||||||
|
$('#price-hint').text(__t('means %1$s per %2$s and %3$s per %4$s', price.toLocaleString({ minimumFractionDigits: 2, maximumFractionDigits: 2 }), document.getElementById("amount_qu_unit").getAttribute("quantity-unit-stock-name"), quprice.toLocaleString({ minimumFractionDigits: 2, maximumFractionDigits: 2 }),document.getElementById("amount_qu_unit").getAttribute("quantity-unit-purchase-name")));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$('#price-hint').text(__t('means %1$s per %2$s', price.toLocaleString({ minimumFractionDigits: 2, maximumFractionDigits: 2 }), document.getElementById("amount_qu_unit").getAttribute("quantity-unit-stock-name")));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user