From 45539696c16669dbc26810e403fccba48c2129f1 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Tue, 30 Oct 2018 11:59:26 +0000 Subject: [PATCH] Bug 21725: Use full statement in HAVING rather than constructed column To test: 1 - prove -v t/db_dpendent/Acquisition/GetBasketsInfosByBookseller.t 2 - Apply patch 3 - prove -v t/db_dpendent/Acquisition/GetBasketsInfosByBookseller.t 4 - It passes 5 - Have some open/closed and some fully and not full received baskets 6 - View a vendor and confirm baskets are shwn as expected 7 - Check 'Show all baskets' shows all baskets Signed-off-by: Martin Renvoize Signed-off-by: Jonathan Druart Note sure this is the best thing but it fixes the issue Signed-off-by: Nick Clemens (cherry picked from commit b5c456479da6a1033f9a697ca1bcf4295920aeb1) Signed-off-by: Martin Renvoize --- C4/Acquisition.pm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm index f7601a6c89..8f8424e0e6 100644 --- a/C4/Acquisition.pm +++ b/C4/Acquisition.pm @@ -713,7 +713,13 @@ sub GetBasketsInfosByBookseller { unless ( $allbaskets ) { # Don't show the basket if it's NOT CLOSED or is FULLY RECEIVED - $query.=" HAVING (closedate IS NULL OR (expected_items > 0))" + $query.=" HAVING (closedate IS NULL OR ( + SUM( + IF(aqorders.datereceived IS NULL + AND (aqorders.datecancellationprinted IS NULL OR aqorders.datecancellationprinted='0000-00-00') + , aqorders.quantity + , 0) + ) > 0))" } my $sth = $dbh->prepare($query); -- 2.39.5