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

(-)a/C4/Circulation.pm (+8 lines)
Lines 2875-2880 sub CanBookBeRenewed { Link Here
2875
                return ( 0, "auto_too_late" );
2875
                return ( 0, "auto_too_late" );
2876
            }
2876
            }
2877
        }
2877
        }
2878
2879
        if ( C4::Context->preference('OPACFineNoRenewalsBlockAutoRenew') ) {
2880
            my $fine_no_renewals = C4::Context->preference("OPACFineNoRenewals");
2881
            my ( $amountoutstanding ) = C4::Members::GetMemberAccountRecords($borrower->{borrowernumber});
2882
            if ( $amountoutstanding and $amountoutstanding > $fine_no_renewals ) {
2883
                return ( 0, "auto_too_much_oweing" );
2884
            }
2885
        }
2878
    }
2886
    }
2879
2887
2880
    if ( defined $issuingrule->{norenewalbefore}
2888
    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 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 90;
20
use Test::More tests => 91;
21
21
22
BEGIN {
22
BEGIN {
23
    require_ok('C4::Circulation');
23
    require_ok('C4::Circulation');
Lines 611-616 C4::Context->dbh->do("DELETE FROM accountlines"); Link Here
611
        is( $error, 'auto_renew', 'Cannot renew, renew is automatic' );
611
        is( $error, 'auto_renew', 'Cannot renew, renew is automatic' );
612
    };
612
    };
613
613
614
    subtest "auto_too_much_oweing | OPACFineNoRenewalsBlockAutoRenew" => sub {
615
        plan tests => 6;
616
        my $item_to_auto_renew = $builder->build({
617
            source => 'Item',
618
            value => {
619
                biblionumber => $biblionumber,
620
                homebranch       => $branch,
621
                holdingbranch    => $branch,
622
            }
623
        });
624
625
        my $ten_days_before = dt_from_string->add( days => -10 );
626
        my $ten_days_ahead = dt_from_string->add( days => 10 );
627
        AddIssue( $renewing_borrower, $item_to_auto_renew->{barcode}, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } );
628
629
        $dbh->do('UPDATE issuingrules SET norenewalbefore = 10, no_auto_renewal_after = 11');
630
        C4::Context->set_preference('OPACFineNoRenewalsBlockAutoRenew','1');
631
        C4::Context->set_preference('OPACFineNoRenewals','10');
632
        my $fines_amount = 5;
633
        C4::Accounts::manualinvoice( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber}, "Some fines", 'F', $fines_amount );
634
        ( $renewokay, $error ) =
635
          CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} );
636
        is( $renewokay, 0, 'Do not renew, renewal is automatic' );
637
        is( $error, 'auto_renew', 'Can auto renew, OPACFineNoRenewals=10, patron has 5' );
638
639
        C4::Accounts::manualinvoice( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber}, "Some fines", 'F', $fines_amount );
640
        ( $renewokay, $error ) =
641
          CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} );
642
        is( $renewokay, 0, 'Do not renew, renewal is automatic' );
643
        is( $error, 'auto_renew', 'Can auto renew, OPACFineNoRenewals=10, patron has 10' );
644
645
        C4::Accounts::manualinvoice( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber}, "Some fines", 'F', $fines_amount );
646
        ( $renewokay, $error ) =
647
          CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} );
648
        is( $renewokay, 0, 'Do not renew, renewal is automatic' );
649
        is( $error, 'auto_too_much_oweing', 'Cannot auto renew, OPACFineNoRenewals=10, patron has 15' );
650
651
        $dbh->do('DELETE FROM accountlines WHERE borrowernumber=?', undef, $renewing_borrowernumber);
652
    };
653
614
    subtest "GetLatestAutoRenewDate" => sub {
654
    subtest "GetLatestAutoRenewDate" => sub {
615
        plan tests => 5;
655
        plan tests => 5;
616
        my $item_to_auto_renew = $builder->build(
656
        my $item_to_auto_renew = $builder->build(
617
- 

Return to bug 15582