Filtering of API-Results (#985)

* Add FilteredApiResponse

* Use FilteredApiResponse for Generic-Entity-Search

* Use FilteredApiResponse for Recipe-Fullfillment

* Use FilteredApiResponse for GetUsers

* Use FilteredApiResponse for current Tasks

* Use FilteredApiResponse for ProductStockEntries & ProductStockLocations

* Use FilteredApiResponse for current chores

* Use FilteredApiResponse for batteries-current

* Fix missing highlighting of "< X days"

* Keep to use existing views

Co-authored-by: Bernd Bestel <bernd@berrnd.de>
This commit is contained in:
fipwmaqzufheoxq92ebc
2020-09-01 19:59:40 +02:00
committed by GitHub
parent 60f3d900e8
commit 32a4f81f62
21 changed files with 197 additions and 57 deletions

View File

@@ -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)