I would like to add the tax_amount to the orders and invoices grids to be able to have them in the export files. I found some documentation and tutorials on telling how to add a custom column, with a new column created in database, but not one showing existing data.
I assume I have to call existing data from sales_order and sales_invoice tables in
app/code/Vendor/Module/view/adminhtml/ui_component/sales_order_grid.xml
and
app/code/Vendor/Module/view/adminhtml/ui_component/sales_order_invoice_grid.xml
So I started with a new module.
app/code/Vendor/Module/etc/module.xml :
<?xml version="1.0" encoding="UTF-8"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd">
<module name="Vendor_Module" setup_version="2.0.0">
<sequence>
<module name="Module"/>
</sequence>
</module>
</config>
app/code/Vendor/Module/etc/di.xml :
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<virtualType name="Magento\Sales\Model\ResourceModel\Order\Grid">
<arguments>
<argument name="joins" xsi:type="array">
<item name="sales_order" xsi:type="array">
<item name="table" xsi:type="string">sales_order</item>
<item name="origin_column" xsi:type="string">entity_id</item>
<item name="target_column" xsi:type="string">entity_id</item>
</item>
</argument>
<argument name="columns" xsi:type="array">
<item name="tax_amount" xsi:type="string">sales_order.tax_amount</item>
</argument>
</arguments>
</virtualType>
</config>
app/code/Vendor/Module/view/adminhtml/ui_component/sales_order_grid.xml :
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
<columns name="sales_order_columns">
<column name="tax_amount">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">text</item>
<item name="label" xsi:type="string" translate="true">Tax amount</item>
</item>
</argument>
</column>
</columns>
</listing>
But it does not seem to work, I only have an empty column.
Any help would be appreciated.
I'm working on Magento 2.2.0.