<?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="error_logs_queue" translate="label comment" showInDefault="0" showInWebsite="0" showInStore="0" sortOrder="70">
        <label>Error, Logs and Queue</label>
        <frontend_model>Avalara\AvaTax\Block\Adminhtml\System\Config\ExpandedFieldSet</frontend_model>
        <group id="error_settings" translate="label comment" showInDefault="0" showInWebsite="0" showInStore="0" sortOrder="10">
            <label>Error Handling Settings</label>
            <attribute type="expanded">1</attribute>
            <frontend_model>Magento\Config\Block\System\Config\Form\Fieldset</frontend_model>
            <field id="response_logging_enabled" translate="label" type="select" sortOrder="2015" showInDefault="0" showInWebsite="0" showInStore="0">
                <config_path>tax/avatax_advanced/response_logging_enabled</config_path>
                <label>Enable Logging of AvaTax Response Data</label>
                <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
                <tooltip><![CDATA[By default, AvaTax API response data for Orders, Invoices, and Credit Memo API calls are stored in the avatax_sales_order, avatax_sales_invoice, and avatax_sales_creditmemo tables. This data is stored in case there is ever a need to compare the exact response data from AvaTax with what is saved on the Adobe Commerce tax fields. Disable this logging if you won't ever need this]]></tooltip>
            </field>
            <field id="error_action" translate="label comment" type="select" sortOrder="2010" showInDefault="0" showInWebsite="0" showInStore="0">
                <config_path>tax/avatax/error_action</config_path>
                <label>Error Action</label>
                <source_model>Avalara\AvaTax\Model\Config\Source\ErrorAction</source_model>
                <tooltip><![CDATA[If there is an error when Avalara estimates tax, the extension uses Adobe Commerce tax rules. If <b>Disable checkout and show error message</b> is selected, the extension prevents users and admins from placing orders.]]></tooltip>
            </field>
            <field id="error_action_disable_checkout_message_frontend" translate="label comment" type="textarea" sortOrder="2020" showInDefault="0" showInWebsite="0" showInStore="0">
                <config_path>tax/avatax/error_action_disable_checkout_message_frontend</config_path>
                <label>Frontend Error Message</label>
                <tooltip><![CDATA[This error message will be displayed to user if there is an error calculating taxes and if <strong>Disable checkout & show error message</strong> is selected above.]]></tooltip>
                <depends>
                    <field id="error_action">1</field>
                </depends>
            </field>
            <field id="error_action_disable_checkout_message_backend" translate="label comment" type="textarea" sortOrder="2030" showInDefault="0" showInWebsite="0" showInStore="0">
                <config_path>tax/avatax/error_action_disable_checkout_message_backend</config_path>
                <label>Backend Error Message</label>
                <tooltip><![CDATA[This error message will be displayed to admin if there is an error calculating taxes and if <strong>Disable checkout & show error message</strong> is selected above.]]></tooltip>
                <depends>
                    <field id="error_action">1</field>
                </depends>
            </field>
            <field id="avatax_timeout" translate="label comment" type="text" sortOrder="2050" showInDefault="0" showInWebsite="0" showInStore="0" canRestore="1">
                <config_path>tax/avatax_advanced/avatax_timeout</config_path>
                <label>AvaTax API Timeout</label>
                <tooltip><![CDATA[This is how long Adobe Commerce should wait to hear from Avalara's servers before assuming they aren't responding.]]></tooltip>
            </field>
        </group>
        <group id="logs_settings" translate="label comment" showInDefault="0" showInWebsite="0" showInStore="0" sortOrder="20">
            <label>Logging Settings</label>
            <attribute type="expanded">1</attribute>
            <frontend_model>Magento\Config\Block\System\Config\Form\Fieldset</frontend_model>
            <field id="logging_db_level" translate="label" type="select" sortOrder="5010" showInDefault="0" showInWebsite="0" showInStore="0">
                <config_path>tax/avatax/logging_db_level</config_path>
                <label>Database Log Level</label>
                <source_model>Avalara\AvaTax\Model\Config\Source\LogLevel</source_model>
                <comment><![CDATA[<strong>Warning</strong> is recommended if you're connected to an Avalara production account.]]></comment>
            </field>
            <field id="logging_db_detail" translate="label" type="select" sortOrder="5020" showInDefault="0" showInWebsite="0" showInStore="0">
                <config_path>tax/avatax/logging_db_detail</config_path>
                <label>Database Log Detail</label>
                <source_model>Avalara\AvaTax\Model\Config\Source\LogDetail</source_model>
                <comment><![CDATA[<strong>Minimal</strong> is recommended if you're connected to an Avalara production account.]]></comment>
            </field>
            <field id="logging_db_lifetime" translate="label" type="text" sortOrder="5030" showInDefault="0" showInWebsite="0" showInStore="0">
                <config_path>tax/avatax/logging_db_lifetime</config_path>
                <label>Database Log Record Lifetime</label>
                <comment>Required days before entries are auto-purged.</comment>
                <frontend_class>validate-number</frontend_class>
                <validate>required-entry integer validate-greater-than-zero</validate>
            </field>
            <field id="logging_file_enabled" translate="label" type="select" sortOrder="5040" showInDefault="0" showInWebsite="0" showInStore="0">
                <config_path>tax/avatax/logging_file_enabled</config_path>
                <label>Enable Logging To File</label>
                <frontend_model>loggingFileEnabledToggle</frontend_model>
                <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
                <comment>Turn this on to create a log of API requests, responses, and errors for transactions. The log is saved in Adobe Commerce. It's useful when troubleshooting issues with transactions.</comment>
            </field>
            <field id="logging_file_mode" translate="label" type="select" sortOrder="5050" showInDefault="0" showInWebsite="0" showInStore="0">
                <config_path>tax/avatax/logging_file_mode</config_path>
                <label>File Log Mode</label>
                <source_model>Avalara\AvaTax\Model\Config\Source\LogFileMode</source_model>
                <depends>
                    <field id="logging_file_enabled">1</field>
                </depends>
                <tooltip>Log files are located in the magento var/log/ directory</tooltip>
            </field>
            <field id="logging_file_builtin_rotation_enabled" translate="label" type="select" sortOrder="5060" showInDefault="0" showInWebsite="0" showInStore="0">
                <config_path>tax/avatax/logging_file_builtin_rotation_enabled</config_path>
                <label>Enable Built-In Log File Rotation</label>
                <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
                <depends>
                    <field id="logging_file_enabled">1</field>
                    <field id="logging_file_mode">2</field>
                </depends>
                <tooltip>Automatic log file rotation will allow you to control how much history is maintained in
                    the AvaTax log files, and separate them by day. For more efficient management of log files you should disable this option and use something like logrotate to handle the rotation of log files at the system level.
                </tooltip>
            </field>
            <field id="logging_file_builtin_rotation_max_files" translate="label" type="text" sortOrder="5070" showInDefault="0" showInWebsite="0" showInStore="0">
                <config_path>tax/avatax/logging_file_builtin_rotation_max_files</config_path>
                <label>Built-In Log File Rotation Max Files</label>
                <frontend_class>validate-number</frontend_class>
                <validate>required-entry integer validate-greater-than-zero</validate>
                <depends>
                    <field id="logging_file_enabled">1</field>
                    <field id="logging_file_mode">2</field>
                    <field id="logging_file_builtin_rotation_enabled">1</field>
                </depends>
                <tooltip>The number of files/days to maintain in the log directory when rotating. The log file rotator will create a new file each day.
                </tooltip>
            </field>
            <field id="logging_file_level" translate="label" type="select" sortOrder="5080" showInDefault="0" showInWebsite="0" showInStore="0">
                <config_path>tax/avatax/logging_file_level</config_path>
                <label>File Log Level</label>
                <source_model>Avalara\AvaTax\Model\Config\Source\LogLevel</source_model>
                <depends>
                    <field id="logging_file_enabled">1</field>
                </depends>
                <comment><![CDATA[<strong>Warning</strong> is recommended if you’re connected to an Avalara production account.]]></comment>
            </field>
            <field id="logging_file_detail" translate="label" type="select" sortOrder="5090" showInDefault="0" showInWebsite="0" showInStore="0">
                <config_path>tax/avatax/logging_file_detail</config_path>
                <label>File Log Detail</label>
                <source_model>Avalara\AvaTax\Model\Config\Source\LogDetail</source_model>
                <depends>
                    <field id="logging_file_enabled">1</field>
                </depends>
                <comment><![CDATA[<strong>Normal</strong> is recommended if you’re connected to an Avalara production account.]]></comment>
            </field>
        </group>
        <group id="queue_settings" translate="label" showInDefault="0" showInWebsite="0" showInStore="0" sortOrder="30">
            <label>Queue Processing Settings</label>
            <comment><![CDATA[These settings have no effect if your business isn't submitting transactions to Avalara.]]></comment>
            <attribute type="expanded">1</attribute>
            <frontend_model>Magento\Config\Block\System\Config\Form\Fieldset</frontend_model>
            <field id="queue_processing_type" translate="label" type="radios" sortOrder="6005" showInDefault="0" showInWebsite="0" showInStore="0">
                <config_path>tax/avatax/queue_processing_type</config_path>
                <label>Queue Processing Type</label>
                <source_model>Avalara\AvaTax\Model\Config\Source\QueueProcessingType</source_model>
                <depends>
                    <field id="queue_submission_enabled">1</field>
                </depends>
            </field>
            <field id="queue_admin_notification_enabled" translate="label" type="select" sortOrder="6010" showInDefault="0" showInWebsite="0" showInStore="0">
                <config_path>tax/avatax/queue_admin_notification_enabled</config_path>
                <label>Enable Queue Admin Notification</label>
                <frontend_model>queueAdminNotificationEnabledToggle</frontend_model>
                <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
                <depends>
                    <field id="queue_submission_enabled">1</field>
                </depends>
                <tooltip>A notification will be displayed at the top of any admin page if there are pending queue records waiting to be submitted to AvaTax but no attempts have been made in the last 24 hours to submit them.</tooltip>
            </field>
            <field id="queue_failure_notification_enabled" translate="label" type="select" sortOrder="6020" showInDefault="0" showInWebsite="0" showInStore="0">
                <config_path>tax/avatax/queue_failure_notification_enabled</config_path>
                <label>Enable Queue Failure Notification</label>
                <frontend_model>queueFailureNotificationEnabledToggle</frontend_model>
                <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
                <depends>
                    <field id="queue_submission_enabled">1</field>
                </depends>
                <tooltip>A notification displays at the top of any admin page if there are transactions waiting to be submitted to Avalara and no attempts have been made to submit them in the last 24 hours.</tooltip>
            </field>
            <field id="queue_max_retry_attempts" translate="label comment" type="text" sortOrder="6030" showInDefault="0" showInWebsite="0" showInStore="0">
                <config_path>tax/avatax/queue_max_retry_attempts</config_path>
                <label>Max Queue Retry Attempts</label>
                <tooltip>Please enter a number 1 or greater in this field.</tooltip>
                <frontend_class>validate-number</frontend_class>
                <validate>required-entry integer validate-greater-than-zero</validate>
            </field>
            <field id="queue_complete_lifetime" translate="label comment" type="text" sortOrder="6040" showInDefault="0" showInWebsite="0" showInStore="0">
                <config_path>tax/avatax/queue_complete_lifetime</config_path>
                <label>Complete Queue Lifetime</label>
                <tooltip>Required. Days before entries are auto-purged.</tooltip>
                <frontend_class>validate-number</frontend_class>
                <validate>required-entry integer validate-greater-than-zero</validate>
                <depends>
                    <field id="queue_submission_enabled">1</field>
                </depends>
            </field>
            <field id="queue_failed_lifetime" translate="label comment" type="text" sortOrder="6050" showInDefault="0" showInWebsite="0" showInStore="0">
                <config_path>tax/avatax/queue_failed_lifetime</config_path>
                <label>Failed Queue Lifetime</label>
                <tooltip>Required. Days before entries are auto-purged.</tooltip>
                <frontend_class>validate-number</frontend_class>
                <validate>required-entry integer validate-greater-than-zero</validate>
                <depends>
                    <field id="queue_submission_enabled">1</field>
                </depends>
            </field>
            <depends>
                <field id="tax/avatax_configuration/sales_tax/tax_mode">3</field>
            </depends>
        </group>
        <depends>
            <field id="tax/avatax_configuration/enabled">1</field>
        </depends>
    </group>
</include>