1 //<script type="text/javascript">
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
5 Roo.namespace('Pman.Tab');
7 Pman.Tab.XtupleReconcile = new Roo.XComponent({
8 part : ["Xtuple", "Reconcile" ],
9 order : '200-Pman.Tab.XtupleReconcile',
11 parent : 'Pman.Tab.XtupleAccountsTab',
12 name : "Pman.Tab.XtupleReconcile",
23 xtype : 'LayoutRegion',
28 xtype : 'LayoutRegion',
34 xtype : 'BorderLayout',
42 url : baseURL + '/Roo/metasql.php',
58 'name': 'metasql_group',
62 'name': 'metasql_name',
66 'name': 'metasql_notes',
70 'name': 'metasql_query',
74 'name': 'metasql_lastuser',
78 'name': 'metasql_lastupdate',
83 'name': 'metasql_grade',
88 totalProperty : 'total'
93 sortInfo : { field : 'metasql_group', direction: 'ASC' },
95 updateBalance : function() {
97 this.each( function(rec) {
98 if (rec.data.doc_type != 'BF') {
99 bal += rec.data.amount *1;
100 rec.set('balance', bal);
102 rec.set('balance', _this.bf);
109 beforeloadadd : function (_self, records, options, res)
111 // _this.total = 0.0;
116 _this.total = 1 * res.raw.amount;
117 _this.bf = 1 * res.raw.amount;
118 Roo.log("TOTAL:" + _this.total);
120 beforeload : function (_self, o)
122 var s = _this.wgrid.getSelectionModel().getSelected();
127 o.params._group = 'bankrec';
128 o.params._name = 'all';
129 o.params['sortdate:text'] = s.data.sortdate;
130 o.params['bankaccntid:number'] = _this.bankacct.getValue();
132 o.params['_cals'] = 'amount'
134 load : function (_self, records, options)
140 Roo.each(records, function(rec) {
141 if (!rec.data.cleared) {
145 if (!rec.data.bankrec_posted) {
148 if (rec.data.doc_type != 'BF') {
149 bal += rec.data.amount *1;
150 rec.set('balance', bal);
152 rec.set('balance', _this.bf);
158 var rec = this.reader.newRow({
159 notes : 'Brought Forward',
163 bankrec_posted : posted
165 this.insert(0, [rec]);
176 xtype : 'PagingToolbar',
177 emptyMsg : "Nothing found",
179 displayMsg : "Displaying records {0} - {1} of {2}",
191 url : baseURL + '/Roo/bankaccnt.php',
200 xtype : 'JsonReader',
202 fields : [{"name":"id","type":"int"},{"name":"bankaccnt_name","type":"string"}],
203 totalProperty : 'total'
208 sortInfo : { direction : 'ASC', field: 'bankaccnt_bankname' },
211 beforeload : function (_self, o){
212 o.params = o.params || {};
223 triggerAction : 'all',
224 fieldLabel : 'bankaccnt',
225 forceSelection : true,
226 selectOnFocus : true,
228 displayField : 'bankaccnt_name',
229 emptyText : "Select bankaccnt",
230 hiddenName : 'bankaccnt_id',
232 valueField : 'bankaccnt_id',
239 name : 'bankaccnt_name',
240 qtip : "Select bankaccnt",
242 tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{bankaccnt_bankname}</b> {bankaccnt_name} - {bankaccnt_descrip} {bankaccnt_accntnumber}</div>',
243 loadingText : "Searching...",
245 render : function (_self)
247 _this.bankacct = _self;
249 select : function (combo, record, index)
251 var curr = record.data.bankaccnt_curr_id_curr_abbr;
252 var col = _this.grid.colModel.config.length -1;
254 _this.grid.colModel.setColumnHeader(col, 'Balance (' + curr +')');
256 _this.grid.ds.removeAll();
258 _this.wgrid.footer.onClick('first');
267 '|xns' : 'Roo.Toolbar',
272 click : function (_self, e)
274 var o = {params : {}};
275 if (!_this.bankacct.getValue()) {
278 o.params._group = 'bankrec';
279 o.params._name = 'all';
280 o.params['bankaccntid:number'] = _this.bankacct.getValue();
281 o.params['_sum_prev'] = 'amount';
282 o.url = baseURL + '/Roo/Metasql';
286 'cleared' : 'Cleared',
288 'doc_type' : 'Doctype',
289 'doc_number' : 'Doc number',
291 'doc_curr' : 'Currency',
292 'base_amount' : 'Base Amount',
293 'doc_exchrate' : 'Exchange Rate',
294 'amount' : 'Amount (Bank Currency)'
297 for (var i in cols) {
300 o.params['csvCols['+n+']'] = i
301 o.params['csvTitles['+n+']'] = cols[i];
306 new Pman.Download(o);
307 Roo.MessageBox.alert("Notice", "Should be downloading now");
312 '|xns' : 'Roo.Toolbar',
320 autoExpandColumn : 'notes',
321 xtype : 'EditorGrid',
328 xtype : 'ColumnModel',
331 renderer : function(v,x,r) {
332 if (r.data.bankrec_posted) {
336 var state = v ? '-checked' : '';
338 return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
341 dataIndex : 'cleared'
345 xtype : 'ColumnModel',
348 renderer : function(v) {
350 return v ? Date.parseDate(v,'Y-m-d').format('d/M/Y') : '';
353 dataIndex : 'sortdate'
357 xtype : 'ColumnModel',
360 renderer : function(v) { return String.format('{0}', v); },
362 dataIndex : 'doc_type'
366 xtype : 'ColumnModel',
368 header : 'Doc Number',
369 renderer : function(v) { return String.format('{0}', v); },
371 dataIndex : 'doc_number'
375 xtype : 'ColumnModel',
378 renderer : function(v) { return String.format('{0}', v); },
384 xtype : 'ColumnModel',
387 renderer : function(v) { return String.format('{0}', v); },
389 dataIndex : 'doc_curr'
394 xtype : 'ColumnModel',
395 header : 'Exchange Rate',
397 renderer : function(v) { return String.format('{0}', v ? (v*1).toFixed(3) : ''); },
399 dataIndex : 'doc_exchrate'
404 xtype : 'ColumnModel',
405 header : 'Base Amount',
407 renderer : function(v) { return String.format('{0}', Roo.util.Format.number(v*1,2)); },
409 dataIndex : 'base_amount'
415 xtype : 'NumberField',
417 decimalPrecision : 2,
421 xtype : 'GridEditor',
430 xtype : 'ColumnModel',
433 renderer : function(v,x,r) {
434 if (r.data.doc_type == 'BF') {
437 return String.format('{0}', v > 0 ? Roo.util.Format.number(v*1,2) : ''); },
439 dataIndex : 'amount',
449 xtype : 'NumberField',
451 decimalPrecision : 2,
455 xtype : 'GridEditor',
464 xtype : 'ColumnModel',
467 renderer : function(v,x,r) {
468 if (r.data.doc_type == 'BF') {
471 return String.format('{0}', v < 0 ? Roo.util.Format.number(v*1,2): ''); },
473 dataIndex : 'amount',
482 xtype : 'ColumnModel',
485 renderer : function(v,x,r) {
486 if (r.data.doc_type == 'BF') {
487 return String.format('{0}', Roo.util.Format.number(v*1,2));
491 //_this.total += (v*1)
492 return String.format('{0}', Roo.util.Format.number(v*1,2));
495 dataIndex : 'balance'
499 beforeedit : function (e)
502 var ch = _this.grid.colModel.config[e.column].header;
503 var val = e.value *1;
507 if (val > 0.0 && ch == 'Debit') {
511 if (val < 0.0 && ch == 'Credit') {
515 if (e.record.data.cleared || e.record.data.bankrec_posted) {
520 // allow start editing..
522 cellclick : function (_self, rowIndex, columnIndex, e)
524 var clear = function(ar)
530 _this.grid.ds.each(function(rec) {
531 if (rec.data.doc_type == 'BF') {
537 var sortdate = false;
539 Roo.each(ar, function(rec) {
540 if (rec.data.cleared || rec.data.bankrec_posted) {
544 sortdate = rec.data.sortdate;
548 altid : rec.data.altid,
549 curr_rate : rec.data.doc_exchrate,
550 amount : rec.data.amount
555 url : baseURL + '/Roo/bankrecitem',
559 bankaccnt_id : _this.bankacct.getValue(),
561 set_clear : Roo.encode(data)
563 success : function() {
564 Roo.each(ar, function(rec) {
565 rec.set('cleared', true);
567 if (ar_in === true) {
568 _this.grid.ds.getAt(0).set('cleared', true);
570 _this.wgrid.footer.onClick('refresh');
576 var unclear = function(ar)
582 _this.grid.ds.each(function(rec) {
583 if (rec.data.doc_type == 'BF') {
589 var sortdate = false;
591 Roo.each(ar, function(rec) {
592 if (!rec.data.cleared || rec.data.bankrec_posted) {
596 sortdate = rec.data.sortdate;
600 altid : rec.data.altid
605 url : baseURL + '/Roo/bankrecitem',
609 bankaccnt_id : _this.bankacct.getValue(),
611 remove_clear :Roo.encode(data)
614 success : function() {
615 Roo.each(ar, function(rec) {
616 rec.set('cleared', false);
618 if (ar_in === true) {
619 _this.grid.ds.getAt(0).set('cleared', false);
621 _this.wgrid.footer.onClick('refresh');
630 var di = this.colModel.config[columnIndex].dataIndex;
631 if (di != 'cleared') {
634 var rec = this.ds.getAt(rowIndex);
635 if (rec.data.doc_type == 'BF') {
637 if (rec.data.cleared) {
649 if (rec.data.cleared) {
666 //_this.dialog = Pman.Dialog.FILL_IN
667 if (_this.panel.active) {
668 this.footer.onClick('first');
671 afteredit : function (e)
677 var ch = _this.grid.colModel.config[e.column].header;
678 var val = e.originalValue *1;
682 if (val > 0.0 && ch == 'Debit') {
686 if (val < 0.0 && ch == 'Credit') {
690 if (e.record.data.cleared || e.record.data.bankrec_posted) {
694 if (val > 0.0 && e.value < 0.0) {
696 e.record.set('amount', e.originalValue);
700 if (val < 0.0 && e.value > 0.0) {
702 e.record.set('amount', e.originalValue);
706 if (e.originalValue*1 == e.value*1) {
710 e.record.set('doc_exchrate', Math.abs(e.value * 1) / Math.abs(e.record.data.base_amount * 1));
713 _this.grid.ds.updateBalance();
714 // send it down the line...
717 url : baseURL + '/Roo/bankrecitem',
720 bankaccnt_id : _this.bankacct.getValue(),
721 set_amount : Math.abs(e.value),
722 sortdate : e.record.data.sortdate,
723 source_id : e.record.data.id,
724 altid : e.record.data.altid
743 title : "Bank Reconcile",
747 tableName : 'metasql',
749 activate : function() {
752 _this.grid.footer.onClick('first');
771 xtype : 'MonthField',
777 render : function (_self)
779 _this.monthSel = _self;
781 select : function (combo, date)
783 _this.grid.ds.removeAll();
784 _this.wgrid.footer.onClick('first');
789 '|xns' : 'Roo.Toolbar',
792 icon : rootURL + '/Pman/templates/images/edit-clear.gif',
795 click : function (_self, e)
797 _this.monthSel.setValue('');
798 _this.grid.ds.removeAll();
\r
799 _this.wgrid.footer.onClick('first');
\r
804 '|xns' : 'Roo.Toolbar',
816 text : "Fix historical data",
818 cls : 'x-btn-text-icon',
819 icon : Roo.rootURL + 'images/default/tree/leaf.gif',
822 click : function (_self, e)
825 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",
832 url : baseURL + '/Roo/Bankrec.php',
837 success : function() {
839 _this.wgrid.footer.onClick('refresh');
841 Roo.MessageBox.alert('Notice', 'FIXED');
851 text : "Fix Closed Periods",
853 cls : 'x-btn-text-icon',
854 icon : Roo.rootURL + 'images/default/tree/leaf.gif',
857 click : function (_self, e)
860 Roo.MessageBox.confirm("Confirm", "Are you sure you want?",
867 url : baseURL + '/Roo/Bankrec.php',
872 success : function() {
874 _this.wgrid.footer.onClick('refresh');
876 Roo.MessageBox.alert('Notice', 'DONE');
887 '|xns' : 'Roo.Toolbar',
890 cls : 'x-btn-text-icon',
891 icon : Roo.rootURL + 'images/default/tree/leaf.gif',
903 xtype : 'RowSelectionModel',
907 selectionchange : function (_self)
909 _this.grid.footer.onClick('first');
916 url : baseURL + '/Roo/metasql.php',
926 xtype : 'JsonReader',
934 totalProperty : 'total'
939 sortInfo : { field : 'sotrdate', direction: 'ASC' },
942 beforeload : function (_self, o)
945 if (!_this.bankacct.getValue()) {
948 var dt = _this.monthSel.getValue();
951 o.params['sortdate:text'] = typeof(dt) == 'string' ? dt : dt.format('Y-m-d');
953 o.params._group = 'bankrec';
954 o.params._name = 'bydate';
955 o.params['bankaccntid:number'] = _this.bankacct.getValue();
960 load : function (_self, records, options, res)
962 var sm = _this.wgrid.getSelectionModel();
964 if(_this.wgrid.lastSelectedRow * 1 >0){
965 sm.selectRow(_this.wgrid.lastSelectedRow);
969 if (!sm.getSelections().length) {
983 xtype : 'PagingToolbar',
984 emptyMsg : "No Date found",
986 displayMsg : "Displaying Date{0} - {1} of {2}",
990 autoExpandColumn : 'sortdate',
997 xtype : 'ColumnModel',
1000 renderer : function(v) {
1002 return v ? Date.parseDate(v,'Y-m-d').format('d/M/Y') : '';
1005 dataIndex : 'sortdate'
1008 '|xns' : 'Roo.grid',
1010 xtype : 'ColumnModel',
1011 header : 'Closing Balance',
1013 renderer : function(v,x,r) {
1015 var color = 'red'; // has some not 'ticked'
1017 if(r.data.no_records - r.data.no_posted == 0){ // all posted on that date
1020 if(r.data.no_records - r.data.no_cleared == 0 && r.data.no_posted != r.data.no_cleared){ // has 'ticked' or posted
1024 return String.format('<span style="color:{0}">{1}</span>', color, Roo.util.Format.number(v*1,2));
1027 dataIndex : 'balance'
1030 '|xns' : 'Roo.grid',
1032 xtype : 'ColumnModel',
1033 header : 'Reconciled',
1035 renderer : function(v,x,r) {
1041 if((r.data.no_records * 1 != r.data.no_posted * 1) || r.data.balance * 1 != v * 1){ // not match
1043 return '<span style="color:red;font-weight:bold">' + Roo.util.Format.number(v*1,2);
1046 return String.format('<span style="color:black">{0}</span>', Roo.util.Format.number(v*1,2));
1050 dataIndex : 'reconciled'
1053 '|xns' : 'Roo.grid',
1055 xtype : 'ColumnModel',
1058 renderer : function(v,x,r) {
1059 var state = v ? '-checked' : '';
1061 return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
1064 dataIndex : 'is_reconciled'
1071 //_this.dialog = Pman.Dialog.FILL_IN
1072 //if (_this.wpanel.active) {
1073 // this.footer.onClick('first');
1076 cellclick : function (_self, rowIndex, columnIndex, e)
1078 var di = this.colModel.getDataIndex(columnIndex);
1080 if (di != 'is_reconciled') {
1084 var rec = this.ds.getAt(rowIndex);
1086 var voidit = function(){
1088 url : baseURL + '/Roo/Bankrec.php',
1092 bankaccnt_id : _this.bankacct.getValue(),
1093 sotrdate : rec.data.sortdate
1096 success : function() {
1097 _this.wgrid.footer.onClick('refresh');
1102 var postit = function(){
1104 url : baseURL + '/Roo/Bankrec.php',
1108 bankaccnt_id : _this.bankacct.getValue(),
1109 sotrdate : rec.data.sortdate
1112 success : function() {
1113 _this.wgrid.footer.onClick('refresh');
1119 if(rec.data.is_reconciled == 1){
1130 rowclick : function (_self, rowIndex, e)
1133 _this.wgrid.lastSelectedRow = rowIndex;
1146 title : "Pick a Date",
1147 xtype : 'GridPanel',
1148 fitContainer : true,
1150 tableName : 'Groups',
1152 activate : function() {
1153 _this.wpanel = this;
1154 //if (_this.wgrid) {
1155 // _this.wgrid.footer.onClick('first');
1169 title : "Bank Reconcile",
1170 xtype : 'NestedLayoutPanel',