Unit Level Rounding

If you prorate tax across an order, each line item has values for the single unit base price and the line item totals for gross, net, and tax. The single unit net price isn't calculated or stored. All rounding is done at the line level, which can cause rounding discrepancies. If your site experiences these discrepancies, you might need to use unit-level rounding.

When updating the tax with the dw.order.LineItem#updateTax() method, and using unit-level rounding, the tax is calculated for each unit, rounded, and then summed.

Note: The default implementation, using dw.ocapi.shop.basket.calculation, also considers this preference in the same way during calculation.

Many order management systems require the single unit net price to calculate refunds for returned products, which must be calculated based on the values that are provided in the order. One way to do this is to divide the net line total by the line item quantity. If the customer returns all three units from the order, the sum of all three returned items is a penny off from the calculated net total.

This feature is disabled by default. You must configure it in order site preferences and configure discount taxation in promotion site preferences.

The following table shows the formulas used for the tax calculations:

  Gross total Tax total Net total
Item level Round (BasePrice * Quantity) Round(GrossTotal * (1-(1/(1+TaxRate))) Round(GrossTotal - TaxTotal)
Unit level Round (BasePrice * Quantity)

$TaxUnit = Round(BasePrice * (1-(1/(1+TaxRate)))

TaxTotal = TaxUnit * Quantity

Round(GrossTotal - TaxTotal)

Configuration Setting

Example

The following table shows an order with three units of product_A, where line-level rounding (the default) is used:

Item Base price Quantity Tax rate Gross total Tax total Net total
1 $18.99 3 0.21% $56.97 $9.89 $47.08
        Gross total order Tax total order Net total order
        $56.97 $9.89 $47.08

The line item net total is 47.08.

Item Base price Quantity Tax rate Gross total Tax total Net total
1 $18.99 1 0.21% $18.99 $3.30 $15.69
2 $18.99 1 0.21% $18.99 $3.30 $15.69
3 $18.99 1 0.21% $18.99 $3.30 $15.69
        Gross total order Tax total order Net total order
        $56.97 $9.90 $47.07

If the order is for three line items of quantity one, the line item net total is $47.07, a one penny discrepancy.

When item price rounding is set to Item-level, the tax total formula is now in two parts (as shown in the above formula table):

  1. TaxUnit = Round(BasePrice * (1-(1/(1+TaxRate)))
  2. TaxTotal = TaxUnit * Quantity

Following the above example, the calculation for an order with three line items, each with a quantity of one, stays the same; while an order with one item with a quantity of three is as follows:

Item Base price Quantity Tax rate Gross total Tax total Net total
1 $18.99 3 0.21% $56.97 $9.90 $47.07
        Gross total order Tax total order Net total order
        $56.97 $9.90 $47.07

With rounding on the unit level, the order totals are the same regardless of whether products are in one or multiple line items.