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

(-)a/C4/Circulation.pm (-17 / +6 lines)
Lines 3053-3070 sub CanBookBeRenewed { Link Here
3053
    return ( 0, "on_reserve" )
3053
    return ( 0, "on_reserve" )
3054
      if ( $item->current_holds->search( { non_priority => 0 } )->count );
3054
      if ( $item->current_holds->search( { non_priority => 0 } )->count );
3055
3055
3056
    my $fillable_holds = Koha::Holds->search(
3056
3057
        {
3057
    my ($status, $matched_reserve, $fillable_holds) = CheckReserves($item);
3058
            biblionumber => $item->biblionumber,
3058
    if ( $fillable_holds ) {
3059
            non_priority => 0,
3060
            found        => undef,
3061
            reservedate  => { '<=' => \'NOW()' },
3062
            suspend      => 0
3063
        }
3064
    );
3065
    if ( $fillable_holds->count ) {
3066
        if ( C4::Context->preference('AllowRenewalIfOtherItemsAvailable') ) {
3059
        if ( C4::Context->preference('AllowRenewalIfOtherItemsAvailable') ) {
3067
            my @possible_holds = $fillable_holds->as_list;
3068
3060
3069
            # Get all other items that could possibly fill reserves
3061
            # Get all other items that could possibly fill reserves
3070
            # FIXME We could join reserves (or more tables) here to eliminate some checks later
3062
            # FIXME We could join reserves (or more tables) here to eliminate some checks later
Lines 3074-3087 sub CanBookBeRenewed { Link Here
3074
                notforloan   => 0,
3066
                notforloan   => 0,
3075
                -not         => { itemnumber => $item->itemnumber } })->as_list;
3067
                -not         => { itemnumber => $item->itemnumber } })->as_list;
3076
3068
3077
            return ( 0, "on_reserve" ) if @possible_holds && (scalar @other_items < scalar @possible_holds);
3069
            return ( 0, "on_reserve" ) if @{$fillable_holds} && (scalar @other_items < scalar @{$fillable_holds} );
3078
3070
3079
            my %matched_items;
3071
            my %matched_items;
3080
            foreach my $possible_hold (@possible_holds) {
3072
            foreach my $possible_hold ( @{$fillable_holds} ) {
3081
                my $fillable = 0;
3073
                my $fillable = 0;
3082
                my $patron_with_reserve = Koha::Patrons->find($possible_hold->borrowernumber);
3074
                my $patron_with_reserve = Koha::Patrons->find($possible_hold->{borrowernumber});
3083
3084
                # FIXME: We are not checking whether the item we are renewing can fill the hold
3085
3075
3086
                foreach my $other_item (@other_items) {
3076
                foreach my $other_item (@other_items) {
3087
                  next if defined $matched_items{$other_item->itemnumber};
3077
                  next if defined $matched_items{$other_item->itemnumber};
Lines 3099-3105 sub CanBookBeRenewed { Link Here
3099
            }
3089
            }
3100
        }
3090
        }
3101
        else {
3091
        else {
3102
            my ($status, $matched_reserve, $possible_reserves) = CheckReserves($item);
3103
            return ( 0, "on_reserve" ) if $status;
3092
            return ( 0, "on_reserve" ) if $status;
3104
        }
3093
        }
3105
    }
3094
    }
(-)a/t/db_dependent/Circulation.t (-6 / +2 lines)
Lines 4457-4468 subtest 'ItemsDeniedRenewal rules are checked' => sub { Link Here
4457
        }
4457
        }
4458
    );
4458
    );
4459
4459
4460
    my $allow_book = $builder->build_object({ class => 'Koha::Items', value => {
4460
    my $allow_book = $builder->build_sample_item({
4461
        homebranch => $idr_lib->branchcode,
4461
        homebranch => $idr_lib->branchcode,
4462
        withdrawn => 0,
4462
        holdingbranch => $idr_lib->branchcode,
4463
        itype => 'NOHIDE',
4464
        location => 'NOPROC'
4465
        }
4466
    });
4463
    });
4467
4464
4468
    my $idr_borrower = $builder->build_object({ class => 'Koha::Patrons', value=> {
4465
    my $idr_borrower = $builder->build_object({ class => 'Koha::Patrons', value=> {
4469
- 

Return to bug 36331