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

svn at svn.open-ils.org svn at svn.open-ils.org
Fri Feb 12 13:33:26 EST 2010


Author: phasefx
Date: 2010-02-12 13:33:22 -0500 (Fri, 12 Feb 2010)
New Revision: 15525

Modified:
   trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Financials.pm
Log:
method for creating/running format related lineitem events, modeled off the one for 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-12 17:21:43 UTC (rev 15524)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Financials.pm	2010-02-12 18:33:22 UTC (rev 15525)
@@ -1088,6 +1088,36 @@
     return $U->fire_object_event(undef, $hook, $po, $po->ordering_agency);
 }
 
+__PACKAGE__->register_method(
+	method => 'format_lineitem',
+	api_name	=> 'open-ils.acq.lineitem.format'
+);
+
+sub format_lineitem {
+    my($self, $conn, $auth, $li_id, $format) = @_;
+    my $e = new_editor(authtoken=>$auth);
+    return $e->event unless $e->checkauth;
+
+    my $li = $e->retrieve_acq_lineitem($li_id) or return $e->event;
+
+    my $context_org;
+    if (defined $li->purchase_order) {
+        my $po = $e->retrieve_acq_purchase_order($li->purchase_order) or return $e->die_event;
+        return $e->event unless $e->allowed('VIEW_PURCHASE_ORDER', $po->ordering_agency);
+        $context_org = $po->ordering_agency;
+    } else {
+        my $pl = $e->retrieve_acq_picklist($li->picklist) or return $e->die_event;
+        if($e->requestor->id != $pl->owner) {
+            return $e->event unless
+                $e->allowed('VIEW_PICKLIST', $pl->org_unit, $pl);
+        }
+        $context_org = $pl->org_unit;
+    }
+
+    my $hook = "format.acqli.$format";
+    return $U->fire_object_event(undef, $hook, $li, $context_org);
+}
+
 __PACKAGE__->register_method (
     method        => 'po_events',
     api_name    => 'open-ils.acq.purchase_order.events.owner',



More information about the open-ils-commits mailing list