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

(-)a/C4/Circulation.pm (+8 lines)
Lines 2842-2847 sub CanBookBeRenewed { Link Here
2842
        }
2842
        }
2843
    }
2843
    }
2844
2844
2845
    if ( C4::Context->preference('MaxOutstandingBlockAutoRenew') ) {
2846
        my $maxoutstanding = C4::Context->preference("maxoutstanding");
2847
        my ( $amountoutstanding ) = C4::Members::GetMemberAccountRecords($borrower->{borrowernumber});
2848
        if ( $amountoutstanding and $amountoutstanding > $maxoutstanding ) {
2849
            return ( 0, "auto_too_much_oweing" );
2850
        }
2851
    }
2852
2845
    if ( defined $issuingrule->{norenewalbefore}
2853
    if ( defined $issuingrule->{norenewalbefore}
2846
        and $issuingrule->{norenewalbefore} ne "" )
2854
        and $issuingrule->{norenewalbefore} ne "" )
2847
    {
2855
    {
(-)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 => 84;
32
use Test::More tests => 85;
33
33
34
BEGIN {
34
BEGIN {
35
    use_ok('C4::Circulation');
35
    use_ok('C4::Circulation');
Lines 555-560 C4::Context->dbh->do("DELETE FROM accountlines"); Link Here
555
        is( $error,     'auto_renew', 'Cannot renew, renew is automatic' );
555
        is( $error,     'auto_renew', 'Cannot renew, renew is automatic' );
556
    };
556
    };
557
557
558
    subtest "auto_too_much_oweing | MaxOutstandingBlockAutoRenew" => sub {
559
        plan tests => 6;
560
        my $item_to_auto_renew = $builder->build({
561
            source => 'Item',
562
            value => {
563
                biblionumber => $biblionumber,
564
                homebranch       => $branch,
565
                holdingbranch    => $branch,
566
            }
567
        });
568
569
        my $ten_days_before = dt_from_string->add( days => -10 );
570
        my $ten_days_ahead = dt_from_string->add( days => 10 );
571
        AddIssue( $renewing_borrower, $item_to_auto_renew->{barcode}, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } );
572
573
        $dbh->do('UPDATE issuingrules SET norenewalbefore = 10, no_auto_renewal_after = 11');
574
        C4::Context->set_preference('MaxOutstandingBlockAutoRenew','1');
575
        C4::Context->set_preference('maxoutstanding','10');
576
        my $fines_amount = 5;
577
        C4::Accounts::manualinvoice( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber}, "Some fines", 'F', $fines_amount );
578
        ( $renewokay, $error ) =
579
          CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} );
580
        is( $renewokay, 0, 'Do not renew, renewal is automatic' );
581
        is( $error, 'auto_renew', 'Can auto renew, maxoutstanding=10, patron has 5' );
582
583
        C4::Accounts::manualinvoice( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber}, "Some fines", 'F', $fines_amount );
584
        ( $renewokay, $error ) =
585
          CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} );
586
        is( $renewokay, 0, 'Do not renew, renewal is automatic' );
587
        is( $error, 'auto_renew', 'Can auto renew, maxoutstanding=10, patron has 10' );
588
589
        C4::Accounts::manualinvoice( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber}, "Some fines", 'F', $fines_amount );
590
        ( $renewokay, $error ) =
591
          CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} );
592
        is( $renewokay, 0, 'Do not renew, renewal is automatic' );
593
        is( $error, 'auto_too_much_oweing', 'Cannot auto renew, maxoutstanding=10, patron has 15' );
594
595
        $dbh->do('DELETE FROM accountlines WHERE borrowernumber=?', undef, $renewing_borrowernumber);
596
    };
597
558
    subtest "GetLatestAutoRenewDate" => sub {
598
    subtest "GetLatestAutoRenewDate" => sub {
559
        plan tests => 3;
599
        plan tests => 3;
560
        my $item_to_auto_renew = $builder->build(
600
        my $item_to_auto_renew = $builder->build(
561
- 

Return to bug 15582