Fix bug with updating category -> group mapping after backend sync#23
Merged
Fix bug with updating category -> group mapping after backend sync#23
Conversation
…fresh categories Bug: Transfers would not be filtered correctly (intermittent issue). Root cause: DataManager.__init__() built category_to_group mapping once from potentially stale config.yaml. When fetch_all_data() fetched fresh categories from API and saved to config.yaml, the mapping was never updated, causing transfers to not map to "Transfers" group. Fix: After saving fresh categories to config.yaml, rebuild the category_to_group mapping so transfers are correctly identified and filtered. Also moved inline imports to top of file per CLAUDE.md guidelines. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Added 2 tests to prevent recurrence of intermittent transfer filtering bug: 1. test_category_mapping_refreshes_after_fetch: - Sets up stale config.yaml with incomplete categories - Initializes DataManager (loads stale mapping) - Calls fetch_all_data() (fetches fresh categories) - Verifies mapping is rebuilt with fresh data 2. test_categories_get_correct_group_in_dataframe: - Sets up config with wrong category-to-group mappings - Verifies DataFrame transactions get correct groups after refresh - Tests user-facing symptom (filtering relies on correct groups) These tests will fail if category mapping is not refreshed after fetching fresh categories from API. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Fixed type annotation for format_transaction_rows return type: - Amount field (index 4) returns Union[str, Text], not just str - Updated return type annotation to reflect this - Added type: ignore comments in tests with proper assertions All style checks now pass: - ruff format --check moneyflow/ tests/ - ruff check moneyflow/ tests/ - pyright moneyflow/ - pyright tests/ 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Removed unused variable initial_group_count. All style checks now pass: - ruff format --check moneyflow/ tests/ - ruff check moneyflow/ tests/ - pyright moneyflow/ - pyright tests/ 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I had encountered a sporadic bug where Transfers (including credit card payments) would not be hidden from view no matter what on some application loads. The issue was that the category->group mapping (e.g. Credit Card Payment -> Transfer) would not get updated after pulling and syncing the backend's actual categories.