Skip to content

Commit d910579

Browse files
flocondetoilebojanz
authored andcommitted
Issue #2934538 by flocondetoile, bojanz: Tax amount removed twice for tax-exempt customer when price include tax
1 parent d2ec01a commit d910579

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

modules/tax/src/Plugin/Commerce/TaxType/LocalTaxTypeBase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ public function apply(OrderInterface $order) {
151151
if ($this->shouldRound()) {
152152
$tax_amount = $this->rounder->round($tax_amount);
153153
}
154-
if ($prices_include_tax && !$this->isDisplayInclusive()) {
154+
if ($prices_include_tax && !$this->isDisplayInclusive() && !$negate) {
155155
$unit_price = $unit_price->subtract($tax_amount);
156156
$order_item->setUnitPrice($unit_price);
157157
}

modules/tax/tests/src/Kernel/Plugin/Commerce/TaxType/CustomTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,26 @@ public function testTaxExemptPrices() {
225225
$order_item = reset($order_items);
226226
$this->assertEquals(new Price('10.33', 'USD'), $order_item->getUnitPrice());
227227

228+
// Confirm that the unit price is only reduced once
229+
// when the tax type itself is not display inclusive.
230+
$configuration['display_inclusive'] = FALSE;
231+
$this->plugin->setConfiguration($configuration);
232+
$order = $this->buildOrder('JP', 'RS', ['JP'], TRUE);
233+
$this->assertTrue($this->plugin->applies($order));
234+
$this->plugin->apply($order);
235+
$this->assertCount(1, $order->collectAdjustments());
236+
$adjustments = $order->collectAdjustments();
237+
$adjustment = reset($adjustments);
238+
$this->assertEquals(new Price('-1.72', 'USD'), $adjustment->getAmount());
239+
$this->assertEquals('0.2', $adjustment->getPercentage());
240+
$this->assertFalse($adjustment->isIncluded());
241+
$order_items = $order->getItems();
242+
$order_item = reset($order_items);
243+
$this->assertEquals(new Price('10.33', 'USD'), $order_item->getUnitPrice());
244+
// Revert the display_inclusive setting for the next set of assertions.
245+
$configuration['display_inclusive'] = TRUE;
246+
$this->plugin->setConfiguration($configuration);
247+
228248
// Applying the Japanese tax should replace the negative adjustment.
229249
// The price should stay the same in RS and JP regardless of which
230250
// tax is included.

0 commit comments

Comments
 (0)