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

(-)a/C4/Circulation.pm (-1 / +1 lines)
Lines 3281-3287 sub CanBookBeRenewed { Link Here
3281
        {
3281
        {
3282
            return ( 0, 'overdue' );
3282
            return ( 0, 'overdue' );
3283
        } elsif ( $finesblockrenewing && $balance > $finesblockrenewing && !$allowfineoverriderenewing ) {
3283
        } elsif ( $finesblockrenewing && $balance > $finesblockrenewing && !$allowfineoverriderenewing ) {
3284
            return ( 0, 'too_much_oweing');
3284
            return ( 0, 'too_much_oweing' );
3285
        }
3285
        }
3286
3286
3287
    }
3287
    }
(-)a/circ/renew.pl (-4 / +3 lines)
Lines 95-106 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_oweing' or $error eq 'auto_too_much_oweing' ) ) {
99
                    if ($override_debt) {
99
                    if ($override_debt) {
100
                        $can_renew = 1;
100
                        $can_renew = 1;
101
                        $error = undef;
101
                        $error     = undef;
102
                    }
102
                    } else {
103
                    else {
104
                        $balance = $patron->account->balance;
103
                        $balance = $patron->account->balance;
105
                        $template->param( balance => $balance );
104
                        $template->param( balance => $balance );
106
                        $can_renew = 0;
105
                        $can_renew = 0;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref (-1 / +1 lines)
Lines 584-590 Circulation: Link Here
584
            - Only allow patrons or staff to renew items if patron has less than
584
            - Only allow patrons or staff to renew items if patron has less than
585
            - pref: FineNoRenewals
585
            - pref: FineNoRenewals
586
              class: currency
586
              class: currency
587
            - [% local_currency %] in fines (leave blank to disable).
587
            - '[% local_currency %] in fines (leave blank to disable).'
588
    Lost item policy:
588
    Lost item policy:
589
        -
589
        -
590
            - By default, set the <a href="/cgi-bin/koha/admin/authorised_values.pl?searchfield=LOST">LOST</a> value of an item to
590
            - By default, set the <a href="/cgi-bin/koha/admin/authorised_values.pl?searchfield=LOST">LOST</a> value of an item to
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt (-1 / +2 lines)
Lines 1135-1141 Link Here
1135
1135
1136
        var amountlimit = "[% Koha.Preference('FineNoRenewals') | html %]";
1136
        var amountlimit = "[% Koha.Preference('FineNoRenewals') | html %]";
1137
        var fines = "[% fines | $Price %]";
1137
        var fines = "[% fines | $Price %]";
1138
        var MSG_CONFIRM_RENEW = _("The patron has a debt of %s\nAre you sure you want to renew checkout(s)?").format(fines);
1138
        var MSG_CONFIRM_RENEW = _("The patron has a debt of %s").format(fines);
1139
        MSG_CONFIRM_RENEW += _("Are you sure you want to renew checkout(s)?");
1139
1140
1140
        // On-site checkout
1141
        // On-site checkout
1141
        function toggle_onsite_checkout(){
1142
        function toggle_onsite_checkout(){
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/renew.tt (-3 / +3 lines)
Lines 140-150 Link Here
140
                    </form>
140
                    </form>
141
                [% END %]
141
                [% END %]
142
            [% ELSIF error == "too_much_oweing" %]
142
            [% ELSIF error == "too_much_oweing" %]
143
144
                <li>The patron has a debt of [% balance | $Price %].</li>
143
                <li>The patron has a debt of [% balance | $Price %].</li>
145
                <form method="post" action="/cgi-bin/koha/circ/renew.pl">
144
                <form method="post" action="/cgi-bin/koha/circ/renew.pl">
146
                    <input type="hidden" name="barcode" value="[% item.barcode | html %]"/>
145
                    [% INCLUDE 'csrf-token.inc' %]
146
                    <input type="hidden" name="barcode" value="[% item.barcode | html %]" />
147
                    <input type="hidden" name="override_debt" value="1" />
147
                    <input type="hidden" name="override_debt" value="1" />
148
                    <input type="hidden" name="op" value="cud-renew" />
148
                    <button type="submit" class="approve"><i class="fa fa-check"></i>Renew checkout(s)</button>
149
                    <button type="submit" class="approve"><i class="fa fa-check"></i>Renew checkout(s)</button>
149
                </form>
150
                </form>
150
            [% ELSIF error == "on_reserve" %]
151
            [% ELSIF error == "on_reserve" %]
Lines 173-179 Link Here
173
                <p>Item cannot be renewed because it's an onsite checkout</p>
174
                <p>Item cannot be renewed because it's an onsite checkout</p>
174
            [% ELSIF error == 'recalled' %]
175
            [% ELSIF error == 'recalled' %]
175
                <p>This item has been recalled.</p>
176
                <p>This item has been recalled.</p>
176
177
            [% ELSE %]
177
            [% ELSE %]
178
178
179
                [% error | html %]
179
                [% error | html %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt (-1 / +2 lines)
Lines 863-869 Link Here
863
863
864
        var amountlimit = "[% Koha.Preference('FineNoRenewals') | html %]";
864
        var amountlimit = "[% Koha.Preference('FineNoRenewals') | html %]";
865
        var fines = "[% fines | $Price %]";
865
        var fines = "[% fines | $Price %]";
866
        var MSG_CONFIRM_RENEW = _("The patron has a debt of %s\n Are you sure you want to renew checkout(s)?").format(fines);
866
        var MSG_CONFIRM_RENEW = _("The patron has a debt of %s").format(fines);
867
        MSG_CONFIRM_RENEW += _("Are you sure you want to renew checkout(s)?");
867
868
868
        function uncheck_sibling(me){
869
        function uncheck_sibling(me){
869
            nodename=me.getAttribute("name");
870
            nodename=me.getAttribute("name");
(-)a/koha-tmpl/intranet-tmpl/prog/js/checkouts.js (-9 / +18 lines)
Lines 503-515 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 (
506
                        } else if (oObj.can_renew_error == "too_much_oweing") {
507
                            oObj.can_renew_error == "too_much_oweing"
508
                        ) {
509
                            msg +=
507
                            msg +=
510
                                "<span class='renewals-disabled'>" +
508
                                "<span class='renewals-disabled'>" +
511
                                __(
509
                                __(
512
                                    "Cannot renew, he patron has a debt of " + parseFloat(oObj.fine).format_price()
510
                                    "Cannot renew, he patron has a debt of " +
511
                                        parseFloat(oObj.fine).format_price()
513
                                ) +
512
                                ) +
514
                                "</span>";
513
                                "</span>";
515
514
Lines 1000-1012 $(document).ready(function () { Link Here
1000
        e.preventDefault();
999
        e.preventDefault();
1001
        let refresh_table = true;
1000
        let refresh_table = true;
1002
1001
1003
        if(show_confirm  && parseFloat(fines) > parseFloat(amountlimit) ) {
1002
        if (show_confirm && parseFloat(fines) > parseFloat(amountlimit)) {
1004
            var result = confirm(MSG_CONFIRM_RENEW);
1003
            var result = confirm(MSG_CONFIRM_RENEW);
1005
            if(!result){
1004
            if (!result) {
1006
                return false;
1005
                return false;
1007
            }
1006
            }
1008
            // Prevent displaying confirm box again
1007
            // Prevent displaying confirm box again
1009
            show_confirm  = false;
1008
            show_confirm = false;
1010
        }
1009
        }
1011
1010
1012
        function renew(item_id) {
1011
        function renew(item_id) {
Lines 1044-1051 $(document).ready(function () { Link Here
1044
                params.date_due = dueDate;
1043
                params.date_due = dueDate;
1045
            }
1044
            }
1046
1045
1047
1046
            $(this)
1048
            $(this).parent().parent().replaceWith("<img id='renew_" + item_id+ "' src='" + interface + "/" + theme + "/img/spinner-small.gif' />");
1047
                .parent()
1048
                .parent()
1049
                .replaceWith(
1050
                    "<img id='renew_" +
1051
                        item_id +
1052
                        "' src='" +
1053
                        interface +
1054
                        "/" +
1055
                        theme +
1056
                        "/img/spinner-small.gif' />"
1057
                );
1049
1058
1050
            const client = APIClient.circulation;
1059
            const client = APIClient.circulation;
1051
            return client.checkouts.renew(params).then(
1060
            return client.checkouts.renew(params).then(
(-)a/opac/opac-user.pl (-2 / +2 lines)
Lines 125-132 if ( $userdebarred || $borr->{'gonenoaddress'} || $borr->{'lost'} ) { Link Here
125
}
125
}
126
126
127
my $amountoutstanding = $patron->account->balance;
127
my $amountoutstanding = $patron->account->balance;
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("OPACFineNoRenewalsIncludeCredits")
132
    ? $amountoutstanding
132
    ? $amountoutstanding
(-)a/t/db_dependent/Circulation.t (-19 / +15 lines)
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( 'OPACFineNoRenewalsBlockAutoRenew', '1' );
1355
        C4::Context->set_preference('FineNoRenewals','10');
1355
        C4::Context->set_preference( 'FineNoRenewals',                   '10' );
1356
        C4::Context->set_preference('OPACFineNoRenewalsIncludeCredit','1');
1356
        C4::Context->set_preference( 'OPACFineNoRenewalsIncludeCredit',  '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 1365-1374 subtest "CanBookBeRenewed tests" => sub { Link Here
1365
                description => "Some fines"
1365
                description => "Some fines"
1366
            }
1366
            }
1367
        )->status('RETURNED')->store;
1367
        )->status('RETURNED')->store;
1368
        ( $renewokay, $error ) =
1368
        ( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrower_obj, $issue );
1369
          CanBookBeRenewed( $renewing_borrower_obj, $issue );
1370
        is( $renewokay, 1,            'Renew, even if renewal is automatic' );
1369
        is( $renewokay, 1,            'Renew, even if renewal is automatic' );
1371
        is( $error, 'auto_renew', 'Can auto renew, FineNoRenewals=10, patron has 5' );
1370
        is( $error,     'auto_renew', 'Can auto renew, FineNoRenewals=10, patron has 5' );
1372
1371
1373
        $account->add_debit(
1372
        $account->add_debit(
1374
            {
1373
            {
Lines 1379-1388 subtest "CanBookBeRenewed tests" => sub { Link Here
1379
                description => "Some fines"
1378
                description => "Some fines"
1380
            }
1379
            }
1381
        )->status('RETURNED')->store;
1380
        )->status('RETURNED')->store;
1382
        ( $renewokay, $error ) =
1381
        ( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrower_obj, $issue );
1383
          CanBookBeRenewed( $renewing_borrower_obj, $issue );
1384
        is( $renewokay, 1,            'Renew, even if renewal is automatic' );
1382
        is( $renewokay, 1,            'Renew, even if renewal is automatic' );
1385
        is( $error, 'auto_renew', 'Can auto renew, FineNoRenewals=10, patron has 10' );
1383
        is( $error,     'auto_renew', 'Can auto renew, FineNoRenewals=10, patron has 10' );
1386
1384
1387
        $account->add_debit(
1385
        $account->add_debit(
1388
            {
1386
            {
Lines 1393-1402 subtest "CanBookBeRenewed tests" => sub { Link Here
1393
                description => "Some fines"
1391
                description => "Some fines"
1394
            }
1392
            }
1395
        )->status('RETURNED')->store;
1393
        )->status('RETURNED')->store;
1396
        ( $renewokay, $error ) =
1394
        ( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrower_obj, $issue );
1397
          CanBookBeRenewed( $renewing_borrower_obj, $issue );
1395
        is( $renewokay, 0,                      'Do not renew, renewal is automatic' );
1398
        is( $renewokay, 0,                       'Do not renew, renewal is automatic' );
1396
        is( $error,     'auto_too_much_oweing', 'Cannot auto renew, FineNoRenewals=10, patron has 15' );
1399
        is( $error, 'auto_too_much_oweing', 'Cannot auto renew, FineNoRenewals=10, patron has 15' );
1400
1397
1401
        $account->add_credit(
1398
        $account->add_credit(
1402
            {
1399
            {
Lines 1893-1899 subtest "CanBookBeRenewed tests" => sub { Link Here
1893
        "Account line description must not contain 'Lost Items ', but be title, barcode, itemcallnumber"
1890
        "Account line description must not contain 'Lost Items ', but be title, barcode, itemcallnumber"
1894
    );
1891
    );
1895
1892
1896
    t::lib::Mocks::mock_preference('FineNoRenewals', 0);
1893
    t::lib::Mocks::mock_preference( 'FineNoRenewals', 0 );
1897
1894
1898
    # Recalls
1895
    # Recalls
1899
    t::lib::Mocks::mock_preference( 'UseRecalls', 1 );
1896
    t::lib::Mocks::mock_preference( 'UseRecalls', 1 );
Lines 1973-1982 subtest "CanBookBeRenewed tests" => sub { Link Here
1973
    $recall->set_cancelled;
1970
    $recall->set_cancelled;
1974
1971
1975
    # Too much debt
1972
    # Too much debt
1976
    t::lib::Mocks::mock_preference('FineNoRenewals', 1);
1973
    t::lib::Mocks::mock_preference( 'FineNoRenewals', 1 );
1977
    ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrower_obj, $issue_1);
1974
    ( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrower_obj, $issue_1 );
1978
    is( $renewokay, 0, 'Cannot renew, too much debt and FineNoRenewals=1' );
1975
    is( $renewokay, 0,                 'Cannot renew, too much debt and FineNoRenewals=1' );
1979
    is( $error, 'too_much_oweing', 'Cannot renew, debt not allowed (returned code is too_much_oweing)');
1976
    is( $error,     'too_much_oweing', 'Cannot renew, debt not allowed (returned code is too_much_oweing)' );
1980
    C4::Context->dbh->do("DELETE FROM accountlines");
1977
    C4::Context->dbh->do("DELETE FROM accountlines");
1981
};
1978
};
1982
1979
1983
- 

Return to bug 23415