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_currency_type = ContextItem(cgi_name='acq.fc')
self.fund_summary = ContextItem()
self.fund_source = ContextItem()
self.fund_source_list = ContextItem()
- self.fund_source_name = ContextItem(cgi_name='acq.fn')
- self.fund_source_currency_type = ContextItem(cgi_name='acq.fc')
- self.fund_source_owner = ContextItem(cgi_name='acq.fo')
+ self.fund_source_name = ContextItem(cgi_name='acq.fsn')
+ self.fund_source_currency_type = ContextItem(cgi_name='acq.fsc')
+ self.fund_source_owner = ContextItem(cgi_name='acq.fso')
self.fund_allocation = ContextItem()
fund.name(r.ctx.acq.fund_name)
fund.org(r.ctx.acq.fund_org)
fund.year(r.ctx.acq.fund_year)
+ fund.currency_type(r.ctx.acq.fund_currency_type)
fund_id = ses.request('open-ils.acq.fund.create',
r.ctx.core.authtoken, fund).recv().content()
usermgr = oilsweb.lib.user.User(r.ctx.core)
tree = usermgr.highest_work_perm_tree('CREATE_FUND')
+ types = ses.request(
+ 'open-ils.acq.currency_type.all.retrieve',
+ r.ctx.core.authtoken).recv().content()
+ r.ctx.acq.currency_types = oils.event.Event.parse_and_raise(types)
+
+
if tree is None:
return _("Insufficient Permissions") # XXX Return a perm failure template
source_list = ses.request(
'open-ils.acq.funding_source.org.retrieve',
- r.ctx.core.authtoken, None, 'MANAGE_FUNDING_SOURCE').recv().content()
+ r.ctx.core.authtoken, None, {'limit_perm':'MANAGE_FUNDING_SOURCE', 'flesh_summary':1}).recv().content()
oils.event.Event.parse_and_raise(source_list)
r.ctx.acq.fund = fund
from oilsweb.lib.request import RequestMgr
import oilsweb.lib.acq.fund
import osrf.net_obj
-import oils.org
+import oils.org, oils.event, oils.const
class FundSourceController(BaseController):
def view(self, **kwargs):
r = RequestMgr()
+ ses = osrf.ses.ClientSession(oils.const.OILS_APP_ACQ)
r.ctx.core.org_tree = oils.org.OrgUtil.fetch_org_tree()
- fund_mgr = oilsweb.lib.acq.fund.FundMgr(r)
- source = fund_mgr.retrieve_fund_source(kwargs.get('id'))
+
+ source = ses.request(
+ 'open-ils.acq.funding_source.retrieve',
+ r.ctx.core.authtoken, kwargs.get('id'), {"flesh_summary":1}).recv().content()
+ oils.event.Event.parse_and_raise(source)
+
source.owner(oils.org.OrgUtil.get_org_unit(source.owner())) # flesh the owner
r.ctx.acq.fund_source = source
return r.render('acq/financial/view_fund_source.html')
def list(self):
r = RequestMgr()
- fund_mgr = oilsweb.lib.acq.fund.FundMgr(r)
- r.ctx.acq.fund_source_list = fund_mgr.retrieve_org_fund_sources()
- for f in r.ctx.acq.fund_source_list:
- f.owner(oils.org.OrgUtil.get_org_unit(f.owner()))
+ ses = osrf.ses.ClientSession(oils.const.OILS_APP_ACQ)
+
+ sources = ses.request(
+ 'open-ils.acq.funding_source.org.retrieve',
+ r.ctx.core.authtoken, None, {"flesh_summary":1}).recv().content()
+
+ oils.event.Event.parse_and_raise(sources)
+ r.ctx.acq.fund_source_list = sources
+
+ for source in sources:
+ source.owner(oils.org.OrgUtil.get_org_unit(source.owner()))
return r.render('acq/financial/list_fund_sources.html')
oils.event.Event.parse_and_raise(source)
return source
- def retrieve_org_fund_sources(self, limit_perm=None):
+ def retrieve_org_fund_sources(self, options=None):
sources = self.ses.request(
'open-ils.acq.funding_source.org.retrieve',
- self.request_mgr.ctx.core.authtoken, None, limit_perm).recv().content()
+ self.request_mgr.ctx.core.authtoken, None, options).recv().content()
oils.event.Event.parse_and_raise(sources)
return sources
</td>
</tr>
<tr>
+ <td class='oils-admin-label'>${_('Fund Currency Type')}</td>
+ <td>
+ <select name='${c.oils.acq.fund_currency_type_.cgi_name}'>
+ % for type in c.oils.acq.currency_types:
+ <option value='${type.code()}'>${type.label()}</option>
+ % endfor
+ </select>
+ </td>
+ </tr>
+ <tr>
<td class='oils-admin-label'>${_('Fund Year')}</td>
<td>
<input type='text' size='42' year='${c.oils.acq.fund_year_.cgi_name}'/>
</td>
</tr>
+
<tr>
<td colspan='2'>
<input type='submit' value='${_("Create Fund")}'/>
<td>
<select name='${c.oils.acq.fund_allocation_source_.cgi_name}'>
% for source in c.oils.acq.fund_source_list:
- <option value='${source.id()}'>${source.name()}</option>
+ <% source_label = _('%(name)s (balance = %(b)s)') % {'name':source.name(), 'b': source.summary()['balance']} %>
+ <option value='${source.id()}'>${source_label}</option>
% endfor
</select>
</td>
<td>${_('Funding Source Name')}</td>
<td>${_('Funding Source Owner')}</td>
<td>${_('Funding Source Currency Type')}</td>
+ <td>${_('Funding Source Balance')}</td>
</tr>
</thead>
<tbody>
<td><a href='${c.oils.acq.prefix}/fund_source/view/${source.id()}'>${source.name()}</a></td>
<td>${source.owner().name()}</td>
<td>${source.currency_type()}</td>
+ <td>${source.summary()['balance']}</td>
</tr>
%endfor
</tbody>
<table class='oils-admin-table'>
<tbody>
<tr>
- <td class='oils-admin-label'>${_('Fund Name')}</td>
+ <td class='oils-admin-label'>${_('Name')}</td>
<td>${c.oils.acq.fund.name()}</td>
</tr>
<tr>
- <td class='oils-admin-label'>${_('Fund Owner')}</td>
+ <td class='oils-admin-label'>${_('Owner')}</td>
<td>${c.oils.acq.fund.org().name()}</td>
</tr>
<tr>
- <td class='oils-admin-label'>${_('Fund Year')}</td>
+ <td class='oils-admin-label'>${_('Currency')}</td>
+ <td>${c.oils.acq.fund.currency_type()}</td>
+ </tr>
+ <tr>
+ <td class='oils-admin-label'>${_('Year')}</td>
<td>${c.oils.acq.fund.year()}</td>
</tr>
<tr>
<td>${c.oils.acq.fund.summary()['allocation_total']}</td>
</tr>
<tr>
- <td class='oils-admin-label'>${_('Fund Balance (Total - (Spent + Encumberances))')}</td>
+ <td class='oils-admin-label'>${_('Balance (Total - (Spent + Encumberances))')}</td>
<td>${c.oils.acq.fund.summary()['combined_balance']}</td>
</tr>
<tr>
- <td class='oils-admin-label'>${_('Fund Spent Balance (Total - Spent)')}</td>
+ <td class='oils-admin-label'>${_('Spent Balance (Total - Spent)')}</td>
<td>${c.oils.acq.fund.summary()['spent_balance']}</td>
</tr>
<tr>
<td class='oils-admin-label'>${_('Funding Source Currency Type')}</td>
<td>${c.oils.acq.fund_source.currency_type()}</td>
</tr>
+ <tr>
+ <td class='oils-admin-label'>${_('Funding Source Credit Total')}</td>
+ <td>${c.oils.acq.fund_source.summary()['credit_total']}</td>
+ </tr>
+ <tr>
+ <td class='oils-admin-label'>${_('Funding Source Allocation Total')}</td>
+ <td>${c.oils.acq.fund_source.summary()['allocation_total']}</td>
+ </tr>
+ <tr>
+ <td class='oils-admin-label'>${_('Funding Source Balance')}</td>
+ <td>${c.oils.acq.fund_source.summary()['balance']}</td>
+ </tr>
</tbody>
</table>
</%def>