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

(-)a/C4/Circulation.pm (+8 lines)
Lines 2912-2917 sub CanBookBeRenewed { Link Here
2912
        }
2912
        }
2913
    }
2913
    }
2914
2914
2915
    if ( C4::Context->preference('OPACFineNoRenewalsBlockAutoRenew') ) {
2916
        my $fine_no_renewals = C4::Context->preference("OPACFineNoRenewals");
2917
        my ( $amountoutstanding ) = C4::Members::GetMemberAccountRecords($borrower->{borrowernumber});
2918
        if ( $amountoutstanding and $amountoutstanding > $fine_no_renewals ) {
2919
            return ( 0, "auto_too_much_oweing" );
2920
        }
2921
    }
2922
2915
    if ( defined $issuingrule->{norenewalbefore}
2923
    if ( defined $issuingrule->{norenewalbefore}
2916
        and $issuingrule->{norenewalbefore} ne "" )
2924
        and $issuingrule->{norenewalbefore} ne "" )
2917
    {
2925
    {
(-)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 30-36 use Koha::Database; Link Here
30
30
31
use t::lib::TestBuilder;
31
use t::lib::TestBuilder;
32
32
33
use Test::More tests => 85;
33
use Test::More tests => 86;
34
34
35
BEGIN {
35
BEGIN {
36
    use_ok('C4::Circulation');
36
    use_ok('C4::Circulation');
Lines 591-596 C4::Context->dbh->do("DELETE FROM accountlines"); Link Here
591
        is( $error, 'auto_renew', 'Cannot renew, renew is automatic' );
591
        is( $error, 'auto_renew', 'Cannot renew, renew is automatic' );
592
    };
592
    };
593
593
594
    subtest "auto_too_much_oweing | OPACFineNoRenewalsBlockAutoRenew" => sub {
595
        plan tests => 6;
596
        my $item_to_auto_renew = $builder->build({
597
            source => 'Item',
598
            value => {
599
                biblionumber => $biblionumber,
600
                homebranch       => $branch,
601
                holdingbranch    => $branch,
602
            }
603
        });
604
605
        my $ten_days_before = dt_from_string->add( days => -10 );
606
        my $ten_days_ahead = dt_from_string->add( days => 10 );
607
        AddIssue( $renewing_borrower, $item_to_auto_renew->{barcode}, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } );
608
609
        $dbh->do('UPDATE issuingrules SET norenewalbefore = 10, no_auto_renewal_after = 11');
610
        C4::Context->set_preference('OPACFineNoRenewalsBlockAutoRenew','1');
611
        C4::Context->set_preference('OPACFineNoRenewals','10');
612
        my $fines_amount = 5;
613
        C4::Accounts::manualinvoice( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber}, "Some fines", 'F', $fines_amount );
614
        ( $renewokay, $error ) =
615
          CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} );
616
        is( $renewokay, 0, 'Do not renew, renewal is automatic' );
617
        is( $error, 'auto_renew', 'Can auto renew, OPACFineNoRenewals=10, patron has 5' );
618
619
        C4::Accounts::manualinvoice( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber}, "Some fines", 'F', $fines_amount );
620
        ( $renewokay, $error ) =
621
          CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} );
622
        is( $renewokay, 0, 'Do not renew, renewal is automatic' );
623
        is( $error, 'auto_renew', 'Can auto renew, OPACFineNoRenewals=10, patron has 10' );
624
625
        C4::Accounts::manualinvoice( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber}, "Some fines", 'F', $fines_amount );
626
        ( $renewokay, $error ) =
627
          CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} );
628
        is( $renewokay, 0, 'Do not renew, renewal is automatic' );
629
        is( $error, 'auto_too_much_oweing', 'Cannot auto renew, OPACFineNoRenewals=10, patron has 15' );
630
631
        $dbh->do('DELETE FROM accountlines WHERE borrowernumber=?', undef, $renewing_borrowernumber);
632
    };
633
594
    subtest "GetLatestAutoRenewDate" => sub {
634
    subtest "GetLatestAutoRenewDate" => sub {
595
        plan tests => 5;
635
        plan tests => 5;
596
        my $item_to_auto_renew = $builder->build(
636
        my $item_to_auto_renew = $builder->build(
597
- 

Return to bug 15582