question

captainben avatar image
captainben asked anton-sh answered

proper taxation when having discounts

Hi I am attempting to create an atomic order with a 5% discount, however I am noticing some issues with how sales tax is applied.

If i attempt to take the discount via the discount method via the order cart object subtotal in the atomic order, the sales tax is applied BEFORE the discount is created...which I don't think is the right way to calculate.

If I attempt to take the discount taking 5% off each line item, then when sales tax is calculated correctly HOWEVER I notice because of rounding issues, the discount is off by 1 cent.

So, how do I have clover calculate the sales to the subtotal AFTER the discount has been applied?

Thanks

REST API
10 |2000

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

bryanvargas avatar image
bryanvargas answered captainben commented

Hey, we have a guide on calculating order totals and taxes. I recommend reading through it: https://docs.clover.com/docs/calculating-order-totals#step-5-taxes

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.

captainben avatar image captainben commented ·

I just read that, but that does not address this issue which could be significant bug.

Let me give you an example use case, say we want to offer %5 off and sales tax on food only is 10.25% (delivery tax is 0%). Keep in mind this example is for an atomic order creation.

EXAMPLE #1: Line item discounting method

Stuffed Weekly Special $26.90
(line item discount: -$1.35 calculated via: .05 * 26.90 = 1.345 which gets rounded to 1.35)

Stuffed Mediterranean $25.95
(line item discount: -$1.30 calculated via: .05 * 25.95 = 1.2975 which gets rounded to 1.30)

DELIVERY_FEE $3.99
--------
Subtotal: $54.19
Sales tax: $5.15
Order total: $59.34

Clover is calculating the discount total via line item discounts to be: 2.65.

The problem with this...is if I were to do a discount on my total subtotal $52.85, I would do 52.85 * .05 = 2.6425....which is a DIFFERENT discount. The external payment source that is feeding the data to the clover api is calculating it's discount via the subtotal and not matching the result of clover. So we have a matching and proper sales tax calculation, but not a proper order discount match.

EXAMPLE #3: Add discount as its own line item

I used the pre-calculated subtotal discount as negative line item (-2.64).

However, it appears that the sales tax is not grouping the items together to include that negative number off the sales tax calculation, giving a tax calculation of: $5.64.

Clover ignores the negative -2.64, and then that leads to a false sales tax calculation

EXAMPLE #3: Total Cart Discounting Method

Because I already know the external source is calculating the discount via the subtotal, I should be able to put in the total discount via a discount on the atomic order order cart, however the results have some discrepancies.

CLOVER total sales tax is calculated to: $5.17

My external sourced used the tax calculation of ((26.90 + 25.95) - ((26.90 + 25.95) * .05)) * .1025 = 5.15

I have spent alot of time trying to figure this out, none are correct. Please explain.


0 Likes 0 ·
captainben avatar image captainben captainben commented ·

@bryan.vargas just want to make sure you saw my response...

0 Likes 0 ·
bryanvargas avatar image
bryanvargas answered bryanvargas edited

Not sure if you read the note we have: When rounding decimal amounts smaller than a cent, such as tax per line item, calculate rounding with the round half up rule. For example, the rounding value of $33.654 is $33.65 and the rounding value of $33.455 is $33.46.

Clover has a 1-cent rounding. Line item rounding will be a cent off because you are doing it individually and each fee is rounded up instead of the combined total(which rounds up one number). This is not an issue or a bug.

10 |2000

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

captainben avatar image
captainben answered parquet76 edited

@bryan.vargas I know your busy, but please review the scenario #3 I posted in more depth with the scenario I have given.

I am aware of how the rounding occurs, but can you explain in more depth how clover is arriving at the 5.17 cent sales tax amount.

Would appreciate it if you can walk me through that calculation.

3 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.

parquet76 avatar image parquet76 commented ·

You can't calculate taxes like that. It is PER item. Why? Because different items could potentially have different rates or be due to different authorities. The link bryan sent you has calculation examples.

0 Likes 0 ·
captainben avatar image captainben parquet76 commented ·

@parquet76 thanks for responding, not sure why bryan is not responding. That said, if that is the case, it's a huge gap. When bringing data into clover that has been externally paid for, it's important to be able to match the calculations of the external payment for proper accounting and taxation.

Not only is matching the data important...per line item can be considered WRONG. Which is crazy that this is the only option.

It's the sub-TOTAL of items in a certain taxation group that are then supposed to be calculated.

I guess the feature request would be that there should be an option in the API that would allow for the taxation to be calculated via tax group subtotal or line by line...but that said...line by line because of rounding..will sometime resulting in incorrect taxation. This is...crazy that this point I am bringing is being so easily disregarded by clover staff and there is no other way to get a response other than this forum on a matter that while results in pennies per transaction could amount to millions in false calculations and false tax reporting

0 Likes 0 ·
parquet76 avatar image parquet76 captainben commented ·

Per line item is not "WRONG" - Clover does hundreds of billions of dollars in transaction volume per year, I think they know how to calculate taxes/totals correctly. Also, if multiple line items on an order have the same tax rate, Clover will group them as you would expect, per the Clover docs:

If multiple line items in an order are taxed using the same tax rate object, Clover calculates taxes on the subtotal of those items. In the above example, if the same Tax A object of 10% is applied to the $11.05 and $7.65 values, calculate tax on the sum of these values.

https://docs.clover.com/docs/calculating-order-totals

0 Likes 0 ·
anton-sh avatar image
anton-sh answered

@captainben Hi! Are there any updates on your issue?

It looks like I have similar behavior with a discount applied.

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