I posted a thread in another area of the user group. I need to change how NS calculates sales tax. We operate in one state only.
I need my sales tax to be computed as follows: (Total of local rates x subtotal) + (State sales tax x subtotal). With NS native calculation on sales tax I'm off by .$01 almost 50% of invoices.
This sounds silly but I need to calculate the tax this way do to the industry.
I did file a case with NS with no avail. After spending many hours within the help section and this forum I came up with a script. It seems to work.
The script resets the rate to my desired results...When an invoice is started a standard rate of say 7.125 (6.875+local tax) may become 7.119345. I also implemented another script to change the tax rate back per the NS zip code tax nexus in order for the main script to be able to recalculate effectively.
I'm pretty green with scripting. Does anyone see any issues? Please feel free to punch holes in this. Any feed back is appreciated:
function SetValues()
{
//Get tax rate for shipping site
var trate = nlapiGetFieldValue('taxrate');
//Get subtotal of invoice
var subtot = nlapiGetFieldValue('subtotal');
//Calculate local tax amount,If any.
(lrate = (trate-6.875)*.01*subtot);
//Calculate State Tax amount
(strate = 6.875*.01*subtot);
//Round local tax amound to the one cent.
(rlrate = Math.round(lrate*100)/100);
//Round state sales tax to the cent.
(rstrate = Math.round(strate*100)/100);
//Calculate new tax rate.
(finalrate = ((rlrate+rstrate)/subtot)*100);
//Change sales tax percentage to new rate.
nlapiSetFieldValue('taxrate',finalrate);
}