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 => 61; |
30 |
use Test::More tests => 70 ; |
31 |
|
31 |
|
32 |
BEGIN { |
32 |
BEGIN { |
33 |
use_ok('C4::Circulation'); |
33 |
use_ok('C4::Circulation'); |
Lines 234-239
C4::Context->dbh->do("DELETE FROM accountlines");
Link Here
|
234 |
$biblionumber |
234 |
$biblionumber |
235 |
); |
235 |
); |
236 |
|
236 |
|
|
|
237 |
|
238 |
|
239 |
|
237 |
# Create borrowers |
240 |
# Create borrowers |
238 |
my %renewing_borrower_data = ( |
241 |
my %renewing_borrower_data = ( |
239 |
firstname => 'John', |
242 |
firstname => 'John', |
Lines 256-266
C4::Context->dbh->do("DELETE FROM accountlines");
Link Here
|
256 |
branchcode => $branch, |
259 |
branchcode => $branch, |
257 |
); |
260 |
); |
258 |
|
261 |
|
|
|
262 |
my %restricted_borrower_data = ( |
263 |
firstname => 'Alice', |
264 |
surname => 'Reservation', |
265 |
categorycode => 'S', |
266 |
debarred => '3228-01-01', |
267 |
branchcode => $branch, |
268 |
); |
269 |
|
259 |
my $renewing_borrowernumber = AddMember(%renewing_borrower_data); |
270 |
my $renewing_borrowernumber = AddMember(%renewing_borrower_data); |
260 |
my $reserving_borrowernumber = AddMember(%reserving_borrower_data); |
271 |
my $reserving_borrowernumber = AddMember(%reserving_borrower_data); |
261 |
my $hold_waiting_borrowernumber = AddMember(%hold_waiting_borrower_data); |
272 |
my $hold_waiting_borrowernumber = AddMember(%hold_waiting_borrower_data); |
|
|
273 |
my $restricted_borrowernumber = AddMember(%restricted_borrower_data); |
262 |
|
274 |
|
263 |
my $renewing_borrower = GetMember( borrowernumber => $renewing_borrowernumber ); |
275 |
my $renewing_borrower = GetMember( borrowernumber => $renewing_borrowernumber ); |
|
|
276 |
my $restricted_borrower = GetMember( borrowernumber => $restricted_borrowernumber ); |
264 |
|
277 |
|
265 |
my $constraint = 'a'; |
278 |
my $constraint = 'a'; |
266 |
my $bibitems = ''; |
279 |
my $bibitems = ''; |
Lines 279-284
C4::Context->dbh->do("DELETE FROM accountlines");
Link Here
|
279 |
$datedue = dt_from_string( $issue->date_due() ); |
292 |
$datedue = dt_from_string( $issue->date_due() ); |
280 |
is (defined $issue2, 1, "Item 2 checked out, due date: " . $issue2->date_due()); |
293 |
is (defined $issue2, 1, "Item 2 checked out, due date: " . $issue2->date_due()); |
281 |
|
294 |
|
|
|
295 |
|
282 |
my $borrowing_borrowernumber = GetItemIssue($itemnumber)->{borrowernumber}; |
296 |
my $borrowing_borrowernumber = GetItemIssue($itemnumber)->{borrowernumber}; |
283 |
is ($borrowing_borrowernumber, $renewing_borrowernumber, "Item checked out to $renewing_borrower->{firstname} $renewing_borrower->{surname}"); |
297 |
is ($borrowing_borrowernumber, $renewing_borrowernumber, "Item checked out to $renewing_borrower->{firstname} $renewing_borrower->{surname}"); |
284 |
|
298 |
|
Lines 374-379
C4::Context->dbh->do("DELETE FROM accountlines");
Link Here
|
374 |
|
388 |
|
375 |
# FIXME: Add more for itemtype not for loan etc. |
389 |
# FIXME: Add more for itemtype not for loan etc. |
376 |
|
390 |
|
|
|
391 |
# Restricted users cannot renew when RestrictionBlockRenewing is enabled |
392 |
my $barcode5 = 'R00000347'; |
393 |
my ( $item_bibnum5, $item_bibitemnum5, $itemnumber5 ) = AddItem( |
394 |
{ |
395 |
homebranch => $branch, |
396 |
holdingbranch => $branch, |
397 |
barcode => $barcode5, |
398 |
replacementprice => 23.00 |
399 |
}, |
400 |
$biblionumber |
401 |
); |
402 |
my $datedue5 = AddIssue($restricted_borrower, $barcode5); |
403 |
is (defined $datedue5, 1, "Item with date due checked out, due date: $datedue5"); |
404 |
|
405 |
C4::Context->set_preference('RestrictionBlockRenewing','1'); |
406 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber2); |
407 |
is( $renewokay, 1, '(Bug 8236), Can renew, user is not restricted'); |
408 |
( $renewokay, $error ) = CanBookBeRenewed($restricted_borrowernumber, $itemnumber5); |
409 |
is( $renewokay, 0, '(Bug 8236), Cannot renew, user is restricted'); |
410 |
|
411 |
# Users cannot renew an overdue item |
412 |
my $barcode6 = 'R00000348'; |
413 |
my ( $item_bibnum6, $item_bibitemnum6, $itemnumber6 ) = AddItem( |
414 |
{ |
415 |
homebranch => $branch, |
416 |
holdingbranch => $branch, |
417 |
barcode => $barcode6, |
418 |
replacementprice => 23.00 |
419 |
}, |
420 |
$biblionumber |
421 |
); |
422 |
|
423 |
my $barcode7 = 'R00000349'; |
424 |
my ( $item_bibnum7, $item_bibitemnum7, $itemnumber7 ) = AddItem( |
425 |
{ |
426 |
homebranch => $branch, |
427 |
holdingbranch => $branch, |
428 |
barcode => $barcode7, |
429 |
replacementprice => 23.00 |
430 |
}, |
431 |
$biblionumber |
432 |
); |
433 |
my $datedue6 = AddIssue( $renewing_borrower, $barcode6); |
434 |
is (defined $datedue6, 1, "Item 2 checked out, due date: $datedue6"); |
435 |
|
436 |
my $passeddatedue1 = AddIssue($renewing_borrower, $barcode7, DateTime->from_epoch(epoch => 1)); |
437 |
is (defined $passeddatedue1, 1, "Item with passed date due checked out, due date: $passeddatedue1"); |
438 |
|
439 |
|
440 |
C4::Context->set_preference('OverduesBlockRenewing','blockitem'); |
441 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber6); |
442 |
is( $renewokay, 1, '(Bug 8236), Can renew, this item is not overdue'); |
443 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber7); |
444 |
is( $renewokay, 0, '(Bug 8236), Cannot renew, this item is overdue'); |
445 |
|
446 |
|
377 |
$reserveid = C4::Reserves::GetReserveId({ biblionumber => $biblionumber, itemnumber => $itemnumber, borrowernumber => $reserving_borrowernumber}); |
447 |
$reserveid = C4::Reserves::GetReserveId({ biblionumber => $biblionumber, itemnumber => $itemnumber, borrowernumber => $reserving_borrowernumber}); |
378 |
CancelReserve({ reserve_id => $reserveid }); |
448 |
CancelReserve({ reserve_id => $reserveid }); |
379 |
|
449 |
|
Lines 469-475
C4::Context->dbh->do("DELETE FROM accountlines");
Link Here
|
469 |
$future->add( days => 7 ); |
539 |
$future->add( days => 7 ); |
470 |
my $units = C4::Overdues::get_chargeable_units('days', $future, $now, 'MPL'); |
540 |
my $units = C4::Overdues::get_chargeable_units('days', $future, $now, 'MPL'); |
471 |
ok( $units == 0, '_get_chargeable_units returns 0 for items not past due date (Bug 12596)' ); |
541 |
ok( $units == 0, '_get_chargeable_units returns 0 for items not past due date (Bug 12596)' ); |
472 |
} |
542 |
|
|
|
543 |
# Users cannot renew any item if there is an overdue item |
544 |
C4::Context->set_preference('OverduesBlockRenewing','block'); |
545 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber6); |
546 |
is( $renewokay, 0, '(Bug 8236), Cannot renew, one of the items is overdue'); |
547 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber7); |
548 |
is( $renewokay, 0, '(Bug 8236), Cannot renew, one of the items is overdue'); |
549 |
|
550 |
} |
473 |
|
551 |
|
474 |
{ |
552 |
{ |
475 |
# GetUpcomingDueIssues tests |
553 |
# GetUpcomingDueIssues tests |
476 |
- |
|
|