Square Banker’s Rounding Clarification

We have been working with the Square API and have some issues with tax calculations that result in: “The total of the requested payments does not match the total of the sale order”. We have found that in some cases Square uses Banker’s rounding but in other cases it uses conventional rounding. I will provide some examples below. The tax rate I am using is 8.875%

Order #1:

  • Item 1: $18.80
  • Item 2: $6.95

Subtotal: $25.75

Itemized Tax:

  • Item 1: $1.6685
  • Item 2: $0.6168125

Itemized Tax Total: $2.2853125

Subtotal Tax: 25.75 * 0.08875 = $2.2853125

Square’s Tax: $2.29

Using conventional rounding at 3dp for both itemized tax total and subtotal tax ($2.285) results in $2.29, since we would round up at 5 and is consistent with the Square’s tax. But for banker’s rounding at 3dp, $2.285 would round to $2.28 which is inconsistent with Square’s tax. If we applied banker’s rounding from the tail end of the number $2.2853125 would round to $2.28 where ($2.285313 → $2.28531 → $2.2853 → $2.285 → $2.28) it is still inconsistent.

In this example, we see that conventional rounding resulted in the tax calculation that is consistent with square but not with banker’s rounding. I will provide another example where using banker’s rounding is consistent with square’s tax calculation.

Order #2:

  • Item 1: $15
  • Item 2: $8
  • Item 3: $6.95
  • Item 4: $6.95

Subtotal: $36.90

Itemized Tax:

  • Item 1: $1.33125
  • Item 2: $0.71
  • Item 3: $0.6168125
  • Item 4: $0.6168125

Itemized Tax Total: $3.274875

Subtotal Tax: 36.90 * 0.08875 = $3.274875

Square’s Tax: $3.27

Using conventional rounding at 3dp $3.274 would round to $3.27, because we would round down at 4. Same with banker’s rounding at 3dp $3.274 would round down to $3.27.

However, if we applied banker’s rounding from the tail end of the number $3.274875 would round to $3.28 where ($3.274875 → $3.27488 → $3.2749 → $3.275 → $3.28).

We would like some clarity as to how Square actually calculates tax. Does banker’s rounding happen at 3dp or at every digit from the tail end of the number until it reaches 2dp? In addition, does Square apply tax to each item, then apply rounding and finally add up the total tax or is the tax only applied on the subtotal?

We dont calculate the tax directly for each line item. The total of all the line items that a particular tax will be applied to is summed up first to get the ‘taxable base’ and then following that, we multiply the rate by this base to get the total amount of that tax to apply. Once we know the total amount of tax to apply, it gets allocated back down to the line items based on their pro rata share of the total ‘tax base’.

The way the ‘bubble distribution’ works is that it always starts with the line item that makes up the greatest portion of the total tax base, allocates its share of the total tax, and works down from there to the next biggest segment of the total tax base. This is to make it so that the ordering of the line_items in the array does not affect which line item has its share calculated first. :slightly_smiling_face:

Thank you for explaining how Square calculates tax.

We would like to further clarify how banker’s rounding actually works. For example if the total tax is $3.4651 would the correct rounding be $3.47 (where we round up because it is not $3.4650 at the exact middle) or would it be $3.46 (where we still apply banker’s rounding to the nearest even number regardless of the 4th dp).

Looking forward to your response.

If the total is $3.4651 it will round to $3.47 where you round up because it is not $3.4650 at the exact middle. :slightly_smiling_face: