<div class="d-flex justify-content-between align-items-center mb-4"><h1 class="h3 mb-0">Reports</h1></div>
<form class="card p-3 mb-3"><div class="row g-2 align-items-end"><div class="col-md-3"><label class="form-label">From</label><input type="date" name="from" value="<%= dates.from %>" class="form-control"></div><div class="col-md-3"><label class="form-label">To</label><input type="date" name="to" value="<%= dates.to %>" class="form-control"></div><div class="col-md-2"><button class="btn btn-primary w-100">View</button></div><div class="col-md-4 text-md-end"><a class="btn btn-outline-primary" href="<%= url(`/reports/download/invoices?from=${dates.from}&to=${dates.to}`) %>">Invoice CSV</a> <a class="btn btn-outline-primary" href="<%= url(`/reports/download/gst?from=${dates.from}&to=${dates.to}`) %>">GST CSV</a> <a class="btn btn-outline-primary" href="<%= url(`/reports/download/hsn?from=${dates.from}&to=${dates.to}`) %>">HSN CSV</a></div></div></form>
<div class="row g-3"><div class="col-lg-8"><div class="card p-3"><h2 class="h5">Invoice Report</h2><div class="table-responsive"><table class="table table-sm"><thead><tr><th>Invoice</th><th>Date</th><th>Customer</th><th>GSTIN</th><th class="text-end">Taxable</th><th class="text-end">CGST</th><th class="text-end">SGST</th><th class="text-end">IGST</th><th class="text-end">Total</th></tr></thead><tbody><% invoiceRows.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 class="text-end"><%= Number(row.taxable_amount).toFixed(2) %></td><td class="text-end"><%= Number(row.cgst_amount).toFixed(2) %></td><td class="text-end"><%= Number(row.sgst_amount).toFixed(2) %></td><td class="text-end"><%= Number(row.igst_amount).toFixed(2) %></td><td class="text-end"><%= Number(row.grand_total).toFixed(2) %></td></tr><% }) %></tbody></table></div></div></div><div class="col-lg-4"><div class="card p-3"><h2 class="h5">HSN Summary</h2><div class="table-responsive"><table class="table table-sm"><thead><tr><th>HSN</th><th class="text-end">Qty</th><th class="text-end">Taxable</th><th class="text-end">Tax</th></tr></thead><tbody><% hsnRows.forEach((row)=>{ %><tr><td><%= row.hsn_code %></td><td class="text-end"><%= Number(row.total_quantity).toFixed(3) %></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></tr><% }) %></tbody></table></div></div></div></div>
