Skip to content

Commit 665da40

Browse files
authored
ENGCOM-5194: Wrong currency sign on creditmemo_grid & sales_order_view > invoice grid #22123
2 parents fd07b0f + 70c0c52 commit 665da40

File tree

9 files changed

+100
-9
lines changed

9 files changed

+100
-9
lines changed
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
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\DB\Adapter\Pdo\Mysql;
11+
use Magento\Framework\Setup\ModuleDataSetupInterface;
12+
use Magento\Framework\Setup\Patch\DataPatchInterface;
13+
use Magento\Framework\Setup\Patch\PatchVersionInterface;
14+
use Magento\Sales\Setup\SalesSetup;
15+
use Magento\Sales\Setup\SalesSetupFactory;
16+
17+
/**
18+
* Update credit memo grid currency code.
19+
*/
20+
class UpdateCreditmemoGridCurrencyCode implements DataPatchInterface, PatchVersionInterface
21+
{
22+
/**
23+
* @var ModuleDataSetupInterface
24+
*/
25+
private $moduleDataSetup;
26+
27+
/**
28+
* @var SalesSetupFactory
29+
*/
30+
private $salesSetupFactory;
31+
32+
/**
33+
* @param ModuleDataSetupInterface $moduleDataSetup
34+
* @param SalesSetupFactory $salesSetupFactory
35+
*/
36+
public function __construct(
37+
ModuleDataSetupInterface $moduleDataSetup,
38+
SalesSetupFactory $salesSetupFactory
39+
) {
40+
$this->moduleDataSetup = $moduleDataSetup;
41+
$this->salesSetupFactory = $salesSetupFactory;
42+
}
43+
44+
/**
45+
* @inheritdoc
46+
*/
47+
public function apply()
48+
{
49+
/** @var SalesSetup $salesSetup */
50+
$salesSetup = $this->salesSetupFactory->create(['setup' => $this->moduleDataSetup]);
51+
/** @var Mysql $connection */
52+
$connection = $salesSetup->getConnection();
53+
$creditMemoGridTable = $salesSetup->getTable('sales_creditmemo_grid');
54+
$orderTable = $salesSetup->getTable('sales_order');
55+
$select = $connection->select();
56+
$condition = 'so.entity_id = scg.order_id';
57+
$select->join(['so' => $orderTable], $condition, ['order_currency_code', 'base_currency_code']);
58+
$sql = $connection->updateFromSelect($select, ['scg' => $creditMemoGridTable]);
59+
$connection->query($sql);
60+
}
61+
62+
/**
63+
* @inheritdoc
64+
*/
65+
public static function getDependencies()
66+
{
67+
return [];
68+
}
69+
70+
/**
71+
* @inheritdoc
72+
*/
73+
public static function getVersion()
74+
{
75+
return '2.0.13';
76+
}
77+
78+
/**
79+
* @inheritdoc
80+
*/
81+
public function getAliases()
82+
{
83+
return [];
84+
}
85+
}

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
@@ -641,6 +641,8 @@
641641
<item name="adjustment_positive" xsi:type="string">sales_creditmemo.adjustment_positive</item>
642642
<item name="adjustment_negative" xsi:type="string">sales_creditmemo.adjustment_negative</item>
643643
<item name="order_base_grand_total" xsi:type="string">sales_order.base_grand_total</item>
644+
<item name="order_currency_code" xsi:type="string">sales_order.order_currency_code</item>
645+
<item name="base_currency_code" xsi:type="string">sales_order.base_currency_code</item>
644646
</argument>
645647
</arguments>
646648
</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)