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

(-)a/C4/Circulation.pm (+8 lines)
Lines 2905-2910 sub CanBookBeRenewed { Link Here
2905
        }
2905
        }
2906
    }
2906
    }
2907
2907
2908
    if ( C4::Context->preference('OPACFineNoRenewalsBlockAutoRenew') ) {
2909
        my $fine_no_renewals = C4::Context->preference("OPACFineNoRenewals");
2910
        my ( $amountoutstanding ) = C4::Members::GetMemberAccountRecords($borrower->{borrowernumber});
2911
        if ( $amountoutstanding and $amountoutstanding > $fine_no_renewals ) {
2912
            return ( 0, "auto_too_much_oweing" );
2913
        }
2914
    }
2915
2908
    if ( defined $issuingrule->{norenewalbefore}
2916
    if ( defined $issuingrule->{norenewalbefore}
2909
        and $issuingrule->{norenewalbefore} ne "" )
2917
        and $issuingrule->{norenewalbefore} ne "" )
2910
    {
2918
    {
(-)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 => 84;
33
use Test::More tests => 85;
34
34
35
BEGIN {
35
BEGIN {
36
    use_ok('C4::Circulation');
36
    use_ok('C4::Circulation');
Lines 573-578 C4::Context->dbh->do("DELETE FROM accountlines"); Link Here
573
        is( $error,     'auto_renew', 'Cannot renew, renew is automatic' );
573
        is( $error,     'auto_renew', 'Cannot renew, renew is automatic' );
574
    };
574
    };
575
575
576
    subtest "auto_too_much_oweing | OPACFineNoRenewalsBlockAutoRenew" => sub {
577
        plan tests => 6;
578
        my $item_to_auto_renew = $builder->build({
579
            source => 'Item',
580
            value => {
581
                biblionumber => $biblionumber,
582
                homebranch       => $branch,
583
                holdingbranch    => $branch,
584
            }
585
        });
586
587
        my $ten_days_before = dt_from_string->add( days => -10 );
588
        my $ten_days_ahead = dt_from_string->add( days => 10 );
589
        AddIssue( $renewing_borrower, $item_to_auto_renew->{barcode}, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } );
590
591
        $dbh->do('UPDATE issuingrules SET norenewalbefore = 10, no_auto_renewal_after = 11');
592
        C4::Context->set_preference('OPACFineNoRenewalsBlockAutoRenew','1');
593
        C4::Context->set_preference('OPACFineNoRenewals','10');
594
        my $fines_amount = 5;
595
        C4::Accounts::manualinvoice( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber}, "Some fines", 'F', $fines_amount );
596
        ( $renewokay, $error ) =
597
          CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} );
598
        is( $renewokay, 0, 'Do not renew, renewal is automatic' );
599
        is( $error, 'auto_renew', 'Can auto renew, OPACFineNoRenewals=10, patron has 5' );
600
601
        C4::Accounts::manualinvoice( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber}, "Some fines", 'F', $fines_amount );
602
        ( $renewokay, $error ) =
603
          CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} );
604
        is( $renewokay, 0, 'Do not renew, renewal is automatic' );
605
        is( $error, 'auto_renew', 'Can auto renew, OPACFineNoRenewals=10, patron has 10' );
606
607
        C4::Accounts::manualinvoice( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber}, "Some fines", 'F', $fines_amount );
608
        ( $renewokay, $error ) =
609
          CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} );
610
        is( $renewokay, 0, 'Do not renew, renewal is automatic' );
611
        is( $error, 'auto_too_much_oweing', 'Cannot auto renew, OPACFineNoRenewals=10, patron has 15' );
612
613
        $dbh->do('DELETE FROM accountlines WHERE borrowernumber=?', undef, $renewing_borrowernumber);
614
    };
615
576
    subtest "GetLatestAutoRenewDate" => sub {
616
    subtest "GetLatestAutoRenewDate" => sub {
577
        plan tests => 3;
617
        plan tests => 3;
578
        my $item_to_auto_renew = $builder->build(
618
        my $item_to_auto_renew = $builder->build(
579
- 

Return to bug 15582