From 87330b90f493d6c90168276fc749334f32beee96 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 11 Mar 2014 09:54:55 +0100 Subject: [PATCH] Bug 11170: (follow-up) improve a bit of unnecessarily convoluted logic This patch also adds POD and UT for the change in SearchOrders() Signed-off-by: Jonathan Druart Signed-off-by: Galen Charlton --- C4/Acquisition.pm | 6 +++--- t/db_dependent/Acquisition.t | 20 +++++++++++++++++++- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm index 5b59519d84..7d493c9280 100644 --- a/C4/Acquisition.pm +++ b/C4/Acquisition.pm @@ -1630,12 +1630,14 @@ sub CancelReceipt { basketno => $basketno, owner => $owner, pending => $pending + ordered => $ordered }); Searches for orders. C<$owner> Finds order for the logged in user. C<$pending> Finds pending orders. Ignores completed and cancelled orders. +C<$ordered> Finds orders to receive only (status 'ordered' or 'partial'). C<@results> is an array of references-to-hash with the keys are fields @@ -1681,12 +1683,10 @@ sub SearchOrders { WHERE (datecancellationprinted is NULL) }; - if ( $pending ) { + if ( $pending or $ordered ) { $query .= q{ AND (quantity > quantityreceived OR quantityreceived is NULL)}; } if ( $ordered ) { - $query .= q{ AND (quantity > quantityreceived OR quantityreceived is NULL)} - unless $pending; $query .= q{ AND aqorders.orderstatus IN ( "ordered", "partial" )}; } diff --git a/t/db_dependent/Acquisition.t b/t/db_dependent/Acquisition.t index 87f0f0f8c9..e78b39cdbc 100755 --- a/t/db_dependent/Acquisition.t +++ b/t/db_dependent/Acquisition.t @@ -8,7 +8,7 @@ use POSIX qw(strftime); use C4::Bookseller qw( GetBookSellerFromId ); -use Test::More tests => 64; +use Test::More tests => 66; BEGIN { use_ok('C4::Acquisition'); @@ -700,6 +700,15 @@ ok( "SearchOrders with pending params gets only pending orders (bug 10723)" ); +$search_orders = SearchOrders({ + booksellerid => $booksellerid, + basketno => $basketno, + pending => 1, + ordered => 1, +}); +is( scalar (@$search_orders), 0, "SearchOrders with pending and ordered params gets only pending ordered orders (bug 11170)" ); + + # # Test GetBudgetByOrderNumber # @@ -760,6 +769,15 @@ is( join( " ", @$test_extra_fields ), is( join( " ", @$test_different_fields ), '', "GetLateOrders gets orders with the right content in every fields" ); +$search_orders = SearchOrders({ + booksellerid => $booksellerid, + basketno => $basketno, + pending => 1, + ordered => 1, +}); +is( scalar (@$search_orders), 3, "SearchOrders with pending and ordered params gets only pending ordered orders. After closing the basket, orders are marked as 'ordered' (bug 11170)" ); + + # # Test AddClaim # -- 2.39.5