Optimized only_check_single_unit_in_stock recipe ingredient shopping list item handling related to QU conversions (closes #2545)

This commit is contained in:
Bernd Bestel 2025-01-13 23:01:42 +01:00
parent caa28af0d2
commit 645f9e2599
No known key found for this signature in database
GPG Key ID: 71BD34C0D4891300
2 changed files with 8 additions and 0 deletions

View File

@ -30,6 +30,7 @@
### Recipes
- Optimized that when adding missing recipe ingredients with the option "Only check if any amount is in stock" enabled to the shopping list and when no corresponding unit conversion exists, the amount/unit is now taken "as is" (as defined in the recipe ingredient) into the created shopping list item
- Fixed that calories/costs of recipe ingredients were wrong when the ingredient option "Only check if any amount is in stock" was set and the on the ingredient used quantity unit was different from the product's QU stock
- Fixed that multi-nested recipes (at least 3 levels of "included recipes") resulted in wrong amounts/costs/calories calculated for the ingredients orginating in those nested recipes (also affected the meal plan)

View File

@ -27,6 +27,7 @@ class RecipesService extends BaseService
{
$product = $this->getDataBase()->products($recipePosition->product_id);
$toOrderAmount = round(($recipePosition->missing_amount - $recipePosition->amount_on_shopping_list), 2);
$quId = $product->qu_id_stock;
if ($recipe->not_check_shoppinglist == 1)
{
@ -43,6 +44,11 @@ class RecipesService extends BaseService
{
$toOrderAmount = $toOrderAmount * $conversion->factor;
}
else
{
$quId = $recipePosition->qu_id;
$toOrderAmount = $recipePosition->missing_amount;
}
}
if ($toOrderAmount > 0)
@ -56,6 +62,7 @@ class RecipesService extends BaseService
$shoppinglistRow = $this->getDataBase()->shopping_list()->createRow([
'product_id' => $recipePosition->product_id,
'amount' => $toOrderAmount,
'qu_id' => $quId,
'note' => $note
]);
$shoppinglistRow->save();