All checks were successful
Docker Build & Deploy / Build Docker Image (push) Successful in 27s
Docker Build & Deploy / Deploy to Production (push) Successful in 9s
Docker Build & Deploy / Cleanup Dangling Images (push) Successful in 2s
Docker Build & Deploy / WeChat Notification (push) Successful in 2s
2.6 KiB
2.6 KiB
Decisions - Statistics Year Selection Enhancement
[2026-01-28] Architecture Decisions
Frontend Implementation Strategy
1. Date Picker Mode Toggle
- Add a toggle switch in the date picker popup to switch between "按月" (month) and "按年" (year) modes
- When "按年" selected: use
columns-type="['year']" - When "按月" selected: use
columns-type="['year', 'month'](current behavior)
2. State Management
- Add
dateSelectionModeref:'month'|'year' - When year-only mode: set
currentMonth = 0to indicate full year - Keep
currentYearas integer (unchanged) - Update
selectedDatearray dynamically based on mode:- Year mode:
['YYYY'] - Month mode:
['YYYY', 'MM']
- Year mode:
3. Display Logic
- Nav bar title:
currentYear年whencurrentMonth === 0, elsecurrentYear年currentMonth月 - Chart titles: Update to reflect year or year-month scope
4. API Calls
- Pass
month: currentMonth.value || 0to all API calls - Backend will handle month=0 as year-only query
Backend Implementation Strategy
1. Repository Layer Change
File: Repository/TransactionRecordRepository.cs
Method: BuildQuery() lines 81-86
if (year.HasValue)
{
if (month.HasValue && month.Value > 0)
{
// Specific month
var dateStart = new DateTime(year.Value, month.Value, 1);
var dateEnd = dateStart.AddMonths(1);
query = query.Where(t => t.OccurredAt >= dateStart && t.OccurredAt < dateEnd);
}
else
{
// Entire year
var dateStart = new DateTime(year.Value, 1, 1);
var dateEnd = new DateTime(year.Value + 1, 1, 1);
query = query.Where(t => t.OccurredAt >= dateStart && t.OccurredAt < dateEnd);
}
}
2. Service Layer
- No changes needed - services already pass month parameter to repository
- Services will receive month=0 for year-only queries
3. API Controller
- No changes needed - already accepts year/month parameters
Testing Strategy
Backend Tests
- Test year-only query returns all transactions for that year
- Test month-specific query still works
- Test edge cases: year boundaries, leap years
Frontend Tests
- Test toggle switches picker mode correctly
- Test year selection updates state and fetches data
- Test display updates correctly for year vs year-month
User Experience Flow
- User clicks date picker in nav bar
- Popup opens with toggle: "按月 | 按年"
- User selects mode (default: 按月 for backward compatibility)
- User selects date(s) and confirms
- Statistics refresh with new scope
- Display updates to show scope (year or year-month)