From 0bd698c968be77460968d9a1cd30193d8dc86879 Mon Sep 17 00:00:00 2001 From: Bernd Bestel Date: Sun, 5 Feb 2023 15:24:28 +0100 Subject: [PATCH] Print stock entry labels when consuming a "Produces product" recipe (closes #2123) --- changelog/70_UNRELEASED_xxxx.xx.xx.md | 1 + services/RecipesService.php | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/changelog/70_UNRELEASED_xxxx.xx.xx.md b/changelog/70_UNRELEASED_xxxx.xx.xx.md index 7c9aa82d..f45c7b4b 100644 --- a/changelog/70_UNRELEASED_xxxx.xx.xx.md +++ b/changelog/70_UNRELEASED_xxxx.xx.xx.md @@ -41,6 +41,7 @@ - Added a new entry "Add to meal plan" in the context/more menu per recipe to directly add a recipe to the meal plan from the recipes page - Changed that when a ingredient has a "Variable amount" set, the text entered there now also replaces the unit when displaying the recipe (not only the amount as before) - When displaying a recipe in fullscreen mode, the ingredients and preparation is now shown side by side (or below each other on small screens) instead of in tabs +- When consuming a recipe which has a "Produces product" set and when the product's "Default stock entry label" is configured accordingly, the corresponding label will now be printed on that action (only server side label printer WebHooks are supported) - Fixed that hiding the "Requirements fulfilled" column (table options) on the recipes page didn't work - Fixed that ingredient costs and calories were wrong when product substitution and unit conversions were involved at the same time diff --git a/services/RecipesService.php b/services/RecipesService.php index 5fc86e72..79a73704 100644 --- a/services/RecipesService.php +++ b/services/RecipesService.php @@ -104,8 +104,9 @@ class RecipesService extends BaseService $recipeRow = $this->getDatabase()->recipes()->where('id = :1', $recipeId)->fetch(); if (!empty($recipeRow->product_id)) { + $product = $this->getDatabase()->products()->where('id = :1', $recipeRow->product_id)->fetch(); $recipeResolvedRow = $this->getDatabase()->recipes_resolved()->where('recipe_id = :1', $recipeId)->fetch(); - $this->getStockService()->AddProduct($recipeRow->product_id, floatval($recipeRow->desired_servings), null, StockService::TRANSACTION_TYPE_SELF_PRODUCTION, date('Y-m-d'), floatval($recipeResolvedRow->costs_per_serving), null, null, $dummyTransactionId, 0, true); + $this->getStockService()->AddProduct($recipeRow->product_id, floatval($recipeRow->desired_servings), null, StockService::TRANSACTION_TYPE_SELF_PRODUCTION, date('Y-m-d'), floatval($recipeResolvedRow->costs_per_serving), null, null, $dummyTransactionId, $product->default_stock_label_type, true); } }