mirror of
https://github.com/grocy/grocy.git
synced 2025-04-30 10:05:45 +00:00
Fixed JS / display errors on refreshing a row on /stockentries
This commit is contained in:
parent
44c6865ba1
commit
900a49a36a
@ -249,6 +249,11 @@ function RefreshStockEntryRow(stockRowId)
|
|||||||
Grocy.Api.Get("stock/products/" + result.product_id,
|
Grocy.Api.Get("stock/products/" + result.product_id,
|
||||||
function(productDetails)
|
function(productDetails)
|
||||||
{
|
{
|
||||||
|
if (result.price == null || result.price.isEmpty())
|
||||||
|
{
|
||||||
|
result.price = 0;
|
||||||
|
}
|
||||||
|
|
||||||
$('#stock-' + stockRowId + '-price').text(__t("%1$s per %2$s", (Number.parseFloat(result.price) * Number.parseFloat(productDetails.product.qu_factor_purchase_to_stock)).toLocaleString(undefined, { style: "currency", currency: Grocy.Currency, minimumFractionDigits: Grocy.UserSettings.stock_decimal_places_prices, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_prices }), productDetails.default_quantity_unit_purchase.name));
|
$('#stock-' + stockRowId + '-price').text(__t("%1$s per %2$s", (Number.parseFloat(result.price) * Number.parseFloat(productDetails.product.qu_factor_purchase_to_stock)).toLocaleString(undefined, { style: "currency", currency: Grocy.Currency, minimumFractionDigits: Grocy.UserSettings.stock_decimal_places_prices, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_prices }), productDetails.default_quantity_unit_purchase.name));
|
||||||
$('#stock-' + stockRowId + '-price').attr("data-original-title", __t("%1$s per %2$s", Number.parseFloat(result.price).toLocaleString(undefined, { style: "currency", currency: Grocy.Currency, minimumFractionDigits: Grocy.UserSettings.stock_decimal_places_prices, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_prices }), productDetails.quantity_unit_stock.name));
|
$('#stock-' + stockRowId + '-price').attr("data-original-title", __t("%1$s per %2$s", Number.parseFloat(result.price).toLocaleString(undefined, { style: "currency", currency: Grocy.Currency, minimumFractionDigits: Grocy.UserSettings.stock_decimal_places_prices, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_prices }), productDetails.quantity_unit_stock.name));
|
||||||
},
|
},
|
||||||
@ -262,6 +267,8 @@ function RefreshStockEntryRow(stockRowId)
|
|||||||
$('#stock-' + stockRowId + '-purchased-date').text(result.purchased_date);
|
$('#stock-' + stockRowId + '-purchased-date').text(result.purchased_date);
|
||||||
$('#stock-' + stockRowId + '-purchased-date-timeago').attr('datetime', result.purchased_date + ' 23:59:59');
|
$('#stock-' + stockRowId + '-purchased-date-timeago').attr('datetime', result.purchased_date + ' 23:59:59');
|
||||||
|
|
||||||
|
if (result.shopping_location_id != null && !result.shopping_location_id.isEmpty())
|
||||||
|
{
|
||||||
var shoppingLocationName = "";
|
var shoppingLocationName = "";
|
||||||
Grocy.Api.Get("objects/shopping_locations/" + result.shopping_location_id,
|
Grocy.Api.Get("objects/shopping_locations/" + result.shopping_location_id,
|
||||||
function(shoppingLocationResult)
|
function(shoppingLocationResult)
|
||||||
@ -276,6 +283,11 @@ function RefreshStockEntryRow(stockRowId)
|
|||||||
console.error(xhr);
|
console.error(xhr);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$('#stock-' + stockRowId + '-shopping-location').text("");
|
||||||
|
}
|
||||||
|
|
||||||
if (result.open == 1)
|
if (result.open == 1)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user