<%- include('partials/head',{title:invoice.invoice_number,subtitle:invoice.brand_name+' · '+(invoice.customer_name||'Customer')}) %><div class="invoicehero"><div><span class="status <%=invoice.status%>"><%=invoice.status%></span><h2><%=money(invoice.total,invoice.currency)%></h2><p>Created <%=String(invoice.created_at).slice(0,10)%> · Due <%=invoice.due_date||'on receipt'%></p></div><div class="actions"><a class="button" href="/invoices/<%=invoice.id%>/pdf">Download PDF</a><form method="post" action="/invoices/<%=invoice.id%>/email"><button>Email client</button></form></div></div><div class="twocol"><div class="panel"><h2>Invoice items</h2><table><thead><tr><th>Description</th><th>Qty</th><th>Unit</th><th>Total</th></tr></thead><tbody><% items.forEach(x=>{ %><tr><td><%=x.description%></td><td><%=x.quantity%></td><td><%=money(x.unit_price,invoice.currency)%></td><td><%=money(x.line_total,invoice.currency)%></td></tr><% })%></tbody></table><div class="totals"><span>Subtotal <b><%=money(invoice.subtotal,invoice.currency)%></b></span><span>Tax <b><%=money(invoice.tax,invoice.currency)%></b></span><span>Discount <b>- <%=money(invoice.discount,invoice.currency)%></b></span><span class="grand">Total <b><%=money(invoice.total,invoice.currency)%></b></span></div></div><div><div class="panel"><h2>Customer</h2><p><b><%=invoice.customer_name||'No customer selected'%></b></p><p><%=invoice.customer_company||''%></p><p><%=invoice.customer_email||''%></p><p><%=invoice.customer_phone||''%></p><p><%=invoice.customer_address||''%></p></div><% if(invoice.payment_method==='card'){ %><div class="panel"><h2>Online payment</h2><% if(invoice.payment_url){ %><a class="primary full" target="_blank" href="<%=invoice.payment_url%>">Open payment page</a><input value="<%=invoice.payment_url%>" readonly onclick="this.select()"><p class="muted">Provider: <%=invoice.provider%></p><% } else if(merchants.length){ %><form method="post" action="/invoices/<%=invoice.id%>/payment-link" class="stack"><label>Merchant account<select name="merchant_account_id"><% merchants.forEach(m=>{ %><option value="<%=m.id%>"><%=m.provider.toUpperCase()%> — <%=m.label%> (<%=m.environment%>)</option><% })%></select></label><button class="primary">Generate payment link</button></form><% } else { %><p>No enabled merchant account is configured for this brand.</p><% } %></div><% } else if(invoice.status!=='paid'){ %><div class="panel"><h2>Bank transfer</h2><p><%=invoice.bank_account_name||''%></p><p><%=invoice.bank_name||''%> · <%=invoice.bank_sort_code||''%> · <%=invoice.bank_account_number||''%></p><form method="post" action="/invoices/<%=invoice.id%>/mark-paid" class="stack"><input name="reference" placeholder="Bank reference"><input name="note" placeholder="Internal note"><button class="primary">Mark payment received</button></form></div><% } %></div></div><%- include('partials/foot') %>
