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

(-)a/C4/Acquisition.pm (-4 / +5 lines)
Lines 18-23 package C4::Acquisition; Link Here
18
# along with Koha; if not, see <https://www.gnu.org/licenses>.
18
# along with Koha; if not, see <https://www.gnu.org/licenses>.
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
BEGIN {
22
BEGIN {
22
    our @EXPORT_OK = qw(
23
    our @EXPORT_OK = qw(
23
        GetBasket NewBasket ReopenBasket ModBasket
24
        GetBasket NewBasket ReopenBasket ModBasket
Lines 67-73 BEGIN { Link Here
67
use Carp qw( carp croak );
68
use Carp qw( carp croak );
68
use Text::CSV_XS;
69
use Text::CSV_XS;
69
use C4::Context;
70
use C4::Context;
70
use C4::Suggestions qw( GetSuggestionFromBiblionumber ModSuggestion );
71
use C4::Suggestions qw( ModSuggestion );
71
use C4::Biblio      qw( GetMarcFromKohaField GetMarcStructure IsMarcStructureInternal );
72
use C4::Biblio      qw( GetMarcFromKohaField GetMarcStructure IsMarcStructureInternal );
72
use C4::Contract    qw( GetContract );
73
use C4::Contract    qw( GetContract );
73
use C4::Log         qw( logaction );
74
use C4::Log         qw( logaction );
Lines 1415-1425 sub ModReceiveOrder { Link Here
1415
    $order->{invoice_unitprice} ||= $order->{unitprice};
1416
    $order->{invoice_unitprice} ||= $order->{unitprice};
1416
    $order->{invoice_currency}  ||= Koha::Acquisition::Currencies->get_active->currency;
1417
    $order->{invoice_currency}  ||= Koha::Acquisition::Currencies->get_active->currency;
1417
1418
1418
    my $suggestionid = GetSuggestionFromBiblionumber($biblionumber);
1419
    my $suggestion = Koha::Suggestions->find( { biblionumber => $biblionumber } );
1419
    if ($suggestionid) {
1420
    if ($suggestion) {
1420
        ModSuggestion(
1421
        ModSuggestion(
1421
            {
1422
            {
1422
                suggestionid => $suggestionid,
1423
                suggestionid => $suggestion->suggestionid,
1423
                STATUS       => 'AVAILABLE',
1424
                STATUS       => 'AVAILABLE',
1424
                biblionumber => $biblionumber
1425
                biblionumber => $biblionumber
1425
            }
1426
            }
(-)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