Skip to content

Ensure that Amazon mode uses config.yaml categories, does not overwrite. Remove unneeded "legacy" categories.yaml handling#22

Merged
wesm merged 6 commits intomainfrom
fix-amazon-mode-categories
Oct 30, 2025
Merged

Ensure that Amazon mode uses config.yaml categories, does not overwrite. Remove unneeded "legacy" categories.yaml handling#22
wesm merged 6 commits intomainfrom
fix-amazon-mode-categories

Conversation

@wesm
Copy link
Owner

@wesm wesm commented Oct 30, 2025

I ran into some minor issues when loading up Amazon mode that arose from recent changes. This normalizes behavior and makes sure that if you have synced Monarch or YNAB categories to config.yaml, that these will be used for categorization in Amazon mode, rather than the default/built-in categories which may be more limited.

wesm and others added 6 commits October 30, 2025 11:30
Amazon mode now uses categories from config.yaml (fetched from Monarch/YNAB)
when available, instead of always using built-in defaults.

Changes:
- AmazonBackend.__init__() accepts config_dir parameter
- AmazonBackend.get_transaction_categories() uses get_effective_category_groups()
- AmazonBackend.update_transaction() uses get_effective_category_groups()
- CLI passes --config-dir to launch_amazon_mode()
- launch_amazon_mode() passes config_dir to AmazonBackend

Fixed misleading comments:
- categories.py: Clarified NOT a merge (one or the other)
- amazon.py: Clarified priority order (config.yaml > defaults)
- cli.py: Fixed categories_dump docstring

This allows Amazon mode to use the same category structure as your
primary backend (Monarch/YNAB) when config.yaml exists.

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

Co-Authored-By: Claude <noreply@anthropic.com>
… settings

Problem: Amazon mode was using built-in defaults instead of categories
from config.yaml. Also, custom category settings in categories.yaml
were not being migrated to config.yaml, causing them to be lost.

Changes:
1. Amazon mode now uses config.yaml categories:
   - AmazonBackend accepts config_dir parameter
   - Uses get_effective_category_groups() instead of DEFAULT_CATEGORY_GROUPS
   - CLI passes --config-dir to Amazon mode

2. Auto-migrate legacy categories.yaml to config.yaml:
   - save_categories_to_config() now checks for categories.yaml
   - Migrates custom settings (rename_groups, add_to_groups, etc.)
   - Only migrates if not already in config.yaml

3. Fixed misleading comments:
   - Clarified get_effective_category_groups() is NOT a merge
   - Updated docstrings to be explicit about priority (config.yaml > defaults)

This ensures Amazon mode uses the same category structure as your
primary backend, and custom category settings are preserved.

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

Co-Authored-By: Claude <noreply@anthropic.com>
…ation file

Removed all legacy categories.yaml support per user request:
- categories.yaml is deprecated, no migration path needed
- config.yaml is the only way to configure categories
- Amazon mode reads from config.yaml but never writes to it

Changes:
- categories.py: Removed legacy categories.yaml loading from load_custom_categories()
- categories.py: Removed legacy migration code from save_categories_to_config()
- cli.py: Removed legacy_path checks and references
- data_manager.py: Updated docstrings to remove categories.yaml mentions
- docs/config/advanced.md: Removed backward compatibility note
- tests: Removed test_loads_legacy_categories_yaml and test_prefers_config_yaml_over_legacy
- tests: All AmazonBackend tests now use temp_config_dir to isolate from user's real config

Amazon mode behavior:
- Reads categories from config.yaml (fetched_categories section)
- Falls back to built-in defaults if config.yaml doesn't exist
- NEVER writes to config.yaml

All 893 tests pass.

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

Co-Authored-By: Claude <noreply@anthropic.com>
…ackend behavior

Changes:
- Removed incorrect "custom_categories" section (doesn't exist in code)
- Added correct "categories" section format (rename_groups, add_to_groups, etc.)
- Clearly documented which backends write vs read config.yaml:
  - Monarch/YNAB: Write fetched_categories on every startup
  - Amazon/Demo: Only read, never write
- Clarified customizations are applied ON TOP of fetched_categories (merge)
- Removed confusing "(Legacy)" label from Advanced section

config.yaml is now the only configuration file. No categories.yaml support.

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

Co-Authored-By: Claude <noreply@anthropic.com>
Updated "Technical Details" to explicitly document:

Step 1: Base categories (one or the other, NOT merged)
  - fetched_categories from config.yaml
  - OR built-in defaults

Step 2: Custom overrides (merged on top of base)
  - categories section from config.yaml
  - Applied via rename_groups, add_to_groups, etc.

This clarifies the distinction between fetched_categories (replaced)
and custom overrides (overlaid).

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

Co-Authored-By: Claude <noreply@anthropic.com>
Added blank lines before lists to satisfy MD032 rule.

All markdown checks now 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: a95d667
Status: ✅  Deploy successful!
Preview URL: https://143c62e2.moneyflow-6wi.pages.dev
Branch Preview URL: https://fix-amazon-mode-categories.moneyflow-6wi.pages.dev

View logs

@wesm wesm merged commit 8e9fc6a into main Oct 30, 2025
7 checks passed
@wesm wesm deleted the fix-amazon-mode-categories branch October 30, 2025 18:29
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.

1 participant