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

(-)a/C4/Circulation.pm (-3 / +7 lines)
Lines 3048-3062 sub CanBookBeRenewed { Link Here
3048
        $final_unseen_renewal = ( C4::Context->preference('UnseenRenewals')
3048
        $final_unseen_renewal = ( C4::Context->preference('UnseenRenewals')
3049
                && $issuing_rule->{unseen_renewals_allowed} == ( $issue->unseen_renewals + 1 ) ) ? 1 : 0;
3049
                && $issuing_rule->{unseen_renewals_allowed} == ( $issue->unseen_renewals + 1 ) ) ? 1 : 0;
3050
3050
3051
        my $overduesblockrenewing = C4::Context->preference('OverduesBlockRenewing');
3051
        my $overduesblockrenewing    = C4::Context->preference('OverduesBlockRenewing');
3052
        my $finesblockrenewing       = C4::Context->preference("FineNoRenewals");
3052
        my $restrictionblockrenewing = C4::Context->preference('RestrictionBlockRenewing');
3053
        my $restrictionblockrenewing = C4::Context->preference('RestrictionBlockRenewing');
3053
        my $restricted  = $patron->is_debarred;
3054
        my $restricted               = $patron->is_debarred;
3054
        my $hasoverdues = $patron->has_overdues;
3055
        my $hasoverdues              = $patron->has_overdues;
3056
        my $balance                  = $patron->account->balance;
3055
3057
3056
        if ( $restricted and $restrictionblockrenewing ) {
3058
        if ( $restricted and $restrictionblockrenewing ) {
3057
            return ( 0, 'restriction');
3059
            return ( 0, 'restriction');
3058
        } elsif ( ($hasoverdues and $overduesblockrenewing eq 'block') || ($issue->is_overdue and $overduesblockrenewing eq 'blockitem') ) {
3060
        } elsif ( ($hasoverdues and $overduesblockrenewing eq 'block') || ($issue->is_overdue and $overduesblockrenewing eq 'blockitem') ) {
3059
            return ( 0, 'overdue');
3061
            return ( 0, 'overdue');
3062
        } elsif ( $finesblockrenewing && $balance > $finesblockrenewing ) {
3063
            return ( 0, 'too_much_oweing');
3060
        }
3064
        }
3061
3065
3062
    }
3066
    }
(-)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 96-107 if ($op eq 'cud-renew' && $barcode) { Link Here
96
                    );
93
                    );
97
                }
94
                }
98
95
99
                if ( $balance > $amountlimit ) {
96
                if ( $error && ($error eq 'too_much_oweing' or $error eq 'auto_too_much_oweing') ) {
100
                    $error     = "too_much_debt";
101
                    $can_renew = 0;
102
                    if ($override_debt) {
97
                    if ($override_debt) {
103
                        $can_renew = 1;
98
                        $can_renew = 1;
104
                        $error     = undef;
99
                        $error = undef;
100
                    }
101
                    else {
102
                        $balance = $patron->account->balance;
103
                        $template->param( balance => $balance );
104
                        $can_renew = 0;
105
                    }
105
                    }
106
                }
106
                }
107
107
Lines 143-149 if ($op eq 'cud-renew' && $barcode) { Link Here
143
        error               => $error,
143
        error               => $error,
144
        soonestrenewdate    => $soonest_renew_date,
144
        soonestrenewdate    => $soonest_renew_date,
145
        latestautorenewdate => $latest_auto_renew_date,
145
        latestautorenewdate => $latest_auto_renew_date,
146
        balance             => $balance,
147
    );
146
    );
148
}
147
}
149
148
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/renew.tt (-1 / +1 lines)
Lines 187-193 Link Here
187
                            [% ELSIF error == 'recalled' %]
187
                            [% ELSIF error == 'recalled' %]
188
                                <p>This item has been recalled.</p>
188
                                <p>This item has been recalled.</p>
189
189
190
                            [% ELSIF error == "too_much_debt" %]
190
                            [% ELSIF error == "too_much_oweing" %]
191
191
192
                                <li>The patron has a debt of [% balance | $Price %].</li>
192
                                <li>The patron has a debt of [% balance | $Price %].</li>
193
                                <form method="post" action="/cgi-bin/koha/circ/renew.pl">
193
                                <form method="post" action="/cgi-bin/koha/circ/renew.pl">
(-)a/t/db_dependent/Circulation.t (-2 / +10 lines)
Lines 475-481 subtest "GetIssuingCharges tests" => sub { Link Here
475
475
476
my ( $reused_itemnumber_1, $reused_itemnumber_2 );
476
my ( $reused_itemnumber_1, $reused_itemnumber_2 );
477
subtest "CanBookBeRenewed tests" => sub {
477
subtest "CanBookBeRenewed tests" => sub {
478
    plan tests => 114;
478
    plan tests => 116;
479
479
480
    C4::Context->set_preference('ItemsDeniedRenewal','');
480
    C4::Context->set_preference('ItemsDeniedRenewal','');
481
    # Generate test biblio
481
    # Generate test biblio
Lines 1727-1732 subtest "CanBookBeRenewed tests" => sub { Link Here
1727
        "Account line description must not contain 'Lost Items ', but be title, barcode, itemcallnumber"
1727
        "Account line description must not contain 'Lost Items ', but be title, barcode, itemcallnumber"
1728
    );
1728
    );
1729
1729
1730
    t::lib::Mocks::mock_preference('FineNoRenewals', 0);
1731
1730
    # Recalls
1732
    # Recalls
1731
    t::lib::Mocks::mock_preference('UseRecalls', 1);
1733
    t::lib::Mocks::mock_preference('UseRecalls', 1);
1732
    Koha::CirculationRules->set_rules({
1734
    Koha::CirculationRules->set_rules({
Lines 1793-1798 subtest "CanBookBeRenewed tests" => sub { Link Here
1793
    ( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrower_obj, $recall_issue );
1795
    ( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrower_obj, $recall_issue );
1794
    is( $renewokay, 1, 'Can renew item if biblio-level recall has already been allocated an item' );
1796
    is( $renewokay, 1, 'Can renew item if biblio-level recall has already been allocated an item' );
1795
    $recall->set_cancelled;
1797
    $recall->set_cancelled;
1798
1799
    # Too much debt
1800
    t::lib::Mocks::mock_preference('FineNoRenewals', 1);
1801
    ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrower_obj, $issue_1);
1802
    is( $renewokay, 0, 'Cannot renew, too much debt and FineNoRenewals=1' );
1803
    is( $error, 'too_much_oweing', 'Cannot renew, debt not allowed (returned code is too_much_oweing)');
1804
    C4::Context->dbh->do("DELETE FROM accountlines");
1796
};
1805
};
1797
1806
1798
subtest "CanBookBeRenewed | bookings" => sub {
1807
subtest "CanBookBeRenewed | bookings" => sub {
1799
- 

Return to bug 23415