question

gerardo avatar image
gerardo asked anthonypinto answered

tax calculation...

Hi,

It seems Clover calculates taxes by grouping items that have the same tax rates, applying the rate to each item and then rounding up on the total. What happens when an item has two tax rates applied to it, let's say 10% and 5%? Do you group that item with others that also have a 15% (10%+5%) rate or do you group them with items that have 10% rate and items that have a 5% rate separately? Here's an example of what I mean using three items that cost $1, $2 and $3 and are respectively taxed at 5%, 10% and 5% + 10%. In other words, the third item has two tax rates applied to it, while the first two only have one tax rate, but different rates.

Possible Approach 1: Tax = roundup($1 * 10%) + roundup($2 * 5%) + round_up($3 * (10%+5%))

Possible Approach 2: Tax = roundup($1 * 10% + $3 * 10%) + roundup($2 * 5% + $3 * 5%)

Which approach is it?

Thanks,

Gerardo

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

anthonypinto avatar image
anthonypinto answered

Our approach resembles your second example

For each tax rate applicable to any subset of an order's line items we do the following:

  1. Find the discounted subtotal of all the lineitems under that tax rate

  2. Find a tax amount based on that subtotal

  3. Round that tax amount (using RoundingMode.HALF_UP)

Once we have the rounded tax amount for each applicable tax rate, it is added to gross total

10 |2000

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