<%- include('../partials/header') %>
<div class="flex ic jb mb16"><div><h2 style="font-size:20px;font-weight:700">GSTR-2 / Purchase Register</h2><p class="muted sm">Inward 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>Bill No.</th><th>Vendor Invoice</th><th>Date</th><th>Vendor</th><th>Vendor GSTIN</th><th class="tr">Invoice Value</th><th class="tr">Taxable</th><th class="tr">CGST</th><th class="tr">SGST</th></tr></thead>
<tbody><%bills.forEach(b=>{%><tr><td class="mono sm"><%=b.billNo%></td><td class="mono xs muted"><%=b.vendorInvoiceNo||'—'%></td><td class="muted sm"><%=moment(b.billDate).format('DD/MM/YYYY')%></td><td class="fw6"><%=b.vendor?.name||'—'%></td><td class="mono sm"><%=b.vendor?.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></tr><%})%></tbody>
<tfoot><tr style="font-weight:700;background:var(--bg3)"><td colspan="5" style="padding:10px 14px">TOTAL (<%=bills.length%> bills)</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></tr></tfoot>
</table></div>
<%- include('../partials/footer') %>
