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

(-)a/C4/Circulation.pm (-1 / +1 lines)
Lines 3253-3259 sub CanBookBeRenewed { Link Here
3253
        {
3253
        {
3254
            return ( 0, 'overdue' );
3254
            return ( 0, 'overdue' );
3255
        } elsif ( $finesblockrenewing && $balance > $finesblockrenewing && !$allowfineoverriderenewing ) {
3255
        } elsif ( $finesblockrenewing && $balance > $finesblockrenewing && !$allowfineoverriderenewing ) {
3256
            return ( 0, 'too_much_oweing');
3256
            return ( 0, 'too_much_oweing' );
3257
        }
3257
        }
3258
3258
3259
    }
3259
    }
(-)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 571-577 Circulation: Link Here
571
            - Only allow patrons or staff to renew items if patron has less than
571
            - Only allow patrons or staff to renew items if patron has less than
572
            - pref: FineNoRenewals
572
            - pref: FineNoRenewals
573
              class: currency
573
              class: currency
574
            - [% local_currency %] in fines (leave blank to disable).
574
            - '[% local_currency %] in fines (leave blank to disable).'
575
    Lost item policy:
575
    Lost item policy:
576
        -
576
        -
577
            - By default, set the <a href="/cgi-bin/koha/admin/authorised_values.pl?searchfield=LOST">LOST</a> value of an item to
577
            - 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 1134-1140 Link Here
1134
1134
1135
        var amountlimit = "[% Koha.Preference('FineNoRenewals') | html %]";
1135
        var amountlimit = "[% Koha.Preference('FineNoRenewals') | html %]";
1136
        var fines = "[% fines | $Price %]";
1136
        var fines = "[% fines | $Price %]";
1137
        var MSG_CONFIRM_RENEW = _("The patron has a debt of %s\nAre you sure you want to renew checkout(s)?").format(fines);
1137
        var MSG_CONFIRM_RENEW = _("The patron has a debt of %s").format(fines);
1138
        MSG_CONFIRM_RENEW += _("Are you sure you want to renew checkout(s)?");
1138
1139
1139
        // On-site checkout
1140
        // On-site checkout
1140
        function toggle_onsite_checkout(){
1141
        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 815-821 Link Here
815
815
816
        var amountlimit = "[% Koha.Preference('FineNoRenewals') | html %]";
816
        var amountlimit = "[% Koha.Preference('FineNoRenewals') | html %]";
817
        var fines = "[% fines | $Price %]";
817
        var fines = "[% fines | $Price %]";
818
        var MSG_CONFIRM_RENEW = _("The patron has a debt of %s\n Are you sure you want to renew checkout(s)?").format(fines);
818
        var MSG_CONFIRM_RENEW = _("The patron has a debt of %s").format(fines);
819
        MSG_CONFIRM_RENEW += _("Are you sure you want to renew checkout(s)?");
819
820
820
        function uncheck_sibling(me){
821
        function uncheck_sibling(me){
821
            nodename=me.getAttribute("name");
822
            nodename=me.getAttribute("name");
(-)a/koha-tmpl/intranet-tmpl/prog/js/checkouts.js (-9 / +18 lines)
Lines 472-484 function LoadIssuesTable() { Link Here
472
472
473
                            span_style = "display: none";
473
                            span_style = "display: none";
474
                            span_class = "renewals-allowed";
474
                            span_class = "renewals-allowed";
475
                        } else if (
475
                        } else if (oObj.can_renew_error == "too_much_oweing") {
476
                            oObj.can_renew_error == "too_much_oweing"
477
                        ) {
478
                            msg +=
476
                            msg +=
479
                                "<span class='renewals-disabled'>" +
477
                                "<span class='renewals-disabled'>" +
480
                                __(
478
                                __(
481
                                    "Cannot renew, he patron has a debt of " + parseFloat(oObj.fine).format_price()
479
                                    "Cannot renew, he patron has a debt of " +
480
                                        parseFloat(oObj.fine).format_price()
482
                                ) +
481
                                ) +
483
                                "</span>";
482
                                "</span>";
484
483
Lines 958-970 $(document).ready(function () { Link Here
958
        e.preventDefault();
957
        e.preventDefault();
959
        let refresh_table = true;
958
        let refresh_table = true;
960
959
961
        if(show_confirm  && parseFloat(fines) > parseFloat(amountlimit) ) {
960
        if (show_confirm && parseFloat(fines) > parseFloat(amountlimit)) {
962
            var result = confirm(MSG_CONFIRM_RENEW);
961
            var result = confirm(MSG_CONFIRM_RENEW);
963
            if(!result){
962
            if (!result) {
964
                return false;
963
                return false;
965
            }
964
            }
966
            // Prevent displaying confirm box again
965
            // Prevent displaying confirm box again
967
            show_confirm  = false;
966
            show_confirm = false;
968
        }
967
        }
969
968
970
        function renew(item_id) {
969
        function renew(item_id) {
Lines 1002-1009 $(document).ready(function () { Link Here
1002
                params.date_due = dueDate;
1001
                params.date_due = dueDate;
1003
            }
1002
            }
1004
1003
1005
1004
            $(this)
1006
            $(this).parent().parent().replaceWith("<img id='renew_" + item_id+ "' src='" + interface + "/" + theme + "/img/spinner-small.gif' />");
1005
                .parent()
1006
                .parent()
1007
                .replaceWith(
1008
                    "<img id='renew_" +
1009
                        item_id +
1010
                        "' src='" +
1011
                        interface +
1012
                        "/" +
1013
                        theme +
1014
                        "/img/spinner-small.gif' />"
1015
                );
1007
1016
1008
            const client = APIClient.circulation;
1017
            const client = APIClient.circulation;
1009
            return client.checkouts.renew(params).then(
1018
            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