Skip to content

Fetch and store actual backend / user categories in config.yaml#14

Merged
wesm merged 4 commits intomainfrom
default-category-configs
Oct 29, 2025
Merged

Fetch and store actual backend / user categories in config.yaml#14
wesm merged 4 commits intomainfrom
default-category-configs

Conversation

@wesm
Copy link
Owner

@wesm wesm commented Oct 29, 2025

This overhauls the category configuration to sync actual categories from the backend so that changes in Monarch or YNAB will be picked up on application load, and it isn't necessary to manually edit config.yaml. If you use Amazon or Demo mode, it will use the "built-in" (Monarch-aligned) categories just to have something that works out of the box.

wesm and others added 4 commits October 29, 2025 15:40
Simplify category system by fetching actual categories from Monarch/YNAB
APIs and storing them in config.yaml, eliminating the need for complex
category transformation logic.

New functions in categories.py:
- convert_api_categories_to_groups() - Convert API format to simple dict
- save_categories_to_config() - Save fetched categories to config.yaml
- Updated get_effective_category_groups() - Load from fetched_categories first

Changes to data_manager.py:
- fetch_all_data() now saves categories to config.yaml on every startup
  for Monarch and YNAB backends
- Demo and Amazon backends skip saving (use built-in defaults)

New category priority order:
1. Monarch/YNAB: Fetch from API → Save to config.yaml → Use on this and future runs
2. Amazon: Use config.yaml if exists (from previous Monarch/YNAB run), else defaults
3. Demo: Always use built-in defaults

Benefits:
- Categories always match the backend's actual structure
- No manual configuration needed
- Amazon mode inherits categories from user's finance platform
- Simpler, more maintainable code

The old merge/transform logic remains for backward compatibility with
existing tests but is no longer used in production code.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Completely rewrite categories.md to reflect the new simplified
category system that automatically fetches from backends.

Key changes:
- Remove complex manual customization instructions
- Explain automatic category fetching from Monarch/YNAB
- Document how categories flow to Amazon mode
- Simplify troubleshooting section
- Move manual customization to "Advanced" section (rarely needed)

The documentation now accurately reflects that:
- Monarch/YNAB users don't need to configure categories
- Categories are automatically synced on every startup
- Amazon mode inherits categories from finance platform
- Demo mode uses built-in defaults

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Add CLI command to audit transaction categories against config.yaml
to identify data quality issues and category mismatches.

Features:
- Compares categories in cached transactions vs config.yaml
- Reports categories in data but not in config (unknown)
- Reports categories in config but not in data (unused)
- Shows transaction counts for each unknown category
- Provides actionable recommendations

Usage:
  moneyflow categories audit

Output includes:
- Summary statistics (total transactions, unique categories)
- List of unknown categories with transaction counts
- List of unused categories (first 10)
- Recommendations for fixing mismatches

Requires --cache flag to be used at least once to have data to audit.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Fix 3 test failures caused by new fetched_categories behavior:

Test fixes:
- test_categories.py: Update test to use fetched_categories format
  instead of old merge behavior
- conftest.py: Isolate tests with tmp_path config_dir to avoid
  using ~/.moneyflow/config.yaml during tests
- mock_backend.py: Fix group name from "Transportation" to
  "Auto & Transport" to match built-in defaults
- test_amazon_orders_importer.py: Use isolated config directory

Code style:
- Run ruff format on categories.py, data_manager.py, cli.py
- Fix f-string linter warnings in cli.py (removed unnecessary f-strings)

All 895 tests now pass ✅
All ruff checks pass ✅

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@cloudflare-workers-and-pages
Copy link

Deploying moneyflow with  Cloudflare Pages  Cloudflare Pages

Latest commit: 1d7b4e0
Status: ✅  Deploy successful!
Preview URL: https://ada413e1.moneyflow-6wi.pages.dev
Branch Preview URL: https://default-category-configs.moneyflow-6wi.pages.dev

View logs

@wesm wesm merged commit a7baa4f into main Oct 29, 2025
6 checks passed
@wesm wesm deleted the default-category-configs branch October 29, 2025 23:04
@wesm
Copy link
Owner Author

wesm commented Oct 29, 2025

@blackary if you have a chance to sanity check whether this works properly for YNAB, I would appreciate it!

@blackary
Copy link
Contributor

Yup, it works for me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants