From e5c7e9c4443e433e90cce599254d24b81b3c0de2 Mon Sep 17 00:00:00 2001
From: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Date: Wed, 10 May 2023 15:19:38 +0200
Subject: [PATCH] Bug 28844: Remove GetSuggestionInfoFromBiblionumber

---
 C4/Suggestions.pm            | 28 ----------------------------
 acqui/orderreceive.pl        |  6 ------
 t/db_dependent/Suggestions.t | 19 ++-----------------
 3 files changed, 2 insertions(+), 51 deletions(-)

diff --git a/C4/Suggestions.pm b/C4/Suggestions.pm
index 14c6b203c1b..29c092426cc 100644
--- a/C4/Suggestions.pm
+++ b/C4/Suggestions.pm
@@ -36,7 +36,6 @@ our @EXPORT  = qw(
   GetSuggestion
   GetSuggestionByStatus
   GetSuggestionFromBiblionumber
-  GetSuggestionInfoFromBiblionumber
   GetSuggestionInfo
   ModStatus
   ModSuggestion
@@ -119,33 +118,6 @@ sub GetSuggestionFromBiblionumber {
     return $suggestionid;
 }
 
-=head2 GetSuggestionInfoFromBiblionumber
-
-Get a suggestion and borrower's informations from it's biblionumber.
-
-return :
-all informations (suggestion and borrower) of the suggestion which is related to the biblionumber given.
-
-=cut
-
-sub GetSuggestionInfoFromBiblionumber {
-    my ($biblionumber) = @_;
-    my $query = q{
-        SELECT suggestions.*,
-            U1.surname          AS surnamesuggestedby,
-            U1.firstname        AS firstnamesuggestedby,
-            U1.borrowernumber   AS borrnumsuggestedby
-        FROM suggestions
-            LEFT JOIN borrowers AS U1 ON suggestedby=U1.borrowernumber
-        WHERE biblionumber=?
-        LIMIT 1
-    };
-    my $dbh = C4::Context->dbh;
-    my $sth = $dbh->prepare($query);
-    $sth->execute($biblionumber);
-    return $sth->fetchrow_hashref;
-}
-
 =head2 GetSuggestionInfo
 
 Get a suggestion and borrower's informations from it's suggestionid
diff --git a/acqui/orderreceive.pl b/acqui/orderreceive.pl
index 2ca33d16471..770c9e88452 100755
--- a/acqui/orderreceive.pl
+++ b/acqui/orderreceive.pl
@@ -133,12 +133,6 @@ if ($order) {
         $template->param( orders => $orders, );
     }
 
-    my $suggestion = GetSuggestionInfoFromBiblionumber( $order->biblionumber );
-
-    if ($suggestion) {
-        $template->param( suggestion => $suggestion );
-    }
-
     $template->param(
         order              => $order,
         creator            => $creator,
diff --git a/t/db_dependent/Suggestions.t b/t/db_dependent/Suggestions.t
index abcbd626c50..31d389752b5 100755
--- a/t/db_dependent/Suggestions.t
+++ b/t/db_dependent/Suggestions.t
@@ -18,7 +18,7 @@
 use Modern::Perl;
 
 use DateTime::Duration;
-use Test::More tests => 91;
+use Test::More tests => 79;
 use Test::Warn;
 
 use t::lib::Mocks;
@@ -34,7 +34,7 @@ use Koha::Patrons;
 use Koha::Suggestions;
 
 BEGIN {
-    use_ok('C4::Suggestions', qw( GetSuggestion ModSuggestion GetSuggestionInfo GetSuggestionFromBiblionumber GetSuggestionInfoFromBiblionumber GetSuggestionByStatus ConnectSuggestionAndBiblio DelSuggestion MarcRecordFromNewSuggestion GetUnprocessedSuggestions DelSuggestionsOlderThan ));
+    use_ok('C4::Suggestions', qw( GetSuggestion ModSuggestion GetSuggestionInfo GetSuggestionFromBiblionumber GetSuggestionByStatus ConnectSuggestionAndBiblio DelSuggestion MarcRecordFromNewSuggestion GetUnprocessedSuggestions DelSuggestionsOlderThan ));
 }
 
 my $schema  = Koha::Database->new->schema;
@@ -298,21 +298,6 @@ is( GetSuggestionFromBiblionumber(2), undef, 'GetSuggestionFromBiblionumber with
 is( GetSuggestionFromBiblionumber($biblio_1->biblionumber), $my_suggestionid, 'GetSuggestionFromBiblionumber functions correctly' );
 
 
-is( GetSuggestionInfoFromBiblionumber(), undef, 'GetSuggestionInfoFromBiblionumber without the biblio number returns undef' );
-is( GetSuggestionInfoFromBiblionumber(2), undef, 'GetSuggestionInfoFromBiblionumber with an invalid biblio number returns undef' );
-$suggestion = GetSuggestionInfoFromBiblionumber($biblio_1->biblionumber);
-is( $suggestion->{suggestionid}, $my_suggestionid, 'GetSuggestionInfoFromBiblionumber returns the suggestion id correctly' );
-is( $suggestion->{title}, $mod_suggestion1->{title}, 'GetSuggestionInfoFromBiblionumber returns the title correctly' );
-is( $suggestion->{author}, $mod_suggestion1->{author}, 'GetSuggestionInfoFromBiblionumber returns the author correctly' );
-is( $suggestion->{publishercode}, $mod_suggestion1->{publishercode}, 'GetSuggestionInfoFromBiblionumber returns the publisher code correctly' );
-is( $suggestion->{suggestedby}, $my_suggestion->{suggestedby}, 'GetSuggestionInfoFromBiblionumber returns the borrower number correctly' );
-is( $suggestion->{biblionumber}, $my_suggestion->{biblionumber}, 'GetSuggestionInfoFromBiblionumber returns the biblio number correctly' );
-is( $suggestion->{STATUS}, $mod_suggestion3->{STATUS}, 'GetSuggestionInfoFromBiblionumber returns the status correctly' );
-is( $suggestion->{surnamesuggestedby}, $member->{surname}, 'GetSuggestionInfoFromBiblionumber returns the surname correctly' );
-is( $suggestion->{firstnamesuggestedby}, $member->{firstname}, 'GetSuggestionInfoFromBiblionumber returns the firstname correctly' );
-is( $suggestion->{borrnumsuggestedby}, $my_suggestion->{suggestedby}, 'GetSuggestionInfoFromBiblionumeber returns the borrower number correctly' );
-
-
 my $suggestions = GetSuggestionByStatus();
 is( @$suggestions, 0, 'GetSuggestionByStatus without the status returns an empty array' );
 $suggestions = GetSuggestionByStatus('CHECKED');
-- 
2.34.1