mirror of
https://github.com/grocy/grocy.git
synced 2026-04-07 21:26:16 +02:00
Fixes #1035: Check available amount after filtering by stock_entry_id
This commit is contained in:
parent
9c92ec4748
commit
ed1607c123
|
|
@ -249,6 +249,11 @@ class StockService extends BaseService
|
||||||
$potentialStockEntries = $this->GetProductStockEntriesForLocation($productId, $locationId, false, $allowSubproductSubstitution);
|
$potentialStockEntries = $this->GetProductStockEntriesForLocation($productId, $locationId, false, $allowSubproductSubstitution);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($specificStockEntryId !== 'default')
|
||||||
|
{
|
||||||
|
$potentialStockEntries = FindAllObjectsInArrayByPropertyValue($potentialStockEntries, 'stock_id', $specificStockEntryId);
|
||||||
|
}
|
||||||
|
|
||||||
$productStockAmount = SumArrayValue($potentialStockEntries, 'amount');
|
$productStockAmount = SumArrayValue($potentialStockEntries, 'amount');
|
||||||
|
|
||||||
if ($amount > $productStockAmount)
|
if ($amount > $productStockAmount)
|
||||||
|
|
@ -256,11 +261,6 @@ class StockService extends BaseService
|
||||||
throw new \Exception('Amount to be consumed cannot be > current stock amount (if supplied, at the desired location)');
|
throw new \Exception('Amount to be consumed cannot be > current stock amount (if supplied, at the desired location)');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($specificStockEntryId !== 'default')
|
|
||||||
{
|
|
||||||
$potentialStockEntries = FindAllObjectsInArrayByPropertyValue($potentialStockEntries, 'stock_id', $specificStockEntryId);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($transactionId === null)
|
if ($transactionId === null)
|
||||||
{
|
{
|
||||||
$transactionId = uniqid();
|
$transactionId = uniqid();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user