From 6165c865bf598db8fc6ea2da9c6f0ed0aef0eb4f Mon Sep 17 00:00:00 2001 From: William Mead Date: Sun, 9 Nov 2025 20:16:28 +0100 Subject: [PATCH] NEW stock API GET movement (#36193) * Added stock movement GET method * Updated PHPDoc --------- Co-authored-by: Laurent Destailleur --- .../stock/class/api_stockmovements.class.php | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/htdocs/product/stock/class/api_stockmovements.class.php b/htdocs/product/stock/class/api_stockmovements.class.php index 41c351ec44d..258e6485531 100644 --- a/htdocs/product/stock/class/api_stockmovements.class.php +++ b/htdocs/product/stock/class/api_stockmovements.class.php @@ -61,31 +61,33 @@ class StockMovements extends DolibarrApi * * Return an array with stock movement information * - * @since 5.0.0 Initial implementation + * @since 23.0.0 Initial implementation * - * @param int $id ID of movement - * @return Object Object with cleaned properties + * @param int $id ID of stock movement + * @return Object Stock movement object with cleaned properties * - * @throws RestException + * @url GET {id} + * + * @throws RestException 400 Bad Request + * @throws RestException 403 Not allowed + * @throws RestException 404 Not found + * @throws RestException 500 Internal Server Error */ - /* public function get($id) { - if (!DolibarrApiAccess::$user->hasRight('stock', 'lire')) { + if (!DolibarrApiAccess::$user->hasRight('stock', 'mouvement', 'lire')) { throw new RestException(403); } - + if ($id == 0) { + throw new RestException(400, 'No stock movement with id 0 can exist'); + } $result = $this->stockmovement->fetch($id); if (!$result ) { - throw new RestException(404, 'warehouse not found'); - } - - if (!DolibarrApi::_checkAccessToResource('warehouse',$this->stockmovement->id)) { - throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + throw new RestException(404, 'stock movement not found'); } return $this->_cleanObjectDatas($this->stockmovement); - }*/ + } /** * Get a list of stock movements