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

(-)a/C4/Circulation.pm (-1 / +2 lines)
Lines 3205-3212 sub CanBookBeRenewed { Link Here
3205
    }
3205
    }
3206
3206
3207
    # There is an item level hold on this item, no other item can fill the hold
3207
    # There is an item level hold on this item, no other item can fill the hold
3208
    # The flag skip_future_holds may be removed in the future. See bug 40435.
3208
    return ( 0, "on_reserve" )
3209
    return ( 0, "on_reserve" )
3209
        if ( $item->current_holds->search( { non_priority => 0 } )->count );
3210
        if ( $item->current_holds( { skip_future_holds => 1 } )->search( { non_priority => 0 } )->count );
3210
3211
3211
    my ( $status, $matched_reserve, $possible_holds ) = C4::Reserves::CheckReserves($item);
3212
    my ( $status, $matched_reserve, $possible_holds ) = C4::Reserves::CheckReserves($item);
3212
    my @fillable_holds = ();
3213
    my @fillable_holds = ();
(-)a/Koha/Item.pm (-4 / +6 lines)
Lines 1174-1184 Respects the lookahead days in ConfirmFutureHolds pref. Link Here
1174
=cut
1174
=cut
1175
1175
1176
sub current_holds {
1176
sub current_holds {
1177
    my ($self)     = @_;
1177
    my ( $self, $params ) = @_;
1178
1178
    my $attributes = { order_by => 'priority' };
1179
    my $attributes = { order_by => 'priority' };
1179
    my $dtf        = Koha::Database->new->schema->storage->datetime_parser;
1180
    my $dtf        = Koha::Database->new->schema->storage->datetime_parser;
1180
    my $dt         = dt_from_string()->add( days => C4::Context->preference('ConfirmFutureHolds') || 0 );
1181
    my $days       = $params->{skip_future_holds} ? 0 : C4::Context->preference('ConfirmFutureHolds') || 0;
1181
    my $params     = {
1182
    my $dt         = dt_from_string()->add( days => $days );
1183
    my $s_params   = {
1182
        itemnumber => $self->itemnumber,
1184
        itemnumber => $self->itemnumber,
1183
        suspend    => 0,
1185
        suspend    => 0,
1184
        -or        => [
1186
        -or        => [
Lines 1186-1192 sub current_holds { Link Here
1186
            waitingdate => { '!=' => undef },
1188
            waitingdate => { '!=' => undef },
1187
        ],
1189
        ],
1188
    };
1190
    };
1189
    my $hold_rs = $self->_result->reserves->search( $params, $attributes );
1191
    my $hold_rs = $self->_result->reserves->search( $s_params, $attributes );
1190
    return Koha::Holds->_new_from_dbic($hold_rs);
1192
    return Koha::Holds->_new_from_dbic($hold_rs);
1191
}
1193
}
1192
1194
(-)a/t/db_dependent/Holds.t (-2 / +14 lines)
Lines 2111-2117 subtest 'EmailPatronWhenHoldIsPlaced tests' => sub { Link Here
2111
};
2111
};
2112
2112
2113
subtest 'current_holds with future holds' => sub {
2113
subtest 'current_holds with future holds' => sub {
2114
    plan tests => 2;
2114
    plan tests => 5;
2115
    $schema->storage->txn_begin;
2115
    $schema->storage->txn_begin;
2116
2116
2117
    t::lib::Mocks::mock_preference( 'ConfirmFutureHolds', 2 );
2117
    t::lib::Mocks::mock_preference( 'ConfirmFutureHolds', 2 );
Lines 2130-2134 subtest 'current_holds with future holds' => sub { Link Here
2130
    t::lib::Mocks::mock_preference( 'ConfirmFutureHolds', 0 );
2130
    t::lib::Mocks::mock_preference( 'ConfirmFutureHolds', 0 );
2131
    is( $item->biblio->current_holds->count, 0, 'No future hold was counted when ConfirmFutureHolds is zero' );
2131
    is( $item->biblio->current_holds->count, 0, 'No future hold was counted when ConfirmFutureHolds is zero' );
2132
2132
2133
    # Test if renewal ignores future holds (until we decide otherwise; see bug 40435)
2134
    my $patron2 = $builder->build_object( { class => 'Koha::Patrons' } );
2135
    t::lib::Mocks::mock_userenv( { branchcode => $patron2->branchcode } );
2136
    my $issue = C4::Circulation::AddIssue( $patron2, $item->barcode, dt_from_string() );
2137
    my ( $ok, $err ) = CanBookBeRenewed( $patron2, $issue );
2138
    is( $ok, 1, 'Hold does not block renewal' );
2139
2140
    # Changing the reservedate should block the renewal
2141
    Koha::Holds->find($hold_id)->reservedate( dt_from_string() )->store;
2142
    ( $ok, $err ) = CanBookBeRenewed( $patron2, $issue );
2143
    is( $ok,  0,            'Hold now blocks renewal' );
2144
    is( $err, 'on_reserve', 'Code for blocking renewal' );
2145
2133
    $schema->storage->txn_rollback;
2146
    $schema->storage->txn_rollback;
2134
};
2147
};
2135
- 

Return to bug 37651