Xero - beautiful accounting software

Xero Developer Help Center

Xero Developer Community

Community > Getting Started >

Pre empting slight differences in totals.

Started by cxc Limited -   in Getting Started

Hey there,
We are currently working on an EDI system that transfers invoices between accounting packages. We are having a little trouble with rounding from other packages (like MYOB) and the consequences are that sometimes the totals of invoices are slightly out (usually by 1 cent) after Xero recalculates the total on import through the API. What I'd like to know is if you could provide the algorithm that XERO uses to do these calculations. This would allow us to put the invoice values through the same calculations and determine/ pre-empt these discrepancies and do something about it.

Any help/information on this is appreciated.
Hi Toby,

We calculate the tax on each line items, round it up to 2dp and then summed it all to get the total tax.

For example: 2.165 rounded up to 2.17 and 2.164 will be rounded down to 2.16

W. Abdullah (Community Manager)  

Thanks Welli, much appreciated,

I have a couple more questions.
Do you calculate tax based the unitprice or the lineItemTotal (quantity * unitPrice) and are either of these values rounded before tax is calculated?

Thanks again!

Toby Holland

cxc Limited  


It is based on the line item total so: tax = (quantity * unit price) * tax rate

We also only support 2dp for unit price, however we accept 4dp for quantity.
So if you entered more than 2dp for unit price, it will be rounded first and then calculated to get the line item total.

You can play around with Xero API Previewer to get familiar with the Xero rounding.

W. Abdullah (Community Manager)  

There are two things that you can do:

- Add additional line items for the difference and coded it to a rounding account (860) OR

- You can override Xero tax calculation by using <TaxAmount> element in the line items xml.

Aaron Geiser  


Just trying to get a client onto Xero but they need to send sales invoices to one of their customers via EDI. Currently they have sage Line 100 (yes there are still some using it!!) and their current software sucks the data out and then sends to their suppliers/customers - is this something that you have developed and we can utilise?

Duncan & Toplis  

Hey David, yes we have developed an EDI that interfaces with Xero. However I noticed that your profile indicates that you are from the UK and unfortunately we currently only support Australian and New Zealand versions of Xero (and other accounting packages). We do plan on eventually supporting more countries so you may register your interest at www.smeedi.com.

Kind Regards,
Toby Holland

cxc Limited  


The solution I need is for a company in Ireland - not sure if that makes any difference

Will log my interest on your website and thanks for the prompt response


Duncan & Toplis  


Did you ever find a solution for your Irish client? I have a similar need. Thanks.

Niall Garvey  

Hi Niall Garvey, could you please contact me with a little more detail of your requirements at toby@smeedi.com. Regards,


cxc Limited