Spaces:
Sleeping
Sleeping
Commit History
-
feat: task geofence validation against destination merchant, shared haversine utility
9c3b067 -
fix: get_today_tasks filters by assigned_to and date only, not merchant_id
dbd2244 -
fix: geo_location is top-level field on employee document, not under location_settings
41d9fa0 -
feat: add geofence validation for check-in and check-out
- Validate employee GPS coordinates against geo_location (lat/lng) configured in location_settings of scm_employees collection - Use precision_level (in km) as the allowed radius boundary - Implement Haversine formula for accurate distance calculation - Skip validation gracefully if geo_location is not configured - Add ERROR_OUTSIDE_GEOFENCE error constant - Validation runs after consent check, before duplicate check-in check - Logs distance, precision, and boundary status for observability5291403
-
docs: simplify Swagger documentation across all routers
- Simplify attendance router (check-in, check-out, summary) - Simplify tasks router (get tasks, update status) - Simplify expenses router (submit expense) - Remove verbose sections and keep only essential information - Improve documentation readability and concisenessdc5b19b -
docs: simplify Swagger documentation for trips endpoints
- Make descriptions more concise and readable - Remove verbose sections and redundant information - Keep only essential information for API users - Improve documentation clarityed049b3 -
feat: implement GET /trips endpoint with optimizations
- Add GET /trips endpoint to fetch user trips from last 7 days - Format duration as human-readable string (e.g., '8h 30m', '45m') - Optimize query with composite index on (user_id, merchant_id, created_at) - Remove redundant indexes to improve write performance - Extract helper functions for duration calculation and formatting - Fix attendance location_id type from string to UUID - Add MS_PER_MINUTE constant for better code clarity - Use integer division for duration calculations80b4a42
-
refactor: remove redundant health endpoints from individual routers
- Remove health endpoints from attendance, tasks, location, geofences, trips, expenses, notifications routers - Keep only main /health endpoint at app level - Reduces API clutter and follows best practices - Single health check endpoint is sufficient for service monitoringbd66b67 -
fix: add missing Optional import in notifications schemas
c078403 -
feat: implement POST /notifications/register endpoint for push tokens
- Add POST /tracker/notifications/register endpoint with JWT authentication - Create scm_push_tokens table in PostgreSQL - Support iOS and Android platforms - Upsert logic: update existing token or insert new - Enable task alerts, attendance reminders, admin messages - Production-ready error handling and logging - Comprehensive OpenAPI documentation81fa08d
-
Implement Expenses API and optimize startup performance
Expenses API Features: - POST /tracker/expenses endpoint for expense submission - Expense types: Fuel, Food, Lodging, Miscellaneous - Receipt photo mandatory for all expenses - Default status: pending (requires admin approval) - Amount validation (positive, max 1M) - Currency validation (ISO 4217, 3-letter codes) - Timestamp validation (within 30 days) Database: - Added trans.scm_expenses table to migrations - 3 performance indexes (user_date, merchant_status, status) - 4 data integrity constraints (status, amount, type, currency) - NUMERIC(12,2) for precise amount storage Security: - JWT authentication required - Merchant ID validated from token - User ID validated from token - All expenses merchant-scoped Testing: - test_expenses_api.py with 5 comprehensive test cases - Tests success, no receipt, negative amount, no auth Performance Optimizations: - Reduced Docker workers from 4 to 1 (faster startup) - Added timeout-keep-alive 30 seconds - Optimized connection handling - No autom…1be45c0 -
Implement stop trip API with production-ready code
Features: - POST /tracker/trips/stop endpoint to end business trips - Trip ownership verification (merchant + user) - Trip status validation (must be active) - End location mandatory - Distance validation (0 to 1000km) - Stop time must be after start time - Trip becomes immutable after stopping (status = completed) - Duration calculated automatically (in minutes) Security: - JWT authentication required - Merchant ID validated from token - User ID validated from token - Trip ownership verified before stopping - Proper HTTP status codes (404, 403, 400, 401, 500) Response: - Returns trip ID, distance, and duration - Success message with trip details Testing: - Updated test_trips_api.py with stop trip tests - Tests success case and duplicate stop (400) - 7 total test cases now Documentation: - Updated TRIPS_QUICK_START.md with stop endpoint - Updated TRACKER_API_COMPLETE_SUMMARY.md - Added SQL queries for checking trips2fad98d -
Implement Trips API with JWT auth and automatic migrations
Features: - POST /tracker/trips/start endpoint for business trip tracking - One active trip per user enforcement - JWT authentication with merchant isolation - Comprehensive validation (coordinates, timestamps) - Production-ready error handling Database: - Added trans.scm_trips table to automatic migrations - 3 performance indexes (user_status, merchant_date, status) - 6 data integrity constraints - Automatic creation on startup Testing: - test_trips_api.py with 5 comprehensive test cases - Tests success, errors, validation, and authentication Documentation: - Removed redundant docs (GEOFENCES_README.md, LOCATION_TRACKING_README.md) - Updated TRACKER_API_COMPLETE_SUMMARY.md with trips info - Added TRIPS_QUICK_START.md for quick reference Code Quality: - Follows existing patterns (geofences, location) - Type hints throughout - Comprehensive docstrings - Structured logging - No diagnostics errors6c31d92 -
feat: implement geofences API with merchant-scoped security
- Created GET /tracker/geofences endpoint - Merchant isolation with JWT validation - Active/inactive status filtering - Haversine distance calculation for point-in-geofence checks - Database table with validation constraints - Indexes on merchant_id, active status, and location - Comprehensive security: users only see their own merchant's geofences - Migration script with test data (4 geofences) - Complete documentation and test suite - Production-ready error handling6bf0a90
-
fix: correct database connection import in location service
- Changed from app.core.database.get_db_connection to app.postgres module - Use get_postgres_connection() and release_postgres_connection() - Added proper connection cleanup in finally blocks - Fixes ImportError on server startup785a469 -
feat: implement location tracking API with TimescaleDB hypertable
- Created POST /tracker/tracking/points endpoint for batch location upload - Implemented TimescaleDB hypertable with 1-day partitioning - Added compression policy (7 days) and retention policy (90 days) - Created indexes on user_id, merchant_id, and recorded_at - Batch upload supports up to 1000 points per request - Comprehensive validation (timestamp order, ranges, coordinates) - JWT authentication required - Migration script with test data - Complete documentation and test suite - Performance: 10-100x faster time-range queries956cecd -
feat: implement task attachments API with MinIO storage integration
Implemented production-ready task attachments upload API with comprehensive features: API Endpoints: - POST /tracker/tasks/{task_id}/attachments - Upload photos and signatures Features: - MinIO S3-compatible object storage integration - File upload with validation (images only, max 10MB) - Support for photo and signature attachment types - JWT authentication and authorization - Employee and merchant validation - Automatic file organization by merchant/task - Public URL generation for uploaded files - Database tracking of all attachments MinIO Integration: - Created MinioStorageAdapter for async file operations - Automatic bucket creation and management - Direct file upload to MinIO - Public URL generation - Secure HTTPS connection Database: - Created trans.scm_task_attachments table - Foreign key to trans.scm_tasks with CASCADE delete - Indexes for fast lookups - Stores file metadata (URL, name, size, MIME type) Code Quality: - Clean separation of concerns (storage, service, route…e0b1eb1
-
feat: implement tasks API with GET today and PATCH status endpoints
Implemented production-ready tasks API with comprehensive features: API Endpoints: - GET /tracker/tasks/today - Fetch employee's tasks for today - PATCH /tracker/tasks/:id/status - Update task status with validation Features: - JWT authentication and authorization - Status transition validation (not_started, in_progress, completed) - Location tracking on every status update - Timestamp tracking (started_at, completed_at) - Employee and merchant authorization checks - Comprehensive error handling with appropriate HTTP codes Database: - Created trans.scm_tasks table with indexes - Migration script (migrate_tasks.py) - SQL script for manual setup (create_tasks_table.sql) Code Quality: - Clean separation of concerns (router, service, schemas) - Full type hints and validation - Comprehensive logging - Idempotent status updates - Production-ready error handling Testing: - Comprehensive test suite (test_tasks_api.py) - Tests all valid and invalid status transitions - Tests authorization …32eb084
-
feat: implement daily attendance summary API
- Add GET /attendance/daily endpoint with optional date query parameter - Add DailyAttendanceResponse schema with onDuty, checkInTime, checkOutTime, totalHours - Add get_daily_attendance service method to query and calculate attendance summary - Implement JWT authentication and comprehensive error handling - Return empty attendance instead of 404 when no record found - Calculate on-duty status and convert minutes to hoursa8ee704
-
refactor: Use server time for check-in/check-out instead of client timestamp
- Remove timestamp field from CheckInRequest and CheckOutRequest - Use datetime.now() on server to generate timestamp and work_date - Prevents timestamp manipulation from client side - More secure and consistent time tracking - Updated API documentation and examples0c2c78b -
feat: Implement check-out API with total working time calculation
- Add CheckOutRequest and CheckOutResponse schemas - Implement create_checkout service method with edge case handling - Add POST /attendance/check-out endpoint - Calculate total working minutes automatically - Handle edge cases: no check-in found, already checked out, GPS disabled - Validate check-out time is after check-in time - Update attendance record with check-out detailsca7fde4 -
Check in service
82fcb44
-
Add initial project structure with Dockerfile, environment configuration, and FastAPI setup
230f597