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

(-)a/C4/Acquisition.pm (-4 / +4 lines)
Lines 69-75 BEGIN { Link Here
69
use Carp qw( carp croak );
69
use Carp qw( carp croak );
70
use Text::CSV_XS;
70
use Text::CSV_XS;
71
use C4::Context;
71
use C4::Context;
72
use C4::Suggestions qw( GetSuggestionFromBiblionumber ModSuggestion );
72
use C4::Suggestions qw( ModSuggestion );
73
use C4::Biblio      qw( GetMarcFromKohaField GetMarcStructure IsMarcStructureInternal );
73
use C4::Biblio      qw( GetMarcFromKohaField GetMarcStructure IsMarcStructureInternal );
74
use C4::Contract    qw( GetContract );
74
use C4::Contract    qw( GetContract );
75
use C4::Log         qw( logaction );
75
use C4::Log         qw( logaction );
Lines 1417-1427 sub ModReceiveOrder { Link Here
1417
    $order->{invoice_unitprice} ||= $order->{unitprice};
1417
    $order->{invoice_unitprice} ||= $order->{unitprice};
1418
    $order->{invoice_currency}  ||= Koha::Acquisition::Currencies->get_active->currency;
1418
    $order->{invoice_currency}  ||= Koha::Acquisition::Currencies->get_active->currency;
1419
1419
1420
    my $suggestionid = GetSuggestionFromBiblionumber($biblionumber);
1420
    my $suggestion = Koha::Suggestions->find( { biblionumber => $biblionumber } );
1421
    if ($suggestionid) {
1421
    if ($suggestion) {
1422
        ModSuggestion(
1422
        ModSuggestion(
1423
            {
1423
            {
1424
                suggestionid => $suggestionid,
1424
                suggestionid => $suggestion->suggestionid,
1425
                STATUS       => 'AVAILABLE',
1425
                STATUS       => 'AVAILABLE',
1426
                biblionumber => $biblionumber
1426
                biblionumber => $biblionumber
1427
            }
1427
            }
(-)a/C4/Suggestions.pm (-26 lines)
Lines 27-33 BEGIN { Link Here
27
        DelSuggestion
27
        DelSuggestion
28
        GetSuggestion
28
        GetSuggestion
29
        GetSuggestionByStatus
29
        GetSuggestionByStatus
30
        GetSuggestionFromBiblionumber
31
        GetSuggestionInfoFromBiblionumber
30
        GetSuggestionInfoFromBiblionumber
32
        GetSuggestionInfo
31
        GetSuggestionInfo
33
        ModStatus
32
        ModStatus
Lines 73-103 Suggestions done by other borrowers can be seen when not "AVAILABLE" Link Here
73
72
74
=head1 FUNCTIONS
73
=head1 FUNCTIONS
75
74
76
=head2 GetSuggestionFromBiblionumber
77
78
$ordernumber = &GetSuggestionFromBiblionumber($biblionumber)
79
80
Get a suggestion from it's biblionumber.
81
82
return :
83
the id of the suggestion which is related to the biblionumber given on input args.
84
85
=cut
86
87
sub GetSuggestionFromBiblionumber {
88
    my ($biblionumber) = @_;
89
    my $query = q{
90
        SELECT suggestionid
91
        FROM   suggestions
92
        WHERE  biblionumber=? LIMIT 1
93
    };
94
    my $dbh = C4::Context->dbh;
95
    my $sth = $dbh->prepare($query);
96
    $sth->execute($biblionumber);
97
    my ($suggestionid) = $sth->fetchrow;
98
    return $suggestionid;
99
}
100
101
=head2 GetSuggestionInfoFromBiblionumber
75
=head2 GetSuggestionInfoFromBiblionumber
102
76
103
Get a suggestion and borrower's information from it's biblionumber.
77
Get a suggestion and borrower's information from it's biblionumber.
(-)a/t/db_dependent/Suggestions.t (-13 / +2 lines)
Lines 19-25 use Modern::Perl; Link Here
19
19
20
use DateTime::Duration;
20
use DateTime::Duration;
21
use Test::NoWarnings;
21
use Test::NoWarnings;
22
use Test::More tests => 95;
22
use Test::More tests => 92;
23
use Test::Warn;
23
use Test::Warn;
24
24
25
use t::lib::Mocks;
25
use t::lib::Mocks;
Lines 38-44 use Koha::Suggestions; Link Here
38
BEGIN {
38
BEGIN {
39
    use_ok(
39
    use_ok(
40
        'C4::Suggestions',
40
        'C4::Suggestions',
41
        qw( ModSuggestion GetSuggestionInfo GetSuggestionFromBiblionumber GetSuggestionInfoFromBiblionumber GetSuggestionByStatus ConnectSuggestionAndBiblio DelSuggestion MarcRecordFromNewSuggestion GetUnprocessedSuggestions DelSuggestionsOlderThan )
41
        qw( ModSuggestion GetSuggestionInfo GetSuggestionInfoFromBiblionumber GetSuggestionByStatus ConnectSuggestionAndBiblio DelSuggestion MarcRecordFromNewSuggestion GetUnprocessedSuggestions DelSuggestionsOlderThan )
42
    );
42
    );
43
}
43
}
44
44
Lines 335-350 is( Link Here
335
    'GetSuggestionInfo returns the borrower number correctly'
335
    'GetSuggestionInfo returns the borrower number correctly'
336
);
336
);
337
337
338
is( GetSuggestionFromBiblionumber(), undef, 'GetSuggestionFromBiblionumber without the biblio number returns undef' );
339
is(
340
    GetSuggestionFromBiblionumber(2), undef,
341
    'GetSuggestionFromBiblionumber with an invalid biblio number returns undef'
342
);
343
is(
344
    GetSuggestionFromBiblionumber( $biblio_1->biblionumber ), $my_suggestionid,
345
    'GetSuggestionFromBiblionumber functions correctly'
346
);
347
348
is(
338
is(
349
    GetSuggestionInfoFromBiblionumber(), undef,
339
    GetSuggestionInfoFromBiblionumber(), undef,
350
    'GetSuggestionInfoFromBiblionumber without the biblio number returns undef'
340
    'GetSuggestionInfoFromBiblionumber without the biblio number returns undef'
351
- 

Return to bug 39722