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

(-)a/C4/Reserves.pm (+4 lines)
Lines 853-858 sub CheckReserves { Link Here
853
853
854
        my $priority = 10000000;
854
        my $priority = 10000000;
855
        foreach my $res (@reserves) {
855
        foreach my $res (@reserves) {
856
857
            #Before allocating to bib-level hold check if reserve respects hold rule, i.e. can patron category/item type combination allow reserves
858
            my $checkreserve = Koha::Hold->check_if_existing_hold_matches_issuingrules( $res->{'borrowernumber'}, $itemnumber );
859
            next unless ($checkreserve eq 'OK');
856
            if ($res->{'found'} && $res->{'found'} eq 'W') {
860
            if ($res->{'found'} && $res->{'found'} eq 'W') {
857
                return ( "Waiting", $res, \@reserves ); # Found it, it is waiting
861
                return ( "Waiting", $res, \@reserves ); # Found it, it is waiting
858
            } elsif ($res->{'found'} && $res->{'found'} eq 'P') {
862
            } elsif ($res->{'found'} && $res->{'found'} eq 'P') {
(-)a/Koha/Hold.pm (-1 / +40 lines)
Lines 476-481 sub is_suspended { Link Here
476
    return $self->suspend();
476
    return $self->suspend();
477
}
477
}
478
478
479
=head3 check_if_existing_hold_matches_issuingrules
480
481
my $checkreserve = Koha::Hold->check_if_existing_hold_matches_issuingrules($res->{'borrowernumber'}, $itemnumber );
482
483
Upon checking in an item of a bibliographic record with a biblio-level hold on it, check if a bib-level hold can be allocated to a patron based on the current values in the issuingrules table
484
485
=cut
486
487
sub check_if_existing_hold_matches_issuingrules {
488
    my ( $self, $borrowernumber, $itemnumber ) = @_;
489
490
    #Get patron and item objects
491
    my $patron = Koha::Patrons->find( $borrowernumber );
492
    my $item = Koha::Items->find( $itemnumber );
493
    $item = $item->unblessed();
494
495
    #Get branchcode
496
    my $branchcode;
497
    my $controlbranch = C4::Context->preference('ReservesControlBranch');
498
499
    if ( $controlbranch eq "ItemHomeLibrary" ) {
500
         $branchcode  = $item->{homebranch};
501
    }
502
    elsif ( $controlbranch eq "PatronLibrary" ) {
503
         $branchcode  = $patron->{branchcode};
504
    }
505
506
    my $issuingrule = Koha::IssuingRules->get_effective_issuing_rule({
507
        branchcode => $branchcode,
508
        categorycode => $patron->categorycode,
509
        itemtype => $item->{itype},
510
    });
511
512
    #Check if the patron catgeory/item type combination is valid
513
    if ( ($issuingrule->reservesallowed || $issuingrule->holds_per_record) == 0 ) {
514
        return 'InvalidHold';
515
    } else {
516
        return 'OK';
517
    }
518
}
479
519
480
=head3 cancel
520
=head3 cancel
481
521
482
- 

Return to bug 23172