mirror of
https://github.com/grocy/grocy.git
synced 2025-08-20 12:20:22 +00:00
Don't allow amounts <= 0 on purchase/consume
References https://github.com/grocy/grocy/issues/2156#issuecomment-2040336492
This commit is contained in:
@@ -113,6 +113,12 @@ class StockService extends BaseService
|
||||
throw new \Exception('Product does not exist or is inactive');
|
||||
}
|
||||
|
||||
|
||||
if ($amount <= 0)
|
||||
{
|
||||
throw new \Exception('Amount can\'t be <= 0');
|
||||
}
|
||||
|
||||
$productDetails = (object)$this->GetProductDetails($productId);
|
||||
|
||||
// Tare weight handling
|
||||
@@ -356,6 +362,11 @@ class StockService extends BaseService
|
||||
throw new \Exception('Product does not exist or is inactive');
|
||||
}
|
||||
|
||||
if ($amount <= 0)
|
||||
{
|
||||
throw new \Exception('Amount can\'t be <= 0');
|
||||
}
|
||||
|
||||
if ($locationId !== null && !$this->LocationExists($locationId))
|
||||
{
|
||||
throw new \Exception('Location does not exist');
|
||||
|
Reference in New Issue
Block a user