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

(-)a/C4/Circulation.pm (+8 lines)
Lines 2872-2877 sub CanBookBeRenewed { Link Here
2872
                return ( 0, "auto_too_late" );
2872
                return ( 0, "auto_too_late" );
2873
            }
2873
            }
2874
        }
2874
        }
2875
2876
        if ( C4::Context->preference('OPACFineNoRenewalsBlockAutoRenew') ) {
2877
            my $fine_no_renewals = C4::Context->preference("OPACFineNoRenewals");
2878
            my ( $amountoutstanding ) = C4::Members::GetMemberAccountRecords($borrower->{borrowernumber});
2879
            if ( $amountoutstanding and $amountoutstanding > $fine_no_renewals ) {
2880
                return ( 0, "auto_too_much_oweing" );
2881
            }
2882
        }
2875
    }
2883
    }
2876
2884
2877
    if ( defined $issuingrule->{norenewalbefore}
2885
    if ( defined $issuingrule->{norenewalbefore}
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/renew.tt (-1 / +1 lines)
Lines 89-95 Link Here
89
                                    </form>
89
                                    </form>
90
                                [% END %]
90
                                [% END %]
91
91
92
                            [% ELSIF error == "auto_renew" %]
92
                            [% ELSIF error == "auto_renew" or error == "auto_too_much_oweing" %]
93
93
94
                                <p>[% item.biblio.title %] [% item.biblioitem.subtitle %] ( [% item.barcode %] ) has been scheduled for automatic renewal. </p>
94
                                <p>[% item.biblio.title %] [% item.biblioitem.subtitle %] ( [% item.barcode %] ) has been scheduled for automatic renewal. </p>
95
95
(-)a/t/db_dependent/Circulation.t (-2 / +41 lines)
Lines 29-35 use Koha::Database; Link Here
29
29
30
use t::lib::TestBuilder;
30
use t::lib::TestBuilder;
31
31
32
use Test::More tests => 90;
32
use Test::More tests => 91;
33
33
34
BEGIN {
34
BEGIN {
35
    use_ok('C4::Circulation');
35
    use_ok('C4::Circulation');
Lines 609-614 C4::Context->dbh->do("DELETE FROM accountlines"); Link Here
609
        is( $error, 'auto_renew', 'Cannot renew, renew is automatic' );
609
        is( $error, 'auto_renew', 'Cannot renew, renew is automatic' );
610
    };
610
    };
611
611
612
    subtest "auto_too_much_oweing | OPACFineNoRenewalsBlockAutoRenew" => sub {
613
        plan tests => 6;
614
        my $item_to_auto_renew = $builder->build({
615
            source => 'Item',
616
            value => {
617
                biblionumber => $biblionumber,
618
                homebranch       => $branch,
619
                holdingbranch    => $branch,
620
            }
621
        });
622
623
        my $ten_days_before = dt_from_string->add( days => -10 );
624
        my $ten_days_ahead = dt_from_string->add( days => 10 );
625
        AddIssue( $renewing_borrower, $item_to_auto_renew->{barcode}, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } );
626
627
        $dbh->do('UPDATE issuingrules SET norenewalbefore = 10, no_auto_renewal_after = 11');
628
        C4::Context->set_preference('OPACFineNoRenewalsBlockAutoRenew','1');
629
        C4::Context->set_preference('OPACFineNoRenewals','10');
630
        my $fines_amount = 5;
631
        C4::Accounts::manualinvoice( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber}, "Some fines", 'F', $fines_amount );
632
        ( $renewokay, $error ) =
633
          CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} );
634
        is( $renewokay, 0, 'Do not renew, renewal is automatic' );
635
        is( $error, 'auto_renew', 'Can auto renew, OPACFineNoRenewals=10, patron has 5' );
636
637
        C4::Accounts::manualinvoice( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber}, "Some fines", 'F', $fines_amount );
638
        ( $renewokay, $error ) =
639
          CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} );
640
        is( $renewokay, 0, 'Do not renew, renewal is automatic' );
641
        is( $error, 'auto_renew', 'Can auto renew, OPACFineNoRenewals=10, patron has 10' );
642
643
        C4::Accounts::manualinvoice( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber}, "Some fines", 'F', $fines_amount );
644
        ( $renewokay, $error ) =
645
          CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} );
646
        is( $renewokay, 0, 'Do not renew, renewal is automatic' );
647
        is( $error, 'auto_too_much_oweing', 'Cannot auto renew, OPACFineNoRenewals=10, patron has 15' );
648
649
        $dbh->do('DELETE FROM accountlines WHERE borrowernumber=?', undef, $renewing_borrowernumber);
650
    };
651
612
    subtest "GetLatestAutoRenewDate" => sub {
652
    subtest "GetLatestAutoRenewDate" => sub {
613
        plan tests => 5;
653
        plan tests => 5;
614
        my $item_to_auto_renew = $builder->build(
654
        my $item_to_auto_renew = $builder->build(
615
- 

Return to bug 15582