From b5fe0a642bff4c421eee67b7406c4a8a86ae6f57 Mon Sep 17 00:00:00 2001 From: Bernd Bestel Date: Sat, 22 Apr 2017 21:51:07 +0200 Subject: [PATCH] Load also last purchased date from stock_log instead of stock --- GrocyLogicStock.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GrocyLogicStock.php b/GrocyLogicStock.php index d104bcf3..a6fc533f 100644 --- a/GrocyLogicStock.php +++ b/GrocyLogicStock.php @@ -24,7 +24,7 @@ class GrocyLogicStock $product = $db->products($productId); $productStockAmount = $db->stock()->where('product_id', $productId)->sum('amount'); - $productLastPurchased = $db->stock()->where('product_id', $productId)->max('purchased_date'); + $productLastPurchased = $db->stock_log()->where('product_id', $productId)->where('transaction_type', self::TRANSACTION_TYPE_PURCHASE)->max('purchased_date'); $productLastUsed = $db->stock_log()->where('product_id', $productId)->where('transaction_type', self::TRANSACTION_TYPE_CONSUME)->max('used_date'); $quPurchase = $db->quantity_units($product->qu_id_purchase); $quStock = $db->quantity_units($product->qu_id_stock);