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
2 changed files with 8 additions and 0 deletions

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();