diff --git a/changelog/69_UNRELEASED_xxxx-xx-xx.md b/changelog/69_UNRELEASED_xxxx-xx-xx.md index 65c2d220..6b89ea67 100644 --- a/changelog/69_UNRELEASED_xxxx-xx-xx.md +++ b/changelog/69_UNRELEASED_xxxx-xx-xx.md @@ -9,6 +9,7 @@ ### Stock - Fixed that the average shelf life of a product (on the productcard) was wrong when the corresponding stock entry was edited +- Fixed that when the stock setting "Decimal places allowed for amounts" was set to `0`, unit conversion (if any) failed when adding the corresponding product to stock ### Shopping list diff --git a/public/viewjs/components/productamountpicker.js b/public/viewjs/components/productamountpicker.js index bb085286..fdb9fa31 100644 --- a/public/viewjs/components/productamountpicker.js +++ b/public/viewjs/components/productamountpicker.js @@ -106,7 +106,13 @@ $(".input-group-productamountpicker").on("change", function() $("#qu-conversion-info").text(__t("This equals %1$s %2$s", destinationAmount.toLocaleString({ minimumFractionDigits: 0, maximumFractionDigits: Grocy.UserSettings.stock_decimal_places_amounts }), destinationQuName)); } - $("#amount").val(destinationAmount.toFixed(Grocy.UserSettings.stock_decimal_places_amounts).replace(/0*$/g, '')); + var n = Number.parseInt(Grocy.UserSettings.stock_decimal_places_amounts); + if (n <= 0) + { + n = 1; + } + + $("#amount").val(destinationAmount.toFixed(n).replace(/0*$/g, '')); }); $("#display_amount").on("keyup", function()