Freelancer Time Tracking & Invoice Generator Library
Project description
invoice-engine-nci
A Python library for freelancer time tracking and invoice generation. Built with only the Python standard library -- no external dependencies required.
Installation
pip install invoice-engine-nci
Quick Start
from invoice_engine import TimeCalculator, InvoiceGenerator, InvoiceValidator, ReportFormatter
# Define time logs
time_logs = [
{
"startTime": "2026-03-01T09:00:00",
"endTime": "2026-03-01T11:30:00",
"description": "Backend API development",
"project": "WebApp",
"billable": True,
},
{
"startTime": "2026-03-01T13:00:00",
"endTime": "2026-03-01T15:00:00",
"description": "Code review",
"project": "WebApp",
"billable": False,
},
]
# Calculate hours
calc = TimeCalculator()
total = calc.calculate_total_hours(time_logs)
billable = calc.calculate_billable_hours(time_logs)
cost = calc.calculate_project_cost(billable, 75.00)
print(f"Total: {calc.format_duration(total)}")
print(f"Billable: {billable}h")
print(f"Cost: ${cost}")
# Generate an invoice
client = {"name": "Jane Doe", "email": "jane@example.com", "company": "Acme Ltd"}
project = {"name": "WebApp", "hourlyRate": 75}
gen = InvoiceGenerator()
invoice = gen.generate_invoice(client, project, time_logs, 75, tax_rate=10)
# Print formatted invoice
print(gen.format_invoice_text(invoice))
# Export time logs to CSV
fmt = ReportFormatter()
print(fmt.to_csv(time_logs))
Modules
TimeCalculator
calculate_duration(start_time, end_time)-- Duration in hours between two ISO datetime strings.calculate_total_hours(time_logs)-- Sum of all durations.calculate_billable_hours(time_logs, billable_only=True)-- Sum of billable durations.calculate_project_cost(hours, hourly_rate)-- Total cost.format_duration(hours)-- Format as "Xh Ym".get_daily_breakdown(time_logs)-- Dict of date to total hours.
InvoiceGenerator
generate_invoice(client, project, time_logs, hourly_rate, tax_rate=0)-- Full invoice dict.generate_invoice_number()-- Unique invoice number.calculate_line_items(time_logs, hourly_rate)-- Line item list.apply_discount(invoice, discount_pct)-- Apply a percentage discount.format_invoice_text(invoice)-- Plain text invoice.format_invoice_html(invoice)-- HTML invoice.
InvoiceValidator
validate_client(data)-- Validate client data.validate_project(data)-- Validate project data.validate_time_log(data)-- Validate time log entry.sanitize_input(text)-- Strip HTML tags.validate_hourly_rate(rate)-- Check rate is positive.
ReportFormatter
format_project_summary(project, time_logs)-- Text project summary.format_weekly_report(time_logs, hourly_rate)-- Weekly breakdown report.to_csv(time_logs)-- CSV export.format_client_statement(client, invoices)-- Client statement.
Testing
python -m pytest tests/
Author
Goutham Uppu
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
invoice_engine_nci-1.0.0.tar.gz
(10.3 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file invoice_engine_nci-1.0.0.tar.gz.
File metadata
- Download URL: invoice_engine_nci-1.0.0.tar.gz
- Upload date:
- Size: 10.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
18b03ff7716e9e8440bd71d5e693a8f684a0c6003b3ab1519937978f0bdd9d7c
|
|
| MD5 |
4574732670e8e1f99b5d48b6fffda9d3
|
|
| BLAKE2b-256 |
f2ad0c8fc0447b6380739744f490627933bc882427fbd27e381064874ae5f11a
|
File details
Details for the file invoice_engine_nci-1.0.0-py3-none-any.whl.
File metadata
- Download URL: invoice_engine_nci-1.0.0-py3-none-any.whl
- Upload date:
- Size: 11.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6115dcf20656298b257a873405014829cbf6e7f79c1f7e71d80d0c3fcfc30af6
|
|
| MD5 |
feeb3d141093d36aae7a43efa25ad386
|
|
| BLAKE2b-256 |
9dc8b07a824feb4c65a1446fabe16e198dda10f08c43e0607e081520961cfc94
|