cmc-sales/webroot/js/quotenik/product_buildup.js
Karl Cordes 4347aee5f0 Changes
2009-11-04 17:12:12 +11:00

51 lines
1.4 KiB
JavaScript
Executable file

function buildup() {
//Fetch all the relevent inputs from the form
costprice = +($F('costprice'));
ourdiscount_percentage = +($F('ourdiscount'));
packing_each = +($F('packing'));
exchange_rate = +($F('exchange_rate'));
shipping_cost = +($F('shippingcost_each'));
duty = +($F('duty'));
sellprice_each = +($F('sellprice_each'));
customs = +($F('customs'));
misc_cost = +($F('misc_cost'));
finance = +($F('finance'));
if(ourdiscount_percentage != 0) {
discount = ourdiscount_percentage / 100;
}
else {
discount = 0;
}
discountamount = discount * costprice;
net_foreign_price = costprice - discountamount;
total_foreign_price = net_foreign_price + packing_each;
$('fob_country_of_export').value = total_foreign_price;
domestic_cost = total_foreign_price / exchange_rate;
$('convert_to_aud').value = domestic_cost.toFixed(2);
dutyamount = (duty / 100) * domestic_cost;
total_landed_cost = domestic_cost + dutyamount + customs + misc_cost + shipping_cost;
financeamount = (finance / 100) * domestic_cost;
financeamount = financeamount.toFixed(2);
$('financeamount').update('Finance amount: ' + financeamount);
total_landed_cost += (+financeamount);
total_landed_cost = total_landed_cost.toFixed(2);
$('total_landed_cost').value = total_landed_cost;
gross_profit_dollars = sellprice_each - total_landed_cost
$('gross_profit_dollars').value = gross_profit_dollars;
$('gross_profit_percent').value = ((gross_profit_dollars / sellprice_each)*100).toFixed(2);
}