<%- include('../partials/header') %>
<div class="flex ic jb mb16"><div><h2 style="font-size:20px;font-weight:700">GSTR-1 Report</h2><p class="muted sm">Outward Supplies · <%=from%> to <%=to%></p></div><div class="flex g8"><a href="/reports" class="btn btn-outline btn-sm"><i class="fa fa-arrow-left"></i></a><button onclick="window.print()" class="btn btn-outline btn-sm no-print"><i class="fa fa-print"></i> Print</button></div></div>
<form method="GET" class="search-bar mb16">
  <div class="dt-range"><label class="muted sm">From</label><input type="date" name="from" value="<%=from%>" style="width:150px"><label class="muted sm">To</label><input type="date" name="to" value="<%=to%>" style="width:150px"></div>
  <button type="submit" class="btn btn-outline btn-sm"><i class="fa fa-filter"></i> Apply</button>
</form>
<div class="tbl-wrap">
  <table><thead><tr><th>Invoice No.</th><th>Date</th><th>Buyer Name</th><th>Buyer GSTIN</th><th class="tr">Invoice Value</th><th class="tr">Taxable</th><th class="tr">CGST</th><th class="tr">SGST</th><th class="tr">IGST</th></tr></thead>
  <tbody><%bills.forEach(b=>{%><tr>
    <td class="mono sm"><%=b.invoiceNo%></td>
    <td class="muted sm"><%=moment(b.invoiceDate).format('DD/MM/YYYY')%></td>
    <td class="fw6"><%=b.client?.name||b.billedTo?.name||'—'%></td>
    <td class="mono sm"><%=b.client?.gstin||'Unregistered'%></td>
    <td class="mono tr">₹<%=(b.netPayable||0).toFixed(2)%></td>
    <td class="mono tr">₹<%=(b.taxableAmount||0).toFixed(2)%></td>
    <td class="mono tr">₹<%=(b.cgstAmount||0).toFixed(2)%></td>
    <td class="mono tr">₹<%=(b.sgstAmount||0).toFixed(2)%></td>
    <td class="mono tr">₹<%=(b.igstAmount||0).toFixed(2)%></td>
  </tr><%})%></tbody>
  <tfoot><tr style="font-weight:700;background:var(--bg3)">
    <td colspan="4" style="padding:10px 14px">TOTAL (<%=bills.length%> invoices)</td>
    <td class="mono tr cacc" style="padding:10px 14px">₹<%=bills.reduce((s,b)=>s+(b.netPayable||0),0).toFixed(2)%></td>
    <td class="mono tr" style="padding:10px 14px">₹<%=bills.reduce((s,b)=>s+(b.taxableAmount||0),0).toFixed(2)%></td>
    <td class="mono tr" style="padding:10px 14px">₹<%=bills.reduce((s,b)=>s+(b.cgstAmount||0),0).toFixed(2)%></td>
    <td class="mono tr" style="padding:10px 14px">₹<%=bills.reduce((s,b)=>s+(b.sgstAmount||0),0).toFixed(2)%></td>
    <td class="mono tr" style="padding:10px 14px">₹<%=bills.reduce((s,b)=>s+(b.igstAmount||0),0).toFixed(2)%></td>
  </tr></tfoot>
  </table>
</div>
<%- include('../partials/footer') %>
