mirror of
https://github.com/grocy/grocy.git
synced 2025-10-22 12:42:23 +00:00
Test/review/rework (and hopefully finalized) new price handling
This commit is contained in:
@@ -11,7 +11,7 @@ Grocy.Components.ProductAmountPicker.Reload = function(productId, destinationQuI
|
||||
$("#qu_id").attr("data-destination-qu-name", FindObjectInArrayByPropertyValue(Grocy.QuantityUnits, 'id', destinationQuId).name);
|
||||
conversionsForProduct.forEach(conversion =>
|
||||
{
|
||||
var factor = conversion.factor;
|
||||
var factor = parseFloat(conversion.factor);
|
||||
if (conversion.to_qu_id == destinationQuId)
|
||||
{
|
||||
factor = 1;
|
||||
@@ -39,6 +39,15 @@ Grocy.Components.ProductAmountPicker.Reload = function(productId, destinationQuI
|
||||
$("#qu_id").val($("#qu_id option:first").val());
|
||||
}
|
||||
|
||||
if ($('#qu_id option').length == 1)
|
||||
{
|
||||
$("#qu_id").attr("disabled", "");
|
||||
}
|
||||
else
|
||||
{
|
||||
$("#qu_id").removeAttr("disabled");
|
||||
}
|
||||
|
||||
$(".input-group-productamountpicker").trigger("change");
|
||||
}
|
||||
|
||||
|
@@ -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