Bug 39725: Remove GetSuggestionByStatus from C4/Suggestions.pm

Signed-off-by: Owen Leonard <oleonard@myacpl.org>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Baptiste Wojtkowski 2026-02-19 14:52:20 +00:00 committed by Lucas Gass
parent 452089fc00
commit 233e02fc1c
No known key found for this signature in database
GPG Key ID: 60B447398B0D36CA
2 changed files with 2 additions and 107 deletions

View File

@ -26,7 +26,6 @@ BEGIN {
ConnectSuggestionAndBiblio
DelSuggestion
GetSuggestion
GetSuggestionByStatus
ModStatus
ModSuggestion
DelSuggestionsOlderThan
@ -70,65 +69,6 @@ Suggestions done by other borrowers can be seen when not "AVAILABLE"
=head1 FUNCTIONS
=head2 GetSuggestionByStatus
$aqorders = &GetSuggestionByStatus($status,[$branchcode])
Get a suggestion from it's status
return :
all the suggestion with C<$status>
=cut
sub GetSuggestionByStatus {
my $status = shift;
my $branchcode = shift;
my $dbh = C4::Context->dbh;
my @sql_params = ($status);
my $query = q{
SELECT suggestions.*,
U1.surname AS surnamesuggestedby,
U1.firstname AS firstnamesuggestedby,
U1.branchcode AS branchcodesuggestedby,
B1.branchname AS branchnamesuggestedby,
U1.borrowernumber AS borrnumsuggestedby,
U1.categorycode AS categorycodesuggestedby,
C1.description AS categorydescriptionsuggestedby,
U2.surname AS surnamemanagedby,
U2.firstname AS firstnamemanagedby,
U2.borrowernumber AS borrnummanagedby
FROM suggestions
LEFT JOIN borrowers AS U1 ON suggestedby=U1.borrowernumber
LEFT JOIN borrowers AS U2 ON managedby=U2.borrowernumber
LEFT JOIN categories AS C1 ON C1.categorycode=U1.categorycode
LEFT JOIN branches AS B1 on B1.branchcode=U1.branchcode
WHERE status = ?
ORDER BY suggestionid
};
# filter on branch
if ( C4::Context->preference("IndependentBranches") || $branchcode ) {
my $userenv = C4::Context->userenv;
if ($userenv) {
unless ( C4::Context->IsSuperLibrarian() ) {
push @sql_params, $userenv->{branch};
$query .= q{ AND (U1.branchcode = ? OR U1.branchcode ='') };
}
}
if ($branchcode) {
push @sql_params, $branchcode;
$query .= q{ AND (U1.branchcode = ? OR U1.branchcode ='') };
}
}
my $sth = $dbh->prepare($query);
$sth->execute(@sql_params);
my $results;
$results = $sth->fetchall_arrayref( {} );
return $results;
}
=head2 ModSuggestion
&ModSuggestion($suggestion)

View File

@ -19,7 +19,7 @@ use Modern::Perl;
use DateTime::Duration;
use Test::NoWarnings;
use Test::More tests => 69;
use Test::More tests => 53;
use Test::Warn;
use t::lib::Mocks;
@ -38,7 +38,7 @@ use Koha::Suggestions;
BEGIN {
use_ok(
'C4::Suggestions',
qw( ModSuggestion GetSuggestionByStatus ConnectSuggestionAndBiblio DelSuggestion MarcRecordFromNewSuggestion GetUnprocessedSuggestions DelSuggestionsOlderThan )
qw( ModSuggestion ConnectSuggestionAndBiblio DelSuggestion MarcRecordFromNewSuggestion GetUnprocessedSuggestions DelSuggestionsOlderThan )
);
}
@ -310,47 +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' );
my $suggestions = GetSuggestionByStatus();
is( @$suggestions, 0, 'GetSuggestionByStatus without the status returns an empty array' );
$suggestions = GetSuggestionByStatus('CHECKED');
is( @$suggestions, 2, 'GetSuggestionByStatus returns the correct number of suggestions' );
is( $suggestions->[0]->{suggestionid}, $my_suggestionid, 'GetSuggestionByStatus returns the suggestion id correctly' );
is( $suggestions->[0]->{title}, $mod_suggestion1->{title}, 'GetSuggestionByStatus returns the title correctly' );
is( $suggestions->[0]->{author}, $mod_suggestion1->{author}, 'GetSuggestionByStatus returns the author correctly' );
is(
$suggestions->[0]->{publishercode}, $mod_suggestion1->{publishercode},
'GetSuggestionByStatus returns the publisher code correctly'
);
is(
$suggestions->[0]->{suggestedby}, $my_suggestion->{suggestedby},
'GetSuggestionByStatus returns the borrower number correctly'
);
is(
$suggestions->[0]->{biblionumber}, $my_suggestion->{biblionumber},
'GetSuggestionByStatus returns the biblio number correctly'
);
is( $suggestions->[0]->{STATUS}, $mod_suggestion3->{STATUS}, 'GetSuggestionByStatus returns the status correctly' );
is(
$suggestions->[0]->{surnamesuggestedby}, $member->{surname},
'GetSuggestionByStatus returns the surname correctly'
);
is(
$suggestions->[0]->{firstnamesuggestedby}, $member->{firstname},
'GetSuggestionByStatus returns the firstname correctly'
);
is(
$suggestions->[0]->{branchcodesuggestedby}, $member->{branchcode},
'GetSuggestionByStatus returns the branch code correctly'
);
is(
$suggestions->[0]->{borrnumsuggestedby}, $my_suggestion->{suggestedby},
'GetSuggestionByStatus returns the borrower number correctly'
);
is(
$suggestions->[0]->{categorycodesuggestedby}, $member->{categorycode},
'GetSuggestionByStatus returns the category code correctly'
);
is( ConnectSuggestionAndBiblio(), '0E0', 'ConnectSuggestionAndBiblio without arguments returns 0E0' );
my $biblio_2 = $builder->build_object( { class => 'Koha::Biblios' } );
my $connect_suggestion_and_biblio = ConnectSuggestionAndBiblio( $my_suggestionid, $biblio_2->biblionumber );
@ -378,10 +337,6 @@ is(
$suggestion = DelSuggestion( $borrowernumber, $my_suggestionid );
is( $suggestion, 1, 'DelSuggestion deletes one suggestion' );
$suggestions = GetSuggestionByStatus('CHECKED');
is( @$suggestions, 2, 'DelSuggestion deletes one suggestion' );
is( $suggestions->[1]->{title}, $del_suggestion->{title}, 'DelSuggestion deletes the correct suggestion' );
# Test budgetid fk
$my_suggestion->{budgetid} = ''; # If budgetid == '', NULL should be set in DB
my $my_suggestionid_test_budget_object = Koha::Suggestion->new($my_suggestion)->store;