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

(-)a/C4/Circulation.pm (+5 lines)
Lines 3308-3313 sub CanBookBeRenewed { Link Here
3308
                        $patron_with_reserve, $other_item, undef,
3308
                        $patron_with_reserve, $other_item, undef,
3309
                        { ignore_hold_counts => 1 }
3309
                        { ignore_hold_counts => 1 }
3310
                    )->{status} eq 'OK';
3310
                    )->{status} eq 'OK';
3311
                    if (    C4::Context->preference('AllowRenewalIfOtherItemsAvailableLocation')
3312
                        and C4::Context->preference('AllowRenewalIfOtherItemsAvailableLocation') eq 'holdbranch' )
3313
                    {
3314
                        next unless $other_item->holdingbranch eq $possible_hold->{branchcode};
3315
                    }
3311
3316
3312
                    # NOTE: At checkin we call 'CheckReserves' which checks hold 'policy'
3317
                    # NOTE: At checkin we call 'CheckReserves' which checks hold 'policy'
3313
                    # CanItemBeReserved checks 'rules' and 'policies' which means
3318
                    # CanItemBeReserved checks 'rules' and 'policies' which means
(-)a/installer/data/mysql/atomicupdate/bug_25193-add_AllowRenewalIfOtherItemsAvailableLocation_syspref.pl (+16 lines)
Line 0 Link Here
1
use Modern::Perl;
2
3
return {
4
    bug_number  => "25193",
5
    description => "Add syspref to control location for use of AllowRenewalIfOtherItemsAvailable",
6
    up          => sub {
7
        my ($args) = @_;
8
        my ( $dbh, $out ) = @$args{qw(dbh out)};
9
10
        $dbh->do(
11
            q{INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES ('AllowRenewalIfOtherItemsAvailableLocation', 'any', 'any|holdbranch', 'Specify where items must be available for fulfilling holds to allow a renewal.', 'Choice') }
12
        );
13
14
        say $out "Added system preference 'AllowRenewalIfOtherItemsAvailableLocation'";
15
    },
16
};
(-)a/installer/data/mysql/mandatory/sysprefs.sql (+1 lines)
Lines 46-51 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
46
('AllowPatronToSetFinesVisibilityForGuarantor', '0', NULL, 'If enabled, the patron can set fines to be visible to their guarantor', 'YesNo'),
46
('AllowPatronToSetFinesVisibilityForGuarantor', '0', NULL, 'If enabled, the patron can set fines to be visible to their guarantor', 'YesNo'),
47
('AllowPKIAuth','None','None|Common Name|emailAddress','Use the field from a client-side SSL certificate to look a user in the Koha database','Choice'),
47
('AllowPKIAuth','None','None|Common Name|emailAddress','Use the field from a client-side SSL certificate to look a user in the Koha database','Choice'),
48
('AllowRenewalIfOtherItemsAvailable','0',NULL,'If enabled, allow a patron to renew an item with unfilled holds if other available items can fill that hold.','YesNo'),
48
('AllowRenewalIfOtherItemsAvailable','0',NULL,'If enabled, allow a patron to renew an item with unfilled holds if other available items can fill that hold.','YesNo'),
49
('AllowRenewalIfOtherItemsAvailableLocation', 'any', 'any|holdbranch', 'Specify where items must be available for fulfilling holds to allow a renewal.', 'Choice'),
49
('AllowRenewalLimitOverride','0',NULL,'if ON, allows renewal limits to be overridden on the circulation screen','YesNo'),
50
('AllowRenewalLimitOverride','0',NULL,'if ON, allows renewal limits to be overridden on the circulation screen','YesNo'),
50
('AllowRenewalOnHoldOverride','0',NULL,'If ON, allow items on hold to be renewed with a specified due date','YesNo'),
51
('AllowRenewalOnHoldOverride','0',NULL,'If ON, allow items on hold to be renewed with a specified due date','YesNo'),
51
('AllowReturnToBranch','anywhere','anywhere|homebranch|holdingbranch|homeorholdingbranch','Where an item may be returned','Choice'),
52
('AllowReturnToBranch','anywhere','anywhere|homebranch|holdingbranch|homeorholdingbranch','Where an item may be returned','Choice'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref (-1 / +6 lines)
Lines 808-814 Circulation: Link Here
808
              choices:
808
              choices:
809
                  1: Allow
809
                  1: Allow
810
                  0: "Don't allow"
810
                  0: "Don't allow"
811
            - a patron to renew an item with unfilled holds if other available items can fill that hold.
811
            - a patron to renew an item with unfilled holds if other available items
812
            - pref: AllowRenewalIfOtherItemsAvailableLocation
813
              choices:
814
                  any: "at any library"
815
                  holdbranch: "at the hold's pickup library"
816
            - can fill that hold.
812
        -
817
        -
813
            - pref: AllowHoldPolicyOverride
818
            - pref: AllowHoldPolicyOverride
814
              choices:
819
              choices:
(-)a/t/db_dependent/Circulation.t (-2 / +92 lines)
Lines 19-25 use Modern::Perl; Link Here
19
use utf8;
19
use utf8;
20
20
21
use Test::NoWarnings;
21
use Test::NoWarnings;
22
use Test::More tests => 84;
22
use Test::More tests => 85;
23
use Test::Exception;
23
use Test::Exception;
24
use Test::MockModule;
24
use Test::MockModule;
25
use Test::Deep qw( cmp_deeply );
25
use Test::Deep qw( cmp_deeply );
Lines 2455-2460 subtest "AllowRenewalIfOtherItemsAvailable tests" => sub { Link Here
2455
    );
2455
    );
2456
}
2456
}
2457
2457
2458
subtest "AllowRenewalIfOtherItemsAvailableLocation tests" => sub {
2459
    plan tests => 3;
2460
2461
    $dbh->do('DELETE FROM issues');
2462
    $dbh->do('DELETE FROM items');
2463
    $dbh->do('DELETE FROM circulation_rules');
2464
    Koha::CirculationRules->set_rules(
2465
        {
2466
            categorycode => undef,
2467
            itemtype     => undef,
2468
            branchcode   => undef,
2469
            rules        => {
2470
                reservesallowed => 25,
2471
                issuelength     => 14,
2472
                lengthunit      => 'days',
2473
                renewalsallowed => 1,
2474
                renewalperiod   => 7,
2475
                norenewalbefore => undef,
2476
                auto_renew      => 0,
2477
                fine            => .10,
2478
                chargeperiod    => 1,
2479
                maxissueqty     => 20,
2480
                onshelfholds    => 1,
2481
            }
2482
        }
2483
    );
2484
    my $biblio = $builder->build_sample_biblio();
2485
2486
    my $item_1 = $builder->build_sample_item(
2487
        {
2488
            biblionumber => $biblio->biblionumber,
2489
            library      => $library2->{branchcode},
2490
            itype        => $itemtype,
2491
        }
2492
    );
2493
2494
    # add second item with different branchcode
2495
    my $item_2 = $builder->build_sample_item(
2496
        {
2497
            biblionumber => $biblio->biblionumber,
2498
            library      => $library->{branchcode},
2499
            itype        => $itemtype,
2500
        }
2501
    );
2502
2503
    my $borrower1 = Koha::Patron->new(
2504
        {
2505
            firstname    => 'Kyle',
2506
            surname      => 'Hall',
2507
            categorycode => $patron_category->{categorycode},
2508
            branchcode   => $library2->{branchcode},
2509
        }
2510
    )->store;
2511
    my $borrowernumber1 = $borrower1->id;
2512
    my $borrower2       = Koha::Patron->new(
2513
        {
2514
            firstname    => 'Chelsea',
2515
            surname      => 'Hall',
2516
            categorycode => $patron_category->{categorycode},
2517
            branchcode   => $library2->{branchcode},
2518
        }
2519
    )->store;
2520
    my $borrowernumber2 = $borrower2->id;
2521
2522
    my $issue = AddIssue( $borrower1, $item_1->barcode );
2523
2524
    # place bib-level reserve
2525
    AddReserve(
2526
        {
2527
            branchcode     => $library2->{branchcode},
2528
            borrowernumber => $borrowernumber2,
2529
            biblionumber   => $biblio->biblionumber,
2530
            priority       => 1,
2531
        }
2532
    );
2533
2534
    t::lib::Mocks::mock_preference( 'AllowRenewalIfOtherItemsAvailable',         1 );
2535
    t::lib::Mocks::mock_preference( 'AllowRenewalIfOtherItemsAvailableLocation', 'any' );
2536
    my ( $renewokay, $error ) = CanBookBeRenewed( $borrower1, $issue );
2537
    is( $renewokay, 1, 'Renewal allowed if items available at any branch' );
2538
2539
    t::lib::Mocks::mock_preference( 'AllowRenewalIfOtherItemsAvailableLocation', 'holdbranch' );
2540
    ( $renewokay, $error ) = CanBookBeRenewed( $borrower1, $issue );
2541
    is( $renewokay, 0, 'Renewal not allowed as available item is at a different branch' );
2542
2543
    # adjust 2nd item to have same branchcode
2544
    $item_2->update( { homebranch => $library2->{branchcode}, holdingbranch => $library2->{branchcode} } )->store;
2545
    ( $renewokay, $error ) = CanBookBeRenewed( $borrower1, $issue );
2546
    is( $renewokay, 1, 'Renewal allowed if items available at hold branch' );
2547
};
2548
2458
subtest 'CanBookBeIssued & AllowReturnToBranch' => sub {
2549
subtest 'CanBookBeIssued & AllowReturnToBranch' => sub {
2459
    plan tests => 27;
2550
    plan tests => 27;
2460
2551
2461
- 

Return to bug 25193