Skip to content

Commit bbd1d12

Browse files
committed
ACP2E-2651: Incorrect subtotal in order when FPT is used
1 parent 75bc247 commit bbd1d12

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

app/code/Magento/Weee/Model/Total/Invoice/Weee.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,7 @@ public function collect(\Magento\Sales\Model\Order\Invoice $invoice)
177177
// If FPT is configured to be included in the subtotal,
178178
// we need to subtract it from the subtotal and the grand total,
179179
// as Collect function from Catalog module knows nothing about FPT and that it is already included in Subtotal
180-
$includeInSubtotal = $this->_weeeData->includeInSubtotal($store);
181-
if ($invoice->isLast() && $includeInSubtotal) {
180+
if ($invoice->isLast() && $this->_weeeData->includeInSubtotal($store)) {
182181
$invoice->setSubtotal($invoice->getSubtotal() - $totalWeeeAmount);
183182
$invoice->setBaseSubtotal($invoice->getBaseSubtotal() - $baseTotalWeeeAmount);
184183
$invoice->setGrandTotal($invoice->getGrandTotal() - $totalWeeeAmountInclTax);
@@ -196,7 +195,7 @@ public function collect(\Magento\Sales\Model\Order\Invoice $invoice)
196195
$invoice->setBaseTaxAmount($invoice->getBaseTaxAmount() + $baseTotalWeeeTaxAmount);
197196

198197
// Add FPT to subtotal and grand total
199-
if ($includeInSubtotal) {
198+
if ($this->_weeeData->includeInSubtotal($store)) {
200199
$order = $invoice->getOrder();
201200
$allowedSubtotal = $order->getSubtotal() - $order->getSubtotalInvoiced() - $invoice->getSubtotal();
202201
$allowedBaseSubtotal = $order->getBaseSubtotal() -

app/code/Magento/Weee/Test/Unit/Model/Total/Invoice/WeeeTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public function testCollect($orderData, $invoiceData, $expectedResults)
115115
$this->setupOrder($orderData);
116116

117117
//Set up weeeData mock
118-
$this->weeeData->expects($this->once())
118+
$this->weeeData->expects($this->atLeastOnce())
119119
->method('includeInSubtotal')
120120
->willReturn($invoiceData['include_in_subtotal']);
121121

@@ -284,8 +284,8 @@ public function collectDataProvider()
284284
'base_tax_amount' => 16.09,
285285
'subtotal' => 300,
286286
'base_subtotal' => 300,
287-
'subtotal_incl_tax' => 344.85,
288-
'base_subtotal_incl_tax' => 344.85,
287+
'subtotal_incl_tax' => 347.32,
288+
'base_subtotal_incl_tax' => 347.32,
289289
],
290290
],
291291
];
@@ -590,8 +590,8 @@ public function collectDataProvider()
590590
'base_tax_amount' => 4.95,
591591
'subtotal' => 100,
592592
'base_subtotal' => 100,
593-
'subtotal_incl_tax' => 114.95,
594-
'base_subtotal_incl_tax' => 114.95,
593+
'subtotal_incl_tax' => 115.77,
594+
'base_subtotal_incl_tax' => 115.77,
595595
],
596596
],
597597
];

0 commit comments

Comments
 (0)