|
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 => 84; |
32 |
use Test::More tests => 85; |
| 33 |
|
33 |
|
| 34 |
BEGIN { |
34 |
BEGIN { |
| 35 |
use_ok('C4::Circulation'); |
35 |
use_ok('C4::Circulation'); |
|
Lines 555-560
C4::Context->dbh->do("DELETE FROM accountlines");
Link Here
|
| 555 |
is( $error, 'auto_renew', 'Cannot renew, renew is automatic' ); |
555 |
is( $error, 'auto_renew', 'Cannot renew, renew is automatic' ); |
| 556 |
}; |
556 |
}; |
| 557 |
|
557 |
|
|
|
558 |
subtest "auto_too_much_oweing | MaxOutstandingBlockAutoRenew" => sub { |
| 559 |
plan tests => 6; |
| 560 |
my $item_to_auto_renew = $builder->build({ |
| 561 |
source => 'Item', |
| 562 |
value => { |
| 563 |
biblionumber => $biblionumber, |
| 564 |
homebranch => $branch, |
| 565 |
holdingbranch => $branch, |
| 566 |
} |
| 567 |
}); |
| 568 |
|
| 569 |
my $ten_days_before = dt_from_string->add( days => -10 ); |
| 570 |
my $ten_days_ahead = dt_from_string->add( days => 10 ); |
| 571 |
AddIssue( $renewing_borrower, $item_to_auto_renew->{barcode}, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); |
| 572 |
|
| 573 |
$dbh->do('UPDATE issuingrules SET norenewalbefore = 10, no_auto_renewal_after = 11'); |
| 574 |
C4::Context->set_preference('MaxOutstandingBlockAutoRenew','1'); |
| 575 |
C4::Context->set_preference('maxoutstanding','10'); |
| 576 |
my $fines_amount = 5; |
| 577 |
C4::Accounts::manualinvoice( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber}, "Some fines", 'F', $fines_amount ); |
| 578 |
( $renewokay, $error ) = |
| 579 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
| 580 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
| 581 |
is( $error, 'auto_renew', 'Can auto renew, maxoutstanding=10, patron has 5' ); |
| 582 |
|
| 583 |
C4::Accounts::manualinvoice( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber}, "Some fines", 'F', $fines_amount ); |
| 584 |
( $renewokay, $error ) = |
| 585 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
| 586 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
| 587 |
is( $error, 'auto_renew', 'Can auto renew, maxoutstanding=10, patron has 10' ); |
| 588 |
|
| 589 |
C4::Accounts::manualinvoice( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber}, "Some fines", 'F', $fines_amount ); |
| 590 |
( $renewokay, $error ) = |
| 591 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
| 592 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
| 593 |
is( $error, 'auto_too_much_oweing', 'Cannot auto renew, maxoutstanding=10, patron has 15' ); |
| 594 |
|
| 595 |
$dbh->do('DELETE FROM accountlines WHERE borrowernumber=?', undef, $renewing_borrowernumber); |
| 596 |
}; |
| 597 |
|
| 558 |
subtest "GetLatestAutoRenewDate" => sub { |
598 |
subtest "GetLatestAutoRenewDate" => sub { |
| 559 |
plan tests => 3; |
599 |
plan tests => 3; |
| 560 |
my $item_to_auto_renew = $builder->build( |
600 |
my $item_to_auto_renew = $builder->build( |
| 561 |
- |
|
|