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

(-)a/C4/Circulation.pm (+8 lines)
Lines 2774-2779 sub CanBookBeRenewed { Link Here
2774
                return ( 0, "auto_too_late" );
2774
                return ( 0, "auto_too_late" );
2775
            }
2775
            }
2776
        }
2776
        }
2777
2778
        if ( C4::Context->preference('OPACFineNoRenewalsBlockAutoRenew') ) {
2779
            my $fine_no_renewals = C4::Context->preference("OPACFineNoRenewals");
2780
            my ( $amountoutstanding ) = C4::Members::GetMemberAccountRecords($borrower->{borrowernumber});
2781
            if ( $amountoutstanding and $amountoutstanding > $fine_no_renewals ) {
2782
                return ( 0, "auto_too_much_oweing" );
2783
            }
2784
        }
2777
    }
2785
    }
2778
2786
2779
    if ( defined $issuing_rule->norenewalbefore
2787
    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 => 94;
20
use Test::More tests => 95;
21
21
22
use DateTime;
22
use DateTime;
23
23
Lines 637-642 C4::Context->dbh->do("DELETE FROM accountlines"); Link Here
637
        is( $error, 'auto_renew', 'Cannot renew, renew is automatic' );
637
        is( $error, 'auto_renew', 'Cannot renew, renew is automatic' );
638
    };
638
    };
639
639
640
    subtest "auto_too_much_oweing | OPACFineNoRenewalsBlockAutoRenew" => sub {
641
        plan tests => 6;
642
        my $item_to_auto_renew = $builder->build({
643
            source => 'Item',
644
            value => {
645
                biblionumber => $biblionumber,
646
                homebranch       => $branch,
647
                holdingbranch    => $branch,
648
            }
649
        });
650
651
        my $ten_days_before = dt_from_string->add( days => -10 );
652
        my $ten_days_ahead = dt_from_string->add( days => 10 );
653
        AddIssue( $renewing_borrower, $item_to_auto_renew->{barcode}, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } );
654
655
        $dbh->do('UPDATE issuingrules SET norenewalbefore = 10, no_auto_renewal_after = 11');
656
        C4::Context->set_preference('OPACFineNoRenewalsBlockAutoRenew','1');
657
        C4::Context->set_preference('OPACFineNoRenewals','10');
658
        my $fines_amount = 5;
659
        C4::Accounts::manualinvoice( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber}, "Some fines", 'F', $fines_amount );
660
        ( $renewokay, $error ) =
661
          CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} );
662
        is( $renewokay, 0, 'Do not renew, renewal is automatic' );
663
        is( $error, 'auto_renew', 'Can auto renew, OPACFineNoRenewals=10, patron has 5' );
664
665
        C4::Accounts::manualinvoice( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber}, "Some fines", 'F', $fines_amount );
666
        ( $renewokay, $error ) =
667
          CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} );
668
        is( $renewokay, 0, 'Do not renew, renewal is automatic' );
669
        is( $error, 'auto_renew', 'Can auto renew, OPACFineNoRenewals=10, patron has 10' );
670
671
        C4::Accounts::manualinvoice( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber}, "Some fines", 'F', $fines_amount );
672
        ( $renewokay, $error ) =
673
          CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} );
674
        is( $renewokay, 0, 'Do not renew, renewal is automatic' );
675
        is( $error, 'auto_too_much_oweing', 'Cannot auto renew, OPACFineNoRenewals=10, patron has 15' );
676
677
        $dbh->do('DELETE FROM accountlines WHERE borrowernumber=?', undef, $renewing_borrowernumber);
678
    };
679
640
    subtest "GetLatestAutoRenewDate" => sub {
680
    subtest "GetLatestAutoRenewDate" => sub {
641
        plan tests => 5;
681
        plan tests => 5;
642
        my $item_to_auto_renew = $builder->build(
682
        my $item_to_auto_renew = $builder->build(
643
- 

Return to bug 15582