Skip to content

Add duplicate transaction detection on PDF upload#17

Merged
7174Andy merged 3 commits into
mainfrom
feat/duplication-detection
Feb 14, 2026
Merged

Add duplicate transaction detection on PDF upload#17
7174Andy merged 3 commits into
mainfrom
feat/duplication-detection

Conversation

@7174Andy
Copy link
Copy Markdown
Owner

Summary

  • Add transaction_exists() method to TransactionRepository that checks for duplicates by matching on (date, amount, description)
  • Integrate duplicate detection into the PDF upload flow (UploadDialog) so that re-uploading the same bank statement silently skips already-imported transactions
  • Add 5 test cases covering the new repository method

How it works

When a user uploads a Bank of America PDF statement, each parsed transaction is checked against the database before insertion. If a transaction with the same date, amount, and description already exists, it is skipped via continue. This prevents duplicate entries when the same statement is uploaded multiple times.

API changes

TransactionRepository.transaction_exists(transaction: Transaction) -> bool (new)

Checks whether a transaction with matching date, amount, and description already exists in the database. Category is intentionally excluded from the check since it may be updated after initial import.

Design decisions

  • Match on (date, amount, description): These three fields uniquely identify a transaction from a bank statement. Category is excluded because it can change via merchant categorization after import.
  • Silent skip (no user feedback on skipped count): Keeps the upload flow simple. A future enhancement could report how many duplicates were skipped.
  • Per-row check vs. batch: Each transaction is checked individually before insert. For typical statement sizes (30-100 transactions), this is performant enough and keeps the logic straightforward.

Test plan

  • test_transaction_exists_returns_true_for_duplicate -- exact match returns True
  • test_transaction_exists_returns_false_when_not_found -- empty DB returns False
  • test_transaction_exists_different_date -- different date returns False
  • test_transaction_exists_different_amount -- different amount returns False
  • test_transaction_exists_different_description -- different description returns False
  • All 43 existing + new tests pass

🤖 Generated with Claude Code

@7174Andy 7174Andy merged commit 9c55d1e into main Feb 14, 2026
3 checks passed
@7174Andy 7174Andy deleted the feat/duplication-detection branch February 14, 2026 18:26
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