Round amount picker max by stock_decimal_places_amounts (closes #2578)

This commit is contained in:
Bernd Bestel 2024-09-10 21:55:31 +02:00
parent 185e6b20ad
commit 9e1020b7f8
No known key found for this signature in database
GPG Key ID: 71BD34C0D4891300
3 changed files with 10 additions and 9 deletions

View File

@ -14,6 +14,7 @@
- This executes the configured barcode lookup plugin with the given barcode - 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) - 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 - 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 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 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 - 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

View File

@ -481,7 +481,7 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e)
if (productDetails.product.enable_tare_weight_handling == 1) if (productDetails.product.enable_tare_weight_handling == 1)
{ {
$("#display_amount").attr("min", productDetails.product.tare_weight); $("#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"); $("#tare-weight-handling-info").removeClass("d-none");
} }
else else
@ -568,7 +568,7 @@ $("#specific_stock_entry").on("change", function(e)
sumValue = sumValue + stockEntry.amount_aggregated; 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) if (sumValue == 0)
{ {
$("#display_amount").parent().find(".invalid-feedback").text(__t('There are no units available at this location')); $("#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 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')) if (productDetails.product.enable_tare_weight_handling == 1 && !$('#consume-exact-amount').is(':checked'))
{ {
$("#display_amount").attr("min", productDetails.product.tare_weight); $("#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"); $("#tare-weight-handling-info").removeClass("d-none");
} }
else else
@ -713,7 +713,7 @@ function RefreshForm()
$("#tare-weight-handling-info").addClass("d-none"); $("#tare-weight-handling-info").addClass("d-none");
$("#display_amount").attr("min", Grocy.DefaultMinAmount); $("#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) if (sumValue == 0)
{ {

View File

@ -365,7 +365,7 @@ $("#location_id_from").on('change', function(e)
sumValue = sumValue + stockEntry.amount; 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) if (sumValue == 0)
{ {
$("#display_amount").parent().find(".invalid-feedback").text(__t('There are no units available at this location')); $("#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) $("#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) $('#display_amount').on('focus', function(e)
@ -442,7 +442,7 @@ $("#specific_stock_entry").on("change", function(e)
sumValue = sumValue + stockEntry.amount; 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) if (sumValue == 0)
{ {
$("#display_amount").parent().find(".invalid-feedback").text(__t('There are no units available at this location')); $("#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 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));
} }
}); });