Refactor transaction extraction and clean up regex logic - #24
Conversation
- Update `pdfparser/utils.py` to fix a bug where non-standard (e.g., 9-digit) user IDs caused transaction amount extraction to fail. The fallback logic now correctly proceeds to parse debit, credit, and balance fields. - Remove dead code in `pdfparser/pymupdf_parser.py` that checked for date patterns in account numbers using an impossible regex match. - Add regression test for 9-digit user ID extraction in `tests/test_utils.py`. Co-authored-by: rager306 <248269686+rager306@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
WalkthroughThis change simplifies account number extraction in PDF parsing by removing a date-pattern guard, and refactors transaction extraction logic to more explicitly handle user ID detection and streamline credit/balance field parsing. A regression test validates the 9-digit user ID scenario. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Tip 🧪 Unit Test Generation v2 is now available!We have significantly improved our unit test generation capabilities. To enable: Add this to your reviews:
finishing_touches:
unit_tests:
enabled: trueTry it out by using the Have feedback? Share your thoughts on our Discord thread! Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This PR addresses issues found during code review.
extract_transactionsfunction had a flaw where if a line was assumed to be a User ID (fallback) but didn't match the strict User ID regex or Amount regex, the parser would stop extracting amounts for that transaction. This caused transactions with non-standard User IDs (e.g. 9 digits) to have empty amounts. The fix unifies the amount extraction logic to run in all cases.re.matchfor hyphens on a digits-only string).test_extract_transactions_with_9_digit_user_idtotests/test_utils.pyto ensure the fix works and prevents regression.PR created automatically by Jules for task 3380125266275653541 started by @rager306
Summary by CodeRabbit
Bug Fixes
Tests
✏️ Tip: You can customize this high-level summary in your review settings.