mirror of
https://github.com/grocy/grocy.git
synced 2025-04-29 01:32:38 +00:00
Fixed produces product handling when consuming meal plan shadow recipes (fixes #2160)
This commit is contained in:
parent
7336693ca2
commit
792c710bdc
@ -49,6 +49,7 @@
|
||||
### Meal plan
|
||||
|
||||
- Added a new sub feature flag `FEATURE_FLAG_RECIPES_MEALPLAN` (in `config.php`) to only disable the meal plan if not needed (thanks @webysther)
|
||||
- Fixed that consuming a recipe from the meal plan didn't add its "Produces product"-product to stock (if any)
|
||||
|
||||
### Chores
|
||||
|
||||
|
@ -101,12 +101,20 @@ class RecipesService extends BaseService
|
||||
}
|
||||
$this->getDatabaseService()->GetDbConnectionRaw()->commit();
|
||||
|
||||
$recipeRow = $this->getDatabase()->recipes()->where('id = :1', $recipeId)->fetch();
|
||||
if (!empty($recipeRow->product_id))
|
||||
$recipe = $this->getDatabase()->recipes()->where('id = :1', $recipeId)->fetch();
|
||||
$productId = $recipe->product_id;
|
||||
if ($recipe->type == self::RECIPE_TYPE_MEALPLAN_SHADOW)
|
||||
{
|
||||
$product = $this->getDatabase()->products()->where('id = :1', $recipeRow->product_id)->fetch();
|
||||
// Use "Produces product" of the original recipe
|
||||
$mealPlanEntry = $this->getDatabase()->meal_plan()->where('id = :1', explode('#', $recipe->name)[1])->fetch();
|
||||
$productId = $this->getDatabase()->recipes()->where('id = :1', $mealPlanEntry->recipe_id)->fetch()->product_id;
|
||||
}
|
||||
|
||||
if (!empty($productId))
|
||||
{
|
||||
$product = $this->getDatabase()->products()->where('id = :1', $productId)->fetch();
|
||||
$recipeResolvedRow = $this->getDatabase()->recipes_resolved()->where('recipe_id = :1', $recipeId)->fetch();
|
||||
$this->getStockService()->AddProduct($recipeRow->product_id, $recipeRow->desired_servings, null, StockService::TRANSACTION_TYPE_SELF_PRODUCTION, date('Y-m-d'), $recipeResolvedRow->costs_per_serving, null, null, $dummyTransactionId, $product->default_stock_label_type, true);
|
||||
$this->getStockService()->AddProduct($productId, $recipe->desired_servings, null, StockService::TRANSACTION_TYPE_SELF_PRODUCTION, date('Y-m-d'), $recipeResolvedRow->costs_per_serving, null, null, $dummyTransactionId, $product->default_stock_label_type, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user