Skip to content

Commit 78e9736

Browse files
authored
ENGCOM-7770: [Fixed #26191] Need To Change Label In Totals Block in Order View Page #27516
2 parents 050b937 + 9be4edd commit 78e9736

File tree

4 files changed

+46
-5
lines changed

4 files changed

+46
-5
lines changed

app/code/Magento/Sales/Block/Adminhtml/Order/Totals.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,23 @@ protected function _initTotals()
4242
'area' => 'footer',
4343
]
4444
);
45-
$this->_totals['due'] = new \Magento\Framework\DataObject(
45+
$code = 'due';
46+
$label = 'Total Due';
47+
$value = $this->getSource()->getTotalDue();
48+
$baseValue = $this->getSource()->getBaseTotalDue();
49+
if ($this->getSource()->getTotalCanceled() > 0 && $this->getSource()->getBaseTotalCanceled() > 0) {
50+
$code = 'canceled';
51+
$label = 'Total Canceled';
52+
$value = $this->getSource()->getTotalCanceled();
53+
$baseValue = $this->getSource()->getBaseTotalCanceled();
54+
}
55+
$this->_totals[$code] = new \Magento\Framework\DataObject(
4656
[
4757
'code' => 'due',
4858
'strong' => true,
49-
'value' => $this->getSource()->getTotalDue(),
50-
'base_value' => $this->getSource()->getBaseTotalDue(),
51-
'label' => __('Total Due'),
59+
'value' => $value,
60+
'base_value' => $baseValue,
61+
'label' => __($label),
5262
'area' => 'footer',
5363
]
5464
);

app/code/Magento/Sales/Model/Order.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1816,7 +1816,7 @@ public function getTotalDue()
18161816
$total = $this->priceCurrency->round($total);
18171817
return max($total, 0);
18181818
}
1819-
1819+
18201820
/**
18211821
* Retrieve order total due value
18221822
*

app/code/Magento/Sales/i18n/en_US.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ Capture,Capture
117117
"Total Paid","Total Paid"
118118
"Total Refunded","Total Refunded"
119119
"Total Due","Total Due"
120+
"Total Canceled","Total Canceled"
120121
Edit,Edit
121122
"Are you sure you want to send an order email to customer?","Are you sure you want to send an order email to customer?"
122123
"This will create an offline refund. To create an online refund, open an invoice and create credit memo for it. Do you want to continue?","This will create an offline refund. To create an online refund, open an invoice and create credit memo for it. Do you want to continue?"

dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Order/TotalsTest.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,36 @@ public function testTotalsInclTax(): void
7272
$this->assertShipping($blockTotals->toHtml(), (float) $order->getShippingInclTax());
7373
}
7474

75+
/**
76+
* Test block totals including canceled amount.
77+
*
78+
* @magentoDataFixture Magento/Sales/_files/order.php
79+
*
80+
* @return void
81+
*/
82+
public function testTotalCanceled(): void
83+
{
84+
$order = $this->orderFactory->create()->loadByIncrementId('100000001');
85+
$order->cancel();
86+
$blockTotals = $this->getBlockTotals()->setOrder($order);
87+
$this->assertCanceled($blockTotals->toHtml(), $order->getTotalCanceled());
88+
}
89+
90+
/**
91+
* Check if canceled amount present in block.
92+
*
93+
* @param string $blockTotalsHtml
94+
* @param float $amount
95+
* @return void
96+
*/
97+
private function assertCanceled(string $blockTotalsHtml, float $amount): void
98+
{
99+
$this->assertTrue(
100+
$this->isBlockContainsTotalAmount($blockTotalsHtml, __('Total Canceled'), $amount),
101+
'Canceled amount is missing or incorrect.'
102+
);
103+
}
104+
75105
/**
76106
* Check if subtotal amount present in block.
77107
*

0 commit comments

Comments
 (0)