← Back to all products

Invoice Generator

$19

PDF and HTML invoice generator with customizable templates, line items, and tax calculations.

📁 9 files
JSONMarkdownPython

📄 Product Preview

Try the interactive reader and demo tools below, or get the full product with all content unlocked.

📖 Interactive Reader (Free Preview) ⚙ Try Demo Tools 📦 Download Free Sample

📁 File Structure 9 files

invoice-generator/ ├── LICENSE ├── README.md ├── examples/ │ └── invoice_data.json ├── free-sample.zip ├── guide/ │ ├── 01_features.md │ ├── 02_cli-reference.md │ └── 03_license.md ├── index.html └── src/ └── invoice_generator.py

📖 Documentation Preview README excerpt

Invoice Generator

Part of the Payment Stack by CodeVault

Generate professional, print-ready HTML invoices from a simple JSON config. Supports line items, taxes, discounts, payment terms, and custom branding.

Features

  • Beautiful, self-contained HTML invoices (no external dependencies)
  • Print-optimized CSS with proper page break handling
  • Line items with quantity, unit pricing, and per-item tax rates
  • Per-item discount percentages
  • Multi-currency support (USD, EUR, GBP, JPY, CAD, AUD)
  • Customizable brand color and text logo
  • Payment methods section (bank transfer, PayPal, etc.)
  • Invoice status badges (draft, sent, paid, overdue, canceled)
  • JSON report output for programmatic use
  • Config validation mode for catching errors before generation
  • Python stdlib only — zero dependencies

Quick Start


# Generate a demo invoice to see it in action
python src/invoice_generator.py --action demo --output demo_invoice.html

# Generate from your own config
python src/invoice_generator.py --config examples/invoice_data.json --output invoice.html

# Validate config without generating
python src/invoice_generator.py --config examples/invoice_data.json --action validate

# Output as JSON report
python src/invoice_generator.py --config examples/invoice_data.json --format json

CLI Reference

FlagDescription
--action, -aAction: generate (default), demo, validate
--config, -cPath to invoice JSON config file
--output, -oOutput file path (default: stdout)
--format, -fOutput format: html (default) or json
--verbose, -vEnable debug logging

Configuration Reference

See examples/invoice_data.json for a complete example. Key fields:

FieldTypeDescription
invoice_numberstringInvoice ID (auto-generated if omitted)
issue_datestringIssue date in YYYY-MM-DD format
due_datestringDue date (defaults to Net 30)
currencystringISO 4217 code: USD, EUR, GBP, JPY, CAD, AUD
senderobjectYour business address and contact info
recipientobjectClient address and contact info
line_itemsarrayItems with description, quantity, unit_price, tax_rate, discount_percent
payment_termsstringTerms text (e.g., "Net 30")

... continues with setup instructions, usage examples, and more.

📄 Code Sample .py preview

src/invoice_generator.py #!/usr/bin/env python3 """ Invoice Generator — Payment Stack by DataNest Generate professional HTML invoices from JSON data: line items with quantity and unit pricing, tax calculation, payment terms, due dates, branding, and notes. Outputs self-contained HTML files ready for printing or PDF conversion. Why this exists: Every SaaS and freelancer needs invoices. Building an invoice generator from scratch means dealing with currency formatting, tax math, HTML/CSS layout for printing, and edge cases like discounts and multi-line notes. This tool handles all of that from a simple JSON config, producing clean HTML invoices you can send directly to clients. Usage: python invoice_generator.py --config invoice_data.json python invoice_generator.py --config invoice_data.json --output invoice_001.html python invoice_generator.py --config invoice_data.json --format json python invoice_generator.py --action demo License: MIT """ from __future__ import annotations import argparse import json import logging import sys import html as html_module import uuid from dataclasses import dataclass, field, asdict from datetime import datetime, date, timedelta, timezone from pathlib import Path from typing import Any, Optional # --------------------------------------------------------------------------- # Constants # --------------------------------------------------------------------------- # Default payment terms in days DEFAULT_NET_DAYS = 30 # Currency formatting rules CURRENCY_CONFIG: dict[str, dict[str, Any]] = { "USD": {"symbol": "$", "decimal_places": 2, "thousands_sep": ",", "decimal_sep": "."}, "EUR": {"symbol": "€", "decimal_places": 2, "thousands_sep": ".", "decimal_sep": ","}, "GBP": {"symbol": "£", "decimal_places": 2, "thousands_sep": ",", "decimal_sep": "."}, "JPY": {"symbol": "¥", "decimal_places": 0, "thousands_sep": ",", "decimal_sep": "."}, # ... 610 more lines ...
Buy Now — $19 Back to Products