Skip to content

Commit 1346893

Browse files
committed
Merge remote-tracking branch 'origin/ACP2E-3874' into PR_2025_05_28
2 parents 3f09d42 + f0a4c0c commit 1346893

File tree

3 files changed

+34
-110
lines changed

3 files changed

+34
-110
lines changed

app/code/Magento/Sales/Block/Adminhtml/Items/Column/DefaultColumn.php

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2011 Adobe
4+
* All Rights Reserved.
55
*/
66
namespace Magento\Sales\Block\Adminhtml\Items\Column;
77

@@ -123,13 +123,11 @@ public function getSku()
123123
public function getTotalAmount($item)
124124
{
125125
$storeId = $item->getStoreId();
126-
$total = $this->displaySalesPricesInclTax($storeId) ? $item->getPriceInclTax()
127-
: $item->getPrice();
128-
129-
$totalAmount = $this->displaySalesPricesInclTax($storeId)
130-
? $total - $item->getDiscountAmount() - $item->getTaxAmount()
131-
: $total - $item->getDiscountAmount();
132-
126+
if ($this->displaySalesPricesInclTax($storeId)) {
127+
$totalAmount = $item->getRowTotalInclTax() - $item->getDiscountAmount() - $item->getTaxAmount();
128+
} else {
129+
$totalAmount = $item->getRowTotal() - $item->getDiscountAmount();
130+
}
133131
return $totalAmount;
134132
}
135133

@@ -142,13 +140,12 @@ public function getTotalAmount($item)
142140
public function getBaseTotalAmount($item)
143141
{
144142
$storeId = $item->getStoreId();
145-
$baseTotal = $this->displaySalesPricesInclTax($storeId) ? $item->getBasePriceInclTax()
146-
: $item->getBasePrice();
147-
148-
$baseTotalAmount = $this->displaySalesPricesInclTax($storeId)
149-
? $baseTotal - $item->getBaseDiscountAmount() - $item->getBaseTaxAmount()
150-
: $baseTotal - $item->getBaseDiscountAmount();
151-
143+
if ($this->displaySalesPricesInclTax($storeId)) {
144+
$baseTotalAmount = $item->getBaseRowTotalInclTax()
145+
- $item->getBaseDiscountAmount() - $item->getBaseTaxAmount();
146+
} else {
147+
$baseTotalAmount = $item->getBaseRowTotal() - $item->getBaseDiscountAmount();
148+
}
152149
return $baseTotalAmount;
153150
}
154151

Lines changed: 18 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2014 Adobe
4+
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

88
namespace Magento\Sales\Test\Unit\Block\Adminhtml\Items\Column;
99

10-
use Magento\Framework\App\Config\ScopeConfigInterface;
1110
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
1211
use Magento\Sales\Block\Adminhtml\Items\Column\DefaultColumn;
1312
use Magento\Sales\Model\Order\Item;
@@ -29,114 +28,42 @@ class DefaultColumnTest extends TestCase
2928
*/
3029
protected $itemMock;
3130

32-
/**
33-
* @var ScopeConfigInterface|MockObject
34-
*/
35-
protected $scopeConfigMock;
36-
3731
protected function setUp(): void
3832
{
3933
$this->objectManagerHelper = new ObjectManagerHelper($this);
40-
$this->scopeConfigMock = $this->getMockBuilder(ScopeConfigInterface::class)
41-
->disableOriginalConstructor()
42-
->getMockForAbstractClass();
4334
$this->defaultColumn = $this->objectManagerHelper->getObject(
44-
DefaultColumn::class,
45-
[
46-
'scopeConfig' => $this->scopeConfigMock
47-
]
35+
DefaultColumn::class
4836
);
4937
$this->itemMock = $this->getMockBuilder(Item::class)
5038
->disableOriginalConstructor()
5139
->getMock();
5240
}
5341

54-
/**
55-
* Verify the total amount based on the price including tax flag
56-
*
57-
* @dataProvider getScopeConfigSalesPriceDataProvider
58-
* @param string $taxIncl
59-
* @param float|null $basePriceInclTax
60-
* @param float $basePrice
61-
* @param float $expectedResult
62-
* @return void
63-
* @throws \ReflectionException
64-
*/
65-
public function testGetTotalAmount(string $taxIncl, $priceInclTax, float $price, float $expectedResult): void
42+
public function testGetTotalAmount()
6643
{
67-
$storeId = 1;
68-
$discountAmount = 15.21;
69-
$taxAmount = 0.34;
44+
$rowTotal = 10;
45+
$discountAmount = 2;
46+
$expectedResult = 8;
7047
$this->itemMock->expects($this->once())
71-
->method('getStoreId')
72-
->willReturn($storeId);
73-
$this->itemMock->expects($this->any())
74-
->method('getPriceInclTax')
75-
->willReturn($priceInclTax);
76-
$this->itemMock->expects($this->any())
77-
->method('getPrice')
78-
->willReturn($price);
48+
->method('getRowTotal')
49+
->willReturn($rowTotal);
7950
$this->itemMock->expects($this->once())
8051
->method('getDiscountAmount')
8152
->willReturn($discountAmount);
82-
$this->itemMock->expects($this->any())
83-
->method('getTaxAmount')
84-
->willReturn($taxAmount);
85-
$this->scopeConfigMock->expects($this->atLeastOnce())
86-
->method('getValue')
87-
->willReturn($taxIncl);
88-
$this->assertEquals($expectedResult, round($this->defaultColumn->getTotalAmount($this->itemMock), 2));
53+
$this->assertEquals($expectedResult, $this->defaultColumn->getTotalAmount($this->itemMock));
8954
}
9055

91-
/**
92-
* Verify the total base amount based on the price including tax flag
93-
*
94-
* @dataProvider getScopeConfigSalesPriceDataProvider
95-
* @param string $taxIncl
96-
* @param float|null $basePriceInclTax
97-
* @param float $basePrice
98-
* @param float $expectedResult
99-
* @return void
100-
* @throws \ReflectionException
101-
*/
102-
public function testGetBaseTotalAmount(
103-
string $taxIncl,
104-
$basePriceInclTax,
105-
float $basePrice,
106-
float $expectedResult
107-
): void {
108-
$storeId = 1;
109-
$baseDiscountAmount = 15.21;
110-
$baseTaxAmount = 0.34;
56+
public function testGetBaseTotalAmount()
57+
{
58+
$baseRowTotal = 10;
59+
$baseDiscountAmount = 2;
60+
$expectedResult = 8;
11161
$this->itemMock->expects($this->once())
112-
->method('getStoreId')
113-
->willReturn($storeId);
114-
$this->itemMock->expects($this->any())
115-
->method('getBasePriceInclTax')
116-
->willReturn($basePriceInclTax);
117-
$this->itemMock->expects($this->any())
118-
->method('getBasePrice')
119-
->willReturn($basePrice);
62+
->method('getBaseRowTotal')
63+
->willReturn($baseRowTotal);
12064
$this->itemMock->expects($this->once())
12165
->method('getBaseDiscountAmount')
12266
->willReturn($baseDiscountAmount);
123-
$this->itemMock->expects($this->any())
124-
->method('getBaseTaxAmount')
125-
->willReturn($baseTaxAmount);
126-
$this->scopeConfigMock->expects($this->atLeastOnce())
127-
->method('getValue')
128-
->willReturn($taxIncl);
129-
$this->assertEquals($expectedResult, round($this->defaultColumn->getBaseTotalAmount($this->itemMock), 2));
130-
}
131-
132-
/**
133-
* @return array
134-
*/
135-
public static function getScopeConfigSalesPriceDataProvider(): array
136-
{
137-
return [
138-
['2', 16.9, 13.52, 1.35],
139-
['1', null, 16.9, 1.69],
140-
];
67+
$this->assertEquals($expectedResult, $this->defaultColumn->getBaseTotalAmount($this->itemMock));
14168
}
14269
}

dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderItemGetListTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2015 Adobe
4+
* All Rights Reserved.
55
*/
66
namespace Magento\Sales\Service\V1;
77

@@ -31,7 +31,7 @@ protected function setUp(): void
3131
*/
3232
public function testGetList()
3333
{
34-
$expectedRowTotals = [110, 100, 90];
34+
$expectedRowTotals = [112, 102, 92];
3535
/** @var \Magento\Framework\Api\SortOrderBuilder $sortOrderBuilder */
3636
$sortOrderBuilder = $this->objectManager->get(
3737
\Magento\Framework\Api\SortOrderBuilder::class

0 commit comments

Comments
 (0)