Fixed StockService->ConsumeProduct $productStockAmount check (fixes #1949)

This commit is contained in:
Bernd Bestel 2022-07-18 17:35:35 +02:00
parent e64df711e2
commit 0b532f7624
No known key found for this signature in database
GPG Key ID: 71BD34C0D4891300
2 changed files with 2 additions and 1 deletions

View File

@ -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

View File

@ -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)');