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

(-)a/C4/Circulation.pm (+5 lines)
Lines 3378-3383 sub CanBookBeRenewed { Link Here
3378
                        $patron_with_reserve, $other_item, undef,
3378
                        $patron_with_reserve, $other_item, undef,
3379
                        { ignore_hold_counts => 1 }
3379
                        { ignore_hold_counts => 1 }
3380
                    )->{status} eq 'OK';
3380
                    )->{status} eq 'OK';
3381
                    if (    C4::Context->preference('AllowRenewalIfOtherItemsAvailableLocation')
3382
                        and C4::Context->preference('AllowRenewalIfOtherItemsAvailableLocation') eq 'holdbranch' )
3383
                    {
3384
                        next unless $other_item->holdingbranch eq $possible_hold->{branchcode};
3385
                    }
3381
3386
3382
                    # NOTE: At checkin we call 'CheckReserves' which checks hold 'policy'
3387
                    # NOTE: At checkin we call 'CheckReserves' which checks hold 'policy'
3383
                    # CanItemBeReserved checks 'rules' and 'policies' which means
3388
                    # 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 809-815 Circulation: Link Here
809
              choices:
809
              choices:
810
                  1: Allow
810
                  1: Allow
811
                  0: "Don't allow"
811
                  0: "Don't allow"
812
            - a patron to renew an item with unfilled holds if other available items can fill that hold.
812
            - a patron to renew an item with unfilled holds if other available items
813
            - pref: AllowRenewalIfOtherItemsAvailableLocation
814
              choices:
815
                  any: "at any library"
816
                  holdbranch: "at the hold's pickup library"
817
            - can fill that hold.
813
        -
818
        -
814
            - pref: AllowHoldPolicyOverride
819
            - pref: AllowHoldPolicyOverride
815
              choices:
820
              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 => 82;
22
use Test::More tests => 83;
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 2402-2407 subtest "AllowRenewalIfOtherItemsAvailable tests" => sub { Link Here
2402
    );
2402
    );
2403
}
2403
}
2404
2404
2405
subtest "AllowRenewalIfOtherItemsAvailableLocation tests" => sub {
2406
    plan tests => 3;
2407
2408
    $dbh->do('DELETE FROM issues');
2409
    $dbh->do('DELETE FROM items');
2410
    $dbh->do('DELETE FROM circulation_rules');
2411
    Koha::CirculationRules->set_rules(
2412
        {
2413
            categorycode => undef,
2414
            itemtype     => undef,
2415
            branchcode   => undef,
2416
            rules        => {
2417
                reservesallowed => 25,
2418
                issuelength     => 14,
2419
                lengthunit      => 'days',
2420
                renewalsallowed => 1,
2421
                renewalperiod   => 7,
2422
                norenewalbefore => undef,
2423
                auto_renew      => 0,
2424
                fine            => .10,
2425
                chargeperiod    => 1,
2426
                maxissueqty     => 20,
2427
                onshelfholds    => 1,
2428
            }
2429
        }
2430
    );
2431
    my $biblio = $builder->build_sample_biblio();
2432
2433
    my $item_1 = $builder->build_sample_item(
2434
        {
2435
            biblionumber => $biblio->biblionumber,
2436
            library      => $library2->{branchcode},
2437
            itype        => $itemtype,
2438
        }
2439
    );
2440
2441
    # add second item with different branchcode
2442
    my $item_2 = $builder->build_sample_item(
2443
        {
2444
            biblionumber => $biblio->biblionumber,
2445
            library      => $library->{branchcode},
2446
            itype        => $itemtype,
2447
        }
2448
    );
2449
2450
    my $borrower1 = Koha::Patron->new(
2451
        {
2452
            firstname    => 'Kyle',
2453
            surname      => 'Hall',
2454
            categorycode => $patron_category->{categorycode},
2455
            branchcode   => $library2->{branchcode},
2456
        }
2457
    )->store;
2458
    my $borrowernumber1 = $borrower1->id;
2459
    my $borrower2       = Koha::Patron->new(
2460
        {
2461
            firstname    => 'Chelsea',
2462
            surname      => 'Hall',
2463
            categorycode => $patron_category->{categorycode},
2464
            branchcode   => $library2->{branchcode},
2465
        }
2466
    )->store;
2467
    my $borrowernumber2 = $borrower2->id;
2468
2469
    my $issue = AddIssue( $borrower1, $item_1->barcode );
2470
2471
    # place bib-level reserve
2472
    AddReserve(
2473
        {
2474
            branchcode     => $library2->{branchcode},
2475
            borrowernumber => $borrowernumber2,
2476
            biblionumber   => $biblio->biblionumber,
2477
            priority       => 1,
2478
        }
2479
    );
2480
2481
    t::lib::Mocks::mock_preference( 'AllowRenewalIfOtherItemsAvailable',         1 );
2482
    t::lib::Mocks::mock_preference( 'AllowRenewalIfOtherItemsAvailableLocation', 'any' );
2483
    my ( $renewokay, $error ) = CanBookBeRenewed( $borrower1, $issue );
2484
    is( $renewokay, 1, 'Renewal allowed if items available at any branch' );
2485
2486
    t::lib::Mocks::mock_preference( 'AllowRenewalIfOtherItemsAvailableLocation', 'holdbranch' );
2487
    ( $renewokay, $error ) = CanBookBeRenewed( $borrower1, $issue );
2488
    is( $renewokay, 0, 'Renewal not allowed as available item is at a different branch' );
2489
2490
    # adjust 2nd item to have same branchcode
2491
    $item_2->update( { homebranch => $library2->{branchcode}, holdingbranch => $library2->{branchcode} } )->store;
2492
    ( $renewokay, $error ) = CanBookBeRenewed( $borrower1, $issue );
2493
    is( $renewokay, 1, 'Renewal allowed if items available at hold branch' );
2494
};
2495
2405
subtest 'CanBookBeIssued & AllowReturnToBranch' => sub {
2496
subtest 'CanBookBeIssued & AllowReturnToBranch' => sub {
2406
    plan tests => 27;
2497
    plan tests => 27;
2407
2498
2408
- 

Return to bug 25193