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 5026-5032 sub _CanBookBeAutoRenewed { Link Here
5026
            ? $patron->account->balance
5026
            ? $patron->account->balance
5027
            : $patron->account->outstanding_debits->total_outstanding;
5027
            : $patron->account->outstanding_debits->total_outstanding;
5028
        if ( $amountoutstanding and $amountoutstanding > $fine_no_renewals ) {
5028
        if ( $amountoutstanding and $amountoutstanding > $fine_no_renewals ) {
5029
            return "auto_too_much_oweing";
5029
            return "auto_too_much_owing";
5030
        }
5030
        }
5031
    }
5031
    }
5032
5032
(-)a/C4/SIP/Sip/MsgType.pm (-1 / +1 lines)
Lines 1253-1259 sub handle_fee_paid { Link Here
1253
        "auto_account_expired" =>
1253
        "auto_account_expired" =>
1254
            "Scheduled for automatic renewal and cannot be renewed because the patron's account has expired",
1254
            "Scheduled for automatic renewal and cannot be renewed because the patron's account has expired",
1255
        "auto_renew"                  => "Scheduled for automatic renewal",
1255
        "auto_renew"                  => "Scheduled for automatic renewal",
1256
        "auto_too_much_oweing"        => "Scheduled for automatic renewal",
1256
        "auto_too_much_owing"         => "Scheduled for automatic renewal",
1257
        "on_reserve"                  => "On hold for another patron",
1257
        "on_reserve"                  => "On hold for another patron",
1258
        "patron_restricted"           => "Patron is currently restricted",
1258
        "patron_restricted"           => "Patron is currently restricted",
1259
        "item_denied_renewal"         => "Item is not allowed renewal",
1259
        "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 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_oweing | OPACFineNoRenewalsBlockAutoRenew & OPACFineNoRenewalsIncludeCredits" => sub {
1328
    subtest "auto_too_much_owing | OPACFineNoRenewalsBlockAutoRenew & OPACFineNoRenewalsIncludeCredits" => 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 1393-1400 subtest "CanBookBeRenewed tests" => sub { Link Here
1393
            }
1393
            }
1394
        )->status('RETURNED')->store;
1394
        )->status('RETURNED')->store;
1395
        ( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrower_obj, $issue );
1395
        ( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrower_obj, $issue );
1396
        is( $renewokay, 0,                      'Do not renew, renewal is automatic' );
1396
        is( $renewokay, 0,                     'Do not renew, renewal is automatic' );
1397
        is( $error,     'auto_too_much_oweing', 'Cannot auto renew, FineNoRenewals=10, patron has 15' );
1397
        is( $error,     'auto_too_much_owing', 'Cannot auto renew, FineNoRenewals=10, patron has 15' );
1398
1398
1399
        $account->add_credit(
1399
        $account->add_credit(
1400
            {
1400
            {
Lines 1415-1421 subtest "CanBookBeRenewed tests" => sub { Link Here
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_oweing',
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, OPACFineNoRenewalsIncludeCredits=1, patron has 15 debt, 5 credit'
1420
        );
1420
        );
1421
1421
Lines 1903-1922 subtest "CanBookBeRenewed tests" => sub { Link Here
1903
    # Too much debt
1903
    # Too much debt
1904
    t::lib::Mocks::mock_preference( 'FineNoRenewals', 1 );
1904
    t::lib::Mocks::mock_preference( 'FineNoRenewals', 1 );
1905
    ( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrower_obj, $issue_1 );
1905
    ( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrower_obj, $issue_1 );
1906
    is( $renewokay, 0,                 'Cannot renew, too much debt and FineNoRenewals=1' );
1906
    is( $renewokay, 0,                'Cannot renew, too much debt and FineNoRenewals=1' );
1907
    is( $error,     'too_much_oweing', 'Cannot renew, debt not allowed (returned code is too_much_oweing)' );
1907
    is( $error,     'too_much_owing', 'Cannot renew, debt not allowed (returned code is too_much_owing)' );
1908
1908
1909
    # AllowFineOverrideRenewing should not affect CanBookBeRenewed behavior
1909
    # AllowFineOverrideRenewing should not affect CanBookBeRenewed behavior
1910
    # The preference only controls whether staff can override in the UI
1910
    # The preference only controls whether staff can override in the UI
1911
    t::lib::Mocks::mock_preference( 'AllowFineOverrideRenewing', 1 );
1911
    t::lib::Mocks::mock_preference( 'AllowFineOverrideRenewing', 1 );
1912
    ( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrower_obj, $issue_1 );
1912
    ( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrower_obj, $issue_1 );
1913
    is( $renewokay, 0,                 'Cannot renew, too much debt even with AllowFineOverrideRenewing enabled' );
1913
    is( $renewokay, 0,                'Cannot renew, too much debt even with AllowFineOverrideRenewing enabled' );
1914
    is( $error,     'too_much_oweing', 'Error code still too_much_oweing with AllowFineOverrideRenewing enabled' );
1914
    is( $error,     'too_much_owing', 'Error code still too_much_owing with AllowFineOverrideRenewing enabled' );
1915
1915
1916
    t::lib::Mocks::mock_preference( 'AllowFineOverrideRenewing', 0 );
1916
    t::lib::Mocks::mock_preference( 'AllowFineOverrideRenewing', 0 );
1917
    ( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrower_obj, $issue_1 );
1917
    ( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrower_obj, $issue_1 );
1918
    is( $renewokay, 0,                 'Cannot renew, too much debt with AllowFineOverrideRenewing disabled' );
1918
    is( $renewokay, 0,                'Cannot renew, too much debt with AllowFineOverrideRenewing disabled' );
1919
    is( $error,     'too_much_oweing', 'Error code still too_much_oweing with AllowFineOverrideRenewing disabled' );
1919
    is( $error,     'too_much_owing', 'Error code still too_much_owing with AllowFineOverrideRenewing disabled' );
1920
1920
1921
    C4::Context->dbh->do("DELETE FROM accountlines");
1921
    C4::Context->dbh->do("DELETE FROM accountlines");
1922
};
1922
};
1923
- 

Return to bug 23415