From bfd29def8d3d718627b154fb83b680a4d47e09a7 Mon Sep 17 00:00:00 2001 From: Bernd Bestel Date: Sat, 9 Mar 2019 17:00:57 +0100 Subject: [PATCH] Show purchase to stock conversion factor on purchase page when QU units are different (closes #169) --- localization/en/strings.php | 3 ++- public/viewjs/purchase.js | 10 +++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/localization/en/strings.php b/localization/en/strings.php index 3ee5041c..521cdf6f 100644 --- a/localization/en/strings.php +++ b/localization/en/strings.php @@ -353,5 +353,6 @@ return array( 'Show battery details' => 'Show battery details', 'Journal for this battery' => 'Journal for this battery', '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' ); diff --git a/public/viewjs/purchase.js b/public/viewjs/purchase.js index d9c458f1..0d766eda 100644 --- a/public/viewjs/purchase.js +++ b/public/viewjs/purchase.js @@ -105,10 +105,18 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e) Grocy.Api.Get('stock/products/' + productId, function (productDetails) { - $('#amount_qu_unit').text(productDetails.quantity_unit_purchase.name); $('#price').val(productDetails.last_price); 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) { $("#amount").attr("min", "0.01");