added fund_allocation creation, added fund summary display
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 6 Feb 2008 21:30:39 +0000 (21:30 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 6 Feb 2008 21:30:39 +0000 (21:30 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/branches/acq-experiment@8675 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/oilsweb/oilsweb/controllers/acq/__init__.py
Open-ILS/web/oilsweb/oilsweb/controllers/acq/fund.py
Open-ILS/web/oilsweb/oilsweb/lib/acq/fund.py
Open-ILS/web/oilsweb/oilsweb/public/oils/media/css/skin/default.css

index dd9100d..c03ccf0 100644 (file)
@@ -33,10 +33,12 @@ class AcqContext(SubContext):
         self.currency_types = ContextItem()
 
         self.fund = ContextItem()
+        self.fund_id = ContextItem(cgi_name='acq.fi')
         self.fund_list = ContextItem()
         self.fund_name = ContextItem(cgi_name='acq.fn')
         self.fund_year = ContextItem(cgi_name='acq.fc')
         self.fund_org = ContextItem(cgi_name='acq.fo')
+        self.fund_summary = ContextItem()
 
         self.fund_source = ContextItem()
         self.fund_source_list = ContextItem()
@@ -44,6 +46,16 @@ class AcqContext(SubContext):
         self.fund_source_currency_type = ContextItem(cgi_name='acq.fc')
         self.fund_source_owner = ContextItem(cgi_name='acq.fo')
 
+
+        self.fund_allocation = ContextItem()
+        self.fund_allocation_list = ContextItem()
+        self.fund_allocation_source= ContextItem(cgi_name='acq.fas')
+        self.fund_allocation_fund = ContextItem(cgi_name='acq.faf')
+        self.fund_allocation_amount = ContextItem(cgi_name='acq.faa')
+        self.fund_allocation_percent = ContextItem(cgi_name='acq.fap')
+        self.fund_allocation_note = ContextItem(cgi_name='acq.fan')
+
+
         # -------------------------------------------------------------
         # utility functions
         self.find_entry_attr = ContextItem(
index ce378a6..3fffde9 100644 (file)
@@ -2,18 +2,31 @@ from oilsweb.lib.base import *
 import pylons
 from oilsweb.lib.request import RequestMgr
 import oilsweb.lib.acq.fund, oilsweb.lib.user
-import osrf.net_obj
-import oils.org
+import osrf.net_obj, osrf.ses
+import oils.org, oils.const, oils.event
 
 class FundController(BaseController):
 
     def view(self, **kwargs):
         r = RequestMgr()
         r.ctx.core.org_tree = oils.org.OrgUtil.fetch_org_tree()
-        fund_mgr = oilsweb.lib.acq.fund.FundMgr(r)
-        fund = fund_mgr.retrieve(kwargs.get('id'))
+        fund_id = kwargs['id']
+
+        ses = osrf.ses.ClientSession(oils.const.OILS_APP_ACQ)
+        fund_req = ses.request('open-ils.acq.fund.retrieve', r.ctx.core.authtoken, fund_id)
+        fund_summary_req = ses.request('open-ils.acq.fund.summary.retrieve', r.ctx.core.authtoken, fund_id)
+
+        # grab the fund object
+        fund = fund_req.recv().content()
+        oils.event.Event.parse_and_raise(fund)
         fund.org(oils.org.OrgUtil.get_org_unit(fund.org())) # flesh the org
         r.ctx.acq.fund = fund
+
+        # grab the fund summary
+        fund_summary = fund_summary_req.recv().content()
+        oils.event.Event.parse_and_raise(fund_summary)
+        r.ctx.acq.fund_summary = fund_summary
+
         return r.render('acq/financial/view_fund.html')
 
     def list(self):
@@ -45,4 +58,27 @@ class FundController(BaseController):
 
         return r.render('acq/financial/create_fund.html')
 
+    def allocate(self):
+        r = RequestMgr()
+        fund_mgr = oilsweb.lib.acq.fund.FundMgr(r)
+
+        if r.ctx.acq.fund_allocation_source:
+            alloc = osrf.net_obj.NetworkObject.acqfa()
+            alloc.funding_source(r.ctx.acq.fund_allocation_source)
+            alloc.fund(r.ctx.acq.fund_allocation_fund)
+            if r.ctx.acq.fund_allocation_amount:
+                alloc.amount(r.ctx.acq.fund_allocation_amount)
+            else:
+                alloc.percent(r.ctx.acq.fund_allocation_percent)
+            alloc.note(r.ctx.acq.fund_allocation_note)
+            fund_mgr.create_allocation(alloc)
+            return redirect_to(controller='acq/fund', action='view', id=r.ctx.acq.fund_allocation_fund)
+
+        fund = fund_mgr.retrieve(r.ctx.acq.fund_id)
+        fund.org(oils.org.OrgUtil.get_org_unit(fund.org())) # flesh the org
+        r.ctx.acq.fund = fund
+        r.ctx.acq.fund_source_list = fund_mgr.retrieve_org_fund_sources('MANAGE_FUNDING_SOURCE')
+        return r.render('acq/financial/create_fund_allocation.html')
+
+
 
index 745c209..c6e2e57 100644 (file)
@@ -21,10 +21,10 @@ class FundMgr(object):
         oils.event.Event.parse_and_raise(fund)
         return fund
 
-    def retrieve_org_funds(self):
+    def retrieve_org_funds(self, limit_perm=None):
         funds = self.ses.request(
             'open-ils.acq.fund.org.retrieve', 
-            self.request_mgr.ctx.core.authtoken).recv().content()
+            self.request_mgr.ctx.core.authtoken, None, limit_perm).recv().content()
         oils.event.Event.parse_and_raise(funds)
         return funds
 
@@ -43,10 +43,10 @@ class FundMgr(object):
         oils.event.Event.parse_and_raise(source)
         return source
 
-    def retrieve_org_fund_sources(self):
+    def retrieve_org_fund_sources(self, limit_perm=None):
         sources = self.ses.request(
             'open-ils.acq.funding_source.org.retrieve', 
-            self.request_mgr.ctx.core.authtoken).recv().content()
+            self.request_mgr.ctx.core.authtoken, None, limit_perm).recv().content()
         oils.event.Event.parse_and_raise(sources)
         return sources
 
@@ -58,4 +58,10 @@ class FundMgr(object):
         oils.event.Event.parse_and_raise(source_id)
         return source_id
 
+    def create_allocation(self, alloc):
+        alloc_id = self.ses.request(
+            'open-ils.acq.fund_allocation.create',
+            self.request_mgr.ctx.core.authtoken, alloc).recv().content()
+        oils.event.Event.parse_and_raise(alloc_id)
+        return alloc_id
 
index 6002bf8..518a6fb 100644 (file)
@@ -28,7 +28,8 @@ body { margin-top: 0px; padding-top: 0px;}
 /* general purpose form table */
 .oils-admin-table { width: 100%; }
 .oils-admin-table td { padding: 4px; }
-.oils-admin-label { width: 20%; }
+.oils-admin-table textarea { width: 400px; height: 40px; overflow:auto;}
+.oils-admin-label { width: auto; }
 
 .label { margin: 1px; }