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

(-)a/C4/Circulation.pm (+4 lines)
Lines 3267-3275 sub CanBookBeRenewed { Link Here
3267
                && $issuing_rule->{unseen_renewals_allowed} == ( $issue->unseen_renewals + 1 ) ) ? 1 : 0;
3267
                && $issuing_rule->{unseen_renewals_allowed} == ( $issue->unseen_renewals + 1 ) ) ? 1 : 0;
3268
3268
3269
        my $overduesblockrenewing    = C4::Context->preference('OverduesBlockRenewing');
3269
        my $overduesblockrenewing    = C4::Context->preference('OverduesBlockRenewing');
3270
        my $finesblockrenewing       = C4::Context->preference("FineNoRenewals");
3270
        my $restrictionblockrenewing = C4::Context->preference('RestrictionBlockRenewing');
3271
        my $restrictionblockrenewing = C4::Context->preference('RestrictionBlockRenewing');
3271
        my $restricted               = $patron->is_debarred;
3272
        my $restricted               = $patron->is_debarred;
3272
        my $hasoverdues              = $patron->has_overdues;
3273
        my $hasoverdues              = $patron->has_overdues;
3274
        my $balance                  = $patron->account->balance;
3273
3275
3274
        if ( $restricted and $restrictionblockrenewing ) {
3276
        if ( $restricted and $restrictionblockrenewing ) {
3275
            return ( 0, 'restriction' );
3277
            return ( 0, 'restriction' );
Lines 3277-3282 sub CanBookBeRenewed { Link Here
3277
            || ( $issue->is_overdue and $overduesblockrenewing eq 'blockitem' ) )
3279
            || ( $issue->is_overdue and $overduesblockrenewing eq 'blockitem' ) )
3278
        {
3280
        {
3279
            return ( 0, 'overdue' );
3281
            return ( 0, 'overdue' );
3282
        } elsif ( $finesblockrenewing && $balance > $finesblockrenewing ) {
3283
            return ( 0, 'too_much_oweing');
3280
        }
3284
        }
3281
3285
3282
    }
3286
    }
(-)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 497-503 subtest "GetIssuingCharges tests" => sub { Link Here
497
497
498
my ( $reused_itemnumber_1, $reused_itemnumber_2 );
498
my ( $reused_itemnumber_1, $reused_itemnumber_2 );
499
subtest "CanBookBeRenewed tests" => sub {
499
subtest "CanBookBeRenewed tests" => sub {
500
    plan tests => 115;
500
    plan tests => 117;
501
501
502
    C4::Context->set_preference( 'ItemsDeniedRenewal', '' );
502
    C4::Context->set_preference( 'ItemsDeniedRenewal', '' );
503
503
Lines 1893-1898 subtest "CanBookBeRenewed tests" => sub { Link Here
1893
        "Account line description must not contain 'Lost Items ', but be title, barcode, itemcallnumber"
1893
        "Account line description must not contain 'Lost Items ', but be title, barcode, itemcallnumber"
1894
    );
1894
    );
1895
1895
1896
    t::lib::Mocks::mock_preference('FineNoRenewals', 0);
1897
1896
    # Recalls
1898
    # Recalls
1897
    t::lib::Mocks::mock_preference( 'UseRecalls', 1 );
1899
    t::lib::Mocks::mock_preference( 'UseRecalls', 1 );
1898
    Koha::CirculationRules->set_rules(
1900
    Koha::CirculationRules->set_rules(
Lines 1969-1974 subtest "CanBookBeRenewed tests" => sub { Link Here
1969
    ( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrower_obj, $recall_issue );
1971
    ( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrower_obj, $recall_issue );
1970
    is( $renewokay, 1, 'Can renew item if biblio-level recall has already been allocated an item' );
1972
    is( $renewokay, 1, 'Can renew item if biblio-level recall has already been allocated an item' );
1971
    $recall->set_cancelled;
1973
    $recall->set_cancelled;
1974
1975
    # Too much debt
1976
    t::lib::Mocks::mock_preference('FineNoRenewals', 1);
1977
    ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrower_obj, $issue_1);
1978
    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)');
1980
    C4::Context->dbh->do("DELETE FROM accountlines");
1972
};
1981
};
1973
1982
1974
subtest "CanBookBeRenewed | bookings" => sub {
1983
subtest "CanBookBeRenewed | bookings" => sub {
1975
- 

Return to bug 23415