Discussions
small script for price calculation
i want to calculate the minimum price we can sell an item based on the weight and the tax class. im new to suitescript, but heres what i have:
function AZmin()
{
var weight = nlapiGetFieldValue('weight');
if (weight <= 749)
{
var shipping = 2.87;
}
if (weight >= 750 && weight <=999)
{
var shipping = 3.49;
}
if (weight >= 1000)
{
var shipping = 5.67;
}
var avgcost = nlapiGetFieldValue('averagecost');
var taxcode = nlapiGetFieldValue('salestaxcode');
if (taxcode == "VAT:S")
{
var minprice = ((avgcost + shipping) /0.68);
}
if (taxcode == "VAT:C")
{
var minprice = ((avgcost + shipping) /0.8);
}
if (taxcode == "VAT:Z")
{
var minprice = ((avgcost + shipping) /0.85);
}
nlapiSetFieldValue("custitem_minprice", minprice);
return true;
}
I thought I could apply this to inventory items in the script deployment, but i cant. What would be the best way to implement this?