[open-ils-commits] r19897 - branches/rel_1_6_2/Open-ILS/src/perlmods/OpenILS/SIP (miker)

svn at svn.open-ils.org svn at svn.open-ils.org
Tue Mar 29 12:59:45 EDT 2011


Author: miker
Date: 2011-03-29 12:59:41 -0400 (Tue, 29 Mar 2011)
New Revision: 19897

Modified:
   branches/rel_1_6_2/Open-ILS/src/perlmods/OpenILS/SIP/Patron.pm
Log:
Patch from Brandon Uhlman addressing SIP2 unavailable holds display.

The unavail_holds() function in OpenILS::SIP::Patron is a placeholder that returns an empty set, instead of an actual list of a patrons' holds not cur
rently ready for pickup.

When an SC determines whether a patron has holds ready for pickup by comparing the cardinalities of hold_items() and unavail_holds() [*] using the exi
sting unavail_holds() logic, it effectively reports every currently placed hold as ready for pickup, which is generally not true.

The attached patch assumes that unavailable holds are those that meet one of two sets of conditions:
- hold requests that are not cancelled (cancel_time = null), not fulfilled (fulfillment time = null), and not captured (capture_time = null)
- hold requests that are neither cancelled nor fulfilled (as above), are captured (capture_time != null), and for which, additionally, the current_cop
y does not have the status 'On holds shelf' (status = 8). The only items that should meet this condition are those that are in transit to a location w
here they will be added to the holds shelf.

The patch iterates through the items meeting each condition, and adds them to a master list of relevant holds, which it then processes (in the same wa
y that hold_items is processed) and returns.

This patch was developed against and tested on rel_1_6_0 from SVN (~ 1.6.0.2), but should apply cleanly against current rel_1_6_0 and trunk; OpenSRF 1
.2.2, PostgreSQL 8.3.8, Ubuntu Hardy 64-bit.

[*] The two cardinalities are returned by SIP message 64 as fixed-length integers in positions 35-38 and 55-58 respectively, so we don't need to itera
te through the list ourseles.



Modified: branches/rel_1_6_2/Open-ILS/src/perlmods/OpenILS/SIP/Patron.pm
===================================================================
--- branches/rel_1_6_2/Open-ILS/src/perlmods/OpenILS/SIP/Patron.pm	2011-03-29 16:58:48 UTC (rev 19896)
+++ branches/rel_1_6_2/Open-ILS/src/perlmods/OpenILS/SIP/Patron.pm	2011-03-29 16:59:41 UTC (rev 19897)
@@ -504,11 +504,27 @@
 }
 
 sub unavail_holds {
-	my ($self, $start, $end) = @_;
-	my @holds;
-	syslog('LOG_DEBUG', 'OILS: Patron->unavail_holds()');
-	return (defined $start and defined $end) ? 
-		[ $holds[($start-1)..($end-1)] ] : \@holds;
+     my ($self, $start, $end) = @_;
+     syslog('LOG_DEBUG', 'OILS: Patron->unavail_holds()');
+ 
+     # Unavailable holds fall into two groups: holds not yet captured (capture_time is null),
+     # and holds captured but not yet on the holds shelf (status <> 8 ['On holds shelf'])
+     # meaning the item is in transit, or you have a bad data issue
+ 
+     my $captured_but_not_waiting_holds = [{ usr => $self->{user}->id, fulfillment_time => undef, cancel_time => undef, capture_time => {'!=', undef}, '+acp' => {status => {'!=', 8}}}, {'join' => 'acp'}];
+     my $uncaptured_holds = { usr => $self->{user}->id, fulfillment_time => undef, cancel_time => undef, capture_time => undef };
+ 
+     my @holds_sip_output;
+ 
+     foreach my $unavail_item_query ($captured_but_not_waiting_holds, $uncaptured_holds)
+     {
+         my $holds_queried_data = $self->{editor}->search_action_hold_request($unavail_item_query);
+         push( @holds_sip_output, OpenILS::SIP::clean_text($self->__hold_to_title($_)) ) for @$holds_queried_data;
+     }
+ 
+     return (defined $start and defined $end) ?
+         [ @holds_sip_output[($start-1)..($end-1)] ] :
+         \@holds_sip_output;
 }
 
 sub block {



More information about the open-ils-commits mailing list