<?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="address_validation" translate="label comment" showInDefault="0" showInWebsite="0" showInStore="0" sortOrder="30">
        <label>Address Validation</label>
        <frontend_model>Avalara\AvaTax\Block\Adminhtml\System\Config\ExpandedFieldSet</frontend_model>
        <field id="address_validation_enabled" translate="label comment" type="select" sortOrder="4010" showInDefault="0" showInWebsite="0" showInStore="0">
            <config_path>tax/avatax/address_validation_enabled</config_path>
            <label>Validate Addresses</label>
            <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
            <frontend_model>addressValidationEnabledToggle</frontend_model>
            <tooltip>Turn this on to enable the Validate addresses option. Customers can use it to validate and correct addresses in the US and Canada.</tooltip>
        </field>
        <field id="address_validation_countries_enabled" translate="label comment" type="multiselect" sortOrder="4020" showInDefault="0" showInWebsite="0" showInStore="0">
            <config_path>tax/avatax/address_validation_countries_enabled</config_path>
            <label>Enabled Countries</label>
            <source_model>Avalara\AvaTax\Model\Config\Source\AddressValidationCountries</source_model>
            <tooltip>Select which countries to enable for address validation. AvaTax Address Validation currently only supports United States and Canada.</tooltip>
            <depends>
                <field id="address_validation_enabled">1</field>
            </depends>
        </field>
        <field id="address_validation_user_has_choice" translate="label comment" type="select" sortOrder="4030" showInDefault="0" showInWebsite="0" showInStore="0">
            <config_path>tax/avatax/address_validation_user_has_choice</config_path>
            <label>Allow User To Choose Original Address</label>
            <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
            <tooltip><![CDATA[Set this to <strong>Yes</strong> to allow the user to choose between the original and validated addresses (valid address will be selected by default). If set to <strong>No</strong>, user will be required to use the validated address or update their original address. This setting is ignored in the backend and the user will always have a choice.]]></tooltip>
            <depends>
                <field id="address_validation_enabled">1</field>
            </depends>
        </field>
        <field id="address_validation_instructions_with_choice" translate="label comment" type="textarea" sortOrder="4040" showInDefault="0" showInWebsite="0" showInStore="0">
            <config_path>tax/avatax/address_validation_instructions_with_choice</config_path>
            <label>Address Validation Instructions</label>
            <tooltip><![CDATA[When user progresses to the <strong>Review & Payments</strong> step of the checkout, this text will be displayed above the <strong>Suggested Address</strong> and <strong>Original Address</strong> checkboxes.]]></tooltip>
            <depends>
                <field id="address_validation_enabled">1</field>
                <field id="address_validation_user_has_choice">1</field>
            </depends>
        </field>
        <field id="address_validation_instructions_without_choice" translate="label comment" type="textarea" sortOrder="4050" showInDefault="0" showInWebsite="0" showInStore="0">
            <config_path>tax/avatax/address_validation_instructions_without_choice</config_path>
            <label>Address Validation Instructions</label>
            <tooltip><![CDATA[When user progresses to the <strong>Review & Payments</strong> step of the checkout, this text will be displayed above the suggested address.]]></tooltip>
            <depends>
                <field id="address_validation_enabled">1</field>
                <field id="address_validation_user_has_choice">0</field>
            </depends>
        </field>
        <field id="address_validation_error_instructions" translate="label comment" type="textarea" sortOrder="4060" showInDefault="0" showInWebsite="0" showInStore="0">
            <config_path>tax/avatax/address_validation_error_instructions</config_path>
            <label>Address Validation Error Message</label>
            <tooltip>This text will be displayed when there is an error in the address validation process. The element assigned the "error-message" class will be filled with the error message summary returned by AvaTax.</tooltip>
            <depends>
                <field id="address_validation_enabled">1</field>
            </depends>
        </field>
        <depends>
            <field id="tax/avatax_configuration/enabled">1</field>
            <field id="tax/avatax_configuration/address_validation_hidden">1</field>
        </depends>
    </group>
</include>