Lines 29-35
use Koha::Database;
Link Here
|
29 |
|
29 |
|
30 |
use t::lib::TestBuilder; |
30 |
use t::lib::TestBuilder; |
31 |
|
31 |
|
32 |
use Test::More tests => 82; |
32 |
use Test::More tests => 83; |
33 |
|
33 |
|
34 |
BEGIN { |
34 |
BEGIN { |
35 |
use_ok('C4::Circulation'); |
35 |
use_ok('C4::Circulation'); |
Lines 455-461
C4::Context->dbh->do("DELETE FROM accountlines");
Link Here
|
455 |
$reserveid = C4::Reserves::GetReserveId({ biblionumber => $biblionumber, itemnumber => $itemnumber, borrowernumber => $reserving_borrowernumber}); |
455 |
$reserveid = C4::Reserves::GetReserveId({ biblionumber => $biblionumber, itemnumber => $itemnumber, borrowernumber => $reserving_borrowernumber}); |
456 |
CancelReserve({ reserve_id => $reserveid }); |
456 |
CancelReserve({ reserve_id => $reserveid }); |
457 |
|
457 |
|
|
|
458 |
# Bug 14101 |
458 |
# Test automatic renewal before value for "norenewalbefore" in policy is set |
459 |
# Test automatic renewal before value for "norenewalbefore" in policy is set |
|
|
460 |
# In this case automatic renewal is not permitted prior to due date |
459 |
my $barcode4 = '11235813'; |
461 |
my $barcode4 = '11235813'; |
460 |
my ( $item_bibnum4, $item_bibitemnum4, $itemnumber4 ) = AddItem( |
462 |
my ( $item_bibnum4, $item_bibitemnum4, $itemnumber4 ) = AddItem( |
461 |
{ |
463 |
{ |
Lines 467-497
C4::Context->dbh->do("DELETE FROM accountlines");
Link Here
|
467 |
$biblionumber |
469 |
$biblionumber |
468 |
); |
470 |
); |
469 |
|
471 |
|
470 |
AddIssue( $renewing_borrower, $barcode4, undef, undef, undef, undef, { auto_renew => 1 } ); |
472 |
AddIssue( $renewing_borrower, $barcode4, undef, undef, undef, undef, |
|
|
473 |
{ auto_renew => 1 } ); |
471 |
( $renewokay, $error ) = |
474 |
( $renewokay, $error ) = |
472 |
CanBookBeRenewed( $renewing_borrowernumber, $itemnumber4 ); |
475 |
CanBookBeRenewed( $renewing_borrowernumber, $itemnumber4 ); |
473 |
is( $renewokay, 0, 'Bug 14101: Cannot renew, renewal is automatic and premature' ); |
476 |
is( $renewokay, 0, 'Bug 14101: Cannot renew, renewal is automatic and premature' ); |
474 |
is( $error, 'auto_too_soon', |
477 |
is( $error, 'auto_too_soon', |
475 |
'Bug 14101: Cannot renew, renewal is automatic and premature, "No renewal before" = undef (returned code is auto_too_soon)' ); |
478 |
'Bug 14101: Cannot renew, renewal is automatic and premature, "No renewal before" = undef (returned code is auto_too_soon)' ); |
476 |
|
479 |
|
477 |
# set policy to require that loans cannot be |
480 |
# Bug 7413 |
478 |
# renewed until seven days prior to the due date |
481 |
# Test premature manual renewal |
479 |
$dbh->do('UPDATE issuingrules SET norenewalbefore = 7'); |
482 |
$dbh->do('UPDATE issuingrules SET norenewalbefore = 7'); |
|
|
483 |
|
480 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber); |
484 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber); |
481 |
is( $renewokay, 0, 'Bug 7413: Cannot renew, renewal is premature'); |
485 |
is( $renewokay, 0, 'Bug 7413: Cannot renew, renewal is premature'); |
482 |
is( $error, 'too_soon', 'Bug 7413: Cannot renew, renewal is premature (returned code is too_soon)'); |
486 |
is( $error, 'too_soon', 'Bug 7413: Cannot renew, renewal is premature (returned code is too_soon)'); |
|
|
487 |
|
488 |
# Bug 14395 |
489 |
# Test 'exact time' setting for syspref NoRenewalBeforePrecision |
490 |
C4::Context->set_preference( 'NoRenewalBeforePrecision', 'exact_time' ); |
491 |
is( |
492 |
GetSoonestRenewDate( $renewing_borrowernumber, $itemnumber ), |
493 |
$datedue->clone->add( days => -7 ), |
494 |
'Bug 14395: Renewals permitted 7 days before due date, as expected' |
495 |
); |
496 |
|
497 |
# Bug 14395 |
498 |
# Test 'date' setting for syspref NoRenewalBeforePrecision |
499 |
C4::Context->set_preference( 'NoRenewalBeforePrecision', 'date' ); |
483 |
is( |
500 |
is( |
484 |
GetSoonestRenewDate($renewing_borrowernumber, $itemnumber), |
501 |
GetSoonestRenewDate( $renewing_borrowernumber, $itemnumber ), |
485 |
$datedue->clone->add(days => -7), |
502 |
$datedue->clone->add( days => -7 )->truncate( to => 'day' ), |
486 |
'Bug 7413: Renewals permitted 7 days before due date, as expected', |
503 |
'Bug 14395: Renewals permitted 7 days before due date, as expected' |
487 |
); |
504 |
); |
488 |
|
505 |
|
489 |
# Test automatic renewal again |
506 |
# Bug 14101 |
|
|
507 |
# Test premature automatic renewal |
490 |
( $renewokay, $error ) = |
508 |
( $renewokay, $error ) = |
491 |
CanBookBeRenewed( $renewing_borrowernumber, $itemnumber4 ); |
509 |
CanBookBeRenewed( $renewing_borrowernumber, $itemnumber4 ); |
492 |
is( $renewokay, 0, 'Bug 14101: Cannot renew, renewal is automatic and premature' ); |
510 |
is( $renewokay, 0, 'Bug 14101: Cannot renew, renewal is automatic and premature' ); |
493 |
is( $error, 'auto_too_soon', |
511 |
is( $error, 'auto_too_soon', |
494 |
'Bug 14101: Cannot renew, renewal is automatic and premature (returned code is auto_too_soon)' |
512 |
'Bug 14101: Cannot renew, renewal is automatic and premature (returned code is auto_too_soon)' |
495 |
); |
513 |
); |
496 |
|
514 |
|
497 |
# Change policy so that loans can only be renewed exactly on due date (0 days prior to due date) |
515 |
# Change policy so that loans can only be renewed exactly on due date (0 days prior to due date) |
Lines 501-507
C4::Context->dbh->do("DELETE FROM accountlines");
Link Here
|
501 |
CanBookBeRenewed( $renewing_borrowernumber, $itemnumber4 ); |
519 |
CanBookBeRenewed( $renewing_borrowernumber, $itemnumber4 ); |
502 |
is( $renewokay, 0, 'Bug 14101: Cannot renew, renewal is automatic and premature' ); |
520 |
is( $renewokay, 0, 'Bug 14101: Cannot renew, renewal is automatic and premature' ); |
503 |
is( $error, 'auto_too_soon', |
521 |
is( $error, 'auto_too_soon', |
504 |
'Bug 14101: Cannot renew, renewal is automatic and premature, "No renewal before" = 0 (returned code is auto_too_soon)' |
522 |
'Bug 14101: Cannot renew, renewal is automatic and premature, "No renewal before" = 0 (returned code is auto_too_soon)' |
505 |
); |
523 |
); |
506 |
|
524 |
|
507 |
# Change policy so that loans can be renewed 99 days prior to the due date |
525 |
# Change policy so that loans can be renewed 99 days prior to the due date |
Lines 511-517
C4::Context->dbh->do("DELETE FROM accountlines");
Link Here
|
511 |
CanBookBeRenewed( $renewing_borrowernumber, $itemnumber4 ); |
529 |
CanBookBeRenewed( $renewing_borrowernumber, $itemnumber4 ); |
512 |
is( $renewokay, 0, 'Bug 14101: Cannot renew, renewal is automatic' ); |
530 |
is( $renewokay, 0, 'Bug 14101: Cannot renew, renewal is automatic' ); |
513 |
is( $error, 'auto_renew', |
531 |
is( $error, 'auto_renew', |
514 |
'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)' |
515 |
); |
533 |
); |
516 |
|
534 |
|
517 |
# Too many renewals |
535 |
# Too many renewals |
518 |
- |
|
|