question

greg avatar image
greg asked brokenoval answered

Function for calculating total tax of an order

I realized that tax is obviously only retrievable from orders that have been paid (using the REST API payments endpoint). I was surprised to find out in other discussions (e.g. here: https://community.clover.com/questions/16077/orde... that for calculating the tax of an unpaid order one should use an algorithm defined in the developer documentation:

https://community.clover.com/questions/16077/order...


Implementing this without any bugs seems not an easy task. I wonder if Clover could provide a way to retrieve this value without letting many developers do the exact same work? Especially as the Register app has to do the same work before payment.

In the end this procedure is necessary to calculate the net revenues, which is a highly relevant number for every company owner. So it should not be made that complicated. A Python example on your github account would be awesome.


REST APITaxes
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
brokenoval avatar image
brokenoval answered
It's a pretty common question actually and I know nothing is currently available.

FYI, when you do the tax calculations you should follow these rules:
  • Tax is calculated at an order level (i.e. don't try calculating tax for multiple orders/ order rates as it won't balance at a macro level)
  • Rounding is very important and where to round is key, follow this logical pattern:
    • For every order group items by Tax Rate (bear in mind some items can have multiple tax rates so should be in multiple groups)
    • Sum the value of each group (e.g. if you have 2 items at 13.5%, add them together first)• Calculate the tax for each group separately
    • Round the total of each tax group to 2 decimal places
    • Sum the tax on each tax group to get the Total Tax on the order

Some of this is documented here: https://docs.clover.com/clover-platform/docs/work... the grouped items confused me for a while as I assumed wrongly at first that the rounding happens at the order level and then wrongly again that the rounding happens at a line item level.

The tax calculation differs whether you are in the US (exclusive) or EU (inclusive) - so bear that in mind too.

God speed
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Welcome to the
Clover Developer Community