fix: products route

This commit is contained in:
nullishamy 2025-11-15 02:01:04 +00:00
parent 7d104d2384
commit 1f8596ccb9
No known key found for this signature in database

View File

@ -47,6 +47,16 @@ class GenericEntityApiController extends BaseApiController
throw new \Exception('Request body could not be parsed (probably invalid JSON format or missing/wrong Content-Type header)'); throw new \Exception('Request body could not be parsed (probably invalid JSON format or missing/wrong Content-Type header)');
} }
if ($args['entity'] == 'products' && (!isset($requestBody['qu_id_purchase']) || empty($requestBody['qu_id_purchase'])))
{
return $this->GenericErrorResponse($response, 'Product does not have Quantity unit purchase defined');
}
if ($args['entity'] == 'products' && (!isset($requestBody['qu_id_stock']) || empty($requestBody['qu_id_stock'])))
{
return $this->GenericErrorResponse($response, 'Product does not have Quantity unit stock defined');
}
$newRow = $this->getDatabase()->{$args['entity']}()->createRow($requestBody); $newRow = $this->getDatabase()->{$args['entity']}()->createRow($requestBody);
$newRow->save(); $newRow->save();
$newObjectId = $this->getDatabase()->lastInsertId(); $newObjectId = $this->getDatabase()->lastInsertId();