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

svn at svn.open-ils.org svn at svn.open-ils.org
Thu Feb 7 11:04:40 EST 2008


Author: erickson
Date: 2008-02-07 10:36:04 -0500 (Thu, 07 Feb 2008)
New Revision: 8682

Modified:
   branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Application/Acq/Financials.pm
Log:
added fund summary fleshing to fund.retrieve and fund.org.retrieve



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-07 15:10:00 UTC (rev 8681)
+++ branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Application/Acq/Financials.pm	2008-02-07 15:36:04 UTC (rev 8682)
@@ -186,12 +186,14 @@
 );
 
 sub retrieve_fund {
-    my($self, $conn, $auth, $fund_id) = @_;
+    my($self, $conn, $auth, $fund_id, $options) = @_;
     my $e = new_editor(authtoken=>$auth);
     return $e->event unless $e->checkauth;
     my $fund = $e->retrieve_acq_fund($fund_id) or return $e->event;
     return $e->event unless
         $e->allowed(['ADMIN_FUND','MANAGE_FUND'], $fund->org);
+    $fund->summary(retrieve_fund_summary_impl($e, $fund))
+        if $$options{flesh_summary};
     return $fund;
 }
 
@@ -204,8 +206,10 @@
             {desc => 'Authentication token', type => 'string'},
             {desc => 'List of org Unit IDs.  If no IDs are provided, this method returns the 
                 full set of funding sources this user has permission to view', type => 'number'},
-            {desc => q/Limiting permission.  this permission is used find the work-org tree from which  
-                the list of orgs is generated if no org ids are provided.  
+            {desc => q/Options hash.  
+                "limit_perm" -- this permission is used find the work-org tree from which  
+                the list of orgs is generated if no org ids are provided.  The default is ADMIN_FUND.
+                "flesh_summary" -- if true, the summary field on each fund is fleshed
                 The default is ADMIN_FUND/, type => 'string'},
         ],
         return => {desc => 'The fund objects on success, Event on failure'}
@@ -213,16 +217,24 @@
 );
 
 sub retrieve_org_funds {
-    my($self, $conn, $auth, $org_id_list, $limit_perm) = @_;
+    my($self, $conn, $auth, $org_id_list, $options) = @_;
     my $e = new_editor(authtoken=>$auth);
     return $e->event unless $e->checkauth;
 
-    $limit_perm ||= 'ADMIN_FUND';
+    my $limit_perm = ($$options{limit_perm}) ? $$options{limit_perm} : 'ADMIN_FUND';
 
     my $org_ids = ($org_id_list and @$org_id_list) ? $org_id_list :
         $U->find_highest_work_orgs($e, $limit_perm, {descendants =>1});
     return [] unless @$org_ids;
-    return $e->search_acq_fund({org => $org_ids});
+    my $funds = $e->search_acq_fund({org => $org_ids});
+
+    if($$options{flesh_summary}) {
+        for my $fund (@$funds) {
+            $fund->summary(retrieve_fund_summary_impl($e, $fund));
+        }
+    }
+
+    return $funds;
 }
 
 __PACKAGE__->register_method(
@@ -244,14 +256,20 @@
     return $e->event unless $e->checkauth;
     my $fund = $e->retrieve_acq_fund($fund_id) or return $e->event;
     return $e->event unless $e->allowed('MANAGE_FUND', $fund->org);
+    return retrieve_fund_summary_impl($e, $fund);
+}
 
-    my $at = $e->search_acq_fund_allocation_total({fund => $fund_id})->[0];
-    my $dt = $e->search_acq_fund_debit_total({fund => $fund_id})->[0];
-    my $et = $e->search_acq_fund_encumberance_total({fund => $fund_id})->[0];
-    my $st = $e->search_acq_fund_spent_total({fund => $fund_id})->[0];
-    my $cb = $e->search_acq_fund_combined_balance({fund => $fund_id})->[0];
-    my $sb = $e->search_acq_fund_spent_balance({fund => $fund_id})->[0];
 
+sub retrieve_fund_summary_impl {
+    my($e, $fund) = @_;
+
+    my $at = $e->search_acq_fund_allocation_total({fund => $fund->id})->[0];
+    my $dt = $e->search_acq_fund_debit_total({fund => $fund->id})->[0];
+    my $et = $e->search_acq_fund_encumberance_total({fund => $fund->id})->[0];
+    my $st = $e->search_acq_fund_spent_total({fund => $fund->id})->[0];
+    my $cb = $e->search_acq_fund_combined_balance({fund => $fund->id})->[0];
+    my $sb = $e->search_acq_fund_spent_balance({fund => $fund->id})->[0];
+
     return {
         allocation_total => ($at) ? $at->amount : 0,
         debit_total => ($dt) ? $dt->amount : 0,



More information about the open-ils-commits mailing list