[open-ils-commits] r15465 - trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq (phasefx)

svn at svn.open-ils.org svn at svn.open-ils.org
Fri Feb 5 15:11:38 EST 2010


Author: phasefx
Date: 2010-02-05 15:11:33 -0500 (Fri, 05 Feb 2010)
New Revision: 15465

Modified:
   trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Financials.pm
Log:
For now, limit the purchase order targeting event retrieval methods to those with EDI related event hooks in their definitions.

Cancel/reset methods for events targeting purchase orders.



Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Financials.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Financials.pm	2010-02-05 19:31:07 UTC (rev 15464)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Financials.pm	2010-02-05 20:11:33 UTC (rev 15465)
@@ -1033,18 +1033,36 @@
     method        => 'po_events',
     api_name    => 'open-ils.acq.purchase_order.events.owner',
     stream      => 1,
+    signature => q/
+        Retrieve EDI-related purchase order events (format.po.jedi), by default those which are pending.
+        @param authtoken Login session key
+        @param owner Id or array of id's for the purchase order Owner field.  Filters the events to just those pertaining to PO's meeting this criteria.
+        @param options Object for tweaking the selection criteria and fleshing options.
+    /
 );
 
 __PACKAGE__->register_method (
     method        => 'po_events',
     api_name    => 'open-ils.acq.purchase_order.events.ordering_agency',
     stream      => 1,
+    signature => q/
+        Retrieve EDI-related purchase order events (format.po.jedi), by default those which are pending.
+        @param authtoken Login session key
+        @param owner Id or array of id's for the purchase order Ordering Agency field.  Filters the events to just those pertaining to PO's meeting this criteria.
+        @param options Object for tweaking the selection criteria and fleshing options.
+    /
 );
 
 __PACKAGE__->register_method (
     method        => 'po_events',
     api_name    => 'open-ils.acq.purchase_order.events.id',
     stream      => 1,
+    signature => q/
+        Retrieve EDI-related purchase order events (format.po.jedi), by default those which are pending.
+        @param authtoken Login session key
+        @param owner Id or array of id's for the purchase order Id field.  Filters the events to just those pertaining to PO's meeting this criteria.
+        @param options Object for tweaking the selection criteria and fleshing options.
+    /
 );
 
 sub po_events {
@@ -1066,6 +1084,15 @@
                     "where"=>{$search_field=>$search_value}
                 }
             }, 
+            "event_def"=>{
+                "in"=>{
+                    "select"=>{atevdef=>["id"]},
+                    "from"=>"atevdef",
+                    "where"=>{
+                        "hook"=>"format.po.jedi"
+                    }
+                }
+            },
             "state"=>"pending" 
         }
     };
@@ -1106,5 +1133,57 @@
     return undef;
 }
 
+__PACKAGE__->register_method (
+	method		=> 'update_po_events',
+    api_name    => 'open-ils.acq.purchase_order.event.cancel.batch',
+    stream      => 1,
+);
+__PACKAGE__->register_method (
+	method		=> 'update_po_events',
+    api_name    => 'open-ils.acq.purchase_order.event.reset.batch',
+    stream      => 1,
+);
+
+sub update_po_events {
+    my($self, $conn, $auth, $event_ids) = @_;
+    my $e = new_editor(xact => 1, authtoken => $auth);
+    return $e->die_event unless $e->checkauth;
+
+    my $x = 1;
+    for my $id (@$event_ids) {
+
+        # do a little dance to determine what libraries we are ultimately affecting
+        my $event = $e->retrieve_action_trigger_event([
+            $id,
+            {   flesh => 2,
+                flesh_fields => {atev => ['event_def'], atevdef => ['hook']}
+            }
+        ]) or return $e->die_event;
+
+        my $po = retrieve_purchase_order_impl(
+            $e,
+            $event->target(),
+            {}
+        );
+
+        return $e->die_event unless $e->allowed( ['CREATE_PURCHASE_ORDER','VIEW_PURCHASE_ORDER'], $po->ordering_agency() );
+
+        if($self->api_name =~ /cancel/) {
+            $event->state('invalid');
+        } elsif($self->api_name =~ /reset/) {
+            $event->clear_start_time;
+            $event->clear_update_time;
+            $event->state('pending');
+        }
+
+        $e->update_action_trigger_event($event) or return $e->die_event;
+        $conn->respond({maximum => scalar(@$event_ids), progress => $x++});
+    }
+
+    $e->commit;
+    return {complete => 1};
+}
+
+
 1;
 



More information about the open-ils-commits mailing list