Make it possible to round up shopping list and recipe ingredient amounts (closes #902, closes #2644)

This commit is contained in:
Bernd Bestel
2025-01-19 20:16:37 +01:00
parent e3965ed82c
commit 1946ff870e
10 changed files with 196 additions and 2 deletions

View File

@@ -80,6 +80,14 @@
id="variable_amount"
name="variable_amount"
value="@if($mode == 'edit'){{ $recipePos->variable_amount }}@endif">
<div class="custom-control custom-checkbox">
<input @if($mode=='edit'
&&
$recipePos->round_up == 1) checked @endif class="form-check-input custom-control-input" type="checkbox" id="round_up" name="round_up" value="1">
<label class="form-check-label custom-control-label"
for="round_up">{{ $__t('Round up quantity amounts to the nearest whole number') }}</label>
</div>
</div>
<div class="form-group @if(!GROCY_FEATURE_FLAG_STOCK) d-none @endif">

View File

@@ -254,6 +254,11 @@
$listItem->amount = $listItem->amount * $productQuConversion->factor;
}
}
if(boolval($userSettings['shopping_list_round_up']))
{
$listItem->amount = ceil($listItem->amount);
}
@endphp
@endif
<td>

View File

@@ -14,6 +14,7 @@
<div class="row">
<div class="col-lg-6 col-12">
<h4 class="mt-2">{{ $__t('Shopping list') }}</h4>
<div class="form-group">
<div class="custom-control custom-checkbox">
<input type="checkbox"
@@ -25,7 +26,22 @@
{{ $__t('Show a month-view calendar') }}
</label>
</div>
</div>
<div class="form-group">
<div class="custom-control custom-checkbox">
<input type="checkbox"
class="form-check-input custom-control-input user-setting-control"
id="shopping_list_round_up"
data-setting-key="shopping_list_round_up">
<label class="form-check-label custom-control-label"
for="shopping_list_round_up">
{{ $__t('Round up quantity amounts to the nearest whole number') }}
</label>
</div>
</div>
<div class="form-group">
<div class="custom-control custom-checkbox">
<input type="checkbox"
class="form-check-input custom-control-input user-setting-control"
@@ -48,7 +64,9 @@
</div>
</div>
<h4 class="mt-2">{{ $__t('Shopping list to stock workflow') }}</h4>
<div class="form-group">
<div class="custom-control custom-checkbox">
<input type="checkbox"