|
Lines 431-437
subtest "GetIssuingCharges tests" => sub {
Link Here
|
| 431 |
|
431 |
|
| 432 |
my ( $reused_itemnumber_1, $reused_itemnumber_2 ); |
432 |
my ( $reused_itemnumber_1, $reused_itemnumber_2 ); |
| 433 |
subtest "CanBookBeRenewed tests" => sub { |
433 |
subtest "CanBookBeRenewed tests" => sub { |
| 434 |
plan tests => 112; |
434 |
plan tests => 113; |
| 435 |
|
435 |
|
| 436 |
C4::Context->set_preference('ItemsDeniedRenewal',''); |
436 |
C4::Context->set_preference('ItemsDeniedRenewal',''); |
| 437 |
# Generate test biblio |
437 |
# Generate test biblio |
|
Lines 1011-1016
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
| 1011 |
is( $renewokay, 1, 'No renewal before is 99, patron opted out of auto_renewal so can renew' ); |
1011 |
is( $renewokay, 1, 'No renewal before is 99, patron opted out of auto_renewal so can renew' ); |
| 1012 |
$renewing_borrower_obj->autorenew_checkouts(1)->store; |
1012 |
$renewing_borrower_obj->autorenew_checkouts(1)->store; |
| 1013 |
|
1013 |
|
|
|
1014 |
|
| 1015 |
# Bug 31427 |
| 1016 |
# Ensure autorenewal errors always take highest precidence |
| 1017 |
subtest "auto_renewal errors first" => sub { |
| 1018 |
plan tests => 4; |
| 1019 |
|
| 1020 |
my $auto_renew_item = $builder->build_sample_item( |
| 1021 |
{ |
| 1022 |
biblionumber => $biblio->biblionumber, |
| 1023 |
library => $branch, |
| 1024 |
} |
| 1025 |
); |
| 1026 |
|
| 1027 |
my $ten_days_ahead = dt_from_string->add( days => 10 ); |
| 1028 |
my $issue = AddIssue( $renewing_borrower_obj, $auto_renew_item->barcode, $ten_days_ahead, undef, undef, undef, { auto_renew => 1 } ); |
| 1029 |
|
| 1030 |
Koha::CirculationRules->set_rules( |
| 1031 |
{ |
| 1032 |
categorycode => undef, |
| 1033 |
branchcode => undef, |
| 1034 |
itemtype => undef, |
| 1035 |
rules => { |
| 1036 |
noautorenewalbefore => 7, |
| 1037 |
renewalsallowed => 2, |
| 1038 |
} |
| 1039 |
} |
| 1040 |
); |
| 1041 |
my ( $renewokay, $error ) = |
| 1042 |
CanBookBeRenewed( $renewing_borrower_obj, $issue, undef, 'cron' ); |
| 1043 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
| 1044 |
is( $error, 'auto_too_soon', 'Cannot auto renew, too soon - returned code is auto_too_soon' ); |
| 1045 |
|
| 1046 |
$issue->renewals_count(2)->store; |
| 1047 |
( $renewokay, $error ) = |
| 1048 |
CanBookBeRenewed( $renewing_borrower_obj, $issue, undef, 'cron' ); |
| 1049 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
| 1050 |
is( $error, 'auto_too_soon', 'Cannot auto renew, too soon - auto renewal error takes precidence over non-autorenewal error too_many' ); |
| 1051 |
}; |
| 1052 |
|
| 1014 |
subtest "too_late_renewal / no_auto_renewal_after" => sub { |
1053 |
subtest "too_late_renewal / no_auto_renewal_after" => sub { |
| 1015 |
plan tests => 16; |
1054 |
plan tests => 16; |
| 1016 |
my $item_to_auto_renew = $builder->build_sample_item( |
1055 |
my $item_to_auto_renew = $builder->build_sample_item( |
| 1017 |
- |
|
|