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

(-)a/C4/ILSDI/Services.pm (-1 / +1 lines)
Lines 219-225 sub GetRecords { Link Here
219
        # Get most of the needed data
219
        # Get most of the needed data
220
        my $biblioitemnumber = $biblioitem->{'biblioitemnumber'};
220
        my $biblioitemnumber = $biblioitem->{'biblioitemnumber'};
221
        my $biblio = Koha::Biblios->find( $biblionumber );
221
        my $biblio = Koha::Biblios->find( $biblionumber );
222
        my $holds  = $biblio->holds_placed_before_today->unblessed;
222
        my $holds  = $biblio->current_holds->unblessed;
223
        my $issues           = GetBiblioIssues($biblionumber);
223
        my $issues           = GetBiblioIssues($biblionumber);
224
        my $items            = GetItemsByBiblioitemnumber($biblioitemnumber);
224
        my $items            = GetItemsByBiblioitemnumber($biblioitemnumber);
225
225
(-)a/C4/SIP/ILS/Item.pm (-1 / +1 lines)
Lines 95-101 sub new { Link Here
95
	my $borrower = GetMember(borrowernumber=>$issue->{'borrowernumber'});
95
	my $borrower = GetMember(borrowernumber=>$issue->{'borrowernumber'});
96
	$item->{patron} = $borrower->{'cardnumber'};
96
	$item->{patron} = $borrower->{'cardnumber'};
97
    my $biblio = Koha::Biblios->find( $item->{biblionumber } );
97
    my $biblio = Koha::Biblios->find( $item->{biblionumber } );
98
    my $holds = $biblio->holds_placed_before_today->unblessed;
98
    my $holds = $biblio->current_holds->unblessed;
99
    $item->{hold_queue} = $holds;
99
    $item->{hold_queue} = $holds;
100
	$item->{hold_shelf}    = [( grep {   defined $_->{found}  and $_->{found} eq 'W' } @{$item->{hold_queue}} )];
100
	$item->{hold_shelf}    = [( grep {   defined $_->{found}  and $_->{found} eq 'W' } @{$item->{hold_queue}} )];
101
	$item->{pending_queue} = [( grep {(! defined $_->{found}) or  $_->{found} ne 'W' } @{$item->{hold_queue}} )];
101
	$item->{pending_queue} = [( grep {(! defined $_->{found}) or  $_->{found} ne 'W' } @{$item->{hold_queue}} )];
(-)a/Koha/Biblio.pm (-3 / +3 lines)
Lines 265-280 sub holds { Link Here
265
    return Koha::Holds->_new_from_dbic($hold_rs);
265
    return Koha::Holds->_new_from_dbic($hold_rs);
266
}
266
}
267
267
268
=head3 holds_placed_before_today
268
=head3 current_holds
269
269
270
my $holds = $biblio->holds_placed_before_today
270
my $holds = $biblio->current_holds
271
271
272
Return the holds placed on this bibliographic record.
272
Return the holds placed on this bibliographic record.
273
It does not include future holds.
273
It does not include future holds.
274
274
275
=cut
275
=cut
276
276
277
sub holds_placed_before_today {
277
sub current_holds {
278
    my ($self) = @_;
278
    my ($self) = @_;
279
    my $dtf = Koha::Database->new->schema->storage->datetime_parser;
279
    my $dtf = Koha::Database->new->schema->storage->datetime_parser;
280
    return $self->holds(
280
    return $self->holds(
(-)a/acqui/parcel.pl (-1 / +1 lines)
Lines 141-147 for my $order ( @orders ) { Link Here
141
    $line{holds} = 0;
141
    $line{holds} = 0;
142
    my @itemnumbers = GetItemnumbersFromOrder( $order->{ordernumber} );
142
    my @itemnumbers = GetItemnumbersFromOrder( $order->{ordernumber} );
143
    my $biblio = Koha::Biblios->find( $order->{ordernumber} );
143
    my $biblio = Koha::Biblios->find( $order->{ordernumber} );
144
    $line{holds} = $biblio->holds_placed_before_today->search(
144
    $line{holds} = $biblio->current_holds->search(
145
        {
145
        {
146
            itemnumber => { -in => \@itemnumbers },
146
            itemnumber => { -in => \@itemnumbers },
147
        }
147
        }
(-)a/serials/routing-preview.pl (-1 / +1 lines)
Lines 74-80 if($ok){ Link Here
74
		# get existing reserves .....
74
		# get existing reserves .....
75
75
76
        my $biblio = Koha::Biblios->find( $biblionumber );
76
        my $biblio = Koha::Biblios->find( $biblionumber );
77
        my $holds = $biblio->holds_placed_before_today;
77
        my $holds = $biblio->current_holds;
78
        my $count = $holds->count;
78
        my $count = $holds->count;
79
        while ( my $hold = $holds->next ) {
79
        while ( my $hold = $holds->next ) {
80
            $count-- if $hold->is_waiting;
80
            $count-- if $hold->is_waiting;
(-)a/t/db_dependent/Koha/Biblios.t (-4 / +3 lines)
Lines 44-50 my $biblioitem = $schema->resultset('Biblioitem')->new( Link Here
44
    }
44
    }
45
)->insert();
45
)->insert();
46
46
47
subtest 'holds + holds_placed_before_today' => sub {
47
subtest 'holds + current_holds' => sub {
48
    plan tests => 5;
48
    plan tests => 5;
49
    C4::Reserves::AddReserve( $patron->branchcode, $patron->borrowernumber, $biblio->biblionumber );
49
    C4::Reserves::AddReserve( $patron->branchcode, $patron->borrowernumber, $biblio->biblionumber );
50
    my $holds = $biblio->holds;
50
    my $holds = $biblio->holds;
Lines 57-64 subtest 'holds + holds_placed_before_today' => sub { Link Here
57
    C4::Reserves::AddReserve( $patron->branchcode, $patron->borrowernumber, $biblio->biblionumber, undef, undef, dt_from_string->add( days => 2 ) );
57
    C4::Reserves::AddReserve( $patron->branchcode, $patron->borrowernumber, $biblio->biblionumber, undef, undef, dt_from_string->add( days => 2 ) );
58
    $holds = $biblio->holds;
58
    $holds = $biblio->holds;
59
    is( $holds->count, 1, '->holds should return future holds' );
59
    is( $holds->count, 1, '->holds should return future holds' );
60
    $holds = $biblio->holds_placed_before_today;
60
    $holds = $biblio->current_holds;
61
    is( $holds->count, 0, '->holds_placed_before_today should not return future holds' );
61
    is( $holds->count, 0, '->current_holds should not return future holds' );
62
    $holds->delete;
62
    $holds->delete;
63
63
64
};
64
};
65
- 

Return to bug 17736