From 4bdfd23d3fdc5e1136eaa381f24ee768b39f9271 Mon Sep 17 00:00:00 2001
From: Aleisha Amohia <aleishaamohia@hotmail.com>
Date: Mon, 9 Nov 2020 10:19:11 +1300
Subject: [PATCH] Bug 19532: (follow-up) Fixing tests and QA tools

And making reverted ajax message clearer

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: David Nind <david@davidnind.com>
---
 Koha/Recalls.pm                            | 2 +-
 koha-tmpl/intranet-tmpl/prog/js/recalls.js | 2 +-
 opac/opac-recall.pl                        | 2 +-
 opac/opac-recalls.pl                       | 2 +-
 recalls/recall_pickup_slip.pl              | 2 +-
 recalls/recalls_old_queue.pl               | 2 +-
 recalls/recalls_overdue.pl                 | 2 +-
 recalls/recalls_queue.pl                   | 2 +-
 recalls/recalls_to_pull.pl                 | 2 +-
 recalls/recalls_waiting.pl                 | 2 +-
 svc/recall                                 | 2 +-
 t/db_dependent/Koha/Recalls.t              | 4 ++--
 12 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/Koha/Recalls.pm b/Koha/Recalls.pm
index e454499f67..55b6e3656d 100644
--- a/Koha/Recalls.pm
+++ b/Koha/Recalls.pm
@@ -183,7 +183,7 @@ sub move_recall {
 
     if ( $message eq 'no action provided' and $item and $item->biblionumber and $borrowernumber ) {
         # move_recall was not called to revert or cancel, but was called to fulfill
-        my $recall = Koha::Recalls->find({ borrowernumber => $borrowernumber, biblionumber => $item->biblionumber, itemnumber => [ $item->itemnumber, undef ], old => undef });
+        my $recall = Koha::Recalls->search({ borrowernumber => $borrowernumber, biblionumber => $item->biblionumber, itemnumber => [ $item->itemnumber, undef ], old => undef }, { order_by => { -asc => 'recalldate' } })->next;
         if ( $recall ) {
             $recall->set_finished;
             $message = 'fulfilled';
diff --git a/koha-tmpl/intranet-tmpl/prog/js/recalls.js b/koha-tmpl/intranet-tmpl/prog/js/recalls.js
index c45a6c8f19..e4a791d795 100644
--- a/koha-tmpl/intranet-tmpl/prog/js/recalls.js
+++ b/koha-tmpl/intranet-tmpl/prog/js/recalls.js
@@ -77,7 +77,7 @@ $(document).ready(function() {
                     if(data.success == 0) {
                         message = __("The recall waiting status may have already been reverted. Please refresh the page.");
                     } else {
-                        message = __("Status updated");
+                        message = __("Waiting status reverted");
                     }
                     $self.parent().parent().parent().parent().html(message);
                 });
diff --git a/opac/opac-recall.pl b/opac/opac-recall.pl
index 779a126b84..f677832448 100755
--- a/opac/opac-recall.pl
+++ b/opac/opac-recall.pl
@@ -23,7 +23,7 @@ use C4::Auth qw( get_template_and_user );
 use C4::Output qw( output_html_with_http_headers );
 use C4::Context;
 
-my $query = new CGI;
+my $query = CGI->new;
 my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
     {
         template_name   => "opac-recall.tt",
diff --git a/opac/opac-recalls.pl b/opac/opac-recalls.pl
index 59c657bf59..f3a9b5f8b4 100755
--- a/opac/opac-recalls.pl
+++ b/opac/opac-recalls.pl
@@ -23,7 +23,7 @@ use C4::Auth qw( get_template_and_user );
 use C4::Output qw( output_html_with_http_headers );
 use Koha::Recalls;
 
-my $input = new CGI;
+my $input = CGI->new;
 my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
    {
       template_name   => "opac-recalls.tt",
diff --git a/recalls/recall_pickup_slip.pl b/recalls/recall_pickup_slip.pl
index 7137e59571..7f4042e5d4 100755
--- a/recalls/recall_pickup_slip.pl
+++ b/recalls/recall_pickup_slip.pl
@@ -23,7 +23,7 @@ use C4::Context;
 use C4::Output qw( output_html_with_http_headers );
 use C4::Auth qw( get_template_and_user );
 
-my $input = new CGI;
+my $input = CGI->new;
 
 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
     {
diff --git a/recalls/recalls_old_queue.pl b/recalls/recalls_old_queue.pl
index bdabc46b7d..64370aa132 100755
--- a/recalls/recalls_old_queue.pl
+++ b/recalls/recalls_old_queue.pl
@@ -22,7 +22,7 @@ use C4::Auth qw( get_template_and_user );
 use C4::Output qw( output_html_with_http_headers );
 use Koha::BiblioFrameworks;
 
-my $query = new CGI;
+my $query = CGI->new;
 my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user(
     {
       template_name   => "recalls/recalls_old_queue.tt",
diff --git a/recalls/recalls_overdue.pl b/recalls/recalls_overdue.pl
index 3c73dd34e7..c0454d1900 100755
--- a/recalls/recalls_overdue.pl
+++ b/recalls/recalls_overdue.pl
@@ -23,7 +23,7 @@ use C4::Output qw( output_html_with_http_headers );
 use Koha::BiblioFrameworks;
 use Koha::DateUtils;
 
-my $query = new CGI;
+my $query = CGI->new;
 my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user(
     {
        template_name   => "recalls/recalls_overdue.tt",
diff --git a/recalls/recalls_queue.pl b/recalls/recalls_queue.pl
index 5676ca815f..197c02f27a 100755
--- a/recalls/recalls_queue.pl
+++ b/recalls/recalls_queue.pl
@@ -22,7 +22,7 @@ use C4::Auth qw( get_template_and_user );
 use C4::Output qw( output_html_with_http_headers );
 use Koha::BiblioFrameworks;
 
-my $query = new CGI;
+my $query = CGI->new;
 my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user(
     {
       template_name   => "recalls/recalls_queue.tt",
diff --git a/recalls/recalls_to_pull.pl b/recalls/recalls_to_pull.pl
index 5b2bfbddd4..7ac95be349 100755
--- a/recalls/recalls_to_pull.pl
+++ b/recalls/recalls_to_pull.pl
@@ -22,7 +22,7 @@ use C4::Auth qw( get_template_and_user );
 use C4::Output qw( output_html_with_http_headers );
 use Koha::BiblioFrameworks;
 
-my $query = new CGI;
+my $query = CGI->new;
 my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user(
     {
       template_name   => "recalls/recalls_to_pull.tt",
diff --git a/recalls/recalls_waiting.pl b/recalls/recalls_waiting.pl
index f18d5c0367..30511c6e33 100755
--- a/recalls/recalls_waiting.pl
+++ b/recalls/recalls_waiting.pl
@@ -25,7 +25,7 @@ use Koha::BiblioFrameworks;
 use Koha::DateUtils;
 use Koha::Patrons;
 
-my $query = new CGI;
+my $query = CGI->new;
 my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user(
     {
         template_name   => "recalls/recalls_waiting.tt",
diff --git a/svc/recall b/svc/recall
index 35c24585ff..3c7970019a 100755
--- a/svc/recall
+++ b/svc/recall
@@ -27,7 +27,7 @@ use C4::Output qw(output_with_http_headers);
 use C4::Circulation qw(AddReturn);
 use Koha::Recalls;
 
-my $input = new CGI;
+my $input = CGI->new;
 my $json = encode_json({ success => 0 });
 
 my ( $auth_status, $sessionID ) = check_cookie_auth( $input->cookie('CGISESSID'), { recall => 'manage_recalls' } );
diff --git a/t/db_dependent/Koha/Recalls.t b/t/db_dependent/Koha/Recalls.t
index 07f8d9f1ad..32dc9e96ba 100755
--- a/t/db_dependent/Koha/Recalls.t
+++ b/t/db_dependent/Koha/Recalls.t
@@ -43,7 +43,7 @@ my $item1 = $builder->build_sample_item();
 my $biblio1 = $item1->biblio;
 my $branch1 = $item1->holdingbranch;
 my $itemtype1 = $item1->effective_itemtype;
-my $item2 = $builder->build_sample_item();
+my $item2 = $builder->build_sample_item({ biblionumber => $biblio1->biblionumber });
 my $biblio2 = $item1->biblio;
 my $branch2 = $item1->holdingbranch;
 my $itemtype2 = $item1->effective_itemtype;
@@ -168,7 +168,7 @@ ok( $recall->cancelled, "Recall cancelled with move_recall" );
     expirationdate => undef,
     interface => 'COMMANDLINE',
 });
-$message = Koha::Recalls->move_recall({ recall_id => $recall->recall_id, itemnumber => $item2->itemnumber, borrowernumber => $patron1->borrowernumber });
+$message = Koha::Recalls->move_recall({ recall_id => $recall->recall_id, item => $item2, borrowernumber => $patron1->borrowernumber });
 $recall = Koha::Recalls->find( $recall->recall_id );
 ok( $recall->finished, "Recall fulfilled with move_recall" );
 
-- 
2.20.1