mirror of
https://github.com/grocy/grocy.git
synced 2025-04-29 09:39:57 +00:00
Merge pull request #343 from Forceu/master
API: Return stock amount of 0 instead of null, if product is not in stock
This commit is contained in:
commit
f88ed1ee8a
@ -78,6 +78,10 @@ class StockService extends BaseService
|
||||
|
||||
$product = $this->Database->products($productId);
|
||||
$productStockAmount = $this->Database->stock()->where('product_id', $productId)->sum('amount');
|
||||
if ($productStockAmount == null)
|
||||
{
|
||||
$productStockAmount = 0;
|
||||
}
|
||||
$productStockAmountOpened = $this->Database->stock()->where('product_id = :1 AND open = 1', $productId)->sum('amount');
|
||||
$productLastPurchased = $this->Database->stock_log()->where('product_id', $productId)->where('transaction_type', self::TRANSACTION_TYPE_PURCHASE)->where('undone', 0)->max('purchased_date');
|
||||
$productLastUsed = $this->Database->stock_log()->where('product_id', $productId)->where('transaction_type', self::TRANSACTION_TYPE_CONSUME)->where('undone', 0)->max('used_date');
|
||||
|
Loading…
x
Reference in New Issue
Block a user