From b4b29878db6f93c57c427c6d9642702b65e84b9b Mon Sep 17 00:00:00 2001 From: Bernd Bestel Date: Sat, 22 Apr 2017 21:15:30 +0200 Subject: [PATCH] Change FIFO to "First expiring first, then first in first out" --- GrocyLogicStock.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GrocyLogicStock.php b/GrocyLogicStock.php index 4a00f3e0..d104bcf3 100644 --- a/GrocyLogicStock.php +++ b/GrocyLogicStock.php @@ -80,7 +80,7 @@ class GrocyLogicStock $db = Grocy::GetDbConnection(); $productStockAmount = $db->stock()->where('product_id', $productId)->sum('amount'); - $potentialStockEntries = $db->stock()->where('product_id', $productId)->orderBy('purchased_date', 'ASC')->fetchAll(); //FIFO + $potentialStockEntries = $db->stock()->where('product_id', $productId)->orderBy('best_before_date', 'ASC')->orderBy('purchased_date', 'ASC')->fetchAll(); //First expiring first, then first in first out if ($amount > $productStockAmount) {