<?xml version="1.0" encoding="utf-8"?>
<odoo>

    <record id="res_config_settings_view_form_fusion_clover" model="ir.ui.view">
        <field name="name">res.config.settings.view.form.fusion.clover</field>
        <field name="model">res.config.settings</field>
        <field name="inherit_id" ref="base.res_config_settings_view_form"/>
        <field name="arch" type="xml">
            <xpath expr="//form" position="inside">
                <app data-string="Fusion Clover" string="Fusion Clover" name="fusion_clover"
                     groups="fusion_clover.group_fusion_clover_admin">

                    <h2>Credit Card Surcharge</h2>
                    <div class="row mt-4 o_settings_container">
                        <div class="col-12 col-lg-6 o_setting_box">
                            <div class="o_setting_left_pane">
                                <field name="clover_surcharge_enabled"/>
                            </div>
                            <div class="o_setting_right_pane">
                                <span class="o_form_label">Credit Card Processing Fee</span>
                                <div class="text-muted">
                                    Automatically add a surcharge line to invoices when collecting payment
                                    via Clover. The fee is calculated as a percentage of the invoice total.
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="row mt-4 o_settings_container"
                         invisible="not clover_surcharge_enabled">
                        <div class="col-12 col-lg-6 o_setting_box">
                            <div class="o_setting_right_pane">
                                <span class="o_form_label">Surcharge Rates by Card Type</span>
                                <div class="text-muted mb-2">
                                    Configure the processing fee percentage for each card brand.
                                </div>
                                <div class="mt-2">
                                    <div class="row mb-2">
                                        <label for="clover_surcharge_visa_rate"
                                               class="col-5 col-form-label">Visa</label>
                                        <div class="col-4">
                                            <field name="clover_surcharge_visa_rate" class="o_input"/>
                                        </div>
                                        <div class="col-1 col-form-label">%</div>
                                    </div>
                                    <div class="row mb-2">
                                        <label for="clover_surcharge_mastercard_rate"
                                               class="col-5 col-form-label">Mastercard</label>
                                        <div class="col-4">
                                            <field name="clover_surcharge_mastercard_rate" class="o_input"/>
                                        </div>
                                        <div class="col-1 col-form-label">%</div>
                                    </div>
                                    <div class="row mb-2">
                                        <label for="clover_surcharge_amex_rate"
                                               class="col-5 col-form-label">American Express</label>
                                        <div class="col-4">
                                            <field name="clover_surcharge_amex_rate" class="o_input"/>
                                        </div>
                                        <div class="col-1 col-form-label">%</div>
                                    </div>
                                    <div class="row mb-2">
                                        <label for="clover_surcharge_debit_rate"
                                               class="col-5 col-form-label">Debit</label>
                                        <div class="col-4">
                                            <field name="clover_surcharge_debit_rate" class="o_input"/>
                                        </div>
                                        <div class="col-1 col-form-label">%</div>
                                    </div>
                                    <div class="row mb-2">
                                        <label for="clover_surcharge_other_rate"
                                               class="col-5 col-form-label">Other Cards</label>
                                        <div class="col-4">
                                            <field name="clover_surcharge_other_rate" class="o_input"/>
                                        </div>
                                        <div class="col-1 col-form-label">%</div>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <div class="col-12 col-lg-6 o_setting_box">
                            <div class="o_setting_right_pane">
                                <span class="o_form_label">Surcharge Product</span>
                                <div class="text-muted mb-2">
                                    The service product used for the processing fee invoice line.
                                </div>
                                <div class="mt-2">
                                    <field name="clover_surcharge_product_id"
                                           domain="[('type', '=', 'service')]"/>
                                </div>
                            </div>
                        </div>
                    </div>

                    <h2>Quick Links</h2>
                    <div class="row mt-4 o_settings_container">
                        <div class="col-12 col-lg-6 o_setting_box">
                            <div class="o_setting_right_pane">
                                <span class="o_form_label">Payment Provider</span>
                                <div class="text-muted mb-2">
                                    Configure your Clover API credentials and merchant ID.
                                </div>
                                <div class="mt-2">
                                    <button name="action_open_clover_provider"
                                            type="object"
                                            string="Configure Payment Provider"
                                            class="btn-link"
                                            icon="fa-arrow-right"/>
                                </div>
                            </div>
                        </div>
                    </div>

                </app>
            </xpath>
        </field>
    </record>

    <record id="action_fusion_clover_settings" model="ir.actions.act_window">
        <field name="name">Fusion Clover Settings</field>
        <field name="res_model">res.config.settings</field>
        <field name="view_mode">form</field>
        <field name="target">current</field>
        <field name="context" eval="{'module': 'fusion_clover'}"/>
    </record>

</odoo>
