added companion api call to fund list retrieval which returns unique set of fund...
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 17 Aug 2009 16:12:06 +0000 (16:12 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 17 Aug 2009 16:12:06 +0000 (16:12 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@13846 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/Acq/Financials.pm

index 4c843f4..54e7a72 100644 (file)
@@ -285,6 +285,11 @@ __PACKAGE__->register_method(
     }
 );
 
+__PACKAGE__->register_method(
+       method => 'retrieve_org_funds',
+       api_name        => 'open-ils.acq.fund.org.years.retrieve');
+
+
 sub retrieve_org_funds {
     my($self, $conn, $auth, $filter, $options) = @_;
     my $e = new_editor(authtoken=>$auth);
@@ -300,7 +305,6 @@ sub retrieve_org_funds {
         $U->user_has_work_perm_at($e, $limit_perm, {descendants =>1});
     return undef unless @{$filter->{org}};
 
-
     my $query = [
         $filter,
         {
@@ -310,6 +314,19 @@ sub retrieve_org_funds {
         }
     ];
 
+    if($self->api_name =~ /years/) {
+        # return the distinct set of fund years covered by the selected funds
+        my $data = $e->json_query({
+            select => {
+                acqf => [{column => 'year', transform => 'distinct'}]
+            }, 
+            from => 'acqf', 
+            where => $filter}
+        );
+
+        return [map { $_->{year} } @$data];
+    }
+
     my $funds = $e->search_acq_fund($query);
 
     for my $fund (@$funds) {