{% extends "ui/templates/base/layout.html" %}
{% block content %}<div class="space-y-6"><div class="flex items-center justify-between"><div><h1 class="text-2xl font-semibold">Platform Invoice {{ invoice.invoice_no }}</h1><p class="text-sm text-slate-500">{{ invoice.account.display_name if invoice.account else invoice.account_id }} • {{ invoice.status }}</p></div><div class="flex gap-2">{% if can_post and invoice.status == 'DRAFT' %}<form method="post" action="/platform-billing/invoices/{{ invoice.id }}/post"><input type="hidden" name="csrf_token" value="{{ csrf_token }}" /><button class="rounded-xl bg-slate-900 px-4 py-2 text-sm font-semibold text-white">Post Invoice</button></form>{% endif %}</div></div><div class="rounded-2xl border bg-white p-5 shadow-soft"><div class="grid gap-3 text-sm md:grid-cols-4"><div><span class="text-slate-500">Invoice Date</span><div class="font-medium">{{ invoice.invoice_date }}</div></div><div><span class="text-slate-500">Due Date</span><div class="font-medium">{{ invoice.due_date or '-' }}</div></div><div><span class="text-slate-500">Tax Type</span><div class="font-medium">{{ invoice.tax_type }}</div></div><div><span class="text-slate-500">Total</span><div class="font-semibold">₹ {{ '%.2f'|format(invoice.total_amount or 0) }}</div></div></div></div><div class="overflow-hidden rounded-2xl border bg-white shadow-soft"><table class="min-w-full text-sm"><thead class="bg-slate-50 text-left"><tr><th class="px-4 py-3">Description</th><th class="px-4 py-3">Charge</th><th class="px-4 py-3 text-right">Taxable</th><th class="px-4 py-3 text-right">Tax</th><th class="px-4 py-3 text-right">Total</th></tr></thead><tbody class="divide-y">{% for line in invoice.lines %}<tr><td class="px-4 py-3">{{ line.description }}</td><td class="px-4 py-3">{{ line.charge_type }}</td><td class="px-4 py-3 text-right">₹ {{ '%.2f'|format(line.taxable_amount or 0) }}</td><td class="px-4 py-3 text-right">₹ {{ '%.2f'|format((line.cgst_amount or 0) + (line.sgst_amount or 0) + (line.igst_amount or 0)) }}</td><td class="px-4 py-3 text-right">₹ {{ '%.2f'|format(line.line_total or 0) }}</td></tr>{% endfor %}</tbody></table></div>{% if can_record_payment %}<form method="post" action="/platform-billing/invoices/{{ invoice.id }}/payments" class="grid gap-3 rounded-2xl border bg-white p-5 shadow-soft md:grid-cols-4"><input type="hidden" name="csrf_token" value="{{ csrf_token }}" /><input name="amount" placeholder="Amount" required class="rounded-xl border px-3 py-2 text-sm" /><input name="mode" value="Bank" class="rounded-xl border px-3 py-2 text-sm" /><input name="reference_no" placeholder="Reference No" class="rounded-xl border px-3 py-2 text-sm" /><button class="rounded-xl bg-brand-600 px-4 py-2 text-sm font-semibold text-white">Record Payment</button></form>{% endif %}</div>{% endblock %}
