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

(-)a/C4/Circulation.pm (+4 lines)
Lines 3174-3182 sub CanBookBeRenewed { Link Here
3174
                && $issuing_rule->{unseen_renewals_allowed} == ( $issue->unseen_renewals + 1 ) ) ? 1 : 0;
3174
                && $issuing_rule->{unseen_renewals_allowed} == ( $issue->unseen_renewals + 1 ) ) ? 1 : 0;
3175
3175
3176
        my $overduesblockrenewing    = C4::Context->preference('OverduesBlockRenewing');
3176
        my $overduesblockrenewing    = C4::Context->preference('OverduesBlockRenewing');
3177
        my $finesblockrenewing       = C4::Context->preference("FineNoRenewals");
3177
        my $restrictionblockrenewing = C4::Context->preference('RestrictionBlockRenewing');
3178
        my $restrictionblockrenewing = C4::Context->preference('RestrictionBlockRenewing');
3178
        my $restricted               = $patron->is_debarred;
3179
        my $restricted               = $patron->is_debarred;
3179
        my $hasoverdues              = $patron->has_overdues;
3180
        my $hasoverdues              = $patron->has_overdues;
3181
        my $balance                  = $patron->account->balance;
3180
3182
3181
        if ( $restricted and $restrictionblockrenewing ) {
3183
        if ( $restricted and $restrictionblockrenewing ) {
3182
            return ( 0, 'restriction' );
3184
            return ( 0, 'restriction' );
Lines 3184-3189 sub CanBookBeRenewed { Link Here
3184
            || ( $issue->is_overdue and $overduesblockrenewing eq 'blockitem' ) )
3186
            || ( $issue->is_overdue and $overduesblockrenewing eq 'blockitem' ) )
3185
        {
3187
        {
3186
            return ( 0, 'overdue' );
3188
            return ( 0, 'overdue' );
3189
        } elsif ( $finesblockrenewing && $balance > $finesblockrenewing ) {
3190
            return ( 0, 'too_much_oweing');
3187
        }
3191
        }
3188
3192
3189
    }
3193
    }
(-)a/circ/renew.pl (-8 / +7 lines)
Lines 67-75 if ( $op eq 'cud-renew' && $barcode ) { Link Here
67
67
68
            $patron = $checkout->patron;
68
            $patron = $checkout->patron;
69
69
70
            $balance = $patron->account->balance;
71
            my $amountlimit = C4::Context->preference("FineNoRenewals");
72
73
            if ( ( $patron->is_debarred || q{} ) lt dt_from_string()->ymd() ) {
70
            if ( ( $patron->is_debarred || q{} ) lt dt_from_string()->ymd() ) {
74
                my $can_renew;
71
                my $can_renew;
75
                my $info;
72
                my $info;
Lines 94-105 if ( $op eq 'cud-renew' && $barcode ) { Link Here
94
                    );
91
                    );
95
                }
92
                }
96
93
97
                if ( $balance > $amountlimit ) {
94
                if ( $error && ($error eq 'too_much_oweing' or $error eq 'auto_too_much_oweing') ) {
98
                    $error     = "too_much_debt";
99
                    $can_renew = 0;
100
                    if ($override_debt) {
95
                    if ($override_debt) {
101
                        $can_renew = 1;
96
                        $can_renew = 1;
102
                        $error     = undef;
97
                        $error = undef;
98
                    }
99
                    else {
100
                        $balance = $patron->account->balance;
101
                        $template->param( balance => $balance );
102
                        $can_renew = 0;
103
                    }
103
                    }
104
                }
104
                }
105
105
Lines 137-143 if ( $op eq 'cud-renew' && $barcode ) { Link Here
137
        error               => $error,
137
        error               => $error,
138
        soonestrenewdate    => $soonest_renew_date,
138
        soonestrenewdate    => $soonest_renew_date,
139
        latestautorenewdate => $latest_auto_renew_date,
139
        latestautorenewdate => $latest_auto_renew_date,
140
        balance             => $balance,
141
    );
140
    );
142
}
141
}
143
142
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/renew.tt (-1 / +1 lines)
Lines 138-144 Link Here
138
                        <button type="submit" class="btn btn-default approve"><i class="fa fa-check"></i> Override limit and renew</button>
138
                        <button type="submit" class="btn btn-default approve"><i class="fa fa-check"></i> Override limit and renew</button>
139
                    </form>
139
                    </form>
140
                [% END %]
140
                [% END %]
141
            [% ELSIF error == "too_much_debt" %]
141
            [% ELSIF error == "too_much_oweing" %]
142
142
143
                <li>The patron has a debt of [% balance | $Price %].</li>
143
                <li>The patron has a debt of [% balance | $Price %].</li>
144
                <form method="post" action="/cgi-bin/koha/circ/renew.pl">
144
                <form method="post" action="/cgi-bin/koha/circ/renew.pl">
(-)a/t/db_dependent/Circulation.t (-2 / +10 lines)
Lines 495-501 subtest "GetIssuingCharges tests" => sub { Link Here
495
495
496
my ( $reused_itemnumber_1, $reused_itemnumber_2 );
496
my ( $reused_itemnumber_1, $reused_itemnumber_2 );
497
subtest "CanBookBeRenewed tests" => sub {
497
subtest "CanBookBeRenewed tests" => sub {
498
    plan tests => 114;
498
    plan tests => 116;
499
499
500
    C4::Context->set_preference( 'ItemsDeniedRenewal', '' );
500
    C4::Context->set_preference( 'ItemsDeniedRenewal', '' );
501
501
Lines 1821-1826 subtest "CanBookBeRenewed tests" => sub { Link Here
1821
        "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"
1822
    );
1822
    );
1823
1823
1824
    t::lib::Mocks::mock_preference('FineNoRenewals', 0);
1825
1824
    # Recalls
1826
    # Recalls
1825
    t::lib::Mocks::mock_preference( 'UseRecalls', 1 );
1827
    t::lib::Mocks::mock_preference( 'UseRecalls', 1 );
1826
    Koha::CirculationRules->set_rules(
1828
    Koha::CirculationRules->set_rules(
Lines 1897-1902 subtest "CanBookBeRenewed tests" => sub { Link Here
1897
    ( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrower_obj, $recall_issue );
1899
    ( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrower_obj, $recall_issue );
1898
    is( $renewokay, 1, 'Can renew item if biblio-level recall has already been allocated an item' );
1900
    is( $renewokay, 1, 'Can renew item if biblio-level recall has already been allocated an item' );
1899
    $recall->set_cancelled;
1901
    $recall->set_cancelled;
1902
1903
    # Too much debt
1904
    t::lib::Mocks::mock_preference('FineNoRenewals', 1);
1905
    ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrower_obj, $issue_1);
1906
    is( $renewokay, 0, 'Cannot renew, too much debt and FineNoRenewals=1' );
1907
    is( $error, 'too_much_oweing', 'Cannot renew, debt not allowed (returned code is too_much_oweing)');
1908
    C4::Context->dbh->do("DELETE FROM accountlines");
1900
};
1909
};
1901
1910
1902
subtest "CanBookBeRenewed | bookings" => sub {
1911
subtest "CanBookBeRenewed | bookings" => sub {
1903
- 

Return to bug 23415