Calculation by JavaScript

 

Function and Global Variable Declaration:

function calculation(){

var qty = $('#P60_QTY').val()||0;

var rate =$('#P60_RATE').val()||0;


var price = parseFloat(qty).toFixed(2)*parseFloat(rate).toFixed(2);

$('#P60_PRICE').val(price.toFixed(2))||0;


var disPct = $('#P60_DISCOUNT_PCT').val()||0;

var disAmnt = price*disPct/100

var aftreDis = price-disAmnt

$('#P60_DISCOUNT_PRICE').val(aftreDis.toFixed(2))||0;

$('#P60_DISCOUNT_AMOUNT').val(disAmnt.toFixed(2))||0;


document.getElementById("P60_DISCOUNT_PRICE_CONTAINER").classList.add("is-active");

document.getElementById("P60_TOTAL_LOCAL_CURRENCY_CONTAINER").classList.add("is-active");


// vat calculation 

var vatPct = $('#P60_VAT_PCT').val()||0;

var vatRate = parseFloat(aftreDis).toFixed(2)*parseFloat(vatPct).toFixed(2)/100;

$('#P60_VAT_RATE').val(vatRate.toFixed(2))||0;


// AIT calculation 

var aitPct = $('#P60_AIT_PCT').val()||0;

var aitRate = parseFloat(aftreDis).toFixed(2)*parseFloat(aitPct).toFixed(2)/100;

$('#P60_AIT_PRICE').val(aitRate.toFixed(2))||0;


// SD calculation 

var sdPct = $('#P60_SD_PCT').val()||0;

var sdRate = parseFloat(aftreDis).toFixed(2)*parseFloat(sdPct).toFixed(2)/100;

$('#P60_SD_RATE').val(sdRate.toFixed(2))||0;


// subTotal calculation 

var subTotal = aftreDis+vatRate+aitRate+sdRate

$('#P60_SUBTOTAL').val(subTotal.toFixed(2))


//local currancy

var currancyRate = $('#P60_CURRENCY_RATE').val()||0;

totalLocalCurrancy = subTotal*currancyRate

$('#P60_TOTAL_LOCAL_CURRENCY').val(totalLocalCurrancy.toFixed(0));

}


================================

select all Items-->Custom Attributes:  oninput="calculation();"


Post a Comment

Previous Post Next Post