mirror of
https://github.com/grocy/grocy.git
synced 2026-04-05 20:36:15 +02:00
services StockService#GetProductStockEntriesByLocation: add method
This commit is contained in:
parent
c7e763fd5c
commit
00f7a241f6
|
|
@ -176,6 +176,21 @@ class StockService extends BaseService
|
|||
}
|
||||
}
|
||||
|
||||
public function GetProductStockEntriesByLocation($productId, $locationId, $excludeOpened = false)
|
||||
{
|
||||
// In order of next use:
|
||||
// First expiring first, then first in first out
|
||||
|
||||
if ($excludeOpened)
|
||||
{
|
||||
return $this->Database->stock()->where('product_id = :1 AND location_id = :2 AND open = 0', $productId, $locationId)->orderBy('best_before_date', 'ASC')->orderBy('purchased_date', 'ASC')->fetchAll();
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->Database->stock()->where('product_id = :1 AND location_id = :2', $productId, $locationId)->orderBy('best_before_date', 'ASC')->orderBy('purchased_date', 'ASC')->fetchAll();
|
||||
}
|
||||
}
|
||||
|
||||
public function AddProduct(int $productId, float $amount, $bestBeforeDate, $transactionType, $purchasedDate, $price, $locationId = null)
|
||||
{
|
||||
if (!$this->ProductExists($productId))
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user