Closed faisal-alvi closed 2 years ago
This appears to be an issue at API level - as opposed to an SDK issue.
4dp are accepted (when the unitdp=4 parameter is passed) on the unit amount and quantity fields but not on the discount field. In this case the discount is being rounded to 27.83 and then failing the validation against the unrounded 27.8260.
To workaround the issue the most reliable method would be to pre-round both values to 2dp and pass these. This will ensure that the validation passes as no rounding is necessary.
@wobinb thanks for the feedback, I have a couple of questions:
You can raise a case either within Xero by clicking the question mark in the top right corner, or by emailing api@xero.com.
There isn't any way of changing the behaviour of the rounding on the discount amount. Changing the unit amount to match would the most reliable workaround.
It is worth noting that from an accounting perspective the line amount gets rounded to 2dp when the journal is posted, so the end result will be the same.
Closing given this is API related and not SDK
SDK you're using (please complete the following information):
Describe the bug While using a WooCommerce Xero extension, faced an issue where we have passed the same value, "27.8260" to the Unit amount, Line amount, and the Discount amount but we get an error in the response, see the
DiscountRate
in the response:To Reproduce Steps to reproduce the behavior:
Expected behavior The passed Discount Amount should not be rounded to 2 decimals. That is creating the issue.
Additional context We pass whatever rounded amount in a request, we always get
DiscountRate
rounded to 2 decimals.