Back to catalog

GST Invoice

Generate [client] monthly invoice PDFs from HTML template.

Category 💼 Consulting
Version v1.0
invoicepdfgtscommercial

GTS Invoice Generation

Generate [client] → [client] monthly invoices as PDFs.

File Layout

All files in /opt/data/wiki/wealth/consulting/invoices/:

File Purpose
invoice-template.html HTML/A4 template with {{INVOICE_NO}} and {{DATE}} placeholders
generate-invoice.py Playwright-based HTML→PDF converter
2026-27-gts-gst.xlsx Invoice tracker (sheet: Invoices)
Output: {date}-[client].pdf Generated invoice PDF

Runtime

  • Python packages (openpyxl, playwright): installed via uv, NOT system python.
  • Always use: uv run python3 ...
  • Chromium browser is pre-cached at ~/.cache/ms-playwright/chromium-1234/
  • Do NOT pip install or uv pip install — packages are already present.

Workflow

1. Read last row from xlsx

uv run --with openpyxl python3 -c "
import openpyxl
wb = openpyxl.load_workbook('2026-27-gts-gst.xlsx', data_only=True)
ws = wb['Invoices']
last = list(ws.iter_rows(min_row=2, values_only=True))[-1]
print(last)
"

Key columns: Date(A), Invoice no(B), Party(C), GSTIN(D), Taxable Value(E), IGST(F), Place of Supply(K), SAC(L).

2. Generate invoice PDF

cd /opt/data/wiki/wealth/consulting/invoices
uv run python3 generate-invoice.py <invoice_no> <date>
  • invoice_no: next in sequence (e.g. gts-2627-006)
  • date: YYYY-MM-DD format
  • Output lands in the same directory as {date}-[client].pdf

3. Verify

Visually check the generated PDF with vision_analyze.

Template Values

The HTML template has hardcoded amounts (₹1,25,000 taxable, 18% IGST, ₹1,47,500 total). If the xlsx last row differs, update the template HTML before running generate-invoice.py — the script only replaces {{INVOICE_NO}} and {{DATE}}.

Invoice Numbering

Pattern: gts-YY-NNN (e.g. gts-2627-006). Increment from the last row in the xlsx.

Pitfalls

  • Never use system python3 for openpyxl/playwright — use uv run python3.
  • The generate-invoice.py script does NOT read the xlsx. You must pass the correct invoice number and date as CLI args.
  • Template amounts are static HTML — if the fee structure changes, edit invoice-template.html directly.