old_circ
permit_override
pending_checkouts
+ cancelled_hold_transit
/;
if( $hold_transit or
$U->copy_status($self->copy->status)->id
== OILS_COPY_STATUS_ON_HOLDS_SHELF ) {
- $self->hold(
- ($hold_transit) ?
+
+ my $hold = ($hold_transit) ?
$self->editor->retrieve_action_hold_request($hold_transit->hold) :
- $U->fetch_open_hold_by_copy($self->copy->id)
- );
+ $U->fetch_open_hold_by_copy($self->copy->id);
- $self->checkin_flesh_events;
- return;
+ $self->hold($hold);
+
+ if( $hold and $hold->cancel_time ) { # this transited hold was cancelled mid-transit
+
+ $logger->info("circulator: we received a transit on a cancelled hold " . $hold->id);
+ $self->reshelve_copy(1);
+ $self->cancelled_hold_transit(1);
+ return if $self->bail_out;
+
+ } else {
+
+ # hold transited to correct location
+ $self->checkin_flesh_events;
+ return;
+ }
}
} elsif( $U->copy_status($self->copy->status)->id == OILS_COPY_STATUS_IN_TRANSIT ) {
+
$logger->warn("circulator: we have a copy ".$self->copy->barcode.
" that is in-transit, but there is no transit.. repairing");
$self->reshelve_copy(1);
} else { # not needed for a hold
-
my $circ_lib = (ref $self->copy->circ_lib) ?
$self->copy->circ_lib->id : $self->copy->circ_lib;
$self->bail_out(1); # no need to commit anything
} else {
+
$self->push_events(OpenILS::Event->new('SUCCESS'))
unless @{$self->events};
}
$payload->{record} = $U->record_to_mvr($self->title) if($self->title and !$self->is_precat);
$payload->{circ} = $self->circ;
$payload->{transit} = $self->transit;
- $payload->{hold} = $self->hold;
-
+ $payload->{cancelled_hold_transit} = 1 if $self->cancelled_hold_transit;
+
+ # $self->hold may or may not have been replaced with a
+ # valid hold after processing a cancelled hold
+ $payload->{hold} = $self->hold unless (not $self->hold or $self->hold->cancel_time);
+
$evt->{payload} = $payload;
}
}
if( $transid ) {
my $trans = $e->retrieve_action_transit_copy($transid);
+ # Leave the transit alive, but set the copy status to
+ # reshelving so it will be properly reshelved when it gets back home
if( $trans ) {
- $logger->info("Aborting transit [$transid] on hold [$hid] cancel...");
- my $evt = OpenILS::Application::Circ::Transit::__abort_transit($e, $trans, $copy, 1);
- $logger->info("Transit abort completed with result $evt");
- return $evt unless "$evt" eq 1;
+ $trans->copy_status( OILS_COPY_STATUS_RESHELVING );
+ $e->update_action_transit_copy($trans) or return $e->die_event;
}
+
}
-
- # We don't want the copy to remain "in transit" or to recover
- # any previous statuses
- $logger->info("setting copy back to reshelving in hold+transit cancel");
- $copy->status(OILS_COPY_STATUS_RESHELVING);
- $copy->editor($e->requestor->id);
- $copy->edit_date('now');
- $e->update_asset_copy($copy) or return $e->event;
}
}