mirror of
https://github.com/grocy/grocy.git
synced 2025-08-20 20:26:42 +00:00
Optimized only_check_single_unit_in_stock recipe ingredient shopping list item handling related to QU conversions (closes #2545)
This commit is contained in:
@@ -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();
|
||||
|
Reference in New Issue
Block a user