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

(-)a/C4/Circulation.pm (+3 lines)
Lines 3204-3209 sub CanBookBeRenewed { Link Here
3204
                        $patron_with_reserve, $other_item, undef,
3204
                        $patron_with_reserve, $other_item, undef,
3205
                        { ignore_hold_counts => 1 }
3205
                        { ignore_hold_counts => 1 }
3206
                    )->{status} eq 'OK';
3206
                    )->{status} eq 'OK';
3207
                    if ( C4::Context->preference('AllowRenewalIfOtherItemsAvailableLocation') eq 'holdbranch' ) {
3208
                        next unless $other_item->holdingbranch eq $possible_hold->{branchcode};
3209
                    }
3207
3210
3208
                    # NOTE: At checkin we call 'CheckReserves' which checks hold 'policy'
3211
                    # NOTE: At checkin we call 'CheckReserves' which checks hold 'policy'
3209
                    # CanItemBeReserved checks 'rules' and 'policies' which means
3212
                    # 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 / +2 lines)
Lines 45-50 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
45
('AllowPatronToSetFinesVisibilityForGuarantor',  '0', NULL, 'If enabled, the patron can set fines to be visible to their guarantor',  'YesNo'),
45
('AllowPatronToSetFinesVisibilityForGuarantor',  '0', NULL, 'If enabled, the patron can set fines to be visible to their guarantor',  'YesNo'),
46
('AllowPKIAuth','None','None|Common Name|emailAddress','Use the field from a client-side SSL certificate to look a user in the Koha database','Choice'),
46
('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
('AllowRenewalIfOtherItemsAvailable','0',NULL,'If enabled, allow a patron to renew an item with unfilled holds if other available items can fill that hold.','YesNo'),
47
('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
('AllowRenewalIfOtherItemsAvailableLocation', 'any', 'any|holdbranch', 'Specify where items must be available for fulfilling holds to allow a renewal.', 'Choice'),
48
('AllowRenewalLimitOverride','0',NULL,'if ON, allows renewal limits to be overridden on the circulation screen','YesNo'),
49
('AllowRenewalLimitOverride','0',NULL,'if ON, allows renewal limits to be overridden on the circulation screen','YesNo'),
49
('AllowRenewalOnHoldOverride','0',NULL,'If ON, allow items on hold to be renewed with a specified due date','YesNo'),
50
('AllowRenewalOnHoldOverride','0',NULL,'If ON, allow items on hold to be renewed with a specified due date','YesNo'),
50
('AllowReturnToBranch','anywhere','anywhere|homebranch|holdingbranch|homeorholdingbranch','Where an item may be returned','Choice'),
51
('AllowReturnToBranch','anywhere','anywhere|homebranch|holdingbranch|homeorholdingbranch','Where an item may be returned','Choice'),
Lines 873-876 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
873
('z3950AuthorAuthFields','701,702,700',NULL,'Define the MARC biblio fields for Personal Name Authorities to fill biblio.author','free'),
874
('z3950AuthorAuthFields','701,702,700',NULL,'Define the MARC biblio fields for Personal Name Authorities to fill biblio.author','free'),
874
('z3950NormalizeAuthor','0','','If ON, Personal Name Authorities will replace authors in biblio.author','YesNo'),
875
('z3950NormalizeAuthor','0','','If ON, Personal Name Authorities will replace authors in biblio.author','YesNo'),
875
('z3950Status','','','This syspref allows to define custom YAML based rules for marking items unavailable in z3950 results.','Textarea')
876
('z3950Status','','','This syspref allows to define custom YAML based rules for marking items unavailable in z3950 results.','Textarea')
876
;
877
;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref (-2 / +7 lines)
Lines 802-808 Circulation: Link Here
802
              choices:
802
              choices:
803
                  1: Allow
803
                  1: Allow
804
                  0: "Don't allow"
804
                  0: "Don't allow"
805
            - a patron to renew an item with unfilled holds if other available items can fill that hold.
805
            - a patron to renew an item with unfilled holds if other available items
806
            - pref: AllowRenewalIfOtherItemsAvailableLocation
807
              choices:
808
                  any: "at any library"
809
                  holdbranch: "at the hold's pickup library"
810
            - can fill that hold.
806
        -
811
        -
807
            - pref: AllowHoldPolicyOverride
812
            - pref: AllowHoldPolicyOverride
808
              choices:
813
              choices:
Lines 1514-1517 Circulation: Link Here
1514
              choices:
1519
              choices:
1515
                  1: Enable
1520
                  1: Enable
1516
                  0: Disable
1521
                  0: Disable
1517
            - "the curbside pickup module."
1522
            - "the curbside pickup module."
(-)a/t/db_dependent/Circulation.t (-2 / +92 lines)
Lines 18-24 Link Here
18
use Modern::Perl;
18
use Modern::Perl;
19
use utf8;
19
use utf8;
20
20
21
use Test::More tests => 75;
21
use Test::More tests => 76;
22
use Test::Exception;
22
use Test::Exception;
23
use Test::MockModule;
23
use Test::MockModule;
24
use Test::Deep qw( cmp_deeply );
24
use Test::Deep qw( cmp_deeply );
Lines 2399-2404 subtest "AllowRenewalIfOtherItemsAvailable tests" => sub { Link Here
2399
    );
2399
    );
2400
}
2400
}
2401
2401
2402
subtest "AllowRenewalIfOtherItemsAvailableLocation tests" => sub {
2403
    plan tests => 3;
2404
2405
    $dbh->do('DELETE FROM issues');
2406
    $dbh->do('DELETE FROM items');
2407
    $dbh->do('DELETE FROM circulation_rules');
2408
    Koha::CirculationRules->set_rules(
2409
        {
2410
            categorycode => undef,
2411
            itemtype     => undef,
2412
            branchcode   => undef,
2413
            rules        => {
2414
                reservesallowed => 25,
2415
                issuelength     => 14,
2416
                lengthunit      => 'days',
2417
                renewalsallowed => 1,
2418
                renewalperiod   => 7,
2419
                norenewalbefore => undef,
2420
                auto_renew      => 0,
2421
                fine            => .10,
2422
                chargeperiod    => 1,
2423
                maxissueqty     => 20,
2424
                onshelfholds    => 1,
2425
            }
2426
        }
2427
    );
2428
    my $biblio = $builder->build_sample_biblio();
2429
2430
    my $item_1 = $builder->build_sample_item(
2431
        {
2432
            biblionumber => $biblio->biblionumber,
2433
            library      => $library2->{branchcode},
2434
            itype        => $itemtype,
2435
        }
2436
    );
2437
2438
    # add second item with different branchcode
2439
    my $item_2 = $builder->build_sample_item(
2440
        {
2441
            biblionumber => $biblio->biblionumber,
2442
            library      => $library->{branchcode},
2443
            itype        => $itemtype,
2444
        }
2445
    );
2446
2447
    my $borrower1 = Koha::Patron->new(
2448
        {
2449
            firstname    => 'Kyle',
2450
            surname      => 'Hall',
2451
            categorycode => $patron_category->{categorycode},
2452
            branchcode   => $library2->{branchcode},
2453
        }
2454
    )->store;
2455
    my $borrowernumber1 = $borrower1->id;
2456
    my $borrower2       = Koha::Patron->new(
2457
        {
2458
            firstname    => 'Chelsea',
2459
            surname      => 'Hall',
2460
            categorycode => $patron_category->{categorycode},
2461
            branchcode   => $library2->{branchcode},
2462
        }
2463
    )->store;
2464
    my $borrowernumber2 = $borrower2->id;
2465
2466
    my $issue = AddIssue( $borrower1, $item_1->barcode );
2467
2468
    # place bib-level reserve
2469
    AddReserve(
2470
        {
2471
            branchcode     => $library2->{branchcode},
2472
            borrowernumber => $borrowernumber2,
2473
            biblionumber   => $biblio->biblionumber,
2474
            priority       => 1,
2475
        }
2476
    );
2477
2478
    t::lib::Mocks::mock_preference( 'AllowRenewalIfOtherItemsAvailable',         1 );
2479
    t::lib::Mocks::mock_preference( 'AllowRenewalIfOtherItemsAvailableLocation', 'any' );
2480
    my ( $renewokay, $error ) = CanBookBeRenewed( $borrower1, $issue );
2481
    is( $renewokay, 1, 'Renewal allowed if items available at any branch' );
2482
2483
    t::lib::Mocks::mock_preference( 'AllowRenewalIfOtherItemsAvailableLocation', 'holdbranch' );
2484
    ( $renewokay, $error ) = CanBookBeRenewed( $borrower1, $issue );
2485
    is( $renewokay, 0, 'Renewal not allowed as available item is at a different branch' );
2486
2487
    # adjust 2nd item to have same branchcode
2488
    $item_2->update( { homebranch => $library2->{branchcode}, holdingbranch => $library2->{branchcode} } )->store;
2489
    ( $renewokay, $error ) = CanBookBeRenewed( $borrower1, $issue );
2490
    is( $renewokay, 1, 'Renewal allowed if items available at hold branch' );
2491
};
2492
2402
subtest 'CanBookBeIssued & AllowReturnToBranch' => sub {
2493
subtest 'CanBookBeIssued & AllowReturnToBranch' => sub {
2403
    plan tests => 26;
2494
    plan tests => 26;
2404
2495
2405
- 

Return to bug 25193