2 "name" : "Pman.Tab.XtupleReconcile",
3 "parent" : "Pman.Tab.XtupleAccountsTab",
4 "title" : "Pman.Tab.XtupleReconcile",
5 "path" : "/home/alan/gitlive/Pman.Xtuple/Pman.Tab.XtupleReconcile.bjs",
11 "title" : "Bank Reconcile",
12 "xtype" : "NestedLayoutPanel",
16 "xtype" : "BorderLayout",
21 "xtype" : "LayoutRegion",
26 "xtype" : "LayoutRegion",
34 "|activate" : "function() {\n _this.panel = this;\n if (_this.grid) {\n _this.grid.footer.onClick('first');\n }\n}"
39 "title" : "Bank Reconcile",
40 "xtype" : "GridPanel",
41 "fitContainer" : true,
43 "tableName" : "metasql",
47 "beforeedit" : "function (e)\n{\n // Roo.log(e);\n var ch = _this.grid.colModel.config[e.column].header;\n var val = e.value *1;\n // Roo.log(ch);\n // Roo.log(val);\n\n if (val > 0.0 && ch == 'Debit') {\n e.cancel = true;\n return;\n }\n if (val < 0.0 && ch == 'Credit') {\n e.cancel = true;\n return;\n }\n if (e.record.data.cleared || e.record.data.bankrec_posted) {\n e.cancel = true;\n return;\n }\n \n // allow start editing..\n}",
48 "cellclick" : "function (_self, rowIndex, columnIndex, e)\n{\n var clear = function(ar) \n {\n var ar_in = ar;\n if (ar === true) {\n ar = [];\n \n _this.grid.ds.each(function(rec) {\n if (rec.data.doc_type == 'BF') {\n return;\n }\n ar.push(rec);\n });\n }\n var sortdate = false;\n var data = [];\n Roo.each(ar, function(rec) {\n if (rec.data.cleared || rec.data.bankrec_posted) {\n return;\n }\n if(!sortdate){\n sortdate = rec.data.sortdate;\n }\n data.push({\n id : rec.data.id,\n altid : rec.data.altid,\n curr_rate : rec.data.doc_exchrate,\n amount : rec.data.amount\n \n });\n });\n new Pman.Request({\n url : baseURL + '/Roo/bankrecitem',\n method : 'POST',\n mask : 'Clearing',\n params : {\n bankaccnt_id : _this.bankacct.getValue(),\n sortdate : sortdate,\n set_clear : Roo.encode(data)\n },\n success : function() {\n Roo.each(ar, function(rec) {\n rec.set('cleared', true);\n });\n if (ar_in === true) {\n _this.grid.ds.getAt(0).set('cleared', true);\n }\n _this.wgrid.footer.onClick('refresh');\n }\n });\n }\n \n \n var unclear = function(ar)\n {\n var ar_in = ar;\n if (ar === true) {\n ar = [];\n \n _this.grid.ds.each(function(rec) {\n if (rec.data.doc_type == 'BF') {\n return;\n }\n ar.push(rec);\n });\n }\n var sortdate = false;\n var data = [];\n Roo.each(ar, function(rec) {\n if (!rec.data.cleared || rec.data.bankrec_posted) {\n return;\n }\n if(!sortdate){\n sortdate = rec.data.sortdate;\n }\n data.push({\n id : rec.data.id,\n altid : rec.data.altid \n });\n });\n\n new Pman.Request({\n url : baseURL + '/Roo/bankrecitem',\n method : 'POST',\n mask : 'Clearing',\n params : {\n bankaccnt_id : _this.bankacct.getValue(),\n sortdate : sortdate,\n remove_clear :Roo.encode(data)\n \n },\n success : function() {\n Roo.each(ar, function(rec) {\n rec.set('cleared', false);\n });\n if (ar_in === true) {\n _this.grid.ds.getAt(0).set('cleared', false);\n } \n _this.wgrid.footer.onClick('refresh');\n }\n });\n \n \n };\n \n \n \n var di = this.colModel.config[columnIndex].dataIndex;\n if (di != 'cleared') {\n return;\n }\n var rec = this.ds.getAt(rowIndex);\n if (rec.data.doc_type == 'BF') {\n \n if (rec.data.cleared) {\n unclear(true);\n \n } else {\n clear(true);\n }\n \n return;\n }\n \n \n \n if (rec.data.cleared) {\n \n unclear([rec]);\n return;\n \n }\n \n clear([rec]);\n \n \n \n \n \n}",
49 "|render" : "function() \n{\n _this.grid = this; \n //_this.dialog = Pman.Dialog.FILL_IN\n if (_this.panel.active) {\n this.footer.onClick('first');\n }\n}",
50 "afteredit" : "function (e)\n{\n\n if (e.cancel) {\n return;\n }\n var ch = _this.grid.colModel.config[e.column].header;\n var val = e.originalValue *1;\n // Roo.log(ch);\n // Roo.log(val);\n\n if (val > 0.0 && ch == 'Debit') {\n e.cancel = true;\n return;\n }\n if (val < 0.0 && ch == 'Credit') {\n e.cancel = true;\n return;\n }\n if (e.record.data.cleared || e.record.data.bankrec_posted) {\n e.cancel = true;\n return;\n }\n if (val > 0.0 && e.value < 0.0) {\n Roo.log(\"CANCEL\"); \n e.record.set('amount', e.originalValue);\n e.cancel = true;\n return;\n }\n if (val < 0.0 && e.value > 0.0) {\n Roo.log(\"CANCEL\");\n e.record.set('amount', e.originalValue);\n e.cancel = true;\n return;\n } \n if (e.originalValue*1 == e.value*1) {\n return;\n }\n \n e.record.set('doc_exchrate', Math.abs(e.value * 1) / Math.abs(e.record.data.base_amount * 1));\n Roo.log(e.record);\n \n _this.grid.ds.updateBalance();\n // send it down the line...\n new Pman.Request({\n method : 'POST',\n url : baseURL + '/Roo/bankrecitem',\n mask : 'Saving',\n params : {\n bankaccnt_id : _this.bankacct.getValue(),\n set_amount : Math.abs(e.value),\n sortdate : e.record.data.sortdate,\n source_id : e.record.data.id,\n altid : e.record.data.altid\n }\n \n });\n \n \n \n \n}"
52 "autoExpandColumn" : "notes",
53 "xtype" : "EditorGrid",
61 "beforeloadadd" : "function (_self, records, options, res)\n{\n // _this.total = 0.0;\n\n \n\n\n _this.total = 1 * res.raw.amount;\n _this.bf = 1 * res.raw.amount;\n Roo.log(\"TOTAL:\" + _this.total);\n}\n",
62 "beforeload" : "function (_self, o)\n{\n var s = _this.wgrid.getSelectionModel().getSelected();\n \n if (!s) {\n return false;\n }\n o.params._group = 'bankrec';\n o.params._name = 'all';\n o.params['sortdate:text'] = s.data.sortdate;\n o.params['bankaccntid:number'] = _this.bankacct.getValue();\n\n o.params['_cals'] = 'amount'\n}",
63 "load" : "function (_self, records, options)\n{\n \n var bal = _this.bf;\n var cleared = true;\n var posted = true;\n Roo.each(records, function(rec) {\n if (!rec.data.cleared) {\n cleared = false;\n\n }\n if (!rec.data.bankrec_posted) {\n posted = false;\n }\n if (rec.data.doc_type != 'BF') {\n bal += rec.data.amount *1;\n rec.set('balance', bal); \n } else {\n rec.set('balance', _this.bf);\n }\n \n \n });\n \n var rec = this.reader.newRow({\n notes : 'Brought Forward',\n balance : _this.bf,\n doc_type : 'BF',\n cleared : cleared,\n bankrec_posted : posted\n });\n this.insert(0, [rec]);\n}"
67 "$ sortInfo" : "{ field : 'metasql_group', direction: 'ASC' }",
69 "$ updateBalance" : "function() {\n var bal = _this.bf;\n this.each( function(rec) {\n if (rec.data.doc_type != 'BF') {\n bal += rec.data.amount *1;\n rec.set('balance', bal); \n } else {\n rec.set('balance', _this.bf);\n }\n \n \n });\n}\n",
70 "* prop" : "dataSource",
73 "$ url" : "baseURL + '/Roo/metasql.php'",
75 "xtype" : "HttpProxy",
82 "xtype" : "JsonReader",
83 "$ fields" : "[\n {\n 'name': 'metasql_id',\n 'type': 'int'\n },\n {\n 'name': 'metasql_group',\n 'type': 'string'\n },\n {\n 'name': 'metasql_name',\n 'type': 'string'\n },\n {\n 'name': 'metasql_notes',\n 'type': 'string'\n },\n {\n 'name': 'metasql_query',\n 'type': 'string'\n },\n {\n 'name': 'metasql_lastuser',\n 'type': 'string'\n },\n {\n 'name': 'metasql_lastupdate',\n 'type': 'date',\n 'dateFormat': 'Y-m-d'\n },\n {\n 'name': 'metasql_grade',\n 'type': 'int'\n }\n]",
86 "totalProperty" : "total"
92 "xtype" : "PagingToolbar",
93 "emptyMsg" : "Nothing found",
95 "displayMsg" : "Displaying records {0} - {1} of {2}",
102 "* prop" : "toolbar",
106 "render" : "function (_self)\n{\n _this.bankacct = _self;\n}",
107 "select" : "function (combo, record, index)\n{ \n var curr = record.data.bankaccnt_curr_id_curr_abbr;\n var col = _this.grid.colModel.config.length -1;\n \n _this.grid.colModel.setColumnHeader(col, 'Balance (' + curr +')');\n \n _this.grid.ds.removeAll();\n \n _this.wgrid.footer.onClick('first');\n}"
110 "triggerAction" : "all",
111 "fieldLabel" : "bankaccnt",
112 "forceSelection" : true,
113 "selectOnFocus" : true,
115 "displayField" : "bankaccnt_name",
116 "emptyText" : "Select bankaccnt",
117 "hiddenName" : "bankaccnt_id",
119 "valueField" : "bankaccnt_id",
120 "xtype" : "ComboBox",
121 "allowBlank" : false,
125 "$ xns" : "Roo.form",
126 "name" : "bankaccnt_name",
127 "qtip" : "Select bankaccnt",
129 "tpl" : "<div class=\"x-grid-cell-text x-btn button\"><b>{bankaccnt_bankname}</b> {bankaccnt_name} - {bankaccnt_descrip} {bankaccnt_accntnumber}</div>",
130 "loadingText" : "Searching...",
134 "|beforeload" : "function (_self, o){\n o.params = o.params || {};\n // set more here\n}\n"
138 "$ sortInfo" : "{ direction : 'ASC', field: 'bankaccnt_bankname' }",
139 "$ xns" : "Roo.data",
143 "$ url" : "baseURL + '/Roo/bankaccnt.php'",
144 "xtype" : "HttpProxy",
146 "$ xns" : "Roo.data",
152 "xtype" : "JsonReader",
153 "$ xns" : "Roo.data",
154 "$ fields" : "[{\"name\":\"id\",\"type\":\"int\"},{\"name\":\"bankaccnt_name\",\"type\":\"string\"}]",
156 "totalProperty" : "total"
164 "click" : "function (_self, e)\n{\n var o = {params : {}}; \n if (!_this.bankacct.getValue()) {\n return false;\n }\n o.params._group = 'bankrec';\n o.params._name = 'all';\n o.params['bankaccntid:number'] = _this.bankacct.getValue();\n o.params['_sum_prev'] = 'amount';\n o.url = baseURL + '/Roo/Metasql';\n o.method = 'GET';\n \n var cols = {\n 'cleared' : 'Cleared',\n 'sortdate' : 'Date',\n 'doc_type' : 'Doctype',\n 'doc_number' : 'Doc number',\n 'notes' : 'Notes',\n 'doc_curr' : 'Currency',\n 'base_amount' : 'Base Amount',\n 'doc_exchrate' : 'Exchange Rate',\n 'amount' : 'Amount (Bank Currency)'\n };\n var n =0;\n for (var i in cols) {\n \n \n o.params['csvCols['+n+']'] = i\n o.params['csvTitles['+n+']'] = cols[i];\n n++;\n }\n\n \n new Pman.Download(o);\n Roo.MessageBox.alert(\"Notice\", \"Should be downloading now\");\n}"
168 "$ xns" : "Roo.Toolbar"
172 "$ xns" : "Roo.Toolbar"
177 "xtype" : "ColumnModel",
179 "header" : "Cleared",
180 "$ renderer" : "function(v,x,r) { \n if (r.data.bankrec_posted) {\n return 'POSTED';\n }\n\n var state = v ? '-checked' : '';\n \n return '<img class=\"x-grid-check-icon' + state + '\" src=\"' + Roo.BLANK_IMAGE_URL + '\"/>';\n }",
181 "$ xns" : "Roo.grid",
182 "* prop" : "colModel[]",
183 "dataIndex" : "cleared"
186 "xtype" : "ColumnModel",
189 "$ renderer" : "function(v) { \n\n return v ? Date.parseDate(v,'Y-m-d').format('d/M/Y') : '';\n }",
190 "$ xns" : "Roo.grid",
191 "* prop" : "colModel[]",
192 "dataIndex" : "sortdate"
195 "xtype" : "ColumnModel",
197 "header" : "Doctype",
198 "$ renderer" : "function(v) { return String.format('{0}', v); }",
199 "$ xns" : "Roo.grid",
200 "* prop" : "colModel[]",
201 "dataIndex" : "doc_type"
204 "xtype" : "ColumnModel",
206 "header" : "Doc Number",
207 "$ renderer" : "function(v) { return String.format('{0}', v); }",
208 "$ xns" : "Roo.grid",
209 "* prop" : "colModel[]",
210 "dataIndex" : "doc_number"
213 "xtype" : "ColumnModel",
216 "$ renderer" : "function(v) { return String.format('{0}', v); }",
217 "$ xns" : "Roo.grid",
218 "* prop" : "colModel[]",
219 "dataIndex" : "notes"
222 "xtype" : "ColumnModel",
224 "header" : "Currency",
225 "$ renderer" : "function(v) { return String.format('{0}', v); }",
226 "$ xns" : "Roo.grid",
227 "* prop" : "colModel[]",
228 "dataIndex" : "doc_curr"
232 "xtype" : "ColumnModel",
233 "header" : "Exchange Rate",
235 "$ renderer" : "function(v) { return String.format('{0}', v ? (v*1).toFixed(3) : ''); }",
236 "$ xns" : "Roo.grid",
237 "* prop" : "colModel[]",
238 "dataIndex" : "doc_exchrate"
242 "xtype" : "ColumnModel",
243 "header" : "Base Amount",
245 "$ renderer" : "function(v) { return String.format('{0}', Roo.util.Format.number(v*1,2)); }",
246 "$ xns" : "Roo.grid",
247 "* prop" : "colModel[]",
248 "dataIndex" : "base_amount"
252 "xtype" : "ColumnModel",
255 "$ renderer" : "function(v,x,r) { \n if (r.data.doc_type == 'BF') {\n return '';\n }\n return String.format('{0}', v > 0 ? Roo.util.Format.number(v*1,2) : ''); }",
256 "$ xns" : "Roo.grid",
257 "* prop" : "colModel[]",
258 "dataIndex" : "amount",
261 "xtype" : "GridEditor",
262 "$ xns" : "Roo.grid",
266 "xtype" : "NumberField",
267 "cls" : "align-right",
268 "decimalPrecision" : 2,
269 "$ xns" : "Roo.form",
278 "xtype" : "ColumnModel",
281 "$ renderer" : "function(v,x,r) { \n if (r.data.doc_type == 'BF') {\n return '';\n }\n return String.format('{0}', v < 0 ? Roo.util.Format.number(v*1,2): ''); }",
282 "$ xns" : "Roo.grid",
283 "* prop" : "colModel[]",
284 "dataIndex" : "amount",
287 "xtype" : "GridEditor",
288 "$ xns" : "Roo.grid",
292 "xtype" : "NumberField",
293 "cls" : "align-right",
294 "decimalPrecision" : 2,
295 "$ xns" : "Roo.form",
304 "xtype" : "ColumnModel",
305 "header" : "Balance",
307 "$ renderer" : "\nfunction(v,x,r) { \n if (r.data.doc_type == 'BF') {\n return String.format('{0}', Roo.util.Format.number(v*1,2)); \n }\n\n\n //_this.total += (v*1)\n return String.format('{0}', Roo.util.Format.number(v*1,2)); \n}",
308 "$ xns" : "Roo.grid",
309 "* prop" : "colModel[]",
310 "dataIndex" : "balance"
318 "|activate" : "function() {\n _this.wpanel = this;\n //if (_this.wgrid) {\n // _this.wgrid.footer.onClick('first');\n //}\n}"
323 "title" : "Pick a Date",
324 "xtype" : "GridPanel",
325 "fitContainer" : true,
327 "tableName" : "Groups",
331 "|render" : "function() \n{\n _this.wgrid = this; \n //_this.dialog = Pman.Dialog.FILL_IN\n //if (_this.wpanel.active) {\n // this.footer.onClick('first');\n //}\n}",
332 "cellclick" : "function (_self, rowIndex, columnIndex, e)\n{\n var di = this.colModel.getDataIndex(columnIndex);\n\n if (di != 'is_reconciled') {\n return;\n }\n \n var rec = this.ds.getAt(rowIndex);\n \n var voidit = function(){\n new Pman.Request({\n url : baseURL + '/Roo/Bankrec.php',\n method :'POST',\n params : {\n _void : 1,\n bankaccnt_id : _this.bankacct.getValue(),\n sotrdate : rec.data.sortdate\n \n },\n success : function() {\n _this.wgrid.footer.onClick('refresh');\n }\n });\n }\n \n var postit = function(){\n new Pman.Request({\n url : baseURL + '/Roo/Bankrec.php',\n method :'POST',\n params : {\n _post : 1,\n bankaccnt_id : _this.bankacct.getValue(),\n sotrdate : rec.data.sortdate\n \n },\n success : function() {\n _this.wgrid.footer.onClick('refresh');\n }\n });\n \n }\n \n if(rec.data.is_reconciled == 1){\n voidit();\n return;\n }\n \n postit();\n return;\n \n \n \n}",
333 "rowclick" : "function (_self, rowIndex, e)\n{\n \n _this.wgrid.lastSelectedRow = rowIndex;\n \n}"
335 "autoExpandColumn" : "sortdate",
338 "$ xns" : "Roo.grid",
344 "* prop" : "toolbar",
348 "render" : "function (_self)\n{\n _this.monthSel = _self;\n}",
349 "select" : "function (combo, date)\n{\n _this.grid.ds.removeAll();\n _this.wgrid.footer.onClick('first');\n}"
352 "xtype" : "MonthField",
360 "click" : "function (_self, e)\n{\n _this.monthSel.setValue('');\n _this.grid.ds.removeAll();\r\n _this.wgrid.footer.onClick('first');\r\n}"
363 "cls" : "x-btn-icon",
364 "$ icon" : "rootURL + '/Pman/templates/images/edit-clear.gif'",
365 "$ xns" : "Roo.Toolbar"
369 "$ xns" : "Roo.Toolbar"
374 "cls" : "x-btn-text-icon",
375 "$ icon" : "Roo.rootURL + 'images/default/tree/leaf.gif'",
376 "$ xns" : "Roo.Toolbar",
380 "$ xns" : "Roo.menu",
385 "click" : "function (_self, e)\n{\n\n Roo.MessageBox.confirm(\"Confirm\", \"Are you sure you want to fix all the historical data? It will recreate all the posted bankrec and delect all the unpost\",\n function (res) {\n if(res!='yes') {\n return;\n \n }\n new Pman.Request({\n url : baseURL + '/Roo/Bankrec.php',\n method :'POST',\n params : {\n _fix : 1\n },\n success : function() {\n if(_this.wgrid){\n _this.wgrid.footer.onClick('refresh');\n }\n Roo.MessageBox.alert('Notice', 'FIXED');\n }\n });\n });\n\n}"
387 "text" : "Fix historical data",
389 "cls" : "x-btn-text-icon",
390 "$ icon" : "Roo.rootURL + 'images/default/tree/leaf.gif'",
395 "click" : "function (_self, e)\n{\n\n Roo.MessageBox.confirm(\"Confirm\", \"Are you sure you want?\",\n function (res) {\n if(res!='yes') {\n return;\n \n }\n new Pman.Request({\n url : baseURL + '/Roo/Bankrec.php',\n method :'POST',\n params : {\n _closedPeriod : 1\n },\n success : function() {\n if(_this.wgrid){\n _this.wgrid.footer.onClick('refresh');\n }\n Roo.MessageBox.alert('Notice', 'DONE');\n }\n });\n });\n\n}"
397 "text" : "Fix Closed Periods",
399 "cls" : "x-btn-text-icon",
400 "$ icon" : "Roo.rootURL + 'images/default/tree/leaf.gif'",
411 "selectionchange" : "function (_self)\n{\n _this.grid.footer.onClick('first');\n}"
413 "xtype" : "RowSelectionModel",
414 "singleSelect" : true,
415 "$ xns" : "Roo.grid",
420 "beforeload" : "function (_self, o)\n{\n\n if (!_this.bankacct.getValue()) {\n return false;\n }\n var dt = _this.monthSel.getValue();\n \n if(dt.length){\n o.params['sortdate:text'] = typeof(dt) == 'string' ? dt : dt.format('Y-m-d');\n }\n o.params._group = 'bankrec';\n o.params._name = 'bydate';\n o.params['bankaccntid:number'] = _this.bankacct.getValue();\n \n\n \n}",
421 "load" : "function (_self, records, options, res)\n{ \n var sm = _this.wgrid.getSelectionModel();\n \n if(_this.wgrid.lastSelectedRow * 1 >0){\n sm.selectRow(_this.wgrid.lastSelectedRow);\n return;\n }\n \n if (!sm.getSelections().length) {\n sm.selectFirstRow();\n }\n\n}"
425 "$ sortInfo" : "{ field : 'sotrdate', direction: 'ASC' }",
426 "$ xns" : "Roo.data",
427 "* prop" : "dataSource",
430 "$ url" : "baseURL + '/Roo/metasql.php'",
431 "xtype" : "HttpProxy",
434 "$ xns" : "Roo.data",
440 "xtype" : "JsonReader",
441 "$ fields" : "[\n {\n 'name': 'sortdate',\n 'type': 'string'\n }\n]",
442 "$ xns" : "Roo.data",
444 "totalProperty" : "total"
450 "xtype" : "PagingToolbar",
451 "emptyMsg" : "No Date found",
453 "displayMsg" : "Displaying Date{0} - {1} of {2}",
454 "displayInfo" : false,
458 "xtype" : "ColumnModel",
461 "$ renderer" : "function(v) { \n\n return v ? Date.parseDate(v,'Y-m-d').format('d/M/Y') : '';\n }",
462 "$ xns" : "Roo.grid",
463 "* prop" : "colModel[]",
464 "dataIndex" : "sortdate"
468 "xtype" : "ColumnModel",
469 "header" : "Closing Balance",
471 "$ renderer" : "function(v,x,r) { \n \n var color = 'red'; // has some not 'ticked'\n \n if(r.data.no_records - r.data.no_posted == 0){ // all posted on that date\n color = 'black';\n }\n if(r.data.no_records - r.data.no_cleared == 0 && r.data.no_posted != r.data.no_cleared){ // has 'ticked' or posted\n color = 'blue';\n }\n \n return String.format('<span style=\"color:{0}\">{1}</span>', color, Roo.util.Format.number(v*1,2)); \n}",
472 "$ xns" : "Roo.grid",
473 "* prop" : "colModel[]",
474 "dataIndex" : "balance"
478 "xtype" : "ColumnModel",
479 "header" : "Reconciled",
481 "$ renderer" : "function(v,x,r) { \n \n if(!v){\n return '';\n }\n \n if((r.data.no_records * 1 != r.data.no_posted * 1) || r.data.balance * 1 != v * 1){ // not match\n \n return '<span style=\"color:red;font-weight:bold\">' + Roo.util.Format.number(v*1,2); \n }\n \n return String.format('<span style=\"color:black\">{0}</span>', Roo.util.Format.number(v*1,2)); \n \n }",
482 "$ xns" : "Roo.grid",
483 "* prop" : "colModel[]",
484 "dataIndex" : "reconciled"
488 "xtype" : "ColumnModel",
491 "$ renderer" : "function(v,x,r) { \n var state = v ? '-checked' : '';\n\n return '<img class=\"x-grid-check-icon' + state + '\" src=\"' + Roo.BLANK_IMAGE_URL + '\"/>';\n }\n \n",
492 "$ xns" : "Roo.grid",
493 "* prop" : "colModel[]",
494 "dataIndex" : "is_reconciled"