All Stories
9-6-tuesday-settlement-cycle-supportReadyEpic 9.6
Story 9.6: Tuesday Settlement Cycle Support
Status: ready-for-dev
Tasks
- **Task 1: Settlement Periods Table Schema** (AC: AC-9.6-2)
- 1.1: Verify settlement_periods table exists with correct schema
- 1.2: Confirm unique constraint on (period_start, period_end)
- 1.3: Verify status check constraint for 'active', 'completed', 'archived'
- 1.4: Confirm indexes on status and settlement_due_date columns
- **Task 2: Settlement Period Calculation Logic** (AC: AC-9.6-1, AC-9.6-3)
- 2.1: Implement Sunday period_start calculation (PST timezone)
- 2.2: Calculate Saturday period_end (period_start + 6 days)
- 2.3: Calculate Tuesday settlement_due_date (period_start + 9 days)
- 2.4: Verify 7-day period span (Sunday 00:00 - Saturday 23:59 PST)
- **Task 3: Automated Settlement Service** (AC: AC-9.6-4)
- 3.1: Create automated_settlement_service.py with period creation logic
- 3.2: Implement Sunday 12:00 AM PST trigger for new periods
- 3.3: Mark previous period as 'completed' on new period creation
- 3.4: Handle atomic transitions (prevent duplicate active periods)
- **Task 4: Current Period API Endpoint** (AC: AC-9.6-5)
- 4.1: Create GET /api/v1/agent/settlements/current-period endpoint
- 4.2: Implement SettlementPeriod Pydantic model for response
- 4.3: Add JWT authentication requirement (get_current_agent)
- 4.4: Handle error cases (no active period, database errors)
- **Task 5: Integration Testing** (AC: All)
- 5.1: Test settlement period creation with correct date calculations
- 5.2: Verify Tuesday due date calculation for multiple weeks
- 5.3: Test automated period transitions (active → completed)
- 5.4: Verify API endpoint returns correct active period data
- **Task 6: Dashboard Integration** (AC: AC-9.6-5)
- 6.1: Integrate current period data into settlement dashboard
- 6.2: Display period dates and Tuesday due date to agents
- 6.3: Add period status indicator (active/completed/archived)
- 6.4: Verify mobile-responsive display of settlement period info
Progress
Tasks6/6
Acceptance Criteria0
Total Tasks6