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()
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(
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):
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')
+
+
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
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
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
/* 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; }