-
Notifications
You must be signed in to change notification settings - Fork 0
Expense Tracking
Status: β Complete and Ready for Production Use Date Implemented: December 14, 2025
TrueHour's expense tracking system allows you to record aviation expenses and link them to budget cards. This enables you to answer questions like "What did I spend this month?" and "Am I on track with my budget?"
- Navigate to Section 3: Expense Tracking
- Click "Add Expense"
- Fill out the form:
- Category: Fuel, Instructor, Rental, Insurance, etc.
- Amount: Dollar amount
- Date: When the expense occurred
- Description: Optional details
- Vendor: Optional (e.g., "Blue Sky Flight Club")
- Click "Save Expense"
- Find your expense in the list
- Click the π (link) icon
- Select a budget card from the dropdown
- Enter amount to link (defaults to full expense amount)
- Click "Link to Budget Card"
The budget card's Actual amount updates immediately!
Navigate to Section 4: Budget Tracking to see:
- Budgeted: Your planned amount
- Actual: Total of linked expenses
- Remaining: What's left
- Progress bar: Visual % used
- β Add, edit, delete expenses
- β 9 expense categories (Fuel, Instructor, Rental, Insurance, Maintenance, Subscription, Membership, Supplies, Other)
- β Recurring expense support (monthly, quarterly, annual)
- β Tax deductible flag
- β Vendor tracking
- β Subcategory support
- β Link one expense to multiple budget cards (expense splitting)
- β Visual linking modal showing existing links
- β Remaining unlinked amount tracking
- β Prevents over-linking (can't exceed expense amount)
- β Real-time budget updates
- β Group by month with totals
- β Color-coded category badges
- β Filter by month
- β Filter by category
- β Summary statistics (count, total, average)
- β Responsive design
Track Rental + Instructor:
1. Add expense: "Rental N12345" - $225 (1.5 hours @ $150/hr)
2. Link to "Training" budget card
3. Add expense: "CFI lesson" - $90 (1.5 hours @ $60/hr)
4. Link to "Training" budget card
Your Training budget card now shows $315 actual spending.
Track Club Membership:
1. Add expense: "Blue Sky Flight Club" - $250
2. Check "Recurring" β Select "Monthly"
3. Link to "Administrative" budget card
Flight with Mixed Purpose:
1. Add expense: "Family flight + training" - $300
2. Link $200 to "Training" budget
3. Link $100 to "Family" budget
Both budgets update proportionally.
GET /api/expenses # List all expenses
GET /api/expenses/{id} # Get single expense
POST /api/expenses # Create expense
PUT /api/expenses/{id} # Update expense
DELETE /api/expenses/{id} # Delete expense
GET /api/expenses/summary # Get expense summaryPOST /api/expense-budget-links # Create link
GET /api/expense-budget-links/expense/{id} # Get links for expense
GET /api/expense-budget-links/budget-card/{id} # Get expenses for budget
DELETE /api/expense-budget-links/{id} # Remove linkSee API Documentation for full details.
id SERIAL PRIMARY KEY
aircraft_id INT (nullable, FK to aircraft)
category TEXT NOT NULL
subcategory TEXT
description TEXT
amount DECIMAL(10,2) NOT NULL
date DATE NOT NULL
is_recurring BOOLEAN DEFAULT FALSE
recurrence_interval TEXT (monthly, quarterly, annual)
recurrence_end_date DATE
vendor TEXT
is_tax_deductible BOOLEAN DEFAULT FALSE
tax_category TEXT
created_at TIMESTAMP
updated_at TIMESTAMPid SERIAL PRIMARY KEY
expense_id INT NOT NULL (FK to expenses)
budget_card_id INT NOT NULL (FK to budget_cards)
amount DECIMAL(10,2) NOT NULL
created_at TIMESTAMP
UNIQUE (expense_id, budget_card_id)User fills form β ExpenseManager.saveExpense()
β
POST /api/expenses
β
postgres_db.create_expense()
β
INSERT INTO expenses
β
Returns created expense
β
Reload expense list
β
Trigger auto-save
User clicks π β ExpenseManager.linkToBudget()
β
GET /api/expense-budget-links/expense/{id}
β
Show modal with budget card selector
β
POST /api/expense-budget-links
β
Validates: expense exists, budget exists, amount β€ expense amount
β
INSERT INTO expense_budget_links
β
Budget card query recalculates actual_amount:
SELECT bc.*, COALESCE(SUM(ebl.amount), 0) as actual_amount
FROM budget_cards bc
LEFT JOIN expense_budget_links ebl ON bc.id = ebl.budget_card_id
β
Reload budget cards (actual_amount updated)
The expense UI is implemented as React components in
frontend-react/src/features/expenses/:
- ExpensesView.tsx - Main expense list with filtering
- CreateExpenseModal.tsx - Create new expenses
- EditExpenseModal.tsx - Edit existing expenses
- ExpensesList.tsx - Expense table with sorting and grouping
Budget card linking is handled via the budget card detail views in
frontend-react/src/features/budget/.
- Check month filter (might be filtering it out)
- Check category filter
- Try "All Months" + "All Categories"
- Make sure you linked the expense (click π)
- Creating an expense doesn't auto-link it
- Must explicitly select budget card(s)
- Create a budget card first
- Ensure budget card status is "active"
- Total linked amounts can't exceed expense amount
- Check existing links first
- Remove links if needed
- Month-over-month comparison charts
- Spending trends visualization
- Export to CSV for tax purposes
- Category breakdown pie charts
- Link budget cards to certification goals
- Show hours progress vs budget burn rate
- Calculate cost per hour
- Answer: "Can I afford to finish my rating?"
-
backend/app/routers/expenses.py- Expense CRUD endpoints -
backend/app/routers/expense_budget_links.py- Budget linking endpoints -
backend/app/routers/budget_cards.py- Budget card endpoints
-
frontend-react/src/features/expenses/- Expense UI components -
frontend-react/src/features/budget/- Budget card UI components -
frontend-react/src/store/expenseStore.ts- Zustand state management - Budget cards query already calculates actual_amount
- Budget cards use LEFT JOIN to calculate actual_amount in SQL
- No N+1 queries
- Efficient single-query loading
- Indexes on expense_date and category for fast filtering
- Foreign key constraints ensure expense and budget exist before linking
- Unique constraint on (expense_id, budget_card_id) prevents duplicates
- Cascade delete: removing expense removes all its links automatically
- Budget Cards - Budget tracking system
- API Documentation - Full API reference
- Database Design - Schema details
- Architecture Overview - System architecture
π View on GitHub | π³ Docker Hub
π Report Issue | π¬ Discussions
License: MIT License | Copyright (c) 2024-2025 FliteAxis
π Getting Started
π¦ Deployment
π§ Development
π Security
- Security Setup Guide
- Security CI/CD Pipeline
- Code Quality & Linting
- SBOM Management
- Vulnerability Scanning
π Dependencies
π³ Docker
π Reference
π Links