From 8e8b3481b648cee3134333023a5ad53ab4d3c12a Mon Sep 17 00:00:00 2001 From: erickson Date: Wed, 20 Oct 2010 15:23:35 +0000 Subject: [PATCH] during checkin, an item's hold may have a fleshed pickup_lib. added code to detect and protect against treating a ref as an ID. minor cleanup git-svn-id: svn://svn.open-ils.org/ILS/trunk@18402 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/perlmods/OpenILS/SIP.pm | 3 ++- .../perlmods/OpenILS/SIP/Transaction/Checkin.pm | 22 ++++++++++++++++------ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/Open-ILS/src/perlmods/OpenILS/SIP.pm b/Open-ILS/src/perlmods/OpenILS/SIP.pm index d22a5e60af..6d31703ad1 100644 --- a/Open-ILS/src/perlmods/OpenILS/SIP.pm +++ b/Open-ILS/src/perlmods/OpenILS/SIP.pm @@ -151,7 +151,8 @@ sub clean_text { sub shortname_from_id { my $id = shift or return; - return editor()->search_actor_org_unit({id => $id})->[0]->shortname; + return $id->shortname if ref $id; + return editor()->retrieve_actor_org_unit($id)->shortname; } sub patron_barcode_from_id { my $id = shift or return; diff --git a/Open-ILS/src/perlmods/OpenILS/SIP/Transaction/Checkin.pm b/Open-ILS/src/perlmods/OpenILS/SIP/Transaction/Checkin.pm index c662104cec..59b630f3ec 100644 --- a/Open-ILS/src/perlmods/OpenILS/SIP/Transaction/Checkin.pm +++ b/Open-ILS/src/perlmods/OpenILS/SIP/Transaction/Checkin.pm @@ -168,14 +168,24 @@ sub do_checkin { } if ($self->item->hold) { - my $holder = OpenILS::SIP->find_patron('usr' => $self->item->hold->usr) or - syslog('LOG_WARNING', "OpenILS::SIP->find_patron cannot find hold usr => '" . $self->item->hold->usr . "'"); + my ($pickup_lib_id, $pickup_lib_sn); - $self->item->hold_patron_bcode( $holder->id ); - $self->item->hold_patron_name( $holder->name ); # Item already had the holder ID, we really just needed the name - $self->item->destination_loc( OpenILS::SIP::shortname_from_id($self->item->hold->pickup_lib) ); # must use pickup_lib as method + my $holder = OpenILS::SIP->find_patron('usr' => $self->item->hold->usr); - my $atype = ($self->item->hold->pickup_lib == $phys_location) ? '01' : '02'; + if (ref $self->item->hold->pickup_lib) { + $pickup_lib_id = $self->item->hold->pickup_lib->id; + $pickup_lib_sn = $self->item->hold->pickup_lib->shortname; + + } else { + $pickup_lib_id = $self->item->hold->pickup_lib; + $pickup_lib_sn = OpenILS::SIP::shortname_from_id($pickup_lib_id); + } + + $self->item->hold_patron_bcode($holder->id); + $self->item->hold_patron_name($holder->name); + $self->item->destination_loc($pickup_lib_sn); + + my $atype = ($pickup_lib_id == $phys_location) ? '01' : '02'; $self->alert_type($atype); } -- 2.11.0