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

(-)a/C4/Circulation.pm (-3 / +3 lines)
Lines 3238-3244 sub CanBookBeRenewed { Link Here
3238
        # extra notices being sent. Cron also implies no override
3238
        # extra notices being sent. Cron also implies no override
3239
        return ( 0, $auto_renew ) if $auto_renew =~ 'auto_account_expired';
3239
        return ( 0, $auto_renew ) if $auto_renew =~ 'auto_account_expired';
3240
        return ( 0, $auto_renew ) if $auto_renew =~ 'auto_too_late';
3240
        return ( 0, $auto_renew ) if $auto_renew =~ 'auto_too_late';
3241
        return ( 0, $auto_renew ) if $auto_renew =~ 'auto_too_much_oweing';
3241
        return ( 0, $auto_renew ) if $auto_renew =~ 'auto_too_much_owing';
3242
3242
3243
        my $issuing_rule = Koha::CirculationRules->get_effective_rules(
3243
        my $issuing_rule = Koha::CirculationRules->get_effective_rules(
3244
            {
3244
            {
Lines 3280-3286 sub CanBookBeRenewed { Link Here
3280
        {
3280
        {
3281
            return ( 0, 'overdue' );
3281
            return ( 0, 'overdue' );
3282
        } elsif ( $finesblockrenewing && $balance > $finesblockrenewing ) {
3282
        } elsif ( $finesblockrenewing && $balance > $finesblockrenewing ) {
3283
            return ( 0, 'too_much_oweing' );
3283
            return ( 0, 'too_much_owing' );
3284
        }
3284
        }
3285
3285
3286
    }
3286
    }
Lines 5053-5059 sub _CanBookBeAutoRenewed { Link Here
5053
            ? $patron->account->balance
5053
            ? $patron->account->balance
5054
            : $patron->account->outstanding_debits->total_outstanding;
5054
            : $patron->account->outstanding_debits->total_outstanding;
5055
        if ( $amountoutstanding and $amountoutstanding > $fine_no_renewals ) {
5055
        if ( $amountoutstanding and $amountoutstanding > $fine_no_renewals ) {
5056
            return "auto_too_much_oweing";
5056
            return "auto_too_much_owing";
5057
        }
5057
        }
5058
    }
5058
    }
5059
5059
(-)a/C4/SIP/Sip/MsgType.pm (-1 / +1 lines)
Lines 1246-1252 sub handle_fee_paid { Link Here
1246
        "auto_account_expired" =>
1246
        "auto_account_expired" =>
1247
            "Scheduled for automatic renewal and cannot be renewed because the patron's account has expired",
1247
            "Scheduled for automatic renewal and cannot be renewed because the patron's account has expired",
1248
        "auto_renew"                  => "Scheduled for automatic renewal",
1248
        "auto_renew"                  => "Scheduled for automatic renewal",
1249
        "auto_too_much_oweing"        => "Scheduled for automatic renewal",
1249
        "auto_too_much_owing"         => "Scheduled for automatic renewal",
1250
        "on_reserve"                  => "On hold for another patron",
1250
        "on_reserve"                  => "On hold for another patron",
1251
        "patron_restricted"           => "Patron is currently restricted",
1251
        "patron_restricted"           => "Patron is currently restricted",
1252
        "item_denied_renewal"         => "Item is not allowed renewal",
1252
        "item_denied_renewal"         => "Item is not allowed renewal",
(-)a/circ/renew.pl (-1 / +1 lines)
Lines 95-101 if ( $op eq 'cud-renew' && $barcode ) { Link Here
95
                    );
95
                    );
96
                }
96
                }
97
97
98
                if ( $error && ( $error eq 'too_much_oweing' or $error eq 'auto_too_much_oweing' ) ) {
98
                if ( $error && ( $error eq 'too_much_owing' or $error eq 'auto_too_much_owing' ) ) {
99
                    if ( $override_debt && C4::Context->preference("AllowFineOverrideRenewing") ) {
99
                    if ( $override_debt && C4::Context->preference("AllowFineOverrideRenewing") ) {
100
                        $can_renew = 1;
100
                        $can_renew = 1;
101
                        $error     = undef;
101
                        $error     = undef;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/renew.tt (-2 / +2 lines)
Lines 126-132 Link Here
126
                        <input type="submit" class="btn btn-default approve" value="Override and renew" />
126
                        <input type="submit" class="btn btn-default approve" value="Override and renew" />
127
                    </form>
127
                    </form>
128
                [% END %]
128
                [% END %]
129
            [% ELSIF error == "auto_renew" or error == "auto_too_much_oweing" %]
129
            [% ELSIF error == "auto_renew" or error == "auto_too_much_owing" %]
130
                <p>[% INCLUDE 'biblio-title.inc' biblio=item.biblio link = 1 %] ( [% item.barcode | html %] ) has been scheduled for automatic renewal. </p>
130
                <p>[% INCLUDE 'biblio-title.inc' biblio=item.biblio link = 1 %] ( [% item.barcode | html %] ) has been scheduled for automatic renewal. </p>
131
                [% SET override_limit = error == "auto_renew" ? "AUTO_RENEW" : "TOO_MUCH" %]
131
                [% SET override_limit = error == "auto_renew" ? "AUTO_RENEW" : "TOO_MUCH" %]
132
132
Lines 139-145 Link Here
139
                        <button type="submit" class="btn btn-default approve"><i class="fa fa-check"></i> Override limit and renew</button>
139
                        <button type="submit" class="btn btn-default approve"><i class="fa fa-check"></i> Override limit and renew</button>
140
                    </form>
140
                    </form>
141
                [% END %]
141
                [% END %]
142
            [% ELSIF error == "too_much_oweing" %]
142
            [% ELSIF error == "too_much_owing" %]
143
                <li>The patron has a debt of [% balance | $Price %].</li>
143
                <li>The patron has a debt of [% balance | $Price %].</li>
144
                [% IF Koha.Preference('AllowFineOverrideRenewing') %]
144
                [% IF Koha.Preference('AllowFineOverrideRenewing') %]
145
                    <form method="post" action="/cgi-bin/koha/circ/renew.pl">
145
                    <form method="post" action="/cgi-bin/koha/circ/renew.pl">
(-)a/koha-tmpl/intranet-tmpl/prog/js/checkouts.js (-2 / +2 lines)
Lines 468-474 function LoadIssuesTable() { Link Here
468
                            span_style = "display: none";
468
                            span_style = "display: none";
469
                            span_class = "renewals-allowed";
469
                            span_class = "renewals-allowed";
470
                        } else if (
470
                        } else if (
471
                            oObj.can_renew_error == "auto_too_much_oweing"
471
                            oObj.can_renew_error == "auto_too_much_owing"
472
                        ) {
472
                        ) {
473
                            msg +=
473
                            msg +=
474
                                "<span class='renewals-disabled'>" +
474
                                "<span class='renewals-disabled'>" +
Lines 503-509 function LoadIssuesTable() { Link Here
503
503
504
                            span_style = "display: none";
504
                            span_style = "display: none";
505
                            span_class = "renewals-allowed";
505
                            span_class = "renewals-allowed";
506
                        } else if (oObj.can_renew_error == "too_much_oweing") {
506
                        } else if (oObj.can_renew_error == "too_much_owing") {
507
                            msg +=
507
                            msg +=
508
                                "<span class='renewals-disabled'>" +
508
                                "<span class='renewals-disabled'>" +
509
                                __(
509
                                __(
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt (-2 / +2 lines)
Lines 59-66 Link Here
59
                            [% INCLUDE "patron-restrictions.inc" %]
59
                            [% INCLUDE "patron-restrictions.inc" %]
60
                        [% END %]
60
                        [% END %]
61
61
62
                        [% IF ( too_much_oweing ) %]
62
                        [% IF ( too_much_owing ) %]
63
                            <li id="too_much_oweing"> You have unpaid fines. Amount: [% too_much_oweing | $Price %]. </li>
63
                            <li id="too_much_owing"> You have unpaid fines. Amount: [% too_much_owing | $Price %]. </li>
64
                        [% END %]
64
                        [% END %]
65
65
66
                        [% IF ( too_many_reserves ) %]
66
                        [% IF ( too_many_reserves ) %]
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt (-1 / +1 lines)
Lines 458-464 Link Here
458
                                                                    <span class="usr-msg no-renew-overdue">Not allowed <span class="renewals">(overdue)</span></span>
458
                                                                    <span class="usr-msg no-renew-overdue">Not allowed <span class="renewals">(overdue)</span></span>
459
                                                                [% ELSIF ( ISSUE.auto_too_late ) %]
459
                                                                [% ELSIF ( ISSUE.auto_too_late ) %]
460
                                                                    <span class="usr-msg no-renew-too-late">No longer renewable</span>
460
                                                                    <span class="usr-msg no-renew-too-late">No longer renewable</span>
461
                                                                [% ELSIF ISSUE.auto_too_much_oweing %]
461
                                                                [% ELSIF ISSUE.auto_too_much_owing %]
462
                                                                    <span class="usr-msg auto-renew-fines">Automatic renewal failed, you have unpaid fines.</span>
462
                                                                    <span class="usr-msg auto-renew-fines">Automatic renewal failed, you have unpaid fines.</span>
463
                                                                    <span class="renewals"
463
                                                                    <span class="renewals"
464
                                                                        >( [% I18N.tx("{renewals_left} of {renewals_allowed} renewals remaining", { renewals_left = ISSUE.renewsleft, renewals_allowed = ISSUE.renewsallowed }) %]
464
                                                                        >( [% I18N.tx("{renewals_left} of {renewals_allowed} renewals remaining", { renewals_left = ISSUE.renewsleft, renewals_allowed = ISSUE.renewsallowed }) %]
(-)a/misc/cronjobs/automatic_renewals.pl (-1 / +1 lines)
Lines 243-249 sub _ProcessRenewals { Link Here
243
            || $error eq 'too_unseen'
243
            || $error eq 'too_unseen'
244
            || $error eq 'auto_account_expired'
244
            || $error eq 'auto_account_expired'
245
            || $error eq 'auto_too_late'
245
            || $error eq 'auto_too_late'
246
            || $error eq 'auto_too_much_oweing'
246
            || $error eq 'auto_too_much_owing'
247
            || $error eq 'auto_too_soon'
247
            || $error eq 'auto_too_soon'
248
            || $error eq 'item_denied_renewal'
248
            || $error eq 'item_denied_renewal'
249
            || $error eq 'item_issued_to_other_patron'
249
            || $error eq 'item_issued_to_other_patron'
(-)a/opac/opac-reserve.pl (-1 / +1 lines)
Lines 125-131 if ( !$can_place_holds ) { Link Here
125
        if ( $msg->message eq 'expired' ) {
125
        if ( $msg->message eq 'expired' ) {
126
            $template->param( expired_patron => 1 );
126
            $template->param( expired_patron => 1 );
127
        } elsif ( $msg->message eq 'debt_limit' ) {
127
        } elsif ( $msg->message eq 'debt_limit' ) {
128
            $template->param( too_much_oweing => sprintf( "%.02f", $msg->{payload}->{total_outstanding} ) );
128
            $template->param( too_much_owing => sprintf( "%.02f", $msg->{payload}->{total_outstanding} ) );
129
        } elsif ( $msg->message eq 'bad_address' ) {
129
        } elsif ( $msg->message eq 'bad_address' ) {
130
            $template->param( GNA => 1 );
130
            $template->param( GNA => 1 );
131
        } elsif ( $msg->message eq 'card_lost' ) {
131
        } elsif ( $msg->message eq 'card_lost' ) {
(-)a/opac/opac-user.pl (-1 / +1 lines)
Lines 258-264 if ( $pending_checkouts->count ) { # Useless test Link Here
258
            $issue->{'auto_renew'}                  = 1 if $renewerror eq 'auto_renew';
258
            $issue->{'auto_renew'}                  = 1 if $renewerror eq 'auto_renew';
259
            $issue->{'auto_too_soon'}               = 1 if $renewerror eq 'auto_too_soon';
259
            $issue->{'auto_too_soon'}               = 1 if $renewerror eq 'auto_too_soon';
260
            $issue->{'auto_too_late'}               = 1 if $renewerror eq 'auto_too_late';
260
            $issue->{'auto_too_late'}               = 1 if $renewerror eq 'auto_too_late';
261
            $issue->{'auto_too_much_oweing'}        = 1 if $renewerror eq 'auto_too_much_oweing';
261
            $issue->{'auto_too_much_owing'}         = 1 if $renewerror eq 'auto_too_much_owing';
262
            $issue->{'item_denied_renewal'}         = 1 if $renewerror eq 'item_denied_renewal';
262
            $issue->{'item_denied_renewal'}         = 1 if $renewerror eq 'item_denied_renewal';
263
            $issue->{'item_issued_to_other_patron'} = 1 if $renewerror eq 'item_issued_to_other_patron';
263
            $issue->{'item_issued_to_other_patron'} = 1 if $renewerror eq 'item_issued_to_other_patron';
264
264
(-)a/t/db_dependent/Circulation.t (-11 / +10 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_oweing | OPACFineNoRenewalsBlockAutoRenew & OPACFineNoRenewalsIncludeCredits" => sub {
1327
    subtest "auto_too_much_owing | OPACFineNoRenewalsBlockAutoRenew & OPACFineNoRenewalsIncludeCredits" => 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 1392-1399 subtest "CanBookBeRenewed tests" => sub { Link Here
1392
            }
1392
            }
1393
        )->status('RETURNED')->store;
1393
        )->status('RETURNED')->store;
1394
        ( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrower_obj, $issue );
1394
        ( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrower_obj, $issue );
1395
        is( $renewokay, 0,                      'Do not renew, renewal is automatic' );
1395
        is( $renewokay, 0,                     'Do not renew, renewal is automatic' );
1396
        is( $error,     'auto_too_much_oweing', 'Cannot auto renew, FineNoRenewals=10, patron has 15' );
1396
        is( $error,     'auto_too_much_owing', 'Cannot auto renew, FineNoRenewals=10, patron has 15' );
1397
1397
1398
        $account->add_credit(
1398
        $account->add_credit(
1399
            {
1399
            {
Lines 1414-1420 subtest "CanBookBeRenewed tests" => sub { Link Here
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_oweing',
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, OPACFineNoRenewalsIncludeCredits=1, patron has 15 debt, 5 credit'
1419
        );
1419
        );
1420
1420
Lines 1972-1991 subtest "CanBookBeRenewed tests" => sub { Link Here
1972
    # Too much debt
1972
    # Too much debt
1973
    t::lib::Mocks::mock_preference( 'FineNoRenewals', 1 );
1973
    t::lib::Mocks::mock_preference( 'FineNoRenewals', 1 );
1974
    ( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrower_obj, $issue_1 );
1974
    ( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrower_obj, $issue_1 );
1975
    is( $renewokay, 0,                 'Cannot renew, too much debt and FineNoRenewals=1' );
1975
    is( $renewokay, 0,                'Cannot renew, too much debt and FineNoRenewals=1' );
1976
    is( $error,     'too_much_oweing', 'Cannot renew, debt not allowed (returned code is too_much_oweing)' );
1976
    is( $error,     'too_much_owing', 'Cannot renew, debt not allowed (returned code is too_much_owing)' );
1977
1977
1978
    # AllowFineOverrideRenewing should not affect CanBookBeRenewed behavior
1978
    # AllowFineOverrideRenewing should not affect CanBookBeRenewed behavior
1979
    # The preference only controls whether staff can override in the UI
1979
    # The preference only controls whether staff can override in the UI
1980
    t::lib::Mocks::mock_preference( 'AllowFineOverrideRenewing', 1 );
1980
    t::lib::Mocks::mock_preference( 'AllowFineOverrideRenewing', 1 );
1981
    ( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrower_obj, $issue_1 );
1981
    ( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrower_obj, $issue_1 );
1982
    is( $renewokay, 0,                 'Cannot renew, too much debt even with AllowFineOverrideRenewing enabled' );
1982
    is( $renewokay, 0,                'Cannot renew, too much debt even with AllowFineOverrideRenewing enabled' );
1983
    is( $error,     'too_much_oweing', 'Error code still too_much_oweing with AllowFineOverrideRenewing enabled' );
1983
    is( $error,     'too_much_owing', 'Error code still too_much_owing with AllowFineOverrideRenewing enabled' );
1984
1984
1985
    t::lib::Mocks::mock_preference( 'AllowFineOverrideRenewing', 0 );
1985
    t::lib::Mocks::mock_preference( 'AllowFineOverrideRenewing', 0 );
1986
    ( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrower_obj, $issue_1 );
1986
    ( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrower_obj, $issue_1 );
1987
    is( $renewokay, 0,                 'Cannot renew, too much debt with AllowFineOverrideRenewing disabled' );
1987
    is( $renewokay, 0,                'Cannot renew, too much debt with AllowFineOverrideRenewing disabled' );
1988
    is( $error,     'too_much_oweing', 'Error code still too_much_oweing with AllowFineOverrideRenewing disabled' );
1988
    is( $error,     'too_much_owing', 'Error code still too_much_owing with AllowFineOverrideRenewing disabled' );
1989
1989
1990
    C4::Context->dbh->do("DELETE FROM accountlines");
1990
    C4::Context->dbh->do("DELETE FROM accountlines");
1991
};
1991
};
1992
- 

Return to bug 23415