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

(-)a/C4/Reserves.pm (+5 lines)
Lines 758-763 sub CheckReserves { Link Here
758
758
759
        my $priority = 10000000;
759
        my $priority = 10000000;
760
        foreach my $res (@reserves) {
760
        foreach my $res (@reserves) {
761
762
            #Before allocating to bib-level hold check if reserve respects hold rule, i.e. can patron category/item type combination allow reserves
763
            my $checkreserve = Koha::Hold->check_if_existing_hold_matches_issuingrules( $res->{'borrowernumber'}, $itemnumber );
764
            next unless ($checkreserve eq 'OK');
765
761
            if ( $res->{'itemnumber'} == $itemnumber && $res->{'priority'} == 0) {
766
            if ( $res->{'itemnumber'} == $itemnumber && $res->{'priority'} == 0) {
762
                if ($res->{'found'} eq 'W') {
767
                if ($res->{'found'} eq 'W') {
763
                    return ( "Waiting", $res, \@reserves ); # Found it, it is waiting
768
                    return ( "Waiting", $res, \@reserves ); # Found it, it is waiting
(-)a/Koha/Hold.pm (-1 / +40 lines)
Lines 337-342 sub is_suspended { Link Here
337
    return $self->suspend();
337
    return $self->suspend();
338
}
338
}
339
339
340
=head3 check_if_existing_hold_matches_issuingrules
341
342
my $checkreserve = Koha::Hold->check_if_existing_hold_matches_issuingrules($res->{'borrowernumber'}, $itemnumber );
343
344
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
345
346
=cut
347
348
sub check_if_existing_hold_matches_issuingrules {
349
    my ( $self, $borrowernumber, $itemnumber ) = @_;
350
351
    #Get patron and item objects
352
    my $patron = Koha::Patrons->find( $borrowernumber );
353
    my $item = Koha::Items->find( $itemnumber );
354
    $item = $item->unblessed();
355
356
    #Get branchcode
357
    my $branchcode;
358
    my $controlbranch = C4::Context->preference('ReservesControlBranch');
359
360
    if ( $controlbranch eq "ItemHomeLibrary" ) {
361
         $branchcode  = $item->{homebranch};
362
    }
363
    elsif ( $controlbranch eq "PatronLibrary" ) {
364
         $branchcode  = $patron->{branchcode};
365
    }
366
367
    my $issuingrule = Koha::IssuingRules->get_effective_issuing_rule({
368
        branchcode => $branchcode,
369
        categorycode => $patron->categorycode,
370
        itemtype => $item->{itype},
371
    });
372
373
    #Check if the patron catgeory/item type combination is valid
374
    if ( ($issuingrule->reservesallowed || $issuingrule->holds_per_record) == 0 ) {
375
        return 'InvalidHold';
376
    } else {
377
        return 'OK';
378
    }
379
}
340
380
341
=head3 cancel
381
=head3 cancel
342
382
343
- 

Return to bug 23172