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

(-)a/C4/Circulation.pm (+8 lines)
Lines 2846-2851 sub CanBookBeRenewed { Link Here
2846
                return ( 0, "auto_too_late" );
2846
                return ( 0, "auto_too_late" );
2847
            }
2847
            }
2848
        }
2848
        }
2849
2850
        if ( C4::Context->preference('OPACFineNoRenewalsBlockAutoRenew') ) {
2851
            my $fine_no_renewals = C4::Context->preference("OPACFineNoRenewals");
2852
            my ( $amountoutstanding ) = C4::Members::GetMemberAccountRecords($borrower->{borrowernumber});
2853
            if ( $amountoutstanding and $amountoutstanding > $fine_no_renewals ) {
2854
                return ( 0, "auto_too_much_oweing" );
2855
            }
2856
        }
2849
    }
2857
    }
2850
2858
2851
    if ( defined $issuing_rule->norenewalbefore
2859
    if ( defined $issuing_rule->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 623-628 C4::Context->dbh->do("DELETE FROM accountlines"); Link Here
623
        is( $error, 'auto_renew', 'Cannot renew, renew is automatic' );
623
        is( $error, 'auto_renew', 'Cannot renew, renew is automatic' );
624
    };
624
    };
625
625
626
    subtest "auto_too_much_oweing | OPACFineNoRenewalsBlockAutoRenew" => sub {
627
        plan tests => 6;
628
        my $item_to_auto_renew = $builder->build({
629
            source => 'Item',
630
            value => {
631
                biblionumber => $biblionumber,
632
                homebranch       => $branch,
633
                holdingbranch    => $branch,
634
            }
635
        });
636
637
        my $ten_days_before = dt_from_string->add( days => -10 );
638
        my $ten_days_ahead = dt_from_string->add( days => 10 );
639
        AddIssue( $renewing_borrower, $item_to_auto_renew->{barcode}, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } );
640
641
        $dbh->do('UPDATE issuingrules SET norenewalbefore = 10, no_auto_renewal_after = 11');
642
        C4::Context->set_preference('OPACFineNoRenewalsBlockAutoRenew','1');
643
        C4::Context->set_preference('OPACFineNoRenewals','10');
644
        my $fines_amount = 5;
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_renew', 'Can auto renew, OPACFineNoRenewals=10, patron has 5' );
650
651
        C4::Accounts::manualinvoice( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber}, "Some fines", 'F', $fines_amount );
652
        ( $renewokay, $error ) =
653
          CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} );
654
        is( $renewokay, 0, 'Do not renew, renewal is automatic' );
655
        is( $error, 'auto_renew', 'Can auto renew, OPACFineNoRenewals=10, patron has 10' );
656
657
        C4::Accounts::manualinvoice( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber}, "Some fines", 'F', $fines_amount );
658
        ( $renewokay, $error ) =
659
          CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} );
660
        is( $renewokay, 0, 'Do not renew, renewal is automatic' );
661
        is( $error, 'auto_too_much_oweing', 'Cannot auto renew, OPACFineNoRenewals=10, patron has 15' );
662
663
        $dbh->do('DELETE FROM accountlines WHERE borrowernumber=?', undef, $renewing_borrowernumber);
664
    };
665
626
    subtest "GetLatestAutoRenewDate" => sub {
666
    subtest "GetLatestAutoRenewDate" => sub {
627
        plan tests => 5;
667
        plan tests => 5;
628
        my $item_to_auto_renew = $builder->build(
668
        my $item_to_auto_renew = $builder->build(
629
- 

Return to bug 15582