diff --git a/changelog/52_UNRELEASED_2019-xx-xx.md b/changelog/52_UNRELEASED_2019-xx-xx.md
index 5747bec8..0209edae 100644
--- a/changelog/52_UNRELEASED_2019-xx-xx.md
+++ b/changelog/52_UNRELEASED_2019-xx-xx.md
@@ -9,7 +9,7 @@
- Please note due to browser security restrictions, this only works when serving grocy via a secure connection (`https://`)
- There is also a `config.php` setting `DISABLE_BROWSER_BARCODE_CAMERA_SCANNING` to disable this, if you don't need it at all (defaults to `false`)
-### Stock improvements
+### Stock improvements/fixes
- Products can now have variations (nested products)
- Define the parent product for a product on the product edit page (only one level is possible, means a product which is used as a parent product in another product, cannot have a parent product itself)
- Parent and sub products can have stock (both are regular products, no difference from that side)
@@ -27,6 +27,7 @@
- `FEATURE_FLAG_STOCK_LOCATION_TRACKING` to disable product location tracking
- `FEATURE_FLAG_STOCK_BEST_BEFORE_DATE_TRACKING` to disable product best before date tracking
- `FEATURE_FLAG_STOCK_PRODUCT_OPENED_TRACKING` to disable product opened tracking
+- Fixed/refined some things regarding purchase/consume/inventory of products with enabled tare weight handling (nothing was broken, but the success popups may not displayed the correct amount that was posted)
### Recipe improvements
- Based on the new linked quantity units, recipe ingredients can now use any product related unit, the amount is calculated according to the cnoversion factor of the unit relation
diff --git a/public/viewjs/consume.js b/public/viewjs/consume.js
index 61b0785b..0c9d45e6 100644
--- a/public/viewjs/consume.js
+++ b/public/viewjs/consume.js
@@ -26,12 +26,16 @@
jsonData.recipe_id = Grocy.Components.RecipePicker.GetValue();
}
+ var bookingResponse = null;
+
Grocy.Api.Get('stock/products/' + jsonForm.product_id,
function(productDetails)
{
Grocy.Api.Post(apiUrl, jsonData,
function(result)
{
+ bookingResponse = result;
+
var addBarcode = GetUriParam('addbarcodetoselection');
if (addBarcode !== undefined)
{
@@ -66,7 +70,14 @@
}
Grocy.FrontendHelpers.EndUiBusy("consume-form");
- toastr.success(__t('Removed %1$s of %2$s from stock', jsonForm.amount + " " + __n(jsonForm.amount, productDetails.quantity_unit_stock.name, productDetails.quantity_unit_stock.name_plural), productDetails.product.name) + ' ' + __t("Undo") + '');
+ if (productDetails.product.enable_tare_weight_handling == 1)
+ {
+ toastr.success(__t('Removed %1$s of %2$s from stock', Math.abs(jsonForm.amount - parseFloat(productDetails.product.tare_weight)) + " " + __n(jsonForm.amount, productDetails.quantity_unit_stock.name, productDetails.quantity_unit_stock.name_plural), productDetails.product.name) + ' ' + __t("Undo") + '');
+ }
+ else
+ {
+ toastr.success(__t('Removed %1$s of %2$s from stock', Math.abs(jsonForm.amount) + " " + __n(jsonForm.amount, productDetails.quantity_unit_stock.name, productDetails.quantity_unit_stock.name_plural), productDetails.product.name) + ' ' + __t("Undo") + '');
+ }
$("#amount").attr("min", "1");
$("#amount").attr("max", "999999");
@@ -242,6 +253,12 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e)
for (i = 0; i < stockEntry.amount; i++)
{
+ // Do this only for the first 50 entries to prevent a very long loop (is more anytime needed)?
+ if (i > 50)
+ {
+ break;
+ }
+
$("#specific_stock_entry").append($("