Added a new API endpoint to get all stock entries per location

References https://www.reddit.com/r/grocy/comments/srfwfs
This commit is contained in:
Bernd Bestel
2022-02-13 20:34:49 +01:00
parent 2457c2c2fd
commit 66bd3f0d59
5 changed files with 83 additions and 0 deletions

View File

@@ -820,6 +820,16 @@ class StockService extends BaseService
return $result;
}
public function GetLocationStockEntries($locationId)
{
if (!$this->LocationExists($locationId))
{
throw new \Exception('Location does not exist');
}
return $this->getDatabase()->stock()->where('location_id', $locationId);
}
public function GetProductStockEntriesForLocation($productId, $locationId, $excludeOpened = false, $allowSubproductSubstitution = false)
{
$stockEntries = $this->GetProductStockEntries($productId, $excludeOpened, $allowSubproductSubstitution, true);