|
Lines 29-35
use Koha::Database;
Link Here
|
| 29 |
|
29 |
|
| 30 |
use t::lib::TestBuilder; |
30 |
use t::lib::TestBuilder; |
| 31 |
|
31 |
|
| 32 |
use Test::More tests => 90; |
32 |
use Test::More tests => 91; |
| 33 |
|
33 |
|
| 34 |
BEGIN { |
34 |
BEGIN { |
| 35 |
use_ok('C4::Circulation'); |
35 |
use_ok('C4::Circulation'); |
|
Lines 609-614
C4::Context->dbh->do("DELETE FROM accountlines");
Link Here
|
| 609 |
is( $error, 'auto_renew', 'Cannot renew, renew is automatic' ); |
609 |
is( $error, 'auto_renew', 'Cannot renew, renew is automatic' ); |
| 610 |
}; |
610 |
}; |
| 611 |
|
611 |
|
|
|
612 |
subtest "auto_too_much_oweing | OPACFineNoRenewalsBlockAutoRenew" => sub { |
| 613 |
plan tests => 6; |
| 614 |
my $item_to_auto_renew = $builder->build({ |
| 615 |
source => 'Item', |
| 616 |
value => { |
| 617 |
biblionumber => $biblionumber, |
| 618 |
homebranch => $branch, |
| 619 |
holdingbranch => $branch, |
| 620 |
} |
| 621 |
}); |
| 622 |
|
| 623 |
my $ten_days_before = dt_from_string->add( days => -10 ); |
| 624 |
my $ten_days_ahead = dt_from_string->add( days => 10 ); |
| 625 |
AddIssue( $renewing_borrower, $item_to_auto_renew->{barcode}, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); |
| 626 |
|
| 627 |
$dbh->do('UPDATE issuingrules SET norenewalbefore = 10, no_auto_renewal_after = 11'); |
| 628 |
C4::Context->set_preference('OPACFineNoRenewalsBlockAutoRenew','1'); |
| 629 |
C4::Context->set_preference('OPACFineNoRenewals','10'); |
| 630 |
my $fines_amount = 5; |
| 631 |
C4::Accounts::manualinvoice( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber}, "Some fines", 'F', $fines_amount ); |
| 632 |
( $renewokay, $error ) = |
| 633 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
| 634 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
| 635 |
is( $error, 'auto_renew', 'Can auto renew, OPACFineNoRenewals=10, patron has 5' ); |
| 636 |
|
| 637 |
C4::Accounts::manualinvoice( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber}, "Some fines", 'F', $fines_amount ); |
| 638 |
( $renewokay, $error ) = |
| 639 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
| 640 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
| 641 |
is( $error, 'auto_renew', 'Can auto renew, OPACFineNoRenewals=10, patron has 10' ); |
| 642 |
|
| 643 |
C4::Accounts::manualinvoice( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber}, "Some fines", 'F', $fines_amount ); |
| 644 |
( $renewokay, $error ) = |
| 645 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
| 646 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
| 647 |
is( $error, 'auto_too_much_oweing', 'Cannot auto renew, OPACFineNoRenewals=10, patron has 15' ); |
| 648 |
|
| 649 |
$dbh->do('DELETE FROM accountlines WHERE borrowernumber=?', undef, $renewing_borrowernumber); |
| 650 |
}; |
| 651 |
|
| 612 |
subtest "GetLatestAutoRenewDate" => sub { |
652 |
subtest "GetLatestAutoRenewDate" => sub { |
| 613 |
plan tests => 5; |
653 |
plan tests => 5; |
| 614 |
my $item_to_auto_renew = $builder->build( |
654 |
my $item_to_auto_renew = $builder->build( |
| 615 |
- |
|
|