mirror of
				https://github.com/grocy/grocy.git
				synced 2025-10-31 10:46:36 +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