Bug #4023 » purchitem-priceamount.js
| 1 |
var store = Ext.StoreMgr.lookup("storePTRPURCHITEM"); if (store != undefined) { var grid = Ext.getCmp(gridName); var selection = grid.getView().getSelectionModel().getSelection()[0]; var idx = grid.store.indexOf(selection); var val = Number(val.value); var priceAmount = isNaN(val) ? 0 : val; var materialQuantity = store.getAt(idx).get('MaterialQuantity'); var discountPercentage = store.getAt(idx).get('DiscountPercentage'); var discount = Math.round((priceAmount * materialQuantity) * (discountPercentage / 100)); var netAmount = Math.round((materialQuantity * priceAmount) - discount); store.getAt(idx).set('NetAmount', netAmount); var taxtype; if (taxtype != '') { taxtype = store.getAt(idx).get('TaxType'); } else { taxtype = '1'; } var persenparam = '0'; Ext.Ajax.request({ async: false, method: 'POST', url: '/UserControl/GetStore', params: { tableName: 'PCMEPGENPARAM', param: 'Parameter[=]TAXPPNPERCENTAGE' }, success: function (response) { var results = Ext.decode(response.responseText); persenparam = results.data[0].Value1; console.log(persenparam); } }); var tax = "0"; var totAmount = 0; if (taxtype === '2') { tax = Math.round(netAmount * (parseFloat(persenparam) / 100)); totAmount = (netAmount + tax); } else if (taxtype === '1') { tax = Math.round(netAmount - (netAmount / ((100 + parseFloat(persenparam)) / 100))); totAmount = netAmount + tax; } store.getAt(idx).set('TotAmount', totAmount); store.getAt(idx).set('Tax', tax); store.getAt(idx).set('Discount', discount); } |
|---|