From dab2395808516ae0dc499dcc9b33c23f6c500e58 Mon Sep 17 00:00:00 2001 From: Baptiste Wojtkowski Date: Tue, 8 Apr 2025 13:53:38 +0200 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 bd418f84..85dc9863 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 ); @@ -1407,11 +1407,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 dc933274..f2999f02 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 informations from it's biblionumber. diff --git a/t/db_dependent/Suggestions.t b/t/db_dependent/Suggestions.t index 87c3f6df..50591c7a 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.30.2