Skip to content

Add Category Feature#6

Merged
7174Andy merged 10 commits intomainfrom
andrew/add-category-feature
Nov 20, 2025
Merged

Add Category Feature#6
7174Andy merged 10 commits intomainfrom
andrew/add-category-feature

Conversation

@7174Andy
Copy link
Copy Markdown
Owner

@7174Andy 7174Andy commented Nov 19, 2025

This pull request introduces merchant normalization and categorization to the expense tracker, allowing for more accurate and automated assignment of categories to transactions based on merchant descriptions. It adds a new MerchantCategoryRepository for managing merchant-category mappings in the database, implements normalization and fuzzy matching logic for merchant names, and integrates these features throughout the application, including the transaction editing and bank statement upload workflows. Comprehensive unit tests are also added to ensure correctness of the new logic.

Merchant categorization and normalization:

  • Added MerchantCategoryRepository with methods to set, get, and list merchant-category mappings, and database schema initialization (expense_tracker/core/repository.py).
  • Introduced merchant normalization and categorization utilities, including normalization of merchant descriptions, categorization logic with fuzzy matching (using rapidfuzz), and helper functions (expense_tracker/utils/merchant.py).
  • Integrated merchant normalization and category suggestion into the expense editing dialog, so editing a transaction can update merchant-category mappings (expense_tracker/gui/dialogs/edit_expense.py) [1] [2] [3].
  • Automatically categorizes transactions during bank statement upload using the new merchant categorization logic (expense_tracker/gui/dialogs/upload.py) [1] [2].

Application and GUI integration:

  • Updated application entry point and main window to use both transaction and merchant repositories, and passed these to dialogs as needed (expense_tracker/app.py, expense_tracker/gui/main_window.py) [1] [2] [3] [4] [5] [6] [7].

Testing and dependencies:

  • Added comprehensive unit tests for merchant normalization, categorization, and fuzzy lookup logic (tests/utils/test_merchat.py).
  • Added unit tests for MerchantCategoryRepository (tests/core/test_repository.py).
  • Added rapidfuzz as a dependency for fuzzy matching (pyproject.toml).

Data model updates:

  • Added new MerchantCategory dataclass to represent merchant-category pairs (expense_tracker/core/model.py).

These changes together enable smarter, more automated transaction categorization and lay the groundwork for future improvements in merchant management and analytics.

@7174Andy 7174Andy marked this pull request as ready for review November 20, 2025 00:00
@7174Andy 7174Andy requested a review from Copilot November 20, 2025 00:02
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request introduces merchant normalization and automated categorization functionality to the expense tracker, enabling smarter transaction categorization based on merchant descriptions with fuzzy matching support.

  • Adds MerchantCategoryRepository for persistent storage of merchant-to-category mappings
  • Implements merchant name normalization and fuzzy matching using rapidfuzz library
  • Integrates automatic categorization into transaction editing and bank statement upload workflows

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 16 comments.

Show a summary per file
File Description
tests/utils/test_merchat.py Comprehensive unit tests for merchant normalization, categorization, and fuzzy lookup functionality
tests/core/test_repository.py Unit tests for MerchantCategoryRepository CRUD operations
pyproject.toml Adds rapidfuzz dependency for fuzzy string matching
expense_tracker/utils/merchant.py New utility module with merchant normalization, categorization logic, and fuzzy matching
expense_tracker/gui/main_window.py Updated to pass both transaction and merchant repositories to dialogs
expense_tracker/gui/dialogs/upload.py Integrates automatic merchant categorization during bank statement uploads
expense_tracker/gui/dialogs/edit_expense.py Adds merchant-category mapping updates when editing transactions
expense_tracker/core/repository.py Implements MerchantCategoryRepository with SQLite storage for merchant-category mappings
expense_tracker/core/model.py Adds MerchantCategory dataclass for merchant-category pairs
expense_tracker/app.py Initializes merchant repository and passes to main window

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread expense_tracker/gui/dialogs/edit_expense.py Outdated
Comment thread expense_tracker/utils/merchant.py Outdated
Comment thread expense_tracker/utils/merchant.py
Comment thread expense_tracker/utils/merchant.py
Comment thread tests/utils/test_merchant.py
Comment thread expense_tracker/core/repository.py Outdated
Comment thread expense_tracker/gui/dialogs/edit_expense.py Outdated
Comment thread expense_tracker/utils/merchant.py Outdated
Comment thread tests/utils/test_merchant.py
Comment thread expense_tracker/app.py Outdated
@7174Andy 7174Andy merged commit 34d5643 into main Nov 20, 2025
3 checks passed
@7174Andy 7174Andy deleted the andrew/add-category-feature branch November 20, 2025 01:06
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