Xero - beautiful accounting software

Xero Developer Help Center

Xero Developer Community

Community > API Endpoints >

Request for Comments - Four Decimal places (4DP)

Started by Ronan Quirke (Community Manager) -   in API Endpoints

This coming Monday, 23rd June, Xero plans on releasing a change to the decimal place precision on unit amounts in Xero.

We wanted to share some details of our plans in advance so you can prepare for this change, and let us know if you have any concerns.

This change will see Xero move from supporting two decimal places on unit prices (unit amounts) to four decimal places.

This is great news for those developers that have been requesting better decimal place support in Xero, but we are conscious that some developers currently send values into the API with higher decimal place precision than we support, and have these values automatically rounded to two decimal places.

In order to prevent this new functionality from becoming a breaking change for existing integrations, we have decided to maintain two decimal place support by default, where possible in the API.

Developers can use four decimal place feature, but only by specifically requesting it, via an additional querystring parameter.

This solution is not perfect however, and there will be scenarios such as retrieving data out of Xero which has values to four decimal places, where 2DP behaviour by default will be problematic.

FAQ’s

What values will support four decimal places?
This change will only be implemented on the unit price field (the UnitAmount field in API language) - this field is supported anywhere there are line items such as invoices, credit notes and bank transactions. All other summary values such as Total, LineAmount etc will remain at two decimal places only.

What should I do to support additional decimal places in my integration?
On Monday, our release notes will contain details of how to implement the new opt-in parameter to enable four decimal places. To future proof your integration, please don’t rely on Xero rounding values for you - please only supply values to the decimal places you support: either two or four.

Thanks for the update - will the querystring parameter be a permanent solution or is it likely to change?

This will probably be in the release notes mentioned in the FAQ but will there be issues when sending values with 2DP but setting the querystring parameter to 4DP or true depending on what is needed (i.e. can we just set it to 4DP and still send 2DP values?)
 

Matthew O'Grady  

Hi Matthew

The parameter will be a permanent solution for this version of the API. Whenever we release a new API version, we will most likely support 4DP by default.

There should be no issue sending in a 2DP value when you have opted in for support of 4DP, we are just concerned that anyone who is currently sending in more DP's than we support, having an integration behave unexpectedly when we support additional decimal places.
 

Ronan Quirke (Community Manager)  

A quick update from our Developer API team. We're very close to finalising the next Xero API release (v2.55) which will include opt-in support for using 4dp on line items which was introduced in the Xero app today.

We expect to release this during the week of 23-27 June.

I'll post another update here once this is available with a link to the release notes.
 

Tony Rule (Xero Staff)  

Hi Guys,

Just wondering if you're far away from this one? If it is still a while off is there any chance you could send through or direct me to some information on how it is being implemented.

Cheers!
 

Matthew O'Grady  

Hi Matthew

The team shipped support for this today. Details here: http://developer.xero.com/documentation/api/v2-release-notes/#2.55

Let me know if you have any questions.

Ronan
 

Ronan Quirke (Community Manager)  

Hi Ronan,

We have updated our API import script with "unitdp" => "4" in July. The code worked fine until recently. When we tried to import the data today, the rounding didn't wotk anymore. We haven't changed the script. Was something changed at your end?

Thank you!
 

Natalie Kuznetsova  

Hi Natalie,

We haven't changed anything with Xero API that can affect this. I also tried adding/retrieving invoices with ?unitdp=4 and it is still work as expected.

Would you able to contact Xero API support (api at xero dot com) with the details of your application so we can check its logs?
 

W. Abdullah (Community Manager)  

Could I please have some help using the 4 DP.

I am using the Api wrapper provided in Github. With the wrapper there are properties exposed.
Could you explain how to set this to 4dp.
 

Phil Williams  

Hello I am new to Xero, would like to see how my online version (United States), will allow me to enter four digit decimal. I am dealing mainly with exports and require 4 digits, please help
 

Shinu Thankachan  

Hi, I am trying to add ?unitdp=4d to my url in this way
https://api-partner.network.xero.com/api.xro/2.0/Invoices?unitdp=4

but I am receiving this error
oauth_problem=signature_invalid&oauth_problem_advice=Failed%20to%20validate%20signature

if I remove the ?unitdp=4 it all works as expected (but only 2 decimal places for the line item charge amounts.)

Can you help?
 

Eric Sigurdson  

@Eric - it sounds like you may not be adding this in the correct way so that it is part of the OAuth signing process.

Can I suggest you start a new thread with some more details on the programming language you are using and anything else that might be useful to help you sort this out?

Ronan
 

Ronan Quirke (Community Manager)  

It's ok, I've worked it out. Thanks!
 

Eric Sigurdson  

Hi, I am trying to add ?unitdp=4d to my url in this way
https://api.xero.com/api.xro/2.0/Invoices?unitdp=4

but I am receiving this error
oauth_problem=signature_invalid&oauth_problem_advice=Failed%20to%20validate%20signature

Can anyone suggest where i am wrong?
 

Barry Dennis  

Is there a post created to request 5 decimal points?
 

Katie Kirkland  

Dear Xero,

My bank statement in in KWD, which requires 3 decimal places. How can i change my xero setting to capture the 3-digit decimal. for your assistance please. Thanks!
 

Elaine Novel Dawis