sub mark_item_missing_pieces {
my( $self, $conn, $auth, $copy_id, $args ) = @_;
- ### FIXME: We're starting a transaction here, but we're doing a lot of things outside of the transaction
- ### FIXME: Even better, we're going to use two transactions, the first to affect pertinent holds before checkout can
-
- my $e2 = new_editor(authtoken=>$auth, xact =>1);
- return $e2->die_event unless $e2->checkauth;
$args ||= {};
+ my $e2 = new_editor(authtoken => $auth);
+ return $e2->event unless $e2->checkauth;
+
my $copy = $e2->retrieve_asset_copy([
$copy_id,
{flesh => 1, flesh_fields => {'acp' => ['call_number']}}])
- or return $e2->die_event;
+ or return $e2->event;
my $owning_lib =
($copy->call_number->id == OILS_PRECAT_CALL_NUMBER) ?
$copy->circ_lib : $copy->call_number->owning_lib;
- return $e2->die_event unless $e2->allowed('MARK_ITEM_MISSING_PIECES', $owning_lib);
+ return $e2->event unless $e2->allowed('MARK_ITEM_MISSING_PIECES', $owning_lib);
#### grab the last circulation
my $circ = $e2->search_action_circulation([
if (!$circ) {
$logger->info('open-ils.circ.mark_item_missing_pieces: no previous checkout');
- $e2->rollback;
return OpenILS::Event->new('ACTION_CIRCULATION_NOT_FOUND',{'copy'=>$copy});
}
$logger->debug("resetting holds that target the marked copy");
OpenILS::Application::Circ::Holds->_reset_hold($e2->requestor, $_) for @$holds;
-
- if (! $e2->commit) {
- return $e2->die_event;
+ if ($copy->status == OILS_COPY_STATUS_IN_TRANSIT) {
+ # KCLS JBAS-537 Abort active transits before attempting to
+ # check the item back out to the most recent patron.
+
+ $logger->info("Canceling active transit on mark-missing-pieces item");
+
+ my $resp = $apputils->simplereq('open-ils.circ',
+ 'open-ils.circ.transit.abort', $auth, {copyid => $copy->id});
+
+ unless ($resp && $resp == 1) {
+ $logger->error(
+ "Error canceling transit on mark-missing-pieces item");
+ return $resp;
+ }
}
my $e = new_editor(authtoken=>$auth, xact =>1);