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