View | Details | Raw Unified | Return to bug 35717
Collapse All | Expand All

(-)a/C4/Acquisition.pm (-2 / +4 lines)
Lines 1385-1394 sub ModReceiveOrder { Link Here
1385
    $order->{invoice_unitprice} ||= $order->{unitprice};
1385
    $order->{invoice_unitprice} ||= $order->{unitprice};
1386
    $order->{invoice_currency}  ||= Koha::Acquisition::Currencies->get_active->currency;
1386
    $order->{invoice_currency}  ||= Koha::Acquisition::Currencies->get_active->currency;
1387
1387
1388
    if ( $order->{suggestionid} ) {
1388
    my $order_object = Koha::Acquistions::Orders->find( $order->{ordernumber} );
1389
    my $suggestions = $order_object->suggestions;
1390
    while ( my $suggestion = $suggestions->next ) {
1389
        ModSuggestion(
1391
        ModSuggestion(
1390
            {
1392
            {
1391
                suggestionid => $order->{suggestionid},
1393
                suggestionid => $suggestion->id,
1392
                STATUS       => 'AVAILABLE',
1394
                STATUS       => 'AVAILABLE',
1393
                biblionumber => $biblionumber
1395
                biblionumber => $biblionumber
1394
            }
1396
            }
(-)a/C4/Suggestions.pm (-26 lines)
Lines 36-42 our @EXPORT = qw( Link Here
36
    DelSuggestion
36
    DelSuggestion
37
    GetSuggestion
37
    GetSuggestion
38
    GetSuggestionByStatus
38
    GetSuggestionByStatus
39
    GetSuggestionFromBiblionumber
40
    GetSuggestionInfo
39
    GetSuggestionInfo
41
    ModStatus
40
    ModStatus
42
    ModSuggestion
41
    ModSuggestion
Lines 94-124 sub GetSuggestion { Link Here
94
    return ( $sth->fetchrow_hashref );
93
    return ( $sth->fetchrow_hashref );
95
}
94
}
96
95
97
=head2 GetSuggestionFromBiblionumber
98
99
$ordernumber = &GetSuggestionFromBiblionumber($biblionumber)
100
101
Get a suggestion from it's biblionumber.
102
103
return :
104
the id of the suggestion which is related to the biblionumber given on input args.
105
106
=cut
107
108
sub GetSuggestionFromBiblionumber {
109
    my ($biblionumber) = @_;
110
    my $query = q{
111
        SELECT suggestionid
112
        FROM   suggestions
113
        WHERE  biblionumber=? LIMIT 1
114
    };
115
    my $dbh = C4::Context->dbh;
116
    my $sth = $dbh->prepare($query);
117
    $sth->execute($biblionumber);
118
    my ($suggestionid) = $sth->fetchrow;
119
    return $suggestionid;
120
}
121
122
=head2 GetSuggestionInfo
96
=head2 GetSuggestionInfo
123
97
124
Get a suggestion and borrower's informations from it's suggestionid
98
Get a suggestion and borrower's informations from it's suggestionid
(-)a/t/db_dependent/Suggestions.t (-8 / +2 lines)
Lines 18-24 Link Here
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use DateTime::Duration;
20
use DateTime::Duration;
21
use Test::More tests => 80;
21
use Test::More tests => 77;
22
use Test::Warn;
22
use Test::Warn;
23
23
24
use t::lib::Mocks;
24
use t::lib::Mocks;
Lines 35-41 use Koha::Patrons; Link Here
35
use Koha::Suggestions;
35
use Koha::Suggestions;
36
36
37
BEGIN {
37
BEGIN {
38
    use_ok('C4::Suggestions', qw( GetSuggestion ModSuggestion GetSuggestionInfo GetSuggestionFromBiblionumber GetSuggestionByStatus ConnectSuggestionAndBiblio DelSuggestion MarcRecordFromNewSuggestion GetUnprocessedSuggestions DelSuggestionsOlderThan ));
38
    use_ok('C4::Suggestions', qw( GetSuggestion ModSuggestion GetSuggestionInfo GetSuggestionByStatus ConnectSuggestionAndBiblio DelSuggestion MarcRecordFromNewSuggestion GetUnprocessedSuggestions DelSuggestionsOlderThan ));
39
}
39
}
40
40
41
my $schema  = Koha::Database->new->schema;
41
my $schema  = Koha::Database->new->schema;
Lines 294-304 is( $suggestion->{firstnamesuggestedby}, $member->{firstname}, 'GetSuggestionInf Link Here
294
is( $suggestion->{borrnumsuggestedby}, $my_suggestion->{suggestedby}, 'GetSuggestionInfo returns the borrower number correctly' );
294
is( $suggestion->{borrnumsuggestedby}, $my_suggestion->{suggestedby}, 'GetSuggestionInfo returns the borrower number correctly' );
295
295
296
296
297
is( GetSuggestionFromBiblionumber(), undef, 'GetSuggestionFromBiblionumber without the biblio number returns undef' );
298
is( GetSuggestionFromBiblionumber(2), undef, 'GetSuggestionFromBiblionumber with an invalid biblio number returns undef' );
299
is( GetSuggestionFromBiblionumber($biblio_1->biblionumber), $my_suggestionid, 'GetSuggestionFromBiblionumber functions correctly' );
300
301
302
my $suggestions = GetSuggestionByStatus();
297
my $suggestions = GetSuggestionByStatus();
303
is( @$suggestions, 0, 'GetSuggestionByStatus without the status returns an empty array' );
298
is( @$suggestions, 0, 'GetSuggestionByStatus without the status returns an empty array' );
304
$suggestions = GetSuggestionByStatus('CHECKED');
299
$suggestions = GetSuggestionByStatus('CHECKED');
305
- 

Return to bug 35717