Skip to content

Commit 65513e6

Browse files
committed
Merge remote-tracking branch 'origin/ACP2E-3993' into PR_2025_08_25_muntianu
2 parents bea3db3 + d54ae33 commit 65513e6

File tree

6 files changed

+25
-21
lines changed

6 files changed

+25
-21
lines changed

app/code/Magento/CatalogGraphQl/Model/Resolver/Product/Price/Discount.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,10 @@ private function getPriceDifferenceAsValue(float $regularPrice, float $finalPric
7272
*/
7373
private function getPriceDifferenceAsPercent(float $regularPrice, float $finalPrice): float
7474
{
75-
$difference = $this->getPriceDifferenceAsValue($regularPrice, $finalPrice);
75+
$difference = $regularPrice - $finalPrice;
76+
if ($difference <= $this->zeroThreshold) {
77+
return 0;
78+
}
7679

7780
if ($difference <= $this->zeroThreshold || $regularPrice <= $this->zeroThreshold) {
7881
return 0;

app/code/Magento/CatalogRule/Model/Indexer/ProductPriceCalculator.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Copyright 2017 Adobe
44
* All Rights Reserved.
55
*/
6+
declare(strict_types=1);
67

78
namespace Magento\CatalogRule\Model\Indexer;
89

@@ -28,7 +29,7 @@ public function __construct(\Magento\Framework\Pricing\PriceCurrencyInterface $p
2829
* Calculates product price.
2930
*
3031
* @param array $ruleData
31-
* @param null $productData
32+
* @param array|null $productData
3233
* @return float
3334
*/
3435
public function calculate($ruleData, $productData = null)
@@ -56,6 +57,6 @@ public function calculate($ruleData, $productData = null)
5657
$productPrice = 0;
5758
}
5859

59-
return $this->priceCurrency->round($productPrice);
60+
return $this->priceCurrency->roundPrice($productPrice, 4);
6061
}
6162
}

app/code/Magento/CatalogRule/Pricing/Price/CatalogRulePrice.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,14 @@
1818
use Magento\Store\Model\StoreManagerInterface;
1919

2020
/**
21-
* Class CatalogRulePrice
22-
*
2321
* @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
2422
*/
2523
class CatalogRulePrice extends AbstractPrice implements BasePriceProviderInterface
2624
{
2725
/**
2826
* Price type identifier string
2927
*/
30-
const PRICE_CODE = 'catalog_rule_price';
28+
public const PRICE_CODE = 'catalog_rule_price';
3129

3230
/**
3331
* @var TimezoneInterface
@@ -97,7 +95,7 @@ public function getValue()
9795
$this->value = $this->value ? (float)$this->value : false;
9896
}
9997
if ($this->value) {
100-
$this->value = $this->priceCurrency->convertAndRound($this->value);
98+
$this->value = $this->priceCurrency->convertAndRound($this->value, null, null, 4);
10199
}
102100
}
103101

app/code/Magento/CatalogRule/Test/Unit/Model/Indexer/ProductPriceCalculatorTest.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
*/
66
declare(strict_types=1);
77

8-
98
namespace Magento\CatalogRule\Test\Unit\Model\Indexer;
109

1110
use Magento\CatalogRule\Model\Indexer\ProductPriceCalculator;
@@ -29,6 +28,7 @@ protected function setUp(): void
2928
{
3029
$this->priceCurrencyMock = $this->getMockBuilder(PriceCurrencyInterface::class)
3130
->disableOriginalConstructor()
31+
->addMethods(['roundPrice'])
3232
->getMockForAbstractClass();
3333
$this->model = new ProductPriceCalculator($this->priceCurrencyMock);
3434
}
@@ -44,8 +44,8 @@ public function testCalculateToFixedPrice()
4444
$productData = ['rule_price' => $rulePrice];
4545

4646
$this->priceCurrencyMock->expects($this->once())
47-
->method('round')
48-
->with($actionAmount)
47+
->method('roundPrice')
48+
->with($actionAmount, 4)
4949
->willReturn($actionAmount);
5050

5151
$this->assertEquals($actionAmount, $this->model->calculate($ruleData, $productData));
@@ -63,8 +63,8 @@ public function testCalculateToPercentPrice()
6363
$productData = ['rule_price' => $rulePrice];
6464

6565
$this->priceCurrencyMock->expects($this->once())
66-
->method('round')
67-
->with($expectedPrice)
66+
->method('roundPrice')
67+
->with($expectedPrice, 4)
6868
->willReturn($expectedPrice);
6969

7070
$this->assertEquals($expectedPrice, $this->model->calculate($ruleData, $productData));
@@ -82,8 +82,8 @@ public function testCalculateByFixedPrice()
8282
$productData = ['rule_price' => $rulePrice];
8383

8484
$this->priceCurrencyMock->expects($this->once())
85-
->method('round')
86-
->with($expectedPrice)
85+
->method('roundPrice')
86+
->with($expectedPrice, 4)
8787
->willReturn($expectedPrice);
8888

8989
$this->assertEquals($expectedPrice, $this->model->calculate($ruleData, $productData));
@@ -101,8 +101,8 @@ public function testCalculateByPercentPrice()
101101
$productData = ['rule_price' => $rulePrice];
102102

103103
$this->priceCurrencyMock->expects($this->once())
104-
->method('round')
105-
->with($expectedPrice)
104+
->method('roundPrice')
105+
->with($expectedPrice, 4)
106106
->willReturn($expectedPrice);
107107

108108
$this->assertEquals($expectedPrice, $this->model->calculate($ruleData, $productData));

app/code/Magento/CatalogRule/Test/Unit/Pricing/Price/CatalogRulePriceTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public function testGetValue()
142142
->willReturn($productId);
143143
$this->priceCurrencyMock->expects($this->once())
144144
->method('convertAndRound')
145-
->with($catalogRulePrice)
145+
->with($catalogRulePrice, null, null, 4)
146146
->willReturn($convertedPrice);
147147

148148
$this->assertEquals($convertedPrice, $this->object->getValue());
@@ -155,7 +155,7 @@ public function testGetValueFromData()
155155

156156
$this->priceCurrencyMock->expects($this->any())
157157
->method('convertAndRound')
158-
->with($catalogRulePrice)
158+
->with($catalogRulePrice, null, null, 4)
159159
->willReturn($convertedPrice);
160160

161161
$this->saleableItemMock->expects($this->once())->method('hasData')

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
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
*/
6+
declare(strict_types=1);
7+
68
namespace Magento\Tax\Model\Calculation;
79

810
use Magento\Tax\Api\Data\QuoteDetailsItemInterface;
@@ -56,7 +58,7 @@ protected function calculateWithTaxInPrice(QuoteDetailsItemInterface $item, $qua
5658

5759
// Calculate $priceInclTax
5860
$applyTaxAfterDiscount = $this->config->applyTaxAfterDiscount($this->storeId);
59-
$priceInclTax = $this->calculationTool->round($item->getUnitPrice());
61+
$priceInclTax = $item->getUnitPrice();
6062
if (!$this->isSameRateAsStore($rate, $storeRate)) {
6163
$priceInclTax = $this->calculatePriceInclTax($priceInclTax, $storeRate, $rate, $round);
6264
}

0 commit comments

Comments
 (0)