How I Built a Free Invoice Generator in Python (Replaces Freshbooks $15/mo)
I was paying $15/month for Freshbooks to generate PDF invoices. Then I spent a weekend writing a Python script that does the same thing for free. Here's how it works.
The Problem with SaaS Invoice Tools
SaaS tools like Freshbooks, FreshDesk, and Invoice Ninja are great when you're just starting out. But once you're generating 5-10 invoices a month, you're paying $15-30/month just for PDF generation and email delivery. That's $180-360/year for what is fundamentally a templating + email problem.
The Python Solution
Here's the core invoice generator:
from reportlab.lib.pagesizes import A4
from reportlab.platypus import SimpleDocTemplate, Table, Paragraph
from reportlab.lib.styles import getSampleStyleSheet
from email.mime.multipart import MIMEMultipart
from email.mime.base import MIMEBase
from email import encoders
import smtplib
import os
def generate_invoice(client_name, items, rate=75):
"""Generate a professional PDF invoice and email it."""
# Create PDF
filename = f"invoice_{client_name.replace(' ', '_')}_{int(time.time())}.pdf"
doc = SimpleDocTemplate(filename, pagesize=A4)
# Build table data
data = [["Description", "Hours", "Rate", "Amount"]]
total = 0
for item in items:
amount = item["hours"] * rate
total += amount
data.append([
item["description"],
str(item["hours"]),
f"${rate}/hr",
f"${amount:.2f}"
])
data.append(["", "", "TOTAL", f"${total:.2f}"])
# Create styled table
table = Table(data)
story = [table]
doc.build(story)
return filename, total
# Usage
invoice_file, total = generate_invoice(
client_name="Acme Corp",
items=[
{"description": "API integration", "hours": 8},
{"description": "Testing & deployment", "hours": 2}
],
rate=75
)
print(f"Invoice generated: {invoice_file} | Total: ${total}")
Adding Email Delivery
The real magic is sending the invoice automatically:
def send_invoice_email(to_email, invoice_file, client_name, total):
"""Send invoice PDF via email."""
msg = MIMEMultipart()
msg['From'] = "your@email.com"
msg['To'] = to_email
msg['Subject'] = f"Invoice - ${total:.2f}"
# Attach PDF
with open(invoice_file, 'rb') as f:
part = MIMEBase('application', 'octet-stream')
part.set_payload(f.read())
encoders.encode_base64(part)
part.add_header('Content-Disposition', f'attachment; filename={invoice_file}')
msg.attach(part)
# Send via SMTP
with smtplib.SMTP_SSL('smtp.gmail.com', 465) as server:
server.login("your@email.com", "your_app_password")
server.send_message(msg)
print(f"Invoice sent to {client_name} at {to_email}")
The Complete Business Toolkit
This invoice generator is part of a larger Python toolkit I built to replace all my SaaS subscriptions:
- Invoice Generator → replaces Freshbooks ($15/mo → $0)
- Email Campaign Tool → replaces Mailchimp ($20/mo → $0)
- Time Tracker → replaces Toggl ($10/mo → $0)
- Proposal Generator → replaces Proposify ($49/mo → $0)
- Revenue Dashboard → replaces expensive analytics tools
Total annual savings: ~$400/yr
I packaged all 5 scripts into a toolkit: Python Business Automation Toolkit — $9 one-time, includes full source code + documentation.
Why Build It Yourself?
- No subscription fees — one-time cost
- Full customization — change templates, add fields, modify logic
- Data ownership — your invoices stay on your machine
- No vendor lock-in — migrate or modify anytime
Performance
In 6 months of daily use:
- Generated 80+ invoices (would cost $90 on Freshbooks)
- Saved ~$90 in subscription fees
- Zero downtime (runs locally)
- Full audit trail in local SQLite DB
The 200 lines of Python paid for itself in month 1.
Want the complete toolkit (all 5 scripts)? Get it here: https://lukassbrad.gumroad.com/l/ugeka — $9 one-time.
Top comments (0)