From d411e7ced85567b8c7d2b090f43aa1e6f416ddb3 Mon Sep 17 00:00:00 2001 From: erickson Date: Mon, 11 Feb 2008 20:53:00 +0000 Subject: [PATCH] added fund currency type info to displays, more funding-source summary usage git-svn-id: svn://svn.open-ils.org/ILS/branches/acq-experiment@8724 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../oilsweb/oilsweb/controllers/acq/__init__.py | 7 +++--- .../web/oilsweb/oilsweb/controllers/acq/fund.py | 9 +++++++- .../oilsweb/oilsweb/controllers/acq/fund_source.py | 26 ++++++++++++++++------ Open-ILS/web/oilsweb/oilsweb/lib/acq/fund.py | 4 ++-- .../oils/default/acq/financial/create_fund.html | 11 +++++++++ .../acq/financial/create_fund_allocation.html | 3 ++- .../default/acq/financial/list_fund_sources.html | 2 ++ .../oils/default/acq/financial/view_fund.html | 14 +++++++----- .../default/acq/financial/view_fund_source.html | 12 ++++++++++ 9 files changed, 69 insertions(+), 19 deletions(-) diff --git a/Open-ILS/web/oilsweb/oilsweb/controllers/acq/__init__.py b/Open-ILS/web/oilsweb/oilsweb/controllers/acq/__init__.py index 52027fee51..79d19771d4 100644 --- a/Open-ILS/web/oilsweb/oilsweb/controllers/acq/__init__.py +++ b/Open-ILS/web/oilsweb/oilsweb/controllers/acq/__init__.py @@ -39,13 +39,14 @@ class AcqContext(SubContext): 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() diff --git a/Open-ILS/web/oilsweb/oilsweb/controllers/acq/fund.py b/Open-ILS/web/oilsweb/oilsweb/controllers/acq/fund.py index 2005115cde..5427e708b6 100644 --- a/Open-ILS/web/oilsweb/oilsweb/controllers/acq/fund.py +++ b/Open-ILS/web/oilsweb/oilsweb/controllers/acq/fund.py @@ -50,6 +50,7 @@ class FundController(BaseController): 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() @@ -60,6 +61,12 @@ class FundController(BaseController): 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 @@ -76,7 +83,7 @@ class FundController(BaseController): 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 diff --git a/Open-ILS/web/oilsweb/oilsweb/controllers/acq/fund_source.py b/Open-ILS/web/oilsweb/oilsweb/controllers/acq/fund_source.py index 9cea205f28..fddbaa6155 100644 --- a/Open-ILS/web/oilsweb/oilsweb/controllers/acq/fund_source.py +++ b/Open-ILS/web/oilsweb/oilsweb/controllers/acq/fund_source.py @@ -3,26 +3,38 @@ import pylons 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') diff --git a/Open-ILS/web/oilsweb/oilsweb/lib/acq/fund.py b/Open-ILS/web/oilsweb/oilsweb/lib/acq/fund.py index c6e2e5733a..0a6a1d8cdb 100644 --- a/Open-ILS/web/oilsweb/oilsweb/lib/acq/fund.py +++ b/Open-ILS/web/oilsweb/oilsweb/lib/acq/fund.py @@ -43,10 +43,10 @@ class FundMgr(object): 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 diff --git a/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/create_fund.html b/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/create_fund.html index a8ff8027dd..065fe6eef3 100644 --- a/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/create_fund.html +++ b/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/create_fund.html @@ -24,11 +24,22 @@ + ${_('Fund Currency Type')} + + + + + ${_('Fund Year')} + diff --git a/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/create_fund_allocation.html b/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/create_fund_allocation.html index 4f3860d091..d6c6232bfe 100644 --- a/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/create_fund_allocation.html +++ b/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/create_fund_allocation.html @@ -21,7 +21,8 @@ diff --git a/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/list_fund_sources.html b/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/list_fund_sources.html index 7bd1494aa4..3c902279fc 100644 --- a/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/list_fund_sources.html +++ b/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/list_fund_sources.html @@ -18,6 +18,7 @@ ${_('Funding Source Name')} ${_('Funding Source Owner')} ${_('Funding Source Currency Type')} + ${_('Funding Source Balance')} @@ -26,6 +27,7 @@ ${source.name()} ${source.owner().name()} ${source.currency_type()} + ${source.summary()['balance']} %endfor diff --git a/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/view_fund.html b/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/view_fund.html index 7b93f23e38..3e39a0445a 100644 --- a/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/view_fund.html +++ b/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/view_fund.html @@ -6,15 +6,19 @@ - + - + - + + + + + @@ -22,11 +26,11 @@ - + - + diff --git a/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/view_fund_source.html b/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/view_fund_source.html index 07aa447c5f..29e3b54683 100644 --- a/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/view_fund_source.html +++ b/Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/financial/view_fund_source.html @@ -17,6 +17,18 @@ + + + + + + + + + + + +
${_('Fund Name')}${_('Name')} ${c.oils.acq.fund.name()}
${_('Fund Owner')}${_('Owner')} ${c.oils.acq.fund.org().name()}
${_('Fund Year')}${_('Currency')}${c.oils.acq.fund.currency_type()}
${_('Year')} ${c.oils.acq.fund.year()}
${c.oils.acq.fund.summary()['allocation_total']}
${_('Fund Balance (Total - (Spent + Encumberances))')}${_('Balance (Total - (Spent + Encumberances))')} ${c.oils.acq.fund.summary()['combined_balance']}
${_('Fund Spent Balance (Total - Spent)')}${_('Spent Balance (Total - Spent)')} ${c.oils.acq.fund.summary()['spent_balance']}
${_('Funding Source Currency Type')} ${c.oils.acq.fund_source.currency_type()}
${_('Funding Source Credit Total')}${c.oils.acq.fund_source.summary()['credit_total']}
${_('Funding Source Allocation Total')}${c.oils.acq.fund_source.summary()['allocation_total']}
${_('Funding Source Balance')}${c.oils.acq.fund_source.summary()['balance']}
-- 2.11.0