From 1c58a309f1bbbc3650924f2520b8b021a9b2a262 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 27 Jul 2018 15:48:23 -0300 Subject: [PATCH] Bug 15184: Add the ordernumbers filters to GetHistory MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit It adds the ability to return the result of GetHistory given a list a ordernumbers Sponsored-by: BULAC - http://www.bulac.fr/ Signed-off-by: Josef Moravec Signed-off-by: Séverine QUEUNE Signed-off-by: Katrin Fischer Signed-off-by: Nick Clemens --- C4/Acquisition.pm | 5 +++++ t/db_dependent/Acquisition.t | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm index 0cca6fe832..8646677360 100644 --- a/C4/Acquisition.pm +++ b/C4/Acquisition.pm @@ -2299,6 +2299,7 @@ sub GetHistory { my $ordernumber = $params{ordernumber}; my $search_children_too = $params{search_children_too} || 0; my $created_by = $params{created_by} || []; + my $ordernumbers = $params{ordernumbers} || []; my @order_loop; my $total_qty = 0; @@ -2459,6 +2460,10 @@ sub GetHistory { push @query_params, @$created_by; } + if ( @$ordernumbers ) { + $query .= ' AND (aqorders.ordernumber IN ( ' . join (',', ('?') x @$ordernumbers ) . '))'; + push @query_params, @$ordernumbers; + } if ( C4::Context->preference("IndependentBranches") ) { unless ( C4::Context->IsSuperLibrarian() ) { diff --git a/t/db_dependent/Acquisition.t b/t/db_dependent/Acquisition.t index 04687eb7a7..28ee67c5b8 100755 --- a/t/db_dependent/Acquisition.t +++ b/t/db_dependent/Acquisition.t @@ -19,7 +19,7 @@ use Modern::Perl; use POSIX qw(strftime); -use Test::More tests => 70; +use Test::More tests => 72; use t::lib::Mocks; use Koha::Database; @@ -438,6 +438,11 @@ my $orders = GetHistory( ordernumber => $ordernumbers[1] ); is( scalar( @$orders ), 1, 'GetHistory with a given ordernumber returns 1 order' ); $orders = GetHistory( ordernumber => $ordernumbers[1], search_children_too => 1 ); is( scalar( @$orders ), 2, 'GetHistory with a given ordernumber and search_children_too set returns 2 orders' ); +$orders = GetHistory( ordernumbers => [$ordernumbers[1]] ); +is( scalar( @$orders ), 1, 'GetHistory with a given ordernumbers returns 1 order' ); +$orders = GetHistory( ordernumbers => \@ordernumbers ); +is( scalar( @$orders ), scalar( @ordernumbers ) - 1, 'GetHistory with a list of ordernumbers returns N-1 orders (was has been deleted [3])' ); + # Test GetHistory() with and without SearchWithISBNVariations # The ISBN passed as a param is the ISBN-10 version of the 13-digit ISBN in the sample record declared in $marcxml -- 2.39.5