mirror of
https://github.com/grocy/grocy.git
synced 2025-08-20 12:20:22 +00:00
Prevent opening more products than are unopened in stock
This commit is contained in:
@@ -265,11 +265,11 @@ class StockService extends BaseService
|
||||
throw new \Exception('Product does not exist');
|
||||
}
|
||||
|
||||
$productStockAmount = $this->Database->stock()->where('product_id', $productId)->sum('amount');
|
||||
$productStockAmountUnopened = $this->Database->stock()->where('product_id = :1 AND open = 0', $productId)->sum('amount');
|
||||
$potentialStockEntries = $this->GetProductStockEntries($productId, true);
|
||||
$product = $this->Database->products($productId);
|
||||
|
||||
if ($amount > $productStockAmount)
|
||||
if ($amount > $productStockAmountUnopened)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
Reference in New Issue
Block a user