This is a personal invoice generation system built for my own use. It is shared publicly for reference and educational purposes only. This is not intended to be a general-purpose tool for others.
A Python-based invoice generation system that produces PDF invoices from YAML data files. Features include:
- Composable Billing Engine: Separates mathematical logic from business configurations
- Multi-Jurisdiction Support: Configurable for different tax systems (demonstrated with GST)
- Smart Numbering: Auto-increments sequence numbers with support for one-off projects
- Export Handling: Letter of Undertaking (LUT) support for zero-rated exports
- Accounting Integration: Optional hledger journal generation
The system follows a three-tier configuration model:
- Universal Formulas (
config/billing.yaml): Abstract math primitives (flat_rate,unit_rate) - Invoice Presets (
config/billing.yaml): Business configurations binding formulas to presentation - Engagement Terms (
data/contracts/*.yaml,data/invoices/*.yaml): Client-specific values
- Data Assembly (
ContextBuilder): Merges YAMLs, resolves profiles, calculates IDs - Business Logic (
FinancialsService): Applies tax rules and currency logic - Presentation (
ViewModelService): Maps to Jinja2 template context - Output (
InvoiceController): Generates PDFs and sidecar YAMLs
- Python 3.10+
- uv (recommended) or pip
# Clone the repository
git clone https://github.com/YOUR_USERNAME/invoice-system.git
cd invoice-system
# Install dependencies
uv pip install -r requirements.txt
# or: pip install -r requirements.txtThe repository includes synthetic sample data for demonstration:
# Generate a sample invoice
uv run generate_invoice.py data/invoices/2024-05_sample_retainer_01.yaml
# Run all tests
uv run python tests/test_suite.py- Update profiles: Edit
data/profiles/with your business and client information - Create contracts: Add contract YAMLs to
data/contracts/ - Generate invoices: Create invoice YAMLs referencing contract IDs
See data/yaml_templates/ for examples.
- AGENTS.md - Detailed architecture and development guidelines
- docs/BILLING_ARCHITECTURE.md - Billing system schema
- Designed for my specific workflow and requirements
- May contain assumptions specific to my business context
- Not actively maintained as a general-purpose tool
- Sample data included is entirely synthetic
If you want to use this:
- Review all code to understand assumptions
- Replace all sample data in
data/with your own - Update configuration in
config/for your jurisdiction - Test thoroughly before using for actual business
The majority of this code was written by AI coding assistants, primarily:
- Gemini 3 Pro / Flash (Google)
- GLM 4.7 (Zhipu AI)
- Kimi K2.5 (Moonshot AI)
- Claude Sonnet 4.5 (Anthropic)
Through extensive prompting, architectural guidance, and iterative refinement by me (the human), these AI systems generated the code, tests, and documentation you see here. While the code is functional and well-structured, it reflects AI-generated patterns and may contain assumptions or approaches that differ from manually-written code.
Implications:
- Code may follow AI-preferred patterns over human conventions
- Error handling and edge cases may reflect training data biases
- Architecture decisions were guided by AI suggestions within human constraints
- Documentation was AI-generated based on human specifications
Use this codebase with the understanding that it represents an AI-human collaboration, not purely human authorship.
[Add your license here - e.g., MIT, Apache-2.0, or proprietary]
- Python 3.10+ with type hints
- Pydantic for data validation
- Jinja2 for templating
- WeasyPrint for PDF generation
- PyYAML for data files
.
├── app/ # Application code
│ ├── modules/ # Domain models and pure logic
│ ├── services/ # Application services
│ └── templates/ # HTML/CSS for PDF
├── config/ # Configuration files
├── data/ # Data files (sample data included)
│ ├── profiles/ # Business, client, bank profiles
│ ├── contracts/ # Contract terms
│ └── invoices/ # Invoice data
├── docs/ # Documentation
├── tests/ # Test suite
└── generate_invoice.py # Main entry point
This repository is designed to work with jj (Jujutsu VCS) but is compatible with standard git.
This software is provided as-is for educational and reference purposes. The author makes no warranties about its fitness for any particular purpose. Use at your own risk.