retrieve_purchase_order now handles multiple PO requests
authorsboyette <sboyette@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 2 Feb 2010 15:08:04 +0000 (15:08 +0000)
committersboyette <sboyette@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 2 Feb 2010 15:08:04 +0000 (15:08 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@15430 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/Acq/Financials.pm

index c6a454c..b5bb788 100644 (file)
@@ -898,31 +898,41 @@ sub search_purchase_order {
 
 
 __PACKAGE__->register_method(
-       method => 'retrieve_purchase_order',
-       api_name        => 'open-ils.acq.purchase_order.retrieve',
-       signature => {
-        desc => 'Retrieves a purchase order',
-        params => [
-            {desc => 'Authentication token', type => 'string'},
-            {desc => 'purchase_order to retrieve', type => 'number'},
-            {desc => q/Options hash.  flesh_lineitems, to get the lineitems and lineitem_attrs; 
+        method    => 'retrieve_purchase_order',
+        api_name  => 'open-ils.acq.purchase_order.retrieve',
+        stream    => 1,
+        signature => {
+                      desc      => 'Retrieves a purchase order',
+                      params    => [
+                                    {desc => 'Authentication token', type => 'string'},
+                                    {desc => 'purchase_order to retrieve', type => 'number'},
+                                    {desc => q/Options hash.  flesh_lineitems, to get the lineitems and lineitem_attrs;
                 clear_marc, to clear the MARC data from the lineitem (for reduced bandwidth)
                 li_limit : number of lineitems to return if fleshing line items;
                 li_offset : lineitem offset if fleshing line items
                 li_order_by : lineitem sort definition if fleshing line items
-                /, 
-                type => 'hash'}
-        ],
-        return => {desc => 'The purchase order, Event on failure'}
-    }
+                /,
+                                     type => 'hash'}
+                                   ],
+                      return => {desc => 'The purchase order, Event on failure'}
+                     }
 );
 
 sub retrieve_purchase_order {
     my($self, $conn, $auth, $po_id, $options) = @_;
     my $e = new_editor(authtoken=>$auth);
     return $e->event unless $e->checkauth;
-    return $e->event if po_perm_failure($e, $po_id);
-    return retrieve_purchase_order_impl($e, $po_id, $options);
+
+    $po_id = [ $po_id ] unless ref $po_id;
+    for ( @{$po_id} ) {
+        my $rv;
+        if ( po_perm_failure($e, $_) )
+          { $rv = $e->event }
+        else
+          { $rv =  retrieve_purchase_order_impl($e, $_, $options) }
+
+        $conn->respond($rv);
+    }
 }