mirror of
https://github.com/grocy/grocy.git
synced 2025-08-19 03:40:10 +00:00
Some refinements for #501
This commit is contained in:
@@ -67,15 +67,6 @@ 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)
|
||||
{
|
||||
@@ -84,6 +75,13 @@ class RecipesService extends BaseService
|
||||
$this->StockService->ConsumeProduct($recipePosition->product_id, $recipePosition->recipe_amount, false, StockService::TRANSACTION_TYPE_CONSUME, 'default', $recipeId);
|
||||
}
|
||||
}
|
||||
|
||||
$recipeRow = $this->Database->recipes()->where('id = :1', $recipeId)->fetch();
|
||||
if (!empty($recipeRow->product_id))
|
||||
{
|
||||
$recipeResolvedRow = $this->Database->recipes_resolved()->where('recipe_id = :1', $recipeId)->fetch();
|
||||
$this->StockService->AddProduct($recipeRow->product_id, floatval($recipeRow->desired_servings), null, StockService::TRANSACTION_TYPE_SELF_PRODUCTION, date('Y-m-d'), floatval($recipeResolvedRow->costs));
|
||||
}
|
||||
}
|
||||
|
||||
private function RecipeExists($recipeId)
|
||||
|
Reference in New Issue
Block a user