<?xml version="1.0"?>
<!--
/**
 * @author Amasty Team
 * @copyright Copyright (c) Amasty (https://www.amasty.com)
 * @package Order Export Entity for Magento 2 (System)
 */-->

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:amasty:module:Amasty_ExportCore:etc/am_export.xsd">
    <entity code="sales_invoice_grid">
        <name>Order Invoice Grid</name>
        <group>Sales</group>
        <collectionFactory class="Amasty\ExportCore\Export\Config\CustomEntity\CollectionFactory">
            <arguments>
                <argument name="tableName" xsi:type="string">sales_invoice_grid</argument>
                <argument name="idField" xsi:type="string">entity_id</argument>
            </arguments>
        </collectionFactory>
        <fieldsConfig>
            <fieldsClass class="Amasty\ExportCore\Export\FieldsClass\Describe"/>
            <fields>
                <field name="entity_id">
                    <filter>
                        <type>text</type>
                    </filter>
                </field>
                <field name="state">
                    <filter>
                        <type>select</type>
                        <options>
                            <class>Amasty\OrderExportEntity\Export\Invoice\SourceOption\InvoiceStateOptions</class>
                        </options>
                    </filter>
                </field>
                <field name="store_id">
                    <filter>
                        <type>store</type>
                    </filter>
                </field>
                <field name="order_id">
                    <filter>
                        <type>text</type>
                    </filter>
                </field>
                <field name="customer_group_id">
                    <filter>
                        <type>select</type>
                        <options>
                            <class>Amasty\ExportCore\Export\SourceOption\CustomerGroupOptions</class>
                        </options>
                    </filter>
                </field>
                <field name="payment_method">
                    <filter>
                        <type>select</type>
                        <options>
                            <class>Amasty\OrderExportEntity\Export\Order\SourceOption\PaymentMethodOptions</class>
                        </options>
                    </filter>
                </field>
                <field name="store_currency_code">
                    <filter>
                        <type>select</type>
                        <options>
                            <class>Amasty\OrderExportEntity\Export\Order\SourceOption\CurrencyOptions</class>
                        </options>
                    </filter>
                </field>
                <field name="order_currency_code">
                    <filter>
                        <type>select</type>
                        <options>
                            <class>Amasty\OrderExportEntity\Export\Order\SourceOption\CurrencyOptions</class>
                        </options>
                    </filter>
                </field>
                <field name="base_currency_code">
                    <filter>
                        <type>select</type>
                        <options>
                            <class>Amasty\OrderExportEntity\Export\Order\SourceOption\CurrencyOptions</class>
                        </options>
                    </filter>
                </field>
                <field name="global_currency_code">
                    <filter>
                        <type>select</type>
                        <options>
                            <class>Amasty\OrderExportEntity\Export\Order\SourceOption\CurrencyOptions</class>
                        </options>
                    </filter>
                </field>
            </fields>
        </fieldsConfig>
    </entity>
    <relation code="invoice_invoice_grid">
        <parent_entity>sales_invoice</parent_entity>
        <child_entity>sales_invoice_grid</child_entity>
        <sub_entity_field_name>sales_invoice_grid</sub_entity_field_name>
        <type>one_to_many</type>
        <arguments>
            <argument name="parent_field_name" xsi:type="string">entity_id</argument>
            <argument name="child_field_name" xsi:type="string">entity_id</argument>
        </arguments>
    </relation>
    <relation code="invoice_grid_invoice">
        <parent_entity>sales_invoice_grid</parent_entity>
        <child_entity>sales_invoice</child_entity>
        <sub_entity_field_name>sales_invoice</sub_entity_field_name>
        <type>one_to_many</type>
        <arguments>
            <argument name="parent_field_name" xsi:type="string">entity_id</argument>
            <argument name="child_field_name" xsi:type="string">entity_id</argument>
        </arguments>
    </relation>
</config>
