From f14c69958b6f0ae5ef67b53ce62521d76177bf24 Mon Sep 17 00:00:00 2001 From: Baptiste Wojtkowski Date: Thu, 30 Oct 2025 13:55:52 +0000 Subject: [PATCH] Bug 39722: Remove GetSuggestionFromBiblionumber from C4/Suggestions.pm --- C4/Acquisition.pm | 8 ++++---- C4/Suggestions.pm | 26 -------------------------- t/db_dependent/Suggestions.t | 14 ++------------ 3 files changed, 6 insertions(+), 42 deletions(-) diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm index f6e8e252401..ef81ab61475 100644 --- a/C4/Acquisition.pm +++ b/C4/Acquisition.pm @@ -21,7 +21,7 @@ use Modern::Perl; use Carp qw( carp croak ); use Text::CSV_XS; use C4::Context; -use C4::Suggestions qw( GetSuggestionFromBiblionumber ModSuggestion ); +use C4::Suggestions qw( ModSuggestion ); use C4::Biblio qw( GetMarcFromKohaField GetMarcStructure IsMarcStructureInternal ); use C4::Contract qw( GetContract ); use C4::Log qw( logaction ); @@ -1419,11 +1419,11 @@ sub ModReceiveOrder { $order->{invoice_unitprice} ||= $order->{unitprice}; $order->{invoice_currency} ||= Koha::Acquisition::Currencies->get_active->currency; - my $suggestionid = GetSuggestionFromBiblionumber($biblionumber); - if ($suggestionid) { + my $suggestion = Koha::Suggestions->find( { biblionumber => $biblionumber } ); + if ($suggestion) { ModSuggestion( { - suggestionid => $suggestionid, + suggestionid => $suggestion->suggestionid, STATUS => 'AVAILABLE', biblionumber => $biblionumber } diff --git a/C4/Suggestions.pm b/C4/Suggestions.pm index d4877d4329b..823b7791df9 100644 --- a/C4/Suggestions.pm +++ b/C4/Suggestions.pm @@ -35,7 +35,6 @@ our @EXPORT = qw( ConnectSuggestionAndBiblio DelSuggestion GetSuggestionByStatus - GetSuggestionFromBiblionumber GetSuggestionInfoFromBiblionumber GetSuggestionInfo ModStatus @@ -70,31 +69,6 @@ Suggestions done by other borrowers can be seen when not "AVAILABLE" =head1 FUNCTIONS -=head2 GetSuggestionFromBiblionumber - -$ordernumber = &GetSuggestionFromBiblionumber($biblionumber) - -Get a suggestion from it's biblionumber. - -return : -the id of the suggestion which is related to the biblionumber given on input args. - -=cut - -sub GetSuggestionFromBiblionumber { - my ($biblionumber) = @_; - my $query = q{ - SELECT suggestionid - FROM suggestions - WHERE biblionumber=? LIMIT 1 - }; - my $dbh = C4::Context->dbh; - my $sth = $dbh->prepare($query); - $sth->execute($biblionumber); - my ($suggestionid) = $sth->fetchrow; - return $suggestionid; -} - =head2 GetSuggestionInfoFromBiblionumber Get a suggestion and borrower's information from it's biblionumber. diff --git a/t/db_dependent/Suggestions.t b/t/db_dependent/Suggestions.t index fa875249e11..d23edec56bc 100755 --- a/t/db_dependent/Suggestions.t +++ b/t/db_dependent/Suggestions.t @@ -19,7 +19,7 @@ use Modern::Perl; use DateTime::Duration; use Test::NoWarnings; -use Test::More tests => 95; +use Test::More tests => 92; use Test::Warn; use t::lib::Mocks; @@ -38,7 +38,7 @@ use Koha::Suggestions; BEGIN { use_ok( 'C4::Suggestions', - qw( ModSuggestion GetSuggestionInfo GetSuggestionFromBiblionumber GetSuggestionInfoFromBiblionumber GetSuggestionByStatus ConnectSuggestionAndBiblio DelSuggestion MarcRecordFromNewSuggestion GetUnprocessedSuggestions DelSuggestionsOlderThan ) + qw( ModSuggestion GetSuggestionInfo GetSuggestionInfoFromBiblionumber GetSuggestionByStatus ConnectSuggestionAndBiblio DelSuggestion MarcRecordFromNewSuggestion GetUnprocessedSuggestions DelSuggestionsOlderThan ) ); } @@ -335,16 +335,6 @@ is( 'GetSuggestionInfo returns the borrower number correctly' ); -is( GetSuggestionFromBiblionumber(), undef, 'GetSuggestionFromBiblionumber without the biblio number returns undef' ); -is( - GetSuggestionFromBiblionumber(2), undef, - 'GetSuggestionFromBiblionumber with an invalid biblio number returns undef' -); -is( - GetSuggestionFromBiblionumber( $biblio_1->biblionumber ), $my_suggestionid, - 'GetSuggestionFromBiblionumber functions correctly' -); - is( GetSuggestionInfoFromBiblionumber(), undef, 'GetSuggestionInfoFromBiblionumber without the biblio number returns undef' -- 2.43.0