2010-03-30 21:52:48 -07:00
|
|
|
$(function () {
|
|
|
|
|
$("input.nocostinput").change(calcNetPrice); //When inputs of class nocostinput change. Calculate quick prices
|
|
|
|
|
|
2010-04-07 20:21:47 -07:00
|
|
|
|
2010-03-30 21:52:48 -07:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Do the simple calculation of net price after discount.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function calcNetPrice() {
|
|
|
|
|
var discountPercent = $("#discountPercent").val();
|
|
|
|
|
var unitPrice = $('#unitPrice').val();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var quantity = $('#LineItemQuantity').val();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var grossSellPrice = quantity * unitPrice;
|
|
|
|
|
|
|
|
|
|
//Calculate the Sale Discount amount.
|
|
|
|
|
var UnitDiscountAmount = (discountPercent/100) * unitPrice;
|
|
|
|
|
|
|
|
|
|
var TotalDiscountAmount = (discountPercent/100) * grossSellPrice;
|
|
|
|
|
UnitDiscountAmount = UnitDiscountAmount.toFixed(2);
|
|
|
|
|
TotalDiscountAmount = TotalDiscountAmount.toFixed(2);
|
|
|
|
|
|
|
|
|
|
$('#total_discountAmount').val(TotalDiscountAmount);
|
|
|
|
|
$('#discountAmountEach').val(UnitDiscountAmount);
|
|
|
|
|
$('#net_price_each').val(unitPrice - UnitDiscountAmount);
|
|
|
|
|
|
|
|
|
|
$('#grossPrice').val(grossSellPrice);
|
|
|
|
|
|
|
|
|
|
var netPrice = grossSellPrice - TotalDiscountAmount;
|
|
|
|
|
$('#netPrice').val(netPrice);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function checkNaN(value) {
|
|
|
|
|
if( isNaN(value) == true) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
return value;
|
|
|
|
|
}
|
|
|
|
|
}
|