<div class="d-flex justify-content-between align-items-center mb-4"><div><h1 class="h3 mb-1"><%= invoice.invoice_number %></h1><p class="text-muted mb-0"><%= invoice.customer_name %> | ₹<%= Number(invoice.grand_total).toFixed(2) %></p></div><div class="d-flex gap-2"><a href="<%= url(`/invoices/${invoice.id}/print`) %>" target="_blank" class="btn btn-primary">Print / PDF</a><% if(invoice.status !== 'cancelled'){ %><form method="post" action="<%= url(`/invoices/${invoice.id}/cancel`) %>" onsubmit="return confirm('Cancel this invoice?')"><button class="btn btn-outline-danger">Cancel</button></form><% } %></div></div>
<div class="card p-4"><div class="row"><div class="col-md-6"><h2 class="h5">Buyer</h2><p><strong><%= invoice.customer_name %></strong><br><%= invoice.customer_address || '' %><br>GSTIN: <%= invoice.customer_gstin || '-' %><br>State: <%= invoice.customer_state_name || '-' %>, Code: <%= invoice.customer_state_code || '-' %></p></div><div class="col-md-6"><h2 class="h5">Consignee</h2><p><strong><%= invoice.consignee_name || '-' %></strong><br><%= invoice.consignee_address || '' %><br>GSTIN: <%= invoice.consignee_gstin || '-' %><br>State: <%= invoice.consignee_state_name || '-' %>, Code: <%= invoice.consignee_state_code || '-' %></p></div></div><div class="table-responsive"><table class="table"><thead><tr><th>#</th><th>Item</th><th>Type</th><th>HSN</th><th class="text-end">Qty</th><th class="text-end">Rate</th><th class="text-end">Taxable</th><th class="text-end">Total</th></tr></thead><tbody><% items.forEach((item,i)=>{ %><tr><td><%= i+1 %></td><td><%= item.description %></td><td><%= item.paper_type %></td><td><%= item.hsn_code %></td><td class="text-end"><%= Number(item.quantity).toFixed(3) %></td><td class="text-end"><%= Number(item.rate).toFixed(2) %></td><td class="text-end"><%= Number(item.taxable_amount).toFixed(2) %></td><td class="text-end"><%= Number(item.total_amount).toFixed(2) %></td></tr><% }) %></tbody></table></div><div class="text-end"><div>Taxable: ₹<%= Number(invoice.taxable_amount).toFixed(2) %></div><div>CGST: ₹<%= Number(invoice.cgst_amount).toFixed(2) %></div><div>SGST: ₹<%= Number(invoice.sgst_amount).toFixed(2) %></div><div>IGST: ₹<%= Number(invoice.igst_amount).toFixed(2) %></div><h3 class="h4">Grand Total: ₹<%= Number(invoice.grand_total).toFixed(2) %></h3></div></div>
