Show purchase to stock conversion factor on purchase page when QU units are different (closes #169)

This commit is contained in:
Bernd Bestel
2019-03-09 17:00:57 +01:00
parent cd0ca4a67c
commit bfd29def8d
2 changed files with 11 additions and 2 deletions

View File

@@ -353,5 +353,6 @@ return array(
'Show battery details' => 'Show battery details', 'Show battery details' => 'Show battery details',
'Journal for this battery' => 'Journal for this battery', 'Journal for this battery' => 'Journal for this battery',
'System info' => 'System info', 'System info' => 'System info',
'Changelog' => 'Changelog' 'Changelog' => 'Changelog',
'will be multiplied a factor of #1 to get #2' => 'will be multiplied a factor of #1 to get #2'
); );

View File

@@ -105,10 +105,18 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e)
Grocy.Api.Get('stock/products/' + productId, Grocy.Api.Get('stock/products/' + productId,
function (productDetails) function (productDetails)
{ {
$('#amount_qu_unit').text(productDetails.quantity_unit_purchase.name);
$('#price').val(productDetails.last_price); $('#price').val(productDetails.last_price);
Grocy.Components.LocationPicker.SetId(productDetails.location.id); Grocy.Components.LocationPicker.SetId(productDetails.location.id);
if (productDetails.product.qu_id_purchase === productDetails.product.qu_id_stock)
{
$('#amount_qu_unit').text(productDetails.quantity_unit_purchase.name);
}
else
{
$('#amount_qu_unit').text(productDetails.quantity_unit_purchase.name + " (" + L("will be multiplied a factor of #1 to get #2", parseInt(productDetails.product.qu_factor_purchase_to_stock).toString(), productDetails.quantity_unit_stock.name) + ")");
}
if (productDetails.product.allow_partial_units_in_stock == 1) if (productDetails.product.allow_partial_units_in_stock == 1)
{ {
$("#amount").attr("min", "0.01"); $("#amount").attr("min", "0.01");