1
|
var getPnl = Ext.ComponentQuery.query('[name=panelTabPTRFINANCEITEM]')[0]; var getTbl = getPnl.query('[name=gridCELLGRIDPTRFINANCEITEM]')[0]; var records = getTbl.getSelectionModel().getSelection()[0]; var row = getTbl.store.indexOf(records); records.set('AccountGroup', val.selection.data.AccountClass); var Status = ''; if (val.selection.data.Clearing == '1') { Status = '0'; } else if (val.selection.data.Clearing == '0') { Status = '2'; } var menuid = MinovaUtil.GetMenuID(); var doctype = undefined; var flag = undefined; var accountvs = ''; var accounttax = ''; Ext.Ajax.request({ async: false, method: 'POST', url: '/UserControl/GetStore', params: { tableName: 'PCMEPMODULETYPE', param: 'MenuID[=]' + menuid }, success: function (response) { var results = Ext.decode(response.responseText); if (results.data.length > 0) { doctype = results.data[0].ModuleItem; } } }); if (doctype == 'IP') { Status = '2'; } records.set('ItemStatus', Status); records.set('SubLedgerType', val.selection.data.SLType); records.set('SubLedgerID', ''); var cc = ''; if (val.selection.data.CostCenter == '1') { cc = Ext.ComponentQuery.query("[name=CostCenter]")[0].getValue(); } records.set('CostCenter', cc); Ext.Ajax.request({ async: false, method: 'POST', url: '/UserControl/GetStore', params: { tableName: 'PCMFILODEFAULTACC', param: 'DocType[=]' + doctype + ',AccountID[=]' + val.selection.data.GlAccount }, success: function (response) { var results = Ext.decode(response.responseText); if (results.data.length > 0) { flag = results.data[0].Flag; accountvs = results.data[0].AccountVs; accounttax = results.data[0].AccountTax; } } }); var store = Ext.StoreMgr.lookup("storePTRFINANCEITEM"); var debet = 0; var credit = 0; var sumcredit = 0; if (flag == 'K') { for (var i = row - 1; i >= 0; i--) { credit = store.getAt(i).get('AmountCredit'); credit = Number(Math.round(parseInt(credit) + 'e2') + 'e-2'); if (credit > 0) { break; } debet = store.getAt(i).get('AmountDebet'); debet = Number(Math.round(parseInt(debet) + 'e2') + 'e-2'); sumcredit = sumcredit + debet; } } store.getAt(row).set('AmountCredit', sumcredit); store.getAt(row).set('AmountCreditCompCurr', store.getAt(row).get('AmountCredit')); if (row > 0) { if (store.getAt(row - 1).get('AmountCredit') == 0) { store.getAt(row).set('Description', store.getAt(row - 1).get('Description')); } } if (accounttax != '') { console.log('nwh'); Ext.ComponentQuery.query('button[name=addPTRFINANCEITEM]')[0].getEl().dom.click(); store.getAt(row + 1).set('GLAccountID', accounttax); Ext.Ajax.request({ async: false, method: 'POST', url: '/UserControl/GetStore', params: { tableName: 'PDSACCCOMP', param: 'GlAccount[=]' + store.getAt(row + 1).get('GLAccountID') }, success: function (response) { var results = Ext.decode(response.responseText); if (results.data.length > 0) { if (results.data[0].Clearing == '1') { store.getAt(row + 1).set('ItemStatus', '0'); if (doctype == 'IP') { store.getAt(row + 1).set('ItemStatus', '2'); } } else if (results.data[0].Clearing == '0') { store.getAt(row + 1).set('ItemStatus', '2'); } } } }); Ext.ComponentQuery.query('button[name=addPTRFINANCEITEM]')[0].getEl().dom.click(); store.getAt(row + 2).set('GLAccountID', accountvs); Ext.Ajax.request({ async: false, method: 'POST', url: '/UserControl/GetStore', params: { tableName: 'PDSACCCOMP', param: 'GlAccount[=]' + store.getAt(row + 2).get('GLAccountID') }, success: function (response) { var results = Ext.decode(response.responseText); if (results.data.length > 0) { if (results.data[0].Clearing == '1') { store.getAt(row + 2).set('ItemStatus', '0'); if (doctype == 'IP') { store.getAt(row + 1).set('ItemStatus', '2'); } } else if (results.data[0].Clearing == '0') { store.getAt(row + 2).set('ItemStatus', '2'); } } } }); } else { if (accountvs != '') { Ext.ComponentQuery.query('button[name=addPTRFINANCEITEM]')[0].getEl().dom.click(); store.getAt(row + 1).set('GLAccountID', accountvs); Ext.Ajax.request({ async: false, method: 'POST', url: '/UserControl/GetStore', params: { tableName: 'PDSACCCOMP', param: 'GlAccount[=]' + store.getAt(row + 1).get('GLAccountID') }, success: function (response) { var results = Ext.decode(response.responseText); if (results.data.length > 0) { if (results.data[0].Clearing == '1') { store.getAt(row + 1).set('ItemStatus', '0'); if (doctype == 'IP') { store.getAt(row + 1).set('ItemStatus', '2'); } } else if (results.data[0].Clearing == '0') { store.getAt(row + 1).set('ItemStatus', '2'); } } } }); } } val.ownerCt.completeEdit(); Ext.ComponentQuery.query('[name=gridCELLGRIDPTRFINANCEITEM]')[0].view.refresh();
|