[open-ils-commits] r17354 - trunk/Open-ILS/src/perlmods/OpenILS/SIP (erickson)
svn at svn.open-ils.org
svn at svn.open-ils.org
Thu Aug 26 13:03:10 EDT 2010
Author: erickson
Date: 2010-08-26 13:03:06 -0400 (Thu, 26 Aug 2010)
New Revision: 17354
Modified:
trunk/Open-ILS/src/perlmods/OpenILS/SIP/Item.pm
Log:
added support for returning hold shelf expire time (CM field) in item info response when an item has been captured for a hold. value is populated if item is on holds shelf or in transit to holds shelf
Modified: trunk/Open-ILS/src/perlmods/OpenILS/SIP/Item.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/SIP/Item.pm 2010-08-26 17:03:05 UTC (rev 17353)
+++ trunk/Open-ILS/src/perlmods/OpenILS/SIP/Item.pm 2010-08-26 17:03:06 UTC (rev 17354)
@@ -151,10 +151,11 @@
atc => [ 'dest' ]
}
}
- ]);
- # warn "Item transit: " . Dumper($transit) . "\nItem transit->dest: " . Dumper($transit->dest);;
+ ])->[0];
+
if ($transit) {
- $self->{destination_loc} = $transit->[0]->dest->shortname;
+ $self->{transit} = $transit;
+ $self->{destination_loc} = $transit->dest->shortname;
} else {
syslog('LOG_WARNING', "OILS: Item('$item_id') status is In Transit, but no action.transit_copy found!");
}
@@ -163,11 +164,12 @@
syslog("LOG_DEBUG", "OILS: Item('$item_id'): found with title '%s'", $self->title_id);
my $config = OpenILS::SIP->config(); # FIXME : will not always match!
+ my $legacy = $config->{implementation_config}->{legacy_script_support} || undef;
- my $legacy = $config->{implementation_config}->{legacy_script_support} || undef;
if( defined $legacy ) {
$self->{legacy_script_support} = ($legacy =~ /t(rue)?/io) ? 1 : 0;
syslog("LOG_DEBUG", "legacy_script_support is set in SIP config: " . $self->{legacy_script_support});
+
} else {
my $lss = OpenSRF::Utils::SettingsClient->new->config_value(
apps => 'open-ils.circ',
@@ -364,8 +366,54 @@
return 0;
}
-sub hold_pickup_date { # TODO
+
+# Note: If the held item is in transit, this will be an approximation of shelf
+# expire time, since the time is not set until the item is checked in at the pickup location
+my %shelf_expire_setting_cache;
+sub hold_pickup_date {
my $self = shift;
+ my $copy = $self->{copy};
+
+ if( ($copy->status->id == OILS_COPY_STATUS_ON_HOLDS_SHELF) ||
+ ($self->{transit} and $self->{transit}->copy_status == OILS_COPY_STATUS_ON_HOLDS_SHELF) ) {
+
+ # item has been captured for a hold
+
+ my $e = OpenILS::SIP->editor();
+ my $hold = $e->search_action_hold_request([
+ {
+ current_copy => $copy->id,
+ capture_time => {'!=' => undef},
+ cancel_time => undef,
+ fulfillment_time => undef
+ },
+ {limit => 1}
+ ])->[0];
+
+ if($hold) {
+ my $date = $hold->shelf_expire_time;
+
+ if(!$date) {
+ # hold has not hit the shelf. create a best guess.
+
+ my $interval = $shelf_expire_setting_cache{$hold->pickup_lib} ||
+ $U->ou_ancestor_setting_value(
+ $hold->pickup_lib,
+ 'circ.holds.default_shelf_expire_interval');
+
+ $shelf_expire_setting_cache{$hold->pickup_lib} = $interval;
+
+ if($interval) {
+ my $seconds = OpenSRF::Utils->interval_to_seconds($interval);
+ $date = DateTime->now->add(seconds => $seconds);
+ $date = $date->strftime('%FT%T%z') if $date;
+ }
+ }
+
+ return OpenILS::SIP->format_date($date) if $date;
+ }
+ }
+
return 0;
}
More information about the open-ils-commits
mailing list