Optimizations regarding displaying prices (closes #1743)

This commit is contained in:
Bernd Bestel
2022-04-02 17:49:35 +02:00
parent 7ad979cba9
commit 6a50f74a14
8 changed files with 215 additions and 71 deletions

View File

@@ -216,7 +216,18 @@ function RefreshStockEntryRow(stockRowId)
}
);
$('#stock-' + stockRowId + '-price').text(result.price);
Grocy.Api.Get("stock/products/" + result.product_id,
function(productDetails)
{
$('#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));
},
function(xhr)
{
console.error(xhr);
}
);
$('#stock-' + stockRowId + '-note').text(result.note);
$('#stock-' + stockRowId + '-purchased-date').text(result.purchased_date);
$('#stock-' + stockRowId + '-purchased-date-timeago').attr('datetime', result.purchased_date + ' 23:59:59');