Introduction
GST invoicing is mandatory for registered businesses in India. Manual invoice creation is tedious and error-prone — wrong GSTIN, wrong SAC code, wrong tax calculation. Automated GST invoice generation from Google Sheets eliminates these errors and saves hours per week.
This post builds a complete GST invoice automation system.
GST invoice requirements (India)
A valid GST invoice must include:
- Supplier details: Name, address, GSTIN
- Recipient details: Name, address, GSTIN (if registered)
- Invoice number: Unique, sequential
- Invoice date: Date of issue
- HSN/SAC code: For goods/services
- Description: Item description
- Quantity and unit: e.g., 1 month, 5 hours
- Taxable value: Price before tax
- GST rate: 5%, 12%, 18%, or 28%
- CGST + SGST (intra-state) or IGST (inter-state)
- Total amount: Including tax
- Place of supply: State name
Step 1: Set up Google Sheets
Create a Google Sheet with these tabs:
Tab 1: Invoices
| A: Invoice # | B: Date | C: Client | D: Client GSTIN | E: Description | F: SAC Code | G: Qty | H: Rate | I: Taxable Value | J: GST % | K: CGST | L: SGST | M: IGST | N: Total | O: Status |
|---|
Tab 2: Clients
| A: Name | B: GSTIN | C: Address | D: State | E: Email | F: Phone |
|---|
Tab 3: Settings
| A: Setting | B: Value |
|---|---|
| Business Name | Your Business Name |
| Business GSTIN | 24XXXXX1234X1ZX |
| Business Address | Your Address |
| Business State | Gujarat |
| Default GST Rate | 18% |
| Invoice Prefix | INV |
| Next Invoice Number | 1 |
Step 2: Python invoice generator
from fpdf import FPDF
import gspread
from google.oauth2.service_account import Credentials
from datetime import datetime
# Connect to Google Sheets
creds = Credentials.from_service_account_file("service_account.json",
scopes=["https://www.googleapis.com/auth/spreadsheets"])
gc = gspread.authorize(creds)
sheet = gc.open("GST Invoices")
def generate_gst_invoice(invoice_data):
"""Generate a GST-compliant invoice PDF."""
pdf = FPDF()
pdf.add_page()
pdf.set_font("Arial", "B", 14)
# Header
pdf.cell(0, 10, invoice_data["business_name"], ln=True, align="C")
pdf.set_font("Arial", "", 10)
pdf.cell(0, 6, f"GSTIN: {invoice_data['business_gstin']}", ln=True, align="C")
pdf.cell(0, 6, invoice_data["business_address"], ln=True, align="C")
pdf.ln(5)
# Invoice details
pdf.set_font("Arial", "B", 12)
pdf.cell(0, 8, "TAX INVOICE", ln=True, align="C")
pdf.ln(3)
pdf.set_font("Arial", "", 10)
pdf.cell(95, 6, f"Invoice No: {invoice_data['invoice_number']}")
pdf.cell(95, 6, f"Date: {invoice_data['date']}", ln=True)
pdf.cell(95, 6, f"Place of Supply: {invoice_data['place_of_supply']}")
pdf.cell(95, 6, f"Due Date: {invoice_data['due_date']}", ln=True)
pdf.ln(5)
# Client details
pdf.set_font("Arial", "B", 10)
pdf.cell(0, 6, "Bill To:", ln=True)
pdf.set_font("Arial", "", 10)
pdf.cell(0, 6, invoice_data["client_name"], ln=True)
pdf.cell(0, 6, invoice_data["client_address"], ln=True)
if invoice_data.get("client_gstin"):
pdf.cell(0, 6, f"GSTIN: {invoice_data['client_gstin']}", ln=True)
pdf.ln(5)
# Line items table
pdf.set_font("Arial", "B", 9)
pdf.cell(60, 7, "Description", border=1)
pdf.cell(25, 7, "SAC Code", border=1)
pdf.cell(15, 7, "Qty", border=1)
pdf.cell(30, 7, "Rate", border=1)
pdf.cell(30, 7, "Taxable", border=1)
pdf.cell(15, 7, "GST%", border=1)
pdf.cell(25, 7, "Total", border=1, ln=True)
pdf.set_font("Arial", "", 9)
for item in invoice_data["items"]:
pdf.cell(60, 7, item["description"][:30], border=1)
pdf.cell(25, 7, item["sac_code"], border=1)
pdf.cell(15, 7, str(item["qty"]), border=1)
pdf.cell(30, 7, f"Rs.{item['rate']:,}", border=1)
pdf.cell(30, 7, f"Rs.{item['taxable']:,}", border=1)
pdf.cell(15, 7, f"{item['gst_rate']}%", border=1)
pdf.cell(25, 7, f"Rs.{item['total']:,}", border=1, ln=True)
pdf.ln(5)
# Tax summary
pdf.set_font("Arial", "B", 10)
pdf.cell(130, 6, "Taxable Value:")
pdf.cell(60, 6, f"Rs. {invoice_data['taxable_total']:,}", ln=True)
if invoice_data["is_intra_state"]:
pdf.cell(130, 6, "CGST:")
pdf.cell(60, 6, f"Rs. {invoice_data['cgst']:,}", ln=True)
pdf.cell(130, 6, "SGST:")
pdf.cell(60, 6, f"Rs. {invoice_data['sgst']:,}", ln=True)
else:
pdf.cell(130, 6, "IGST:")
pdf.cell(60, 6, f"Rs. {invoice_data['igst']:,}", ln=True)
pdf.cell(130, 6, "Total (incl. GST):")
pdf.cell(60, 6, f"Rs. {invoice_data['grand_total']:,}", ln=True)
pdf.ln(10)
pdf.set_font("Arial", "I", 9)
pdf.cell(0, 6, "This is a computer-generated invoice.", ln=True)
pdf.cell(0, 6, "Thank you for your business!", ln=True)
filename = f"GST_Invoice_{invoice_data['invoice_number']}.pdf"
pdf.output(filename)
return filename
Step 3: Calculate GST
def calculate_gst(items, client_state, business_state):
"""Calculate CGST+SGST (intra-state) or IGST (inter-state)."""
taxable_total = sum(item["qty"] * item["rate"] for item in items)
is_intra = client_state == business_state
# Calculate per-item GST
for item in items:
item["taxable"] = item["qty"] * item["rate"]
item["gst_amount"] = item["taxable"] * item["gst_rate"] / 100
item["total"] = item["taxable"] + item["gst_amount"]
cgst = sgst = igst = 0
if is_intra:
cgst = taxable_total * 0.09 # 9% CGST (for 18% GST)
sgst = taxable_total * 0.09 # 9% SGST
else:
igst = taxable_total * 0.18 # 18% IGST
return {
"taxable_total": taxable_total,
"cgst": round(cgst, 2),
"sgst": round(sgst, 2),
"igst": round(igst, 2),
"grand_total": round(taxable_total + cgst + sgst + igst, 2),
"is_intra_state": is_intra,
}
Step 4: Automate from Google Sheets
def generate_from_sheet():
"""Generate invoices from Google Sheets data."""
sheet = gc.open("GST Invoices").sheet1
data = sheet.get_all_records()
invoices_to_generate = [row for row in data if row["Status"] == "Pending"]
for row in invoices_to_generate:
# Get client details
clients_sheet = gc.open("GST Invoices").worksheet("Clients")
client = clients_sheet.find(row["Client"]).row_values
# Calculate GST
items = [{"description": row["Description"], "sac_code": row["SAC Code"],
"qty": row["Qty"], "rate": row["Rate"], "gst_rate": row["GST %"]}]
gst = calculate_gst(items, client["State"], "Gujarat")
# Generate invoice
invoice_data = {
"business_name": "Your Business Name",
"business_gstin": "24XXXXX1234X1ZX",
"business_address": "Your Address",
"client_name": row["Client"],
"client_address": client["Address"],
"client_gstin": client["GSTIN"],
"invoice_number": row["Invoice #"],
"date": row["Date"],
"due_date": row["Due Date"],
"place_of_supply": client["State"],
"items": items,
**gst,
}
filename = generate_gst_invoice(invoice_data)
# Update status
sheet.update_cell(row["_row"], 15, "Generated") # Status column
print(f"Generated: {filename}")
generate_from_sheet()
Step 5: Automate with cron
# Generate invoices daily at 9 AM
0 9 * * * cd /path/to/project && python generate_gst_invoices.py
Or use GitHub Actions:
name: Generate GST Invoices
on:
schedule:
- cron: '0 9 * * *'
jobs:
generate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: pip install fpdf gspread google-auth
- run: python generate_gst_invoices.py
SAC codes for common services
| Service | SAC Code | GST Rate |
|---|---|---|
| Web development | 998314 | 18% |
| Graphic design | 998391 | 18% |
| Content writing | 998392 | 18% |
| Digital marketing | 998361 | 18% |
| Consulting | 998312 | 18% |
| Software development | 998315 | 18% |
| Video editing | 998393 | 18% |
| Photography | 998394 | 18% |
Common mistakes
- Wrong SAC code — use the correct code for your service. Wrong code = wrong tax rate.
- Wrong GST rate — most services are 18%. Check if yours qualifies for a lower rate.
- Intra-state vs inter-state — CGST+SGST for same state, IGST for different states.
- Missing GSTIN — if your client is GST-registered, you must include their GSTIN.
- No invoice numbering — invoices must be sequential. Use a prefix + number (INV-001, INV-002).
- Not keeping records — keep all invoices for 6 years (GST requirement).
Key Concepts
- GST = Goods and Services Tax (India)
- SAC code = Service Accounting Code (for services)
- HSN code = Harmonized System of Nomenclature (for goods)
- CGST = Central GST (intra-state)
- SGST = State GST (intra-state)
- IGST = Integrated GST (inter-state)
- Invoice number = unique, sequential identifier
What to Try Next
- Automate invoices and payment reminders for the full flow
- Create a freelance invoice template for manual invoicing
- Track freelance income and expenses for tax filing
- Build an invoice dashboard in Streamlit
FAQ
Do I need GST registration as a freelancer?
Only if your annual turnover exceeds ₹20 lakhs. Below that, you don’t need GST registration. But if you work with GST-registered clients, they may prefer GST invoices (you can issue them without registration using a “Bill of Supply”).
What’s the difference between GST invoice and regular invoice?
A GST invoice includes GSTIN, SAC/HSN code, tax breakdown (CGST/SGST/IGST), and place of supply. A regular invoice doesn’t have these. If you’re GST-registered, you must issue GST invoices.
Can I generate invoices in bulk?
Yes — the script above processes all pending rows in your Google Sheet. Add multiple rows and run the script once to generate all invoices. See Python Script to Create PDF Invoices in Bulk.
How do I handle reverse charge mechanism (RCM)?
If you’re providing services to a GST-registered client and the service falls under RCM, the client pays the GST (not you). Mark the invoice as “Reverse Charge Applicable” and don’t charge GST. Consult a CA for RCM applicability. See Track Freelance Income and Expenses.