Skip to content

Commit f730c44

Browse files
wesmclaude
andcommitted
fix: Allow field-based sorting to persist in aggregate views
Fixed state.py sort validation that was resetting field sorts to AMOUNT: - cycle_grouping() now allows MERCHANT/CATEGORY/GROUP/ACCOUNT sorts - go_back() now allows field sorts when returning to aggregate views This was preventing the 's' key from cycling to field sorts because the view switching logic would immediately reset it back to AMOUNT. Now field sorting works correctly in all aggregate views. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent a6d9c8c commit f730c44

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

moneyflow/state.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,15 @@ def cycle_grouping(self) -> str:
270270
self.selected_account = None
271271

272272
# Reset sort to valid field for aggregate views if needed
273-
if self.sort_by not in [SortMode.COUNT, SortMode.AMOUNT]:
273+
# Now includes field-based sorting (MERCHANT, CATEGORY, GROUP, ACCOUNT)
274+
if self.sort_by not in [
275+
SortMode.COUNT,
276+
SortMode.AMOUNT,
277+
SortMode.MERCHANT,
278+
SortMode.CATEGORY,
279+
SortMode.GROUP,
280+
SortMode.ACCOUNT,
281+
]:
274282
self.sort_by = SortMode.AMOUNT
275283

276284
# Cycle through views
@@ -412,8 +420,15 @@ def go_back(self) -> tuple[bool, int]:
412420

413421
# Reset sort to valid field for aggregate views
414422
# (Detail views can have DATE, MERCHANT, CATEGORY, ACCOUNT, AMOUNT)
415-
# (Aggregate views only have COUNT, AMOUNT)
416-
if self.sort_by not in [SortMode.COUNT, SortMode.AMOUNT]:
423+
# (Aggregate views have COUNT, AMOUNT, and field-based sorting)
424+
if self.sort_by not in [
425+
SortMode.COUNT,
426+
SortMode.AMOUNT,
427+
SortMode.MERCHANT,
428+
SortMode.CATEGORY,
429+
SortMode.GROUP,
430+
SortMode.ACCOUNT,
431+
]:
417432
self.sort_by = SortMode.AMOUNT
418433
self.sort_direction = SortDirection.DESC
419434

0 commit comments

Comments
 (0)