}
if ($hold) {
+ # If there is a transit, abort it. NOTE: We do this before
+ # canceling to avoid negative consequences of retargeting and
+ # in case the reset of the hold done by the transit abort ever
+ # messes with cancel_time, etc.
+ if ($hold->transit() && $self->{abort_transit_on_hold_cancel}) {
+ $self->abort_transit($hold->transit());
+ }
my $result = $self->cancel_hold($hold);
if (ref($result)) {
$response->problem(_problem_from_event("Temporary Processing Failure", $result));
return $r;
}
+=head2 abort_transit
+
+ $result = $ils->abort_transit($transit);
+
+This method aborts the passed in transit and returns true or false if
+it succeeded. In general, we don't care about the return value here,
+but subclasses might.
+
+=cut
+
+sub abort_transit {
+ my $self = shift;
+ my $transit = shift;
+ my $result = $U->simplereq(
+ 'open-ils.circ',
+ 'open-ils.circ.transit.abort',
+ $self->{session}->{authtoken},
+ {transitid => $transit->id()}
+ );
+ if (ref($result)) {
+ return 0;
+ }
+ return 1;
+}
+
=head2 create_hold_note
$note = $ils->create_hold_note($hold, $title, $body);
$hold = $ils->find_hold_via_note($title, $body);
Searches for a hold based on a note title and note body. Returns the
-note if found, undef otherwise. The search is limited to unfulfilled,
-uncanceled hold where the request_lib equals the NCIPServer working
-org. unit.
+hold, and fleshes its transit (if any), if found, undef otherwise.
+The search is limited to unfulfilled, uncanceled hold where the
+request_lib equals the NCIPServer working org. unit.
=cut
'open-ils.pcrud.search.ahrn',
$self->{session}->{authtoken},
$search,
- {flesh => 1, flesh_fields => {ahrn => ['hold']}}
+ {flesh => 2, flesh_fields => {ahrn => ['hold'], ahr => ['transit']}}
);
if (ref($note) eq 'Fieldmapper::action::hold_request_note') {
return $note->hold();
my ($stat) = grep {$_->id() == $entry->{stat_cat}} @$stat_cats;
push(@{$self->{stat_cat_entries}}, grep {$_->owner() =~ $re && $_->value() eq $entry->{content}} @{$stat->entries()});
}
+
+ # Check if we should abort transits on request cancellation. We
+ # put this in a different variable because someone may not have
+ # updated their configuration since this feature was added and we
+ # don't want runtime errors.
+ $self->{abort_transit_on_hold_cancel} = 0;
+ if ($self->{config}->{holds} && $self->{config}->{holds}->{abort_transit_on_cancel}) {
+ $self->{abort_transit_on_hold_cancel} = 1;
+ }
}
# Search for holds using the user, idvalue and selection_ou.