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

(-)a/C4/Circulation.pm (-3 / +3 lines)
Lines 3275-3281 sub CanBookBeRenewed { Link Here
3275
        my $balance                  = $account->balance;
3275
        my $balance                  = $account->balance;
3276
        my $non_issues_charges       = $account->non_issues_charges;
3276
        my $non_issues_charges       = $account->non_issues_charges;
3277
        my $amountoutstanding_for_renewal =
3277
        my $amountoutstanding_for_renewal =
3278
            C4::Context->preference("OPACFineNoRenewalsIncludeCredits")
3278
            C4::Context->preference("FineNoRenewalsIncludeCredits")
3279
            ? $balance
3279
            ? $balance
3280
            : $non_issues_charges;
3280
            : $non_issues_charges;
3281
3281
Lines 5025-5035 sub _CanBookBeAutoRenewed { Link Here
5025
        }
5025
        }
5026
    }
5026
    }
5027
5027
5028
    if ( C4::Context->preference('OPACFineNoRenewalsBlockAutoRenew') ) {
5028
    if ( C4::Context->preference('FineNoRenewalsBlockAutoRenew') ) {
5029
        my $fine_no_renewals = C4::Context->preference("FineNoRenewals");
5029
        my $fine_no_renewals = C4::Context->preference("FineNoRenewals");
5030
        my $account          = $patron->account;
5030
        my $account          = $patron->account;
5031
        my $amountoutstanding =
5031
        my $amountoutstanding =
5032
            C4::Context->preference("OPACFineNoRenewalsIncludeCredits")
5032
            C4::Context->preference("FineNoRenewalsIncludeCredits")
5033
            ? $account->balance
5033
            ? $account->balance
5034
            : $account->non_issues_charges;
5034
            : $account->non_issues_charges;
5035
        if ( $amountoutstanding and $amountoutstanding > $fine_no_renewals ) {
5035
        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 514-521 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
514
('OpacExportOptions','bibtex,dc,marcxml,marc8,utf8,marcstd,mods,ris,isbd',NULL,'Define export options available on OPAC detail page.','multiple'),
514
('OpacExportOptions','bibtex,dc,marcxml,marc8,utf8,marcstd,mods,ris,isbd',NULL,'Define export options available on OPAC detail page.','multiple'),
515
('OPACFallback', 'prog', 'bootstrap|prog', 'Define the fallback theme for the OPAC interface.', 'Themes'),
515
('OPACFallback', 'prog', 'bootstrap|prog', 'Define the fallback theme for the OPAC interface.', 'Themes'),
516
('OpacFavicon','',NULL,'Enter a complete URL to an image to replace the default Koha favicon on the OPAC','free'),
516
('OpacFavicon','',NULL,'Enter a complete URL to an image to replace the default Koha favicon on the OPAC','free'),
517
('OPACFineNoRenewalsBlockAutoRenew','0',NULL,'Block/Allow auto renewals if the patron owe more than FineNoRenewals','YesNo'),
517
('FineNoRenewalsBlockAutoRenew','0',NULL,'Block/Allow auto renewals if the patron owes more than FineNoRenewals','YesNo'),
518
('OPACFineNoRenewalsIncludeCredits','1',NULL,'If enabled the value specified in FineNoRenewals should include any unapplied account credits in the calculation','YesNo'),
518
('FineNoRenewalsBlockSelfCheckRenew','0',NULL,'Block self-checkout renewals if the patron owes more than the value of FineNoRenewals','YesNo'),
519
('FineNoRenewalsIncludeCredits','1',NULL,'If enabled the value specified in FineNoRenewals should include any unapplied account credits in the calculation','YesNo'),
519
('OPACFinesTab','1',NULL,'If OFF the patron fines tab in the OPAC is disabled.','YesNo'),
520
('OPACFinesTab','1',NULL,'If OFF the patron fines tab in the OPAC is disabled.','YesNo'),
520
('OPACFRBRizeEditions','0',NULL,'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'),
521
('OPACFRBRizeEditions','0',NULL,'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'),
521
('OpacHiddenItems','',NULL,'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'),
522
('OpacHiddenItems','',NULL,'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 516-526 Circulation: Link Here
516
                  block: block renewing for all the patron's items.
516
                  block: block renewing for all the patron's items.
517
        -
517
        -
518
            - If a patron owes more than the value of <a href="/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=FineNoRenewals">FineNoRenewals</a>,
518
            - If a patron owes more than the value of <a href="/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=FineNoRenewals">FineNoRenewals</a>,
519
            - pref: OPACFineNoRenewalsBlockAutoRenew
519
            - pref: FineNoRenewalsBlockAutoRenew
520
              choices:
520
              choices:
521
                  1: block
521
                  1: block
522
                  0: allow
522
                  0: allow
523
            - their auto-renewals.
523
            - their auto-renewals.
524
        -
525
            - If a patron owes more than the value of <a href="/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=FineNoRenewals">FineNoRenewals</a>,
526
            - pref: FineNoRenewalsBlockSelfCheckRenew
527
              choices:
528
                  1: block
529
                  0: allow
530
            - renewals via the self-checkout system.
524
        -
531
        -
525
            - If a patron pays off all fines on an overdue item that is accruing fines,
532
            - If a patron pays off all fines on an overdue item that is accruing fines,
526
            - pref: RenewAccruingItemWhenPaid
533
            - 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