Line items with multiple price components have incorrect (sometimes negative) tax calculations

Created on 2 March 2022, about 3 years ago
Updated 14 May 2025, 8 days ago

Problem/Motivation

I have products that use rules that fire "Set the unit price to a specific amount" actions to adjust the base price of products on "Calculating the sell price of a product" events. This works by adding a 2nd 'base_price' component to the line item, but code in _commerce_taxjar_request_add_lines() is assuming a single 'base_price' component which means that as it loops through components it uses the last one. In most cases, the rules I have are lowering the price and this means the used 'base_price' component is negative and is displaying a negative sales tax.

Proposed resolution

In _commerce_taxjar_request_add_lines() at line 214 as this loops through price components and checks for 'base_price', change:

          $unit_price = ($component['price']['amount'] / (int) $line_item->quantity) / 100;

to

          $unit_price += ($component['price']['amount'] / (int) $line_item->quantity) / 100;
πŸ› Bug report
Status

Closed: outdated

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States cYu

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024