Project

General

Profile

Feature #3377 » SDATATABLEFIELD - PTRFINANCEITEM - AmountDebet - SelectFunction - TULISAN.js

Tri Rizqiaty, 01/30/2025 03:05 PM

 
1
var records = val.up('grid').getSelectionModel().getSelection(); var ExchangeRate = records[0].get('ExchangeRate'); var CurrencyFrom = records[0].get('Currency'); var CurrencyTo = records[0].get('CompanyCurrency'); var CompanyCurrAmount = Number(Math.round(parseInt(recs) + 'e2') + 'e-2'); if (CurrencyFrom != CurrencyTo) { CompanyCurrAmount = (Number(Math.round(parseInt(ExchangeRate) + 'e2') + 'e-2') * Number(Math.round(parseInt(recs) + 'e2') + 'e-2')); } records[0].set('AmountDebetCompCurr', CompanyCurrAmount); var menuid = MinovaUtil.GetMenuID(); var doctype = undefined; var accountvs = ''; var accounttax = ''; var flag = ''; var getPnl = Ext.ComponentQuery.query('[name=panelTabPTRFINANCEITEM]')[0]; var getTbl = getPnl.query('[name=gridCELLGRIDPTRFINANCEITEM]')[0]; var row = getTbl.store.indexOf(records[0]); 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; } } }); Ext.Ajax.request({ async: false, method: 'POST', url: '/UserControl/GetStore', params: { tableName: 'PCMFILODEFAULTACC', param: 'DocType[=]' + doctype + ',AccountID[=]' + records[0].get('GLAccountID') }, success: function (response) { var results = Ext.decode(response.responseText); if (results.data.length > 0) { accountvs = results.data[0].AccountVs; accounttax = results.data[0].AccountTax; flag = results.data[0].Flag; } } }); var store = Ext.StoreMgr.lookup("storePTRFINANCEITEM"); var amount = Number(Math.round(parseInt(recs) + 'e2') + 'e-2'); var fieldname = 'AmountCredit'; var fieldname2 = 'AmountCreditCompCurr'; if (doctype == 'AR') { if (flag == 'D') { fieldname = 'AmountDebet'; fieldname2 = 'AmountDebetCompCurr'; } if (accounttax != '') { store.getAt(row + 1).set(fieldname, amount - (amount * 100 / 110)); store.getAt(row + 2).set(fieldname, amount * 100 / 110); store.getAt(row + 1).set(fieldname2, store.getAt(row + 1).get(fieldname)); store.getAt(row + 2).set(fieldname2, store.getAt(row + 2).get(fieldname)); } else { if (accountvs != '') { store.getAt(row + 1).set(fieldname, amount); store.getAt(row + 1).set(fieldname2, store.getAt(row + 1).get(fieldname)); } } } else { if (accounttax != '') { store.getAt(row + 1).set('AmountDebet', amount * 10 / 100); store.getAt(row + 2).set('AmountCredit', amount + (amount * 10 / 100)); store.getAt(row + 1).set('AmountDebetCompCurr', store.getAt(row + 1).get('AmountDebet')); store.getAt(row + 2).set('AmountCreditCompCurr', store.getAt(row + 2).get('AmountDebet')); } else { if (accountvs != '') { store.getAt(row + 1).set('AmountCredit', amount); store.getAt(row + 1).set('AmountCreditCompCurr', store.getAt(row + 1).get('AmountCredit')); } } } var AmountDebet = 0; var AmountCredit = 0; var AmountDebetLast = 0; var AmountDebetBefore = 0; for (var i = 0; i < (store.count() - 1); i++) { AmountDebet = AmountDebet + parseFloat(store.getAt(i).get('AmountDebet')); AmountCredit = AmountCredit + parseFloat(store.getAt(i).get('AmountCredit')); AmountDebetLast = parseFloat(store.getAt(i).get('AmountDebet')); if (row == i) { AmountDebetBefore = parseFloat(store.getAt(i).get('AmountDebet')); } console.log('DLast ' + i.toString() + parseFloat(store.getAt(i).get('AmountDebetLast'))); console.log('DBefore ' + i.toString() + parseFloat(store.getAt(i).get('AmountDebetBefore'))); } var AmountDiff = 0; if (AmountDebetLast == 0) { AmountDiff = (AmountDebet + amount) - AmountCredit; } else { AmountDiff = (AmountDebet + amount - AmountDebetBefore) - AmountCredit; } if (AmountDiff < 0) { Ext.ComponentQuery.query('[name=amountdiff]')[0].setValue('Debet ' + AmountDiff.toString()); } else if (AmountDiff > 0) { Ext.ComponentQuery.query('[name=amountdiff]')[0].setValue('Credit ' + AmountDiff.toString()); } else { Ext.ComponentQuery.query('[name=amountdiff]')[0].setValue('Balance'); }
(3-3/6)