|
Lines 532-537
C4::Context->dbh->do("DELETE FROM accountlines");
Link Here
|
| 532 |
'Bug 14101: Cannot renew, renewal is automatic (returned code is auto_renew)' |
532 |
'Bug 14101: Cannot renew, renewal is automatic (returned code is auto_renew)' |
| 533 |
); |
533 |
); |
| 534 |
|
534 |
|
|
|
535 |
subtest "too_late_renewal / no_auto_renewal_after" => sub { |
| 536 |
plan tests => 8; |
| 537 |
my $item_to_auto_renew = $builder->build( |
| 538 |
{ source => 'Item', |
| 539 |
value => { |
| 540 |
biblionumber => $biblionumber, |
| 541 |
homebranch => $branch, |
| 542 |
holdingbranch => $branch, |
| 543 |
} |
| 544 |
} |
| 545 |
); |
| 546 |
|
| 547 |
my $ten_days_before = dt_from_string->add( days => -10 ); |
| 548 |
my $ten_days_ahead = dt_from_string->add( days => 10 ); |
| 549 |
AddIssue( $renewing_borrower, $item_to_auto_renew->{barcode}, $ten_days_ahead, undef, $ten_days_before, undef, { auto_renew => 1 } ); |
| 550 |
|
| 551 |
$dbh->do('UPDATE issuingrules SET norenewalbefore = 7, no_auto_renewal_after = 9'); |
| 552 |
( $renewokay, $error ) = |
| 553 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
| 554 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
| 555 |
is( $error, 'auto_too_late', 'Cannot renew, too late(returned code is auto_too_late)' ); |
| 556 |
|
| 557 |
$dbh->do('UPDATE issuingrules SET norenewalbefore = 7, no_auto_renewal_after = 10'); |
| 558 |
( $renewokay, $error ) = |
| 559 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
| 560 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
| 561 |
is( $error, 'auto_too_late', 'Cannot auto renew, too late - no_auto_renewal_after is inclusive(returned code is auto_too_late)' ); |
| 562 |
|
| 563 |
$dbh->do('UPDATE issuingrules SET norenewalbefore = 7, no_auto_renewal_after = 11'); |
| 564 |
( $renewokay, $error ) = |
| 565 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
| 566 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
| 567 |
is( $error, 'auto_too_soon', 'Cannot auto renew, too soon - no_auto_renewal_after is defined(returned code is auto_too_late)' ); |
| 568 |
|
| 569 |
$dbh->do('UPDATE issuingrules SET norenewalbefore = 10, no_auto_renewal_after = 11'); |
| 570 |
( $renewokay, $error ) = |
| 571 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
| 572 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
| 573 |
is( $error, 'auto_renew', 'Cannot renew, renew is automatic' ); |
| 574 |
}; |
| 575 |
|
| 535 |
# Too many renewals |
576 |
# Too many renewals |
| 536 |
|
577 |
|
| 537 |
# set policy to forbid renewals |
578 |
# set policy to forbid renewals |
| 538 |
- |
|
|