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

(-)a/C4/Circulation.pm (-3 / +3 lines)
Lines 3247-3253 sub CanBookBeRenewed { Link Here
3247
        my $balance                  = $account->balance;
3247
        my $balance                  = $account->balance;
3248
        my $non_issues_charges       = $account->non_issues_charges;
3248
        my $non_issues_charges       = $account->non_issues_charges;
3249
        my $amountoutstanding_for_renewal =
3249
        my $amountoutstanding_for_renewal =
3250
            C4::Context->preference("OPACFineNoRenewalsIncludeCredits")
3250
            C4::Context->preference("FineNoRenewalsIncludeCredits")
3251
            ? $balance
3251
            ? $balance
3252
            : $non_issues_charges;
3252
            : $non_issues_charges;
3253
3253
Lines 4993-5003 sub _CanBookBeAutoRenewed { Link Here
4993
        }
4993
        }
4994
    }
4994
    }
4995
4995
4996
    if ( C4::Context->preference('OPACFineNoRenewalsBlockAutoRenew') ) {
4996
    if ( C4::Context->preference('FineNoRenewalsBlockAutoRenew') ) {
4997
        my $fine_no_renewals = C4::Context->preference("FineNoRenewals");
4997
        my $fine_no_renewals = C4::Context->preference("FineNoRenewals");
4998
        my $account          = $patron->account;
4998
        my $account          = $patron->account;
4999
        my $amountoutstanding =
4999
        my $amountoutstanding =
5000
            C4::Context->preference("OPACFineNoRenewalsIncludeCredits")
5000
            C4::Context->preference("FineNoRenewalsIncludeCredits")
5001
            ? $account->balance
5001
            ? $account->balance
5002
            : $account->non_issues_charges;
5002
            : $account->non_issues_charges;
5003
        if ( $amountoutstanding and $amountoutstanding > $fine_no_renewals ) {
5003
        if ( $amountoutstanding and $amountoutstanding > $fine_no_renewals ) {
(-)a/installer/data/mysql/atomicupdate/bug_23415.pl (-3 / +29 lines)
Lines 2-9 use Modern::Perl; Link Here
2
2
3
return {
3
return {
4
    bug_number  => "23415",
4
    bug_number  => "23415",
5
    description => "Rename OPACFineNoRenewals and add new syspref AllowFineOverrideRenewing",
5
    description =>
6
    up          => sub {
6
        "Rename OPACFineNoRenewals and related sysprefs, add new sysprefs AllowFineOverrideRenewing and FineNoRenewalsBlockSelfCheckRenew",
7
    up => sub {
7
        my ($args) = @_;
8
        my ($args) = @_;
8
        my ( $dbh, $out ) = @$args{qw(dbh out)};
9
        my ( $dbh, $out ) = @$args{qw(dbh out)};
9
10
Lines 13-19 return { Link Here
13
        }
14
        }
14
        );
15
        );
15
16
16
        say $out "Updated system preference 'OPACFineNoRenewals'";
17
        say $out "Updated system preference 'OPACFineNoRenewals' to 'FineNoRenewals'";
18
19
        $dbh->do(
20
            q{
21
            UPDATE IGNORE systempreferences SET variable = "FineNoRenewalsIncludeCredits" WHERE variable = "OPACFineNoRenewalsIncludeCredits";
22
        }
23
        );
24
25
        say $out "Updated system preference 'OPACFineNoRenewalsIncludeCredits' to 'FineNoRenewalsIncludeCredits'";
26
27
        $dbh->do(
28
            q{
29
            UPDATE IGNORE systempreferences SET variable = "FineNoRenewalsBlockAutoRenew" WHERE variable = "OPACFineNoRenewalsBlockAutoRenew";
30
        }
31
        );
32
33
        say $out "Updated system preference 'OPACFineNoRenewalsBlockAutoRenew' to 'FineNoRenewalsBlockAutoRenew'";
17
34
18
        $dbh->do(
35
        $dbh->do(
19
            q{
36
            q{
Lines 23-27 return { Link Here
23
        );
40
        );
24
41
25
        say $out "Added new system preference 'AllowFineOverrideRenewing'";
42
        say $out "Added new system preference 'AllowFineOverrideRenewing'";
43
44
        $dbh->do(
45
            q{
46
            INSERT IGNORE INTO systempreferences (variable, value, options, explanation, type)
47
            VALUES ('FineNoRenewalsBlockSelfCheckRenew', '0', '', 'Block self-checkout renewals if the patron owes more than the value of FineNoRenewals.','YesNo')
48
        }
49
        );
50
51
        say $out "Added new system preference 'FineNoRenewalsBlockSelfCheckRenew'";
26
    },
52
    },
27
};
53
};
(-)a/installer/data/mysql/mandatory/sysprefs.sql (-2 / +3 lines)
Lines 508-515 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
508
('OpacExportOptions','bibtex,dc,marcxml,marc8,utf8,marcstd,mods,ris,isbd','','Define export options available on OPAC detail page.','multiple'),
508
('OpacExportOptions','bibtex,dc,marcxml,marc8,utf8,marcstd,mods,ris,isbd','','Define export options available on OPAC detail page.','multiple'),
509
('OPACFallback', 'prog', 'bootstrap|prog', 'Define the fallback theme for the OPAC interface.', 'Themes'),
509
('OPACFallback', 'prog', 'bootstrap|prog', 'Define the fallback theme for the OPAC interface.', 'Themes'),
510
('OpacFavicon','','','Enter a complete URL to an image to replace the default Koha favicon on the OPAC','free'),
510
('OpacFavicon','','','Enter a complete URL to an image to replace the default Koha favicon on the OPAC','free'),
511
('OPACFineNoRenewalsBlockAutoRenew','0','','Block/Allow auto renewals if the patron owe more than FineNoRenewals','YesNo'),
511
('FineNoRenewalsBlockAutoRenew','0','','Block/Allow auto renewals if the patron owes more than FineNoRenewals','YesNo'),
512
('OPACFineNoRenewalsIncludeCredits','1',NULL,'If enabled the value specified in FineNoRenewals should include any unapplied account credits in the calculation','YesNo'),
512
('FineNoRenewalsBlockSelfCheckRenew','0','','Block self-checkout renewals if the patron owes more than the value of FineNoRenewals','YesNo'),
513
('FineNoRenewalsIncludeCredits','1',NULL,'If enabled the value specified in FineNoRenewals should include any unapplied account credits in the calculation','YesNo'),
513
('OPACFinesTab','1','','If OFF the patron fines tab in the OPAC is disabled.','YesNo'),
514
('OPACFinesTab','1','','If OFF the patron fines tab in the OPAC is disabled.','YesNo'),
514
('OPACFRBRizeEditions','0','','If ON, the OPAC will query one or more ISBN web services for associated ISBNs and display an Editions tab on the details pages','YesNo'),
515
('OPACFRBRizeEditions','0','','If ON, the OPAC will query one or more ISBN web services for associated ISBNs and display an Editions tab on the details pages','YesNo'),
515
('OpacHiddenItems','','','This syspref allows to define custom rules for hiding specific items at the OPAC. See https://wiki.koha-community.org/wiki/OpacHiddenItems for more information.','Textarea'),
516
('OpacHiddenItems','','','This syspref allows to define custom rules for hiding specific items at the OPAC. See https://wiki.koha-community.org/wiki/OpacHiddenItems for more information.','Textarea'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref (-1 / +8 lines)
Lines 503-513 Circulation: Link Here
503
                  block: block renewing for all the patron's items.
503
                  block: block renewing for all the patron's items.
504
        -
504
        -
505
            - If a patron owes more than the value of <a href="/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=FineNoRenewals">FineNoRenewals</a>,
505
            - If a patron owes more than the value of <a href="/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=FineNoRenewals">FineNoRenewals</a>,
506
            - pref: OPACFineNoRenewalsBlockAutoRenew
506
            - pref: FineNoRenewalsBlockAutoRenew
507
              choices:
507
              choices:
508
                  1: block
508
                  1: block
509
                  0: allow
509
                  0: allow
510
            - their auto-renewals.
510
            - their auto-renewals.
511
        -
512
            - If a patron owes more than the value of <a href="/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=FineNoRenewals">FineNoRenewals</a>,
513
            - pref: FineNoRenewalsBlockSelfCheckRenew
514
              choices:
515
                  1: block
516
                  0: allow
517
            - renewals via the self-checkout system.
511
        -
518
        -
512
            - If a patron pays off all fines on an overdue item that is accruing fines,
519
            - If a patron pays off all fines on an overdue item that is accruing fines,
513
            - pref: RenewAccruingItemWhenPaid
520
            - pref: RenewAccruingItemWhenPaid
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref (-1 / +1 lines)
Lines 646-652 OPAC: Link Here
646
                  opacrenew: "'OPACRenew'"
646
                  opacrenew: "'OPACRenew'"
647
            - as branchcode to store in the statistics table for renewals done in the OPAC.
647
            - as branchcode to store in the statistics table for renewals done in the OPAC.
648
        -
648
        -
649
            - pref: OPACFineNoRenewalsIncludeCredits
649
            - pref: FineNoRenewalsIncludeCredits
650
              choices:
650
              choices:
651
                  1: Include
651
                  1: Include
652
                  0: "Don't include"
652
                  0: "Don't include"
(-)a/opac/opac-user.pl (-1 / +1 lines)
Lines 128-134 my $amountoutstanding = $patron->account->balance; Link Here
128
my $no_renewal_amt    = C4::Context->preference('FineNoRenewals');
128
my $no_renewal_amt    = C4::Context->preference('FineNoRenewals');
129
$no_renewal_amt = undef unless looks_like_number($no_renewal_amt);
129
$no_renewal_amt = undef unless looks_like_number($no_renewal_amt);
130
my $amountoutstandingfornewal =
130
my $amountoutstandingfornewal =
131
    C4::Context->preference("OPACFineNoRenewalsIncludeCredits")
131
    C4::Context->preference("FineNoRenewalsIncludeCredits")
132
    ? $amountoutstanding
132
    ? $amountoutstanding
133
    : $patron->account->outstanding_debits->total_outstanding;
133
    : $patron->account->outstanding_debits->total_outstanding;
134
134
(-)a/opac/sco/sco-main.pl (+20 lines)
Lines 333-338 if ( $patron && ( $op eq 'cud-renew' ) ) { Link Here
333
333
334
        if ( $patron->checkouts->find( { itemnumber => $item->itemnumber } ) ) {
334
        if ( $patron->checkouts->find( { itemnumber => $item->itemnumber } ) ) {
335
            my ( $status, $renewerror ) = CanBookBeRenewed( $patron, $item->checkout );
335
            my ( $status, $renewerror ) = CanBookBeRenewed( $patron, $item->checkout );
336
337
            # Override FineNoRenewals check if FineNoRenewalsBlockSelfCheckRenew is disabled
338
            if (  !$status
339
                && $renewerror eq 'too_much_owing'
340
                && !C4::Context->preference('FineNoRenewalsBlockSelfCheckRenew') )
341
            {
342
                $status     = 1;
343
                $renewerror = undef;
344
            }
345
336
            if ($status) {
346
            if ($status) {
337
                AddRenewal(
347
                AddRenewal(
338
                    {
348
                    {
Lines 361-366 if ($patron) { Link Here
361
        while ( my $c = $pending_checkouts->next ) {
371
        while ( my $c = $pending_checkouts->next ) {
362
            my $checkout = $c->unblessed_all_relateds;
372
            my $checkout = $c->unblessed_all_relateds;
363
            my ( $can_be_renewed, $renew_error ) = CanBookBeRenewed( $patron, $c );
373
            my ( $can_be_renewed, $renew_error ) = CanBookBeRenewed( $patron, $c );
374
375
            # Override FineNoRenewals check if FineNoRenewalsBlockSelfCheckRenew is disabled
376
            if (  !$can_be_renewed
377
                && $renew_error eq 'too_much_owing'
378
                && !C4::Context->preference('FineNoRenewalsBlockSelfCheckRenew') )
379
            {
380
                $can_be_renewed = 1;
381
                $renew_error    = undef;
382
            }
383
364
            $checkout->{can_be_renewed} = $can_be_renewed;    # In the future this will be $checkout->can_be_renewed
384
            $checkout->{can_be_renewed} = $can_be_renewed;    # In the future this will be $checkout->can_be_renewed
365
            $checkout->{renew_error}    = $renew_error;
385
            $checkout->{renew_error}    = $renew_error;
366
            $checkout->{overdue}        = $c->is_overdue;
386
            $checkout->{overdue}        = $c->is_overdue;
(-)a/t/db_dependent/Circulation.t (-9 / +8 lines)
Lines 1325-1331 subtest "CanBookBeRenewed tests" => sub { Link Here
1325
        is( $error,     'auto_renew', 'Cannot renew, renew is automatic' );
1325
        is( $error,     'auto_renew', 'Cannot renew, renew is automatic' );
1326
    };
1326
    };
1327
1327
1328
    subtest "auto_too_much_owing | OPACFineNoRenewalsBlockAutoRenew & OPACFineNoRenewalsIncludeCredits" => sub {
1328
    subtest "auto_too_much_owing | FineNoRenewalsBlockAutoRenew & FineNoRenewalsIncludeCredits" => sub {
1329
        plan tests => 10;
1329
        plan tests => 10;
1330
        my $item_to_auto_renew = $builder->build_sample_item(
1330
        my $item_to_auto_renew = $builder->build_sample_item(
1331
            {
1331
            {
Lines 1352-1360 subtest "CanBookBeRenewed tests" => sub { Link Here
1352
                }
1352
                }
1353
            }
1353
            }
1354
        );
1354
        );
1355
        C4::Context->set_preference( 'OPACFineNoRenewalsBlockAutoRenew', '1' );
1355
        C4::Context->set_preference( 'FineNoRenewalsBlockAutoRenew', '1' );
1356
        C4::Context->set_preference( 'FineNoRenewals',                   '10' );
1356
        C4::Context->set_preference( 'FineNoRenewals',               '10' );
1357
        C4::Context->set_preference( 'OPACFineNoRenewalsIncludeCredits', '1' );
1357
        C4::Context->set_preference( 'FineNoRenewalsIncludeCredits', '1' );
1358
        my $fines_amount = 5;
1358
        my $fines_amount = 5;
1359
        my $account      = Koha::Account->new( { patron_id => $renewing_borrowernumber } );
1359
        my $account      = Koha::Account->new( { patron_id => $renewing_borrowernumber } );
1360
        $account->add_debit(
1360
        $account->add_debit(
Lines 1408-1426 subtest "CanBookBeRenewed tests" => sub { Link Here
1408
        is( $renewokay, 1, 'Renew, even if renewal is automatic' );
1408
        is( $renewokay, 1, 'Renew, even if renewal is automatic' );
1409
        is(
1409
        is(
1410
            $error, 'auto_renew',
1410
            $error, 'auto_renew',
1411
            'Can auto renew, FineNoRenewals=10, OPACFineNoRenewalsIncludeCredits=1, patron has 15 debt, 5 credit'
1411
            'Can auto renew, FineNoRenewals=10, FineNoRenewalsIncludeCredits=1, patron has 15 debt, 5 credit'
1412
        );
1412
        );
1413
1413
1414
        C4::Context->set_preference( 'OPACFineNoRenewalsIncludeCredits', '0' );
1414
        C4::Context->set_preference( 'FineNoRenewalsIncludeCredits', '0' );
1415
        ( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrower_obj, $issue );
1415
        ( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrower_obj, $issue );
1416
        is( $renewokay, 0, 'Do not renew, renewal is automatic' );
1416
        is( $renewokay, 0, 'Do not renew, renewal is automatic' );
1417
        is(
1417
        is(
1418
            $error, 'auto_too_much_owing',
1418
            $error, 'auto_too_much_owing',
1419
            'Cannot auto renew, FineNoRenewals=10, OPACFineNoRenewalsIncludeCredits=1, patron has 15 debt, 5 credit'
1419
            'Cannot auto renew, FineNoRenewals=10, FineNoRenewalsIncludeCredits=0, patron has 15 debt, 5 credit'
1420
        );
1420
        );
1421
1421
1422
        $dbh->do( 'DELETE FROM accountlines WHERE borrowernumber=?', undef, $renewing_borrowernumber );
1422
        $dbh->do( 'DELETE FROM accountlines WHERE borrowernumber=?', undef, $renewing_borrowernumber );
1423
        C4::Context->set_preference( 'OPACFineNoRenewalsIncludeCredits', '1' );
1423
        C4::Context->set_preference( 'FineNoRenewalsIncludeCredits', '1' );
1424
    };
1424
    };
1425
1425
1426
    subtest "auto_account_expired | BlockExpiredPatronOpacActions" => sub {
1426
    subtest "auto_account_expired | BlockExpiredPatronOpacActions" => sub {
1427
- 

Return to bug 23415