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 2096-2139
subtest 'AddIssue | recalls' => sub {
Link Here
|
2096 |
|
2096 |
|
2097 |
# checking out item that they have recalled |
2097 |
# checking out item that they have recalled |
2098 |
my $recall1 = Koha::Recall->new( |
2098 |
my $recall1 = Koha::Recall->new( |
2099 |
{ borrowernumber => $patron1->borrowernumber, |
2099 |
{ patron_id => $patron1->borrowernumber, |
2100 |
biblionumber => $item->biblionumber, |
2100 |
biblio_id => $item->biblionumber, |
2101 |
itemnumber => $item->itemnumber, |
2101 |
item_id => $item->itemnumber, |
2102 |
item_level_recall => 1, |
2102 |
item_level => 1, |
2103 |
branchcode => $patron1->branchcode, |
2103 |
pickup_library_id => $patron1->branchcode, |
2104 |
} |
2104 |
} |
2105 |
)->store; |
2105 |
)->store; |
2106 |
AddIssue( $patron1->unblessed, $item->barcode, undef, undef, undef, undef, { recall_id => $recall1->recall_id } ); |
2106 |
AddIssue( $patron1->unblessed, $item->barcode, undef, undef, undef, undef, { recall_id => $recall1->id } ); |
2107 |
$recall1 = Koha::Recalls->find( $recall1->recall_id ); |
2107 |
$recall1 = Koha::Recalls->find( $recall1->id ); |
2108 |
is( $recall1->fulfilled, 1, 'Recall was fulfilled when patron checked out item' ); |
2108 |
is( $recall1->fulfilled, 1, 'Recall was fulfilled when patron checked out item' ); |
2109 |
AddReturn( $item->barcode, $item->homebranch ); |
2109 |
AddReturn( $item->barcode, $item->homebranch ); |
2110 |
|
2110 |
|
2111 |
# this item is has a recall request. cancel recall |
2111 |
# this item is has a recall request. cancel recall |
2112 |
my $recall2 = Koha::Recall->new( |
2112 |
my $recall2 = Koha::Recall->new( |
2113 |
{ borrowernumber => $patron2->borrowernumber, |
2113 |
{ patron_id => $patron2->borrowernumber, |
2114 |
biblionumber => $item->biblionumber, |
2114 |
biblio_id => $item->biblionumber, |
2115 |
itemnumber => $item->itemnumber, |
2115 |
item_id => $item->itemnumber, |
2116 |
item_level_recall => 1, |
2116 |
item_level => 1, |
2117 |
branchcode => $patron2->branchcode, |
2117 |
pickup_library_id => $patron2->branchcode, |
2118 |
} |
2118 |
} |
2119 |
)->store; |
2119 |
)->store; |
2120 |
AddIssue( $patron1->unblessed, $item->barcode, undef, undef, undef, undef, { recall_id => $recall2->recall_id, cancel_recall => 'cancel' } ); |
2120 |
AddIssue( $patron1->unblessed, $item->barcode, undef, undef, undef, undef, { recall_id => $recall2->id, cancel_recall => 'cancel' } ); |
2121 |
$recall2 = Koha::Recalls->find( $recall2->recall_id ); |
2121 |
$recall2 = Koha::Recalls->find( $recall2->id ); |
2122 |
is( $recall2->cancelled, 1, 'Recall was cancelled when patron checked out item' ); |
2122 |
is( $recall2->cancelled, 1, 'Recall was cancelled when patron checked out item' ); |
2123 |
AddReturn( $item->barcode, $item->homebranch ); |
2123 |
AddReturn( $item->barcode, $item->homebranch ); |
2124 |
|
2124 |
|
2125 |
# this item is waiting to fulfill a recall. revert recall |
2125 |
# this item is waiting to fulfill a recall. revert recall |
2126 |
my $recall3 = Koha::Recall->new( |
2126 |
my $recall3 = Koha::Recall->new( |
2127 |
{ borrowernumber => $patron2->borrowernumber, |
2127 |
{ patron_id => $patron2->borrowernumber, |
2128 |
biblionumber => $item->biblionumber, |
2128 |
biblio_id => $item->biblionumber, |
2129 |
itemnumber => $item->itemnumber, |
2129 |
item_id => $item->itemnumber, |
2130 |
item_level_recall => 1, |
2130 |
item_level => 1, |
2131 |
branchcode => $patron2->branchcode, |
2131 |
pickup_library_id => $patron2->branchcode, |
2132 |
} |
2132 |
} |
2133 |
)->store; |
2133 |
)->store; |
2134 |
$recall3->set_waiting; |
2134 |
$recall3->set_waiting; |
2135 |
AddIssue( $patron1->unblessed, $item->barcode, undef, undef, undef, undef, { recall_id => $recall3->recall_id, cancel_recall => 'revert' } ); |
2135 |
AddIssue( $patron1->unblessed, $item->barcode, undef, undef, undef, undef, { recall_id => $recall3->id, cancel_recall => 'revert' } ); |
2136 |
$recall3 = Koha::Recalls->find( $recall3->recall_id ); |
2136 |
$recall3 = Koha::Recalls->find( $recall3->id ); |
2137 |
is( $recall3->requested, 1, 'Recall was reverted from waiting when patron checked out item' ); |
2137 |
is( $recall3->requested, 1, 'Recall was reverted from waiting when patron checked out item' ); |
2138 |
AddReturn( $item->barcode, $item->homebranch ); |
2138 |
AddReturn( $item->barcode, $item->homebranch ); |
2139 |
}; |
2139 |
}; |
Lines 4116-4162
subtest 'CanBookBeIssued | recalls' => sub {
Link Here
|
4116 |
|
4116 |
|
4117 |
# item-level recall |
4117 |
# item-level recall |
4118 |
my $recall = Koha::Recall->new( |
4118 |
my $recall = Koha::Recall->new( |
4119 |
{ borrowernumber => $patron1->borrowernumber, |
4119 |
{ patron_id => $patron1->borrowernumber, |
4120 |
biblionumber => $item->biblionumber, |
4120 |
biblio_id => $item->biblionumber, |
4121 |
itemnumber => $item->itemnumber, |
4121 |
item_id => $item->itemnumber, |
4122 |
item_level_recall => 1, |
4122 |
item_level => 1, |
4123 |
branchcode => $patron1->branchcode, |
4123 |
pickup_library_id => $patron1->branchcode, |
4124 |
} |
4124 |
} |
4125 |
)->store; |
4125 |
)->store; |
4126 |
|
4126 |
|
4127 |
my ( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $patron2, $item->barcode, undef, undef, undef, undef ); |
4127 |
my ( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $patron2, $item->barcode, undef, undef, undef, undef ); |
4128 |
is( $needsconfirmation->{RECALLED}->recall_id, $recall->recall_id, "Another patron has placed an item-level recall on this item" ); |
4128 |
is( $needsconfirmation->{RECALLED}->id, $recall->id, "Another patron has placed an item-level recall on this item" ); |
4129 |
|
4129 |
|
4130 |
$recall->set_cancelled; |
4130 |
$recall->set_cancelled; |
4131 |
|
4131 |
|
4132 |
# biblio-level recall |
4132 |
# biblio-level recall |
4133 |
$recall = Koha::Recall->new( |
4133 |
$recall = Koha::Recall->new( |
4134 |
{ borrowernumber => $patron1->borrowernumber, |
4134 |
{ patron_id => $patron1->borrowernumber, |
4135 |
biblionumber => $item->biblionumber, |
4135 |
biblio_id => $item->biblionumber, |
4136 |
itemnumber => undef, |
4136 |
item_id => undef, |
4137 |
item_level_recall => 0, |
4137 |
item_level => 0, |
4138 |
branchcode => $patron1->branchcode, |
4138 |
pickup_library_id => $patron1->branchcode, |
4139 |
} |
4139 |
} |
4140 |
)->store; |
4140 |
)->store; |
4141 |
|
4141 |
|
4142 |
( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $patron2, $item->barcode, undef, undef, undef, undef ); |
4142 |
( $issuingimpossible, $needsconfirmation ) = CanBookBeIssued( $patron2, $item->barcode, undef, undef, undef, undef ); |
4143 |
is( $needsconfirmation->{RECALLED}->recall_id, $recall->recall_id, "Another patron has placed a biblio-level recall and this item is eligible to fill it" ); |
4143 |
is( $needsconfirmation->{RECALLED}->id, $recall->id, "Another patron has placed a biblio-level recall and this item is eligible to fill it" ); |
4144 |
|
4144 |
|
4145 |
$recall->set_cancelled; |
4145 |
$recall->set_cancelled; |
4146 |
|
4146 |
|
4147 |
# biblio-level recall |
4147 |
# biblio-level recall |
4148 |
$recall = Koha::Recall->new( |
4148 |
$recall = Koha::Recall->new( |
4149 |
{ borrowernumber => $patron1->borrowernumber, |
4149 |
{ patron_id => $patron1->borrowernumber, |
4150 |
biblionumber => $item->biblionumber, |
4150 |
biblio_id => $item->biblionumber, |
4151 |
itemnumber => undef, |
4151 |
item_id => undef, |
4152 |
item_level_recall => 0, |
4152 |
item_level => 0, |
4153 |
branchcode => $patron1->branchcode, |
4153 |
pickup_library_id => $patron1->branchcode, |
4154 |
} |
4154 |
} |
4155 |
)->store; |
4155 |
)->store; |
4156 |
$recall->set_waiting( { item => $item, expirationdate => dt_from_string() } ); |
4156 |
$recall->set_waiting( { item => $item, expirationdate => dt_from_string() } ); |
4157 |
|
4157 |
|
4158 |
my ( undef, undef, undef, $messages ) = CanBookBeIssued( $patron1, $item->barcode, undef, undef, undef, undef ); |
4158 |
my ( undef, undef, undef, $messages ) = CanBookBeIssued( $patron1, $item->barcode, undef, undef, undef, undef ); |
4159 |
is( $messages->{RECALLED}, $recall->recall_id, "This book can be issued by this patron and they have placed a recall" ); |
4159 |
is( $messages->{RECALLED}, $recall->id, "This book can be issued by this patron and they have placed a recall" ); |
4160 |
|
4160 |
|
4161 |
$recall->set_cancelled; |
4161 |
$recall->set_cancelled; |
4162 |
}; |
4162 |
}; |
Lines 4196-4220
subtest 'AddReturn | recalls' => sub {
Link Here
|
4196 |
# this item can fill a recall with pickup at this branch |
4196 |
# this item can fill a recall with pickup at this branch |
4197 |
AddIssue( $patron1->unblessed, $item1->barcode ); |
4197 |
AddIssue( $patron1->unblessed, $item1->barcode ); |
4198 |
my $recall1 = Koha::Recall->new( |
4198 |
my $recall1 = Koha::Recall->new( |
4199 |
{ borrowernumber => $patron2->borrowernumber, |
4199 |
{ patron_id => $patron2->borrowernumber, |
4200 |
biblionumber => $item1->biblionumber, |
4200 |
biblio_id => $item1->biblionumber, |
4201 |
itemnumber => $item1->itemnumber, |
4201 |
item_id => $item1->itemnumber, |
4202 |
item_level_recall => 1, |
4202 |
item_level => 1, |
4203 |
branchcode => $item1->homebranch, |
4203 |
pickup_library_id => $item1->homebranch, |
4204 |
} |
4204 |
} |
4205 |
)->store; |
4205 |
)->store; |
4206 |
my ( $doreturn, $messages, $iteminfo, $borrowerinfo ) = AddReturn( $item1->barcode, $item1->homebranch ); |
4206 |
my ( $doreturn, $messages, $iteminfo, $borrowerinfo ) = AddReturn( $item1->barcode, $item1->homebranch ); |
4207 |
is( $messages->{RecallFound}->recall_id, $recall1->recall_id, "Recall found" ); |
4207 |
is( $messages->{RecallFound}->id, $recall1->id, "Recall found" ); |
4208 |
$recall1->set_cancelled; |
4208 |
$recall1->set_cancelled; |
4209 |
|
4209 |
|
4210 |
# this item can fill a recall but needs transfer |
4210 |
# this item can fill a recall but needs transfer |
4211 |
AddIssue( $patron1->unblessed, $item1->barcode ); |
4211 |
AddIssue( $patron1->unblessed, $item1->barcode ); |
4212 |
$recall1 = Koha::Recall->new( |
4212 |
$recall1 = Koha::Recall->new( |
4213 |
{ borrowernumber => $patron2->borrowernumber, |
4213 |
{ patron_id => $patron2->borrowernumber, |
4214 |
biblionumber => $item1->biblionumber, |
4214 |
biblio_id => $item1->biblionumber, |
4215 |
itemnumber => $item1->itemnumber, |
4215 |
item_id => $item1->itemnumber, |
4216 |
item_level_recall => 1, |
4216 |
item_level => 1, |
4217 |
branchcode => $patron2->branchcode, |
4217 |
pickup_library_id => $patron2->branchcode, |
4218 |
} |
4218 |
} |
4219 |
)->store; |
4219 |
)->store; |
4220 |
( $doreturn, $messages, $iteminfo, $borrowerinfo ) = AddReturn( $item1->barcode, $item1->homebranch ); |
4220 |
( $doreturn, $messages, $iteminfo, $borrowerinfo ) = AddReturn( $item1->barcode, $item1->homebranch ); |
Lines 4224-4239
subtest 'AddReturn | recalls' => sub {
Link Here
|
4224 |
# this item is already in transit, do not ask to transfer |
4224 |
# this item is already in transit, do not ask to transfer |
4225 |
AddIssue( $patron1->unblessed, $item1->barcode ); |
4225 |
AddIssue( $patron1->unblessed, $item1->barcode ); |
4226 |
$recall1 = Koha::Recall->new( |
4226 |
$recall1 = Koha::Recall->new( |
4227 |
{ borrowernumber => $patron2->borrowernumber, |
4227 |
{ patron_id => $patron2->borrowernumber, |
4228 |
biblionumber => $item1->biblionumber, |
4228 |
biblio_id => $item1->biblionumber, |
4229 |
itemnumber => $item1->itemnumber, |
4229 |
item_id => $item1->itemnumber, |
4230 |
item_level_recall => 1, |
4230 |
item_level => 1, |
4231 |
branchcode => $patron2->branchcode, |
4231 |
pickup_library_id => $patron2->branchcode, |
4232 |
} |
4232 |
} |
4233 |
)->store; |
4233 |
)->store; |
4234 |
$recall1->start_transfer; |
4234 |
$recall1->start_transfer; |
4235 |
( $doreturn, $messages, $iteminfo, $borrowerinfo ) = AddReturn( $item1->barcode, $patron2->branchcode ); |
4235 |
( $doreturn, $messages, $iteminfo, $borrowerinfo ) = AddReturn( $item1->barcode, $patron2->branchcode ); |
4236 |
is( $messages->{TransferredRecall}->recall_id, $recall1->recall_id, "In transit recall found" ); |
4236 |
is( $messages->{TransferredRecall}->id, $recall1->id, "In transit recall found" ); |
4237 |
$recall1->set_cancelled; |
4237 |
$recall1->set_cancelled; |
4238 |
}; |
4238 |
}; |
4239 |
|
4239 |
|