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

(-)a/C4/Reserves.pm (+5 lines)
Lines 810-815 sub CheckReserves { Link Here
810
810
811
        my $priority = 10000000;
811
        my $priority = 10000000;
812
        foreach my $res (@reserves) {
812
        foreach my $res (@reserves) {
813
814
            #Before allocating to bib-level hold check if reserve respects hold rule, i.e. can patron category/item type combination allow reserves
815
            my $checkreserve = Koha::Hold->check_if_existing_hold_matches_issuingrules( $res->{'borrowernumber'}, $itemnumber );
816
            next unless ($checkreserve eq 'OK');
817
813
            if ( $res->{'itemnumber'} && $res->{'itemnumber'} == $itemnumber && $res->{'priority'} == 0) {
818
            if ( $res->{'itemnumber'} && $res->{'itemnumber'} == $itemnumber && $res->{'priority'} == 0) {
814
                if ($res->{'found'} eq 'W') {
819
                if ($res->{'found'} eq 'W') {
815
                    return ( "Waiting", $res, \@reserves ); # Found it, it is waiting
820
                    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