diff --git a/changelog/69_UNRELEASED_xxxx-xx-xx.md b/changelog/69_UNRELEASED_xxxx-xx-xx.md index 6b89ea67..9d9fb348 100644 --- a/changelog/69_UNRELEASED_xxxx-xx-xx.md +++ b/changelog/69_UNRELEASED_xxxx-xx-xx.md @@ -10,6 +10,7 @@ - Fixed that the average shelf life of a product (on the productcard) was wrong when the corresponding stock entry was edited - Fixed that when the stock setting "Decimal places allowed for amounts" was set to `0`, unit conversion (if any) failed when adding the corresponding product to stock +- Fixed that consuming a parent product which is not in stock itself (so essentially using any of the child products) may failed when unit conversions were involved (the current stock amount check was wrong in that case) ### Shopping list diff --git a/services/StockService.php b/services/StockService.php index 731e5c78..0565c5d0 100644 --- a/services/StockService.php +++ b/services/StockService.php @@ -406,7 +406,7 @@ class StockService extends BaseService $potentialStockEntries = FindAllObjectsInArrayByPropertyValue($potentialStockEntries, 'stock_id', $specificStockEntryId); } - $productStockAmount = SumArrayValue($potentialStockEntries, 'amount'); + $productStockAmount = floatval($productDetails->stock_amount_aggregated); if ($amount > $productStockAmount) { throw new \Exception('Amount to be consumed cannot be > current stock amount (if supplied, at the desired location)');