Optimized dynamic leading zeros rounding in productamountpicker (fixes #1943)

This commit is contained in:
Bernd Bestel 2022-07-14 17:01:12 +02:00
parent 8cb9157c73
commit e64df711e2
No known key found for this signature in database
GPG Key ID: 71BD34C0D4891300
2 changed files with 8 additions and 1 deletions

View File

@ -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

View File

@ -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()