mirror of
https://github.com/grocy/grocy.git
synced 2025-04-29 17:45:39 +00:00
Fixed recipe consume stock fulfillment checking (frontend and API) (fixes #1781)
This commit is contained in:
parent
8e3a9d6c04
commit
1344e84534
55
changelog/67_UNRELEASED_xxxx-xx-xx.md
Normal file
55
changelog/67_UNRELEASED_xxxx-xx-xx.md
Normal file
@ -0,0 +1,55 @@
|
||||
> ⚠️ xxxBREAKING CHANGESxxx
|
||||
|
||||
> ❗ xxxImportant upgrade informationXXX
|
||||
|
||||
### New feature: xxxx
|
||||
|
||||
- xxx
|
||||
|
||||
### Stock
|
||||
|
||||
- xxx
|
||||
|
||||
### Shopping list
|
||||
|
||||
- xxx
|
||||
|
||||
### Recipes
|
||||
|
||||
- Fixed that consuming recipes was possible when not all ingredients were in-stock (and this potentially consumed some of the in-stock ingredients; not matching the message "nothing removed")
|
||||
|
||||
### Meal plan
|
||||
|
||||
- xxx
|
||||
|
||||
### Chores
|
||||
|
||||
- xxx
|
||||
|
||||
### Calendar
|
||||
|
||||
- xxx
|
||||
|
||||
### Tasks
|
||||
|
||||
- xxx
|
||||
|
||||
### Batteries
|
||||
|
||||
- xxx
|
||||
|
||||
### Equipment
|
||||
|
||||
- xxx
|
||||
|
||||
### Userfields
|
||||
|
||||
- xxx
|
||||
|
||||
### General
|
||||
|
||||
- xxx
|
||||
|
||||
### API
|
||||
|
||||
- Endpoint `/recipes/{recipeId}/consume`: Fixed that consuming partially fulfilled recipes was possible, although an error was already returned in that case (and potentially some of the in-stock ingredients were consumed in fact)
|
@ -3388,6 +3388,16 @@
|
||||
"responses": {
|
||||
"204": {
|
||||
"description": "The operation was successful"
|
||||
},
|
||||
"400": {
|
||||
"description": "The operation was not successful (possible errors are: Invalid recipe id, recipe need is not fulfilled)",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/Error400"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -74,6 +74,12 @@ class RecipesService extends BaseService
|
||||
throw new \Exception('Recipe does not exist');
|
||||
}
|
||||
|
||||
$recipeResolved = $this->getDatabase()->recipes_resolved()->where('recipe_id', $recipeId)->fetch();
|
||||
if ($recipeResolved->need_fulfilled == 0)
|
||||
{
|
||||
throw new \Exception('Recipe need is not fulfilled, consuming not possible');
|
||||
}
|
||||
|
||||
$transactionId = uniqid();
|
||||
|
||||
$recipePositions = $this->getDatabase()->recipes_pos_resolved()->where('recipe_id', $recipeId)->fetchAll();
|
||||
|
@ -295,7 +295,7 @@
|
||||
<div class="d-flex justify-content-between align-items-center">
|
||||
<h3 class="card-title mb-0">{{ $recipe->name }}</h3>
|
||||
<div class="card-icons d-flex flex-wrap justify-content-end flex-shrink-1">
|
||||
<a class="@if(!GROCY_FEATURE_FLAG_STOCK) d-none @endif recipe-consume @if(FindObjectInArrayByPropertyValue($recipesResolved, 'recipe_id', $recipe->id)->need_fulfilled == 0) disabled @endif"
|
||||
<a class="btn @if(!GROCY_FEATURE_FLAG_STOCK) d-none @endif recipe-consume @if(FindObjectInArrayByPropertyValue($recipesResolved, 'recipe_id', $recipe->id)->need_fulfilled == 0) disabled @endif"
|
||||
href="#"
|
||||
data-toggle="tooltip"
|
||||
title="{{ $__t('Consume all ingredients needed by this recipe') }}"
|
||||
@ -303,7 +303,7 @@
|
||||
data-recipe-name="{{ $recipe->name }}">
|
||||
<i class="fas fa-utensils"></i>
|
||||
</a>
|
||||
<a class="@if(!GROCY_FEATURE_FLAG_STOCK) d-none @endif recipe-shopping-list @if(FindObjectInArrayByPropertyValue($recipesResolved, 'recipe_id', $recipe->id)->need_fulfilled_with_shopping_list == 1) disabled @endif"
|
||||
<a class="btn @if(!GROCY_FEATURE_FLAG_STOCK) d-none @endif recipe-shopping-list @if(FindObjectInArrayByPropertyValue($recipesResolved, 'recipe_id', $recipe->id)->need_fulfilled_with_shopping_list == 1) disabled @endif"
|
||||
href="#"
|
||||
data-toggle="tooltip"
|
||||
title="{{ $__t('Put missing products on shopping list') }}"
|
||||
@ -311,14 +311,14 @@
|
||||
data-recipe-name="{{ $recipe->name }}">
|
||||
<i class="fas fa-cart-plus"></i>
|
||||
</a>
|
||||
<a class="recipe-fullscreen hide-when-embedded"
|
||||
<a class="btn recipe-fullscreen hide-when-embedded"
|
||||
id="selectedRecipeToggleFullscreenButton"
|
||||
href="#"
|
||||
data-toggle="tooltip"
|
||||
title="{{ $__t('Expand to fullscreen') }}">
|
||||
<i class="fas fa-expand-arrows-alt"></i>
|
||||
</a>
|
||||
<a class="recipe-print"
|
||||
<a class="btn recipe-print"
|
||||
href="#"
|
||||
data-toggle="tooltip"
|
||||
title="{{ $__t('Print') }}">
|
||||
@ -331,7 +331,7 @@
|
||||
<div class="mb-4 @if(!empty($recipe->picture_file_name)) d-none @else d-flex @endif d-print-block justify-content-between align-items-center">
|
||||
<h1 class="card-title mb-0">{{ $recipe->name }}</h1>
|
||||
<div class="card-icons d-flex flex-wrap justify-content-end flex-shrink-1 d-print-none">
|
||||
<a class="recipe-consume @if(FindObjectInArrayByPropertyValue($recipesResolved, 'recipe_id', $recipe->id)->need_fulfilled == 0) disabled @endif"
|
||||
<a class="btn recipe-consume @if(FindObjectInArrayByPropertyValue($recipesResolved, 'recipe_id', $recipe->id)->need_fulfilled == 0) disabled @endif"
|
||||
href="#"
|
||||
data-toggle="tooltip"
|
||||
title="{{ $__t('Consume all ingredients needed by this recipe') }}"
|
||||
@ -339,7 +339,7 @@
|
||||
data-recipe-name="{{ $recipe->name }}">
|
||||
<i class="fas fa-utensils"></i>
|
||||
</a>
|
||||
<a class="recipe-shopping-list @if(FindObjectInArrayByPropertyValue($recipesResolved, 'recipe_id', $recipe->id)->need_fulfilled_with_shopping_list == 1) disabled @endif"
|
||||
<a class="btn recipe-shopping-list @if(FindObjectInArrayByPropertyValue($recipesResolved, 'recipe_id', $recipe->id)->need_fulfilled_with_shopping_list == 1) disabled @endif"
|
||||
href="#"
|
||||
data-toggle="tooltip"
|
||||
title="{{ $__t('Put missing products on shopping list') }}"
|
||||
@ -347,13 +347,13 @@
|
||||
data-recipe-name="{{ $recipe->name }}">
|
||||
<i class="fas fa-cart-plus"></i>
|
||||
</a>
|
||||
<a class="recipe-fullscreen hide-when-embedded"
|
||||
<a class=" btnrecipe-fullscreen hide-when-embedded"
|
||||
href="#"
|
||||
data-toggle="tooltip"
|
||||
title="{{ $__t('Expand to fullscreen') }}">
|
||||
<i class="fas fa-expand-arrows-alt"></i>
|
||||
</a>
|
||||
<a class="recipe-print PrintRecipe"
|
||||
<a class="btn recipe-print PrintRecipe"
|
||||
href="#"
|
||||
data-toggle="tooltip"
|
||||
title="{{ $__t('Print') }}">
|
||||
|
Loading…
x
Reference in New Issue
Block a user