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

(-)a/C4/Circulation.pm (-17 / +6 lines)
Lines 3069-3086 sub CanBookBeRenewed { Link Here
3069
    return ( 0, "on_reserve" )
3069
    return ( 0, "on_reserve" )
3070
      if ( $item->current_holds->search( { non_priority => 0 } )->count );
3070
      if ( $item->current_holds->search( { non_priority => 0 } )->count );
3071
3071
3072
    my $fillable_holds = Koha::Holds->search(
3072
3073
        {
3073
    my ($status, $matched_reserve, $fillable_holds) = CheckReserves($item);
3074
            biblionumber => $item->biblionumber,
3074
    if ( $fillable_holds ) {
3075
            non_priority => 0,
3076
            found        => undef,
3077
            reservedate  => { '<=' => \'NOW()' },
3078
            suspend      => 0
3079
        }
3080
    );
3081
    if ( $fillable_holds->count ) {
3082
        if ( C4::Context->preference('AllowRenewalIfOtherItemsAvailable') ) {
3075
        if ( C4::Context->preference('AllowRenewalIfOtherItemsAvailable') ) {
3083
            my @possible_holds = $fillable_holds->as_list;
3084
3076
3085
            # Get all other items that could possibly fill reserves
3077
            # Get all other items that could possibly fill reserves
3086
            # FIXME We could join reserves (or more tables) here to eliminate some checks later
3078
            # FIXME We could join reserves (or more tables) here to eliminate some checks later
Lines 3090-3103 sub CanBookBeRenewed { Link Here
3090
                notforloan   => 0,
3082
                notforloan   => 0,
3091
                -not         => { itemnumber => $item->itemnumber } })->as_list;
3083
                -not         => { itemnumber => $item->itemnumber } })->as_list;
3092
3084
3093
            return ( 0, "on_reserve" ) if @possible_holds && (scalar @other_items < scalar @possible_holds);
3085
            return ( 0, "on_reserve" ) if @{$fillable_holds} && (scalar @other_items < scalar @{$fillable_holds} );
3094
3086
3095
            my %matched_items;
3087
            my %matched_items;
3096
            foreach my $possible_hold (@possible_holds) {
3088
            foreach my $possible_hold ( @{$fillable_holds} ) {
3097
                my $fillable = 0;
3089
                my $fillable = 0;
3098
                my $patron_with_reserve = Koha::Patrons->find($possible_hold->borrowernumber);
3090
                my $patron_with_reserve = Koha::Patrons->find($possible_hold->{borrowernumber});
3099
3100
                # FIXME: We are not checking whether the item we are renewing can fill the hold
3101
3091
3102
                foreach my $other_item (@other_items) {
3092
                foreach my $other_item (@other_items) {
3103
                  next if defined $matched_items{$other_item->itemnumber};
3093
                  next if defined $matched_items{$other_item->itemnumber};
Lines 3115-3121 sub CanBookBeRenewed { Link Here
3115
            }
3105
            }
3116
        }
3106
        }
3117
        else {
3107
        else {
3118
            my ($status, $matched_reserve, $possible_reserves) = CheckReserves($item);
3119
            return ( 0, "on_reserve" ) if $status;
3108
            return ( 0, "on_reserve" ) if $status;
3120
        }
3109
        }
3121
    }
3110
    }
(-)a/t/db_dependent/Circulation.t (-6 / +2 lines)
Lines 4421-4432 subtest 'ItemsDeniedRenewal rules are checked' => sub { Link Here
4421
        }
4421
        }
4422
    );
4422
    );
4423
4423
4424
    my $allow_book = $builder->build_object({ class => 'Koha::Items', value => {
4424
    my $allow_book = $builder->build_sample_item({
4425
        homebranch => $idr_lib->branchcode,
4425
        homebranch => $idr_lib->branchcode,
4426
        withdrawn => 0,
4426
        holdingbranch => $idr_lib->branchcode,
4427
        itype => 'NOHIDE',
4428
        location => 'NOPROC'
4429
        }
4430
    });
4427
    });
4431
4428
4432
    my $idr_borrower = $builder->build_object({ class => 'Koha::Patrons', value=> {
4429
    my $idr_borrower = $builder->build_object({ class => 'Koha::Patrons', value=> {
4433
- 

Return to bug 36331