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 851-857 Link Here
851
851
852
        var amountlimit = "[% Koha.Preference('FineNoRenewals') | html %]";
852
        var amountlimit = "[% Koha.Preference('FineNoRenewals') | html %]";
853
        var fines = "[% fines | $Price %]";
853
        var fines = "[% fines | $Price %]";
854
        var MSG_CONFIRM_RENEW = _("The patron has a debt of %s\n Are you sure you want to renew checkout(s)?").format(fines);
854
        var MSG_CONFIRM_RENEW = _("The patron has a debt of %s").format(fines);
855
        MSG_CONFIRM_RENEW += _("Are you sure you want to renew checkout(s)?");
855
856
856
        function uncheck_sibling(me){
857
        function uncheck_sibling(me){
857
            nodename=me.getAttribute("name");
858
            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 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( 'OPACFineNoRenewalsBlockAutoRenew', '1' );
1356
        C4::Context->set_preference('FineNoRenewals','10');
1356
        C4::Context->set_preference( 'FineNoRenewals',                   '10' );
1357
        C4::Context->set_preference('OPACFineNoRenewalsIncludeCredit','1');
1357
        C4::Context->set_preference( 'OPACFineNoRenewalsIncludeCredit',  '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 1366-1375 subtest "CanBookBeRenewed tests" => sub { Link Here
1366
                description => "Some fines"
1366
                description => "Some fines"
1367
            }
1367
            }
1368
        )->status('RETURNED')->store;
1368
        )->status('RETURNED')->store;
1369
        ( $renewokay, $error ) =
1369
        ( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrower_obj, $issue );
1370
          CanBookBeRenewed( $renewing_borrower_obj, $issue );
1371
        is( $renewokay, 1,            'Renew, even if renewal is automatic' );
1370
        is( $renewokay, 1,            'Renew, even if renewal is automatic' );
1372
        is( $error, 'auto_renew', 'Can auto renew, FineNoRenewals=10, patron has 5' );
1371
        is( $error,     'auto_renew', 'Can auto renew, FineNoRenewals=10, patron has 5' );
1373
1372
1374
        $account->add_debit(
1373
        $account->add_debit(
1375
            {
1374
            {
Lines 1380-1389 subtest "CanBookBeRenewed tests" => sub { Link Here
1380
                description => "Some fines"
1379
                description => "Some fines"
1381
            }
1380
            }
1382
        )->status('RETURNED')->store;
1381
        )->status('RETURNED')->store;
1383
        ( $renewokay, $error ) =
1382
        ( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrower_obj, $issue );
1384
          CanBookBeRenewed( $renewing_borrower_obj, $issue );
1385
        is( $renewokay, 1,            'Renew, even if renewal is automatic' );
1383
        is( $renewokay, 1,            'Renew, even if renewal is automatic' );
1386
        is( $error, 'auto_renew', 'Can auto renew, FineNoRenewals=10, patron has 10' );
1384
        is( $error,     'auto_renew', 'Can auto renew, FineNoRenewals=10, patron has 10' );
1387
1385
1388
        $account->add_debit(
1386
        $account->add_debit(
1389
            {
1387
            {
Lines 1394-1403 subtest "CanBookBeRenewed tests" => sub { Link Here
1394
                description => "Some fines"
1392
                description => "Some fines"
1395
            }
1393
            }
1396
        )->status('RETURNED')->store;
1394
        )->status('RETURNED')->store;
1397
        ( $renewokay, $error ) =
1395
        ( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrower_obj, $issue );
1398
          CanBookBeRenewed( $renewing_borrower_obj, $issue );
1396
        is( $renewokay, 0,                      'Do not renew, renewal is automatic' );
1399
        is( $renewokay, 0,                       'Do not renew, renewal is automatic' );
1397
        is( $error,     'auto_too_much_oweing', 'Cannot auto renew, FineNoRenewals=10, patron has 15' );
1400
        is( $error, 'auto_too_much_oweing', 'Cannot auto renew, FineNoRenewals=10, patron has 15' );
1401
1398
1402
        $account->add_credit(
1399
        $account->add_credit(
1403
            {
1400
            {
Lines 1824-1830 subtest "CanBookBeRenewed tests" => sub { Link Here
1824
        "Account line description must not contain 'Lost Items ', but be title, barcode, itemcallnumber"
1821
        "Account line description must not contain 'Lost Items ', but be title, barcode, itemcallnumber"
1825
    );
1822
    );
1826
1823
1827
    t::lib::Mocks::mock_preference('FineNoRenewals', 0);
1824
    t::lib::Mocks::mock_preference( 'FineNoRenewals', 0 );
1828
1825
1829
    # Recalls
1826
    # Recalls
1830
    t::lib::Mocks::mock_preference( 'UseRecalls', 1 );
1827
    t::lib::Mocks::mock_preference( 'UseRecalls', 1 );
Lines 1904-1913 subtest "CanBookBeRenewed tests" => sub { Link Here
1904
    $recall->set_cancelled;
1901
    $recall->set_cancelled;
1905
1902
1906
    # Too much debt
1903
    # Too much debt
1907
    t::lib::Mocks::mock_preference('FineNoRenewals', 1);
1904
    t::lib::Mocks::mock_preference( 'FineNoRenewals', 1 );
1908
    ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrower_obj, $issue_1);
1905
    ( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrower_obj, $issue_1 );
1909
    is( $renewokay, 0, 'Cannot renew, too much debt and FineNoRenewals=1' );
1906
    is( $renewokay, 0,                 'Cannot renew, too much debt and FineNoRenewals=1' );
1910
    is( $error, 'too_much_oweing', 'Cannot renew, debt not allowed (returned code is too_much_oweing)');
1907
    is( $error,     'too_much_oweing', 'Cannot renew, debt not allowed (returned code is too_much_oweing)' );
1911
    C4::Context->dbh->do("DELETE FROM accountlines");
1908
    C4::Context->dbh->do("DELETE FROM accountlines");
1912
};
1909
};
1913
1910
1914
- 

Return to bug 23415