mirror of
https://github.com/DRYTRIX/TimeTracker.git
synced 2026-01-06 11:40:52 -06:00
- Clients: add model, routes, and templates
- app/models/client.py
- app/routes/clients.py
- templates/clients/{create,edit,list,view}.html
- docs/CLIENT_MANAGEMENT_README.md
- Database: add enhanced init/verify scripts, migrations, and docs
- docker/{init-database-enhanced.py,start-enhanced.py,verify-database.py}
- docs/ENHANCED_DATABASE_STARTUP.md
- migrations/{add_analytics_column.sql,add_analytics_setting.py,migrate_to_client_model.py}
- Scripts: add version manager and docker network test helpers
- scripts/version-manager.{bat,ps1,py,sh}
- scripts/test-docker-network.{bat,sh}
- docs/VERSION_MANAGEMENT.md
- UI: tweak base stylesheet
- app/static/base.css
- Tests: add client system test
- test_client_system.py
6.3 KiB
6.3 KiB
Client Management System
Overview
The TimeTracker application now includes a comprehensive client management system that allows administrators to:
- Create and manage client organizations
- Set default hourly rates per client
- Automatically populate project rates when creating projects
- Track client statistics and project relationships
- Maintain client contact information
Features
Client Management
- Client Creation: Create new clients with detailed information
- Client Editing: Update client details, rates, and contact information
- Client Archiving: Archive inactive clients while preserving data
- Client Deletion: Remove clients (only when no projects exist)
Rate Management
- Default Hourly Rates: Set standard rates per client
- Automatic Rate Population: Rates automatically fill when creating projects
- Project-Level Override: Individual projects can still have custom rates
Project Integration
- Client Selection: Dropdown selection instead of manual typing
- Error Prevention: Eliminates typos and duplicate client names
- Relationship Tracking: Clear view of all projects per client
Database Schema
Clients Table
CREATE TABLE clients (
id INTEGER PRIMARY KEY,
name VARCHAR(200) NOT NULL UNIQUE,
description TEXT,
contact_person VARCHAR(200),
email VARCHAR(200),
phone VARCHAR(50),
address TEXT,
default_hourly_rate NUMERIC(9, 2),
status VARCHAR(20) DEFAULT 'active',
created_at DATETIME NOT NULL,
updated_at DATETIME NOT NULL
);
Updated Projects Table
CREATE TABLE projects (
id INTEGER PRIMARY KEY,
name VARCHAR(200) NOT NULL,
client_id INTEGER NOT NULL,
description TEXT,
billable BOOLEAN DEFAULT TRUE,
hourly_rate NUMERIC(9, 2),
billing_ref VARCHAR(100),
status VARCHAR(20) DEFAULT 'active',
created_at DATETIME NOT NULL,
updated_at DATETIME NOT NULL,
FOREIGN KEY (client_id) REFERENCES clients (id)
);
Migration
From Old System
The old system stored client names as strings in the projects.client field. The migration script will:
- Create the new
clientstable - Extract unique client names from existing projects
- Create
Clientrecords for each unique client - Add
client_idcolumn to projects table - Update project records to reference client IDs
- Remove the old
clientcolumn
Running Migration
cd migrations
python migrate_to_client_model.py
Usage
Creating a New Client
- Navigate to Clients → New Client
- Fill in client information:
- Client Name (required)
- Default Hourly Rate (optional)
- Description (optional)
- Contact Person (optional)
- Email (optional)
- Phone (optional)
- Address (optional)
- Click Create Client
Creating a Project with Client
- Navigate to Projects → Create Project
- Select a client from the dropdown
- The hourly rate will automatically populate if the client has a default rate
- You can still modify the rate per project if needed
Managing Clients
- View Client: See client details and associated projects
- Edit Client: Update client information and rates
- Archive Client: Mark client as inactive
- Delete Client: Remove client (only if no projects exist)
API Endpoints
Client Management
GET /clients- List all clientsPOST /clients/create- Create new clientGET /clients/<id>- View client detailsPOST /clients/<id>/edit- Edit clientPOST /clients/<id>/archive- Archive clientPOST /clients/<id>/activate- Activate clientPOST /clients/<id>/delete- Delete client
API for Dropdowns
GET /api/clients- Get active clients for dropdowns (JSON)
Benefits
Error Prevention
- No More Typos: Dropdown selection eliminates manual typing errors
- Consistent Naming: Standardized client names across the system
- Duplicate Prevention: System prevents duplicate client entries
Efficiency
- Automatic Rate Population: Saves time when creating projects
- Quick Client Selection: Faster project creation process
- Centralized Management: All client information in one place
Better Organization
- Client Overview: See all projects and statistics per client
- Contact Management: Keep client contact information organized
- Rate Tracking: Monitor and adjust client rates easily
Security
Access Control
- Admin Only: Client creation, editing, and deletion restricted to administrators
- View Access: All authenticated users can view client information
- Project Access: Users can see client information through projects
Data Integrity
- Foreign Key Constraints: Ensures data consistency
- Cascade Protection: Prevents client deletion when projects exist
- Audit Trail: Tracks creation and modification timestamps
Future Enhancements
Potential Features
- Client Categories: Group clients by industry or type
- Rate History: Track rate changes over time
- Client Notes: Add internal notes about clients
- Bulk Operations: Import/export client data
- Client Dashboard: Dedicated analytics per client
Integration Opportunities
- Invoice System: Enhanced client billing
- Reporting: Client-specific time and cost reports
- Communication: Email integration for client updates
Troubleshooting
Common Issues
Migration Errors
- Ensure database backup before running migration
- Check database permissions
- Verify all required tables exist
Client Not Found
- Check if client is archived
- Verify client exists in database
- Ensure proper foreign key relationships
Rate Not Populating
- Verify client has default hourly rate set
- Check JavaScript console for errors
- Ensure client is active
Support
For issues or questions about the client management system, please:
- Check the application logs
- Verify database schema
- Test with a simple client creation
- Contact system administrator
Conclusion
The new client management system provides a robust foundation for managing client relationships and project billing. It eliminates common errors, improves efficiency, and provides better organization of client information. The system is designed to be scalable and can accommodate future enhancements as needed.