All Stories
9-1-cashier-balance-viewDoneEpic 9.1
Story 9.1: Cashier Balance View
Status: done
Tasks
- **Task 1: Create Cashier Endpoint** (AC: 1)
- 1.1 Create `cashier.py` router in `server/app/api/v1/endpoints/agents/`
- 1.2 Add JWT authentication dependency: `Depends(get_current_agent)`
- 1.3 Implement agent ownership verification
- 1.4 Add appropriate HTTP error responses (404, 403)
- 1.5 Register router in main application
- **Task 2: Balance Data Retrieval** (AC: 2, 3, 4)
- 2.1 Query users table for customer data (account_balance, pending_bets, credit_limit, account_type)
- 2.2 Implement available balance calculation logic
- 2.3 Handle Credit vs PostUp account type logic
- 2.4 Add Pydantic response model for type safety
- 2.5 Ensure Decimal precision for financial values
- **Task 3: Settlement History Integration** (AC: 5)
- 3.1 Query settlement_history table for last settlement
- 3.2 Order by final_settlement_date DESC, limit 1
- 3.3 Handle case when no previous settlements exist
- 3.4 Return amount_settled and final_settlement_date
- **Task 4: Response Model Creation**
- 4.1 Create CashierBalanceResponse Pydantic model
- 4.2 Include all required fields with proper types
- 4.3 Add field descriptions for API documentation
- 4.4 Validate response structure in OpenAPI docs
- **Task 5: Frontend Integration** (AC: 6)
- 5.1 Create TanStack Query hook: `useCashierBalance(customerId)`
- 5.2 Add balance display to cashier interface
- 5.3 Implement mobile-responsive design
- 5.4 Add loading and error states
- 5.5 Format currency values with FinancialDisplay component
- **Task 6: Testing**
- 6.1 Unit tests for balance calculation logic
- 6.2 Integration tests for endpoint with mock data
- 6.3 Test agent ownership verification
- 6.4 Test Credit vs PostUp account calculations
- 6.5 Test settlement history retrieval (with and without data)
Progress
Tasks6/6
Acceptance Criteria0
Total Tasks6