Rounding in Xero


Xero may calculate line item or document totals in ways that are slightly different to other applications. Neither approach is necessarily incorrect, just slightly different.
This guide documents possible scenarios and ways to handle them via the API.

Line item totals

Xero calculates tax on a per line basis, rounding to two decimal places, and then sums the tax totals of each line to calculate the total invoice tax. Other systems may total lines and then calculate the tax amount, which can lead to a slight variance.


Invoice line 1: Product A @ $25.06, tax at 15%: $3.76 line total: $28.82
Invoice line 2: Product B @ $25.61, tax at 15%: $3.84 line total: $29.45
Invoice line 3: Product C @ $25.63, tax at 15%: $3.85 line total: $29.48

Xero totals: Subtotal: $76.30, Tax: $11.44
Xero document total: $87.74

Another system total: Subtotal: $76.30 + Tax @ 15%: 11.45
This can be illustrated below in Xero as the approach is the equivalent of just having one line in Xero:

Unit prices

All monetary calculations in Xero are to two decimals places. This can be troublesome when importing transactions into Xero from source systems that support more than 2 decimal places, particularly on unit prices.

If the source system has a line with many decimal places, eg:
Invoice line 1: 1000 x Product A @ $0.061171 (sub total of $61.17)

A better way to represent this line in Xero might be:

      <Description>1000 x Product A @ $0.061171</Description>

Ways to resolve

To ensure you can resolve any rounding issues, you will need to know when they occur. There are two approaches you can take:

  1. Apply the same logic to calculations and rounding as Xero, so your application knows in advance of any issues and can add an adjustment as required
  2. Read the response from the API when you have created the item, and if there is a variation between the expected total and the total in Xero, edit the item and add an adjustment line

Rounding Line

If possible, you should add a rounding line to adjust the total to reflect the source system:

      <Description>Rounding adjustment: document total $87.75</Description>

Every Xero organisation will have a rounding account, but you should ensure the account code is correct by making a GET Accounts API call at setup/configuration stage to ensure it is either the default value above, or if the user has changed it to another code, it can be found by the following element within the <Account/> element:


Overriding TaxAmount

With the Invoices endpoint, you can now use the element to enter your own tax calculation and override Xero’s default calculation.

Eg: on PUT or POST Invoice:

      <Description>My own calculation</Description>


  • This is currently only available on the Invoices endpoint for Tax Exclusive invoices
  • TaxAmount specified cannot be greater than the UnitAmount