Skip to content

Commit 32c51d4

Browse files
committed
Check negative difference after rounding #10790
1 parent 2416307 commit 32c51d4

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

app/code/Magento/Tax/Model/Calculation/AbstractAggregateCalculator.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,16 @@ protected function calculateWithTaxNotInPrice(QuoteDetailsItemInterface $item, $
150150
$rowTotalInclTax = $rowTotal + $rowTaxBeforeDiscount;
151151
$priceInclTax = $rowTotalInclTax / $quantity;
152152

153+
if ($round) {
154+
$priceInclTax = $this->calculationTool->round($priceInclTax);
155+
}
156+
157+
$pricePerItemInclTax = $rowTotalInclTax / $quantity;
158+
159+
if (($pricePerItemInclTax - $priceInclTax) < 0) {
160+
$priceInclTax = $pricePerItemInclTax;
161+
}
162+
153163
return $this->taxDetailsItemDataObjectFactory->create()
154164
->setCode($item->getCode())
155165
->setType($item->getType())

0 commit comments

Comments
 (0)