Working with Taxes using Commerce API
There are two tax calculation features available in NetSuite — SuiteTax and Legacy Taxes. SuiteTax uses internal or external tax engines to calculate taxes for transactions in NetSuite. At present, SuiteTax is available only for Commerce web stores that cater to the US and Canada. See SuiteTax and SuiteCommerce SuiteTax Support for more information about SuiteTax.
SuiteTax is not supported for tax calculation on SiteBuilder websites.
SuiteTax
SuiteTax calculates the total taxes applicable for each item in a sales order. The following methods retrieve SuiteTax tax calculations for a web store order:
-
recalculateTaxes()
-triggers tax calculation for a sales order. Taxes are not calculated or recalculated unless this method is called. -
getTaxDetails(), getTaxDetails(fields)
-retrieves tax details for each line item in the sales order, including items, shipping, and handling (if set up as separate from shipping). If multiple tax types apply to a sales order, this method retrieves ataxdetails
object for each tax type for each line item.-
The
taxdetailsreference
field for an item in theorderitem
object matches thetaxdetailsreference
field in the relatedtaxdetails
objects returned bygetTaxDetails()
. IfgetTaxDetails()
does not return anytaxdetails
objects with a matchingtaxdetailsreference
field, it means no taxes are applicable for that item. -
The
taxamount
field contains the total of the taxes applicable for the item. If multiple taxes apply to a line item, this is the total amount for the tax type in thetaxtype
field.
-
-
getOrderSummary(fields)
-retrieves the fields:-
taxonshipping
-shipping tax amount. -
taxtotal
-total taxes for the whole order.
-
-
getSummaryTaxTotals()
-retrieves the tax amount per tax type for the whole sales order. If multiple tax types apply to a sales order, this method returns multiplesummarytax
objects.
Legacy Taxes
The field used for legacy taxes must not be used if SuiteTax is enabled.
In the United States, per item taxes are not applied to an order. Instead tax is applied to the entire order. The following tax fields are present in the orderitem
object and are only used when countries require per line tax:
-
taxtype1
-
taxrate1
-
taxtype2
-
taxrate2
Since every line can have a different tax type or tax rate you should define the taxes per order line. When a line is not taxed, omit those fields.
You should also check the value of pricesincludevat
in the sitesettings
object to verify whether taxes are included in the price. These fields are only required when tax is not included in the price.