<?xml version="1.0"?>
<!--
/**
 * Avalara_AvaTax
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Open Software License (OSL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/osl-3.0.php
 *
 * @copyright  Copyright (c) 2016 Avalara, Inc.
 * @license    http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
 */
-->
<include xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_include.xsd">
    <group id="sales_tax" translate="label comment" showInDefault="1" showInWebsite="1" showInStore="1" sortOrder="20">
        <label>Tax Calculation</label>
        <frontend_model>Avalara\AvaTax\Block\Adminhtml\System\Config\ExpandedFieldSet</frontend_model>
        <field id="company_id" translate="label" type="select" sortOrder="1001" showInDefault="0" showInWebsite="0" showInStore="0">
            <config_path>tax/avatax/company_id</config_path>
            <label>Company Name</label>
            <frontend_model>companyCodeFrontendModel</frontend_model>
            <source_model>Avalara\AvaTax\Model\Config\Source\CompanyCode</source_model>
            <tooltip><![CDATA[Choose the company to use. If you don't see values in this dropdown, then enter values into the <strong>Account Number</strong> and <strong>License Key</strong> fields above.]]></tooltip>
            <depends>
                <field id="enabled">1</field>
            </depends>
        </field>
        <!-- This code scope needed for Adobe Commerce 2.3.2 and later. Adobe Commerce team added extra private method (filterNodes($configData)) to Magento\Config\Controller\Adminhtml\System\Config\Save for validation the file system.xml before save configuration data to the database.
        For the successful pass of the validation, there was added the declarative code. -->
        <!-- Start -->
        <field id="company_code" type="hidden" >
            <config_path>tax/avatax/company_code</config_path>
            <label>Company Code</label>
            <depends>
                <field id="enabled">1</field>
            </depends>
        </field>
        <!-- End -->
        <field id="tax_included" translate="label" type="radios" sortOrder="1002" showInDefault="0" showInWebsite="0" showInStore="0">
            <config_path>tax/avatax/tax_included</config_path>
            <label>Taxation Policy</label>
            <source_model>Avalara\AvaTax\Model\Config\Source\TaxIncluded</source_model>
            <frontend_model>Avalara\AvaTax\Block\Adminhtml\System\Config\TaxIncluded</frontend_model>
        </field>

        <field id="tax_mode" translate="label" type="radios" sortOrder="1003" showInDefault="0" showInWebsite="0" showInStore="0">
            <config_path>tax/avatax/tax_mode</config_path>
            <label>Tax Mode</label>
            <source_model>Avalara\AvaTax\Model\Config\Source\TaxMode</source_model>
        </field>
        <field id="tax_calculation_countries_enabled" translate="label comment" type="multiselect" sortOrder="1005" showInDefault="0" showInWebsite="0" showInStore="0">
            <config_path>tax/avatax/tax_calculation_countries_enabled</config_path>
            <label>Taxable Countries</label>
            <source_model>Avalara\AvaTax\Model\Config\Source\TaxCalculationCountries</source_model>
            <tooltip><![CDATA[Select which countries to enable for tax calculation (address verification countries are <a href="#row_tax_avatax_address_validation_header">configured below</a>).]]></tooltip>
            <depends>
                <field id="tax_mode" negative="1">1</field>
            </depends>
        </field>
        <field id="commit_submitted_transactions" translate="label" type="select" sortOrder="1009" showInDefault="0" showInWebsite="0" showInStore="0">
            <config_path>tax/avatax/commit_submitted_transactions</config_path>
            <label>Commit Submitted Transactions</label>
            <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
            <tooltip><![CDATA[Should transactions sent to AvaTax be committed? Only change to <strong>No</strong> if you have specific reason to do so.]]></tooltip>
            <depends>
                <field id="tax_mode">3</field>
            </depends>
        </field>
        <field id="data_mapping_header" translate="label" type="label" sortOrder="3000" showInDefault="1" showInWebsite="1" showInStore="1">
            <label><![CDATA[<strong>Data Mapping</strong>]]></label>
        </field>
        <field id="customer_code_format" translate="label comment" type="select" sortOrder="3010" showInDefault="1" showInWebsite="1" showInStore="1">
            <config_path>tax/avatax/customer_code_format</config_path>
            <label>Customer Code Format</label>
            <tooltip> Select a format to identify customers in Avalara. By default, the customer or guest ID is used.</tooltip>
            <source_model>Avalara\AvaTax\Model\Config\Source\CustomerCode</source_model>
        </field>
        <field id="upc_attribute" translate="label comment" type="select" sortOrder="3020" showInDefault="1" showInWebsite="0" showInStore="0">
            <config_path>tax/avatax/upc_attribute</config_path>
            <label>UPC Attribute To Use As Item Code</label>
            <source_model>Avalara\AvaTax\Model\Config\Source\Product\Attributes</source_model>
            <tooltip><![CDATA[Select a UPC product attribute of Adobe Commerce to map it with the AvaTax Item Code field.<br>To use a UPC product attribute as the AvaTax ItemCode, select which attribute maps to your UPC attribute. If a UPC attribute is present on a product record, it’s used as the AvaTax ItemCode and is prepended to the UPC. Otherwise, the product’s SKUs are sent.<br>Sending the UPC in the ItemCode field bypasses the Avalara Tax Code selection and mapping in your product record. The UPC, when sent in the ItemCode field, maps directly to the Avalara Product Tax Code. You don’t have to map those codes separately.<br>If you don't select a UPC attribute from this list, then by default, the Adobe Commerce product SKU is used as the AvaTax ItemCode in your transactions.]]></tooltip>
        </field>
        <field id="ref1_attribute" translate="label comment" type="select" sortOrder="3030" showInDefault="0" showInWebsite="0" showInStore="0">
            <config_path>tax/avatax/ref1_attribute</config_path>
            <label>Ref1 Attribute</label>
            <source_model>Avalara\AvaTax\Model\Config\Source\Product\Attributes</source_model>
            <tooltip><![CDATA[AvaTax allows you to pass arbitrary information into two reference fields for each line item. Select a text type product attribute to be sent to AvaTax in the <strong>Ref1</strong> field. Only the first 250 characters of this attribute will be sent to AvaTax.]]></tooltip>
        </field>
        <field id="ref2_attribute" translate="label comment" type="select" sortOrder="3040" showInDefault="0" showInWebsite="0" showInStore="0">
            <config_path>tax/avatax/ref2_attribute</config_path>
            <label>Ref2 Attribute</label>
            <source_model>Avalara\AvaTax\Model\Config\Source\Product\Attributes</source_model>
            <tooltip><![CDATA[AvaTax allows you to pass arbitrary information into two reference fields for each line item. Select a text type product attribute to be sent to AvaTax in the <strong>Ref2</strong> field. Only the first 250 characters of this attribute will be sent to AvaTax.]]></tooltip>
        </field>
        <field id="shipping_tax_code" translate="label" type="text" sortOrder="3065" showInDefault="0" showInWebsite="0" showInStore="0" canRestore="1">
            <config_path>tax/avatax/shipping_tax_code</config_path>
            <label>Shipping Tax Code</label>
            <frontend_model>Avalara\AvaTax\Block\Adminhtml\System\Config\ShippingTaxCode</frontend_model>
            <frontend_class>avatax-tax-code</frontend_class>
            <comment>Set a default shipping tax code for transactions that are missing a shipping tax code. Avalara assigns the shipping tax code for a third-party common carrier (FR) if you don't enter a value.</comment>
        </field>
        <field id="avatax_adjustment_taxes" translate="label" type="select" sortOrder="3066" showInDefault="0" showInWebsite="0" showInStore="0">
            <config_path>tax/avatax_advanced/avatax_adjustment_taxes</config_path>
            <label>Calculate Tax on Adjustment Refunds and Adjustment Fees</label>
            <frontend_model>adjustmentEnabledToggle</frontend_model>
            <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
            <tooltip><![CDATA[Adobe Commerce does not calculate taxes for adjustment refunds and adjustment fees. Avalara calculates tax for these items if this setting is enabled.]]></tooltip>
        </field>
        <field id="sku_shipping" translate="label" type="text" sortOrder="3070" showInDefault="0" showInWebsite="0" showInStore="0">
            <config_path>tax/avatax/sku_shipping</config_path>
            <label>Shipping SKU</label>
            <tooltip>The SKU sent to denote shipping costs.</tooltip>
            <frontend_class>required-entry validate-length maximum-length-50</frontend_class>
        </field>
        <field id="sku_adjustment_positive" translate="label" type="text" sortOrder="3080" showInDefault="0" showInWebsite="0" showInStore="0">
            <config_path>tax/avatax/sku_adjustment_positive</config_path>
            <label>Adjustment Refund SKU</label>
            <tooltip>The SKU sent to denote positive adjustments on Credit Memos.</tooltip>
            <frontend_class>required-entry validate-length maximum-length-50</frontend_class>
        </field>
        <field id="sku_adjustment_negative" translate="label" type="text" sortOrder="3090" showInDefault="0" showInWebsite="0" showInStore="0">
            <config_path>tax/avatax/sku_adjustment_negative</config_path>
            <label>Adjustment Fee SKU</label>
            <tooltip>The SKU sent to denote negative adjustments on Credit Memos.</tooltip>
            <frontend_class>required-entry validate-length maximum-length-50</frontend_class>
        </field>
        <field id="sku_gift_wrap_order" translate="label" type="text" sortOrder="3100" showInDefault="0" showInWebsite="0" showInStore="0">
            <config_path>tax/avatax/sku_gift_wrap_order</config_path>
            <label>Gift Wrap Order SKU</label>
            <tooltip>The SKU sent AvaTax to denote gift wrap order costs. Only relevant for Adobe Commerce Enterprise.</tooltip>
            <frontend_class>required-entry validate-length maximum-length-50</frontend_class>
        </field>
        <field id="sku_gift_wrap_item" translate="label" type="text" sortOrder="3110" showInDefault="0" showInWebsite="0" showInStore="0">
            <config_path>tax/avatax/sku_gift_wrap_item</config_path>
            <label>Gift Wrap Items SKU</label>
            <tooltip>The SKU sent AvaTax to denote gift wrap item costs. Only relevant for Adobe Commerce Enterprise.</tooltip>
            <frontend_class>required-entry validate-length maximum-length-50</frontend_class>
        </field>
        <field id="sku_gift_wrap_card" translate="label" type="text" sortOrder="3120" showInDefault="0" showInWebsite="0" showInStore="0">
            <config_path>tax/avatax/sku_gift_wrap_card</config_path>
            <label>Gift Wrap Printed Card SKU</label>
            <tooltip>The SKU sent to denote gift wrap printed card costs. Only relevant for Adobe Commerce Enterprise.</tooltip>
            <frontend_class>required-entry validate-length maximum-length-50</frontend_class>
        </field>
        <depends>
            <field id="tax/avatax_configuration/enabled">1</field>
        </depends>
    </group>
</include>