Skip to content

Commit 9640f2e

Browse files
committed
ACP2E-3993: GraphQl invalid discount calculation
1 parent 3920c2b commit 9640f2e

File tree

4 files changed

+7
-4
lines changed

4 files changed

+7
-4
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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,6 @@ public function calculate($ruleData, $productData = null)
5656
$productPrice = 0;
5757
}
5858

59-
return $this->priceCurrency->round($productPrice);
59+
return $this->priceCurrency->roundPrice($productPrice, 4);
6060
}
6161
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public function getValue()
9797
$this->value = $this->value ? (float)$this->value : false;
9898
}
9999
if ($this->value) {
100-
$this->value = $this->priceCurrency->convertAndRound($this->value);
100+
$this->value = $this->priceCurrency->convertAndRound($this->value, null, null, 4);
101101
}
102102
}
103103

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ protected function calculateWithTaxInPrice(QuoteDetailsItemInterface $item, $qua
5656

5757
// Calculate $priceInclTax
5858
$applyTaxAfterDiscount = $this->config->applyTaxAfterDiscount($this->storeId);
59-
$priceInclTax = $this->calculationTool->round($item->getUnitPrice());
59+
$priceInclTax = $item->getUnitPrice();
6060
if (!$this->isSameRateAsStore($rate, $storeRate)) {
6161
$priceInclTax = $this->calculatePriceInclTax($priceInclTax, $storeRate, $rate, $round);
6262
}

0 commit comments

Comments
 (0)