[open-ils-commits] r8807 - branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Application/Acq

svn at svn.open-ils.org svn at svn.open-ils.org
Wed Feb 20 17:44:39 EST 2008


Author: erickson
Date: 2008-02-20 17:14:12 -0500 (Wed, 20 Feb 2008)
New Revision: 8807

Modified:
   branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Application/Acq/Financials.pm
Log:
added entry count fleshing to line items in po fetching

Modified: branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Application/Acq/Financials.pm
===================================================================
--- branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Application/Acq/Financials.pm	2008-02-20 22:11:47 UTC (rev 8806)
+++ branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Application/Acq/Financials.pm	2008-02-20 22:14:12 UTC (rev 8807)
@@ -581,6 +581,7 @@
                 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
+                flesh_lineitem_detail_count : flesh lineitem_detail_count field
                 /,
                 type => 'hash'}
         ],
@@ -631,6 +632,7 @@
                 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
+                flesh_lineitem_detail_count : flesh lineitem_detail_count field
                 /, 
                 type => 'hash'}
         ],
@@ -688,6 +690,13 @@
             $_->clear_marc for @$items;
         }
 
+        if($$options{flesh_lineitem_details_count}) {
+            for my $item (@$items) {
+                my $ids = $e->search_acq_po_li_detail({po_lineitem => $item->id}, {idlist => 1});
+                $item->lineitem_details_count(scalar(@$ids));
+            }
+        }
+
         $po->lineitems($items);
     }
 
@@ -722,22 +731,8 @@
     return $e->die_event unless $e->checkauth;
     $options ||= {};
 
-    return $e->die_event if 
-        po_perm_failure($e, $po_li->purchase_order, $po_li->fund);
+    return $e->die_event if po_perm_failure($e, $po_li->purchase_order);
 
-#    my $po = $e->retrieve_acq_purchase_order($po_li->purchase_order)
-#        or return $e->die_event;
-#
-#    my $provider = $e->retrieve_acq_provider($po->provider)
-#        or return $e->die_event;
-#
-#    return $e->die_event unless $e->allowed('MANAGE_PROVIDER', $provider->owner, $provider);
-#
-#    if($e->requestor->id != $po->owner) {
-#        return $e->die_event unless 
-#            $e->allowed('MANAGE_PURCHASE_ORDER', $provider->owner, $po);
-#    }
-
     # if a picklist_entry ID is provided, use that as the basis for this item
     my $ple = $e->retrieve_acq_picklist_entry([
         $$options{picklist_entry}, 
@@ -746,14 +741,6 @@
 
     $po_li->marc($ple->marc);
     $po_li->eg_bib_id($ple->eg_bib_id);
-
-#    if($po_li->fund) {
-#        # check fund perms if using the non-default fund
-#        my $fund = $e->retrieve_acq_fund($po_li->fund)
-#            or return $e->die_event;
-#        return $e->die_event unless $e->allowed('MANAGE_FUND', $fund->org, $fund);
-#    }
-
     $e->create_acq_po_lineitem($po_li) or return $e->die_event;
 
     for my $plea (@{$ple->attributes}) {
@@ -803,7 +790,7 @@
     my $po = $e->retrieve_acq_purchase_order($po_li->purchase_order);
     my $provider = $e->retrieve_acq_provider($po->provider);
 
-    my $fund = $e->retrieve_acq_fund($$options{fund_id})
+    my $fund = $e->retrieve_acq_fund($li_detail->fund)
         or return $e->die_event;
 
     if($e->requestor->id != $po->owner) {
@@ -844,7 +831,8 @@
         params => [
             {desc => 'Authentication token', type => 'string'},
             {desc => 'po_lineitem ID', type => 'number'},
-            {desc => q/Options hash.  /, 
+            {desc => q/Options hash. flesh_li_details: fleshes the details objects, which
+                additionally flesh the fund_debit and fund objects/, 
                 type => 'hash'}
         ],
         return => {desc => 'The lineitem object, Event on failure'}
@@ -858,13 +846,19 @@
     $options ||= {};
 
     my $po_li = $e->retrieve_acq_po_lineitem($li_id) or return $e->event;
-    return $e->die_event if po_perm_failure($e, $po_li->purchase_order, $po_li->fund);
+    return $e->die_event if po_perm_failure($e, $po_li->purchase_order);
 
     if($$options{flesh_li_details}) {
-        my $details = $e->search_acq_po_li_detail({po_lineitem => $li_id});
+        my $details = $e->search_acq_po_li_detail([
+            {po_lineitem => $li_id}, {
+                flesh => 1,
+                flesh_fields => {acqpolid => ['fund_debit', 'fund']}
+            }
+        ]);
         $po_li->lineitem_details($details);
     }
 
+
     if($$options{flesh_li_attrs}) {
         my $attrs = $e->search_acq_po_li_attr({po_lineitem => $li_id});
         $po_li->attributes($attrs);
@@ -875,5 +869,4 @@
 }
 
 
-
 1;



More information about the open-ils-commits mailing list