diff --git a/public/viewjs/stockentries.js b/public/viewjs/stockentries.js index 03a1dec5..266db407 100644 --- a/public/viewjs/stockentries.js +++ b/public/viewjs/stockentries.js @@ -249,6 +249,11 @@ function RefreshStockEntryRow(stockRowId) Grocy.Api.Get("stock/products/" + result.product_id, 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').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,20 +267,27 @@ function RefreshStockEntryRow(stockRowId) $('#stock-' + stockRowId + '-purchased-date').text(result.purchased_date); $('#stock-' + stockRowId + '-purchased-date-timeago').attr('datetime', result.purchased_date + ' 23:59:59'); - var shoppingLocationName = ""; - Grocy.Api.Get("objects/shopping_locations/" + result.shopping_location_id, - function(shoppingLocationResult) - { - shoppingLocationName = shoppingLocationResult.name; + if (result.shopping_location_id != null && !result.shopping_location_id.isEmpty()) + { + var shoppingLocationName = ""; + Grocy.Api.Get("objects/shopping_locations/" + result.shopping_location_id, + function(shoppingLocationResult) + { + shoppingLocationName = shoppingLocationResult.name; - $('#stock-' + stockRowId + '-shopping-location').attr('data-shopping-location-id', result.location_id); - $('#stock-' + stockRowId + '-shopping-location').text(shoppingLocationName); - }, - function(xhr) - { - console.error(xhr); - } - ); + $('#stock-' + stockRowId + '-shopping-location').attr('data-shopping-location-id', result.location_id); + $('#stock-' + stockRowId + '-shopping-location').text(shoppingLocationName); + }, + function(xhr) + { + console.error(xhr); + } + ); + } + else + { + $('#stock-' + stockRowId + '-shopping-location').text(""); + } if (result.open == 1) {