| name | expense-report-generator |
| description | Generate formatted expense reports from receipt data or CSV. Create professional PDF reports with categorization, totals, and approval workflows. |
Expense Report Generator
Create professional expense reports from receipt data with automatic categorization and totals.
Features
- Multiple Input Formats: CSV, JSON, or manual entry
- Auto-Categorization: Classify expenses by type
- Receipt Tracking: Link receipts to expenses
- Approval Workflow: Status tracking and approver info
- Policy Compliance: Flag out-of-policy expenses
- PDF Export: Professional formatted reports
- Reimbursement Calculation: Track paid/unpaid amounts
Quick Start
from expense_report import ExpenseReportGenerator
report = ExpenseReportGenerator()
report.set_employee("John Doe", "EMP001", "Engineering")
report.set_period("2024-01-01", "2024-01-31")
report.add_expense(
date="2024-01-15",
description="Client dinner",
category="Meals",
amount=125.50,
receipt="receipt_001.jpg"
)
report.add_expense(
date="2024-01-18",
description="Uber to airport",
category="Transportation",
amount=45.00
)
report.generate_pdf("expense_report.pdf")
CLI Usage
python expense_report.py --input expenses.csv --employee "John Doe" --output report.pdf
python expense_report.py --input data.csv --start 2024-01-01 --end 2024-01-31 -o report.pdf
python expense_report.py --input data.csv --employee "Jane Smith" --dept Sales \
--approver "Bob Manager" -o report.pdf
python expense_report.py --input data.csv --policy policy.json -o report.pdf
Input Format
CSV Format
date,description,category,amount,receipt,notes
2024-01-15,Client dinner at Restaurant,Meals,125.50,receipt_001.jpg,Met with ABC Corp
2024-01-16,Uber to client site,Transportation,32.00,,
2024-01-17,Office supplies,Supplies,45.99,receipt_002.jpg,
2024-01-18,Flight to NYC,Travel,450.00,flight_confirm.pdf,Project kickoff
JSON Format
{
"employee": "John Doe",
"employee_id": "EMP001",
"department": "Engineering",
"period": {"start": "2024-01-01", "end": "2024-01-31"},
"expenses": [
{
"date": "2024-01-15",
"description": "Client dinner",
"category": "Meals",
"amount": 125.50,
"receipt": "receipt_001.jpg"
}
]
}
Policy Configuration
{
"limits": {
"Meals": 75,
"Transportation": 100,
"Lodging": 250,
"Supplies": 200
},
"requires_receipt": 25,
"requires_approval": 500,
"prohibited": ["Alcohol", "Personal items"]
}
API Reference
ExpenseReportGenerator Class
class ExpenseReportGenerator:
def __init__(self)
def set_employee(self, name: str, employee_id: str = None,
department: str = None) -> 'ExpenseReportGenerator'
def set_period(self, start: str, end: str) -> 'ExpenseReportGenerator'
def set_approver(self, name: str, title: str = None) -> 'ExpenseReportGenerator'
def set_project(self, project_name: str, project_code: str = None) -> 'ExpenseReportGenerator'
def add_expense(self, date: str, description: str, category: str,
amount: float, receipt: str = None, notes: str = None,
reimbursable: bool = True) -> 'ExpenseReportGenerator'
def () ->
() ->
() ->
() -> []
() ->
() -> [, ]
() -> [, ]
() ->
() ->
() ->
() ->
() ->
Expense Categories
Standard categories:
- Meals: Business meals and entertainment
- Transportation: Taxi, rideshare, rental car, parking
- Travel: Flights, trains, hotels
- Lodging: Hotel, accommodation
- Supplies: Office supplies, equipment
- Communication: Phone, internet
- Professional: Conferences, training, memberships
- Other: Miscellaneous expenses
Report Summary
summary = report.get_summary()
Policy Compliance
report.set_policy({
"limits": {
"Meals": 75,
"Daily_meals": 100
},
"requires_receipt": 25,
"requires_approval": 500
})
violations = report.check_compliance()
Generated Report Contents
The PDF report includes:
-
Header
- Company logo (optional)
- Report title and date range
- Employee information
-
Summary Section
- Total amount
- Category breakdown
- Reimbursement status
-
Expense Details Table
- Date, description, category
- Amount, receipt status
- Notes
-
Category Charts
- Pie chart of spending by category
- Daily spending bar chart
-
Compliance Notes
- Policy violations (if any)
- Missing receipts
-
Approval Section
- Employee signature line
- Approver signature line
- Date fields
Example Workflows
Monthly Employee Report
report = ExpenseReportGenerator()
report.set_employee("Sarah Johnson", "EMP042", "Marketing")
report.set_period("2024-02-01", "2024-02-29")
report.set_approver("Mike Director", "VP Marketing")
report.load_csv("february_expenses.csv")
violations = report.check_compliance()
if violations:
print(f"Warning: {len(violations)} policy violations")
report.generate_pdf("sarah_feb_expenses.pdf")
print(f"Total: ${report.get_total():,.2f}")
Project Expense Tracking
report = ExpenseReportGenerator()
report.set_employee("Project Team")
report.set_project("Website Redesign", "PRJ-2024-001")
report.set_period("2024-01-01", "2024-03-31")
report.add_expense("2024-01-15", "Design software license", "Software", 299.00)
report.add_expense("2024-02-01", "User testing incentives", "Research", 500.00)
report.add_expense("2024-02-20", "Stock photos", "Creative", 150.00)
summary = report.by_category()
print("Project Expenses by Category:")
for cat, amount in summary.items():
print(f" {cat}: ${amount:,.2f}")
Dependencies
- pandas>=2.0.0
- reportlab>=4.0.0
- matplotlib>=3.7.0