[open-ils-commits] r13596 - trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ (erickson)

svn at svn.open-ils.org svn at svn.open-ils.org
Wed Jul 15 10:06:39 EDT 2009


Author: erickson
Date: 2009-07-15 10:06:37 -0400 (Wed, 15 Jul 2009)
New Revision: 13596

Modified:
   trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm
Log:
patched up some logic bugs, fixed some typos

Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm	2009-07-15 12:22:34 UTC (rev 13595)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm	2009-07-15 14:06:37 UTC (rev 13596)
@@ -1290,11 +1290,15 @@
         $hold = undef;
     }
 
-    $hold = $self->find_related_uncaptured_hold($copy, $patron) unless $hold;
+    unless($hold) {
+        $hold = $self->find_related_user_hold($copy, $patron) or return;
+        $logger->info("circulator: found related hold to fulfill in checkout");
+    }
 
-    $logger->debug("circulator: checkout filfilling hold " . $hold->id);
+    $logger->debug("circulator: checkout fulfilling hold " . $hold->id);
 
     # if the hold was never officially captured, capture it.
+    $hold->current_copy($copy->id);
     $hold->capture_time('now') unless $hold->capture_time;
     $hold->fulfillment_time('now');
     $hold->fulfillment_staff($e->requestor->id);
@@ -1314,33 +1318,37 @@
 # (with hold_type T or V) for the patron that could be fulfilled by the checked 
 # out item.  Fulfill the oldest hold and only fulfill 1 of them.
 # ------------------------------------------------------------------------------
-sub find_related_uncaptured_hold {
+sub find_related_user_hold {
     my($self, $copy, $patron) = @_;
     my $e = $self->editor;
 
     return undef if $self->volume->id == OILS_PRECAT_CALL_NUMBER; 
 
     return undef unless $U->ou_ancestor_setting_value(        
-        $self->requestor->ws_ou, 'circ.checkout_fills_related_hold', $e);
+        $e->requestor->ws_ou, 'circ.checkout_fills_related_hold', $e);
 
-    my $args = {
-        cancel_time => undef, 
-        fulfillment_time => undef,
-        usr => $patron->id,
-        order_by => {ahr => 'request_time asc'},
-        '-or' => [
-            {expire_time => undef},
-            {expire_time => {'>' => 'now'}}
-        ]
-    };
+    my $args = [
+        {   
+            cancel_time => undef, 
+            fulfillment_time => undef,
+            usr => $patron->id,
+            '-or' => [
+                {expire_time => undef},
+                {expire_time => {'>' => 'now'}}
+            ]
+        }, {
+            order_by => {ahr => 'request_time asc'}, 
+            limit => 1
+        }
+    ];
 
-    $args->{hold_type} = 'V';
-    $args->{target} = $self->volume->id;
-    my $v_hold = $e->search_action_hold_request([$args, {limit => 1}])->[0];
+    $args->[0]->{hold_type} = 'V';
+    $args->[0]->{target} = $self->volume->id;
+    my $v_hold = $e->search_action_hold_request($args)->[0];
 
-    $args->{hold_type} = 'T';
-    $args->{target} = $self->title->id;
-    my $t_hold = $e->search_action_hold_request([$args, {limit => 1}])->[0];
+    $args->[0]->{hold_type} = 'T';
+    $args->[0]->{target} = $self->title->id;
+    my $t_hold = $e->search_action_hold_request($args)->[0];
 
     if($t_hold and $v_hold) {
 



More information about the open-ils-commits mailing list