diff --git a/changelog/76_UNRELEASED_xxxx-xx-xx.md b/changelog/76_UNRELEASED_xxxx-xx-xx.md index aa0ab397..021b73c5 100644 --- a/changelog/76_UNRELEASED_xxxx-xx-xx.md +++ b/changelog/76_UNRELEASED_xxxx-xx-xx.md @@ -14,6 +14,7 @@ - This executes the configured barcode lookup plugin with the given barcode - If the lookup was successful, the product edit page of the created product is displayed, where the product setup can be completed (if required) - After that, the transaction is continued with that product +- Optimized form validation (max amount checks) related to unit conversion with a lot of decimal places on the consume and transfer page - Fixed that when copying a product, the field "Treat opened as out of stock" wasn't copied along (thanks @TheDodger) - Fixed that the product groups filter on the master data products page used a contains search instead of an exact search - Fixed that Scan Mode on the purchase and consume page didn't work (not all fields were properly populated) when using/scanning a product Grocycodes diff --git a/public/viewjs/consume.js b/public/viewjs/consume.js index 2fab1da7..8cc9b022 100644 --- a/public/viewjs/consume.js +++ b/public/viewjs/consume.js @@ -481,7 +481,7 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e) if (productDetails.product.enable_tare_weight_handling == 1) { $("#display_amount").attr("min", productDetails.product.tare_weight); - $('#display_amount').attr('max', productDetails.stock_amount + productDetails.product.tare_weight); + $('#display_amount').attr('max', (productDetails.stock_amount + productDetails.product.tare_weight).toFixed(Grocy.UserSettings.stock_decimal_places_amounts)); $("#tare-weight-handling-info").removeClass("d-none"); } else @@ -568,7 +568,7 @@ $("#specific_stock_entry").on("change", function(e) sumValue = sumValue + stockEntry.amount_aggregated; } }); - $("#display_amount").attr("max", sumValue); + $("#display_amount").attr("max", sumValue.toFixed(Grocy.UserSettings.stock_decimal_places_amounts)); if (sumValue == 0) { $("#display_amount").parent().find(".invalid-feedback").text(__t('There are no units available at this location')); @@ -582,7 +582,7 @@ $("#specific_stock_entry").on("change", function(e) } else { - $("#display_amount").attr("max", $('option:selected', this).attr('amount')); + $("#display_amount").attr("max", Number.parseFloat($('option:selected', this).attr('amount')).toFixed(Grocy.UserSettings.stock_decimal_places_amounts)); } }); @@ -705,7 +705,7 @@ function RefreshForm() if (productDetails.product.enable_tare_weight_handling == 1 && !$('#consume-exact-amount').is(':checked')) { $("#display_amount").attr("min", productDetails.product.tare_weight); - $('#display_amount').attr('max', sumValue + productDetails.product.tare_weight); + $('#display_amount').attr('max', (sumValue + productDetails.product.tare_weight).toFixed(Grocy.UserSettings.stock_decimal_places_amounts)); $("#tare-weight-handling-info").removeClass("d-none"); } else @@ -713,7 +713,7 @@ function RefreshForm() $("#tare-weight-handling-info").addClass("d-none"); $("#display_amount").attr("min", Grocy.DefaultMinAmount); - $('#display_amount').attr('max', sumValue * $("#qu_id option:selected").attr("data-qu-factor")); + $('#display_amount').attr('max', (sumValue * $("#qu_id option:selected").attr("data-qu-factor")).toFixed(Grocy.UserSettings.stock_decimal_places_amounts)); if (sumValue == 0) { diff --git a/public/viewjs/transfer.js b/public/viewjs/transfer.js index ba998794..1bc1158a 100644 --- a/public/viewjs/transfer.js +++ b/public/viewjs/transfer.js @@ -365,7 +365,7 @@ $("#location_id_from").on('change', function(e) sumValue = sumValue + stockEntry.amount; } }); - $("#display_amount").attr("max", sumValue * $("#qu_id option:selected").attr("data-qu-factor")); + $("#display_amount").attr("max", (sumValue * $("#qu_id option:selected").attr("data-qu-factor")).toFixed(Grocy.UserSettings.stock_decimal_places_amounts)); if (sumValue == 0) { $("#display_amount").parent().find(".invalid-feedback").text(__t('There are no units available at this location')); @@ -392,7 +392,7 @@ $("#location_id_to").on('change', function(e) $("#qu_id").on('change', function(e) { - $("#display_amount").attr("max", Number.parseFloat($('#display_amount').attr("data-stock-amount")) * $("#qu_id option:selected").attr("data-qu-factor")); + $("#display_amount").attr("max", (Number.parseFloat($('#display_amount').attr("data-stock-amount")) * $("#qu_id option:selected").attr("data-qu-factor")).toFixed(Grocy.UserSettings.stock_decimal_places_amounts)); }); $('#display_amount').on('focus', function(e) @@ -442,7 +442,7 @@ $("#specific_stock_entry").on("change", function(e) sumValue = sumValue + stockEntry.amount; } }); - $("#display_amount").attr("max", sumValue * $("#qu_id option:selected").attr("data-qu-factor")); + $("#display_amount").attr("max", (sumValue * $("#qu_id option:selected").attr("data-qu-factor")).toFixed(Grocy.UserSettings.stock_decimal_places_amounts)); if (sumValue == 0) { $("#display_amount").parent().find(".invalid-feedback").text(__t('There are no units available at this location')); @@ -456,7 +456,7 @@ $("#specific_stock_entry").on("change", function(e) } else { - $("#display_amount").attr("max", $('option:selected', this).attr('amount')); + $("#display_amount").attr("max", Number.parseFloat($('option:selected', this).attr('amount')).toFixed(Grocy.UserSettings.stock_decimal_places_amounts)); } });