Skip to content

Commit ddbea4c

Browse files
ENGCOM-5194: Wrong currency sign on creditmemo_grid & sales_order_view > invoice grid #22123
- Merge Pull Request #22123 from gymbeam/magento2:2.3-develop - Merged commits: 1. da32829 2. 3142776 3. 18a6653 4. 6833c61 5. ae304ac
2 parents 514e3d0 + ae304ac commit ddbea4c

File tree

9 files changed

+98
-9
lines changed

9 files changed

+98
-9
lines changed
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Sales\Setup\Patch\Data;
9+
10+
use Magento\Framework\Setup\ModuleDataSetupInterface;
11+
use Magento\Framework\Setup\Patch\DataPatchInterface;
12+
use Magento\Framework\Setup\Patch\PatchVersionInterface;
13+
use Magento\Sales\Setup\SalesSetupFactory;
14+
15+
/**
16+
* Update credit memo grid currency code.
17+
*/
18+
class UpdateCreditmemoGridCurrencyCode implements DataPatchInterface, PatchVersionInterface
19+
{
20+
/**
21+
* @var ModuleDataSetupInterface
22+
*/
23+
private $moduleDataSetup;
24+
25+
/**
26+
* @var SalesSetupFactory
27+
*/
28+
private $salesSetupFactory;
29+
30+
/**
31+
* @param ModuleDataSetupInterface $moduleDataSetup
32+
* @param SalesSetupFactory $salesSetupFactory
33+
*/
34+
public function __construct(
35+
ModuleDataSetupInterface $moduleDataSetup,
36+
SalesSetupFactory $salesSetupFactory
37+
) {
38+
$this->moduleDataSetup = $moduleDataSetup;
39+
$this->salesSetupFactory = $salesSetupFactory;
40+
}
41+
42+
/**
43+
* @inheritdoc
44+
*/
45+
public function apply()
46+
{
47+
$salesSetup = $this->salesSetupFactory->create(['setup' => $this->moduleDataSetup]);
48+
$connection = $salesSetup->getConnection();
49+
$creditMemoGridTable = $salesSetup->getTable('sales_creditmemo_grid');
50+
$orderTable = $salesSetup->getTable('sales_order');
51+
// phpcs:disable Magento2.SQL.RawQuery
52+
$sql = "UPDATE {$creditMemoGridTable} AS scg
53+
JOIN {$orderTable} AS so ON so.entity_id = scg.order_id
54+
SET scg.order_currency_code = so.order_currency_code,
55+
scg.base_currency_code = so.base_currency_code;";
56+
57+
$connection->query($sql);
58+
}
59+
60+
/**
61+
* @inheritdoc
62+
*/
63+
public static function getDependencies()
64+
{
65+
return [];
66+
}
67+
68+
/**
69+
* @inheritdoc
70+
*/
71+
public static function getVersion()
72+
{
73+
return '2.0.13';
74+
}
75+
76+
/**
77+
* @inheritdoc
78+
*/
79+
public function getAliases()
80+
{
81+
return [];
82+
}
83+
}

app/code/Magento/Sales/Test/Mftf/Section/AdminOrderInvoicesTabSection.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<element name="filters" type="button" selector="//div[@id='sales_order_view_tabs_order_invoices_content']//button[@data-action='grid-filter-expand']" timeout="30"/>
1818
<element name="applyFilters" type="button" selector="//div[@id='sales_order_view_tabs_order_invoices_content']//button[@data-action='grid-filter-apply']" timeout="30"/>
1919
<element name="invoiceId" type="input" selector="//div[@id='sales_order_view_tabs_order_invoices_content']//input[@name='increment_id']" timeout="30"/>
20-
<element name="amountFrom" type="input" selector="[name='grand_total[from]']" timeout="30"/>
21-
<element name="amountTo" type="input" selector="[name='grand_total[to]']" timeout="30"/>
20+
<element name="amountFrom" type="input" selector="[name='base_grand_total[from]']" timeout="30"/>
21+
<element name="amountTo" type="input" selector="[name='base_grand_total[to]']" timeout="30"/>
2222
</section>
2323
</sections>

app/code/Magento/Sales/etc/db_schema.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1386,6 +1386,8 @@
13861386
comment="Adjustment Negative"/>
13871387
<column xsi:type="decimal" name="order_base_grand_total" scale="4" precision="20" unsigned="false"
13881388
nullable="true" comment="Order Grand Total"/>
1389+
<column xsi:type="varchar" name="order_currency_code" nullable="true" length="3" comment="Order Currency Code"/>
1390+
<column xsi:type="varchar" name="base_currency_code" nullable="true" length="3" comment="Base Currency Code"/>
13891391
<constraint xsi:type="primary" referenceId="PRIMARY">
13901392
<column name="entity_id"/>
13911393
</constraint>

app/code/Magento/Sales/etc/db_schema_whitelist.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -815,7 +815,9 @@
815815
"shipping_and_handling": true,
816816
"adjustment_positive": true,
817817
"adjustment_negative": true,
818-
"order_base_grand_total": true
818+
"order_base_grand_total": true,
819+
"order_currency_code": true,
820+
"base_currency_code": true
819821
},
820822
"index": {
821823
"SALES_CREDITMEMO_GRID_ORDER_INCREMENT_ID": true,

app/code/Magento/Sales/etc/di.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,8 @@
640640
<item name="adjustment_positive" xsi:type="string">sales_creditmemo.adjustment_positive</item>
641641
<item name="adjustment_negative" xsi:type="string">sales_creditmemo.adjustment_negative</item>
642642
<item name="order_base_grand_total" xsi:type="string">sales_order.base_grand_total</item>
643+
<item name="order_currency_code" xsi:type="string">sales_order.order_currency_code</item>
644+
<item name="base_currency_code" xsi:type="string">sales_order.base_currency_code</item>
643645
</argument>
644646
</arguments>
645647
</virtualType>

app/code/Magento/Sales/etc/module.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77
-->
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
9-
<module name="Magento_Sales" >
9+
<module name="Magento_Sales">
1010
<sequence>
1111
<module name="Magento_Rule"/>
1212
<module name="Magento_Catalog"/>

app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_creditmemo_grid.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@
119119
<column name="base_grand_total" class="Magento\Sales\Ui\Component\Listing\Column\Price">
120120
<settings>
121121
<filter>textRange</filter>
122-
<label translate="true">Refunded</label>
122+
<label translate="true">Refunded (Base)</label>
123123
</settings>
124124
</column>
125125
<column name="order_status" component="Magento_Ui/js/grid/columns/select">
@@ -194,7 +194,7 @@
194194
<visible>false</visible>
195195
</settings>
196196
</column>
197-
<column name="subtotal" class="Magento\Sales\Ui\Component\Listing\Column\Price">
197+
<column name="subtotal" class="Magento\Sales\Ui\Component\Listing\Column\PurchasedPrice">
198198
<settings>
199199
<filter>textRange</filter>
200200
<label translate="true">Subtotal</label>

app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_view_invoice_grid.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@
130130
<label translate="true">Status</label>
131131
</settings>
132132
</column>
133-
<column name="grand_total" class="Magento\Sales\Ui\Component\Listing\Column\PurchasedPrice">
133+
<column name="base_grand_total" class="Magento\Sales\Ui\Component\Listing\Column\Price">
134134
<settings>
135135
<filter>textRange</filter>
136136
<label translate="true">Amount</label>

dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Invoice/Grid.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ class Grid extends \Magento\Ui\Test\Block\Adminhtml\DataGrid
2424
'selector' => 'input[name="order_increment_id"]',
2525
],
2626
'grand_total_from' => [
27-
'selector' => 'input[name="grand_total[from]"]',
27+
'selector' => 'input[name="base_grand_total[from]"]',
2828
],
2929
'grand_total_to' => [
30-
'selector' => 'input[name="grand_total[to]"]',
30+
'selector' => 'input[name="base_grand_total[to]"]',
3131
],
3232
];
3333

0 commit comments

Comments
 (0)