mirror of
https://github.com/grocy/grocy.git
synced 2025-04-29 09:39:57 +00:00
Fix missing property warnings (references #1025)
This commit is contained in:
parent
e91bc0b01b
commit
a66a4d0c22
@ -527,21 +527,32 @@ class StockService extends BaseService
|
||||
$stockCurrentRow->is_aggregated_amount = 0;
|
||||
}
|
||||
|
||||
$productLastPurchased = $this->getDatabase()->products_last_purchased()->where('product_id', $productId)->fetch();
|
||||
$lastPurchasedDate = null;
|
||||
$lastPrice = null;
|
||||
$lastQuFactorPurchaseToStock = null;
|
||||
$lastShoppingLocation = null;
|
||||
$avgPrice = null;
|
||||
$oldestPrice = null;
|
||||
if ($productLastPurchased)
|
||||
{
|
||||
$lastPurchasedDate = $productLastPurchased->purchased_date;
|
||||
$lastPrice = $productLastPurchased->price;
|
||||
$lastQuFactorPurchaseToStock = $productLastPurchased->qu_factor_purchase_to_stock;
|
||||
$lastShoppingLocation = $productLastPurchased->shopping_location_id;
|
||||
$avgPrice = $this->getDatabase()->products_average_price()->where('product_id', $productId)->fetch()->price;
|
||||
$oldestPrice = $this->getDatabase()->products_oldest_stock_unit_price()->where('product_id', $productId)->fetch()->price;
|
||||
}
|
||||
|
||||
$product = $this->getDatabase()->products($productId);
|
||||
$productBarcodes = $this->getDatabase()->product_barcodes()->where('product_id', $productId)->fetchAll();
|
||||
$productLastPurchased = $this->getDatabase()->products_last_purchased()->where('product_id', $productId)->fetch();
|
||||
$productLastUsed = $this->getDatabase()->stock_log()->where('product_id', $productId)->where('transaction_type', self::TRANSACTION_TYPE_CONSUME)->where('undone', 0)->max('used_date');
|
||||
$nextBestBeforeDate = $this->getDatabase()->stock()->where('product_id', $productId)->min('best_before_date');
|
||||
$quPurchase = $this->getDatabase()->quantity_units($product->qu_id_purchase);
|
||||
$quStock = $this->getDatabase()->quantity_units($product->qu_id_stock);
|
||||
$location = $this->getDatabase()->locations($product->location_id);
|
||||
$averageShelfLifeDays = intval($this->getDatabase()->stock_average_product_shelf_life()->where('id', $productId)->fetch()->average_shelf_life_days);
|
||||
$lastPrice = $productLastPurchased->price;
|
||||
$lastQuFactorPurchaseToStock = $productLastPurchased->qu_factor_purchase_to_stock;
|
||||
$avgPrice = $this->getDatabase()->products_average_price()->where('product_id', $productId)->fetch();
|
||||
$oldestPrice = $this->getDatabase()->products_oldest_stock_unit_price()->where('product_id', $productId)->fetch();
|
||||
$defaultShoppingLocation = null;
|
||||
$lastShoppingLocation = $productLastPurchased->shopping_location_id;
|
||||
|
||||
$consumeCount = $this->getDatabase()->stock_log()->where('product_id', $productId)->where('transaction_type', self::TRANSACTION_TYPE_CONSUME)->where('undone = 0 AND spoiled = 0')->sum('amount') * -1;
|
||||
$consumeCountSpoiled = $this->getDatabase()->stock_log()->where('product_id', $productId)->where('transaction_type', self::TRANSACTION_TYPE_CONSUME)->where('undone = 0 AND spoiled = 1')->sum('amount') * -1;
|
||||
@ -556,7 +567,7 @@ class StockService extends BaseService
|
||||
return [
|
||||
'product' => $product,
|
||||
'product_barcodes' => $productBarcodes,
|
||||
'last_purchased' => $productLastPurchased->purchased_date,
|
||||
'last_purchased' => $lastPurchasedDate,
|
||||
'last_used' => $productLastUsed,
|
||||
'stock_amount' => $stockCurrentRow->amount,
|
||||
'stock_factor_purchase_amount' => $stockCurrentRow->factor_purchase_amount,
|
||||
@ -568,8 +579,8 @@ class StockService extends BaseService
|
||||
'quantity_unit_stock' => $quStock,
|
||||
'last_price' => $lastPrice,
|
||||
'last_qu_factor_purchase_to_stock' => $lastQuFactorPurchaseToStock,
|
||||
'avg_price' => $avgPrice->price,
|
||||
'oldest_price' => $oldestPrice->price,
|
||||
'avg_price' => $avgPrice,
|
||||
'oldest_price' => $oldestPrice,
|
||||
'last_shopping_location_id' => $lastShoppingLocation,
|
||||
'default_shopping_location_id' => $product->shopping_location_id,
|
||||
'next_best_before_date' => $nextBestBeforeDate,
|
||||
|
Loading…
x
Reference in New Issue
Block a user