<field reporter:label="Prev Destination" name="prev_dest" reporter:datatype="org_unit"/>
<field reporter:label="Send Date/Time" name="source_send_time" reporter:datatype="timestamp"/>
<field reporter:label="Transited Copy" name="target_copy" reporter:datatype="link"/>
+ <field reporter:label="Cancel Date/Time" name="cancel_time" reporter:datatype="timestamp"/>
<field reporter:label="Hold Transit" name="hold_transit_copy" oils_persist:virtual="true" reporter:datatype="link"/>
</fields>
<links>
<field reporter:label="Transited Copy" name="target_copy" reporter:datatype="link"/>
<field reporter:label="Base Transit" name="transit_copy" oils_persist:virtual="true" reporter:datatype="link"/>
<field reporter:label="Prev Destination Library" name="prev_dest" reporter:datatype="org_unit"/>
+ <field reporter:label="Cancel Date/Time" name="cancel_time" reporter:datatype="timestamp"/>
</fields>
<links>
<link field="transit_copy" reltype="might_have" key="id" map="" class="atc"/>
<field reporter:label="Transited Copy" name="target_copy" reporter:datatype="link"/>
<field reporter:label="Base Transit" name="transit_copy" oils_persist:virtual="true" reporter:datatype="link"/>
<field reporter:label="Prev Destination Library" name="prev_dest" reporter:datatype="org_unit"/>
+ <field reporter:label="Cancel Date/Time" name="cancel_time" reporter:datatype="timestamp"/>
</fields>
<links>
<link field="transit_copy" reltype="might_have" key="id" map="" class="atc"/>
<field reporter:label="Send Date/Time" name="source_send_time" reporter:datatype="timestamp"/>
<field reporter:label="Transited Copy" name="target_copy" reporter:datatype="link"/>
<field reporter:label="Hold Transit" name="hold_transit_copy" oils_persist:virtual="true" reporter:datatype="link"/>
+ <field reporter:label="Cancel Date/Time" name="cancel_time" reporter:datatype="timestamp"/>
</fields>
<links>
<link field="hold_transit_copy" reltype="might_have" key="id" map="" class="ahtc"/>
$transit = $self->simplereq(
'open-ils.cstore',
- 'open-ils.cstore.direct.action.hold_transit_copy.search', { hold => $holdid } );
+ 'open-ils.cstore.direct.action.hold_transit_copy.search', { hold => $holdid, cancel_time => undef } );
$evt = OpenILS::Event->new('ACTION_HOLD_TRANSIT_COPY_NOT_FOUND', holdid => $holdid) unless $transit;
my($transit, $evt);
$transit = $self->cstorereq(
'open-ils.cstore.direct.action.transit_copy.search',
- { target_copy => $copyid, dest_recv_time => undef });
+ { target_copy => $copyid, dest_recv_time => undef, cancel_time => undef });
$evt = OpenILS::Event->new('ACTION_TRANSIT_COPY_NOT_FOUND') unless $transit;
return ($transit, $evt);
}
# need to transit the item ... is it already in transit?
my $transit = $e->search_action_reservation_transit_copy(
- {"reservation" => $res_id, "dest_recv_time" => undef}
+ {"reservation" => $res_id, "dest_recv_time" => undef, cancel_time => undef}
)->[0];
if (!$transit) { # not yet in transit
$copy->edit_date('now');
$editor->update_asset_copy($copy) or return $editor->event;
- # Delete any open transits for this copy
+ # Cancel any open transits for this copy
my $transits = $editor->search_action_transit_copy(
- { target_copy=>$copy->id, dest_recv_time => undef } );
+ { target_copy=>$copy->id, dest_recv_time => undef, cancel_time => undef } );
for my $t (@$transits) {
- $editor->delete_action_transit_copy($t)
+ $t->cancel_time('now');
+ $editor->update_action_transit_copy($t)
or return $editor->event;
}
OpenILS::Application::Circ::Holds::flesh_hold_transits([$hold]) if $hold;
my $transit = $e->search_action_transit_copy(
- { target_copy => $copy_id, dest_recv_time => undef } )->[0];
+ { target_copy => $copy_id, dest_recv_time => undef, cancel_time => undef } )->[0];
# find the most recent circulation for the requested copy,
# be it active, completed, or aged.
my $res_id_list = [ map { $_->id } @$resources ];
my $transit = $circulator->editor->search_action_reservation_transit_copy(
[
- { target_copy => $res_id_list, dest => $circulator->circ_lib, dest_recv_time => undef },
+ { target_copy => $res_id_list, dest => $circulator->circ_lib, dest_recv_time => undef, cancel_time => undef },
{ order_by => { artc => 'source_send_time' }, limit => 1 }
]
)->[0]; # Any transit for this barcode?
# capture the transit so we don't have to fetch it again later during checkin
$self->transit(
$self->editor->search_action_transit_copy(
- {target_copy => $self->copy->id, dest_recv_time => undef}
+ {target_copy => $self->copy->id, dest_recv_time => undef, cancel_time => undef}
)->[0]
);
if( $self->copy and !$self->transit ) {
$self->transit(
$self->editor->search_action_transit_copy(
- { target_copy => $self->copy->id, dest_recv_time => undef }
+ { target_copy => $self->copy->id, dest_recv_time => undef, cancel_time => undef }
)->[0]
);
}
$hold->transit(
$e->search_action_hold_transit_copy([
- {hold => $hold->id},
+ {hold => $hold->id, cancel_time => undef},
{order_by => {ahtc => 'source_send_time desc'}, limit => 1}])->[0]
);
my $hid = $hold->id;
$logger->warn("! canceling hold [$hid] that is in transit");
- my $transid = $e->search_action_hold_transit_copy({hold=>$hold->id},{idlist=>1})->[0];
+ my $transid = $e->search_action_hold_transit_copy({hold=>$hold->id,cancel_time=>undef},{idlist=>1})->[0];
if( $transid ) {
my $trans = $e->retrieve_action_transit_copy($transid);
# update the transit to reflect the new pickup location
my $transit = $e->search_action_hold_transit_copy(
- {hold=>$hold->id, dest_recv_time => undef})->[0]
+ {hold=>$hold->id, cancel_time => undef, dest_recv_time => undef})->[0]
or return $e->die_event;
$transit->prev_dest($transit->dest); # mark the previous destination on the transit
my $transit = $e->search_action_hold_transit_copy({
hold => $hold->id,
target_copy => $copy->id,
+ cancel_time => undef,
dest_recv_time => {'!=' => undef},
})->[0];
my $start_time = ($transit) ? $transit->dest_recv_time : $hold->capture_time;
# We don't want the copy to remain "in transit"
$copy->status(OILS_COPY_STATUS_RESHELVING);
$logger->warn("! reseting hold [$hid] that is in transit");
- my $transid = $e->search_action_hold_transit_copy({hold=>$hold->id},{idlist=>1})->[0];
+ my $transid = $e->search_action_hold_transit_copy({hold=>$hold->id,cancel_time=>undef},{idlist=>1})->[0];
if( $transid ) {
my $trans = $e->retrieve_action_transit_copy($transid);
$apputils->simplereq(
'open-ils.cstore',
"open-ils.cstore.direct.action.hold_transit_copy.search.atomic",
- { hold => $hold->id },
+ { hold => $hold->id, cancel_time => undef },
{ order_by => { ahtc => 'id desc' }, limit => 1 }
)->[0]
);
} elsif( $copy ) {
$transit = $e->search_action_transit_copy(
- { target_copy => $copy->id, dest_recv_time => undef })->[0];
+ { target_copy => $copy->id, dest_recv_time => undef, cancel_time => undef })->[0];
return $e->event unless $transit;
}
my $holdtransit = $e->retrieve_action_hold_transit_copy($transit->id);
- return $e->die_event unless $e->delete_action_transit_copy($transit);
+ # rather than deleting the transit row, set the cancel_time
+ $transit->cancel_time('now');
+ return $e->die_event unless $e->update_action_transit_copy($transit);
# Only change the copy status if the copy status is "In Transit."
if ($copy->status == OILS_COPY_STATUS_IN_TRANSIT) {
return $e->event unless $e->checkauth;
return $e->event unless $e->allowed('VIEW_USER'); # XXX rely on editor perms
my $t = $e->search_action_transit_copy(
- { target_copy => $copyid, dest_recv_time => undef });
+ { target_copy => $copyid, dest_recv_time => undef, cancel_time => undef });
return $e->event unless @$t;
return $$t[0];
}
my $t = $e->search_action_transit_copy(
{
target_copy => $copyid,
- dest_recv_time => undef
+ dest_recv_time => undef,
+ cancel_time => undef
}
)->[0];
return $e->event unless $t;
return $e->event unless $e->allowed('VIEW_CIRCULATIONS'); # eh.. basically the same permission
my $order_by = {order_by => { atc => 'source_send_time' }};
- my $search = { dest_recv_time => undef };
+ my $search = { dest_recv_time => undef, cancel_time => undef };
if($end_date) {
if($start_date) {
__PACKAGE__->columns(Primary => 'id');
__PACKAGE__->columns(Essential => qw/source dest persistant_transfer target_copy
source_send_time dest_recv_time prev_hop prev_dest
- copy_status hold/);
+ cancel_time copy_status hold/);
#-------------------------------------------------------------------------------
__PACKAGE__->columns(Primary => 'id');
__PACKAGE__->columns(Essential => qw/source dest persistant_transfer target_copy
source_send_time dest_recv_time prev_hop prev_dest
- copy_status reservation/);
+ cancel_time copy_status reservation/);
#-------------------------------------------------------------------------------
__PACKAGE__->columns(Primary => 'id');
__PACKAGE__->columns(Essential => qw/source dest persistant_transfer target_copy
source_send_time dest_recv_time prev_hop prev_dest
- copy_status/);
+ cancel_time copy_status/);
#-------------------------------------------------------------------------------
COALESCE(dest_recv_time, source_send_time) AS moment
FROM action.transit_copy
WHERE target_copy = %d
+ AND cancel_time IS NULL
ORDER BY moment DESC LIMIT 1
) UNION (
SELECT
WHERE
atc.target_copy = %d AND
(atc.dest = %d OR atc.source = %d) AND
- atc.dest_recv_time >= NOW() - (SELECT value FROM go_home_interval)
+ atc.dest_recv_time >= NOW() - (SELECT value FROM go_home_interval) AND
+ atc.cancel_time IS NULL
) AS result FROM copy_has_not_been_home
) !, $cp->id, $cp->circ_lib, $cp->circ_lib);
$joins .= " JOIN copy_has_not_been_home_even_to_idle ON (true) ";
my $transit = $e->search_action_transit_copy([
{
target_copy => $copy->id, # NOT barcode ($self->id)
- dest_recv_time => undef
+ dest_recv_time => undef,
+ cancel_time => undef
},
{
flesh => 1,
prev_hop INT REFERENCES action.transit_copy (id) DEFERRABLE INITIALLY DEFERRED,
copy_status INT NOT NULL REFERENCES config.copy_status (id) DEFERRABLE INITIALLY DEFERRED,
persistant_transfer BOOL NOT NULL DEFAULT FALSE,
- prev_dest INT REFERENCES actor.org_unit (id) DEFERRABLE INITIALLY DEFERRED
+ prev_dest INT REFERENCES actor.org_unit (id) DEFERRABLE INITIALLY DEFERRED,
+ cancel_time TIMESTAMP WITH TIME ZONE
);
CREATE INDEX active_transit_dest_idx ON "action".transit_copy (dest);
CREATE INDEX active_transit_source_idx ON "action".transit_copy (source);
--- /dev/null
+BEGIN;
+
+SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+
+ALTER TABLE action.transit_copy
+ ADD COLUMN cancel_time TIMESTAMPTZ;
+
+COMMIT;