|
Lines 30-36
use Koha::Database;
Link Here
|
| 30 |
|
30 |
|
| 31 |
use t::lib::TestBuilder; |
31 |
use t::lib::TestBuilder; |
| 32 |
|
32 |
|
| 33 |
use Test::More tests => 84; |
33 |
use Test::More tests => 85; |
| 34 |
|
34 |
|
| 35 |
BEGIN { |
35 |
BEGIN { |
| 36 |
use_ok('C4::Circulation'); |
36 |
use_ok('C4::Circulation'); |
|
Lines 573-578
C4::Context->dbh->do("DELETE FROM accountlines");
Link Here
|
| 573 |
is( $error, 'auto_renew', 'Cannot renew, renew is automatic' ); |
573 |
is( $error, 'auto_renew', 'Cannot renew, renew is automatic' ); |
| 574 |
}; |
574 |
}; |
| 575 |
|
575 |
|
|
|
576 |
subtest "auto_too_much_oweing | OPACFineNoRenewalsBlockAutoRenew" => sub { |
| 577 |
plan tests => 6; |
| 578 |
my $item_to_auto_renew = $builder->build({ |
| 579 |
source => 'Item', |
| 580 |
value => { |
| 581 |
biblionumber => $biblionumber, |
| 582 |
homebranch => $branch, |
| 583 |
holdingbranch => $branch, |
| 584 |
} |
| 585 |
}); |
| 586 |
|
| 587 |
my $ten_days_before = dt_from_string->add( days => -10 ); |
| 588 |
my $ten_days_ahead = dt_from_string->add( days => 10 ); |
| 589 |
AddIssue( $renewing_borrower, $item_to_auto_renew->{barcode}, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); |
| 590 |
|
| 591 |
$dbh->do('UPDATE issuingrules SET norenewalbefore = 10, no_auto_renewal_after = 11'); |
| 592 |
C4::Context->set_preference('OPACFineNoRenewalsBlockAutoRenew','1'); |
| 593 |
C4::Context->set_preference('OPACFineNoRenewals','10'); |
| 594 |
my $fines_amount = 5; |
| 595 |
C4::Accounts::manualinvoice( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber}, "Some fines", 'F', $fines_amount ); |
| 596 |
( $renewokay, $error ) = |
| 597 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
| 598 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
| 599 |
is( $error, 'auto_renew', 'Can auto renew, OPACFineNoRenewals=10, patron has 5' ); |
| 600 |
|
| 601 |
C4::Accounts::manualinvoice( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber}, "Some fines", 'F', $fines_amount ); |
| 602 |
( $renewokay, $error ) = |
| 603 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
| 604 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
| 605 |
is( $error, 'auto_renew', 'Can auto renew, OPACFineNoRenewals=10, patron has 10' ); |
| 606 |
|
| 607 |
C4::Accounts::manualinvoice( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber}, "Some fines", 'F', $fines_amount ); |
| 608 |
( $renewokay, $error ) = |
| 609 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
| 610 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
| 611 |
is( $error, 'auto_too_much_oweing', 'Cannot auto renew, OPACFineNoRenewals=10, patron has 15' ); |
| 612 |
|
| 613 |
$dbh->do('DELETE FROM accountlines WHERE borrowernumber=?', undef, $renewing_borrowernumber); |
| 614 |
}; |
| 615 |
|
| 576 |
subtest "GetLatestAutoRenewDate" => sub { |
616 |
subtest "GetLatestAutoRenewDate" => sub { |
| 577 |
plan tests => 3; |
617 |
plan tests => 3; |
| 578 |
my $item_to_auto_renew = $builder->build( |
618 |
my $item_to_auto_renew = $builder->build( |
| 579 |
- |
|
|