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

(-)a/C4/Circulation.pm (+4 lines)
Lines 3239-3247 sub CanBookBeRenewed { Link Here
3239
                && $issuing_rule->{unseen_renewals_allowed} == ( $issue->unseen_renewals + 1 ) ) ? 1 : 0;
3239
                && $issuing_rule->{unseen_renewals_allowed} == ( $issue->unseen_renewals + 1 ) ) ? 1 : 0;
3240
3240
3241
        my $overduesblockrenewing    = C4::Context->preference('OverduesBlockRenewing');
3241
        my $overduesblockrenewing    = C4::Context->preference('OverduesBlockRenewing');
3242
        my $finesblockrenewing       = C4::Context->preference("FineNoRenewals");
3242
        my $restrictionblockrenewing = C4::Context->preference('RestrictionBlockRenewing');
3243
        my $restrictionblockrenewing = C4::Context->preference('RestrictionBlockRenewing');
3243
        my $restricted               = $patron->is_debarred;
3244
        my $restricted               = $patron->is_debarred;
3244
        my $hasoverdues              = $patron->has_overdues;
3245
        my $hasoverdues              = $patron->has_overdues;
3246
        my $balance                  = $patron->account->balance;
3245
3247
3246
        if ( $restricted and $restrictionblockrenewing ) {
3248
        if ( $restricted and $restrictionblockrenewing ) {
3247
            return ( 0, 'restriction' );
3249
            return ( 0, 'restriction' );
Lines 3249-3254 sub CanBookBeRenewed { Link Here
3249
            || ( $issue->is_overdue and $overduesblockrenewing eq 'blockitem' ) )
3251
            || ( $issue->is_overdue and $overduesblockrenewing eq 'blockitem' ) )
3250
        {
3252
        {
3251
            return ( 0, 'overdue' );
3253
            return ( 0, 'overdue' );
3254
        } elsif ( $finesblockrenewing && $balance > $finesblockrenewing ) {
3255
            return ( 0, 'too_much_oweing');
3252
        }
3256
        }
3253
3257
3254
    }
3258
    }
(-)a/circ/renew.pl (-8 / +7 lines)
Lines 68-76 if ( $op eq 'cud-renew' && $barcode ) { Link Here
68
            $patron = $checkout->patron;
68
            $patron = $checkout->patron;
69
            my $borrowernumber = $patron->borrowernumber;
69
            my $borrowernumber = $patron->borrowernumber;
70
70
71
            $balance = $patron->account->balance;
72
            my $amountlimit = C4::Context->preference("FineNoRenewals");
73
74
            if ( ( $patron->is_debarred || q{} ) lt dt_from_string()->ymd() ) {
71
            if ( ( $patron->is_debarred || q{} ) lt dt_from_string()->ymd() ) {
75
                my $confirmations;
72
                my $confirmations;
76
                my $can_renew;
73
                my $can_renew;
Lines 98-109 if ( $op eq 'cud-renew' && $barcode ) { Link Here
98
                    );
95
                    );
99
                }
96
                }
100
97
101
                if ( $balance > $amountlimit ) {
98
                if ( $error && ($error eq 'too_much_oweing' or $error eq 'auto_too_much_oweing') ) {
102
                    $error     = "too_much_debt";
103
                    $can_renew = 0;
104
                    if ($override_debt) {
99
                    if ($override_debt) {
105
                        $can_renew = 1;
100
                        $can_renew = 1;
106
                        $error     = undef;
101
                        $error = undef;
102
                    }
103
                    else {
104
                        $balance = $patron->account->balance;
105
                        $template->param( balance => $balance );
106
                        $can_renew = 0;
107
                    }
107
                    }
108
                }
108
                }
109
109
Lines 142-148 if ( $op eq 'cud-renew' && $barcode ) { Link Here
142
        error               => $error,
142
        error               => $error,
143
        soonestrenewdate    => $soonest_renew_date,
143
        soonestrenewdate    => $soonest_renew_date,
144
        latestautorenewdate => $latest_auto_renew_date,
144
        latestautorenewdate => $latest_auto_renew_date,
145
        balance             => $balance,
146
    );
145
    );
147
}
146
}
148
147
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/renew.tt (-1 / +1 lines)
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_debt" %]
142
            [% ELSIF error == "too_much_oweing" %]
143
143
144
                <li>The patron has a debt of [% balance | $Price %].</li>
144
                <li>The patron has a debt of [% balance | $Price %].</li>
145
                <form method="post" action="/cgi-bin/koha/circ/renew.pl">
145
                <form method="post" action="/cgi-bin/koha/circ/renew.pl">
(-)a/t/db_dependent/Circulation.t (-2 / +10 lines)
Lines 498-504 subtest "GetIssuingCharges tests" => sub { Link Here
498
498
499
my ( $reused_itemnumber_1, $reused_itemnumber_2 );
499
my ( $reused_itemnumber_1, $reused_itemnumber_2 );
500
subtest "CanBookBeRenewed tests" => sub {
500
subtest "CanBookBeRenewed tests" => sub {
501
    plan tests => 114;
501
    plan tests => 116;
502
502
503
    C4::Context->set_preference( 'ItemsDeniedRenewal', '' );
503
    C4::Context->set_preference( 'ItemsDeniedRenewal', '' );
504
504
Lines 1824-1829 subtest "CanBookBeRenewed tests" => sub { Link Here
1824
        "Account line description must not contain 'Lost Items ', but be title, barcode, itemcallnumber"
1824
        "Account line description must not contain 'Lost Items ', but be title, barcode, itemcallnumber"
1825
    );
1825
    );
1826
1826
1827
    t::lib::Mocks::mock_preference('FineNoRenewals', 0);
1828
1827
    # Recalls
1829
    # Recalls
1828
    t::lib::Mocks::mock_preference( 'UseRecalls', 1 );
1830
    t::lib::Mocks::mock_preference( 'UseRecalls', 1 );
1829
    Koha::CirculationRules->set_rules(
1831
    Koha::CirculationRules->set_rules(
Lines 1900-1905 subtest "CanBookBeRenewed tests" => sub { Link Here
1900
    ( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrower_obj, $recall_issue );
1902
    ( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrower_obj, $recall_issue );
1901
    is( $renewokay, 1, 'Can renew item if biblio-level recall has already been allocated an item' );
1903
    is( $renewokay, 1, 'Can renew item if biblio-level recall has already been allocated an item' );
1902
    $recall->set_cancelled;
1904
    $recall->set_cancelled;
1905
1906
    # Too much debt
1907
    t::lib::Mocks::mock_preference('FineNoRenewals', 1);
1908
    ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrower_obj, $issue_1);
1909
    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)');
1911
    C4::Context->dbh->do("DELETE FROM accountlines");
1903
};
1912
};
1904
1913
1905
subtest "CanBookBeRenewed | bookings" => sub {
1914
subtest "CanBookBeRenewed | bookings" => sub {
1906
- 

Return to bug 23415