mirror of
https://github.com/grocy/grocy.git
synced 2025-08-20 04:12:59 +00:00
This commit is contained in:
@@ -46,6 +46,7 @@ class RecipesService extends BaseService
|
||||
}
|
||||
else
|
||||
{
|
||||
// No conversion exists => take the amount/unit as is
|
||||
$quId = $recipePosition->qu_id;
|
||||
$toOrderAmount = $recipePosition->missing_amount;
|
||||
}
|
||||
@@ -53,19 +54,24 @@ class RecipesService extends BaseService
|
||||
|
||||
if ($toOrderAmount > 0)
|
||||
{
|
||||
$note = $this->getLocalizationService()->__t('Added for recipe %s', $recipe->name);
|
||||
if (!empty($recipePosition->note))
|
||||
$alreadyExistingEntry = $this->getDatabase()->shopping_list()->where('product_id', $recipePosition->product_id)->fetch();
|
||||
if ($alreadyExistingEntry)
|
||||
{
|
||||
$note .= "\n" . $recipePosition->note;
|
||||
// Update
|
||||
$alreadyExistingEntry->update([
|
||||
'amount' => $alreadyExistingEntry->amount + $toOrderAmount
|
||||
]);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Insert
|
||||
$shoppinglistRow = $this->getDataBase()->shopping_list()->createRow([
|
||||
'product_id' => $recipePosition->product_id,
|
||||
'amount' => $toOrderAmount,
|
||||
'qu_id' => $quId
|
||||
]);
|
||||
$shoppinglistRow->save();
|
||||
}
|
||||
|
||||
$shoppinglistRow = $this->getDataBase()->shopping_list()->createRow([
|
||||
'product_id' => $recipePosition->product_id,
|
||||
'amount' => $toOrderAmount,
|
||||
'qu_id' => $quId,
|
||||
'note' => $note
|
||||
]);
|
||||
$shoppinglistRow->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -32,7 +32,6 @@ class StockService extends BaseService
|
||||
$amountToAdd = round($missingProduct->amount_missing, 2);
|
||||
|
||||
$alreadyExistingEntry = $this->getDatabase()->shopping_list()->where('product_id', $missingProduct->id)->fetch();
|
||||
|
||||
if ($alreadyExistingEntry)
|
||||
{
|
||||
// Update
|
||||
|
Reference in New Issue
Block a user