cache has no object when a new object is created. if not in the cache, assume balanc...
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 12 May 2009 20:39:30 +0000 (20:39 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 12 May 2009 20:39:30 +0000 (20:39 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@13149 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/js/ui/default/acq/financial/list_funding_sources.js
Open-ILS/web/js/ui/default/acq/financial/list_funds.js

index 8d09576..1f805b6 100644 (file)
@@ -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() {
index 11bb2ba..947756f 100644 (file)
@@ -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)