<odoo>
<template id="report_business_performance">
    <t t-call="web.html_container">
     <t t-call="web.basic_layout">
        <t t-foreach="docs" t-as="doc" t-set="first_doc" t-if="False"/>
    
            <link rel="stylesheet" href="/sos_inventory/static/src/css/style.css?v=7"/>

        <div class="page">
        <br></br>
            <h4 style="text-align: center;">Business Performance Report- <t t-esc="financial_year"/></h4>
            <span style="float: right;font-weight: bold;">Note : Rupees(In Lakhs)</span>
            <!-- ✅ SUMMARY TABLE -->
            <t t-if="not is_filtered_by_sales_person">

            <table class="table_custom" style="width:100%; font-size:14px;">
             <thead>
             <tr style="background-color: #c4c4ff;">
                <td colspan="15"><b>Summary</b></td>
              </tr>
    <tr style="background-color:#e4e0f9">
        <th>Month</th>
        <t t-foreach="months" t-as="m">
    <th><t t-esc="month_names[m]"/></th>
</t>
        <th>Total</th>
         <th>YTD</th>
    </tr>
</thead>
                <tbody>
                    <tr>
                        <td style="background-color:#e4e0f9"><strong>Target</strong></td>
                        <t t-set="total_target" t-value="0"/>
                        <t t-foreach="months" t-as="m">
                            <t t-set="val" t-value="summary['target'][m]"/>
                            <td><t t-esc="val"/></td>
                            <t t-set="total_target" t-value="total_target + val"/>
                        </t>
                        <td><t t-esc="'%.2f' % float(total_target)"/></td>
                         <td><t t-esc="summary['ytd']['target']"/></td>
                    </tr>
                    <tr>
                        <td style="background-color:#e4e0f9"><strong>PO Received</strong></td>
                        <t t-set="total_sales" t-value="0"/>
                        <t t-foreach="months" t-as="m">
                            <t t-set="val" t-value="summary['sales'][m]"/>
                            <td><t t-esc="val"/></td>
                            <t t-set="total_sales" t-value="total_sales + val"/>
                        </t>
                        <td><t t-esc="'%.2f' % float(total_sales)"/></td>
                            <td><t t-esc="summary['ytd']['sales']"/></td>

                    </tr>
                    <tr>
                        <td style="background-color:#e4e0f9"><strong>Billed</strong></td>
                        <t t-set="total_billed" t-value="0"/>
                        <t t-foreach="months" t-as="m">
                            <t t-set="val" t-value="summary['billed'][m]"/>
                            <td><t t-esc="'%.2f' % val"/></td>
                            <t t-set="total_billed" t-value="total_billed + val"/>
                        </t>

                        <td><t t-esc="'%.2f' % float(total_billed)"/></td>
                            <td><t t-esc="summary['ytd']['billed']"/></td>

                    </tr>
<tr>
    <td style="background-color:#e4e0f9"><strong>Yet to Bill</strong></td>
    <t t-set="total_yet_billed" t-value="0"/>
    
    <t t-foreach="enumerated_months" t-as="item">
        <t t-set="i" t-value="item[0]"/>
        <t t-set="m" t-value="item[1]"/>

        <t t-if="i &lt;= current_month_index">
            <t t-set="val" t-value="summary['yet_to_billed'][m] or 0.0"/>
            <td><t t-esc="'%.2f' % val"/></td>
            <t t-set="total_yet_billed" t-value="total_yet_billed + val"/>
        </t>
        <t t-else="">
            <td>0.00</td>
        </t>
    </t>

    <td><t t-esc="summary['ytd']['yet_to_billed']"/></td>
    <td><t t-esc="summary['ytd']['yet_to_billed']"/></td>
</tr>





                    <tr>
                        <td style="background-color:#e4e0f9"><strong>Collected</strong></td>
                        <t t-set="total_collected" t-value="0"/>
                        <t t-foreach="months" t-as="m">
                            <t t-set="val" t-value="summary['collected'][m]"/>
                            <td><t t-esc="'%.2f' % val"/></td>
                            <t t-set="total_collected" t-value="total_collected + val"/>
                        </t>
                        <td><t t-esc="'%.2f' % float(total_collected)"/></td>
                            <td><t t-esc="summary['ytd']['collected']"/></td>

                    </tr>


                </tbody>
            </table>
            <br/>
            <hr/>
            </t>

            

            <!-- 🔁 INDIVIDUAL SALES PERSON TABLES -->
            <t t-foreach="docs" t-as="doc">
                <table class="table_custom" style="width:100%; font-size:14px;">
<thead>
<tr style="background-color: #c4c4ff;">
                <td colspan="15"><b>Sales Executive : <t t-esc="doc.sales_person.name"/></b></td>
              </tr>
    <tr style="background-color:#e4e0f9">
        <th>Month</th>
             <t t-foreach="months" t-as="m">
    <th><t t-esc="month_names[m]"/></th>
</t>
        <th>Total</th>
        <th>YTD</th>
    </tr>
</thead>
                    <tbody>
                        <tr>
                            <td style="background-color:#e4e0f9"><strong>Target</strong></td>
                            <td><t t-esc="'%.2f' % float(doc.planned_target_april)"/></td>
                            <td><t t-esc="'%.2f' % float(doc.planned_target_may)"/></td>
                            <td><t t-esc="'%.2f' % float(doc.planned_target_june)"/></td>
                            <td><t t-esc="'%.2f' % float(doc.planned_target_july)"/></td>
                            <td><t t-esc="'%.2f' % float(doc.planned_target_august)"/></td>
                            <td><t t-esc="'%.2f' % float(doc.planned_target_september)"/></td>
                            <td><t t-esc="'%.2f' % float(doc.planned_target_october)"/></td>
                            <td><t t-esc="'%.2f' % float(doc.planned_target_november)"/></td>
                            <td><t t-esc="'%.2f' % float(doc.planned_target_december)"/></td>
                            <td><t t-esc="'%.2f' % float(doc.planned_target_january)"/></td>
                            <td><t t-esc="'%.2f' % float(doc.planned_target_february)"/></td>
                            <td><t t-esc="'%.2f' % float(doc.planned_target_march)"/></td>
                            <td><t t-esc="'%.2f' % float(doc.planned_target_total)"/></td>
                            <td><t t-esc="'%.2f' % float(doc.ytd_target)"/></td>
                        </tr>
                        <tr>
                            <td style="background-color:#e4e0f9"><strong>PO Received</strong></td>
                            <td><t t-esc="'%.2f' % float(doc.actual_target_april)"/></td>
                            <td><t t-esc="'%.2f' % float(doc.actual_target_may)"/></td>
                            <td><t t-esc="'%.2f' % float(doc.actual_target_june)"/></td>
                            <td><t t-esc="'%.2f' % float(doc.actual_target_july)"/></td>
                            <td><t t-esc="'%.2f' % float(doc.actual_target_august)"/></td>
                            <td><t t-esc="'%.2f' % float(doc.actual_target_september)"/></td>
                            <td><t t-esc="'%.2f' % float(doc.actual_target_october)"/></td>
                            <td><t t-esc="'%.2f' % float(doc.actual_target_november)"/></td>
                            <td><t t-esc="'%.2f' % float(doc.actual_target_december)"/></td>
                            <td><t t-esc="'%.2f' % float(doc.actual_target_january)"/></td>
                            <td><t t-esc="'%.2f' % float(doc.actual_target_february)"/></td>
                            <td><t t-esc="'%.2f' % float(doc.actual_target_march)"/></td>
                            <td><t t-esc="'%.2f' % float(doc.actual_target_total)"/></td>
                            <td><t t-esc="'%.2f' % float(doc.ytd_sales)"/></td>
                        </tr>
                        <!-- <tr>
                            <td><strong>%</strong></td>
                            <td><t t-esc="doc.achievement_percentage_april"/></td>
                            <td><t t-esc="doc.achievement_percentage_may"/></td>
                            <td><t t-esc="doc.achievement_percentage_june"/></td>
                            <td><t t-esc="doc.achievement_percentage_july"/></td>
                            <td><t t-esc="doc.achievement_percentage_august"/></td>
                            <td><t t-esc="doc.achievement_percentage_september"/></td>
                            <td><t t-esc="doc.achievement_percentage_october"/></td>
                            <td><t t-esc="doc.achievement_percentage_november"/></td>
                            <td><t t-esc="doc.achievement_percentage_december"/></td>
                            <td><t t-esc="doc.achievement_percentage_january"/></td>
                            <td><t t-esc="doc.achievement_percentage_february"/></td>
                            <td><t t-esc="doc.achievement_percentage_march"/></td>
                            <td><t t-esc="doc.achievement_percentage_total"/></td>
                            <td><t t-esc="doc.ytd_sales_percentage"/>%</td>
                        </tr> -->
                       
                        <tr>
                            <td style="background-color:#e4e0f9"><strong>Billed</strong></td>
                            <td><t t-esc="'%.2f' % float(doc.billed_target_april)"/></td>
                            <td><t t-esc="'%.2f' % float(doc.billed_target_may)"/></td>
                            <td><t t-esc="'%.2f' % float(doc.billed_target_june)"/></td>
                            <td><t t-esc="'%.2f' % float(doc.billed_target_july)"/></td>
                            <td><t t-esc="'%.2f' % float(doc.billed_target_august)"/></td>
                            <td><t t-esc="'%.2f' % float(doc.billed_target_september)"/></td>
                            <td><t t-esc="'%.2f' % float(doc.billed_target_october)"/></td>
                            <td><t t-esc="'%.2f' % float(doc.billed_target_november)"/></td>
                            <td><t t-esc="'%.2f' % float(doc.billed_target_december)"/></td>
                            <td><t t-esc="'%.2f' % float(doc.billed_target_january)"/></td>
                            <td><t t-esc="'%.2f' % float(doc.billed_target_february)"/></td>
                            <td><t t-esc="'%.2f' % float(doc.billed_target_march)"/></td>
                            <td><t t-esc="'%.2f' % float(doc.billed_target_total)"/></td>
                            <td><t t-esc="'%.2f' % float(doc.ytd_billed)"/></td>
                        </tr>
                        <tr>
    <td style="background-color:#e4e0f9"><strong>Yet to Bill</strong></td>
    
    <td><t t-esc="'%.2f' % float(doc.yet_to_billed_target_april) if current_month_index >= 0 else '0.00'"/></td>
    <td><t t-esc="'%.2f' % float(doc.yet_to_billed_target_may) if current_month_index >= 1 else '0.00'"/></td>
    <td><t t-esc="'%.2f' % float(doc.yet_to_billed_target_june) if current_month_index >= 2 else '0.00'"/></td>
    <td><t t-esc="'%.2f' % float(doc.yet_to_billed_target_july) if current_month_index >= 3 else '0.00'"/></td>
    <td><t t-esc="'%.2f' % float(doc.yet_to_billed_target_august) if current_month_index >= 4 else '0.00'"/></td>
    <td><t t-esc="'%.2f' % float(doc.yet_to_billed_target_september) if current_month_index >= 5 else '0.00'"/></td>
    <td><t t-esc="'%.2f' % float(doc.yet_to_billed_target_october) if current_month_index >= 6 else '0.00'"/></td>
    <td><t t-esc="'%.2f' % float(doc.yet_to_billed_target_november) if current_month_index >= 7 else '0.00'"/></td>
    <td><t t-esc="'%.2f' % float(doc.yet_to_billed_target_december) if current_month_index >= 8 else '0.00'"/></td>
    <td><t t-esc="'%.2f' % float(doc.yet_to_billed_target_january) if current_month_index >= 9 else '0.00'"/></td>
    <td><t t-esc="'%.2f' % float(doc.yet_to_billed_target_february) if current_month_index >= 10 else '0.00'"/></td>
    <td><t t-esc="'%.2f' % float(doc.yet_to_billed_target_march) if current_month_index >= 11 else '0.00'"/></td>

    <td><t t-esc="'%.2f' % float(doc.ytd_yet_to_billed)"/></td>
    <td><t t-esc="'%.2f' % float(doc.ytd_yet_to_billed)"/></td>
</tr>

                        <tr>
                            <td style="background-color:#e4e0f9"><strong>Collected</strong></td>
                            <td><t t-esc="'%.2f' % float(doc.collected_target_april)"/></td>
                            <td><t t-esc="'%.2f' % float(doc.collected_target_may)"/></td>
                            <td><t t-esc="'%.2f' % float(doc.collected_target_june)"/></td>
                            <td><t t-esc="'%.2f' % float(doc.collected_target_july)"/></td>
                            <td><t t-esc="'%.2f' % float(doc.collected_target_august)"/></td>
                            <td><t t-esc="'%.2f' % float(doc.collected_target_september)"/></td>
                            <td><t t-esc="'%.2f' % float(doc.collected_target_october)"/></td>
                            <td><t t-esc="'%.2f' % float(doc.collected_target_november)"/></td>
                            <td><t t-esc="'%.2f' % float(doc.collected_target_december)"/></td>
                            <td><t t-esc="'%.2f' % float(doc.collected_target_january)"/></td>
                            <td><t t-esc="'%.2f' % float(doc.collected_target_february)"/></td>
                            <td><t t-esc="'%.2f' % float(doc.collected_target_march)"/></td>
                            <td><t t-esc="'%.2f' % float(doc.collected_target_total)"/></td>
                            <td><t t-esc="'%.2f' % float(doc.ytd_collected)"/></td>
                        </tr>
                    </tbody>
                </table>
                <br/>
            </t>
        </div>
    </t>
     </t>
</template>


</odoo>