1
|
var records = val.up('grid').getSelectionModel().getSelection();
|
2
|
var ExchangeRate = records[0].get('ExchangeRate');
|
3
|
var CurrencyFrom = records[0].get('Currency');
|
4
|
var CurrencyTo = records[0].get('CompanyCurrency');
|
5
|
var CompanyCurrAmount = Number(Math.round(parseInt(recs) + 'e2') + 'e-2');
|
6
|
if (CurrencyFrom != CurrencyTo) {
|
7
|
CompanyCurrAmount = (Number(Math.round(parseInt(ExchangeRate) + 'e2') + 'e-2') * Number(Math.round(parseInt(recs) + 'e2') + 'e-2'));
|
8
|
}
|
9
|
records[0].set('AmountDebetCompCurr', CompanyCurrAmount);
|
10
|
var menuid = MinovaUtil.GetMenuID();
|
11
|
var doctype = undefined;
|
12
|
var accountvs = '';
|
13
|
var accounttax = '';
|
14
|
var flag = '';
|
15
|
var getPnl = Ext.ComponentQuery.query('[name=panelTabPTRFINANCEITEM]')[0];
|
16
|
var getTbl = getPnl.query('[name=gridCELLGRIDPTRFINANCEITEM]')[0];
|
17
|
var row = getTbl.store.indexOf(records[0]);
|
18
|
Ext.Ajax.request({
|
19
|
async: false,
|
20
|
method: 'POST',
|
21
|
url: '/UserControl/GetStore',
|
22
|
params: {
|
23
|
tableName: 'PCMEPMODULETYPE',
|
24
|
param: 'MenuID[=]' + menuid
|
25
|
},
|
26
|
success: function (response) {
|
27
|
var results = Ext.decode(response.responseText);
|
28
|
if (results.data.length > 0) {
|
29
|
doctype = results.data[0].ModuleItem;
|
30
|
}
|
31
|
}
|
32
|
});
|
33
|
Ext.Ajax.request({
|
34
|
async: false,
|
35
|
method: 'POST',
|
36
|
url: '/UserControl/GetStore',
|
37
|
params: {
|
38
|
tableName: 'PCMFILODEFAULTACC',
|
39
|
param: 'DocType[=]' + doctype + ',AccountID[=]' + records[0].get('GLAccountID')
|
40
|
},
|
41
|
success: function (response) {
|
42
|
var results = Ext.decode(response.responseText);
|
43
|
if (results.data.length > 0) {
|
44
|
accountvs = results.data[0].AccountVs;
|
45
|
accounttax = results.data[0].AccountTax;
|
46
|
flag = results.data[0].Flag;
|
47
|
}
|
48
|
}
|
49
|
});
|
50
|
var store = Ext.StoreMgr.lookup("storePTRFINANCEITEM");
|
51
|
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;
|
52
|
var AmountCredit = 0;
|
53
|
var AmountDebetLast = 0;
|
54
|
var AmountDebetBefore = 0;
|
55
|
for (var i = 0; i < (store.count() - 1); i++) {
|
56
|
AmountDebet = AmountDebet + parseFloat(store.getAt(i).get('AmountDebet'));
|
57
|
AmountCredit = AmountCredit + parseFloat(store.getAt(i).get('AmountCredit'));
|
58
|
AmountDebetLast = parseFloat(store.getAt(i).get('AmountDebet'));
|
59
|
if (row == i) {
|
60
|
AmountDebetBefore = parseFloat(store.getAt(i).get('AmountDebet'));
|
61
|
}
|
62
|
console.log('DLast ' + i.toString() + parseFloat(store.getAt(i).get('AmountDebetLast')));
|
63
|
console.log('DBefore ' + i.toString() + parseFloat(store.getAt(i).get('AmountDebetBefore')));
|
64
|
}
|
65
|
var AmountDiff = 0;
|
66
|
if (AmountDebetLast == 0) {
|
67
|
AmountDiff = (AmountDebet + amount) - AmountCredit;
|
68
|
} else {
|
69
|
AmountDiff = (AmountDebet + amount - AmountDebetBefore) - AmountCredit;
|
70
|
}
|
71
|
if (AmountDiff < 0) {
|
72
|
Ext.ComponentQuery.query('[name=amountdiff]')[0].setValue('Debet ' + Ext.util.Format.number(AmountDiff, '0,000.00'));
|
73
|
} else if (AmountDiff > 0) {
|
74
|
Ext.ComponentQuery.query('[name=amountdiff]')[0].setValue('Credit ' + Ext.util.Format.number(AmountDiff, '0,000.00'));
|
75
|
} else {
|
76
|
Ext.ComponentQuery.query('[name=amountdiff]')[0].setValue('Balance');
|
77
|
}
|