From 1f8596ccb94bd2c9136fbb4db6b4398a2dc00a41 Mon Sep 17 00:00:00 2001 From: nullishamy Date: Sat, 15 Nov 2025 02:01:04 +0000 Subject: [PATCH] fix: products route --- controllers/GenericEntityApiController.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/controllers/GenericEntityApiController.php b/controllers/GenericEntityApiController.php index 1ea59f72..6fe49dca 100644 --- a/controllers/GenericEntityApiController.php +++ b/controllers/GenericEntityApiController.php @@ -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)'); } + 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->save(); $newObjectId = $this->getDatabase()->lastInsertId();