Hello,
I am working on small project that requires this:
have three fields:
- Basic price:
- NET price
- Gross price
NET Price is determend by Profit margin rate
Gross price is detremend by VAT rate
I need to be able to "live" update all three fields no mater where is the input.
e.g if I type in basic price Net price and gross price will update automaticly, or if typed Gross price Net price and basic price will update automaticly
So far I have his:
1. NET and gross price update:
Code:
function updateNet() {
if( document.adminForm.product_price_incl_tax.value != '' ) {
var taxRate = getTaxRate();
var r = new RegExp("\,", "i");
document.adminForm.product_price_incl_tax.value = document.adminForm.product_price_incl_tax.value.replace( r, "." );
var netValue = document.adminForm.product_price_incl_tax.value;
if (taxRate > 0) {
netValue = netValue / (taxRate + 1);
}
document.adminForm.product_price.value = doRound(netValue, 5);
}
}
2. gross and NET price update:
Code:
function updateGross() {
if( document.adminForm.product_price.value != '' ) {
var taxRate = getTaxRate();
var r = new RegExp("\,", "i");
document.adminForm.product_price.value = document.adminForm.product_price.value.replace( r, "." );
var grossValue = document.adminForm.product_price.value;
if (taxRate > 0) {
grossValue = grossValue * (taxRate + 1);
}
document.adminForm.product_price_incl_tax.value = doRound(grossValue, 5);
}
}
3. Basic and NET price update:
Code:
function updateProfit() {
if( document.adminForm.product_profitmargin_price.value != '' ) {
var profitRate = getProfitRate();
var r = new RegExp("\,", "i");
document.adminForm.product_profitmargin_price.value = document.adminForm.product_profitmargin_price.value.replace( r, "." );
document.adminForm.product_price_incl_tax.value = document.adminForm.product_price_incl_tax.value.replace( r, "." );
var netValue = document.adminForm.product_profitmargin_price.value;
if (profitRate > 0) {
netValue = netValue * (profitRate + 1);
}
document.adminForm.product_price.value = doRound(netValue, 5);
}
}
so I am missing as described above, possibility to update all three fields at once and currently stacked with this partial solution
Any help is highly appreciated.