Skip to content

Commit f9c521f

Browse files
MC-42612: Negative discount amount displays on order page in admin for product $0.00 price
- Do not apply rounding delta on the discount amount when the product price is 0
1 parent 4567eae commit f9c521f

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

app/code/Magento/SalesRule/Model/Utility.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,8 @@ public function deltaRoundingFix(
195195
//TODO Seems \Magento\Quote\Model\Quote\Item\AbstractItem::getDiscountPercent() returns float value
196196
//that can not be used as array index
197197
$percentKey = $item->getDiscountPercent();
198-
if ($percentKey) {
198+
$rowTotal = $item->getRowTotal();
199+
if ($percentKey && $rowTotal > 0) {
199200
$delta = isset($this->_roundingDeltas[$percentKey]) ? $this->_roundingDeltas[$percentKey] : 0;
200201
$baseDelta = isset($this->_baseRoundingDeltas[$percentKey]) ? $this->_baseRoundingDeltas[$percentKey] : 0;
201202

app/code/Magento/SalesRule/Test/Unit/Model/UtilityTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,7 @@ public function testDeltaRoundignFix()
463463
$discountAmount = 10.003;
464464
$baseDiscountAmount = 12.465;
465465
$percent = 15;
466+
$rowTotal = 100;
466467
$roundedDiscount = round($discountAmount, 2);
467468
$roundedBaseDiscount = round($baseDiscountAmount, 2);
468469
$delta = $discountAmount - $roundedDiscount;
@@ -491,6 +492,7 @@ public function testDeltaRoundignFix()
491492
->willReturn($store);
492493

493494
$this->item->setDiscountPercent($percent);
495+
$this->item->setRowTotal($rowTotal);
494496

495497
$discountData = $this->createMock(Data::class);
496498
$discountData->expects($this->at(0))
@@ -523,7 +525,6 @@ public function testDeltaRoundignFix()
523525

524526
$this->assertEquals($this->utility, $this->utility->deltaRoundingFix($discountData, $this->item));
525527
$this->assertEquals($this->utility, $this->utility->deltaRoundingFix($discountData, $this->item));
526-
527528
}
528529

529530
public function testResetRoundingDeltas()

0 commit comments

Comments
 (0)