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