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

    <record id="deposit_deduction_wizard_form" model="ir.ui.view">
        <field name="name">deposit.deduction.wizard.form</field>
        <field name="model">deposit.deduction.wizard</field>
        <field name="arch" type="xml">
            <form string="Process Security Deposit">
                <group>
                    <group>
                        <field name="order_id" readonly="1"/>
                        <field name="partner_id" readonly="1"/>
                    </group>
                    <group>
                        <field name="deposit_total" widget="monetary"/>
                        <field name="has_card_on_file" invisible="1"/>
                    </group>
                </group>

                <separator string="Action"/>
                <group>
                    <field name="action_type" widget="radio"/>
                </group>

                <!-- Deduction fields (partial / no refund) -->
                <group invisible="action_type not in ('partial_refund', 'no_refund')">
                    <group>
                        <field name="deduction_amount" widget="monetary"
                               required="action_type in ('partial_refund', 'no_refund')"/>
                    </group>
                    <group>
                        <field name="remaining_preview" widget="monetary"
                               invisible="action_type != 'partial_refund'"/>
                        <field name="overage_preview" widget="monetary"
                               decoration-danger="overage_preview > 0"/>
                    </group>
                </group>

                <group invisible="action_type not in ('partial_refund', 'no_refund')">
                    <field name="reason"
                           required="action_type in ('partial_refund', 'no_refund')"
                           placeholder="Describe the damages or reason for deduction..."/>
                </group>

                <!-- Refund preview for full refund / sold -->
                <group invisible="action_type not in ('full_refund', 'sold')">
                    <field name="refund_preview" widget="monetary" string="Amount to Refund"/>
                </group>

                <!-- Sold note -->
                <div class="alert alert-info" role="alert"
                     invisible="action_type != 'sold'">
                    <i class="fa fa-info-circle me-2"/>
                    The full security deposit will be refunded to the customer's card.
                    The rental will be marked as sold and an activity will be created for follow-up.
                </div>

                <!-- Refund method note -->
                <div class="alert alert-warning" role="alert"
                     invisible="has_card_on_file or action_type in ('no_refund',)">
                    <i class="fa fa-exclamation-triangle me-2"/>
                    No card on file. The refund will need to be processed manually.
                </div>

                <footer>
                    <button name="action_confirm"
                            string="Process Deposit"
                            type="object"
                            class="btn-primary"
                            icon="fa-check"
                            confirm="This will process the deposit and close the rental. Continue?"/>
                    <button string="Cancel" class="btn-secondary" special="cancel"/>
                </footer>
            </form>
        </field>
    </record>

</odoo>
