mirror of
https://github.com/grocy/grocy.git
synced 2025-08-20 04:12:59 +00:00
recipes can create products (#501)
This commit is contained in:
@@ -67,6 +67,15 @@ class RecipesService extends BaseService
|
||||
throw new \Exception('Recipe does not exist');
|
||||
}
|
||||
|
||||
$recipeRow = $this->Database->recipes()->where('id = :1', $recipeId)->fetch();
|
||||
if ($recipeRow->product_id != null)
|
||||
{
|
||||
$recipeResolvedRow = $this->Database->recipes_resolved()->where('recipe_id = :1', $recipeId)->fetch();
|
||||
$price = number_format($recipeResolvedRow->costs, 2);
|
||||
$bookingAmount = floatval($recipeRow->desired_servings);
|
||||
$this->StockService->AddProduct($recipeRow->product_id, $bookingAmount, null, StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d'), $price);
|
||||
}
|
||||
|
||||
$recipePositions = $this->Database->recipes_pos_resolved()->where('recipe_id', $recipeId)->fetchAll();
|
||||
foreach ($recipePositions as $recipePosition)
|
||||
{
|
||||
|
Reference in New Issue
Block a user