|
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 => 88; |
33 |
use Test::More tests => 89; |
| 34 |
|
34 |
|
| 35 |
BEGIN { |
35 |
BEGIN { |
| 36 |
use_ok('C4::Circulation'); |
36 |
use_ok('C4::Circulation'); |
|
Lines 591-596
C4::Context->dbh->do("DELETE FROM accountlines");
Link Here
|
| 591 |
is( $error, 'auto_renew', 'Cannot renew, renew is automatic' ); |
591 |
is( $error, 'auto_renew', 'Cannot renew, renew is automatic' ); |
| 592 |
}; |
592 |
}; |
| 593 |
|
593 |
|
|
|
594 |
subtest "auto_too_much_oweing | OPACFineNoRenewalsBlockAutoRenew" => sub { |
| 595 |
plan tests => 6; |
| 596 |
my $item_to_auto_renew = $builder->build({ |
| 597 |
source => 'Item', |
| 598 |
value => { |
| 599 |
biblionumber => $biblionumber, |
| 600 |
homebranch => $branch, |
| 601 |
holdingbranch => $branch, |
| 602 |
} |
| 603 |
}); |
| 604 |
|
| 605 |
my $ten_days_before = dt_from_string->add( days => -10 ); |
| 606 |
my $ten_days_ahead = dt_from_string->add( days => 10 ); |
| 607 |
AddIssue( $renewing_borrower, $item_to_auto_renew->{barcode}, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); |
| 608 |
|
| 609 |
$dbh->do('UPDATE issuingrules SET norenewalbefore = 10, no_auto_renewal_after = 11'); |
| 610 |
C4::Context->set_preference('OPACFineNoRenewalsBlockAutoRenew','1'); |
| 611 |
C4::Context->set_preference('OPACFineNoRenewals','10'); |
| 612 |
my $fines_amount = 5; |
| 613 |
C4::Accounts::manualinvoice( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber}, "Some fines", 'F', $fines_amount ); |
| 614 |
( $renewokay, $error ) = |
| 615 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
| 616 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
| 617 |
is( $error, 'auto_renew', 'Can auto renew, OPACFineNoRenewals=10, patron has 5' ); |
| 618 |
|
| 619 |
C4::Accounts::manualinvoice( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber}, "Some fines", 'F', $fines_amount ); |
| 620 |
( $renewokay, $error ) = |
| 621 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
| 622 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
| 623 |
is( $error, 'auto_renew', 'Can auto renew, OPACFineNoRenewals=10, patron has 10' ); |
| 624 |
|
| 625 |
C4::Accounts::manualinvoice( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber}, "Some fines", 'F', $fines_amount ); |
| 626 |
( $renewokay, $error ) = |
| 627 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
| 628 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
| 629 |
is( $error, 'auto_too_much_oweing', 'Cannot auto renew, OPACFineNoRenewals=10, patron has 15' ); |
| 630 |
|
| 631 |
$dbh->do('DELETE FROM accountlines WHERE borrowernumber=?', undef, $renewing_borrowernumber); |
| 632 |
}; |
| 633 |
|
| 594 |
subtest "GetLatestAutoRenewDate" => sub { |
634 |
subtest "GetLatestAutoRenewDate" => sub { |
| 595 |
plan tests => 5; |
635 |
plan tests => 5; |
| 596 |
my $item_to_auto_renew = $builder->build( |
636 |
my $item_to_auto_renew = $builder->build( |
| 597 |
- |
|
|