added some fund and funding_source fleshing flags. showing basic allocation summary...
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 12 Feb 2008 23:24:17 +0000 (23:24 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 12 Feb 2008 23:24:17 +0000 (23:24 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/branches/acq-experiment@8735 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/Acq/Financials.pm
Open-ILS/web/oilsweb/oilsweb/controllers/acq/fund.py
Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/view_fund.html

index 0a66d94..780ef44 100644 (file)
@@ -83,9 +83,11 @@ sub retrieve_funding_source {
     my($self, $conn, $auth, $funding_source_id, $options) = @_;
     my $e = new_editor(authtoken=>$auth);
     return $e->event unless $e->checkauth;
+
     my $flesh = {flesh => 1, flesh_fields => {acqfs => []}};
     push(@{$flesh->{flesh_fields}->{acqfs}}, 'credits') if $$options{flesh_credits};
     push(@{$flesh->{flesh_fields}->{acqfs}}, 'allocations') if $$options{flesh_allocations};
+
     my $funding_source = $e->retrieve_acq_funding_source([$funding_source_id, $flesh]) or return $e->event;
     return $e->event unless $e->allowed(
         ['ADMIN_FUNDING_SOURCE','MANAGE_FUNDING_SOURCE'], $funding_source->owner, $funding_source); 
@@ -244,9 +246,10 @@ sub retrieve_fund {
     my $e = new_editor(authtoken=>$auth);
     return $e->event unless $e->checkauth;
 
-    my $flesh = {flesh => 1, flesh_fields => {acqf => []}};
+    my $flesh = {flesh => 2, flesh_fields => {acqf => []}};
     push(@{$flesh->{flesh_fields}->{acqf}}, 'debits') if $$options{flesh_debits};
     push(@{$flesh->{flesh_fields}->{acqf}}, 'allocations') if $$options{flesh_allocations};
+    push(@{$flesh->{flesh_fields}->{acqfa}}, 'funding_source') if $$options{flesh_allocation_sources};
 
     my $fund = $e->retrieve_acq_fund([$fund_id, $flesh]) or return $e->event;
     return $e->event unless $e->allowed(['ADMIN_FUND','MANAGE_FUND'], $fund->org, $fund);
index f007d3e..2620a18 100644 (file)
@@ -26,8 +26,12 @@ class FundController(BaseController):
         fund_id = kwargs['id']
         ses = ClientSession(oils.const.OILS_APP_ACQ)
 
-        # grab the fund object
-        fund = self._retrieve_fund(r, ses, fund_id)
+        fund = ses.request('open-ils.acq.fund.retrieve', 
+            r.ctx.core.authtoken, fund_id, 
+            {"flesh_summary":1, 'flesh_allocations':1, 'flesh_allocation_sources':1}).recv().content()
+        Event.parse_and_raise(fund)
+        fund.org(OrgUtil.get_org_unit(fund.org())) # flesh the org
+
         r.ctx.acq.fund = fund
         return r.render('acq/financial/view_fund.html')
 
index 96d2085..745b437 100644 (file)
@@ -4,10 +4,12 @@
 <%def name="page_title()">${_('View Fund')}</%def>
 <%def name="block_content()">
 
+<% fund = c.oils.acq.fund %>
+
 <div id='oils-acq-list-header' class='container'>
-    <div id='oils-acq-list-header-label'>${c.oils.acq.fund.name()}</div>
+    <div id='oils-acq-list-header-label'>${fund.name()}</div>
     <div id='oils-acq-list-header-create'>
-        <a href='${c.oils.acq.prefix}/fund/allocate?${c.oils.acq.fund_id_.cgi_name}=${c.oils.acq.fund.id()}'>${_('Allocate Money')}</a>
+        <a href='${c.oils.acq.prefix}/fund/allocate?${c.oils.acq.fund_id_.cgi_name}=${fund.id()}'>${_('Allocate Money')}</a>
     </div>
 </div>
 
     <tbody>
         <tr>
             <td class='oils-admin-label'>${_('Owner')}</td>
-            <td>${c.oils.acq.fund.org().name()}</td> 
+            <td>${fund.org().name()}</td> 
         </tr>
         <tr>
             <td class='oils-admin-label'>${_('Currency')}</td>
-            <td>${c.oils.acq.fund.currency_type()}</td> 
+            <td>${fund.currency_type()}</td> 
         </tr>
         <tr>
             <td class='oils-admin-label'>${_('Year')}</td>
-            <td>${c.oils.acq.fund.year()}</td> 
+            <td>${fund.year()}</td> 
         </tr>
         <tr>
             <td class='oils-admin-label'>${_('Amount Allocated to this Fund')}</td>
-            <td>${c.oils.acq.fund.summary()['allocation_total']}</td> 
+            <td>${fund.summary()['allocation_total']}</td> 
         </tr>
         <tr>
             <td class='oils-admin-label'>${_('Balance (Total - (Spent + Encumberances))')}</td>
-            <td>${c.oils.acq.fund.summary()['combined_balance']}</td> 
+            <td>${fund.summary()['combined_balance']}</td> 
         </tr>
         <tr>
             <td class='oils-admin-label'>${_('Spent Balance (Total - Spent)')}</td>
-            <td>${c.oils.acq.fund.summary()['spent_balance']}</td> 
+            <td>${fund.summary()['spent_balance']}</td> 
        </tr>
        <tr>
             <td class='oils-admin-label'>${_('Total Debits (Spent + Encumbered)')}</td>
-            <td>${c.oils.acq.fund.summary()['debit_total']}</td> 
+            <td>${fund.summary()['debit_total']}</td> 
         </tr>
         <tr>
             <td class='oils-admin-label'>${_('Total Spent')}</td>
-            <td>${c.oils.acq.fund.summary()['spent_total']}</td> 
+            <td>${fund.summary()['spent_total']}</td> 
         </tr>
         <tr>
             <td class='oils-admin-label'>${_('Total Encumbered')}</td>
-            <td>${c.oils.acq.fund.summary()['encumberance_total']}</td> 
+            <td>${fund.summary()['encumberance_total']}</td> 
         </tr>
     </tbody>
 </table>
+
+<h3>${_('Fund Allocations')}</h3>
+<table class='oils-admin-table'>
+    <thead>
+        <tr>
+            <td>${_('Funding Source')}</td>
+            <td>${_('Amount/Percent')}</td>
+        </tr>
+    </thead>
+    <tbody>
+        % for alloc in fund.allocations():
+        <tr>
+            <td>${alloc.funding_source().name()}</td> 
+            % if alloc.amount() != 0 and alloc.amount() is not None:
+                <td>${alloc.amount()}</td> 
+            % else:
+                <% percent = _('%(p)s%%') % {'p':alloc.percent()} %>
+                <td>${percent}</td> 
+            % endif
+        </tr>
+        % endfor
+    </tbody>
+</table>
+
 </%def>