|
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 |
- |
|
|