mirror of
https://github.com/grocy/grocy.git
synced 2026-04-06 21:06:15 +02:00
Use FilteredApiResponse for ProductStockEntries & ProductStockLocations
This commit is contained in:
parent
c99c7c3859
commit
076e8df7d3
|
|
@ -552,12 +552,12 @@ class StockApiController extends BaseApiController
|
|||
$allowSubproductSubstitution = true;
|
||||
}
|
||||
|
||||
return $this->ApiResponse($response, $this->getStockService()->GetProductStockEntries($args['productId'], false, $allowSubproductSubstitution));
|
||||
return $this->FilteredApiResponse($response, $this->getStockService()->GetProductStockEntries($args['productId'], false, $allowSubproductSubstitution, false), $request->getQueryParams());
|
||||
}
|
||||
|
||||
public function ProductStockLocations(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
|
||||
{
|
||||
return $this->ApiResponse($response, $this->getStockService()->GetProductStockLocations($args['productId']));
|
||||
return $this->FilteredApiResponse($response, $this->getStockService()->GetProductStockLocations($args['productId']), $request->getQueryParams());
|
||||
}
|
||||
|
||||
public function RemoveProductFromShoppingList(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
|
||||
|
|
|
|||
|
|
@ -603,7 +603,7 @@ class StockService extends BaseService
|
|||
return $returnData;
|
||||
}
|
||||
|
||||
public function GetProductStockEntries($productId, $excludeOpened = false, $allowSubproductSubstitution = false)
|
||||
public function GetProductStockEntries($productId, $excludeOpened = false, $allowSubproductSubstitution = false, $ordered = true)
|
||||
{
|
||||
// In order of next use:
|
||||
// First expiring first, then first in first out
|
||||
|
|
@ -621,8 +621,10 @@ class StockService extends BaseService
|
|||
{
|
||||
$sqlWhereAndOpen = 'AND open = 0';
|
||||
}
|
||||
|
||||
return $this->getDatabase()->stock()->where($sqlWhereProductId . ' ' . $sqlWhereAndOpen, $productId)->orderBy('best_before_date', 'ASC')->orderBy('purchased_date', 'ASC')->fetchAll();
|
||||
$result = $this->getDatabase()->stock()->where($sqlWhereProductId . ' ' . $sqlWhereAndOpen, $productId);
|
||||
if ($ordered)
|
||||
return $result->orderBy('best_before_date', 'ASC')->orderBy('purchased_date', 'ASC');
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function GetProductStockEntriesForLocation($productId, $locationId, $excludeOpened = false, $allowSubproductSubstitution = false)
|
||||
|
|
@ -633,7 +635,7 @@ class StockService extends BaseService
|
|||
|
||||
public function GetProductStockLocations($productId)
|
||||
{
|
||||
return $this->getDatabase()->stock_current_locations()->where('product_id', $productId)->fetchAll();
|
||||
return $this->getDatabase()->stock_current_locations()->where('product_id', $productId);
|
||||
}
|
||||
|
||||
public function GetStockEntry($entryId)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user