<div class="d-flex justify-content-between align-items-center mb-4"><h1 class="h3 mb-0">Billing History</h1><a class="btn btn-primary" href="<%= url('/invoices/create') %>">Create Bill</a></div>
<form class="card p-3 mb-3"><div class="row g-2"><div class="col-md-3"><input type="date" name="from" value="<%= filters.from || '' %>" class="form-control"></div><div class="col-md-3"><input type="date" name="to" value="<%= filters.to || '' %>" class="form-control"></div><div class="col-md-3"><input name="q" value="<%= filters.q || '' %>" class="form-control" placeholder="Invoice, customer, GSTIN"></div><div class="col-md-2"><select name="status" class="form-select"><option value="">All Status</option><option <%= filters.status==='active'?'selected':'' %>>active</option><option <%= filters.status==='cancelled'?'selected':'' %>>cancelled</option></select></div><div class="col-md-1"><button class="btn btn-primary w-100">Go</button></div></div></form>
<div class="card p-3"><div class="table-responsive"><table class="table align-middle"><thead><tr><th>Invoice</th><th>Date</th><th>Customer</th><th>GSTIN</th><th>Status</th><th class="text-end">Taxable</th><th class="text-end">GST</th><th class="text-end">Total</th><th></th></tr></thead><tbody><% invoices.forEach((row)=>{ %><tr><td><%= row.invoice_number %></td><td><%= formatDate(row.invoice_date) %></td><td><%= row.customer_name %></td><td><%= row.customer_gstin || '-' %></td><td><span class="badge badge-soft"><%= row.status %></span></td><td class="text-end">₹<%= Number(row.taxable_amount).toFixed(2) %></td><td class="text-end">₹<%= Number(row.cgst_amount + row.sgst_amount + row.igst_amount).toFixed(2) %></td><td class="text-end">₹<%= Number(row.grand_total).toFixed(2) %></td><td class="text-end"><a class="btn btn-sm btn-outline-primary" href="<%= url(`/invoices/${row.id}`) %>">View</a></td></tr><% }) %></tbody></table></div></div>
