From b00db6a0093c7a05a455eae4ff94594a1ac1bffb Mon Sep 17 00:00:00 2001 From: Karl Cordes Date: Wed, 31 Mar 2010 15:52:48 +1100 Subject: [PATCH] Forgot the new JS --- webroot/js/lineItemPriceNoCosting.js | 59 ++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 webroot/js/lineItemPriceNoCosting.js diff --git a/webroot/js/lineItemPriceNoCosting.js b/webroot/js/lineItemPriceNoCosting.js new file mode 100644 index 00000000..c6769720 --- /dev/null +++ b/webroot/js/lineItemPriceNoCosting.js @@ -0,0 +1,59 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + + + +$(function () { + $("input.nocostinput").change(calcNetPrice); //When inputs of class nocostinput change. Calculate quick prices + + + +}) + + + + +/** + * 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; + } +}