From e69effada7943ca7ea01cb038cd3cbf26a75c324 Mon Sep 17 00:00:00 2001 From: erickson Date: Tue, 12 May 2009 20:39:30 +0000 Subject: [PATCH] cache has no object when a new object is created. if not in the cache, assume balance, etc. info of '0' git-svn-id: svn://svn.open-ils.org/ILS/trunk@13149 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../default/acq/financial/list_funding_sources.js | 7 +++++-- .../web/js/ui/default/acq/financial/list_funds.js | 14 +++++++------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/Open-ILS/web/js/ui/default/acq/financial/list_funding_sources.js b/Open-ILS/web/js/ui/default/acq/financial/list_funding_sources.js index 8d095764be..1f805b6b88 100644 --- a/Open-ILS/web/js/ui/default/acq/financial/list_funding_sources.js +++ b/Open-ILS/web/js/ui/default/acq/financial/list_funding_sources.js @@ -19,8 +19,11 @@ function getOrgInfo(rowIndex, item) { function getBalanceInfo(rowIndex, item) { if(!item) return ''; - var data = this.grid.store.getValue( item, 'id'); - return new String(openils.acq.FundingSource.cache[data].summary().balance); + var id = this.grid.store.getValue( item, 'id'); + var fs = openils.acq.FundingSource.cache[id]; + if(fs && fs.summary()) + return fs.summary().balance; + return 0; } function loadFSGrid() { diff --git a/Open-ILS/web/js/ui/default/acq/financial/list_funds.js b/Open-ILS/web/js/ui/default/acq/financial/list_funds.js index 11bb2ba84c..947756f2ad 100644 --- a/Open-ILS/web/js/ui/default/acq/financial/list_funds.js +++ b/Open-ILS/web/js/ui/default/acq/financial/list_funds.js @@ -11,30 +11,31 @@ dojo.require('openils.acq.Fund'); dojo.require('openils.widget.AutoGrid'); function getOrgInfo(rowIndex, item) { - if(!item) return ''; var owner = this.grid.store.getValue(item, 'org'); return fieldmapper.aou.findOrgUnit(owner).shortname(); - } function getBalanceInfo(rowIndex, item) { if(!item) return ''; - var data = this.grid.store.getValue( item, 'id'); - return new String(openils.acq.Fund.cache[data].summary().combined_balance); + var id = this.grid.store.getValue( item, 'id'); + var fund = openils.acq.Fund.cache[id]; + if(fund && fund.summary()) + return fund.summary().combined_balance; + return 0; } function loadFundGrid() { var yearStore = {identifier:'year', name:'year', items:[]}; var yearsAdded = {}; /* don't duplicate the years in the selector */ - + fieldmapper.standardRequest( [ 'open-ils.acq', 'open-ils.acq.fund.org.retrieve'], { async: true, params: [openils.User.authtoken, null, {flesh_summary:1}], onresponse : function(r) { if(lf = openils.Util.readResponse(r)) { - openils.acq.Fund.cache[lf.id()] = lf; + openils.acq.Fund.cache[lf.id()] = lf; lfGrid.store.newItem(acqf.toStoreItem(lf)); var year = lf.year(); if(!(year in yearsAdded)) { @@ -56,7 +57,6 @@ function loadFundGrid() { } function filterGrid() { - console.log('filtergrid called'); var year = fundFilterYearSelect.getValue(); console.log(year); if(year) -- 2.43.2