Bug 39723: Remove GetSuggestionInfoFromBiblionumber from C4/Suggestions.pm
To test: Create, edit and receive a command from a suggestion (the lonely call of modReceiveOrder is at the receipt in acqui/finishreceive.pl) Run `prove prove t/db_dependent/Acquisition.t` Run `prove prove t/db_dependent/Suggestions.t` 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:
parent
5323b8858e
commit
df21bc24eb
|
|
@ -27,7 +27,6 @@ BEGIN {
|
|||
DelSuggestion
|
||||
GetSuggestion
|
||||
GetSuggestionByStatus
|
||||
GetSuggestionInfoFromBiblionumber
|
||||
GetSuggestionInfo
|
||||
ModStatus
|
||||
ModSuggestion
|
||||
|
|
@ -72,33 +71,6 @@ Suggestions done by other borrowers can be seen when not "AVAILABLE"
|
|||
|
||||
=head1 FUNCTIONS
|
||||
|
||||
=head2 GetSuggestionInfoFromBiblionumber
|
||||
|
||||
Get a suggestion and borrower's information from it's biblionumber.
|
||||
|
||||
return :
|
||||
all information (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 information from it's suggestionid
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ 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( GetSuggestionInfoFromBiblionumber GetSuggestionInfo );
|
||||
use C4::Suggestions qw( GetSuggestionInfo );
|
||||
use Koha::Biblios;
|
||||
use Koha::Acquisition::Baskets;
|
||||
use Koha::Acquisition::Booksellers;
|
||||
|
|
@ -658,10 +658,10 @@ sub get_order_infos {
|
|||
$line{deleted_biblio} = Koha::Old::Biblios->find( $order->{deleted_biblionumber} );
|
||||
}
|
||||
|
||||
my $suggestion = GetSuggestionInfoFromBiblionumber( $line{biblionumber} );
|
||||
$line{suggestionid} = $$suggestion{suggestionid};
|
||||
$line{surnamesuggestedby} = $$suggestion{surnamesuggestedby};
|
||||
$line{firstnamesuggestedby} = $$suggestion{firstnamesuggestedby};
|
||||
my $suggestion = Koha::Suggestions->search( { biblionumber => $line{biblionumber} } )->single;
|
||||
$line{suggestionid} = $suggestion->suggestionid;
|
||||
$line{surnamesuggestedby} = $suggestion->suggester->surname;
|
||||
$line{firstnamesuggestedby} = $suggestion->suggester->firstname;
|
||||
|
||||
$line{estimated_delivery_date} = $order->{estimated_delivery_date};
|
||||
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ 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( GetSuggestionInfoFromBiblionumber GetSuggestionInfo );
|
||||
use C4::Suggestions qw( GetSuggestionInfo );
|
||||
|
||||
use Koha::Acquisition::Booksellers;
|
||||
use Koha::Acquisition::Currencies;
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ 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( GetSuggestionInfoFromBiblionumber GetSuggestionInfo );
|
||||
use C4::Suggestions qw( GetSuggestionInfo );
|
||||
|
||||
use Koha::Acquisition::Baskets;
|
||||
use Koha::Acquisition::Bookseller;
|
||||
|
|
@ -150,10 +150,10 @@ for my $order (@orders) {
|
|||
$total_tax_excluded += get_rounded_price( $line{unitprice_tax_excluded} ) * $line{quantity};
|
||||
$total_tax_included += get_rounded_price( $line{unitprice_tax_included} ) * $line{quantity};
|
||||
|
||||
my $suggestion = GetSuggestionInfoFromBiblionumber( $line{biblionumber} );
|
||||
$line{suggestionid} = $suggestion->{suggestionid};
|
||||
$line{surnamesuggestedby} = $suggestion->{surnamesuggestedby};
|
||||
$line{firstnamesuggestedby} = $suggestion->{firstnamesuggestedby};
|
||||
my $suggestion = Koha::Suggestions->search( { biblionumber => $line{biblionumber} } )->single;
|
||||
$line{suggestionid} = $suggestion->suggestionid;
|
||||
$line{surnamesuggestedby} = $suggestion->suggester->surname;
|
||||
$line{firstnamesuggestedby} = $suggestion->suggester->firstname;
|
||||
|
||||
if ( $line{parent_ordernumber} != $line{ordernumber} ) {
|
||||
if ( grep { $_->{ordernumber} == $line{parent_ordernumber} } @orders ) {
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ use Modern::Perl;
|
|||
|
||||
use DateTime::Duration;
|
||||
use Test::NoWarnings;
|
||||
use Test::More tests => 92;
|
||||
use Test::More tests => 80;
|
||||
use Test::Warn;
|
||||
|
||||
use t::lib::Mocks;
|
||||
|
|
@ -38,7 +38,7 @@ use Koha::Suggestions;
|
|||
BEGIN {
|
||||
use_ok(
|
||||
'C4::Suggestions',
|
||||
qw( ModSuggestion GetSuggestionInfo GetSuggestionInfoFromBiblionumber GetSuggestionByStatus ConnectSuggestionAndBiblio DelSuggestion MarcRecordFromNewSuggestion GetUnprocessedSuggestions DelSuggestionsOlderThan )
|
||||
qw( ModSuggestion GetSuggestionInfo GetSuggestionByStatus ConnectSuggestionAndBiblio DelSuggestion MarcRecordFromNewSuggestion GetUnprocessedSuggestions DelSuggestionsOlderThan )
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -335,53 +335,6 @@ is(
|
|||
'GetSuggestionInfo returns the borrower number 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');
|
||||
|
|
|
|||
Loading…
Reference in New Issue