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 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 816-822 Link Here
816
816
817
        var amountlimit = "[% Koha.Preference('FineNoRenewals') | html %]";
817
        var amountlimit = "[% Koha.Preference('FineNoRenewals') | html %]";
818
        var fines = "[% fines | $Price %]";
818
        var fines = "[% fines | $Price %]";
819
        var MSG_CONFIRM_RENEW = _("The patron has a debt of %s\n Are you sure you want to renew checkout(s)?").format(fines);
819
        var MSG_CONFIRM_RENEW = _("The patron has a debt of %s").format(fines);
820
        MSG_CONFIRM_RENEW += _("Are you sure you want to renew checkout(s)?");
820
821
821
        function uncheck_sibling(me){
822
        function uncheck_sibling(me){
822
            nodename=me.getAttribute("name");
823
            nodename=me.getAttribute("name");
(-)a/koha-tmpl/intranet-tmpl/prog/js/checkouts.js (-9 / +18 lines)
Lines 484-496 function LoadIssuesTable() { Link Here
484
484
485
                            span_style = "display: none";
485
                            span_style = "display: none";
486
                            span_class = "renewals-allowed";
486
                            span_class = "renewals-allowed";
487
                        } else if (
487
                        } else if (oObj.can_renew_error == "too_much_oweing") {
488
                            oObj.can_renew_error == "too_much_oweing"
489
                        ) {
490
                            msg +=
488
                            msg +=
491
                                "<span class='renewals-disabled'>" +
489
                                "<span class='renewals-disabled'>" +
492
                                __(
490
                                __(
493
                                    "Cannot renew, he patron has a debt of " + parseFloat(oObj.fine).format_price()
491
                                    "Cannot renew, he patron has a debt of " +
492
                                        parseFloat(oObj.fine).format_price()
494
                                ) +
493
                                ) +
495
                                "</span>";
494
                                "</span>";
496
495
Lines 980-992 $(document).ready(function () { Link Here
980
        e.preventDefault();
979
        e.preventDefault();
981
        let refresh_table = true;
980
        let refresh_table = true;
982
981
983
        if(show_confirm  && parseFloat(fines) > parseFloat(amountlimit) ) {
982
        if (show_confirm && parseFloat(fines) > parseFloat(amountlimit)) {
984
            var result = confirm(MSG_CONFIRM_RENEW);
983
            var result = confirm(MSG_CONFIRM_RENEW);
985
            if(!result){
984
            if (!result) {
986
                return false;
985
                return false;
987
            }
986
            }
988
            // Prevent displaying confirm box again
987
            // Prevent displaying confirm box again
989
            show_confirm  = false;
988
            show_confirm = false;
990
        }
989
        }
991
990
992
        function renew(item_id) {
991
        function renew(item_id) {
Lines 1024-1031 $(document).ready(function () { Link Here
1024
                params.date_due = dueDate;
1023
                params.date_due = dueDate;
1025
            }
1024
            }
1026
1025
1027
1026
            $(this)
1028
            $(this).parent().parent().replaceWith("<img id='renew_" + item_id+ "' src='" + interface + "/" + theme + "/img/spinner-small.gif' />");
1027
                .parent()
1028
                .parent()
1029
                .replaceWith(
1030
                    "<img id='renew_" +
1031
                        item_id +
1032
                        "' src='" +
1033
                        interface +
1034
                        "/" +
1035
                        theme +
1036
                        "/img/spinner-small.gif' />"
1037
                );
1029
1038
1030
            const client = APIClient.circulation;
1039
            const client = APIClient.circulation;
1031
            return client.checkouts.renew(params).then(
1040
            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