<odoo>
  <template id="report_billing_target">
    <t t-call="web.basic_layout">
      <t t-set="report_title" t-value="'Billing Target Report'" />
      <link rel="stylesheet" href="/sos_inventory/static/src/css/style.css?v=7" />
      <div class="page">
      <style>
    .wide-column {
        width: 200px;
    }
</style>
      <br></br>
        <h4 class="text-center" style="margin-bottom: 20px;">BILLING TARGET</h4>
<table class="table_custom" style="width: 100%; table-layout: fixed;">
  <thead style="background-color: #fef0ff;">
    <tr style="margin-top: 30px; color: #1a73e8;font-size:18px;background-color: #e8c1eb;">
      <td colspan="14">Summary</td>
    </tr>
    <tr>
      <th class="wide-column">Month</th>
      <t t-foreach="month_names" t-as="month">
        <th><t t-esc="month[:3]" /></th>
      </t>
      <th>Total</th> <!-- 👈 Add this -->
    </tr>
  </thead>
  <tbody>
    <tr class="summary-row">
      <td><strong>Grand Total</strong></td>
      <t t-foreach="month_names" t-as="month">
        <td><t t-esc="'%.2f' % overall_monthly_totals.get(month, 0.0)" /></td>
      </t>
      <td><t t-esc="'%.2f' % grand_total" /></td> <!-- 👈 Add this -->
    </tr>
  </tbody>
</table>

            <br></br>
        <t t-foreach="billing_data.items()" t-as="sales_data">
  <t t-set="sales_person" t-value="sales_data[0]" />
  <t t-set="sales_person_data" t-value="sales_data[1]" />

  <table class="table_custom" style="width: 100%; table-layout: fixed;">
    <thead style="background-color: #fef0ff;">
      <tr style="margin-top: 30px; color: #1a73e8; font-size:18px; background-color: #e8c1eb;">
        <td colspan="14">Sales Executive: <t t-esc="sales_person" /></td>
      </tr>
      <tr>
        <th class="wide-column">Product</th>
        <t t-foreach="month_names" t-as="month">
          <th><t t-esc="month[:3]" /></th>
        </t>
        <th>Total</th> <!-- 👈 new column -->
      </tr>
    </thead>
    <tbody>
      <t t-foreach="filtered_products_by_exec.get(sales_person, [])" t-as="product">
        <tr>
          <td class="wide-column"><t t-esc="product" /></td>
          <t t-set="product_total" t-value="0.0" />
          <t t-foreach="month_names" t-as="month">
            <t t-set="val" t-value="billing_data.get(sales_person, {}).get(month, {}).get(product, 0.0)" />
            <td>
              <t t-if="val">
                <t t-esc="'₹ {:.2f}'.format(val)" />
                <t t-set="product_total" t-value="product_total + val" />
              </t>
            </td>
          </t>
          <td><t t-esc="'₹ {:.2f}'.format(product_total)" /></td> <!-- 👈 product total -->
        </tr>
      </t>

      <!-- Totals Row -->
      <tr style="font-weight: bold; background-color: #fef0ff;">
        <td>Total</td>
        <t t-set="grand_total_per_sales_person" t-value="0.0" />
        <t t-foreach="month_names" t-as="month">
          <t t-set="total_val" t-value="monthly_totals.get(sales_person, {}).get(month, 0.0)" />
          <td>
            <t t-if="total_val">
              <t t-esc="'₹ {:.2f}'.format(total_val)" />
              <t t-set="grand_total_per_sales_person" t-value="grand_total_per_sales_person + total_val" />
            </t>
          </td>
        </t>
        <td><t t-esc="'₹ {:.2f}'.format(grand_total_per_sales_person)" /></td>
      </tr>
    </tbody>
  </table>
  <br />
</t>

      </div>
    </t>
  </template>
</odoo>
