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

(-)a/C4/Acquisition.pm (-4 / +4 lines)
Lines 21-27 use Modern::Perl; Link Here
21
use Carp qw( carp croak );
21
use Carp qw( carp croak );
22
use Text::CSV_XS;
22
use Text::CSV_XS;
23
use C4::Context;
23
use C4::Context;
24
use C4::Suggestions qw( GetSuggestionFromBiblionumber ModSuggestion );
24
use C4::Suggestions qw( ModSuggestion );
25
use C4::Biblio      qw( GetMarcFromKohaField GetMarcStructure IsMarcStructureInternal );
25
use C4::Biblio      qw( GetMarcFromKohaField GetMarcStructure IsMarcStructureInternal );
26
use C4::Contract    qw( GetContract );
26
use C4::Contract    qw( GetContract );
27
use C4::Log         qw( logaction );
27
use C4::Log         qw( logaction );
Lines 1407-1417 sub ModReceiveOrder { Link Here
1407
    $order->{invoice_unitprice} ||= $order->{unitprice};
1407
    $order->{invoice_unitprice} ||= $order->{unitprice};
1408
    $order->{invoice_currency}  ||= Koha::Acquisition::Currencies->get_active->currency;
1408
    $order->{invoice_currency}  ||= Koha::Acquisition::Currencies->get_active->currency;
1409
1409
1410
    my $suggestionid = GetSuggestionFromBiblionumber($biblionumber);
1410
    my $suggestion = Koha::Suggestions->find( { biblionumber => $biblionumber } );
1411
    if ($suggestionid) {
1411
    if ($suggestion) {
1412
        ModSuggestion(
1412
        ModSuggestion(
1413
            {
1413
            {
1414
                suggestionid => $suggestionid,
1414
                suggestionid => $suggestion->suggestionid,
1415
                STATUS       => 'AVAILABLE',
1415
                STATUS       => 'AVAILABLE',
1416
                biblionumber => $biblionumber
1416
                biblionumber => $biblionumber
1417
            }
1417
            }
(-)a/C4/Suggestions.pm (-26 lines)
Lines 35-41 our @EXPORT = qw( Link Here
35
    ConnectSuggestionAndBiblio
35
    ConnectSuggestionAndBiblio
36
    DelSuggestion
36
    DelSuggestion
37
    GetSuggestionByStatus
37
    GetSuggestionByStatus
38
    GetSuggestionFromBiblionumber
39
    GetSuggestionInfoFromBiblionumber
38
    GetSuggestionInfoFromBiblionumber
40
    GetSuggestionInfo
39
    GetSuggestionInfo
41
    ModStatus
40
    ModStatus
Lines 70-100 Suggestions done by other borrowers can be seen when not "AVAILABLE" Link Here
70
69
71
=head1 FUNCTIONS
70
=head1 FUNCTIONS
72
71
73
=head2 GetSuggestionFromBiblionumber
74
75
$ordernumber = &GetSuggestionFromBiblionumber($biblionumber)
76
77
Get a suggestion from it's biblionumber.
78
79
return :
80
the id of the suggestion which is related to the biblionumber given on input args.
81
82
=cut
83
84
sub GetSuggestionFromBiblionumber {
85
    my ($biblionumber) = @_;
86
    my $query = q{
87
        SELECT suggestionid
88
        FROM   suggestions
89
        WHERE  biblionumber=? LIMIT 1
90
    };
91
    my $dbh = C4::Context->dbh;
92
    my $sth = $dbh->prepare($query);
93
    $sth->execute($biblionumber);
94
    my ($suggestionid) = $sth->fetchrow;
95
    return $suggestionid;
96
}
97
98
=head2 GetSuggestionInfoFromBiblionumber
72
=head2 GetSuggestionInfoFromBiblionumber
99
73
100
Get a suggestion and borrower's informations from it's biblionumber.
74
Get a suggestion and borrower's informations 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