From 1e36864f8d3839729abc7742cecb29773047a494 Mon Sep 17 00:00:00 2001 From: Baptiste Wojtkowski Date: Thu, 19 Feb 2026 14:34:21 +0000 Subject: [PATCH] Bug 39724: Remove GetSuggestionInfo from C4/Suggestions.pm --- C4/Suggestions.pm | 28 ---------------------------- acqui/basket.pl | 5 ++--- acqui/neworderempty.pl | 9 ++++----- acqui/orderreceive.pl | 9 +-------- acqui/parcel.pl | 1 - t/db_dependent/Suggestions.t | 29 ++--------------------------- 6 files changed, 9 insertions(+), 72 deletions(-) diff --git a/C4/Suggestions.pm b/C4/Suggestions.pm index d1ed57fda99..1ce0a5364d4 100644 --- a/C4/Suggestions.pm +++ b/C4/Suggestions.pm @@ -27,7 +27,6 @@ BEGIN { DelSuggestion GetSuggestion GetSuggestionByStatus - GetSuggestionInfo ModStatus ModSuggestion DelSuggestionsOlderThan @@ -71,33 +70,6 @@ Suggestions done by other borrowers can be seen when not "AVAILABLE" =head1 FUNCTIONS -=head2 GetSuggestionInfo - -Get a suggestion and borrower's information from it's suggestionid - -return : -all information (suggestion and borrower) of the suggestion which is related to the suggestionid given. - -=cut - -sub GetSuggestionInfo { - my ($suggestionid) = @_; - 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 suggestionid=? - LIMIT 1 - }; - my $dbh = C4::Context->dbh; - my $sth = $dbh->prepare($query); - $sth->execute($suggestionid); - return $sth->fetchrow_hashref; -} - =head2 GetSuggestionByStatus $aqorders = &GetSuggestionByStatus($status,[$branchcode]) diff --git a/acqui/basket.pl b/acqui/basket.pl index 6453f2795c3..aae5c57b627 100755 --- a/acqui/basket.pl +++ b/acqui/basket.pl @@ -26,9 +26,8 @@ use C4::Output qw( output_html_with_http_headers output_and_exit ); use CGI qw ( -utf8 ); use C4::Acquisition qw( GetBasket CanUserManageBasket GetBasketAsCSV NewBasket NewBasketgroup ModBasket ReopenBasket ModBasketUsers GetBasketgroup GetBasketgroups GetBasketUsers GetOrders GetOrder get_rounded_price ); -use C4::Budgets qw( GetBudgetHierarchy GetBudget CanUserUseBudget ); -use C4::Contract qw( GetContract ); -use C4::Suggestions qw( GetSuggestionInfo ); +use C4::Budgets qw( GetBudgetHierarchy GetBudget CanUserUseBudget ); +use C4::Contract qw( GetContract ); use Koha::Biblios; use Koha::Acquisition::Baskets; use Koha::Acquisition::Booksellers; diff --git a/acqui/neworderempty.pl b/acqui/neworderempty.pl index 307c48509e2..1f0c87c5b25 100755 --- a/acqui/neworderempty.pl +++ b/acqui/neworderempty.pl @@ -72,7 +72,6 @@ use C4::Budgets qw( GetBudget GetBudgetHierarchy CanUserUseBudget ); use C4::Acquisition qw( GetOrder GetBasket FillWithDefaultValues GetOrderUsers ); use C4::Contract qw( GetContract ); -use C4::Suggestions qw( GetSuggestionInfo ); use C4::Biblio qw( AddBiblio GetBiblioData @@ -323,7 +322,7 @@ if ( not $ordernumber or $biblionumber ) { $template->param( catalog_details => \@catalog_details, ); my $suggestion; -$suggestion = GetSuggestionInfo($suggestionid) if $suggestionid; +$suggestion = Koha::Suggestions->find( { suggestionid => $suggestionid } ) if $suggestionid; my $active_currency = Koha::Acquisition::Currencies->get_active; @@ -461,9 +460,9 @@ $template->param( closedate => $basket->{'closedate'}, # order details - suggestionid => $suggestion->{suggestionid}, - surnamesuggestedby => $suggestion->{surnamesuggestedby}, - firstnamesuggestedby => $suggestion->{firstnamesuggestedby}, + suggestionid => $suggestion->suggestionid, + surnamesuggestedby => $suggestion->surname, + firstnamesuggestedby => $suggestion->firstname, biblionumber => $biblionumber, uncertainprice => $data->{'uncertainprice'}, discount_2dp => sprintf( "%.2f", $bookseller->discount ), # for display diff --git a/acqui/orderreceive.pl b/acqui/orderreceive.pl index 216f5b9750e..038c310797e 100755 --- a/acqui/orderreceive.pl +++ b/acqui/orderreceive.pl @@ -66,8 +66,7 @@ use C4::Auth qw( get_template_and_user ); use C4::Output qw( output_html_with_http_headers ); use C4::Budgets qw( GetBudget GetBudgetPeriods GetBudgetPeriod GetBudgetHierarchy CanUserUseBudget ); use C4::Members; -use C4::Biblio qw( GetMarcStructure ); -use C4::Suggestions qw( GetSuggestionInfo ); +use C4::Biblio qw( GetMarcStructure ); use Koha::Acquisition::Booksellers; use Koha::Acquisition::Currencies; @@ -133,12 +132,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/acqui/parcel.pl b/acqui/parcel.pl index fda6d8e9a1f..5b0debc7f81 100755 --- a/acqui/parcel.pl +++ b/acqui/parcel.pl @@ -60,7 +60,6 @@ use C4::Acquisition qw( CancelReceipt GetInvoice GetInvoiceDetails get_rounded_p use C4::Budgets qw( GetBudget GetBudgetByOrderNumber GetBudgetName ); use CGI qw ( -utf8 ); use C4::Output qw( output_html_with_http_headers ); -use C4::Suggestions qw( GetSuggestionInfo ); use Koha::Acquisition::Baskets; use Koha::Acquisition::Bookseller; diff --git a/t/db_dependent/Suggestions.t b/t/db_dependent/Suggestions.t index 98824879510..6cf914b3318 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 => 80; +use Test::More tests => 69; use Test::Warn; use t::lib::Mocks; @@ -38,7 +38,7 @@ use Koha::Suggestions; BEGIN { use_ok( 'C4::Suggestions', - qw( ModSuggestion GetSuggestionInfo GetSuggestionByStatus ConnectSuggestionAndBiblio DelSuggestion MarcRecordFromNewSuggestion GetUnprocessedSuggestions DelSuggestionsOlderThan ) + qw( ModSuggestion GetSuggestionByStatus ConnectSuggestionAndBiblio DelSuggestion MarcRecordFromNewSuggestion GetUnprocessedSuggestions DelSuggestionsOlderThan ) ); } @@ -310,31 +310,6 @@ $messages = C4::Letters::GetQueuedMessages( { borrowernumber => $borrowernumber2 is( scalar(@$messages), 1, 'No new letter should have been generated if the update raised an error' ); -is( GetSuggestionInfo(), undef, 'GetSuggestionInfo without the suggestion id returns undef' ); -$suggestion = GetSuggestionInfo($my_suggestionid); -is( $suggestion->{suggestionid}, $my_suggestionid, 'GetSuggestionInfo returns the suggestion id correctly' ); -is( $suggestion->{title}, $mod_suggestion1->{title}, 'GetSuggestionInfo returns the title correctly' ); -is( $suggestion->{author}, $mod_suggestion1->{author}, 'GetSuggestionInfo returns the author correctly' ); -is( - $suggestion->{publishercode}, $mod_suggestion1->{publishercode}, - 'GetSuggestionInfo returns the publisher code correctly' -); -is( - $suggestion->{suggestedby}, $my_suggestion->{suggestedby}, - 'GetSuggestionInfo returns the borrower number correctly' -); -is( - $suggestion->{biblionumber}, $my_suggestion->{biblionumber}, - 'GetSuggestionInfo returns the biblio number correctly' -); -is( $suggestion->{STATUS}, $mod_suggestion3->{STATUS}, 'GetSuggestionInfo returns the status correctly' ); -is( $suggestion->{surnamesuggestedby}, $member->{surname}, 'GetSuggestionInfo returns the surname correctly' ); -is( $suggestion->{firstnamesuggestedby}, $member->{firstname}, 'GetSuggestionInfo returns the firstname correctly' ); -is( - $suggestion->{borrnumsuggestedby}, $my_suggestion->{suggestedby}, - 'GetSuggestionInfo returns the borrower number correctly' -); - my $suggestions = GetSuggestionByStatus(); is( @$suggestions, 0, 'GetSuggestionByStatus without the status returns an empty array' ); $suggestions = GetSuggestionByStatus('CHECKED'); -- 2.43.0