Tax calculation can be incorrect with multiple line items

Created on 14 May 2025, 9 days ago

When checking out with multiple line items, Taxjar (the API service) returns a tax amount for each line item, as well as an overall "amount to collect".

Commerce Taxjar (the Drupal module), always creates an order adjustment for each line item, using the individual line item tax amounts.

However, this calculation can be incorrect due to rounding errors.

For example, observed behavior:

  • given 3 line items
  • each line item tax amount of $7.666666 - rounds to $7.67
  • 3 commerce line item adjustments created for $7.67 each
  • "amount to collect" returned from Taxjar (API service) is $7.66666 * 3 = $23.00
  • total tax applied by line item adjustments is $23.01
  • Expected behavior:
    Total tax on order matches "amount to collect" returned from Taxjar (API service).

    Proposed solution:
    - Remove code that creates Commerce Line Item adjustments
    - Create a mechanism to create a single Commerce Order adjustment to represent tax

πŸ› Bug report
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States AaronBauman Philadelphia

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024