Skip to content

Commit 74ab06e

Browse files
author
Mike Weis
committed
MAGETWO-28380: Totals taxes sorting is different on order/invoice/refund create and view pages
- updated per code review
1 parent e1e4dd6 commit 74ab06e

File tree

2 files changed

+7
-17
lines changed

2 files changed

+7
-17
lines changed

app/code/Magento/Tax/Helper/Data.php

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -682,23 +682,17 @@ public function getCalculatedTaxes($source)
682682
* 'tax_amount' => $taxAmount,
683683
* 'base_tax_amount' => $baseTaxAmount,
684684
* 'title' => $title,
685-
* 'percent' => $percent,
686-
* 'type' => $type
685+
* 'percent' => $percent
687686
* )
688687
* )
689688
*
690689
* @param array $taxClassAmount
691690
* @param OrderTaxDetailsItemInterface $itemTaxDetail
692691
* @param float $ratio
693-
* @param string $type
694692
* @return array
695693
*/
696-
private function _aggregateTaxes(
697-
$taxClassAmount,
698-
OrderTaxDetailsItemInterface $itemTaxDetail,
699-
$ratio,
700-
$type = 'product'
701-
) {
694+
private function _aggregateTaxes($taxClassAmount, OrderTaxDetailsItemInterface $itemTaxDetail, $ratio)
695+
{
702696
$itemAppliedTaxes = $itemTaxDetail->getAppliedTaxes();
703697
foreach ($itemAppliedTaxes as $itemAppliedTax) {
704698
$taxAmount = $itemAppliedTax->getAmount() * $ratio;
@@ -711,7 +705,6 @@ private function _aggregateTaxes(
711705
if (!isset($taxClassAmount[$taxCode])) {
712706
$taxClassAmount[$taxCode]['title'] = $itemAppliedTax->getTitle();
713707
$taxClassAmount[$taxCode]['percent'] = $itemAppliedTax->getPercent();
714-
$taxClassAmount[$taxCode]['type'] = $type;
715708
$taxClassAmount[$taxCode]['tax_amount'] = $taxAmount;
716709
$taxClassAmount[$taxCode]['base_tax_amount'] = $baseTaxAmount;
717710
} else {
@@ -835,7 +828,6 @@ protected function calculateTaxForItems(EntityInterface $order, EntityInterface
835828
}
836829

837830
// Apply any taxes for shipping
838-
$shippingType = \Magento\Sales\Model\Quote\Address::TYPE_SHIPPING;
839831
$shippingTaxAmount = $salesItem->getShippingTaxAmount();
840832
$originalShippingTaxAmount = $order->getShippingTaxAmount();
841833
if ($shippingTaxAmount && $originalShippingTaxAmount &&
@@ -846,9 +838,9 @@ protected function calculateTaxForItems(EntityInterface $order, EntityInterface
846838
$itemTaxDetails = $orderTaxDetails->getItems();
847839
foreach ($itemTaxDetails as $itemTaxDetail) {
848840
//Aggregate taxable items associated with shipping
849-
if ($itemTaxDetail->getType() == $shippingType) {
841+
if ($itemTaxDetail->getType() == \Magento\Sales\Model\Quote\Address::TYPE_SHIPPING) {
850842
$taxClassAmount =
851-
$this->_aggregateTaxes($taxClassAmount, $itemTaxDetail, $shippingRatio, $shippingType);
843+
$this->_aggregateTaxes($taxClassAmount, $itemTaxDetail, $shippingRatio);
852844
}
853845
}
854846
}

dev/tests/unit/testsuite/Magento/Tax/Helper/DataTest.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,6 @@ public function getCalculatedTaxesForOrderItemsDataProvider()
301301
'percent' => 20.0,
302302
'tax_amount' => 2.5,
303303
'base_tax_amount' => 2.5,
304-
'type' => 'product',
305304
],
306305
],
307306
],
@@ -363,11 +362,11 @@ public function getCalculatedTaxesForOrderItemsDataProvider()
363362
'percent' => 20.0,
364363
'tax_amount' => 6.5,
365364
'base_tax_amount' => 6.5,
366-
'type' => 'product',
367365
],
368366
],
369367
],
370368
//Scenario 3: one item, with both shipping and product taxes
369+
// note that 'shipping tax' is listed before 'product tax'
371370
'one_item_with_both_shipping_and_product_taxes' => [
372371
'order' => [
373372
'order_id' => 1,
@@ -418,20 +417,19 @@ public function getCalculatedTaxesForOrderItemsDataProvider()
418417
),
419418
],
420419
],
420+
// note that 'shipping tax' is now listed after 'product tax'
421421
'expected_results' => [
422422
[
423423
'title' => 'US-CA-Sales-Tax',
424424
'percent' => 20.0,
425425
'tax_amount' => 5.00,
426426
'base_tax_amount' => 5.00,
427-
'type' => 'product',
428427
],
429428
[
430429
'title' => 'US-CA-Sales-Tax-Ship',
431430
'percent' => 10.0,
432431
'tax_amount' => 2.00,
433432
'base_tax_amount' => 2.00,
434-
'type' => 'shipping',
435433
],
436434
],
437435
],

0 commit comments

Comments
 (0)