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 5052-5062 sub _CanBookBeAutoRenewed { Link Here
5052
        }
5052
        }
5053
    }
5053
    }
5054
5054
5055
    if ( C4::Context->preference('OPACFineNoRenewalsBlockAutoRenew') ) {
5055
    if ( C4::Context->preference('FineNoRenewalsBlockAutoRenew') ) {
5056
        my $fine_no_renewals = C4::Context->preference("FineNoRenewals");
5056
        my $fine_no_renewals = C4::Context->preference("FineNoRenewals");
5057
        my $account          = $patron->account;
5057
        my $account          = $patron->account;
5058
        my $amountoutstanding =
5058
        my $amountoutstanding =
5059
            C4::Context->preference("OPACFineNoRenewalsIncludeCredits")
5059
            C4::Context->preference("FineNoRenewalsIncludeCredits")
5060
            ? $account->balance
5060
            ? $account->balance
5061
            : $account->non_issues_charges;
5061
            : $account->non_issues_charges;
5062
        if ( $amountoutstanding and $amountoutstanding > $fine_no_renewals ) {
5062
        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 516-523 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
516
('OpacExportOptions','bibtex,dc,marcxml,marc8,utf8,marcstd,mods,ris,isbd',NULL,'Define export options available on OPAC detail page.','multiple'),
516
('OpacExportOptions','bibtex,dc,marcxml,marc8,utf8,marcstd,mods,ris,isbd',NULL,'Define export options available on OPAC detail page.','multiple'),
517
('OPACFallback', 'prog', 'bootstrap|prog', 'Define the fallback theme for the OPAC interface.', 'Themes'),
517
('OPACFallback', 'prog', 'bootstrap|prog', 'Define the fallback theme for the OPAC interface.', 'Themes'),
518
('OpacFavicon','',NULL,'Enter a complete URL to an image to replace the default Koha favicon on the OPAC','free'),
518
('OpacFavicon','',NULL,'Enter a complete URL to an image to replace the default Koha favicon on the OPAC','free'),
519
('OPACFineNoRenewalsBlockAutoRenew','0',NULL,'Block/Allow auto renewals if the patron owe more than FineNoRenewals','YesNo'),
519
('FineNoRenewalsBlockAutoRenew','0',NULL,'Block/Allow auto renewals if the patron owes more than FineNoRenewals','YesNo'),
520
('OPACFineNoRenewalsIncludeCredits','1',NULL,'If enabled the value specified in FineNoRenewals should include any unapplied account credits in the calculation','YesNo'),
520
('FineNoRenewalsBlockSelfCheckRenew','0',NULL,'Block self-checkout renewals if the patron owes more than the value of FineNoRenewals','YesNo'),
521
('FineNoRenewalsIncludeCredits','1',NULL,'If enabled the value specified in FineNoRenewals should include any unapplied account credits in the calculation','YesNo'),
521
('OPACFinesTab','1',NULL,'If OFF the patron fines tab in the OPAC is disabled.','YesNo'),
522
('OPACFinesTab','1',NULL,'If OFF the patron fines tab in the OPAC is disabled.','YesNo'),
522
('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'),
523
('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'),
523
('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'),
524
('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 652-658 OPAC: Link Here
652
                  opacrenew: "'OPACRenew'"
652
                  opacrenew: "'OPACRenew'"
653
            - as branchcode to store in the statistics table for renewals done in the OPAC.
653
            - as branchcode to store in the statistics table for renewals done in the OPAC.
654
        -
654
        -
655
            - pref: OPACFineNoRenewalsIncludeCredits
655
            - pref: FineNoRenewalsIncludeCredits
656
              choices:
656
              choices:
657
                  1: Include
657
                  1: Include
658
                  0: "Don't include"
658
                  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 1324-1330 subtest "CanBookBeRenewed tests" => sub { Link Here
1324
        is( $error,     'auto_renew', 'Cannot renew, renew is automatic' );
1324
        is( $error,     'auto_renew', 'Cannot renew, renew is automatic' );
1325
    };
1325
    };
1326
1326
1327
    subtest "auto_too_much_owing | OPACFineNoRenewalsBlockAutoRenew & OPACFineNoRenewalsIncludeCredits" => sub {
1327
    subtest "auto_too_much_owing | FineNoRenewalsBlockAutoRenew & FineNoRenewalsIncludeCredits" => sub {
1328
        plan tests => 10;
1328
        plan tests => 10;
1329
        my $item_to_auto_renew = $builder->build_sample_item(
1329
        my $item_to_auto_renew = $builder->build_sample_item(
1330
            {
1330
            {
Lines 1351-1359 subtest "CanBookBeRenewed tests" => sub { Link Here
1351
                }
1351
                }
1352
            }
1352
            }
1353
        );
1353
        );
1354
        C4::Context->set_preference( 'OPACFineNoRenewalsBlockAutoRenew', '1' );
1354
        C4::Context->set_preference( 'FineNoRenewalsBlockAutoRenew', '1' );
1355
        C4::Context->set_preference( 'FineNoRenewals',                   '10' );
1355
        C4::Context->set_preference( 'FineNoRenewals',               '10' );
1356
        C4::Context->set_preference( 'OPACFineNoRenewalsIncludeCredits', '1' );
1356
        C4::Context->set_preference( 'FineNoRenewalsIncludeCredits', '1' );
1357
        my $fines_amount = 5;
1357
        my $fines_amount = 5;
1358
        my $account      = Koha::Account->new( { patron_id => $renewing_borrowernumber } );
1358
        my $account      = Koha::Account->new( { patron_id => $renewing_borrowernumber } );
1359
        $account->add_debit(
1359
        $account->add_debit(
Lines 1407-1425 subtest "CanBookBeRenewed tests" => sub { Link Here
1407
        is( $renewokay, 1, 'Renew, even if renewal is automatic' );
1407
        is( $renewokay, 1, 'Renew, even if renewal is automatic' );
1408
        is(
1408
        is(
1409
            $error, 'auto_renew',
1409
            $error, 'auto_renew',
1410
            'Can auto renew, FineNoRenewals=10, OPACFineNoRenewalsIncludeCredits=1, patron has 15 debt, 5 credit'
1410
            'Can auto renew, FineNoRenewals=10, FineNoRenewalsIncludeCredits=1, patron has 15 debt, 5 credit'
1411
        );
1411
        );
1412
1412
1413
        C4::Context->set_preference( 'OPACFineNoRenewalsIncludeCredits', '0' );
1413
        C4::Context->set_preference( 'FineNoRenewalsIncludeCredits', '0' );
1414
        ( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrower_obj, $issue );
1414
        ( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrower_obj, $issue );
1415
        is( $renewokay, 0, 'Do not renew, renewal is automatic' );
1415
        is( $renewokay, 0, 'Do not renew, renewal is automatic' );
1416
        is(
1416
        is(
1417
            $error, 'auto_too_much_owing',
1417
            $error, 'auto_too_much_owing',
1418
            'Cannot auto renew, FineNoRenewals=10, OPACFineNoRenewalsIncludeCredits=1, patron has 15 debt, 5 credit'
1418
            'Cannot auto renew, FineNoRenewals=10, FineNoRenewalsIncludeCredits=0, patron has 15 debt, 5 credit'
1419
        );
1419
        );
1420
1420
1421
        $dbh->do( 'DELETE FROM accountlines WHERE borrowernumber=?', undef, $renewing_borrowernumber );
1421
        $dbh->do( 'DELETE FROM accountlines WHERE borrowernumber=?', undef, $renewing_borrowernumber );
1422
        C4::Context->set_preference( 'OPACFineNoRenewalsIncludeCredits', '1' );
1422
        C4::Context->set_preference( 'FineNoRenewalsIncludeCredits', '1' );
1423
    };
1423
    };
1424
1424
1425
    subtest "auto_account_expired | BlockExpiredPatronOpacActions" => sub {
1425
    subtest "auto_account_expired | BlockExpiredPatronOpacActions" => sub {
1426
- 

Return to bug 23415