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 => 60; |
30 |
use Test::More tests => 69 ; |
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 277-282
C4::Context->dbh->do("DELETE FROM accountlines");
Link Here
|
277 |
my $datedue2 = AddIssue( $renewing_borrower, $barcode2); |
290 |
my $datedue2 = AddIssue( $renewing_borrower, $barcode2); |
278 |
is (defined $datedue2, 1, "Item 2 checked out, due date: $datedue2"); |
291 |
is (defined $datedue2, 1, "Item 2 checked out, due date: $datedue2"); |
279 |
|
292 |
|
|
|
293 |
|
280 |
my $borrowing_borrowernumber = GetItemIssue($itemnumber)->{borrowernumber}; |
294 |
my $borrowing_borrowernumber = GetItemIssue($itemnumber)->{borrowernumber}; |
281 |
is ($borrowing_borrowernumber, $renewing_borrowernumber, "Item checked out to $renewing_borrower->{firstname} $renewing_borrower->{surname}"); |
295 |
is ($borrowing_borrowernumber, $renewing_borrowernumber, "Item checked out to $renewing_borrower->{firstname} $renewing_borrower->{surname}"); |
282 |
|
296 |
|
Lines 348-354
C4::Context->dbh->do("DELETE FROM accountlines");
Link Here
|
348 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber2, 1); |
362 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber2, 1); |
349 |
is( $renewokay, 1, 'Can renew item 2, item-level hold is on item 1'); |
363 |
is( $renewokay, 1, 'Can renew item 2, item-level hold is on item 1'); |
350 |
|
364 |
|
351 |
|
365 |
|
352 |
# Items can't fill hold for reasons |
366 |
# Items can't fill hold for reasons |
353 |
ModItem({ notforloan => 1 }, $biblionumber, $itemnumber); |
367 |
ModItem({ notforloan => 1 }, $biblionumber, $itemnumber); |
354 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber, 1); |
368 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber, 1); |
Lines 357-362
C4::Context->dbh->do("DELETE FROM accountlines");
Link Here
|
357 |
|
371 |
|
358 |
# FIXME: Add more for itemtype not for loan etc. |
372 |
# FIXME: Add more for itemtype not for loan etc. |
359 |
|
373 |
|
|
|
374 |
# Restricted users cannot renew when RestrictionBlockRenewing is enabled |
375 |
my $barcode5 = 'R00000347'; |
376 |
my ( $item_bibnum5, $item_bibitemnum5, $itemnumber5 ) = AddItem( |
377 |
{ |
378 |
homebranch => $branch, |
379 |
holdingbranch => $branch, |
380 |
barcode => $barcode5, |
381 |
replacementprice => 23.00 |
382 |
}, |
383 |
$biblionumber |
384 |
); |
385 |
my $datedue5 = AddIssue($restricted_borrower, $barcode5); |
386 |
is (defined $datedue5, 1, "Item with date due checked out, due date: $datedue5"); |
387 |
|
388 |
C4::Context->set_preference('RestrictionBlockRenewing','1'); |
389 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber2); |
390 |
is( $renewokay, 1, '(Bug 8236), Can renew, user is not restricted'); |
391 |
( $renewokay, $error ) = CanBookBeRenewed($restricted_borrowernumber, $itemnumber5); |
392 |
is( $renewokay, 0, '(Bug 8236), Cannot renew, user is restricted'); |
393 |
|
394 |
# Users cannot renew an overdue item |
395 |
my $barcode6 = 'R00000348'; |
396 |
my ( $item_bibnum6, $item_bibitemnum6, $itemnumber6 ) = AddItem( |
397 |
{ |
398 |
homebranch => $branch, |
399 |
holdingbranch => $branch, |
400 |
barcode => $barcode6, |
401 |
replacementprice => 23.00 |
402 |
}, |
403 |
$biblionumber |
404 |
); |
405 |
|
406 |
my $barcode7 = 'R00000349'; |
407 |
my ( $item_bibnum7, $item_bibitemnum7, $itemnumber7 ) = AddItem( |
408 |
{ |
409 |
homebranch => $branch, |
410 |
holdingbranch => $branch, |
411 |
barcode => $barcode7, |
412 |
replacementprice => 23.00 |
413 |
}, |
414 |
$biblionumber |
415 |
); |
416 |
my $datedue6 = AddIssue( $renewing_borrower, $barcode6); |
417 |
is (defined $datedue6, 1, "Item 2 checked out, due date: $datedue6"); |
418 |
|
419 |
my $passeddatedue1 = AddIssue($renewing_borrower, $barcode7, DateTime->from_epoch(epoch => 1)); |
420 |
is (defined $passeddatedue1, 1, "Item with passed date due checked out, due date: $passeddatedue1"); |
421 |
|
422 |
|
423 |
C4::Context->set_preference('OverduesBlockRenewing','blockitem'); |
424 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber6); |
425 |
is( $renewokay, 1, '(Bug 8236), Can renew, this item is not overdue'); |
426 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber7); |
427 |
is( $renewokay, 0, '(Bug 8236), Cannot renew, this item is overdue'); |
428 |
|
429 |
|
360 |
$reserveid = C4::Reserves::GetReserveId({ biblionumber => $biblionumber, itemnumber => $itemnumber, borrowernumber => $reserving_borrowernumber}); |
430 |
$reserveid = C4::Reserves::GetReserveId({ biblionumber => $biblionumber, itemnumber => $itemnumber, borrowernumber => $reserving_borrowernumber}); |
361 |
CancelReserve({ reserve_id => $reserveid }); |
431 |
CancelReserve({ reserve_id => $reserveid }); |
362 |
|
432 |
|
Lines 452-458
C4::Context->dbh->do("DELETE FROM accountlines");
Link Here
|
452 |
$future->add( days => 7 ); |
522 |
$future->add( days => 7 ); |
453 |
my $units = C4::Overdues::_get_chargeable_units('days', $future, $now, 'MPL'); |
523 |
my $units = C4::Overdues::_get_chargeable_units('days', $future, $now, 'MPL'); |
454 |
ok( $units == 0, '_get_chargeable_units returns 0 for items not past due date (Bug 12596)' ); |
524 |
ok( $units == 0, '_get_chargeable_units returns 0 for items not past due date (Bug 12596)' ); |
455 |
} |
525 |
|
|
|
526 |
# Users cannot renew any item if there is an overdue item |
527 |
C4::Context->set_preference('OverduesBlockRenewing','block'); |
528 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber6); |
529 |
is( $renewokay, 0, '(Bug 8236), Cannot renew, one of the items is overdue'); |
530 |
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber7); |
531 |
is( $renewokay, 0, '(Bug 8236), Cannot renew, one of the items is overdue'); |
532 |
|
533 |
} |
456 |
|
534 |
|
457 |
{ |
535 |
{ |
458 |
# GetUpcomingDueIssues tests |
536 |
# GetUpcomingDueIssues tests |
459 |
- |
|
|