mirror of
https://github.com/grocy/grocy.git
synced 2026-04-07 05:16: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;
|
$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)
|
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)
|
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;
|
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:
|
// In order of next use:
|
||||||
// First expiring first, then first in first out
|
// First expiring first, then first in first out
|
||||||
|
|
@ -621,8 +621,10 @@ class StockService extends BaseService
|
||||||
{
|
{
|
||||||
$sqlWhereAndOpen = 'AND open = 0';
|
$sqlWhereAndOpen = 'AND open = 0';
|
||||||
}
|
}
|
||||||
|
$result = $this->getDatabase()->stock()->where($sqlWhereProductId . ' ' . $sqlWhereAndOpen, $productId);
|
||||||
return $this->getDatabase()->stock()->where($sqlWhereProductId . ' ' . $sqlWhereAndOpen, $productId)->orderBy('best_before_date', 'ASC')->orderBy('purchased_date', 'ASC')->fetchAll();
|
if ($ordered)
|
||||||
|
return $result->orderBy('best_before_date', 'ASC')->orderBy('purchased_date', 'ASC');
|
||||||
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function GetProductStockEntriesForLocation($productId, $locationId, $excludeOpened = false, $allowSubproductSubstitution = false)
|
public function GetProductStockEntriesForLocation($productId, $locationId, $excludeOpened = false, $allowSubproductSubstitution = false)
|
||||||
|
|
@ -633,7 +635,7 @@ class StockService extends BaseService
|
||||||
|
|
||||||
public function GetProductStockLocations($productId)
|
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)
|
public function GetStockEntry($entryId)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user