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

(-)a/C4/Circulation.pm (+8 lines)
Lines 2742-2747 sub CanBookBeRenewed { Link Here
2742
                return ( 0, "auto_too_late" );
2742
                return ( 0, "auto_too_late" );
2743
            }
2743
            }
2744
        }
2744
        }
2745
2746
        if ( C4::Context->preference('OPACFineNoRenewalsBlockAutoRenew') ) {
2747
            my $fine_no_renewals = C4::Context->preference("OPACFineNoRenewals");
2748
            my ( $amountoutstanding ) = C4::Members::GetMemberAccountRecords($borrower->{borrowernumber});
2749
            if ( $amountoutstanding and $amountoutstanding > $fine_no_renewals ) {
2750
                return ( 0, "auto_too_much_oweing" );
2751
            }
2752
        }
2745
    }
2753
    }
2746
2754
2747
    if ( defined $issuing_rule->norenewalbefore
2755
    if ( defined $issuing_rule->norenewalbefore
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/renew.tt (-1 / +1 lines)
Lines 90-96 Link Here
90
                                    </form>
90
                                    </form>
91
                                [% END %]
91
                                [% END %]
92
92
93
                            [% ELSIF error == "auto_renew" %]
93
                            [% ELSIF error == "auto_renew" or error == "auto_too_much_oweing" %]
94
94
95
                                <p>[% item.biblio.title %] [% item.biblioitem.subtitle %] ( [% item.barcode %] ) has been scheduled for automatic renewal. </p>
95
                                <p>[% item.biblio.title %] [% item.biblioitem.subtitle %] ( [% item.barcode %] ) has been scheduled for automatic renewal. </p>
96
96
(-)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 => 92;
20
use Test::More tests => 93;
21
21
22
BEGIN {
22
BEGIN {
23
    require_ok('C4::Circulation');
23
    require_ok('C4::Circulation');
Lines 624-629 C4::Context->dbh->do("DELETE FROM accountlines"); Link Here
624
        is( $error, 'auto_renew', 'Cannot renew, renew is automatic' );
624
        is( $error, 'auto_renew', 'Cannot renew, renew is automatic' );
625
    };
625
    };
626
626
627
    subtest "auto_too_much_oweing | OPACFineNoRenewalsBlockAutoRenew" => sub {
628
        plan tests => 6;
629
        my $item_to_auto_renew = $builder->build({
630
            source => 'Item',
631
            value => {
632
                biblionumber => $biblionumber,
633
                homebranch       => $branch,
634
                holdingbranch    => $branch,
635
            }
636
        });
637
638
        my $ten_days_before = dt_from_string->add( days => -10 );
639
        my $ten_days_ahead = dt_from_string->add( days => 10 );
640
        AddIssue( $renewing_borrower, $item_to_auto_renew->{barcode}, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } );
641
642
        $dbh->do('UPDATE issuingrules SET norenewalbefore = 10, no_auto_renewal_after = 11');
643
        C4::Context->set_preference('OPACFineNoRenewalsBlockAutoRenew','1');
644
        C4::Context->set_preference('OPACFineNoRenewals','10');
645
        my $fines_amount = 5;
646
        C4::Accounts::manualinvoice( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber}, "Some fines", 'F', $fines_amount );
647
        ( $renewokay, $error ) =
648
          CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} );
649
        is( $renewokay, 0, 'Do not renew, renewal is automatic' );
650
        is( $error, 'auto_renew', 'Can auto renew, OPACFineNoRenewals=10, patron has 5' );
651
652
        C4::Accounts::manualinvoice( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber}, "Some fines", 'F', $fines_amount );
653
        ( $renewokay, $error ) =
654
          CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} );
655
        is( $renewokay, 0, 'Do not renew, renewal is automatic' );
656
        is( $error, 'auto_renew', 'Can auto renew, OPACFineNoRenewals=10, patron has 10' );
657
658
        C4::Accounts::manualinvoice( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber}, "Some fines", 'F', $fines_amount );
659
        ( $renewokay, $error ) =
660
          CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} );
661
        is( $renewokay, 0, 'Do not renew, renewal is automatic' );
662
        is( $error, 'auto_too_much_oweing', 'Cannot auto renew, OPACFineNoRenewals=10, patron has 15' );
663
664
        $dbh->do('DELETE FROM accountlines WHERE borrowernumber=?', undef, $renewing_borrowernumber);
665
    };
666
627
    subtest "GetLatestAutoRenewDate" => sub {
667
    subtest "GetLatestAutoRenewDate" => sub {
628
        plan tests => 5;
668
        plan tests => 5;
629
        my $item_to_auto_renew = $builder->build(
669
        my $item_to_auto_renew = $builder->build(
630
- 

Return to bug 15582