question

wsadiq avatar image
wsadiq asked wsadiq answered

Tax Calculation on an Order

Hello,


I am having a hard time figuring out how Clover calculated taxes. I have looked at https://docs.clover.com/docs/calculating-order-totals and still cannot get to the total that Clover has come up with.


We have a the following order:



Pizza 1 x $18.10 = $18.10

Bread 1 x $2.45 = $2.45

Delivery Charge 1 x $5.00 (added as a non-taxable line item on the order).

Order subtotal = $25.55

Discount -$2.06 (calculated as 10% on subtotal excluding delivery charge).

Tax Total (Ours) $1.53

Tax Total (Clover) $1.56


I cannot explain this 3c difference. If we remove the delivery surcharge then the tax amount matches. But as I mentioned above, delivery surcharge is added as a non-taxable custom item so its inclusion or exclusion should not effect tax calculations.


Can you please help.

OrdersTaxes
4 comments
10 |2000

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

You may want to read this, https://community.clover.com/questions/27659/delivery-charges-for-orders-on-rest-api.html. You can mark an item as non-taxable, but you can't mark an item as being excluded from the discount. If this doesn't clear things up for you, provide the order id and environment.

0 Likes 0 ·
wsadiq avatar image wsadiq David Marginian ♦♦ ·

Hi David,


The issue is exactly the same as JMS's issue described in the post you mentioned but I do not see a resolution to it. This order is NDK5C9S3YFK94 in sandbox environment. Just like JMS's issue, we have a flat service charge and an order level discount resulting in a lower tax calculated then what Clover calculates.

0 Likes 0 ·

There is no fix for it. You will need to calculate the total as we do and not treat the non tax item specially regarding discounts.

0 Likes 0 ·
Show more comments
wsadiq avatar image
wsadiq answered
Hi David,


I think I figured out. I was not rounding the taxable part of the line item (after subtracting its portion of the order discount) before applying the tax rate. Once I did that, it is coming out correct.

2 comments
10 |2000

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

Ok, that last community post has some info on the calculation as well.
0 Likes 0 ·
wsadiq avatar image wsadiq David Marginian ♦♦ ·
I know and I was accounting for all the issues discussed in that post. I had missed rounding totals at one particular point and that was causing the error. Thanks for your help.
0 Likes 0 ·
wsadiq avatar image
wsadiq answered David Marginian Deactivated converted comment to answer

Ah.... Tax calculation errors keep coming back to haunt again and again. Can someone from Clover help. I have created a simple case in our dev environment. It is a simple order with 2 items, a $5 discount on the order and a $0.01 surcharge. Our system calculates tax of $0.37 while clover is calculating tax $0.38. The order receipt can be looked at here https://sandbox.dev.clover.com/r/59Q2QERGFEWF6..


We do not have an issue with surcharge when there is no discount. The same logic calculates the tax correctly in this case https://sandbox.dev.clover.com/r/NRBYWVJVPTA7T..


I have been racking my brain and cannot figure out where the rounding error is happening. Can anyone from Clover please help.

2 comments
10 |2000

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

Before I take a closer look at this order, information on calculating order totals can be found here - https://docs.clover.com/docs/calculating-order-totals.. Are you saying you are following those steps and not arriving at the same tax/total as documented? You may want to take a look at the accepted answer here for a better example - https://community.clover.com/questions/31457/taxes-with-amount-discounts-off-by-001.html.

0 Likes 0 ·
wsadiq avatar image wsadiq David Marginian ♦♦ ·

Hi Dave, As I mentioned in an earlier post in this thread dated Apr 21, 2021 - yes I am following those rules. I included 2 receipts. there is some weird rounding error that is happening somewhere in one of the two cases but I just cannot figure out. As you can see from one of the two receipts, the surcharge and discount are generally being correctly handled.

I am happy to provide program logic in a private email if you need. Ideally, we would have used https://docs.clover.com/reference/ordercheckoutatomicorder.. However, it is not very useful in its current form because it does not allow custom items and as per Clover's suggestions, delivery charges are best handled as custom line items. So we have to resort to trying to mimic Clover's logic which in our case is resulting in rounding error ONLY in some cases.


Thanks for your help.

0 Likes 0 ·

Welcome to the
Clover Developer Community