From: Bill Erickson Date: Tue, 27 Dec 2011 18:18:08 +0000 (-0500) Subject: Hold current_shelf_lib API for setting/clearing. X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=46a751a8a8ded31c2dd7cfe96d9385e9037c353f;p=evergreen%2Fmasslnc.git Hold current_shelf_lib API for setting/clearing. Sets and clears the hold.current_shelf_lib value as appropriate during hold capture, transit checkin, hold resetting, etc. Also, we now create hold transits (instead of regular transits) when a captured copy is (unexpectedly) found at the wrong branch and needs to transit to the pickup lib. This can happen if the captured copy simply transits to the wrong place (existing behavior) or the pickup lib for the hold was changed while the copy was on the shelf (new behavior). Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm index 50ef6d6d73..406bd2492f 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm @@ -1655,6 +1655,7 @@ sub handle_checkout_holds { $hold->clear_capture_time; $hold->clear_shelf_time; $hold->clear_shelf_expire_time; + $hold->clear_current_shelf_lib; return $self->bail_on_event($e->event) unless $e->update_action_hold_request($hold); @@ -2798,23 +2799,42 @@ sub checkin_build_copy_transit { my $self = shift; my $dest = shift; my $copy = $self->copy; - my $transit = Fieldmapper::action::transit_copy->new; + my $transit = Fieldmapper::action::transit_copy->new; + + # if we are transiting an item to the shelf shelf, it's a hold transit + if (my $hold = $self->remote_hold) { + $transit = Fieldmapper::action::hold_transit_copy->new; + $transit->hold($hold->id); + + # the item is going into transit, remove any shelf-iness + if ($hold->current_shelf_lib or $hold->shelf_time) { + $hold->clear_current_shelf_lib; + $hold->clear_shelf_time; + return $self->bail_on_events($self->editor->event) + unless $self->editor->update_action_hold_request($hold); + } + } #$dest ||= (ref($copy->circ_lib)) ? $copy->circ_lib->id : $copy->circ_lib; $logger->info("circulator: transiting copy to $dest"); - $transit->source($self->circ_lib); - $transit->dest($dest); - $transit->target_copy($copy->id); - $transit->source_send_time('now'); - $transit->copy_status( $U->copy_status($copy->status)->id ); + $transit->source($self->circ_lib); + $transit->dest($dest); + $transit->target_copy($copy->id); + $transit->source_send_time('now'); + $transit->copy_status( $U->copy_status($copy->status)->id ); $logger->debug("circulator: setting copy status on transit: ".$transit->copy_status); - return $self->bail_on_events($self->editor->event) - unless $self->editor->create_action_transit_copy($transit); + if ($self->remote_hold) { + return $self->bail_on_events($self->editor->event) + unless $self->editor->create_action_hold_transit_copy($transit); + } else { + return $self->bail_on_events($self->editor->event) + unless $self->editor->create_action_transit_copy($transit); + } - $copy->status(OILS_COPY_STATUS_IN_TRANSIT); + $copy->status(OILS_COPY_STATUS_IN_TRANSIT); $self->update_copy; $self->checkin_changed(1); } @@ -3171,6 +3191,7 @@ sub put_hold_on_shelf { my($self, $hold) = @_; $hold->shelf_time('now'); + $hold->current_shelf_lib($self->circ_lib); my $shelf_expire = $U->ou_ancestor_setting_value( $self->circ_lib, 'circ.holds.default_shelf_expire_interval', $self->editor); diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm index 6705d617de..d35e13d5ac 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm @@ -672,6 +672,7 @@ sub uncancel_hold { $hold->clear_capture_time; $hold->clear_prev_check_time; $hold->clear_shelf_expire_time; + $hold->clear_current_shelf_lib; $e->update_action_hold_request($hold) or return $e->die_event; $e->commit; @@ -1796,6 +1797,7 @@ sub _reset_hold { $hold->clear_current_copy; $hold->clear_shelf_time; $hold->clear_shelf_expire_time; + $hold->clear_current_shelf_lib; $e->update_action_hold_request($hold) or return $e->die_event; $e->commit;