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 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