Don't allow amounts <= 0 on purchase/consume

References https://github.com/grocy/grocy/issues/2156#issuecomment-2040336492
This commit is contained in:
Bernd Bestel 2024-04-05 20:12:11 +02:00
parent 6602c76005
commit af1f2aef96
No known key found for this signature in database
GPG Key ID: 71BD34C0D4891300

View File

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