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

    <!-- ============================================================ -->
    <!--         DEFAULT FOLLOW-UP LEVELS                              -->
    <!-- ============================================================ -->

    <record id="fusion_followup_level_1" model="fusion.followup.level">
        <field name="name">First Reminder</field>
        <field name="sequence">10</field>
        <field name="delay">15</field>
        <field name="send_email" eval="True"/>
        <field name="send_sms" eval="False"/>
        <field name="send_letter" eval="False"/>
        <field name="join_invoices" eval="True"/>
        <field name="description" type="html">
            <p>Dear Customer,</p>
            <p>We notice that your account has an outstanding balance past the due date.
            We kindly ask you to settle the amount at your earliest convenience.</p>
            <p>If payment has already been made, please disregard this notice.</p>
            <p>Best regards</p>
        </field>
        <field name="company_id" ref="base.main_company"/>
    </record>

    <record id="fusion_followup_level_2" model="fusion.followup.level">
        <field name="name">Second Reminder</field>
        <field name="sequence">20</field>
        <field name="delay">30</field>
        <field name="send_email" eval="True"/>
        <field name="send_sms" eval="False"/>
        <field name="send_letter" eval="True"/>
        <field name="join_invoices" eval="True"/>
        <field name="description" type="html">
            <p>Dear Customer,</p>
            <p>Despite our previous reminder, your account still has an overdue balance.
            We urge you to arrange payment promptly to avoid further action.</p>
            <p>Please contact us immediately if there is a dispute regarding the invoice.</p>
            <p>Best regards</p>
        </field>
        <field name="company_id" ref="base.main_company"/>
    </record>

    <record id="fusion_followup_level_3" model="fusion.followup.level">
        <field name="name">Final Notice</field>
        <field name="sequence">30</field>
        <field name="delay">45</field>
        <field name="send_email" eval="True"/>
        <field name="send_sms" eval="True"/>
        <field name="send_letter" eval="True"/>
        <field name="join_invoices" eval="True"/>
        <field name="description" type="html">
            <p>Dear Customer,</p>
            <p>This is our final notice regarding your overdue account balance.
            Immediate payment is required. Failure to remit payment may result
            in suspension of services and further collection measures.</p>
            <p>Please contact our accounting department without delay.</p>
            <p>Best regards</p>
        </field>
        <field name="company_id" ref="base.main_company"/>
    </record>

    <!-- ============================================================ -->
    <!--         DEFAULT EMAIL TEMPLATE                                -->
    <!-- ============================================================ -->

    <record id="email_template_fusion_followup_default" model="mail.template">
        <field name="name">Fusion: Payment Follow-up</field>
        <field name="model_id" ref="base.model_res_partner"/>
        <field name="email_from">{{ (object.company_id.email or user.email_formatted) }}</field>
        <field name="subject">{{ object.company_id.name }} - Payment Reminder for {{ object.name }}</field>
        <field name="body_html" type="html">
            <div style="margin: 0; padding: 0; font-family: Arial, sans-serif;">
                <p style="margin: 0 0 12px 0;">
                    Dear <t t-out="object.name or 'Customer'"/>,
                </p>
                <p style="margin: 0 0 12px 0;">
                    We are writing to remind you that your account with
                    <strong><t t-out="object.company_id.name or ''"/></strong>
                    has an outstanding balance that is past due.
                </p>
                <p style="margin: 0 0 12px 0;">
                    Please arrange payment at your earliest convenience. If you have
                    already sent payment, please disregard this notice and accept
                    our thanks.
                </p>
                <p style="margin: 0 0 12px 0;">
                    Should you have any questions or wish to discuss payment
                    arrangements, please do not hesitate to contact us.
                </p>
                <p style="margin: 0 0 4px 0;">Best regards,</p>
                <p style="margin: 0;">
                    <t t-out="user.name or ''"/><br/>
                    <t t-out="object.company_id.name or ''"/>
                </p>
            </div>
        </field>
        <field name="lang">{{ object.lang }}</field>
        <field name="auto_delete" eval="False"/>
    </record>

    <!-- ============================================================ -->
    <!--         SCHEDULED ACTION (ir.cron)                            -->
    <!-- ============================================================ -->

    <record id="cron_fusion_followup_check" model="ir.cron">
        <field name="name">Fusion: Payment Follow-up Check</field>
        <field name="model_id" ref="base.model_res_partner"/>
        <field name="state">code</field>
        <field name="code">model.compute_partners_needing_followup()</field>
        <field name="interval_number">1</field>
        <field name="interval_type">days</field>

        <field name="active" eval="True"/>
    </record>

</odoo>
