Lines 1450-1460
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
1450 |
|
1450 |
|
1451 |
# item-level and this item: renewal not allowed |
1451 |
# item-level and this item: renewal not allowed |
1452 |
my $recall = Koha::Recall->new({ |
1452 |
my $recall = Koha::Recall->new({ |
1453 |
biblionumber => $recall_item1->biblionumber, |
1453 |
biblio_id => $recall_item1->biblionumber, |
1454 |
itemnumber => $recall_item1->itemnumber, |
1454 |
item_id => $recall_item1->itemnumber, |
1455 |
borrowernumber => $recall_borrower->borrowernumber, |
1455 |
patron_id => $recall_borrower->borrowernumber, |
1456 |
branchcode => $recall_borrower->branchcode, |
1456 |
pickup_library_id => $recall_borrower->branchcode, |
1457 |
item_level_recall => 1, |
1457 |
item_level => 1, |
1458 |
})->store; |
1458 |
})->store; |
1459 |
( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrowernumber, $recall_item1->itemnumber ); |
1459 |
( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrowernumber, $recall_item1->itemnumber ); |
1460 |
is( $error, 'recalled', 'Cannot renew item that has been recalled' ); |
1460 |
is( $error, 'recalled', 'Cannot renew item that has been recalled' ); |
Lines 1462-1472
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
1462 |
|
1462 |
|
1463 |
# biblio-level requested recall: renewal not allowed |
1463 |
# biblio-level requested recall: renewal not allowed |
1464 |
$recall = Koha::Recall->new({ |
1464 |
$recall = Koha::Recall->new({ |
1465 |
biblionumber => $recall_item1->biblionumber, |
1465 |
biblio_id => $recall_item1->biblionumber, |
1466 |
itemnumber => undef, |
1466 |
item_id => undef, |
1467 |
borrowernumber => $recall_borrower->borrowernumber, |
1467 |
patron_id => $recall_borrower->borrowernumber, |
1468 |
branchcode => $recall_borrower->branchcode, |
1468 |
pickup_library_id => $recall_borrower->branchcode, |
1469 |
item_level_recall => 0, |
1469 |
item_level => 0, |
1470 |
})->store; |
1470 |
})->store; |
1471 |
( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrowernumber, $recall_item1->itemnumber ); |
1471 |
( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrowernumber, $recall_item1->itemnumber ); |
1472 |
is( $error, 'recalled', 'Cannot renew item if biblio is recalled and has no item allocated' ); |
1472 |
is( $error, 'recalled', 'Cannot renew item if biblio is recalled and has no item allocated' ); |
Lines 1474-1484
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
1474 |
|
1474 |
|
1475 |
# item-level and not this item: renewal allowed |
1475 |
# item-level and not this item: renewal allowed |
1476 |
$recall = Koha::Recall->new({ |
1476 |
$recall = Koha::Recall->new({ |
1477 |
biblionumber => $recall_item2->biblionumber, |
1477 |
biblio_id => $recall_item2->biblionumber, |
1478 |
itemnumber => $recall_item2->itemnumber, |
1478 |
item_id => $recall_item2->itemnumber, |
1479 |
borrowernumber => $recall_borrower->borrowernumber, |
1479 |
patron_id => $recall_borrower->borrowernumber, |
1480 |
branchcode => $recall_borrower->branchcode, |
1480 |
pickup_library_id => $recall_borrower->branchcode, |
1481 |
item_level_recall => 1, |
1481 |
item_level => 1, |
1482 |
})->store; |
1482 |
})->store; |
1483 |
( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrowernumber, $recall_item1->itemnumber ); |
1483 |
( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrowernumber, $recall_item1->itemnumber ); |
1484 |
is( $renewokay, 1, 'Can renew item if item-level recall on biblio is not on this item' ); |
1484 |
is( $renewokay, 1, 'Can renew item if item-level recall on biblio is not on this item' ); |
Lines 1486-1496
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
1486 |
|
1486 |
|
1487 |
# biblio-level waiting recall: renewal allowed |
1487 |
# biblio-level waiting recall: renewal allowed |
1488 |
$recall = Koha::Recall->new({ |
1488 |
$recall = Koha::Recall->new({ |
1489 |
biblionumber => $recall_item1->biblionumber, |
1489 |
biblio_id => $recall_item1->biblionumber, |
1490 |
itemnumber => undef, |
1490 |
item_id => undef, |
1491 |
borrowernumber => $recall_borrower->borrowernumber, |
1491 |
patron_id => $recall_borrower->borrowernumber, |
1492 |
branchcode => $recall_borrower->branchcode, |
1492 |
pickup_library_id => $recall_borrower->branchcode, |
1493 |
item_level_recall => 0, |
1493 |
item_level => 0, |
1494 |
})->store; |
1494 |
})->store; |
1495 |
$recall->set_waiting({ item => $recall_item1 }); |
1495 |
$recall->set_waiting({ item => $recall_item1 }); |
1496 |
( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrowernumber, $recall_item1->itemnumber ); |
1496 |
( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrowernumber, $recall_item1->itemnumber ); |
Lines 1995-2038
subtest 'AddIssue | recalls' => sub {
Link Here
|
1995 |
|
1995 |
|
1996 |
# checking out item that they have recalled |
1996 |
# checking out item that they have recalled |
1997 |
my $recall1 = Koha::Recall->new( |
1997 |
my $recall1 = Koha::Recall->new( |
1998 |
{ borrowernumber => $patron1->borrowernumber, |
1998 |
{ patron_id => $patron1->borrowernumber, |
1999 |
biblionumber => $item->biblionumber, |
1999 |
biblio_id => $item->biblionumber, |
2000 |
itemnumber => $item->itemnumber, |
2000 |
item_id => $item->itemnumber, |
2001 |
item_level_recall => 1, |
2001 |
item_level => 1, |
2002 |
branchcode => $patron1->branchcode, |
2002 |
pickup_library_id => $patron1->branchcode, |
2003 |
} |
2003 |
} |
2004 |
)->store; |
2004 |
)->store; |
2005 |
AddIssue( $patron1->unblessed, $item->barcode, undef, undef, undef, undef, { recall_id => $recall1->recall_id } ); |
2005 |
AddIssue( $patron1->unblessed, $item->barcode, undef, undef, undef, undef, { recall_id => $recall1->id } ); |
2006 |
$recall1 = Koha::Recalls->find( $recall1->recall_id ); |
2006 |
$recall1 = Koha::Recalls->find( $recall1->id ); |
2007 |
is( $recall1->fulfilled, 1, 'Recall was fulfilled when patron checked out item' ); |
2007 |
is( $recall1->fulfilled, 1, 'Recall was fulfilled when patron checked out item' ); |
2008 |
AddReturn( $item->barcode, $item->homebranch ); |
2008 |
AddReturn( $item->barcode, $item->homebranch ); |
2009 |
|
2009 |
|
2010 |
# this item is has a recall request. cancel recall |
2010 |
# this item is has a recall request. cancel recall |
2011 |
my $recall2 = Koha::Recall->new( |
2011 |
my $recall2 = Koha::Recall->new( |
2012 |
{ borrowernumber => $patron2->borrowernumber, |
2012 |
{ patron_id => $patron2->borrowernumber, |
2013 |
biblionumber => $item->biblionumber, |
2013 |
biblio_id => $item->biblionumber, |
2014 |
itemnumber => $item->itemnumber, |
2014 |
item_id => $item->itemnumber, |
2015 |
item_level_recall => 1, |
2015 |
item_level => 1, |
2016 |
branchcode => $patron2->branchcode, |
2016 |
pickup_library_id => $patron2->branchcode, |
2017 |
} |
2017 |
} |
2018 |
)->store; |
2018 |
)->store; |
2019 |
AddIssue( $patron1->unblessed, $item->barcode, undef, undef, undef, undef, { recall_id => $recall2->recall_id, cancel_recall => 'cancel' } ); |
2019 |
AddIssue( $patron1->unblessed, $item->barcode, undef, undef, undef, undef, { recall_id => $recall2->id, cancel_recall => 'cancel' } ); |
2020 |
$recall2 = Koha::Recalls->find( $recall2->recall_id ); |
2020 |
$recall2 = Koha::Recalls->find( $recall2->id ); |
2021 |
is( $recall2->cancelled, 1, 'Recall was cancelled when patron checked out item' ); |
2021 |
is( $recall2->cancelled, 1, 'Recall was cancelled when patron checked out item' ); |
2022 |
AddReturn( $item->barcode, $item->homebranch ); |
2022 |
AddReturn( $item->barcode, $item->homebranch ); |
2023 |
|
2023 |
|
2024 |
# this item is waiting to fulfill a recall. revert recall |
2024 |
# this item is waiting to fulfill a recall. revert recall |
2025 |
my $recall3 = Koha::Recall->new( |
2025 |
my $recall3 = Koha::Recall->new( |
2026 |
{ borrowernumber => $patron2->borrowernumber, |
2026 |
{ patron_id => $patron2->borrowernumber, |
2027 |
biblionumber => $item->biblionumber, |
2027 |
biblio_id => $item->biblionumber, |
2028 |
itemnumber => $item->itemnumber, |
2028 |
item_id => $item->itemnumber, |
2029 |
item_level_recall => 1, |
2029 |
item_level => 1, |
2030 |
branchcode => $patron2->branchcode, |
2030 |
pickup_library_id => $patron2->branchcode, |
2031 |
} |
2031 |
} |
2032 |
)->store; |
2032 |
)->store; |
2033 |
$recall3->set_waiting; |
2033 |
$recall3->set_waiting; |
2034 |
AddIssue( $patron1->unblessed, $item->barcode, undef, undef, undef, undef, { recall_id => $recall3->recall_id, cancel_recall => 'revert' } ); |
2034 |
AddIssue( $patron1->unblessed, $item->barcode, undef, undef, undef, undef, { recall_id => $recall3->id, cancel_recall => 'revert' } ); |
2035 |
$recall3 = Koha::Recalls->find( $recall3->recall_id ); |
2035 |
$recall3 = Koha::Recalls->find( $recall3->id ); |
2036 |
is( $recall3->requested, 1, 'Recall was reverted from waiting when patron checked out item' ); |
2036 |
is( $recall3->requested, 1, 'Recall was reverted from waiting when patron checked out item' ); |
2037 |
AddReturn( $item->barcode, $item->homebranch ); |
2037 |
AddReturn( $item->barcode, $item->homebranch ); |
2038 |
}; |
2038 |
}; |
Lines 3975-4021
subtest 'CanBookBeIssued | recalls' => sub {
Link Here
|
3975 |
|
3975 |
|
3976 |
# item-level recall |
3976 |
# item-level recall |
3977 |
my $recall = Koha::Recall->new( |
3977 |
my $recall = Koha::Recall->new( |
3978 |
{ borrowernumber => $patron1->borrowernumber, |
3978 |
{ patron_id => $patron1->borrowernumber, |
3979 |
biblionumber => $item->biblionumber, |
3979 |
biblio_id => $item->biblionumber, |
3980 |
itemnumber => $item->itemnumber, |
3980 |
item_id => $item->itemnumber, |
3981 |
item_level_recall => 1, |
3981 |
item_level => 1, |
3982 |
branchcode => $patron1->branchcode, |
3982 |
pickup_library_id => $patron1->branchcode, |
3983 |
} |
3983 |
} |
3984 |
)->store; |
3984 |
)->store; |
3985 |
|
3985 |
|
3986 |
my ( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $patron2, $item->barcode, undef, undef, undef, undef ); |
3986 |
my ( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $patron2, $item->barcode, undef, undef, undef, undef ); |
3987 |
is( $needsconfirmation->{RECALLED}->recall_id, $recall->recall_id, "Another patron has placed an item-level recall on this item" ); |
3987 |
is( $needsconfirmation->{RECALLED}->id, $recall->id, "Another patron has placed an item-level recall on this item" ); |
3988 |
|
3988 |
|
3989 |
$recall->set_cancelled; |
3989 |
$recall->set_cancelled; |
3990 |
|
3990 |
|
3991 |
# biblio-level recall |
3991 |
# biblio-level recall |
3992 |
$recall = Koha::Recall->new( |
3992 |
$recall = Koha::Recall->new( |
3993 |
{ borrowernumber => $patron1->borrowernumber, |
3993 |
{ patron_id => $patron1->borrowernumber, |
3994 |
biblionumber => $item->biblionumber, |
3994 |
biblio_id => $item->biblionumber, |
3995 |
itemnumber => undef, |
3995 |
item_id => undef, |
3996 |
item_level_recall => 0, |
3996 |
item_level => 0, |
3997 |
branchcode => $patron1->branchcode, |
3997 |
pickup_library_id => $patron1->branchcode, |
3998 |
} |
3998 |
} |
3999 |
)->store; |
3999 |
)->store; |
4000 |
|
4000 |
|
4001 |
( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $patron2, $item->barcode, undef, undef, undef, undef ); |
4001 |
( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $patron2, $item->barcode, undef, undef, undef, undef ); |
4002 |
is( $needsconfirmation->{RECALLED}->recall_id, $recall->recall_id, "Another patron has placed a biblio-level recall and this item is eligible to fill it" ); |
4002 |
is( $needsconfirmation->{RECALLED}->id, $recall->id, "Another patron has placed a biblio-level recall and this item is eligible to fill it" ); |
4003 |
|
4003 |
|
4004 |
$recall->set_cancelled; |
4004 |
$recall->set_cancelled; |
4005 |
|
4005 |
|
4006 |
# biblio-level recall |
4006 |
# biblio-level recall |
4007 |
$recall = Koha::Recall->new( |
4007 |
$recall = Koha::Recall->new( |
4008 |
{ borrowernumber => $patron1->borrowernumber, |
4008 |
{ patron_id => $patron1->borrowernumber, |
4009 |
biblionumber => $item->biblionumber, |
4009 |
biblio_id => $item->biblionumber, |
4010 |
itemnumber => undef, |
4010 |
item_id => undef, |
4011 |
item_level_recall => 0, |
4011 |
item_level => 0, |
4012 |
branchcode => $patron1->branchcode, |
4012 |
pickup_library_id => $patron1->branchcode, |
4013 |
} |
4013 |
} |
4014 |
)->store; |
4014 |
)->store; |
4015 |
$recall->set_waiting( { item => $item, expirationdate => dt_from_string() } ); |
4015 |
$recall->set_waiting( { item => $item, expirationdate => dt_from_string() } ); |
4016 |
|
4016 |
|
4017 |
my ( undef, undef, undef, $messages ) = CanBookBeIssued( $patron1, $item->barcode, undef, undef, undef, undef ); |
4017 |
my ( undef, undef, undef, $messages ) = CanBookBeIssued( $patron1, $item->barcode, undef, undef, undef, undef ); |
4018 |
is( $messages->{RECALLED}, $recall->recall_id, "This book can be issued by this patron and they have placed a recall" ); |
4018 |
is( $messages->{RECALLED}, $recall->id, "This book can be issued by this patron and they have placed a recall" ); |
4019 |
|
4019 |
|
4020 |
$recall->set_cancelled; |
4020 |
$recall->set_cancelled; |
4021 |
}; |
4021 |
}; |
Lines 4055-4079
subtest 'AddReturn | recalls' => sub {
Link Here
|
4055 |
# this item can fill a recall with pickup at this branch |
4055 |
# this item can fill a recall with pickup at this branch |
4056 |
AddIssue( $patron1->unblessed, $item1->barcode ); |
4056 |
AddIssue( $patron1->unblessed, $item1->barcode ); |
4057 |
my $recall1 = Koha::Recall->new( |
4057 |
my $recall1 = Koha::Recall->new( |
4058 |
{ borrowernumber => $patron2->borrowernumber, |
4058 |
{ patron_id => $patron2->borrowernumber, |
4059 |
biblionumber => $item1->biblionumber, |
4059 |
biblio_id => $item1->biblionumber, |
4060 |
itemnumber => $item1->itemnumber, |
4060 |
item_id => $item1->itemnumber, |
4061 |
item_level_recall => 1, |
4061 |
item_level => 1, |
4062 |
branchcode => $item1->homebranch, |
4062 |
pickup_library_id => $item1->homebranch, |
4063 |
} |
4063 |
} |
4064 |
)->store; |
4064 |
)->store; |
4065 |
my ( $doreturn, $messages, $iteminfo, $borrowerinfo ) = AddReturn( $item1->barcode, $item1->homebranch ); |
4065 |
my ( $doreturn, $messages, $iteminfo, $borrowerinfo ) = AddReturn( $item1->barcode, $item1->homebranch ); |
4066 |
is( $messages->{RecallFound}->recall_id, $recall1->recall_id, "Recall found" ); |
4066 |
is( $messages->{RecallFound}->id, $recall1->id, "Recall found" ); |
4067 |
$recall1->set_cancelled; |
4067 |
$recall1->set_cancelled; |
4068 |
|
4068 |
|
4069 |
# this item can fill a recall but needs transfer |
4069 |
# this item can fill a recall but needs transfer |
4070 |
AddIssue( $patron1->unblessed, $item1->barcode ); |
4070 |
AddIssue( $patron1->unblessed, $item1->barcode ); |
4071 |
$recall1 = Koha::Recall->new( |
4071 |
$recall1 = Koha::Recall->new( |
4072 |
{ borrowernumber => $patron2->borrowernumber, |
4072 |
{ patron_id => $patron2->borrowernumber, |
4073 |
biblionumber => $item1->biblionumber, |
4073 |
biblio_id => $item1->biblionumber, |
4074 |
itemnumber => $item1->itemnumber, |
4074 |
item_id => $item1->itemnumber, |
4075 |
item_level_recall => 1, |
4075 |
item_level => 1, |
4076 |
branchcode => $patron2->branchcode, |
4076 |
pickup_library_id => $patron2->branchcode, |
4077 |
} |
4077 |
} |
4078 |
)->store; |
4078 |
)->store; |
4079 |
( $doreturn, $messages, $iteminfo, $borrowerinfo ) = AddReturn( $item1->barcode, $item1->homebranch ); |
4079 |
( $doreturn, $messages, $iteminfo, $borrowerinfo ) = AddReturn( $item1->barcode, $item1->homebranch ); |
Lines 4083-4098
subtest 'AddReturn | recalls' => sub {
Link Here
|
4083 |
# this item is already in transit, do not ask to transfer |
4083 |
# this item is already in transit, do not ask to transfer |
4084 |
AddIssue( $patron1->unblessed, $item1->barcode ); |
4084 |
AddIssue( $patron1->unblessed, $item1->barcode ); |
4085 |
$recall1 = Koha::Recall->new( |
4085 |
$recall1 = Koha::Recall->new( |
4086 |
{ borrowernumber => $patron2->borrowernumber, |
4086 |
{ patron_id => $patron2->borrowernumber, |
4087 |
biblionumber => $item1->biblionumber, |
4087 |
biblio_id => $item1->biblionumber, |
4088 |
itemnumber => $item1->itemnumber, |
4088 |
item_id => $item1->itemnumber, |
4089 |
item_level_recall => 1, |
4089 |
item_level => 1, |
4090 |
branchcode => $patron2->branchcode, |
4090 |
pickup_library_id => $patron2->branchcode, |
4091 |
} |
4091 |
} |
4092 |
)->store; |
4092 |
)->store; |
4093 |
$recall1->start_transfer; |
4093 |
$recall1->start_transfer; |
4094 |
( $doreturn, $messages, $iteminfo, $borrowerinfo ) = AddReturn( $item1->barcode, $patron2->branchcode ); |
4094 |
( $doreturn, $messages, $iteminfo, $borrowerinfo ) = AddReturn( $item1->barcode, $patron2->branchcode ); |
4095 |
is( $messages->{TransferredRecall}->recall_id, $recall1->recall_id, "In transit recall found" ); |
4095 |
is( $messages->{TransferredRecall}->id, $recall1->id, "In transit recall found" ); |
4096 |
$recall1->set_cancelled; |
4096 |
$recall1->set_cancelled; |
4097 |
}; |
4097 |
}; |
4098 |
|
4098 |
|