mirror of
https://github.com/grocy/grocy.git
synced 2025-08-20 04:12:59 +00:00
Fixed missing recipe ingredient amount when "Only check if any amount is in stock" is enabled and when there are unit conversions (fixes #1718)
This commit is contained in:
@@ -36,6 +36,18 @@ class RecipesService extends BaseService
|
||||
$toOrderAmount = round($recipePosition->missing_amount, 2);
|
||||
}
|
||||
|
||||
// When the recipe ingredient option "Only check if any amount is in stock" is enabled,
|
||||
// any QU can be used and the amount is not based on qu_stock then
|
||||
// => Do the unit conversion here (if any)
|
||||
if ($recipePosition->only_check_single_unit_in_stock == 1)
|
||||
{
|
||||
$conversion = $this->getDatabase()->quantity_unit_conversions_resolved()->where('product_id = :1 AND from_qu_id = :2 AND to_qu_id = :3', $recipePosition->product_id, $recipePosition->qu_id, $product->qu_id_stock)->fetch();
|
||||
if ($conversion != null)
|
||||
{
|
||||
$toOrderAmount = $toOrderAmount * floatval($conversion->factor);
|
||||
}
|
||||
}
|
||||
|
||||
if ($toOrderAmount > 0)
|
||||
{
|
||||
$note = $this->getLocalizationService()->__t('Added for recipe %s', $recipe->name);
|
||||
|
Reference in New Issue
Block a user