Skip to content

Commit

Permalink
fix: round ingredient amounts when not using fractions (#4470)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kuchenpirat authored Oct 30, 2024
1 parent 2b2bc04 commit 985b563
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion frontend/composables/recipes/use-recipe-ingredients.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export function useParsedIngredientText(ingredient: RecipeIngredient, disableAmo
// casting to number is required as sometimes quantity is a string
if (quantity && Number(quantity) !== 0) {
if (unit && !unit.fraction) {
returnQty = (quantity * scale).toString();
returnQty = Number((quantity * scale).toPrecision(3)).toString();
} else {
const fraction = frac(quantity * scale, 10, true);
if (fraction[0] !== undefined && fraction[0] > 0) {
Expand Down

0 comments on commit 985b563

Please sign in to comment.