Project

General

Profile

Support #1900 » Discount Percent 20230124.js

Tri Rizqiaty, 01/30/2023 04:19 PM

 
1
var store = Ext.StoreMgr.lookup("storePTRSALESITEMS");
2
var grid = Ext.getCmp(gridName);
3
var selection = grid.getView().getSelectionModel().getSelection()[0];
4
var idx = grid.store.indexOf(selection);
5
var discountPercentage = val.value;
6
var priceAmount = store.getAt(idx).get('PriceAmount');
7
var quantityTransaction = store.getAt(idx).get('QuantityTransaction');
8
var discount = priceAmount * quantityTransaction * discountPercentage / 100;
9
var netAmount = (quantityTransaction * priceAmount) - discount;
10
var taxPercent = parseFloat(Ext.ComponentQuery.query('[name=TaxPercentage][nameTable=PTRSALESHEADER]')[0].getValue()) / 100;
11
console.log(taxPercent);
12
if (taxPercent == undefined) {
13
    taxPercent = 0;
14
} else {
15
    taxPercent = taxPercent;
16
}
17
var tax = "0";
18
var totAmount = 0;
19
if (store.getAt(idx).get('TaxType') == '1') {
20
    var _tax = Math.round(netAmount / (1 + taxPercent));
21
    tax = Math.round(netAmount - _tax);
22
    totAmount = netAmount;
23
} else if (store.getAt(idx).get('TaxType') == '2') {
24
    tax = Math.round(netAmount * taxPercent);
25
    totAmount = (netAmount + tax);
26
} else {
27
    var _tax = Math.round(netAmount / (1 + taxPercent));
28
    tax = Math.round(netAmount - _tax);
29
    totAmount = netAmount;
30
}
31
store.getAt(idx).set('Discount', discount);
32
store.getAt(idx).set('NetAmount', netAmount);
33
store.getAt(idx).set('Tax', tax);
34
store.getAt(idx).set('TotAmount', totAmount);
(3-3/5)