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

(-)a/C4/Circulation.pm (-42 / +45 lines)
Lines 432-439 sub TooMany { Link Here
432
    # applicable issuing rule
432
    # applicable issuing rule
433
433
434
    # If the parent rule is for default type we discount it
434
    # If the parent rule is for default type we discount it
435
    my $parent_maxissueqty;
435
    my $parent_maxissueqty_rule;
436
    $parent_maxissueqty = Koha::CirculationRules->get_effective_rule_value(
436
    $parent_maxissueqty_rule = Koha::CirculationRules->get_effective_rule(
437
        {
437
        {
438
            categorycode => $cat_borrower,
438
            categorycode => $cat_borrower,
439
            itemtype     => $parent_type,
439
            itemtype     => $parent_type,
Lines 441-448 sub TooMany { Link Here
441
            rule_name    => 'maxissueqty',
441
            rule_name    => 'maxissueqty',
442
        }
442
        }
443
    ) if $parent_type;
443
    ) if $parent_type;
444
    # If the parent rule is for default type we discount it
445
    $parent_maxissueqty_rule = undef if $parent_maxissueqty_rule && !defined $parent_maxissueqty_rule->itemtype;
444
446
445
    my $maxissueqty = Koha::CirculationRules->get_effective_rule_value(
447
    my $maxissueqty_rule = Koha::CirculationRules->get_effective_rule(
446
        {
448
        {
447
            categorycode => $cat_borrower,
449
            categorycode => $cat_borrower,
448
            itemtype     => $type,
450
            itemtype     => $type,
Lines 451-457 sub TooMany { Link Here
451
        }
453
        }
452
    );
454
    );
453
455
454
    my $maxonsiteissueqty = Koha::CirculationRules->get_effective_rule_value(
456
    my $maxonsiteissueqty_rule = Koha::CirculationRules->get_effective_rule(
455
        {
457
        {
456
            categorycode => $cat_borrower,
458
            categorycode => $cat_borrower,
457
            itemtype     => $type,
459
            itemtype     => $type,
Lines 463-480 sub TooMany { Link Here
463
    # if a rule is found and has a loan limit set, count
465
    # if a rule is found and has a loan limit set, count
464
    # how many loans the patron already has that meet that
466
    # how many loans the patron already has that meet that
465
    # rule
467
    # rule
466
    if (defined $maxissueqty and $maxissueqty ne "") {
468
    if (defined $maxissueqty_rule and $maxissueqty_rule->rule_value ne "") {
467
469
468
        my $checkouts;
470
        my $checkouts;
469
        if ( $branch ) {
471
        if ( $maxissueqty_rule->branchcode ) {
470
            if ( C4::Context->preference('CircControl') eq 'PickupLibrary' ) {
472
            if ( C4::Context->preference('CircControl') eq 'PickupLibrary' ) {
471
                $checkouts = $patron->checkouts->search(
473
                $checkouts = $patron->checkouts->search(
472
                    { 'me.branchcode' => $branch } );
474
                    { 'me.branchcode' => $maxissueqty_rule->branchcode } );
473
            } elsif (C4::Context->preference('CircControl') eq 'PatronLibrary') {
475
            } elsif (C4::Context->preference('CircControl') eq 'PatronLibrary') {
474
                $checkouts = $patron->checkouts; # if branch is the patron's home branch, then count all loans by patron
476
                $checkouts = $patron->checkouts; # if branch is the patron's home branch, then count all loans by patron
475
            } else {
477
            } else {
476
                my $branch_type = C4::Context->preference('HomeOrHoldingBranch') || 'homebranch';
478
                my $branch_type = C4::Context->preference('HomeOrHoldingBranch') || 'homebranch';
477
                $checkouts = $patron->checkouts->search( { "item.$branch_type" => $branch } );
479
                $checkouts = $patron->checkouts->search( { "item.$branch_type" => $maxissueqty_rule->branchcode } );
478
            }
480
            }
479
        } else {
481
        } else {
480
            $checkouts = $patron->checkouts; # if rule is not branch specific then count all loans by patron
482
            $checkouts = $patron->checkouts; # if rule is not branch specific then count all loans by patron
Lines 484-503 sub TooMany { Link Here
484
        my $sum_checkouts;
486
        my $sum_checkouts;
485
487
486
        my @types;
488
        my @types;
487
        unless ( $type ) {
489
        unless ( $maxissueqty_rule->itemtype ) {
488
            # matching rule has the default item type, so count only
490
            # matching rule has the default item type, so count only
489
            # those existing loans that don't fall under a more
491
            # those existing loans that don't fall under a more
490
            # specific rule
492
            # specific rule
491
            @types = Koha::CirculationRules->search(
493
            @types = Koha::CirculationRules->search(
492
                {
494
                {
493
                    branchcode => $branch,
495
                    branchcode => $maxissueqty_rule->branchcode,
494
                    categorycode => $cat_borrower,
496
                    categorycode => [ $maxissueqty_rule->categorycode, $cat_borrower ],
495
                    itemtype  => { '!=' => undef },
497
                    itemtype  => { '!=' => undef },
496
                    rule_name => 'maxissueqty'
498
                    rule_name => 'maxissueqty'
497
                }
499
                }
498
            )->get_column('itemtype');
500
            )->get_column('itemtype');
499
        } else {
501
        } else {
500
            if ( $parent_maxissueqty ) {
502
            if ( defined $parent_maxissueqty_rule ) {
501
                # if we have a parent item type then we count loans of the
503
                # if we have a parent item type then we count loans of the
502
                # specific item type or its siblings or parent
504
                # specific item type or its siblings or parent
503
                my $children = Koha::ItemTypes->search({ parent_type => $parent_type });
505
                my $children = Koha::ItemTypes->search({ parent_type => $parent_type });
Lines 516-522 sub TooMany { Link Here
516
        while ( my $c = $checkouts->next ) {
518
        while ( my $c = $checkouts->next ) {
517
            my $itemtype = $c->item->effective_itemtype;
519
            my $itemtype = $c->item->effective_itemtype;
518
520
519
            unless ( $type ) {
521
            unless ( $maxissueqty_rule->itemtype ) {
520
                next if grep {$_ eq $itemtype} @types;
522
                next if grep {$_ eq $itemtype} @types;
521
            } else {
523
            } else {
522
                next unless grep {$_ eq $itemtype} @types;
524
                next unless grep {$_ eq $itemtype} @types;
Lines 535-554 sub TooMany { Link Here
535
            checkout_count               => $checkout_count,
537
            checkout_count               => $checkout_count,
536
            onsite_checkout_count        => $onsite_checkout_count,
538
            onsite_checkout_count        => $onsite_checkout_count,
537
            onsite_checkout              => $onsite_checkout,
539
            onsite_checkout              => $onsite_checkout,
538
            max_checkouts_allowed        => $maxissueqty,,
540
            max_checkouts_allowed        => $maxissueqty_rule ? $maxissueqty_rule->rule_value : undef,
539
            max_onsite_checkouts_allowed => $maxonsiteissueqty,
541
            max_onsite_checkouts_allowed => $maxonsiteissueqty_rule ? $maxonsiteissueqty_rule->rule_value : undef,
540
            switch_onsite_checkout       => $switch_onsite_checkout,
542
            switch_onsite_checkout       => $switch_onsite_checkout,
541
        };
543
        };
542
        # If parent rules exists
544
        # If parent rules exists
543
        if ( defined $parent_maxissueqty ){
545
        if ( defined $parent_maxissueqty_rule ) {
544
            $checkout_rules->{max_checkouts_allowed} = $parent_maxissueqty;
546
            $checkout_rules->{max_checkouts_allowed} = $parent_maxissueqty_rule->rule_value;
545
            my $qty_over = _check_max_qty($checkout_rules);
547
            my $qty_over = _check_max_qty($checkout_rules);
546
            return $qty_over if defined $qty_over;
548
            return $qty_over if defined $qty_over;
547
549
548
            # If the parent rule is less than or equal to the child, we only need check the parent
550
            # If the parent rule is less than or equal to the child, we only need check the parent
549
            if( $maxissueqty < $parent_maxissueqty && defined($type) ) {
551
            if(
552
                $maxissueqty_rule->rule_value < $parent_maxissueqty_rule->rule_value
553
                && defined($maxissueqty_rule->itemtype)
554
            ) {
550
                $checkout_rules->{checkout_count} = $checkout_count_type;
555
                $checkout_rules->{checkout_count} = $checkout_count_type;
551
                $checkout_rules->{max_checkouts_allowed} = $maxissueqty;
556
                $checkout_rules->{max_checkouts_allowed} = $maxissueqty_rule->rule_value;
552
                my $qty_over = _check_max_qty($checkout_rules);
557
                my $qty_over = _check_max_qty($checkout_rules);
553
                return $qty_over if defined $qty_over;
558
                return $qty_over if defined $qty_over;
554
            }
559
            }
Lines 560-566 sub TooMany { Link Here
560
565
561
    # Now count total loans against the limit for the branch
566
    # Now count total loans against the limit for the branch
562
    my $branch_borrower_circ_rule = GetBranchBorrowerCircRule($branch, $cat_borrower);
567
    my $branch_borrower_circ_rule = GetBranchBorrowerCircRule($branch, $cat_borrower);
563
    if (defined($branch_borrower_circ_rule->{patron_maxissueqty}) and $branch_borrower_circ_rule->{patron_maxissueqty} ne '') {
568
    if (
569
        defined($branch_borrower_circ_rule->{patron_maxissueqty})
570
        and $branch_borrower_circ_rule->{patron_maxissueqty} ne ''
571
    ) {
564
        my $checkouts;
572
        my $checkouts;
565
        if ( C4::Context->preference('CircControl') eq 'PickupLibrary' ) {
573
        if ( C4::Context->preference('CircControl') eq 'PickupLibrary' ) {
566
            $checkouts = $patron->checkouts->search(
574
            $checkouts = $patron->checkouts->search(
Lines 592-598 sub TooMany { Link Here
592
        return $qty_over if defined $qty_over;
600
        return $qty_over if defined $qty_over;
593
    }
601
    }
594
602
595
    unless ( defined $maxissueqty || defined $branch_borrower_circ_rule->{patron_maxissueqty} ) {
603
    unless ( defined $maxissueqty_rule || defined $branch_borrower_circ_rule->{patron_maxissueqty} ) {
596
        return { reason => 'NO_RULE_DEFINED', max_allowed => 0 };
604
        return { reason => 'NO_RULE_DEFINED', max_allowed => 0 };
597
    }
605
    }
598
606
Lines 610-616 sub _check_max_qty { Link Here
610
    my $switch_onsite_checkout       = $params->{switch_onsite_checkout};
618
    my $switch_onsite_checkout       = $params->{switch_onsite_checkout};
611
619
612
    if ( $onsite_checkout and defined $max_onsite_checkouts_allowed ) {
620
    if ( $onsite_checkout and defined $max_onsite_checkouts_allowed ) {
613
        if ( $max_onsite_checkouts_allowed eq '' ) { return; }
621
        return if $max_onsite_checkouts_allowed eq '';
614
        if ( $onsite_checkout_count >= $max_onsite_checkouts_allowed ) {
622
        if ( $onsite_checkout_count >= $max_onsite_checkouts_allowed ) {
615
            return {
623
            return {
616
                reason      => 'TOO_MANY_ONSITE_CHECKOUTS',
624
                reason      => 'TOO_MANY_ONSITE_CHECKOUTS',
Lines 620-626 sub _check_max_qty { Link Here
620
        }
628
        }
621
    }
629
    }
622
    if ( C4::Context->preference('ConsiderOnSiteCheckoutsAsNormalCheckouts') ) {
630
    if ( C4::Context->preference('ConsiderOnSiteCheckoutsAsNormalCheckouts') ) {
623
        if ( $max_checkouts_allowed eq '' ) { return; }
631
        return if $max_checkouts_allowed eq '';
624
        my $delta = $switch_onsite_checkout ? 1 : 0;
632
        my $delta = $switch_onsite_checkout ? 1 : 0;
625
        if ( $checkout_count >= $max_checkouts_allowed + $delta ) {
633
        if ( $checkout_count >= $max_checkouts_allowed + $delta ) {
626
            return {
634
            return {
Lines 631-640 sub _check_max_qty { Link Here
631
        }
639
        }
632
    }
640
    }
633
    elsif ( not $onsite_checkout ) {
641
    elsif ( not $onsite_checkout ) {
634
        if ( $max_checkouts_allowed eq '' ) { return; }
642
        return if $max_checkouts_allowed eq '';
635
        if (
643
        if (
636
            $checkout_count - $onsite_checkout_count >= $max_checkouts_allowed )
644
            $checkout_count - $onsite_checkout_count >= $max_checkouts_allowed
637
        {
645
        ) {
638
            return {
646
            return {
639
                reason      => 'TOO_MANY_CHECKOUTS',
647
                reason      => 'TOO_MANY_CHECKOUTS',
640
                count       => $checkout_count - $onsite_checkout_count,
648
                count       => $checkout_count - $onsite_checkout_count,
Lines 1416-1437 sub checkHighHolds { Link Here
1416
1424
1417
        my $orig_due = C4::Circulation::CalcDateDue( $issuedate, $itype, $branchcode, $patron );
1425
        my $orig_due = C4::Circulation::CalcDateDue( $issuedate, $itype, $branchcode, $patron );
1418
1426
1419
        my $rule = Koha::CirculationRules->get_effective_rule_value(
1427
        # overrides decreaseLoanHighHoldsDuration syspref
1428
        my $duration = Koha::CirculationRules->get_effective_rule_value(
1420
            {
1429
            {
1421
                categorycode => $patron->categorycode,
1430
                categorycode => $patron->categorycode,
1422
                itemtype     => $item->effective_itemtype,
1431
                itemtype     => $item->effective_itemtype,
1423
                branchcode   => $branchcode,
1432
                branchcode   => $branchcode,
1424
                rule_name    => 'decreaseloanholds',
1433
                rule_name    => 'decreaseloanholds',
1425
            }
1434
            }
1426
        );
1435
        ) || C4::Context->preference('decreaseLoanHighHoldsDuration');
1427
1436
1428
        my $duration;
1429
        if ( defined($rule) && $rule ne '' ){
1430
            # overrides decreaseLoanHighHoldsDuration syspref
1431
            $duration = $rule;
1432
        } else {
1433
            $duration = C4::Context->preference('decreaseLoanHighHoldsDuration');
1434
        }
1435
        my $reduced_datedue = $calendar->addDuration( $issuedate, $duration );
1437
        my $reduced_datedue = $calendar->addDuration( $issuedate, $duration );
1436
        $reduced_datedue->set_hour($orig_due->hour);
1438
        $reduced_datedue->set_hour($orig_due->hour);
1437
        $reduced_datedue->set_minute($orig_due->minute);
1439
        $reduced_datedue->set_minute($orig_due->minute);
Lines 1919-1924 wildcards. Link Here
1919
1921
1920
sub GetBranchBorrowerCircRule {
1922
sub GetBranchBorrowerCircRule {
1921
    my ( $branchcode, $categorycode ) = @_;
1923
    my ( $branchcode, $categorycode ) = @_;
1924
1922
    return Koha::CirculationRules->get_effective_rules(
1925
    return Koha::CirculationRules->get_effective_rules(
1923
        {
1926
        {
1924
            categorycode => $categorycode,
1927
            categorycode => $categorycode,
Lines 2690-2700 sub _calculate_new_debar_dt { Link Here
2690
            ]
2693
            ]
2691
        }
2694
        }
2692
    );
2695
    );
2693
    my $finedays = $issuing_rule ? $issuing_rule->{finedays} : undef;
2696
    return unless $issuing_rule->{finedays};
2694
    my $unit     = $issuing_rule ? $issuing_rule->{lengthunit} : undef;
2697
    my $finedays = $issuing_rule->{finedays};
2698
    my $unit     = $issuing_rule->{lengthunit};
2695
    my $chargeable_units = C4::Overdues::get_chargeable_units($unit, $dt_due, $return_date, $branchcode);
2699
    my $chargeable_units = C4::Overdues::get_chargeable_units($unit, $dt_due, $return_date, $branchcode);
2696
2700
2697
    return unless $finedays;
2698
2701
2699
    # finedays is in days, so hourly loans must multiply by 24
2702
    # finedays is in days, so hourly loans must multiply by 24
2700
    # thus 1 hour late equals 1 day suspension * finedays rate
2703
    # thus 1 hour late equals 1 day suspension * finedays rate
Lines 3217-3230 sub AddRenewal { Link Here
3217
        # a maximum value has been set in the circ rules
3220
        # a maximum value has been set in the circ rules
3218
        my $unseen_renewals = $issue->unseen_renewals;
3221
        my $unseen_renewals = $issue->unseen_renewals;
3219
        if (C4::Context->preference('UnseenRenewals')) {
3222
        if (C4::Context->preference('UnseenRenewals')) {
3220
            my $rule = Koha::CirculationRules->get_effective_rule(
3223
            my $unseen_renewals_allowed = Koha::CirculationRules->get_effective_rule_value(
3221
                {   categorycode => $patron->categorycode,
3224
                {   categorycode => $patron->categorycode,
3222
                    itemtype     => $item_object->effective_itemtype,
3225
                    itemtype     => $item_object->effective_itemtype,
3223
                    branchcode   => $circ_library->branchcode,
3226
                    branchcode   => $circ_library->branchcode,
3224
                    rule_name    => 'unseen_renewals_allowed'
3227
                    rule_name    => 'unseen_renewals_allowed'
3225
                }
3228
                }
3226
            );
3229
            );
3227
            if (!$seen && $rule && looks_like_number($rule->rule_value)) {
3230
            if (!$seen && $unseen_renewals_allowed && looks_like_number($unseen_renewals_allowed)) {
3228
                $unseen_renewals++;
3231
                $unseen_renewals++;
3229
            } else {
3232
            } else {
3230
                # If the renewal is seen, unseen should revert to 0
3233
                # If the renewal is seen, unseen should revert to 0
Lines 3583-3596 sub GetIssuingCharges { Link Here
3583
            # FIXME This should follow CircControl
3586
            # FIXME This should follow CircControl
3584
            my $branch = C4::Context::mybranch();
3587
            my $branch = C4::Context::mybranch();
3585
            $patron //= Koha::Patrons->find( $borrowernumber );
3588
            $patron //= Koha::Patrons->find( $borrowernumber );
3586
            my $discount = Koha::CirculationRules->get_effective_rule({
3589
            my $discount = Koha::CirculationRules->get_effective_rule_value({
3587
                categorycode => $patron->categorycode,
3590
                categorycode => $patron->categorycode,
3588
                branchcode   => $branch,
3591
                branchcode   => $branch,
3589
                itemtype     => $item_type,
3592
                itemtype     => $item_type,
3590
                rule_name    => 'rentaldiscount'
3593
                rule_name    => 'rentaldiscount'
3591
            });
3594
            });
3592
            if ($discount) {
3595
            if ($discount) {
3593
                $charge = ( $charge * ( 100 - $discount->rule_value ) ) / 100;
3596
                $charge = ( $charge * ( 100 - $discount ) ) / 100;
3594
            }
3597
            }
3595
            $charge = sprintf '%.2f', $charge; # ensure no fractions of a penny returned
3598
            $charge = sprintf '%.2f', $charge; # ensure no fractions of a penny returned
3596
        }
3599
        }
(-)a/Koha/Biblio.pm (-3 / +3 lines)
Lines 1566-1574 sub can_be_recalled { Link Here
1566
                'on_shelf_recalls',
1566
                'on_shelf_recalls',
1567
            ],
1567
            ],
1568
        });
1568
        });
1569
        push( @recalls_allowed, $rule->{recalls_allowed} ) if $rule;
1569
        push( @recalls_allowed, $rule->{recalls_allowed} ) if $rule->{recalls_allowed};
1570
        push( @recalls_per_record, $rule->{recalls_per_record} ) if $rule;
1570
        push( @recalls_per_record, $rule->{recalls_per_record} ) if $rule->{recalls_per_record};
1571
        push( @on_shelf_recalls, $rule->{on_shelf_recalls} ) if $rule;
1571
        push( @on_shelf_recalls, $rule->{on_shelf_recalls} ) if $rule->{on_shelf_recalls};
1572
    }
1572
    }
1573
    my $recalls_allowed = (sort {$b <=> $a} @recalls_allowed)[0]; # take highest
1573
    my $recalls_allowed = (sort {$b <=> $a} @recalls_allowed)[0]; # take highest
1574
    my $recalls_per_record = (sort {$b <=> $a} @recalls_per_record)[0]; # take highest
1574
    my $recalls_per_record = (sort {$b <=> $a} @recalls_per_record)[0]; # take highest
(-)a/Koha/CirculationRules.pm (-1 / +3 lines)
Lines 313-319 sub get_effective_rule_value { Link Here
313
        if ($rule) {
313
        if ($rule) {
314
            $value = $rule->rule_value;
314
            $value = $rule->rule_value;
315
        }
315
        }
316
        $value //= 'undef';
316
        else {
317
            $value = 'undef';
318
        }
317
        $memory_cache->set_in_cache( $cache_key, $value );
319
        $memory_cache->set_in_cache( $cache_key, $value );
318
    }
320
    }
319
    return if $value eq 'undef';
321
    return if $value eq 'undef';
(-)a/Koha/Item.pm (-3 / +4 lines)
Lines 1902-1913 sub can_be_recalled { Link Here
1902
    });
1902
    });
1903
1903
1904
    # check recalls allowed has been set and is not zero
1904
    # check recalls allowed has been set and is not zero
1905
    return 0 if ( !defined($rule->{recalls_allowed}) || $rule->{recalls_allowed} == 0 );
1905
    return 0 if !$rule->{recalls_allowed};
1906
1906
1907
    if ( $patron ) {
1907
    if ( $patron ) {
1908
        # check borrower has not reached open recalls allowed limit
1908
        # check borrower has not reached open recalls allowed limit
1909
        return 0 if ( $patron->recalls->filter_by_current->count >= $rule->{recalls_allowed} );
1909
        return 0 if ( $patron->recalls->filter_by_current->count >= $rule->{recalls_allowed} );
1910
1910
1911
        $rule->{recalls_per_record} //= 0;
1911
        # check borrower has not reach open recalls allowed per record limit
1912
        # check borrower has not reach open recalls allowed per record limit
1912
        return 0 if ( $patron->recalls->filter_by_current->search({ biblio_id => $self->biblionumber })->count >= $rule->{recalls_per_record} );
1913
        return 0 if ( $patron->recalls->filter_by_current->search({ biblio_id => $self->biblionumber })->count >= $rule->{recalls_per_record} );
1913
1914
Lines 1976-1987 sub can_be_waiting_recall { Link Here
1976
            branchcode   => $branchcode,
1977
            branchcode   => $branchcode,
1977
            categorycode => $most_relevant_recall ? $most_relevant_recall->patron->categorycode : undef,
1978
            categorycode => $most_relevant_recall ? $most_relevant_recall->patron->categorycode : undef,
1978
            itemtype     => $self->effective_itemtype,
1979
            itemtype     => $self->effective_itemtype,
1979
            rules        => [ 'recalls_allowed', ],
1980
            rules        => [ 'recalls_allowed' ],
1980
        }
1981
        }
1981
    );
1982
    );
1982
1983
1983
    # check recalls allowed has been set and is not zero
1984
    # check recalls allowed has been set and is not zero
1984
    return 0 if ( !defined($rule->{recalls_allowed}) || $rule->{recalls_allowed} == 0 );
1985
    return 0 if !$rule->{recalls_allowed};
1985
1986
1986
    # can recall
1987
    # can recall
1987
    return 1;
1988
    return 1;
(-)a/misc/cronjobs/recalls/expire_recalls.pl (-3 / +3 lines)
Lines 50-56 while( my $recall = $recalls->next ) { Link Here
50
        }
50
        }
51
    }
51
    }
52
    if ( $recall->waiting ) {
52
    if ( $recall->waiting ) {
53
        my $recall_shelf_time = Koha::CirculationRules->get_effective_rule({
53
        my $recall_shelf_time = Koha::CirculationRules->get_effective_rule_value({
54
            categorycode => $recall->patron->categorycode,
54
            categorycode => $recall->patron->categorycode,
55
            itemtype => $recall->item->effective_itemtype,
55
            itemtype => $recall->item->effective_itemtype,
56
            branchcode => $recall->pickup_library_id,
56
            branchcode => $recall->pickup_library_id,
Lines 58-65 while( my $recall = $recalls->next ) { Link Here
58
        });
58
        });
59
        my $waitingdate = dt_from_string( $recall->waiting_date )->truncate( to  => 'day' );
59
        my $waitingdate = dt_from_string( $recall->waiting_date )->truncate( to  => 'day' );
60
        my $days_waiting = $today->subtract_datetime( $waitingdate );
60
        my $days_waiting = $today->subtract_datetime( $waitingdate );
61
        if ( defined $recall_shelf_time and $recall_shelf_time->rule_value >= 0 ) {
61
        if ( defined $recall_shelf_time and $recall_shelf_time >= 0 ) {
62
            if ( $days_waiting->days > $recall_shelf_time->rule_value ) {
62
            if ( $days_waiting->days > $recall_shelf_time ) {
63
                # recall has been awaiting pickup for longer than the circ rules allow
63
                # recall has been awaiting pickup for longer than the circ rules allow
64
                $recall->set_expired({ interface => 'COMMANDLINE' });
64
                $recall->set_expired({ interface => 'COMMANDLINE' });
65
            }
65
            }
(-)a/opac/opac-recall.pl (-2 / +2 lines)
Lines 48-60 if ( C4::Context->preference('UseRecalls') ) { Link Here
48
    # check if already recalled
48
    # check if already recalled
49
    my $recalled = $biblio->recalls->filter_by_current->search({ patron_id => $borrowernumber })->count;
49
    my $recalled = $biblio->recalls->filter_by_current->search({ patron_id => $borrowernumber })->count;
50
    if ( defined $recalled and $recalled > 0 ) {
50
    if ( defined $recalled and $recalled > 0 ) {
51
        my $recalls_per_record = Koha::CirculationRules->get_effective_rule({
51
        my $recalls_per_record = Koha::CirculationRules->get_effective_rule_value({
52
            categorycode => $patron->categorycode,
52
            categorycode => $patron->categorycode,
53
            branchcode => undef,
53
            branchcode => undef,
54
            itemtype => undef,
54
            itemtype => undef,
55
            rule_name => 'recalls_per_record'
55
            rule_name => 'recalls_per_record'
56
        });
56
        });
57
        if ( defined $recalls_per_record and $recalls_per_record->rule_value and $recalled >= $recalls_per_record->rule_value ){
57
        if ( defined $recalls_per_record and $recalls_per_record and $recalled >= $recalls_per_record ) {
58
            $error = 'duplicate';
58
            $error = 'duplicate';
59
        }
59
        }
60
    }
60
    }
(-)a/t/db_dependent/Circulation/Branch.t (-4 / +7 lines)
Lines 1-6 Link Here
1
#!/usr/bin/perl
1
#!/usr/bin/perl
2
2
3
# This file is part of Koha.
3
# Thi
4
# le is part of Koha.
4
#
5
#
5
# Koha is free software; you can redistribute it and/or modify it
6
# Koha is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License as published by
7
# under the terms of the GNU General Public License as published by
Lines 143-150 my $borrower_id1 = Koha::Patron->new({ Link Here
143
144
144
is_deeply(
145
is_deeply(
145
    GetBranchBorrowerCircRule(),
146
    GetBranchBorrowerCircRule(),
146
    { patron_maxissueqty => undef, patron_maxonsiteissueqty => undef },
147
    undef,
147
"Without parameter, GetBranchBorrower returns undef (unilimited) for patron_maxissueqty and patron_maxonsiteissueqty if no rules defined"
148
    "Without parameter, GetBranchBorrower returns undef (unilimited) for patron_maxissueqty and patron_maxonsiteissueqty if no rules defined"
148
);
149
);
149
150
150
Koha::CirculationRules->set_rules(
151
Koha::CirculationRules->set_rules(
Lines 337-342 subtest "GetBranchItemRule() tests" => sub { Link Here
337
    $schema->storage->txn_begin;
338
    $schema->storage->txn_begin;
338
339
339
    $dbh->do('DELETE FROM circulation_rules');
340
    $dbh->do('DELETE FROM circulation_rules');
341
    my $memory_cache = Koha::Cache::Memory::Lite->get_instance;
342
    $memory_cache->flush();
343
340
344
341
    my $homebranch    = $builder->build( { source => 'Branch' } )->{branchcode};
345
    my $homebranch    = $builder->build( { source => 'Branch' } )->{branchcode};
342
    my $holdingbranch = $builder->build( { source => 'Branch' } )->{branchcode};
346
    my $holdingbranch = $builder->build( { source => 'Branch' } )->{branchcode};
343
- 

Return to bug 32092