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

(-)a/C4/Circulation.pm (-1 / +2 lines)
Lines 3191-3198 sub CanBookBeRenewed { Link Here
3191
    }
3191
    }
3192
3192
3193
    # There is an item level hold on this item, no other item can fill the hold
3193
    # There is an item level hold on this item, no other item can fill the hold
3194
    # The flag skip_future_holds may be removed in the future. See bug 40435.
3194
    return ( 0, "on_reserve" )
3195
    return ( 0, "on_reserve" )
3195
        if ( $item->current_holds->search( { non_priority => 0 } )->count );
3196
        if ( $item->current_holds( { skip_future_holds => 1 } )->search( { non_priority => 0 } )->count );
3196
3197
3197
    my ( $status, $matched_reserve, $possible_holds ) = C4::Reserves::CheckReserves($item);
3198
    my ( $status, $matched_reserve, $possible_holds ) = C4::Reserves::CheckReserves($item);
3198
    my @fillable_holds = ();
3199
    my @fillable_holds = ();
(-)a/Koha/Item.pm (-4 / +6 lines)
Lines 1164-1174 Respects the lookahead days in ConfirmFutureHolds pref. Link Here
1164
=cut
1164
=cut
1165
1165
1166
sub current_holds {
1166
sub current_holds {
1167
    my ($self)     = @_;
1167
    my ( $self, $params ) = @_;
1168
1168
    my $attributes = { order_by => 'priority' };
1169
    my $attributes = { order_by => 'priority' };
1169
    my $dtf        = Koha::Database->new->schema->storage->datetime_parser;
1170
    my $dtf        = Koha::Database->new->schema->storage->datetime_parser;
1170
    my $dt         = dt_from_string()->add( days => C4::Context->preference('ConfirmFutureHolds') || 0 );
1171
    my $days       = $params->{skip_future_holds} ? 0 : C4::Context->preference('ConfirmFutureHolds') || 0;
1171
    my $params     = {
1172
    my $dt         = dt_from_string()->add( days => $days );
1173
    my $s_params   = {
1172
        itemnumber => $self->itemnumber,
1174
        itemnumber => $self->itemnumber,
1173
        suspend    => 0,
1175
        suspend    => 0,
1174
        -or        => [
1176
        -or        => [
Lines 1176-1182 sub current_holds { Link Here
1176
            waitingdate => { '!=' => undef },
1178
            waitingdate => { '!=' => undef },
1177
        ],
1179
        ],
1178
    };
1180
    };
1179
    my $hold_rs = $self->_result->reserves->search( $params, $attributes );
1181
    my $hold_rs = $self->_result->reserves->search( $s_params, $attributes );
1180
    return Koha::Holds->_new_from_dbic($hold_rs);
1182
    return Koha::Holds->_new_from_dbic($hold_rs);
1181
}
1183
}
1182
1184
(-)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