From 70d51c757bac946f4a7c5cdbc4aa8d9661f79793 Mon Sep 17 00:00:00 2001 From: Bernd Bestel Date: Tue, 6 Jul 2021 19:31:55 +0200 Subject: [PATCH] Only show in-stock products on the /consume page (closes #1429) --- changelog/62_UNRELEASED_xxxx-xx-xx.md | 1 + controllers/StockController.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/changelog/62_UNRELEASED_xxxx-xx-xx.md b/changelog/62_UNRELEASED_xxxx-xx-xx.md index 68412c81..b214f52f 100644 --- a/changelog/62_UNRELEASED_xxxx-xx-xx.md +++ b/changelog/62_UNRELEASED_xxxx-xx-xx.md @@ -28,6 +28,7 @@ ### Stock improvements/fixes - Product barcodes are now enforced to be unique across products - On the stock overview page it's now also possible to search/filter by product barcodes (via the general search field) +- The product picker on the consume page now only shows products which are currently in stock - Fixed that editing stock entries was not possible - Fixed that consuming with Scan Mode was not possible - Fixed that the current stock total value (header of the stock overview page) didn't include decimal amounts (thanks @Ape) diff --git a/controllers/StockController.php b/controllers/StockController.php index 7b606aa4..4f6c38d7 100644 --- a/controllers/StockController.php +++ b/controllers/StockController.php @@ -11,7 +11,7 @@ class StockController extends BaseController public function Consume(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args) { return $this->renderPage($response, 'consume', [ - 'products' => $this->getDatabase()->products()->where('active = 1')->orderBy('name'), + 'products' => $this->getDatabase()->products()->where('active = 1')->where('id IN (SELECT product_id from stock_current WHERE amount_aggregated > 0)')->orderBy('name'), 'barcodes' => $this->getDatabase()->product_barcodes_comma_separated(), 'recipes' => $this->getDatabase()->recipes()->where('type', RecipesService::RECIPE_TYPE_NORMAL)->orderBy('name', 'COLLATE NOCASE'), 'locations' => $this->getDatabase()->locations()->orderBy('name', 'COLLATE NOCASE'),