dojo.require('openils.Util');
dojo.require('openils.User');
dojo.require('openils.CGI');
-dojo.require('openils.acq.Fund');
+dojo.require('openils.PermaCrud');
dojo.require('openils.widget.AutoGrid');
dojo.require('openils.widget.ProgressDialog');
dojo.require('fieldmapper.OrgUtils');
var contextOrg;
var rolloverResponses;
var rolloverMode = false;
+var fundFleshFields = [
+ 'spent_balance',
+ 'combined_balance',
+ 'spent_total',
+ 'encumbrance_total',
+ 'debit_total',
+ 'allocation_total'
+];
function getBalanceInfo(rowIndex, item) {
if(!item) return '';
- 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;
+ return this.grid.store.getValue(item, this.field) || 0;
}
function initPage() {
openils.Util.hide('acq-fund-list-rollover-summary');
year = year || fundFilterYearSelect.attr('value');
- fieldmapper.standardRequest(
- [ 'open-ils.acq', 'open-ils.acq.fund.org.retrieve'],
- { async: true,
-
- params: [
- openils.User.authtoken,
- {year : year, org : fieldmapper.aou.descendantNodeList(contextOrg, true)},
- {
- flesh_summary:1,
- limit: lfGrid.displayLimit,
- offset: lfGrid.displayOffset
- }
- ],
-
- onresponse : function(r) {
- if(lf = openils.Util.readResponse(r)) {
- openils.acq.Fund.cache[lf.id()] = lf;
- lfGrid.store.newItem(acqf.toStoreItem(lf));
+ var pcrud = new openils.PermaCrud();
+ pcrud.search('acqf',
+ { year : year,
+ org : fieldmapper.aou.descendantNodeList(contextOrg, true)
+ },
+ { flesh : 1,
+ flesh_fields : {acqf : fundFleshFields},
+ streaming : true,
+ onresponse : function(r, obj) {
+ if(fund = openils.Util.readResponse(r)) {
+ fundFleshFields.forEach(function(ff) {
+ field = fund[ff]();
+ fund[ff](field ? field.amount() : '0');
+ });
+ lfGrid.store.newItem(acqf.toStoreItem(fund));
}
},
-
oncomplete : function(r) {
lfGrid.hideLoadProgressIndicator();
}