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

svn at svn.open-ils.org svn at svn.open-ils.org
Wed Feb 10 17:10:19 EST 2010


Author: erickson
Date: 2010-02-10 17:10:13 -0500 (Wed, 10 Feb 2010)
New Revision: 15499

Modified:
   trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Financials.pm
Log:
updated the reporting output. limited returned funds to funds that are propagable and returning the rollover amount for funds whose balances rolled to the following year's funds

Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Financials.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Financials.pm	2010-02-10 21:45:59 UTC (rev 15498)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Acq/Financials.pm	2010-02-10 22:10:13 UTC (rev 15499)
@@ -1329,6 +1329,8 @@
     return $e->die_event unless $e->checkauth;
     return $e->die_event unless $e->allowed('ADMIN_FUND', $org_id);
 
+    my $combined = ($self->api_name =~ /combined/); 
+
     my $org_ids = ($descendants) ? 
         [   
             map 
@@ -1349,7 +1351,7 @@
         ]
     });
 
-    if($self->api_name =~ /combined/) {
+    if($combined) {
 
         # Roll the uncumbrances over to next year's funds
         # Mark the funds for $year as inactive
@@ -1364,13 +1366,34 @@
         });
     }
 
-    # Fetch all funds for the specified org units for return to call w/ summary
-    my $fund_ids = $e->search_acq_fund({year => int($year) + 1, org => $org_ids});
+    # Fetch all funds for the specified org units for the subsequent year
+    my $fund_ids = $e->search_acq_fund(
+        {
+            year => int($year) + 1, 
+            org => $org_ids,
+            propagate => 't'
+        }, 
+        {idlist => 1}
+    );
 
     foreach (@$fund_ids) {
         my $fund = $e->retrieve_acq_fund($_) or return $e->die_event;
         $fund->summary(retrieve_fund_summary_impl($e, $fund));
-        $conn->respond($fund);
+
+        my $amount = 0;
+        if($combined and $U->is_true($fund->rollover)) {
+            # see how much money was rolled over
+
+            my $sum = $e->json_query({
+                select => {acqftr => [{column => 'dest_amount', transform => 'sum'}]}, 
+                from => 'acqftr', 
+                where => {dest_fund => $fund->id, note => 'Rollover'}
+            })->[0];
+
+            $amount = $sum->{dest_amount} if $sum;
+        }
+
+        $conn->respond({fund => $fund, rollover_amount => $amount});
     }
 
     $self->api_name =~ /dry_run/ and $e->rollback or $e->commit;



More information about the open-ils-commits mailing list